* Added new ModestRetrievePicker as a replacement of
[modest] / src / hildon2 / modest-default-account-settings-dialog.c
index bdfb231..b3c24df 100644 (file)
 #include "modest-hildon-includes.h"
 #include "modest-default-account-settings-dialog.h"
 #include "modest-account-mgr.h"
-#include "widgets/modest-serversecurity-combo-box.h"
-#include "widgets/modest-secureauth-combo-box.h"
+#include "modest-secureauth-picker.h"
 #include "widgets/modest-validating-entry.h"
-#include "widgets/modest-retrieve-combo-box.h"
+#include "modest-retrieve-picker.h"
 #include "widgets/modest-limit-retrieve-combo-box.h"
 #include "modest-text-utils.h"
 #include "modest-account-mgr.h"
 #include "modest-account-mgr-helpers.h" /* For modest_account_mgr_get_account_data(). */
 #include <modest-server-account-settings.h>
 #include "modest-runtime.h" /* For modest_runtime_get_account_mgr(). */
-#include "maemo/modest-connection-specific-smtp-window.h"
-#include "maemo/modest-signature-editor-dialog.h"
+#include "modest-connection-specific-smtp-window.h"
+#include "modest-signature-editor-dialog.h"
 #include <modest-utils.h>
 #include <modest-defs.h>
-#include "maemo/modest-maemo-utils.h"
-#include "maemo/modest-maemo-security-options-view.h"
+#include "modest-maemo-utils.h"
+#include "modest-maemo-security-options-view.h"
 #include "widgets/modest-ui-constants.h"
 #include <tny-account.h>
 #include <tny-status.h>
@@ -105,7 +104,7 @@ struct _ModestDefaultAccountSettingsDialogPrivate
        
        GtkWidget *page_account_details;
        GtkWidget *entry_account_title;
-       GtkWidget *combo_retrieve;
+       GtkWidget *retrieve_picker;
        GtkWidget *combo_limit_retrieve;
        GtkWidget *caption_leave_messages;
        GtkWidget *checkbox_leave_messages;
@@ -123,18 +122,9 @@ struct _ModestDefaultAccountSettingsDialogPrivate
        GtkWidget *page_incoming;
        GtkWidget *caption_incoming;
        GtkWidget *entry_incomingserver;
-/*     GtkWidget *combo_incoming_security; */
-/*     GtkWidget *checkbox_incoming_auth; */
 
        GtkWidget *page_outgoing;
        GtkWidget *entry_outgoingserver;
-/*     GtkWidget *caption_outgoing_username; */
-/*     GtkWidget *entry_outgoing_username; */
-/*     GtkWidget *caption_outgoing_password; */
-/*     GtkWidget *entry_outgoing_password; */
-/*     GtkWidget *combo_outgoing_security; */
-/*     GtkWidget *combo_outgoing_auth; */
-/*     GtkWidget *entry_outgoing_port; */
        GtkWidget *checkbox_outgoing_smtp_specific;
        GtkWidget *button_outgoing_smtp_servers;
        
@@ -210,6 +200,12 @@ on_modified_combobox_changed (GtkComboBox *widget, gpointer user_data)
 }
 
 static void
+on_modified_picker_changed (HildonPickerButton *widget, gpointer user_data)
+{
+       set_modified (MODEST_DEFAULT_ACCOUNT_SETTINGS_DIALOG (user_data), TRUE);
+}
+
+static void
 on_modified_entry_changed (GtkEditable *editable, gpointer user_data)
 {
        set_modified (MODEST_DEFAULT_ACCOUNT_SETTINGS_DIALOG (user_data), TRUE);
@@ -252,7 +248,10 @@ connect_for_modified (ModestDefaultAccountSettingsDialog *self, GtkWidget *widge
                        G_CALLBACK (on_modified_entry_changed), self);
        } else if (GTK_IS_COMBO_BOX (widget)) {
                g_signal_connect (G_OBJECT (widget), "changed",
-                       G_CALLBACK (on_modified_combobox_changed), self);       
+                       G_CALLBACK (on_modified_combobox_changed), self);
+       } else if (HILDON_IS_PICKER_BUTTON (widget)) {
+               g_signal_connect (G_OBJECT (widget), "value-changed",
+                                 G_CALLBACK (on_modified_picker_changed), self);
        } else if (GTK_IS_TOGGLE_BUTTON (widget)) {
                g_signal_connect (G_OBJECT (widget), "toggled",
                        G_CALLBACK (on_modified_checkbox_toggled), self);
@@ -407,13 +406,11 @@ create_page_account_details (ModestDefaultAccountSettingsDialog *self)
                on_entry_max, self);
        
        /* The retrieve combobox: */
