2007-04-23 Murray Cumming <murrayc@murrayc.com>
[modest] / src / maemo / modest-account-settings-dialog.c
index 31ddbf6..05ee8a5 100644 (file)
 #include <gtk/gtkmessagedialog.h>
 #include <gtk/gtkstock.h>
 #include <hildon-widgets/hildon-caption.h>
-#include "maemo/easysetup/modest-easysetup-country-combo-box.h"
-#include "maemo/easysetup/modest-easysetup-provider-combo-box.h"
-#include "maemo/easysetup/modest-easysetup-servertype-combo-box.h"
-#include "widgets/modest-easysetup-serversecurity-combo-box.h"
-#include "widgets/modest-easysetup-secureauth-combo-box.h"
+#include <hildon-widgets/hildon-number-editor.h>
+#include "widgets/modest-serversecurity-combo-box.h"
+#include "widgets/modest-secureauth-combo-box.h"
 #include "widgets/modest-validating-entry.h"
 #include "widgets/modest-retrieve-combo-box.h"
 #include "widgets/modest-limit-retrieve-combo-box.h"
@@ -371,7 +369,7 @@ create_page_user_details (ModestAccountSettingsDialog *self)
        
        /* Signature button: */
        if (!self->button_signature)
-               self->button_signature = gtk_button_new_with_label (_("mcen_bd_emailsetup_edit"));
+               self->button_signature = gtk_button_new_with_label (_("mcen_bd_edit"));
        caption = hildon_caption_new (sizegroup, _("mcen_fi_email_signature"), 
                self->button_signature, NULL, HILDON_CAPTION_OPTIONAL);
        gtk_widget_show (self->button_signature);
@@ -412,8 +410,8 @@ static void update_incoming_server_security_choices (ModestAccountSettingsDialog
 {
        /* Fill the combo with appropriately titled choices for POP or IMAP. */
        /* The choices are the same, but the titles are different, as in the UI spec. */
-       easysetup_serversecurity_combo_box_fill (
-               EASYSETUP_SERVERSECURITY_COMBO_BOX (self->combo_incoming_security), protocol);
+       modest_serversecurity_combo_box_fill (
+               MODEST_SERVERSECURITY_COMBO_BOX (self->combo_incoming_security), protocol);
 }
            
 static GtkWidget* create_page_incoming (ModestAccountSettingsDialog *self)
@@ -445,7 +443,7 @@ static GtkWidget* create_page_incoming (ModestAccountSettingsDialog *self)
        /* The secure connection widgets: */
        /* This will be filled by update_incoming_server_security_choices(). */
        if (!self->combo_incoming_security)
-               self->combo_incoming_security = GTK_WIDGET (easysetup_serversecurity_combo_box_new ());
+               self->combo_incoming_security = GTK_WIDGET (modest_serversecurity_combo_box_new ());
        GtkWidget *caption = hildon_caption_new (sizegroup, _("mcen_li_emailsetup_secure_connection"), 
                self->combo_incoming_security, NULL, HILDON_CAPTION_OPTIONAL);
        gtk_widget_show (self->combo_incoming_security);
@@ -460,7 +458,7 @@ static GtkWidget* create_page_incoming (ModestAccountSettingsDialog *self)
        /* The port widgets: */
        /* TODO: There are various rules about this in the UI spec. */
        if (!self->entry_incoming_port)
-               self->entry_incoming_port = GTK_WIDGET (gtk_entry_new ());
+               self->entry_incoming_port = GTK_WIDGET (hildon_number_editor_new (0, 10000 /* arbitrary min and max */));
        caption = hildon_caption_new (sizegroup, _("mcen_fi_emailsetup_port"), 
                self->entry_incoming_port, NULL, HILDON_CAPTION_OPTIONAL);
        gtk_widget_show (self->entry_incoming_port);
@@ -528,8 +526,8 @@ on_combo_outgoing_auth_changed (GtkComboBox *widget, gpointer user_data)
        ModestAccountSettingsDialog *self = MODEST_ACCOUNT_SETTINGS_DIALOG (user_data);
        
        ModestProtocol protocol_security = 
-               easysetup_secureauth_combo_box_get_active_secureauth (
-                       EASYSETUP_SECUREAUTH_COMBO_BOX (self->combo_outgoing_auth));
+               modest_secureauth_combo_box_get_active_secureauth (
+                       MODEST_SECUREAUTH_COMBO_BOX (self->combo_outgoing_auth));
        const gboolean secureauth_used = protocol_security != MODEST_PROTOCOL_AUTH_NONE;
        
        gtk_widget_set_sensitive (self->caption_outgoing_username, secureauth_used);
@@ -542,13 +540,12 @@ on_combo_outgoing_security_changed (GtkComboBox *widget, gpointer user_data)
        ModestAccountSettingsDialog *self = MODEST_ACCOUNT_SETTINGS_DIALOG (user_data);
        
        const gint port_number = 
-               easysetup_serversecurity_combo_box_get_active_serversecurity_port (
-                       EASYSETUP_SERVERSECURITY_COMBO_BOX (self->combo_outgoing_security));
+               modest_serversecurity_combo_box_get_active_serversecurity_port (
+                       MODEST_SERVERSECURITY_COMBO_BOX (self->combo_outgoing_security));
 
        if(port_number != 0) {
-               gchar* str = g_strdup_printf ("%d", port_number);
-               gtk_entry_set_text (GTK_ENTRY (self->entry_outgoing_port), str);
-               g_free (str);   
+               hildon_number_editor_set_value (
+                       HILDON_NUMBER_EDITOR (self->entry_outgoing_port), port_number);
        }               
 }
 
