From: Armin Burgmeier Date: Sun, 22 Jul 2007 13:17:17 +0000 (+0000) Subject: 2007-07-22 Armin Burgmeier X-Git-Tag: git_migration_finished~2778 X-Git-Url: http://git.maemo.org/git/?p=modest;a=commitdiff_plain;h=f9300629125062bd4d908bd1211a8b8f697adecf;ds=sidebyside 2007-07-22 Armin Burgmeier * src/maemo/modest-ui-actions.c: Use current account instead of default account for creating viewer windows, so that the viewer window knows to which account the viewed message belongs. * src/maemo/modest-msg-view-window.c: Destroy the window when the corresponding account is deleted. This fixes projects.maemo.org bug pmo-trunk-r2763 --- diff --git a/ChangeLog2 b/ChangeLog2 index 67bfc0d..e4b527b 100644 --- a/ChangeLog2 +++ b/ChangeLog2 @@ -1,3 +1,13 @@ +2007-07-22 Armin Burgmeier + + * src/maemo/modest-ui-actions.c: Use current account instead of + default account for creating viewer windows, so that the viewer + window knows to which account the viewed message belongs. + + * src/maemo/modest-msg-view-window.c: Destroy the window when the + corresponding account is deleted. This fixes projects.maemo.org bug + NB#62936. + 2007-07-18 Armin Burgmeier * src/maemo/modest-connection-specific-smtp-edit-window.c: Don't let diff --git a/src/maemo/modest-msg-view-window.c b/src/maemo/modest-msg-view-window.c index de4a45a..3a5f47e 100644 --- a/src/maemo/modest-msg-view-window.c +++ b/src/maemo/modest-msg-view-window.c @@ -53,6 +53,7 @@ #include #include "modest-ui-dimming-manager.h" #include +#include #define DEFAULT_FOLDER "MyDocs/.documents" @@ -95,6 +96,10 @@ static void on_queue_changed (ModestMailOperationQue ModestMailOperation *mail_op, ModestMailOperationQueueNotification type, ModestMsgViewWindow *self); +static void on_account_removed (ModestAccountMgr *obj, + const gchar *account, + gboolean server_account, + gpointer user_data); static void view_msg_cb (ModestMailOperation *mail_op, TnyHeader *header, TnyMsg *msg, gpointer user_data); @@ -154,6 +159,7 @@ struct _ModestMsgViewWindowPrivate { guint clipboard_change_handler; guint queue_change_handler; + guint account_removed_handler; guint progress_bar_timeout; @@ -250,6 +256,8 @@ modest_msg_view_window_init (ModestMsgViewWindow *obj) priv->msg_view = NULL; priv->header_model = NULL; priv->clipboard_change_handler = 0; + priv->queue_change_handler = 0; + priv->account_removed_handler = 0; priv->current_toolbar_mode = TOOLBAR_MODE_NORMAL; priv->optimized_view = FALSE; @@ -445,13 +453,15 @@ modest_msg_view_window_finalize (GObject *obj) g_signal_handler_disconnect (G_OBJECT (modest_runtime_get_mail_operation_queue ()), priv->queue_change_handler); priv->queue_change_handler = 0; } + if (priv->account_removed_handler > 0) { + g_signal_handler_disconnect (G_OBJECT (modest_runtime_get_account_mgr ()), priv->account_removed_handler); + priv->account_removed_handler = 0; + } if (priv->header_model != NULL) { g_object_unref (priv->header_model); priv->header_model = NULL; } - /* disconnet operations queue observer */ - if (priv->progress_bar_timeout > 0) { g_source_remove (priv->progress_bar_timeout); priv->progress_bar_timeout = 0; @@ -665,6 +675,12 @@ modest_msg_view_window_new (TnyMsg *msg, G_CALLBACK (on_queue_changed), obj); + /* Account manager */ + priv->account_removed_handler = g_signal_connect (G_OBJECT(modest_runtime_get_account_mgr()), + "account-removed", + G_CALLBACK(on_account_removed), + obj); + modest_window_set_active_account (MODEST_WINDOW(obj), modest_account_name); priv->last_search = NULL; @@ -1567,6 +1583,25 @@ observers_empty (ModestMsgViewWindow *self) return is_empty; } +static void +on_account_removed (ModestAccountMgr *mgr, + const gchar *account, + gboolean server_account, + gpointer user_data) +{ + ModestTnyAccountStore *store = modest_runtime_get_account_store (); + const gchar *our_acc = modest_window_get_active_account (MODEST_WINDOW (user_data)); + + TnyAccount *tny_acc = modest_tny_account_store_get_tny_account_by (store, MODEST_TNY_ACCOUNT_STORE_QUERY_ID, account); + if(tny_acc != NULL) + { + const gchar* parent_acc = modest_tny_account_get_parent_modest_account_name_for_server_account (tny_acc); + if (strcmp (parent_acc, our_acc) == 0) + { + gtk_widget_destroy (GTK_WIDGET (user_data)); + } + } +} static void on_queue_changed (ModestMailOperationQueue *queue, diff --git a/src/modest-ui-actions.c b/src/modest-ui-actions.c index 937d1b9..9d6c944 100644 --- a/src/modest-ui-actions.c +++ b/src/modest-ui-actions.c @@ -728,9 +728,9 @@ open_msg_cb (ModestMailOperation *mail_op, headers_action_mark_as_read (header, MODEST_WINDOW(parent_win), NULL); /* Get account */ - account = modest_account_mgr_get_default_account (modest_runtime_get_account_mgr()); + account = g_strdup (modest_window_get_active_account (MODEST_WINDOW (parent_win))); if (!account) - account = g_strdup (modest_window_get_active_account (MODEST_WINDOW (parent_win))); + account = modest_account_mgr_get_default_account (modest_runtime_get_account_mgr()); /* Gets folder type (OUTBOX headers will be opened in edit window */ if (modest_tny_folder_is_local_folder (folder))