* Fixes #84315, do not enable the user to change some parametters if there was a...
authorSergio Villar Senin <svillar@igalia.com>
Wed, 16 Apr 2008 10:45:35 +0000 (10:45 +0000)
committerSergio Villar Senin <svillar@igalia.com>
Wed, 16 Apr 2008 10:45:35 +0000 (10:45 +0000)
pmo-trunk-r4420

src/gnome/modest-account-settings-dialog.c
src/maemo/modest-account-settings-dialog.c
src/modest-account-mgr-helpers.c
src/modest-tny-account-store.c
src/widgets/modest-account-settings-dialog.h

index 1c095b6..c234fff 100644 (file)
@@ -1605,6 +1605,29 @@ enable_buttons (ModestAccountSettingsDialog *self)
 }
 
 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 (incomming_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);
+}
+
+void
 modest_account_settings_dialog_save_password (ModestAccountSettingsDialog *dialog)
 {
        g_return_if_fail (MODEST_IS_ACCOUNT_SETTINGS_DIALOG (dialog));
index 0d83c49..e501233 100644 (file)
@@ -1624,6 +1624,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)
 {
index dd203f4..1542e83 100644 (file)
@@ -515,10 +515,6 @@ modest_account_mgr_save_server_settings (ModestAccountMgr *self,
                                                                           protocol, TRUE));
        }
 
-       if (!has_errors) {
-         modest_account_mgr_set_server_account_username_has_succeeded (self, account_name, FALSE);
-       }
-
        return !has_errors;
 
 }
index 3de8134..23aff8b 100644 (file)
@@ -2007,9 +2007,10 @@ modest_tny_account_store_show_account_settings_dialog (ModestTnyAccountStore *se
        found = g_hash_table_lookup_extended (priv->account_settings_dialog_hash,
                                              account_name, NULL, (gpointer*)&dialog_as_gpointer);
 
-       if (found)
+       if (found) {
+               modest_account_settings_dialog_check_allow_changes ((ModestAccountSettingsDialog *) dialog_as_gpointer);
                return (GtkWidget *) dialog_as_gpointer;
-       else {
+       } else {
                ModestAccountSettings *settings;
                GtkWidget *dialog;
                dialog = (GtkWidget *) modest_account_settings_dialog_new ();
@@ -2017,6 +2018,7 @@ modest_tny_account_store_show_account_settings_dialog (ModestTnyAccountStore *se
                modest_account_settings_dialog_set_account (MODEST_ACCOUNT_SETTINGS_DIALOG (dialog), settings);
                g_object_unref (settings);
                modest_account_settings_dialog_switch_to_user_info (MODEST_ACCOUNT_SETTINGS_DIALOG (dialog));
+               modest_account_settings_dialog_check_allow_changes (MODEST_ACCOUNT_SETTINGS_DIALOG (dialog));
                modest_window_mgr_set_modal (modest_runtime_get_window_mgr (), GTK_WINDOW (dialog));
                
                g_hash_table_insert (priv->account_settings_dialog_hash, g_strdup (account_name), dialog);
index 5e6bd1c..2d15ce9 100644 (file)
@@ -110,6 +110,7 @@ void modest_account_settings_dialog_set_modified (ModestAccountSettingsDialog *d
 
 void modest_account_settings_dialog_save_password (ModestAccountSettingsDialog *dialog);
 
+void modest_account_settings_dialog_check_allow_changes (ModestAccountSettingsDialog *self);
 G_END_DECLS
 
 #endif /* _MODEST_ACCOUNT_SETTINGS_DIALOG */