@@ -558,13 +555,12 @@ on_combo_incoming_security_changed (GtkComboBox *widget, gpointer user_data)
        ModestAccountSettingsDialog *self = MODEST_ACCOUNT_SETTINGS_DIALOG (user_data);
        
        const gint port_number = 
-               easysetup_serversecurity_combo_box_get_active_serversecurity_port (
-                       EASYSETUP_SERVERSECURITY_COMBO_BOX (self->combo_incoming_security));
+               modest_serversecurity_combo_box_get_active_serversecurity_port (
+                       MODEST_SERVERSECURITY_COMBO_BOX (self->combo_incoming_security));
 
        if(port_number != 0) {
-               gchar* str = g_strdup_printf ("%d", port_number);
-               gtk_entry_set_text (GTK_ENTRY (self->entry_incoming_port), str);
-               g_free (str);   
+               hildon_number_editor_set_value (
+                       HILDON_NUMBER_EDITOR (self->entry_incoming_port), port_number);
        }               
 }
 
@@ -590,7 +586,7 @@ static GtkWidget* create_page_outgoing (ModestAccountSettingsDialog *self)
        
        /* The secure authentication widgets: */
        if (!self->combo_outgoing_auth)
-               self->combo_outgoing_auth = GTK_WIDGET (easysetup_secureauth_combo_box_new ());
+               self->combo_outgoing_auth = GTK_WIDGET (modest_secureauth_combo_box_new ());
        caption = hildon_caption_new (sizegroup, _("mcen_li_emailsetup_secure_authentication"), 
                self->combo_outgoing_auth, NULL, HILDON_CAPTION_OPTIONAL);
        gtk_widget_show (self->combo_outgoing_auth);
@@ -631,11 +627,11 @@ static GtkWidget* create_page_outgoing (ModestAccountSettingsDialog *self)
        gtk_widget_show (self->caption_outgoing_password);
        
        /* The secure connection widgets: */
-       /* This will be filled and set with easysetup_serversecurity_combo_box_fill() 
-        * and easysetup_serversecurity_combo_box_set_active_serversecurity().
+       /* This will be filled and set with modest_serversecurity_combo_box_fill() 
+        * and modest_serversecurity_combo_box_set_active_serversecurity().
         */
        if (!self->combo_outgoing_security)
-               self->combo_outgoing_security = GTK_WIDGET (easysetup_serversecurity_combo_box_new ());
+               self->combo_outgoing_security = GTK_WIDGET (modest_serversecurity_combo_box_new ());
        caption = hildon_caption_new (sizegroup, _("mcen_li_emailsetup_secure_connection"), 
                self->combo_outgoing_security, NULL, HILDON_CAPTION_OPTIONAL);
        gtk_widget_show (self->combo_outgoing_security);
