Fixed a modality issue, use the window manager to set the signature dialog as modal
[modest] / src / maemo / modest-account-settings-dialog.c
index bb1701b..04b7e16 100644 (file)
@@ -137,9 +137,6 @@ modest_account_settings_dialog_finalize (GObject *object)
        if (self->account_manager)
                g_object_unref (G_OBJECT (self->account_manager));
                
-       if (self->specific_window)
-               gtk_widget_destroy (self->specific_window);
-               
        if (self->signature_dialog)
                gtk_widget_destroy (self->signature_dialog);
 
@@ -432,7 +429,8 @@ static void
 on_button_signature (GtkButton *button, gpointer user_data)
 {
        ModestAccountSettingsDialog * self = MODEST_ACCOUNT_SETTINGS_DIALOG (user_data);
-       
+       gint response;
+
        /* Create the window, if necessary: */
        if (!(self->signature_dialog)) {
                self->signature_dialog = GTK_WIDGET (modest_signature_editor_dialog_new ());
@@ -450,19 +448,19 @@ on_button_signature (GtkButton *button, gpointer user_data)
        }
 
        /* Show the window: */  
-       gtk_window_set_transient_for (GTK_WINDOW (self->signature_dialog), GTK_WINDOW (self));
-       gtk_window_set_modal (GTK_WINDOW (self->signature_dialog), TRUE);
-    const gint response = gtk_dialog_run (GTK_DIALOG (self->signature_dialog));
-    gtk_widget_hide (self->signature_dialog);
-    if (response != GTK_RESPONSE_OK) {
-       /* Destroy the widget now, and its data: */
-       gtk_widget_destroy (self->signature_dialog);
-       self->signature_dialog = NULL;
-    }
-    else {
-       /* Mark modified, so we use the dialog's data later: */
-       self->modified = TRUE;  
-    }
+       modest_window_mgr_set_modal (modest_runtime_get_window_mgr (),
+                                    GTK_WINDOW (self->signature_dialog));
+
+       response = gtk_dialog_run (GTK_DIALOG (self->signature_dialog));
+       gtk_widget_hide (self->signature_dialog);
+       if (response != GTK_RESPONSE_OK) {
+               /* Destroy the widget now, and its data: */
+               gtk_widget_destroy (self->signature_dialog);
+               self->signature_dialog = NULL;
+       } else {
+               /* Mark modified, so we use the dialog's data later: */
+               self->modified = TRUE;  
+       }
 }
 
 static GtkWidget*
@@ -523,6 +521,9 @@ create_page_user_details (ModestAccountSettingsDialog *self)
         * as required by our UI specification: */
        modest_validating_entry_set_unallowed_characters_whitespace (
                MODEST_VALIDATING_ENTRY (self->entry_user_username));
+       modest_validating_entry_set_func (MODEST_VALIDATING_ENTRY (self->entry_user_username), 
+                                         modest_maemo_utils_on_entry_invalid_character, 
+                                         self);
        
        /* Set max length as in the UI spec:
         * The UI spec seems to want us to show a dialog if we hit the maximum. */
@@ -715,18 +716,15 @@ static void
 on_button_outgoing_smtp_servers (GtkButton *button, gpointer user_data)
 {
        ModestAccountSettingsDialog * self = MODEST_ACCOUNT_SETTINGS_DIALOG (user_data);
-       
+       ModestConnectionSpecificSmtpWindow *smtp_win;
+
        /* Create the window if necessary: */
-       if (!(self->specific_window)) {
-               self->specific_window = GTK_WIDGET (modest_connection_specific_smtp_window_new ());
-               modest_connection_specific_smtp_window_fill_with_connections (
-                       MODEST_CONNECTION_SPECIFIC_SMTP_WINDOW (self->specific_window), self->account_manager);
-       }
+       smtp_win = modest_connection_specific_smtp_window_new ();
+       modest_connection_specific_smtp_window_fill_with_connections (smtp_win, self->account_manager);
 
        /* Show the window: */  
-       gtk_window_set_transient_for (GTK_WINDOW (self->specific_window), GTK_WINDOW (self));
-       gtk_window_set_modal (GTK_WINDOW (self->specific_window), TRUE);
-       gtk_widget_show (self->specific_window);
+       modest_window_mgr_set_modal (modest_runtime_get_window_mgr (), GTK_WINDOW (smtp_win));
+       gtk_widget_show (GTK_WIDGET (smtp_win));
        self->modified = TRUE;
 }
 
@@ -1044,7 +1042,7 @@ check_data (ModestAccountSettingsDialog *self)
                                if(error == NULL || error->domain != modest_utils_get_supported_secure_authentication_error_quark() ||
                                                error->code != MODEST_UTILS_GET_SUPPORTED_SECURE_AUTHENTICATION_ERROR_CANCELED)
                                        hildon_banner_show_information(GTK_WIDGET (self), NULL, 
-                                                                      _("Could not discover supported secure authentication methods."));
+                                                                      _("mcen_ib_unableto_discover_auth_methods"));
 
                                if(error != NULL)
                                        g_error_free(error);
@@ -1544,13 +1542,7 @@ save_configuration (ModestAccountSettingsDialog *dialog)
        if (account_name != NULL)
                modest_account_mgr_save_account_settings (dialog->account_manager, dialog->settings);
 
-       if (dialog->specific_window) {
-               return modest_connection_specific_smtp_window_save_server_accounts (
-                       MODEST_CONNECTION_SPECIFIC_SMTP_WINDOW (dialog->specific_window));
-       } else {
-               return TRUE;
-       }
-
+       return TRUE;
 }
 
 static gboolean entry_is_empty (GtkWidget *entry)
@@ -1621,6 +1613,33 @@ enable_buttons (ModestAccountSettingsDialog *self)
                                           enable_ok);
 }
 
+void
+modest_account_settings_dialog_check_allow_changes (ModestAccountSettingsDialog *self)
+{
+       ModestServerAccountSettings *incoming_settings;
+       const gchar *server_account_name;
+       gboolean username_known;
+
+       if (!G_IS_OBJECT (self->settings))
+               return;
+
+       incoming_settings = modest_account_settings_get_store_settings (self->settings);
+       server_account_name = modest_server_account_settings_get_account_name (incoming_settings);
+
+       username_known = modest_account_mgr_get_server_account_username_has_succeeded (self->account_manager, 
+                                                                                      server_account_name);
+
+       /* Enable or disable widgets */
+       gtk_widget_set_sensitive (self->entry_user_username, !username_known);
+       gtk_widget_set_sensitive (self->entry_incomingserver, !username_known);
+       /* gtk_widget_set_sensitive (self->entry_outgoingserver, !username_known); */
+       /* gtk_widget_set_sensitive (self->entry_outgoing_username, !username_known); */
+       gtk_widget_set_sensitive (self->entry_incoming_port, !username_known);
+/*     gtk_widget_set_sensitive (self->entry_outgoing_port, !username_known); */
+       gtk_widget_set_sensitive (self->combo_incoming_security, !username_known);
+/*     gtk_widget_set_sensitive (self->combo_outgoing_security, !username_known); */
+}
+
 void 
 modest_account_settings_dialog_set_modified (ModestAccountSettingsDialog *dialog, gboolean modified)
 {