-       priv->combo_retrieve = GTK_WIDGET (modest_retrieve_combo_box_new ());
-       caption = create_caption_new_with_asterisk (self, sizegroup, _("mcen_fi_advsetup_retrievetype"), 
-               priv->combo_retrieve, NULL, HILDON_CAPTION_MANDATORY);
-       gtk_widget_show (priv->combo_retrieve);
-       connect_for_modified (self, priv->combo_retrieve);
-       gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, MODEST_MARGIN_HALF);
-       gtk_widget_show (caption);
+       priv->retrieve_picker = GTK_WIDGET (modest_retrieve_picker_new ());
+       hildon_button_set_title (HILDON_BUTTON (priv->retrieve_picker), _("mcen_fi_advsetup_retrievetype"));
+       gtk_widget_show (priv->retrieve_picker);
+       connect_for_modified (self, priv->retrieve_picker);
+       gtk_box_pack_start (GTK_BOX (box), priv->retrieve_picker, FALSE, FALSE, MODEST_MARGIN_HALF);
        
        /* The limit-retrieve combobox: */
        priv->combo_limit_retrieve = GTK_WIDGET (modest_limit_retrieve_combo_box_new ());
@@ -678,19 +675,6 @@ update_incoming_server_title (ModestDefaultAccountSettingsDialog *self,
        g_free (with_asterisk);
 }
 
-/** Change the caption title for the incoming server, 
- * as specified in the UI spec:
- */
-/* static void  */
-/* update_incoming_server_security_choices (ModestDefaultAccountSettingsDialog *self,  */
-/*                                      ModestProtocolType protocol) */
-/* { */
-/*     /\* 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. *\/ */
-/*     modest_serversecurity_combo_box_fill ( */
-/*             MODEST_SERVERSECURITY_COMBO_BOX (priv->combo_incoming_security), protocol); */
-/* } */
-           
 static GtkWidget* 
 create_page_incoming (ModestDefaultAccountSettingsDialog *self)
 {
@@ -781,41 +765,6 @@ on_button_outgoing_smtp_servers (GtkButton *button, gpointer user_data)
        priv->modified = TRUE;
 }
 
-/* static void */
-/* on_combo_outgoing_auth_changed (GtkComboBox *widget, gpointer user_data) */
-/* { */
-/*     ModestDefaultAccountSettingsDialog *self; */
-/*     ModestProtocolRegistry *protocol_registry; */
-/*     ModestProtocolType protocol_security;    */
-/*     gboolean secureauth_used; */
-
-/*     self = MODEST_DEFAULT_ACCOUNT_SETTINGS_DIALOG (user_data); */
-/*     protocol_registry = modest_runtime_get_protocol_registry (); */
-       
-/*     protocol_security =  */
-/*             modest_secureauth_combo_box_get_active_secureauth ( */
-/*                     MODEST_SECUREAUTH_COMBO_BOX (priv->combo_outgoing_auth)); */
-/*     secureauth_used = modest_protocol_registry_protocol_type_is_secure (protocol_registry, protocol_security); */
-       
-/*     gtk_widget_set_sensitive (priv->caption_outgoing_username, secureauth_used); */
-/*     gtk_widget_set_sensitive (priv->caption_outgoing_password, secureauth_used); */
-/* } */
-
-/* static void */
-/* on_combo_outgoing_security_changed (GtkComboBox *widget, gpointer user_data) */
-/* { */
-/*     ModestDefaultAccountSettingsDialog *self = MODEST_DEFAULT_ACCOUNT_SETTINGS_DIALOG (user_data); */
-       
-/*     const gint port_number =  */
-/*             modest_serversecurity_combo_box_get_active_serversecurity_port ( */
-/*                     MODEST_SERVERSECURITY_COMBO_BOX (priv->combo_outgoing_security)); */
-
-/*     if(port_number != 0) { */
-/*             hildon_number_editor_set_value ( */
-/*                     HILDON_NUMBER_EDITOR (priv->entry_outgoing_port), port_number); */
-/*     }                */
-/* } */
-
 static void
 on_missing_mandatory_data (ModestSecurityOptionsView *security_view,
                           gboolean missing,
@@ -998,62 +947,6 @@ check_data (ModestDefaultAccountSettingsDialog *self)
                return FALSE;
        }
        