@@ -648,7 +644,7 @@ static GtkWidget* create_page_outgoing (ModestAccountSettingsDialog *self)
        
        /* The port widgets: */
        if (!self->entry_outgoing_port)
-               self->entry_outgoing_port = GTK_WIDGET (gtk_entry_new ());
+               self->entry_outgoing_port = GTK_WIDGET (hildon_number_editor_new (0, 10000 /* arbitrary min and max */));
        caption = hildon_caption_new (sizegroup, _("mcen_fi_emailsetup_port"), 
                self->entry_outgoing_port, NULL, HILDON_CAPTION_OPTIONAL);
        gtk_widget_show (self->entry_outgoing_port);
@@ -668,7 +664,7 @@ static GtkWidget* create_page_outgoing (ModestAccountSettingsDialog *self)
        
        /* Connection-specific SMTP-Severs Edit button: */
        if (!self->button_outgoing_smtp_servers)
-               self->button_outgoing_smtp_servers = gtk_button_new_with_label (_("mcen_bd_emailsetup_edit"));
+               self->button_outgoing_smtp_servers = gtk_button_new_with_label (_("mcen_bd_edit"));
        caption = hildon_caption_new (sizegroup, _("mcen_fi_advsetup_optional_smtp"), 
                self->button_outgoing_smtp_servers, NULL, HILDON_CAPTION_OPTIONAL);
        gtk_widget_show (self->button_outgoing_smtp_servers);
@@ -932,22 +928,13 @@ void modest_account_settings_dialog_set_account_name (ModestAccountSettingsDialo
                
                const ModestProtocol security = modest_server_account_get_security (
                        dialog->account_manager, incoming_account->account_name);
-               easysetup_serversecurity_combo_box_set_active_serversecurity (
-                       EASYSETUP_SERVERSECURITY_COMBO_BOX (dialog->combo_incoming_security), security);
+               modest_serversecurity_combo_box_set_active_serversecurity (
+                       MODEST_SERVERSECURITY_COMBO_BOX (dialog->combo_incoming_security), security);
                
                const gint port_num = modest_account_mgr_get_int (dialog->account_manager, incoming_account->account_name,
                        MODEST_ACCOUNT_PORT, TRUE /* server account */);
-               gchar *port_str = g_strdup_printf ("%d", port_num);
-               gtk_entry_set_text (GTK_ENTRY (dialog->entry_incoming_port), port_str);
-               g_free (port_str);
-       
-               /* TODO:
-       gchar            *uri;
-       ModestProtocol    proto;
-       gchar            *password;
-       time_t            last_updated;
-       GSList           *options;
-       */
+               hildon_number_editor_set_value (
+                       HILDON_NUMBER_EDITOR (dialog->entry_incoming_port), port_num);
        
        }
        
@@ -964,24 +951,23 @@ void modest_account_settings_dialog_set_account_name (ModestAccountSettingsDialo
                /* Get the secure-auth setting: */
                const ModestProtocol secure_auth = modest_server_account_get_secure_auth(
                        dialog->account_manager, outgoing_account->account_name);
-               easysetup_secureauth_combo_box_set_active_secureauth (
-                       EASYSETUP_SECUREAUTH_COMBO_BOX (dialog->combo_outgoing_auth), secure_auth);
+               modest_secureauth_combo_box_set_active_secureauth (
+                       MODEST_SECUREAUTH_COMBO_BOX (dialog->combo_outgoing_auth), secure_auth);
                on_combo_outgoing_auth_changed (GTK_COMBO_BOX (dialog->combo_outgoing_auth), dialog);
                
-               easysetup_serversecurity_combo_box_fill (
-                       EASYSETUP_SERVERSECURITY_COMBO_BOX (dialog->combo_outgoing_security), outgoing_account->proto);
+               modest_serversecurity_combo_box_fill (
+                       MODEST_SERVERSECURITY_COMBO_BOX (dialog->combo_outgoing_security), outgoing_account->proto);
                
                /* Get the security setting: */
                const ModestProtocol security = modest_server_account_get_security (
                        dialog->account_manager, outgoing_account->account_name);
-               easysetup_serversecurity_combo_box_set_active_serversecurity (
-                       EASYSETUP_SERVERSECURITY_COMBO_BOX (dialog->combo_outgoing_security), security);
+               modest_serversecurity_combo_box_set_active_serversecurity (
+                       MODEST_SERVERSECURITY_COMBO_BOX (dialog->combo_outgoing_security), security);
                
                const gint port_num = modest_account_mgr_get_int (dialog->account_manager, outgoing_account->account_name,
                        MODEST_ACCOUNT_PORT, TRUE /* server account */);
-               gchar *port_str = g_strdup_printf ("%d", port_num);
-               gtk_entry_set_text (GTK_ENTRY (dialog->entry_outgoing_port), port_str);
-               g_free (port_str);
+               hildon_number_editor_set_value (
+                       HILDON_NUMBER_EDITOR (dialog->entry_outgoing_port), port_num);
        }
        
        /* account_data->is_enabled,  */
