* fixes for latest hildon version
[modest] / src / maemo / modest-account-settings-dialog.c
index 331c409..6632390 100644 (file)
@@ -15,8 +15,8 @@
 #include <gtk/gtkcheckbutton.h>
 #include <gtk/gtkmessagedialog.h>
 #include <gtk/gtkstock.h>
-#include <hildon-widgets/hildon-caption.h>
-#include <hildon-widgets/hildon-number-editor.h>
+#include "modest-hildon-includes.h"
+
 #include "widgets/modest-serversecurity-combo-box.h"
 #include "widgets/modest-secureauth-combo-box.h"
 #include "widgets/modest-validating-entry.h"
@@ -216,6 +216,14 @@ static GtkWidget* create_caption_new_with_asterix(ModestAccountSettingsDialog *s
        return caption;
 }
 
+
+static void
+on_entry_max (ModestValidatingEntry *self, gpointer user_data)
+{
+       ModestAccountSettingsDialog *dialog = MODEST_ACCOUNT_SETTINGS_DIALOG (user_data);
+       show_error (GTK_WINDOW (dialog), _("ckdg_ib_maximum_characters_reached"));
+}
+
 static GtkWidget*
 create_page_account_details (ModestAccountSettingsDialog *self)
 {
@@ -230,7 +238,10 @@ create_page_account_details (ModestAccountSettingsDialog *self)
        GtkSizeGroup* sizegroup = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
            
        /* The description widgets: */  
-       self->entry_account_title = GTK_WIDGET (easysetup_validating_entry_new ());
+       self->entry_account_title = GTK_WIDGET (modest_validating_entry_new ());
+       /* Do use auto-capitalization: */
+       hildon_gtk_entry_set_input_mode (GTK_ENTRY (self->entry_account_title), 
+               HILDON_GTK_INPUT_MODE_FULL | HILDON_GTK_INPUT_MODE_AUTOCAP);
        GtkWidget *caption = create_caption_new_with_asterix (self, sizegroup, _("mcen_fi_account_title"), 
                self->entry_account_title, NULL, HILDON_CAPTION_MANDATORY);
        gtk_widget_show (self->entry_account_title);
@@ -252,13 +263,15 @@ create_page_account_details (ModestAccountSettingsDialog *self)
        list_prevent = g_list_append (list_prevent, ">"); 
        list_prevent = g_list_append (list_prevent, "|");
        list_prevent = g_list_append (list_prevent, "^");       
-       easysetup_validating_entry_set_unallowed_characters (
-               EASYSETUP_VALIDATING_ENTRY (self->entry_account_title), list_prevent);
+       modest_validating_entry_set_unallowed_characters (
+               MODEST_VALIDATING_ENTRY (self->entry_account_title), list_prevent);
        g_list_free (list_prevent);
        
        /* Set max length as in the UI spec:
-        * TODO: The UI spec seems to want us to show a dialog if we hit the maximum. */
+        * The UI spec seems to want us to show a dialog if we hit the maximum. */
        gtk_entry_set_max_length (GTK_ENTRY (self->entry_account_title), 64);
+       modest_validating_entry_set_max_func (MODEST_VALIDATING_ENTRY (self->entry_account_title), 
+               on_entry_max, self);
        
        /* The retrieve combobox: */
        self->combo_retrieve = GTK_WIDGET (modest_retrieve_combo_box_new ());
@@ -280,11 +293,13 @@ create_page_account_details (ModestAccountSettingsDialog *self)
 
        /* The leave-messages widgets: */
        if(!self->checkbox_leave_messages)
-               self->checkbox_leave_messages = 
-                       gtk_check_button_new_with_label (_("mcen_fi_advsetup_leave_on_server"));
-       gtk_box_pack_start (GTK_BOX (box), self->checkbox_leave_messages, FALSE, FALSE, MODEST_MARGIN_HALF);
+               self->checkbox_leave_messages = gtk_check_button_new ();
+       caption = create_caption_new_with_asterix (self, sizegroup, _("mcen_fi_advsetup_leave_on_server"), 
+               self->checkbox_leave_messages, NULL, HILDON_CAPTION_MANDATORY);
        gtk_widget_show (self->checkbox_leave_messages);
        connect_for_modified (self, self->checkbox_leave_messages);
+       gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, MODEST_MARGIN_HALF);
+       gtk_widget_show (caption);
        
        gtk_widget_show (GTK_WIDGET (box));
        