-/*     /\* Find a suitable authentication method when secure authentication is desired *\/ */
-/*     port_num = hildon_number_editor_get_value ( */
-/*             HILDON_NUMBER_EDITOR (priv->entry_incoming_port)); */
-/*     username = gtk_entry_get_text (GTK_ENTRY (priv->entry_user_username)); */
-
-/*     protocol_registry = modest_runtime_get_protocol_registry (); */
-
-/*     protocol_security_incoming = modest_serversecurity_combo_box_get_active_serversecurity ( */
-/*             MODEST_SERVERSECURITY_COMBO_BOX (priv->combo_incoming_security)); */
-/*     if (!modest_protocol_registry_protocol_type_is_secure(protocol_registry, protocol_security_incoming)) */
-/*     { */
-/*             if (gtk_toggle_button_get_active ( */
-/*                             GTK_TOGGLE_BUTTON (priv->checkbox_incoming_auth))) { */
-/*                     GError *error = NULL; */
-/*                     GList *list_auth_methods; */
-
-/*                     list_auth_methods =  */
-/*                             modest_utils_get_supported_secure_authentication_methods (priv->incoming_protocol,  */
-/*                                                                                       hostname, port_num, username, GTK_WINDOW (self), &error); */
-/*                     if (list_auth_methods) { */
-/*                             GList* method; */
-
-/*                             /\* Use the first supported method. */
-/*                              * TODO: Should we prioritize them, to prefer a particular one? *\/ */
-/*                             for (method = list_auth_methods; method != NULL; method = g_list_next(method)) */
-/*                             { */
-/*                                     ModestProtocolType proto = (ModestProtocolType)(GPOINTER_TO_INT(method->data)); */
-/*                                     // Allow secure methods, e.g MD5 only */
-/*                                     if (modest_protocol_registry_protocol_type_is_secure(protocol_registry, proto)) */
-/*                                     { */
-/*                                             priv->protocol_authentication_incoming = proto; */
-/*                                             break; */
-/*                                     } */
-/*                             } */
-/*                             g_list_free (list_auth_methods); */
-/*                     } */
-
-/*                     if (list_auth_methods == NULL ||  */
-/*                         !modest_protocol_registry_protocol_type_is_secure(protocol_registry, priv->protocol_authentication_incoming)) */
-/*                     { */
-/*                             if(error == NULL || error->domain != modest_utils_get_supported_secure_authentication_error_quark() || */
-/*                                             error->code != MODEST_UTILS_GET_SUPPORTED_SECURE_AUTHENTICATION_ERROR_CANCELED) */
-/*                                     modest_platform_information_banner(GTK_WIDGET (self), NULL,  */
-/*                                                                    _("mcen_ib_unableto_discover_auth_methods")); */
-
-/*                             if(error != NULL) */
-/*                                     g_error_free(error); */
-                                       
-/*                             /\* This is a nasty hack. jschmid. *\/ */
-/*                             /\* Don't let the dialog close *\/ */
-/*                             /\*g_signal_stop_emission_by_name (dialog, "response");*\/ */
-/*                             return FALSE; */
-/*                     } */
-/*             } */
-/*     } */
-       
        return TRUE;
 }
 
@@ -1272,8 +1165,6 @@ modest_default_account_settings_dialog_load_settings (ModestAccountSettingsDialo
                            null_means_empty (modest_account_settings_get_fullname (settings)));
        gtk_entry_set_text( GTK_ENTRY (priv->entry_user_email), 
                            null_means_empty (modest_account_settings_get_email_address (settings)));
-       modest_retrieve_combo_box_set_active_retrieve_conf (MODEST_RETRIEVE_COMBO_BOX (priv->combo_retrieve), 
-                                                           modest_account_settings_get_retrieve_type (settings));
        modest_limit_retrieve_combo_box_set_active_limit_retrieve (
                MODEST_LIMIT_RETRIEVE_COMBO_BOX (priv->combo_limit_retrieve), 
                modest_account_settings_get_retrieve_limit (settings));
@@ -1288,7 +1179,9 @@ modest_default_account_settings_dialog_load_settings (ModestAccountSettingsDialo
                gchar *proto_name, *title;
                ModestProtocolType incoming_protocol;
 
-               modest_retrieve_combo_box_fill (MODEST_RETRIEVE_COMBO_BOX (priv->combo_retrieve), modest_server_account_settings_get_protocol (incoming_account));
+               modest_retrieve_picker_fill (MODEST_RETRIEVE_PICKER (priv->retrieve_picker), modest_server_account_settings_get_protocol (incoming_account));
+               modest_retrieve_picker_set_active_retrieve_conf (MODEST_RETRIEVE_PICKER (priv->retrieve_picker), 
+                                                                modest_account_settings_get_retrieve_type (settings));
                
                if (!modest_protocol_registry_protocol_type_has_leave_on_server (protocol_registry,
                                                                                 modest_server_account_settings_get_protocol (incoming_account))) {
@@ -1422,8 +1315,8 @@ save_configuration (ModestDefaultAccountSettingsDialog *dialog)
                modest_account_settings_set_signature (priv->settings, signature);
        }
        
-       retrieve_type = modest_retrieve_combo_box_get_active_retrieve_conf (
-               MODEST_RETRIEVE_COMBO_BOX (priv->combo_retrieve));
+       retrieve_type = modest_retrieve_picker_get_active_retrieve_conf (
+               MODEST_RETRIEVE_PICKER (priv->retrieve_picker));
        modest_account_settings_set_retrieve_type (priv->settings, retrieve_type);
        
        retrieve_limit = modest_limit_retrieve_combo_box_get_active_limit_retrieve (