GNOME version compiles again. It does not link yet though, because there are some...
[modest] / src / maemo / modest-default-account-settings-dialog.c
index e4d8b51..eb41e84 100644 (file)
@@ -115,7 +115,6 @@ struct _ModestDefaultAccountSettingsDialogPrivate
        GtkWidget *entry_user_username;
        GtkWidget *entry_user_password;
        GtkWidget *entry_user_email;
-/*     GtkWidget *entry_incoming_port; */
        GtkWidget *button_signature;
        
        GtkWidget *page_complete_easysetup;
@@ -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;
        
@@ -507,7 +497,8 @@ on_button_signature (GtkButton *button, gpointer user_data)
 
        /* Show the window: */  
        modest_window_mgr_set_modal (modest_runtime_get_window_mgr (),
-                                    GTK_WINDOW (priv->signature_dialog));
+                                    GTK_WINDOW (priv->signature_dialog),
+                                    GTK_WINDOW (self));
 
        response = gtk_dialog_run (GTK_DIALOG (priv->signature_dialog));
        gtk_widget_hide (priv->signature_dialog);
@@ -776,7 +767,8 @@ on_button_outgoing_smtp_servers (GtkButton *button, gpointer user_data)
        modest_connection_specific_smtp_window_fill_with_connections (smtp_win, priv->account_manager);
 
        /* Show the window: */  
-       modest_window_mgr_set_modal (modest_runtime_get_window_mgr (), GTK_WINDOW (smtp_win));
+       modest_window_mgr_set_modal (modest_runtime_get_window_mgr (), 
+                                    GTK_WINDOW (smtp_win), GTK_WINDOW (self));
        gtk_widget_show (GTK_WIDGET (smtp_win));
        priv->modified = TRUE;
 }
@@ -1057,7 +1049,27 @@ check_data (ModestDefaultAccountSettingsDialog *self)
        return TRUE;
 }
 
-static void 
+static gboolean
+on_delete_event (GtkWidget *widget,
+                 GdkEvent  *event,
+                 gpointer   user_data)
+{
+       ModestDefaultAccountSettingsDialog *self = MODEST_DEFAULT_ACCOUNT_SETTINGS_DIALOG (user_data);
+       ModestDefaultAccountSettingsDialogPrivate *priv;
+       ModestSecurityOptionsView *incoming_sec, *outgoing_sec;
+
+       priv = MODEST_DEFAULT_ACCOUNT_SETTINGS_DIALOG_GET_PRIVATE (self);
+
+       /* Check if security widgets changed */
+       incoming_sec = MODEST_SECURITY_OPTIONS_VIEW (priv->incoming_security);
+       outgoing_sec = MODEST_SECURITY_OPTIONS_VIEW (priv->outgoing_security);
+
+       return modest_security_options_view_changed (incoming_sec, priv->settings) ||
+               modest_security_options_view_changed (outgoing_sec, priv->settings) ||
+               priv->modified;
+}
+
+static void
 on_response (GtkDialog *wizard_dialog,
             gint response_id,
             gpointer user_data)
