* Migrated to hildon 2 check buttons and thumbable controls
[modest] / src / hildon2 / modest-maemo-security-options-view.c
index 36c0177..cebf7cc 100644 (file)
 #include "widgets/modest-ui-constants.h"
 #include "widgets/modest-validating-entry.h"
 #include "modest-serversecurity-picker.h"
-#include "widgets/modest-secureauth-combo-box.h"
-#ifdef MODEST_HAVE_HILDON0_WIDGETS
-#include <hildon-widgets/hildon-caption.h>
-#include <hildon-widgets/hildon-number-editor.h>
-#else
-#include <hildon/hildon-caption.h>
+#include "modest-secureauth-picker.h"
+#include "modest-maemo-utils.h"
 #include <hildon/hildon-number-editor.h>
-#endif /*MODEST_HAVE_HILDON0_WIDGETS*/
+#include <hildon/hildon-check-button.h>
 
 #define PORT_MIN 1
 #define PORT_MAX 65535
@@ -58,7 +54,7 @@ G_DEFINE_TYPE (ModestMaemoSecurityOptionsView,
 
 static void on_entry_changed (GtkEditable *editable, gpointer user_data);
 
-/* Tracks changes in the incoming security combo box */
+/* Tracks changes in the incoming security picker */
 static void
 on_security_changed (GtkWidget *widget, 
                     ModestMaemoSecurityOptionsView *self)
@@ -80,8 +76,8 @@ on_security_changed (GtkWidget *widget,
 
        if (MODEST_SECURITY_OPTIONS_VIEW (self)->type == MODEST_SECURITY_OPTIONS_INCOMING) {
                /* Activate and dim checkbutton if it's secure */
-               gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ppriv->auth_view), 
-                                             is_secure);
+               hildon_check_button_set_active (GTK_BUTTON (ppriv->auth_view), 
+                                               is_secure);
                gtk_widget_set_sensitive (ppriv->auth_view, !is_secure);
        } else {
 
@@ -103,7 +99,7 @@ on_auth_changed (GtkWidget *widget,
                 ModestMaemoSecurityOptionsView *self)
 {
        ModestSecurityOptionsViewPrivate* ppriv;
-       ModestSecureauthComboBox *combo;
+       ModestSecureauthPicker *picker;
        ModestProtocolRegistry *protocol_registry;
        ModestProtocolType auth_proto;
        gboolean secureauth_used;
@@ -111,9 +107,9 @@ on_auth_changed (GtkWidget *widget,
 
        ppriv = MODEST_SECURITY_OPTIONS_VIEW_GET_PRIVATE (self);
        protocol_registry = modest_runtime_get_protocol_registry ();
-       combo = MODEST_SECUREAUTH_COMBO_BOX (ppriv->auth_view);
+       picker = MODEST_SECUREAUTH_PICKER (ppriv->auth_view);
 
-       auth_proto = modest_secureauth_combo_box_get_active_secureauth (combo);
+       auth_proto = modest_secureauth_picker_get_active_secureauth (picker);
        secureauth_used = modest_protocol_registry_protocol_type_is_secure (protocol_registry, 
                                                                            auth_proto);
 
@@ -139,20 +135,22 @@ create_incoming_security (ModestSecurityOptionsView* self,
        ppriv = MODEST_SECURITY_OPTIONS_VIEW_GET_PRIVATE (self);
 
        /* Create widgets for incoming security */
-       ppriv->security_view = GTK_WIDGET (modest_serversecurity_picker_new ());
-       hildon_button_set_title (HILDON_BUTTON (ppriv->security_view), _("mcen_li_emailsetup_secure_connection"));
+       ppriv->security_view = GTK_WIDGET (modest_serversecurity_picker_new (MODEST_EDITABLE_SIZE,
+                                                                            MODEST_EDITABLE_ARRANGEMENT));
+       modest_maemo_utils_create_picker_layout (size_group, 
+                                                _("mcen_li_emailsetup_secure_connection"), 
+                                                ppriv->security_view);
 
        if (ppriv->full) {              
                ppriv->port_view = GTK_WIDGET (hildon_number_editor_new (PORT_MIN, PORT_MAX));
-               entry_caption = hildon_caption_new (size_group, _("mcen_fi_emailsetup_port"), 
-                                                   ppriv->port_view, NULL, 
-                                                   HILDON_CAPTION_OPTIONAL);
+               entry_caption = modest_maemo_utils_create_captioned (size_group, _("mcen_fi_emailsetup_port"), 
+                                                                    ppriv->port_view);
        }
 
-       ppriv->auth_view = gtk_check_button_new ();
-       check_caption = 
-               hildon_caption_new (size_group, _("mcen_li_emailsetup_secure_authentication"),
-                                   ppriv->auth_view, NULL, HILDON_CAPTION_OPTIONAL);
+       ppriv->auth_view = hildon_check_button_new (MODEST_EDITABLE_SIZE);
+       check_caption = modest_maemo_utils_create_captioned (size_group, 
+                                                            _("mcen_li_emailsetup_secure_authentication"),
+                                                            ppriv->auth_view);
 
        /* Track changes in UI */       
        g_signal_connect (G_OBJECT (ppriv->security_view), "value-changed",
@@ -186,7 +184,7 @@ on_entry_max (ModestValidatingEntry *self,
 }
 
 /*
- * TODO: call this whenever the auth combo changes. If we set it
+ * TODO: call this whenever the auth picker changes. If we set it
  * explicitely at the beggining to a value then there is no need to
  * call this handler directly at the beginning
  */
@@ -197,7 +195,7 @@ on_entry_changed (GtkEditable *editable,
        ModestSecurityOptionsView* self;
        ModestSecurityOptionsViewPrivate *ppriv;
        ModestProtocolType auth_proto;
-       ModestSecureauthComboBox *combo;
+       ModestSecureauthPicker *picker;
        gboolean is_secure, missing;
        ModestProtocolRegistry *protocol_registry;
 
@@ -206,8 +204,8 @@ on_entry_changed (GtkEditable *editable,
        protocol_registry = modest_runtime_get_protocol_registry ();
 
        /* Outgoing username is mandatory if outgoing auth is secure */
-       combo = MODEST_SECUREAUTH_COMBO_BOX (ppriv->auth_view);
-       auth_proto = modest_secureauth_combo_box_get_active_secureauth (combo);
+       picker = MODEST_SECUREAUTH_PICKER (ppriv->auth_view);
+       auth_proto = modest_secureauth_picker_get_active_secureauth (picker);
        is_secure = modest_protocol_registry_protocol_type_is_secure (protocol_registry, 
                                                                      auth_proto);
 
@@ -228,21 +226,24 @@ create_outgoing_security (ModestSecurityOptionsView* self,
                          GtkSizeGroup *size_group)
 {
        ModestSecurityOptionsViewPrivate *ppriv;
-       GtkWidget *auth_caption, *user_caption = NULL;
+       GtkWidget *user_caption = NULL;
        GtkWidget *pwd_caption = NULL, *port_caption = NULL;
 
        ppriv = MODEST_SECURITY_OPTIONS_VIEW_GET_PRIVATE (self);
        
        /* The secure connection widgets */
-       ppriv->security_view = GTK_WIDGET (modest_serversecurity_picker_new ());
+       ppriv->security_view = GTK_WIDGET (modest_serversecurity_picker_new (MODEST_EDITABLE_SIZE,
+                                                                            MODEST_EDITABLE_ARRANGEMENT));
        modest_serversecurity_picker_fill (MODEST_SERVERSECURITY_PICKER (ppriv->security_view), 
                                              MODEST_PROTOCOLS_TRANSPORT_SMTP);
-       hildon_button_set_title (HILDON_BUTTON (ppriv->security_view), _("mcen_li_emailsetup_secure_connection"));
+       modest_maemo_utils_create_picker_layout (size_group, _("mcen_li_emailsetup_secure_connection"), 
+                                                ppriv->security_view);
        
        /* The secure authentication widgets */
-       ppriv->auth_view = GTK_WIDGET (modest_secureauth_combo_box_new ());
-       auth_caption = hildon_caption_new (size_group, _("mcen_li_emailsetup_secure_authentication"),
-                                          ppriv->auth_view, NULL, HILDON_CAPTION_OPTIONAL);
+       ppriv->auth_view = GTK_WIDGET (modest_secureauth_picker_new (MODEST_EDITABLE_SIZE,
+                                                                    MODEST_EDITABLE_ARRANGEMENT));
+       modest_maemo_utils_create_picker_layout (size_group, _("mcen_li_emailsetup_secure_authentication"), 
+                                                ppriv->auth_view);
 
        if (ppriv->full) {
                gchar *user_label;
@@ -255,9 +256,8 @@ create_outgoing_security (ModestSecurityOptionsView* self,
                                                 HILDON_GTK_INPUT_MODE_FULL);
 
                user_label = g_strdup_printf("%s*", _("mail_fi_username"));
-               user_caption = hildon_caption_new (size_group, user_label, 
-                                                  ppriv->user_entry, NULL, 
-                                                  HILDON_CAPTION_MANDATORY);
+               user_caption = modest_maemo_utils_create_captioned (size_group, user_label, 
+                                                                   ppriv->user_entry);
                g_free (user_label);
        
                /* Prevent the use of some characters. Limit the max
@@ -277,21 +277,19 @@ create_outgoing_security (ModestSecurityOptionsView* self,
                                                 HILDON_GTK_INPUT_MODE_INVISIBLE);
                gtk_entry_set_visibility (GTK_ENTRY (ppriv->pwd_entry), FALSE);
 
-               pwd_caption = hildon_caption_new (size_group, _("mail_fi_password"), 
-                                                 ppriv->pwd_entry, NULL, 
-                                                 HILDON_CAPTION_OPTIONAL);
+               pwd_caption = modest_maemo_utils_create_captioned (size_group, _("mail_fi_password"), 
+                                                                  ppriv->pwd_entry);
 
                ppriv->port_view = GTK_WIDGET (hildon_number_editor_new (PORT_MIN, PORT_MAX));
-               port_caption = hildon_caption_new (size_group, _("mcen_fi_emailsetup_port"), 
-                                                   ppriv->port_view, NULL, 
-                                                   HILDON_CAPTION_OPTIONAL);
+               port_caption = modest_maemo_utils_create_captioned (size_group, _("mcen_fi_emailsetup_port"), 
+                                                                   ppriv->port_view);
        }
 
        /* Track changes in UI */       
        g_signal_connect (G_OBJECT (ppriv->security_view), "value-changed",
                          G_CALLBACK (on_security_changed), self);
        if (ppriv->full) {
-               g_signal_connect (G_OBJECT (ppriv->auth_view), "changed",
+               g_signal_connect (G_OBJECT (ppriv->auth_view), "value-changed",
                                  G_CALLBACK (on_auth_changed), self);
                g_signal_connect (G_OBJECT (ppriv->user_entry), "changed",
                                  G_CALLBACK (on_entry_changed), self);
@@ -301,13 +299,13 @@ create_outgoing_security (ModestSecurityOptionsView* self,
        modest_serversecurity_picker_set_active_serversecurity (
                MODEST_SERVERSECURITY_PICKER (ppriv->security_view), 
                MODEST_PROTOCOLS_CONNECTION_NONE);
-       modest_secureauth_combo_box_set_active_secureauth (
-          MODEST_SECUREAUTH_COMBO_BOX (ppriv->auth_view),
+       modest_secureauth_picker_set_active_secureauth (
+          MODEST_SECUREAUTH_PICKER (ppriv->auth_view),
           MODEST_PROTOCOLS_AUTH_NONE);
 
        /* Pack into container */
        if (ppriv->full) {
-               gtk_box_pack_start (GTK_BOX (self), auth_caption, FALSE, FALSE, MODEST_MARGIN_HALF);
+               gtk_box_pack_start (GTK_BOX (self), ppriv->auth_view, FALSE, FALSE, MODEST_MARGIN_HALF);
                gtk_box_pack_start (GTK_BOX (self), user_caption, FALSE, FALSE, MODEST_MARGIN_HALF);
                gtk_box_pack_start (GTK_BOX (self), pwd_caption, FALSE, FALSE, MODEST_MARGIN_HALF);
                gtk_box_pack_start (GTK_BOX (self), ppriv->security_view, FALSE, FALSE, MODEST_MARGIN_HALF);
@@ -315,7 +313,7 @@ create_outgoing_security (ModestSecurityOptionsView* self,
        } else {
                /* The order is different */
                gtk_box_pack_start (GTK_BOX (self), ppriv->security_view, FALSE, FALSE, MODEST_MARGIN_HALF);
-               gtk_box_pack_start (GTK_BOX (self), auth_caption, FALSE, FALSE, MODEST_MARGIN_HALF);
+               gtk_box_pack_start (GTK_BOX (self), ppriv->auth_view, FALSE, FALSE, MODEST_MARGIN_HALF);
        }
 
        /* Show widgets */
@@ -329,7 +327,6 @@ create_outgoing_security (ModestSecurityOptionsView* self,
        }
        gtk_widget_show (ppriv->security_view);
        gtk_widget_show (ppriv->auth_view);
-       gtk_widget_show (auth_caption);
 }
 
 GtkWidget *