@@ -1061,15 +1047,13 @@ save_configuration (ModestAccountSettingsDialog *dialog)
                        : MODEST_PROTOCOL_AUTH_NONE;
        modest_server_account_set_secure_auth (dialog->account_manager, incoming_account_name, protocol_authentication_incoming);
                        
-       const ModestProtocol protocol_security_incoming = easysetup_serversecurity_combo_box_get_active_serversecurity (
-               EASYSETUP_SERVERSECURITY_COMBO_BOX (dialog->combo_incoming_security));
+       const ModestProtocol protocol_security_incoming = modest_serversecurity_combo_box_get_active_serversecurity (
+               MODEST_SERVERSECURITY_COMBO_BOX (dialog->combo_incoming_security));
        modest_server_account_set_security (dialog->account_manager, incoming_account_name, protocol_security_incoming);
        
        /* port: */
-       const gchar* port_str = gtk_entry_get_text (GTK_ENTRY (dialog->entry_incoming_port));
-       gint port_num = 0;
-       if (port_str)
-               port_num = atoi (port_str);
+       gint port_num = hildon_number_editor_get_value (
+                       HILDON_NUMBER_EDITOR (dialog->entry_incoming_port));
        modest_account_mgr_set_int (dialog->account_manager, incoming_account_name,
                        MODEST_ACCOUNT_PORT, port_num, TRUE /* server account */);
                
@@ -1098,19 +1082,17 @@ save_configuration (ModestAccountSettingsDialog *dialog)
        if (!test)
                return FALSE;
        
-       const ModestProtocol protocol_security_outgoing = easysetup_serversecurity_combo_box_get_active_serversecurity (
-               EASYSETUP_SERVERSECURITY_COMBO_BOX (dialog->combo_outgoing_security));
+       const ModestProtocol protocol_security_outgoing = modest_serversecurity_combo_box_get_active_serversecurity (
+               MODEST_SERVERSECURITY_COMBO_BOX (dialog->combo_outgoing_security));
        modest_server_account_set_security (dialog->account_manager, outgoing_account_name, protocol_security_outgoing);
        
-       const ModestProtocol protocol_authentication_outgoing = easysetup_secureauth_combo_box_get_active_secureauth (
-               EASYSETUP_SECUREAUTH_COMBO_BOX (dialog->combo_outgoing_auth));
+       const ModestProtocol protocol_authentication_outgoing = modest_secureauth_combo_box_get_active_secureauth (
+               MODEST_SECUREAUTH_COMBO_BOX (dialog->combo_outgoing_auth));
        modest_server_account_set_secure_auth (dialog->account_manager, outgoing_account_name, protocol_authentication_outgoing);       
                
        /* port: */
-       port_str = gtk_entry_get_text (GTK_ENTRY (dialog->entry_outgoing_port));
-       port_num = 0;
-       if (port_str)
-               port_num = atoi (port_str);
+       port_num = hildon_number_editor_get_value (
+                       HILDON_NUMBER_EDITOR (dialog->entry_outgoing_port));
        modest_account_mgr_set_int (dialog->account_manager, outgoing_account_name,
                        MODEST_ACCOUNT_PORT, port_num, TRUE /* server account */);