@@ -1078,14 +1090,14 @@ on_response (GtkDialog *wizard_dialog,
                modest_security_options_view_changed (outgoing_sec, priv->settings);
 
        /* Warn about unsaved changes: */
-       if (response_id == GTK_RESPONSE_CANCEL && (priv->modified || sec_changed)) {
+       if ((response_id == GTK_RESPONSE_CANCEL || response_id == GTK_RESPONSE_DELETE_EVENT) && 
+           (priv->modified || sec_changed)) {
                GtkDialog *dialog = GTK_DIALOG (hildon_note_new_confirmation (GTK_WINDOW (self), 
                        _("imum_nc_wizard_confirm_lose_changes")));
-               /* TODO: These button names will be ambiguous, and not specified in the UI specification. */
-                
+
                 const gint dialog_response = gtk_dialog_run (dialog);
                 gtk_widget_destroy (GTK_WIDGET (dialog));
-                
+
                if (dialog_response != GTK_RESPONSE_OK)
                        prevent_response = TRUE;
        }
@@ -1093,14 +1105,16 @@ on_response (GtkDialog *wizard_dialog,
        else if (response_id != GTK_RESPONSE_CANCEL && !check_data (self)) {
                prevent_response = TRUE;
        }
-               
+
        if (prevent_response) {
                /* This is a nasty hack. murrayc. */
                /* Don't let the dialog close */
                g_signal_stop_emission_by_name (wizard_dialog, "response");
                return; 
+       } else {
+               modest_tny_account_store_set_send_mail_blocked (modest_runtime_get_account_store (), FALSE);
        }
-               
+
        if (response_id == GTK_RESPONSE_OK) {
                /* Try to save the changes if modified (NB #59251): */
                if (priv->modified || sec_changed) {
@@ -1120,7 +1134,7 @@ on_response (GtkDialog *wizard_dialog,
                                        transport_settings = modest_account_settings_get_transport_settings (priv->settings);
                                        store_account_name = modest_server_account_settings_get_account_name (store_settings);
                                        transport_account_name = modest_server_account_settings_get_account_name (transport_settings);
-                                       
+
                                        if (store_account_name) {
                                                modest_account_mgr_notify_account_update (priv->account_manager, 
                                                                                          store_account_name);
@@ -1131,7 +1145,7 @@ on_response (GtkDialog *wizard_dialog,
                                        }
                                        g_object_unref (store_settings);
                                        g_object_unref (transport_settings);
-                                       
+
                                        modest_platform_information_banner(NULL, NULL, _("mcen_ib_advsetup_settings_saved"));
                                }
                        } else {
@@ -1186,25 +1200,29 @@ modest_default_account_settings_dialog_init (ModestDefaultAccountSettingsDialog
        gtk_container_add (GTK_CONTAINER (dialog->vbox), GTK_WIDGET (priv->notebook));
        gtk_container_set_border_width (GTK_CONTAINER (dialog->vbox), MODEST_MARGIN_HALF);
        gtk_widget_show (GTK_WIDGET (priv->notebook));
-        
+
     /* Add the buttons: */
     gtk_dialog_add_button (GTK_DIALOG(self), _("mcen_bd_dialog_ok"), GTK_RESPONSE_OK);
     gtk_dialog_add_button (GTK_DIALOG(self), _("mcen_bd_dialog_cancel"), GTK_RESPONSE_CANCEL);
-    
+
     /* Connect to the dialog's response signal: */
-    /* We use connect-before 
-     * so we can stop the signal emission, 
+    /* We use connect-before
+     * so we can stop the signal emission,
      * to stop the default signal handler from closing the dialog.
      */
-    g_signal_connect (G_OBJECT (self), "response",
-            G_CALLBACK (on_response), self); 
-            
+    g_signal_connect (G_OBJECT (self), "response", G_CALLBACK (on_response), self);
+    g_signal_connect (G_OBJECT (self), "delete-event", G_CALLBACK (on_delete_event), self);
+
     priv->modified = FALSE;
 
-    /* When this window is shown, hibernation should not be possible, 
+    /* When this window is shown, hibernation should not be possible,
         * because there is no sensible way to save the state: */
     modest_window_mgr_prevent_hibernation_while_window_is_shown (
-       modest_runtime_get_window_mgr (), GTK_WINDOW (self)); 
+       modest_runtime_get_window_mgr (), GTK_WINDOW (self));
+
+    /* Prevent sending mails while editing an account, to avoid hangs on unprotected locks
+     * while sending messages causes an error dialog and we have a lock */
+    modest_tny_account_store_set_send_mail_blocked (modest_runtime_get_account_store (), TRUE);
 
     hildon_help_dialog_help_enable (GTK_DIALOG(self), "applications_email_accountsettings",
                                    modest_maemo_utils_get_osso_context());