From: Dirk-Jan C. Binnema Date: Thu, 14 Jun 2007 09:32:36 +0000 (+0000) Subject: * always check accounts are set up before opening the editor; if none are X-Git-Tag: git_migration_finished~3291 X-Git-Url: http://git.maemo.org/git/?p=modest;a=commitdiff_plain;h=18e2fbaf1e8f82b90becd8e8425018b2e7b09c18 * always check accounts are set up before opening the editor; if none are specified, open the account wizard * make sure the editor cannot be opened with a NULL account * Fixes: NB#55368 pmo-trunk-r2221 --- diff --git a/src/maemo/modest-main-window.c b/src/maemo/modest-main-window.c index c5b2e70..c0e44dd 100644 --- a/src/maemo/modest-main-window.c +++ b/src/maemo/modest-main-window.c @@ -643,29 +643,29 @@ modest_main_window_on_show (GtkWidget *self, gpointer user_data) TNY_ACCOUNT_STORE (modest_runtime_get_account_store ())); + + wrap_in_scrolled_window (folder_win, GTK_WIDGET(priv->folder_view)); + wrap_in_scrolled_window (priv->contents_widget, GTK_WIDGET(priv->header_view)); + + /* Load previous osso state, for instance if we are being restored from + * hibernation: */ + modest_osso_load_state(); + + /* Restore window & widget settings */ + + restore_settings (MODEST_MAIN_WINDOW(self), TRUE); + /* 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) - { + 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)); } - wrap_in_scrolled_window (folder_win, GTK_WIDGET(priv->folder_view)); - wrap_in_scrolled_window (priv->contents_widget, GTK_WIDGET(priv->header_view)); - - /* Load previous osso state, for instance if we are being restored from - * hibernation: */ - modest_osso_load_state(); - - /* Restore window & widget settings */ - - restore_settings (MODEST_MAIN_WINDOW(self), TRUE); } ModestWindow* @@ -836,7 +836,7 @@ modest_main_window_new (void) G_CALLBACK (on_hildon_program_is_topmost_notify), self); g_signal_connect (G_OBJECT(self), "show", - G_CALLBACK (modest_main_window_on_show), folder_win); + G_CALLBACK (modest_main_window_on_show), folder_win); restore_settings (MODEST_MAIN_WINDOW(self), FALSE); diff --git a/src/maemo/modest-msg-edit-window.c b/src/maemo/modest-msg-edit-window.c index b70cda1..559d027 100644 --- a/src/maemo/modest-msg-edit-window.c +++ b/src/maemo/modest-msg-edit-window.c @@ -833,6 +833,7 @@ modest_msg_edit_window_new (TnyMsg *msg, const gchar *account_name) gint file_format; g_return_val_if_fail (msg, NULL); + g_return_val_if_fail (account_name, NULL); obj = g_object_new(MODEST_TYPE_MSG_EDIT_WINDOW, NULL); @@ -880,7 +881,8 @@ modest_msg_edit_window_new (TnyMsg *msg, const gchar *account_name) g_object_unref (action_group); /* Load the UI definition */ - gtk_ui_manager_add_ui_from_file (parent_priv->ui_manager, MODEST_UIDIR "modest-msg-edit-window-ui.xml", &error); + gtk_ui_manager_add_ui_from_file (parent_priv->ui_manager, MODEST_UIDIR "modest-msg-edit-window-ui.xml", + &error); if (error != NULL) { g_warning ("Could not merge modest-msg-edit-window-ui.xml: %s", error->message); g_clear_error (&error); diff --git a/src/modest-ui-actions.c b/src/modest-ui-actions.c index 2658dcd..38fdd3d 100644 --- a/src/modest-ui-actions.c +++ b/src/modest-ui-actions.c @@ -128,6 +128,20 @@ static void _on_send_receive_progress_changed (ModestMailOperation *mail_op +static void +run_account_setup_wizard (ModestWindow *win) +{ + ModestEasysetupWizardDialog *wizard; + + g_return_if_fail (MODEST_IS_WINDOW(win)); + + wizard = modest_easysetup_wizard_dialog_new (); + gtk_window_set_transient_for (GTK_WINDOW (wizard), GTK_WINDOW (win)); + gtk_dialog_run (GTK_DIALOG (wizard)); + gtk_widget_destroy (GTK_WIDGET (wizard)); +} + + void modest_ui_actions_on_about (GtkAction *action, ModestWindow *win) { @@ -366,19 +380,11 @@ modest_ui_actions_on_add_to_contacts (GtkAction *action, ModestWindow *win) void modest_ui_actions_on_accounts (GtkAction *action, ModestWindow *win) { - /* This is currently only implemented for Maemo, - * because it requires a providers preset file which is not publically available. - */ + /* This is currently only implemented for Maemo */ #ifdef MODEST_PLATFORM_MAEMO /* Defined in config.h */ - 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: */ - ModestEasysetupWizardDialog *wizard = modest_easysetup_wizard_dialog_new (); - gtk_window_set_transient_for (GTK_WINDOW (wizard), GTK_WINDOW (win)); - gtk_dialog_run (GTK_DIALOG (wizard)); - gtk_widget_destroy (GTK_WIDGET (wizard)); + if (!modest_account_mgr_has_accounts(modest_runtime_get_account_mgr(), TRUE)) { + run_account_setup_wizard (win); + return; } else { /* Show the list of accounts: */ GtkDialog *account_win = GTK_DIALOG(modest_account_view_window_new ()); @@ -425,6 +431,8 @@ on_smtp_servers_window_hide (GtkWindow* window, gpointer user_data) gtk_widget_destroy (GTK_WIDGET (window)); } + + void modest_ui_actions_on_smtp_servers (GtkAction *action, ModestWindow *win) { @@ -475,6 +483,12 @@ modest_ui_actions_on_new_msg (GtkAction *action, ModestWindow *win) TnyAccount *account = NULL; ModestWindowMgr *mgr; gchar *signature = NULL, *blank_and_signature = NULL; + + /* if there are no accounts yet, just show the wizard */ + if (!modest_account_mgr_has_accounts (modest_runtime_get_account_mgr(), TRUE)) { + run_account_setup_wizard (win); + return; + } account_name = g_strdup(modest_window_get_active_account (win)); if (!account_name) @@ -520,13 +534,6 @@ modest_ui_actions_on_new_msg (GtkAction *action, ModestWindow *win) goto cleanup; } -/* tny_folder_add_msg (folder, msg, &err); */ -/* if (err) { */ -/* g_printerr ("modest: error adding msg to Drafts folder: %s", */ -/* err->message); */ -/* g_error_free (err); */ -/* goto cleanup; */ -/* } */ /* Create and register edit window */ /* This is destroyed by TOOD. */ @@ -586,6 +593,11 @@ open_msg_cb (ModestMailOperation *mail_op, /* If the header is in the drafts folder then open the editor, else the message view window */ if (folder_type == TNY_FOLDER_TYPE_DRAFTS) { + /* we cannot edit without a valid account... */ + if (!modest_account_mgr_has_accounts(modest_runtime_get_account_mgr(), TRUE)) { + run_account_setup_wizard(parent_win); + goto cleanup; + } win = modest_msg_edit_window_new (msg, account); } else { gchar *uid = modest_tny_folder_get_header_unique_id (header); @@ -632,6 +644,7 @@ open_msg_cb (ModestMailOperation *mail_op, gtk_widget_show_all (GTK_WIDGET(win)); } +cleanup: /* Free */ g_free(account); g_object_unref (msg); @@ -889,6 +902,12 @@ reply_forward (ReplyForwardAction action, ModestWindow *win) g_return_if_fail (MODEST_IS_WINDOW(win)); + /* we need an account when editing */ + if (!modest_account_mgr_has_accounts(modest_runtime_get_account_mgr(), TRUE)) { + run_account_setup_wizard (win); + return; + } + header_list = get_selected_headers (win); if (!header_list) return; diff --git a/src/widgets/modest-window-mgr.c b/src/widgets/modest-window-mgr.c index b6ffd3f..3477b2d 100644 --- a/src/widgets/modest-window-mgr.c +++ b/src/widgets/modest-window-mgr.c @@ -461,15 +461,14 @@ on_nonhibernating_window_show(GtkWidget *widget, gpointer user_data) G_CALLBACK (on_nonhibernating_window_hide), self); } -void modest_window_mgr_prevent_hibernation_while_window_is_shown (ModestWindowMgr *self, GtkWindow *window) +void modest_window_mgr_prevent_hibernation_while_window_is_shown (ModestWindowMgr *self, + GtkWindow *window) { g_return_if_fail (MODEST_IS_WINDOW_MGR (self)); if (GTK_WIDGET_VISIBLE(window)) { on_nonhibernating_window_show (GTK_WIDGET (window), self); - } - else - { + } else { /* Wait for it to be shown: */ g_signal_connect (window, "show", G_CALLBACK (on_nonhibernating_window_show), self);