From 3266fbf87e009daf846687835198f80ae3a2d923 Mon Sep 17 00:00:00 2001 From: Murray Cumming Date: Fri, 6 Apr 2007 12:23:31 +0000 Subject: [PATCH] 2007-04-06 Murray Cumming * src/maemo/easysetup/modest-easysetup-wizard.c: (create_account): Set the email address and user fullname, which I now see must be done separately. * src/maemo/modest-account-settings-dialog.h: * src/maemo/modest-account-settings-dialog.c: (on_response), (modest_account_settings_dialog_set_account_name): Show the email address, fullname, leave-on-server and authentication. (save_configuration): Save most of the non-server-account specific stuff, but I don't see how to do the rest. pmo-trunk-r1522 --- ChangeLog2 | 14 ++++++ src/maemo/easysetup/modest-easysetup-wizard.c | 11 +++++ src/maemo/modest-account-settings-dialog.c | 60 ++++++++++++++++++++++++- src/maemo/modest-account-settings-dialog.h | 2 + 4 files changed, 85 insertions(+), 2 deletions(-) diff --git a/ChangeLog2 b/ChangeLog2 index b5a161d..af2e535 100644 --- a/ChangeLog2 +++ b/ChangeLog2 @@ -1,5 +1,19 @@ 2007-04-06 Murray Cumming + * src/maemo/easysetup/modest-easysetup-wizard.c: (create_account): + Set the email address and user fullname, which I now see must be + done separately. + + * src/maemo/modest-account-settings-dialog.h: + * src/maemo/modest-account-settings-dialog.c: + (on_response), + (modest_account_settings_dialog_set_account_name): Show the email address, fullname, + leave-on-server and authentication. + (save_configuration): Save most of the non-server-account specific stuff, but I don't see + how to do the rest. + +2007-04-06 Murray Cumming + * src/maemo/modest-account-settings-dialog.c: * src/maemo/modest-account-settings-dialog.h: diff --git a/src/maemo/easysetup/modest-easysetup-wizard.c b/src/maemo/easysetup/modest-easysetup-wizard.c index 661f6ae..8290bc7 100644 --- a/src/maemo/easysetup/modest-easysetup-wizard.c +++ b/src/maemo/easysetup/modest-easysetup-wizard.c @@ -1352,6 +1352,17 @@ create_account (ModestEasysetupWizardDialog *self) return FALSE; } + /* The user name and email address must be set additionally: */ + const gchar* user_name = gtk_entry_get_text (GTK_ENTRY (self->entry_user_name)); + modest_account_mgr_set_string (self->account_manager, account_name, + MODEST_ACCOUNT_FULLNAME, user_name, FALSE /* not server account */); + + const gchar* emailaddress = gtk_entry_get_text (GTK_ENTRY (self->entry_user_email)); + modest_account_mgr_set_string (self->account_manager, account_name, + MODEST_ACCOUNT_EMAIL, emailaddress, FALSE /* not server account */); + + /* TODO: Should we set MODEST_ACCOUNT_DISPLAY_NAME? It's not clear what it is. */ + return FALSE; } diff --git a/src/maemo/modest-account-settings-dialog.c b/src/maemo/modest-account-settings-dialog.c index 8a37e2a..e7356f2 100644 --- a/src/maemo/modest-account-settings-dialog.c +++ b/src/maemo/modest-account-settings-dialog.c @@ -52,6 +52,9 @@ static void enable_buttons (ModestAccountSettingsDialog *self); static void +save_configuration (ModestAccountSettingsDialog *dialog); + +static void modest_account_settings_dialog_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec) { @@ -83,6 +86,9 @@ modest_account_settings_dialog_finalize (GObject *object) { ModestAccountSettingsDialog *self = MODEST_ACCOUNT_SETTINGS_DIALOG (object); + if (self->original_account_name) + g_free (self->original_account_name); + if (self->account_manager) g_object_unref (G_OBJECT (self->account_manager)); @@ -572,6 +578,11 @@ on_response (GtkDialog *wizard_dialog, { ModestAccountSettingsDialog *self = MODEST_ACCOUNT_SETTINGS_DIALOG (wizard_dialog); enable_buttons (self); + + /* TODO: Prevent the OK response if the data is invalid. */ + + if (response_id == GTK_RESPONSE_OK) + save_configuration (self); } static void @@ -632,6 +643,15 @@ modest_account_settings_dialog_new (void) */ void modest_account_settings_dialog_set_account_name (ModestAccountSettingsDialog *dialog, const gchar* account_name) { + if (!account_name) + return; + + /* Save the account name so we can refer to it if the user changes it: */ + if (dialog->original_account_name) + g_free (dialog->original_account_name); + dialog->original_account_name = g_strdup (account_name); + + /* Get the account data for this account name: */ ModestAccountData *account_data = modest_account_mgr_get_account_data (dialog->account_manager, account_name); if (!account_data) { @@ -644,13 +664,19 @@ void modest_account_settings_dialog_set_account_name (ModestAccountSettingsDialo return; } + /* Show the account data in the widgets: */ gtk_entry_set_text( GTK_ENTRY (dialog->entry_account_title), account_name ? account_name : ""); gtk_entry_set_text( GTK_ENTRY (dialog->entry_user_name), - account_data->fullname ? account_data->fullname : ""); /* TODO: Not working. */ - gtk_entry_set_text( GTK_ENTRY (dialog->entry_user_email), /* TODO: Not working. */ + account_data->fullname ? account_data->fullname : ""); + gtk_entry_set_text( GTK_ENTRY (dialog->entry_user_email), account_data->email ? account_data->email : ""); + const gboolean leave_on_server = modest_account_mgr_get_bool (dialog->account_manager, account_name, + MODEST_ACCOUNT_LEAVE_ON_SERVER, FALSE /* not server account */); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->checkbox_leave_messages), leave_on_server); + + ModestServerAccountData *incoming_account = account_data->store_account; if (incoming_account) { gtk_entry_set_text( GTK_ENTRY (dialog->entry_user_username), @@ -706,6 +732,36 @@ void modest_account_settings_dialog_set_account_name (ModestAccountSettingsDialo modest_account_mgr_free_account_data (dialog->account_manager, account_data); } + +static void +save_configuration (ModestAccountSettingsDialog *dialog) +{ + g_assert (dialog->original_account_name); + + const gchar* account_name = dialog->original_account_name; + + /* Set the account data from the widgets: */ + const gchar* user_name = gtk_entry_get_text (GTK_ENTRY (dialog->entry_user_name)); + modest_account_mgr_set_string (dialog->account_manager, account_name, + MODEST_ACCOUNT_FULLNAME, user_name, FALSE /* not server account */); + + const gchar* emailaddress = gtk_entry_get_text (GTK_ENTRY (dialog->entry_user_email)); + modest_account_mgr_set_string (dialog->account_manager, account_name, + MODEST_ACCOUNT_EMAIL, emailaddress, FALSE /* not server account */); + + /* TODO: Change name: */ + /* Possibly the account name may never change, but that should be hidden, + * and the display name may change, defaulting to the account name. + */ + + const gboolean leave_on_server = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->checkbox_leave_messages)); + modest_account_mgr_set_bool (dialog->account_manager, account_name, + MODEST_ACCOUNT_LEAVE_ON_SERVER, leave_on_server, FALSE /* not server account */); + + + /* TODO: How can we change the incoming and outgoing server account details? */ +} + #if 0 static gboolean diff --git a/src/maemo/modest-account-settings-dialog.h b/src/maemo/modest-account-settings-dialog.h index 7413a4e..5e5912d 100644 --- a/src/maemo/modest-account-settings-dialog.h +++ b/src/maemo/modest-account-settings-dialog.h @@ -41,6 +41,8 @@ typedef struct { * and to create new accounts: */ ModestAccountMgr *account_manager; + gchar * original_account_name; + GtkWidget *page_account_details; GtkWidget *entry_account_title; GtkWidget *checkbox_leave_messages; -- 1.7.9.5