@@ -338,10 +353,14 @@ create_page_user_details (ModestAccountSettingsDialog *self)
        GtkSizeGroup* sizegroup = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
         
        /* The name widgets: */
-       self->entry_user_name = GTK_WIDGET (easysetup_validating_entry_new ());
+       self->entry_user_name = GTK_WIDGET (modest_validating_entry_new ());
+       /* Auto-capitalization is the default, so let's turn it off: */
+       hildon_gtk_entry_set_input_mode (GTK_ENTRY (self->entry_user_name), HILDON_GTK_INPUT_MODE_FULL);
        /* Set max length as in the UI spec:
-        * TODO: The UI spec seems to want us to show a dialog if we hit the maximum. */
+        * The UI spec seems to want us to show a dialog if we hit the maximum. */
        gtk_entry_set_max_length (GTK_ENTRY (self->entry_user_name), 64);
+       modest_validating_entry_set_max_func (MODEST_VALIDATING_ENTRY (self->entry_user_name), 
+               on_entry_max, self);
        GtkWidget *caption = create_caption_new_with_asterix (self, sizegroup, 
                _("mcen_li_emailsetup_name"), self->entry_user_name, NULL, HILDON_CAPTION_OPTIONAL);
        gtk_widget_show (self->entry_user_name);
@@ -354,12 +373,14 @@ create_page_user_details (ModestAccountSettingsDialog *self)
        GList *list_prevent = NULL;
        list_prevent = g_list_append (list_prevent, "<");
        list_prevent = g_list_append (list_prevent, ">");
-       easysetup_validating_entry_set_unallowed_characters (
-               EASYSETUP_VALIDATING_ENTRY (self->entry_user_name), list_prevent);
+       modest_validating_entry_set_unallowed_characters (
+               MODEST_VALIDATING_ENTRY (self->entry_user_name), list_prevent);
        g_list_free (list_prevent);
        
        /* The username widgets: */     
-       self->entry_user_username = GTK_WIDGET (easysetup_validating_entry_new ());
+       self->entry_user_username = GTK_WIDGET (modest_validating_entry_new ());
+       /* Auto-capitalization is the default, so let's turn it off: */
+       hildon_gtk_entry_set_input_mode (GTK_ENTRY (self->entry_user_username), HILDON_GTK_INPUT_MODE_FULL);
        caption = create_caption_new_with_asterix (self, sizegroup, _("mail_fi_username"), 
                self->entry_user_username, NULL, HILDON_CAPTION_MANDATORY);
        gtk_widget_show (self->entry_user_username);
@@ -369,15 +390,19 @@ create_page_user_details (ModestAccountSettingsDialog *self)
        
        /* Prevent the use of some characters in the username, 
         * as required by our UI specification: */
-       easysetup_validating_entry_set_unallowed_characters_whitespace (
-               EASYSETUP_VALIDATING_ENTRY (self->entry_user_username));
+       modest_validating_entry_set_unallowed_characters_whitespace (
+               MODEST_VALIDATING_ENTRY (self->entry_user_username));
        
        /* Set max length as in the UI spec:
-        * TODO: The UI spec seems to want us to show a dialog if we hit the maximum. */
+        * The UI spec seems to want us to show a dialog if we hit the maximum. */
        gtk_entry_set_max_length (GTK_ENTRY (self->entry_user_username), 64);
+       modest_validating_entry_set_max_func (MODEST_VALIDATING_ENTRY (self->entry_user_username), 
+               on_entry_max, self);
        
        /* The password widgets: */     
        self->entry_user_password = gtk_entry_new ();
