Fixes NB#123383, unexpected lines appear in new email editor body area
[modest] / src / hildon2 / modest-easysetup-wizard-dialog.c
index e3236dd..d32e8ed 100644 (file)
@@ -407,7 +407,7 @@ create_page_welcome (ModestEasysetupWizardDialog *self)
 }
 
 static void
-on_account_country_selector_changed (HildonTouchSelector *widget, gint column, gpointer user_data)
+on_account_country_selector_changed (HildonTouchSelector *widget, gpointer user_data)
 {
        ModestEasysetupWizardDialog *self = MODEST_EASYSETUP_WIZARD_DIALOG (user_data);
        g_assert(self);
@@ -1253,9 +1253,8 @@ fill_providers (ModestEasysetupWizardDialog *self)
                modest_country_picker_load_data(
                        MODEST_COUNTRY_PICKER (priv->account_country_picker));
                /* connect to country picker's changed signal, so we can fill the provider picker: */
-               g_signal_connect (G_OBJECT (hildon_picker_button_get_selector
-                                           (HILDON_PICKER_BUTTON (priv->account_country_picker))),
-                                 "changed",
+               g_signal_connect ((GObject *) priv->account_country_picker,
+                                 "value-changed",
                                  G_CALLBACK (on_account_country_selector_changed), self);
 
                modest_country_picker_set_active_country_locale (
@@ -1568,17 +1567,31 @@ create_subsequent_easysetup_pages (ModestEasysetupWizardDialog *self)
 
 /* */
 static void
-remove_non_common_tabs (GtkNotebook *notebook,
+remove_non_common_tabs (ModestEasysetupWizardDialog *self,
                        gboolean remove_user_details)
 {
        gint starting_tab;
+       GtkNotebook *notebook;
+       ModestEasysetupWizardDialogPrivate *priv;
+
+       priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
+       g_object_get (self, "wizard-notebook", &notebook, NULL);
+
        /* The first 2 tabs are the common ones (welcome tab and the
           providers tab), so we always remove starting from the
           end */
-
        starting_tab = (remove_user_details) ? 2 : 3;
-       while (gtk_notebook_get_n_pages (notebook) > starting_tab)
+       while (gtk_notebook_get_n_pages (notebook) > starting_tab) {
+               /* Disconnect signal */
+               GtkWidget *page = gtk_notebook_get_nth_page (notebook, -1);
+               if (modest_signal_mgr_is_connected (priv->missing_data_signals, (GObject *) page, "missing-mandatory-data")) {
+                       priv->missing_data_signals = modest_signal_mgr_disconnect (priv->missing_data_signals,
+                                                                                  (GObject *) page,
+                                                                                  "missing-mandatory-data");
+               }
+               /* Remove page from notebook */
                gtk_notebook_remove_page (notebook, -1);
+       }
 }
 
 static void
@@ -1605,8 +1618,12 @@ create_subsequent_pages (ModestEasysetupWizardDialog *self)
        picker = MODEST_PROVIDER_PICKER (priv->account_serviceprovider_picker);
        id_type = modest_provider_picker_get_active_id_type (picker);
        g_object_get (self, "wizard-notebook", &notebook, NULL);
-       modest_wizard_dialog_set_response_override_handler (MODEST_WIZARD_DIALOG (self),
-                                                           NULL);
+
+       /* Remove the response override handler for non-plugin
+          protocols. For plugins it'll be overriden later */
+       if (id_type != MODEST_PROVIDER_PICKER_ID_PLUGIN_PROTOCOL)
+               modest_wizard_dialog_set_response_override_handler (MODEST_WIZARD_DIALOG (self),
+                                                                   NULL);
 
 
        if (id_type == MODEST_PROVIDER_PICKER_ID_OTHER) {
@@ -1614,13 +1631,13 @@ create_subsequent_pages (ModestEasysetupWizardDialog *self)
 
                /* If we come from a rollbacked easysetup */
                if (priv->page_complete_easysetup) {
-                       remove_non_common_tabs (notebook, FALSE);
+                       remove_non_common_tabs (self, FALSE);
                        priv->page_complete_easysetup = NULL;
                }
 
                /* If we come from a rollbacked plugin protocol setup */
                if (priv->last_plugin_protocol_selected != MODEST_PROTOCOL_REGISTRY_TYPE_INVALID) {
-                       remove_non_common_tabs (notebook, TRUE);
+                       remove_non_common_tabs (self, TRUE);
                        priv->last_plugin_protocol_selected = MODEST_PROTOCOL_REGISTRY_TYPE_INVALID;
                        modest_signal_mgr_disconnect_all_and_destroy (priv->missing_data_signals);
                        priv->missing_data_signals = NULL;
@@ -1630,7 +1647,7 @@ create_subsequent_pages (ModestEasysetupWizardDialog *self)
        } else {
                /* If we come from a rollbacked custom setup */
                if (priv->page_custom_incoming) {
-                       remove_non_common_tabs (notebook, TRUE);
+                       remove_non_common_tabs (self, TRUE);
                        init_user_page (priv);
                        init_incoming_page (priv);
                        init_outgoing_page (priv);
@@ -1643,6 +1660,7 @@ create_subsequent_pages (ModestEasysetupWizardDialog *self)
                        ModestProtocol *protocol;
                        gchar *proto_name;
                        ModestProtocolType proto_type;
+                       ModestWizardDialogResponseOverrideFunc response_override;
 
                        /* Get protocol data */
                        proto_name = modest_provider_picker_get_active_provider_id (picker);
@@ -1655,27 +1673,30 @@ create_subsequent_pages (ModestEasysetupWizardDialog *self)
                        /* If we come from a rollbacked easy setup */
                        if (priv->last_plugin_protocol_selected != proto_type &&
                            priv->page_complete_easysetup) {
-                               remove_non_common_tabs (notebook, TRUE);
+                               remove_non_common_tabs (self, TRUE);
                                init_user_page (priv);
                                priv->page_complete_easysetup = NULL;
                        }
 
+                       /* Ensure that the response override handler
+                          is set. It might happen that plugins clear
+                          them incorrectly */
+                       response_override = modest_account_protocol_get_wizard_response_override
+                               (MODEST_ACCOUNT_PROTOCOL (protocol));
+                       modest_wizard_dialog_set_response_override_handler (MODEST_WIZARD_DIALOG (self),
+                                                                           response_override);
+
                        if (protocol && MODEST_IS_ACCOUNT_PROTOCOL (protocol) &&
                            proto_type != priv->last_plugin_protocol_selected) {
                                ModestPairList *tabs;
                                GSList *tmp;
                                gboolean first_page = TRUE;
-                               ModestWizardDialogResponseOverrideFunc response_override;
 
                                /* Remember the last selected plugin protocol */
                                priv->last_plugin_protocol_selected = proto_type;
 
                                /* Get tabs */
                                tabs = modest_account_protocol_get_easysetupwizard_tabs (MODEST_ACCOUNT_PROTOCOL (protocol));
-                               response_override = modest_account_protocol_get_wizard_response_override
-                                       (MODEST_ACCOUNT_PROTOCOL (protocol));
-                               modest_wizard_dialog_set_response_override_handler (MODEST_WIZARD_DIALOG (self),
-                                                                                   response_override);
                                tmp = (GSList *) tabs;
                                while (tmp) {
                                        ModestPair *pair = (ModestPair *) tmp->data;
@@ -1709,7 +1730,7 @@ create_subsequent_pages (ModestEasysetupWizardDialog *self)
                } else {
                        if (priv->last_plugin_protocol_selected !=
                            MODEST_PROTOCOL_REGISTRY_TYPE_INVALID) {
-                               remove_non_common_tabs (notebook, TRUE);
+                               remove_non_common_tabs (self, TRUE);
                                init_user_page (priv);
                                priv->page_complete_easysetup = NULL;
                                priv->last_plugin_protocol_selected = MODEST_PROTOCOL_REGISTRY_TYPE_INVALID;