* Removed the setting for putting all the hildon buttons as
[modest] / src / hildon2 / modest-maemo-security-options-view.c
index 578fd01..41e55d9 100644 (file)
 #include "widgets/modest-validating-entry.h"
 #include "modest-serversecurity-picker.h"
 #include "modest-secureauth-picker.h"
-#include <hildon/hildon-caption.h>
+#include "modest-maemo-utils.h"
 #include <hildon/hildon-number-editor.h>
+#include <hildon/hildon-check-button.h>
+#include "modest-hildon-includes.h"
 
 #define PORT_MIN 1
 #define PORT_MAX 65535
@@ -75,8 +77,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 (HILDON_CHECK_BUTTON (ppriv->auth_view), 
+                                               is_secure);
                gtk_widget_set_sensitive (ppriv->auth_view, !is_secure);
        } else {
 
@@ -126,28 +128,35 @@ on_auth_changed (GtkWidget *widget,
 
 static void
 create_incoming_security (ModestSecurityOptionsView* self,
-                         GtkSizeGroup *size_group)
+                         GtkSizeGroup *title_size_group,
+                         GtkSizeGroup *value_size_group)
 {
        ModestSecurityOptionsViewPrivate *ppriv;
-       GtkWidget *check_caption, *entry_caption = NULL;
+       GtkWidget *entry_caption = NULL;
 
        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,
+                                                                            HILDON_BUTTON_ARRANGEMENT_HORIZONTAL));
+       modest_serversecurity_picker_fill (MODEST_SERVERSECURITY_PICKER (ppriv->security_view), 
+                                          modest_protocol_registry_get_pop_type_id ());
+       modest_maemo_utils_set_hbutton_layout (title_size_group, 
+                                              value_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 (title_size_group,
+                                                                    value_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);
+       gtk_button_set_label (GTK_BUTTON (ppriv->auth_view), _("mcen_li_emailsetup_secure_authentication"));
+       gtk_button_set_alignment (GTK_BUTTON (ppriv->auth_view), 0.0, 0.5);
 
        /* Track changes in UI */       
        g_signal_connect (G_OBJECT (ppriv->security_view), "value-changed",
@@ -159,7 +168,7 @@ create_incoming_security (ModestSecurityOptionsView* self,
        if (ppriv->full)
                gtk_box_pack_start (GTK_BOX (self), entry_caption, 
                                    FALSE, FALSE, MODEST_MARGIN_HALF);
-       gtk_box_pack_start (GTK_BOX (self), check_caption,
+       gtk_box_pack_start (GTK_BOX (self), ppriv->auth_view,
                            FALSE, FALSE, MODEST_MARGIN_HALF);
 
        /* Show widgets */
@@ -169,7 +178,6 @@ create_incoming_security (ModestSecurityOptionsView* self,
        }
        gtk_widget_show (ppriv->security_view);
        gtk_widget_show (ppriv->auth_view);
-       gtk_widget_show (check_caption);
 }
 
 static void
@@ -220,7 +228,8 @@ on_entry_changed (GtkEditable *editable,
 
 static void
 create_outgoing_security (ModestSecurityOptionsView* self,
-                         GtkSizeGroup *size_group)
+                         GtkSizeGroup *title_size_group,
+                         GtkSizeGroup *value_size_group)
 {
        ModestSecurityOptionsViewPrivate *ppriv;
        GtkWidget *user_caption = NULL;
@@ -229,14 +238,22 @@ create_outgoing_security (ModestSecurityOptionsView* self,
        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,
+                                                                            HILDON_BUTTON_ARRANGEMENT_HORIZONTAL));
        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_set_hbutton_layout (title_size_group,
+                                              value_size_group,
+                                              _("mcen_li_emailsetup_secure_connection"), 
+                                              ppriv->security_view);
        
        /* The secure authentication widgets */
-       ppriv->auth_view = GTK_WIDGET (modest_secureauth_picker_new ());
-       hildon_button_set_title (HILDON_BUTTON (ppriv->auth_view), _("mcen_li_emailsetup_secure_authentication"));
+       ppriv->auth_view = GTK_WIDGET (modest_secureauth_picker_new (MODEST_EDITABLE_SIZE,
+                                                                    HILDON_BUTTON_ARRANGEMENT_HORIZONTAL));
+       modest_maemo_utils_set_hbutton_layout (title_size_group,
+                                              value_size_group,
+                                              _("mcen_li_emailsetup_secure_authentication"), 
+                                              ppriv->auth_view);
 
        if (ppriv->full) {
                gchar *user_label;
@@ -249,9 +266,10 @@ 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 (title_size_group,
+                                                                   value_size_group,
+                                                                   user_label, 
+                                                                   ppriv->user_entry);
                g_free (user_label);
        
                /* Prevent the use of some characters. Limit the max
@@ -271,21 +289,23 @@ 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 (title_size_group,
+                                                                  value_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 (title_size_group,
+                                                                   value_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);
@@ -328,7 +348,8 @@ create_outgoing_security (ModestSecurityOptionsView* self,
 GtkWidget *    
 modest_maemo_security_options_view_new  (ModestSecurityOptionsType type,
                                         gboolean full,
-                                        GtkSizeGroup *size_group)
+                                        GtkSizeGroup *title_size_group,
+                                        GtkSizeGroup *value_size_group)
 {
        ModestSecurityOptionsView* self;
        ModestSecurityOptionsViewPrivate *ppriv;
@@ -340,9 +361,9 @@ modest_maemo_security_options_view_new  (ModestSecurityOptionsType type,
        ppriv->full = full;
        self->type = type;
        if (self->type == MODEST_SECURITY_OPTIONS_INCOMING)
-               create_incoming_security (self, size_group);
+               create_incoming_security (self, title_size_group, value_size_group);
        else
-               create_outgoing_security (self, size_group);
+               create_outgoing_security (self, title_size_group, value_size_group);
 
        return (GtkWidget *) self;
 }