From 548fd25b34e6ecf04f677a632d88b4f32158966d Mon Sep 17 00:00:00 2001 From: Johannes Schmid Date: Mon, 11 Jun 2007 21:21:33 +0000 Subject: [PATCH 1/1] 2007-06-11 Johannes Schmid * src/maemo/modest-maemo-utils.c: (modest_maemo_utils_get_supported_secure_authentication_methods): Added label to dialog instead of unreadable title * src/maemo/modest-main-window.c: (sync_accounts_cb), (modest_main_window_new): Fixed projects.maemo.org bug NB#58576 by moving previous fix out of dead code. * src/modest-account-mgr.c: (modest_account_mgr_has_accounts): * src/modest-account-mgr.h: Added method to avoid code duplication * src/modest-ui-actions.c: (modest_ui_actions_on_accounts), (modest_ui_actions_on_send_receive): Use modest_account_mgr_has_accounts pmo-trunk-r2165 --- ChangeLog2 | 19 +++++++++++++++++++ src/maemo/modest-maemo-utils.c | 8 +++++--- src/maemo/modest-main-window.c | 14 +++++++++++++- src/modest-account-mgr.c | 12 ++++++++++++ src/modest-account-mgr.h | 12 ++++++++++++ src/modest-ui-actions.c | 14 +++++--------- 6 files changed, 66 insertions(+), 13 deletions(-) diff --git a/ChangeLog2 b/ChangeLog2 index 6d28fed..46e2c5f 100644 --- a/ChangeLog2 +++ b/ChangeLog2 @@ -1,3 +1,22 @@ +2007-06-11 Johannes Schmid + + * src/maemo/modest-maemo-utils.c: + (modest_maemo_utils_get_supported_secure_authentication_methods): + Added label to dialog instead of unreadable title + + * src/maemo/modest-main-window.c: (sync_accounts_cb), + (modest_main_window_new): + Fixed projects.maemo.org bug NB#58576 by moving previous fix out of + dead code. + + * src/modest-account-mgr.c: (modest_account_mgr_has_accounts): + * src/modest-account-mgr.h: + Added method to avoid code duplication + + * src/modest-ui-actions.c: (modest_ui_actions_on_accounts), + (modest_ui_actions_on_send_receive): + Use modest_account_mgr_has_accounts + 2007-06-11 Murray Cumming * src/maemo/easysetup/modest-presets.c: diff --git a/src/maemo/modest-maemo-utils.c b/src/maemo/modest-maemo-utils.c index 43b3e73..d45f1d8 100644 --- a/src/maemo/modest-maemo-utils.c +++ b/src/maemo/modest-maemo-utils.c @@ -383,17 +383,19 @@ GList* modest_maemo_utils_get_supported_secure_authentication_methods (ModestTra info->result = NULL; info->cancel = FALSE; info->progress = gtk_progress_bar_new(); - info->dialog = gtk_dialog_new_with_buttons(_("Checking for supported authentication types"), + info->dialog = gtk_dialog_new_with_buttons(_("Authentication"), parent_window, GTK_DIALOG_MODAL, GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, NULL); + //gtk_window_set_default_size(GTK_WINDOW(info->dialog), 300, 100); g_signal_connect(G_OBJECT(info->dialog), "response", G_CALLBACK(on_secure_auth_cancel), info); + gtk_container_add(GTK_CONTAINER(GTK_DIALOG(info->dialog)->vbox), + gtk_label_new("Checking for supported authentication types...")); gtk_container_add(GTK_CONTAINER(GTK_DIALOG(info->dialog)->vbox), info->progress); - gtk_widget_show(info->progress); - gtk_widget_show(info->dialog); + gtk_widget_show_all(info->dialog); gtk_progress_bar_pulse(GTK_PROGRESS_BAR(info->progress)); printf ("DEBUG: %s: STARTING.\n", __FUNCTION__); diff --git a/src/maemo/modest-main-window.c b/src/maemo/modest-main-window.c index 43b8a84..6068f0a 100644 --- a/src/maemo/modest-main-window.c +++ b/src/maemo/modest-main-window.c @@ -564,7 +564,7 @@ connect_signals (ModestMainWindow *self) gboolean sync_accounts_cb (ModestMainWindow *win) { - modest_ui_actions_on_send_receive (NULL, MODEST_WINDOW (win)); + modest_ui_actions_do_send_receive (NULL, MODEST_WINDOW (win)); return FALSE; /* Do not call this idle handler again. */ } #endif @@ -769,6 +769,18 @@ modest_main_window_new (void) tny_account_store_view_set_account_store (TNY_ACCOUNT_STORE_VIEW (priv->folder_view), TNY_ACCOUNT_STORE (modest_runtime_get_account_store ())); + /* Check if accounts exist and show the account wizard if not */ + gboolean accounts_exist = + modest_account_mgr_has_accounts(modest_runtime_get_account_mgr(), TRUE); + + if (!accounts_exist) + { + /* This is necessary to have the main window shown behind the dialog + It's an ugly hack... jschmid */ + gtk_widget_show_all(GTK_WIDGET(self)); + modest_ui_actions_on_accounts (NULL, MODEST_WINDOW(self)); + } + /* Do send & receive when we are idle */ /* TODO: Enable this again. I have commented it out because, * at least in scratchbox, this can cause us to start a second diff --git a/src/modest-account-mgr.c b/src/modest-account-mgr.c index f5bde23..0c9da01 100644 --- a/src/modest-account-mgr.c +++ b/src/modest-account-mgr.c @@ -1163,3 +1163,15 @@ _modest_account_mgr_get_account_keyname (const gchar *account_name, const gchar return retval; } + +gboolean +modest_account_mgr_has_accounts (ModestAccountMgr* self, gboolean enabled) +{ + /* Check that at least one account exists: */ + GSList *account_names = modest_account_mgr_account_names (self, + enabled); + gboolean accounts_exist = account_names != NULL; + g_slist_free (account_names); + + return accounts_exist; +} diff --git a/src/modest-account-mgr.h b/src/modest-account-mgr.h index 580be8a..90237c0 100644 --- a/src/modest-account-mgr.h +++ b/src/modest-account-mgr.h @@ -428,6 +428,18 @@ gboolean modest_account_mgr_unset (ModestAccountMgr *self, const gchar *key, gboolean server_account); +/** + * modest_account_mgr_has_accounts: + * @self: a ModestAccountMgr instance + * @enabled: TRUE to search for enabled accounts only + * + * Checks if any accounts exist + * + * Returns: TRUE if accounts exist, FALSE otherwise + */ + +gboolean modest_account_mgr_has_accounts (ModestAccountMgr* self, gboolean enabled); + G_END_DECLS #endif /* __MODEST_ACCOUNT_MGR_H__ */ diff --git a/src/modest-ui-actions.c b/src/modest-ui-actions.c index 74335fe..c7f8b43 100644 --- a/src/modest-ui-actions.c +++ b/src/modest-ui-actions.c @@ -369,10 +369,8 @@ modest_ui_actions_on_accounts (GtkAction *action, ModestWindow *win) * because it requires a providers preset file which is not publically available. */ #ifdef MODEST_PLATFORM_MAEMO /* Defined in config.h */ - GSList *account_names = modest_account_mgr_account_names (modest_runtime_get_account_mgr(), - TRUE /* enabled accounts only */); - gboolean accounts_exist = account_names != NULL; - g_slist_free (account_names); + gboolean accounts_exist = modest_account_mgr_has_accounts( + modest_runtime_get_account_mgr(), TRUE); if (!accounts_exist) { /* If there are no accounts yet, just show the easy-setup wizard, as per the UI spec: */ @@ -1115,11 +1113,9 @@ modest_ui_actions_do_send_receive_all (ModestWindow *win) void modest_ui_actions_on_send_receive (GtkAction *action, ModestWindow *win) { - /* Check that at least one account exists: */ - GSList *account_names = modest_account_mgr_account_names (modest_runtime_get_account_mgr(), - TRUE /* enabled accounts only */); - gboolean accounts_exist = account_names != NULL; - g_slist_free (account_names); + /* Check if accounts exist */ + gboolean accounts_exist = + modest_account_mgr_has_accounts(modest_runtime_get_account_mgr(), TRUE); /* If not, allow the user to create an account before trying to send/receive. */ if (!accounts_exist) -- 1.7.9.5