+       /* Auto-capitalization is the default, so let's turn it off: */
+       hildon_gtk_entry_set_input_mode (GTK_ENTRY (self->entry_user_password), HILDON_GTK_INPUT_MODE_FULL);
        gtk_entry_set_visibility (GTK_ENTRY (self->entry_user_password), FALSE);
        /* gtk_entry_set_invisible_char (GTK_ENTRY (self->entry_user_password), '*'); */
        caption = create_caption_new_with_asterix (self, sizegroup, 
@@ -388,7 +413,9 @@ create_page_user_details (ModestAccountSettingsDialog *self)
        gtk_widget_show (caption);
        
        /* The email address widgets: */        
-       self->entry_user_email = GTK_WIDGET (easysetup_validating_entry_new ());
+       self->entry_user_email = GTK_WIDGET (modest_validating_entry_new ());
+       /* Auto-capitalization is the default, so let's turn it off: */
+       hildon_gtk_entry_set_input_mode (GTK_ENTRY (self->entry_user_email), HILDON_GTK_INPUT_MODE_FULL);
        caption = create_caption_new_with_asterix (self, sizegroup, 
                _("mcen_li_emailsetup_email_address"), self->entry_user_email, NULL, HILDON_CAPTION_MANDATORY);
        gtk_entry_set_text (GTK_ENTRY (self->entry_user_email), EXAMPLE_EMAIL_ADDRESS); /* Default text. */
@@ -398,9 +425,10 @@ create_page_user_details (ModestAccountSettingsDialog *self)
        gtk_widget_show (caption);
        
        /* Set max length as in the UI spec:
-        * TODO: The UI spec seems to want us to show a dialog if we hit the maximum. */
+        * The UI spec seems to want us to show a dialog if we hit the maximum. */
        gtk_entry_set_max_length (GTK_ENTRY (self->entry_user_email), 64);
-       
+       modest_validating_entry_set_max_func (MODEST_VALIDATING_ENTRY (self->entry_user_email), 
+               on_entry_max, self);
        
        /* Signature button: */
        if (!self->button_signature)
@@ -462,6 +490,8 @@ static GtkWidget* create_page_incoming (ModestAccountSettingsDialog *self)
        /* The incoming server widgets: */
        if(!self->entry_incomingserver)
                self->entry_incomingserver = gtk_entry_new ();
+       /* Auto-capitalization is the default, so let's turn it off: */
+       hildon_gtk_entry_set_input_mode (GTK_ENTRY (self->entry_incomingserver), HILDON_GTK_INPUT_MODE_FULL);
 
        if (self->caption_incoming)
          gtk_widget_destroy (self->caption_incoming);
@@ -504,11 +534,13 @@ static GtkWidget* create_page_incoming (ModestAccountSettingsDialog *self)
        
        /* The secure authentication widgets: */
        if(!self->checkbox_incoming_auth)
-               self->checkbox_incoming_auth = 
-                       gtk_check_button_new_with_label (_("mcen_li_emailsetup_secure_authentication"));
-       gtk_box_pack_start (GTK_BOX (box), self->checkbox_incoming_auth, FALSE, FALSE, MODEST_MARGIN_HALF);
+               self->checkbox_incoming_auth = gtk_check_button_new ();
+       caption = hildon_caption_new (sizegroup, _("mcen_li_emailsetup_secure_authentication"), 
+               self->checkbox_incoming_auth, NULL, HILDON_CAPTION_OPTIONAL);
        gtk_widget_show (self->checkbox_incoming_auth);
        connect_for_modified (self, self->checkbox_incoming_auth);
+       gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, MODEST_MARGIN_HALF);
+       gtk_widget_show (caption);
        
        gtk_widget_show (GTK_WIDGET (box));
        
@@ -613,6 +645,8 @@ static GtkWidget* create_page_outgoing (ModestAccountSettingsDialog *self)
        /* The outgoing server widgets: */
        if (!self->entry_outgoingserver)
                self->entry_outgoingserver = gtk_entry_new ();
+       /* Auto-capitalization is the default, so let's turn it off: */
+       hildon_gtk_entry_set_input_mode (GTK_ENTRY (self->entry_outgoingserver), HILDON_GTK_INPUT_MODE_FULL);
        GtkWidget *caption = create_caption_new_with_asterix (self, sizegroup, 
                _("mcen_li_emailsetup_smtp"), self->entry_outgoingserver, NULL, HILDON_CAPTION_OPTIONAL);
        gtk_widget_show (self->entry_outgoingserver);
