From f213dbb1f46f0bffdb25951aef59992efcfd8232 Mon Sep 17 00:00:00 2001 From: Sergio Villar Senin Date: Thu, 7 Jun 2007 09:46:15 +0000 Subject: [PATCH] * Fixes NB#55338 pmo-trunk-r2093 --- src/widgets/modest-folder-view.c | 38 +++++++++++++++++++++++++++++++++++--- src/widgets/modest-msg-view.c | 2 +- 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/src/widgets/modest-folder-view.c b/src/widgets/modest-folder-view.c index 0e35b8d..52ff5de 100644 --- a/src/widgets/modest-folder-view.c +++ b/src/widgets/modest-folder-view.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -718,7 +719,9 @@ static gboolean update_model (ModestFolderView *self, ModestTnyAccountStore *account_store) { ModestFolderViewPrivate *priv; - GtkTreeModel *model; + GtkTreeModel *model, *old_model; + TnyAccount *local_account; + TnyList *model_as_list; g_return_val_if_fail (account_store, FALSE); @@ -728,7 +731,27 @@ update_model (ModestFolderView *self, ModestTnyAccountStore *account_store) g_signal_emit (G_OBJECT(self), signals[FOLDER_SELECTION_CHANGED_SIGNAL], 0, NULL, TRUE); - + + /* Remove the old model as observer of the local folder account */ + local_account = + modest_tny_account_store_get_tny_account_by_account (modest_runtime_get_account_store (), + MODEST_ACTUAL_LOCAL_FOLDERS_ACCOUNT_ID, + TNY_ACCOUNT_TYPE_STORE); + old_model = gtk_tree_view_get_model (GTK_TREE_VIEW (self)); + if (old_model) { + GtkTreeModel *sorted, *model; + + if (GTK_IS_TREE_MODEL_FILTER (old_model)) + sorted = gtk_tree_model_filter_get_model (GTK_TREE_MODEL_FILTER (old_model)); + else + sorted = old_model; + + model = gtk_tree_model_sort_get_model (GTK_TREE_MODEL_SORT (sorted)); + + tny_folder_store_remove_observer (TNY_FOLDER_STORE (local_account), + TNY_FOLDER_STORE_OBSERVER (model)); + } + /* FIXME: the local accounts are not shown when the query selects only the subscribed folders. */ /* model = tny_gtk_folder_store_tree_model_new (TRUE, priv->query); */ @@ -736,13 +759,22 @@ update_model (ModestFolderView *self, ModestTnyAccountStore *account_store) /* Deal with the model via its TnyList Interface, * filling the TnyList via a get_accounts() call: */ - TnyList *model_as_list = TNY_LIST(model); + model_as_list = TNY_LIST(model); /* Get the accounts: */ tny_account_store_get_accounts (TNY_ACCOUNT_STORE(account_store), model_as_list, TNY_ACCOUNT_STORE_STORE_ACCOUNTS); + + /* Set the folder view as an account observer in order to let + us see the UI changes automatically when creating and + deleting folders just under the local account */ + tny_folder_store_add_observer (TNY_FOLDER_STORE (local_account), + TNY_FOLDER_STORE_OBSERVER (model)); + + g_object_unref (model_as_list); model_as_list = NULL; + g_object_unref (local_account); /* if (account_list) diff --git a/src/widgets/modest-msg-view.c b/src/widgets/modest-msg-view.c index 43185d7..6c7f40a 100644 --- a/src/widgets/modest-msg-view.c +++ b/src/widgets/modest-msg-view.c @@ -1415,7 +1415,7 @@ modest_msg_view_get_message (ModestMsgView *self) { TnyMsg *msg; - g_return_val_if_fail (self, NULL); + g_return_val_if_fail (MODEST_IS_MSG_VIEW (self), NULL); msg = MODEST_MSG_VIEW_GET_PRIVATE(self)->msg; -- 1.7.9.5