@@ -634,7 +668,9 @@ static GtkWidget* create_page_outgoing (ModestAccountSettingsDialog *self)
        g_signal_connect (G_OBJECT (self->combo_outgoing_auth), "changed", (GCallback)on_combo_outgoing_auth_changed, self);
        
        /* The username widgets: */     
-       self->entry_outgoing_username = GTK_WIDGET (easysetup_validating_entry_new ());
+       self->entry_outgoing_username = GTK_WIDGET (modest_validating_entry_new ());
+       /* Auto-capitalization is the default, so let's turn it off: */
+       hildon_gtk_entry_set_input_mode (GTK_ENTRY (self->entry_outgoing_username), HILDON_GTK_INPUT_MODE_FULL);
        self->caption_outgoing_username = create_caption_new_with_asterix (self, sizegroup, _("mail_fi_username"), 
                self->entry_outgoing_username, NULL, HILDON_CAPTION_MANDATORY);
        gtk_widget_show (self->entry_outgoing_username);
@@ -644,15 +680,19 @@ static GtkWidget* create_page_outgoing (ModestAccountSettingsDialog *self)
        
        /* Prevent the use of some characters in the username, 
         * as required by our UI specification: */
-       easysetup_validating_entry_set_unallowed_characters_whitespace (
-               EASYSETUP_VALIDATING_ENTRY (self->entry_outgoing_username));
+       modest_validating_entry_set_unallowed_characters_whitespace (
+               MODEST_VALIDATING_ENTRY (self->entry_outgoing_username));
        
        /* Set max length as in the UI spec:
-        * TODO: The UI spec seems to want us to show a dialog if we hit the maximum. */
+        * The UI spec seems to want us to show a dialog if we hit the maximum. */
        gtk_entry_set_max_length (GTK_ENTRY (self->entry_outgoing_username), 64);
-       
+       modest_validating_entry_set_max_func (MODEST_VALIDATING_ENTRY (self->entry_outgoing_username), 
+               on_entry_max, self);
+               
        /* The password widgets: */     
        self->entry_outgoing_password = gtk_entry_new ();
+       /* Auto-capitalization is the default, so let's turn it off: */
+       hildon_gtk_entry_set_input_mode (GTK_ENTRY (self->entry_outgoing_password), HILDON_GTK_INPUT_MODE_FULL);
        gtk_entry_set_visibility (GTK_ENTRY (self->entry_outgoing_password), FALSE);
        /* gtk_entry_set_invisible_char (GTK_ENTRY (self->entry_outgoing_password), '*'); */
        self->caption_outgoing_password = create_caption_new_with_asterix (self, sizegroup, 
@@ -694,12 +734,15 @@ static GtkWidget* create_page_outgoing (ModestAccountSettingsDialog *self)
        
        /* connection-specific checkbox: */
        if (!self->checkbox_outgoing_smtp_specific) {
-               self->checkbox_outgoing_smtp_specific = gtk_check_button_new_with_label (_("mcen_fi_advsetup_connection_smtp"));
+               self->checkbox_outgoing_smtp_specific = gtk_check_button_new ();
                gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (self->checkbox_outgoing_smtp_specific), 
                        FALSE);
        }
-       gtk_box_pack_start (GTK_BOX (box), self->checkbox_outgoing_smtp_specific, FALSE, FALSE, MODEST_MARGIN_HALF);
+       caption = hildon_caption_new (sizegroup, _("mcen_fi_advsetup_connection_smtp"), 
+               self->checkbox_outgoing_smtp_specific, NULL, HILDON_CAPTION_OPTIONAL);
        gtk_widget_show (self->checkbox_outgoing_smtp_specific);
+       gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, MODEST_MARGIN_HALF);
+       gtk_widget_show (caption);
        connect_for_modified (self, self->checkbox_outgoing_smtp_specific);
        
        /* Connection-specific SMTP-Severs Edit button: */