diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2013-11-19 23:27:28 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2013-11-20 03:50:57 +0800 |
commit | b82b708aac03b472e6d90efcb7239a884ec01026 (patch) | |
tree | 0ab8b149da94a3eb2828f75aa72975c9963f8bff /mail | |
parent | ba85b310f1a1df61709080d9361b178614bca1fb (diff) | |
download | gsoc2013-evolution-b82b708aac03b472e6d90efcb7239a884ec01026.tar gsoc2013-evolution-b82b708aac03b472e6d90efcb7239a884ec01026.tar.gz gsoc2013-evolution-b82b708aac03b472e6d90efcb7239a884ec01026.tar.bz2 gsoc2013-evolution-b82b708aac03b472e6d90efcb7239a884ec01026.tar.lz gsoc2013-evolution-b82b708aac03b472e6d90efcb7239a884ec01026.tar.xz gsoc2013-evolution-b82b708aac03b472e6d90efcb7239a884ec01026.tar.zst gsoc2013-evolution-b82b708aac03b472e6d90efcb7239a884ec01026.zip |
Make em_folder_tree_model_remove_folders() private.
Only called from within EMFolderTreeModel itself.
Working toward making the EMFolderTreeModelStoreInfo struct private to
EMFolderTreeModel, so it can then be made thread-safe.
Diffstat (limited to 'mail')
-rw-r--r-- | mail/em-folder-tree-model.c | 95 | ||||
-rw-r--r-- | mail/em-folder-tree-model.h | 4 |
2 files changed, 51 insertions, 48 deletions
diff --git a/mail/em-folder-tree-model.c b/mail/em-folder-tree-model.c index 4092fe1463..2014b048aa 100644 --- a/mail/em-folder-tree-model.c +++ b/mail/em-folder-tree-model.c @@ -192,6 +192,54 @@ folder_tree_model_sort (GtkTreeModel *model, } static void +folder_tree_model_remove_folders (EMFolderTreeModel *folder_tree_model, + EMFolderTreeModelStoreInfo *si, + GtkTreeIter *toplevel) +{ + GtkTreeModel *model; + GtkTreeIter iter; + gchar *full_name; + gboolean is_store; + gboolean iter_valid; + + model = GTK_TREE_MODEL (folder_tree_model); + + iter_valid = gtk_tree_model_iter_children (model, &iter, toplevel); + + while (iter_valid) { + GtkTreeIter next = iter; + + /* Recursing will invalidate the current tree model + * iterator, so we have to fetch the next one first. */ + iter_valid = gtk_tree_model_iter_next (model, &next); + folder_tree_model_remove_folders (folder_tree_model, si, &iter); + iter = next; + } + + gtk_tree_model_get ( + model, toplevel, + COL_STRING_FULL_NAME, &full_name, + COL_BOOL_IS_STORE, &is_store, -1); + + if (full_name != NULL) + g_hash_table_remove (si->full_hash, full_name); + + gtk_tree_store_remove (GTK_TREE_STORE (model), toplevel); + + /* Freeing the GtkTreeRowReference in the store info may finalize + * the model. Keep the model alive until the store info is fully + * removed from the hash table. */ + if (is_store) { + g_object_ref (folder_tree_model); + g_hash_table_remove ( + folder_tree_model->priv->store_index, si->store); + g_object_unref (folder_tree_model); + } + + g_free (full_name); +} + +static void folder_tree_model_service_removed (EMailAccountStore *account_store, CamelService *service, EMFolderTreeModel *folder_tree_model) @@ -984,7 +1032,7 @@ folder_tree_model_folder_unsubscribed_cb (CamelStore *store, gtk_tree_model_get_iter (GTK_TREE_MODEL (model), &iter, path); gtk_tree_path_free (path); - em_folder_tree_model_remove_folders (model, si, &iter); + folder_tree_model_remove_folders (model, si, &iter); } static void @@ -1044,7 +1092,7 @@ folder_tree_model_folder_renamed_cb (CamelStore *store, gtk_tree_model_get_iter (GTK_TREE_MODEL (model), &iter, path); gtk_tree_path_free (path); - em_folder_tree_model_remove_folders (model, si, &iter); + folder_tree_model_remove_folders (model, si, &iter); /* Make sure we don't already have the new folder name. */ reference = g_hash_table_lookup (si->full_hash, info->full_name); @@ -1228,7 +1276,7 @@ em_folder_tree_model_remove_store (EMFolderTreeModel *model, gtk_tree_path_free (path); /* recursively remove subfolders and finally the toplevel store */ - em_folder_tree_model_remove_folders (model, si, &iter); + folder_tree_model_remove_folders (model, si, &iter); } GList * @@ -1239,47 +1287,6 @@ em_folder_tree_model_list_stores (EMFolderTreeModel *model) return g_hash_table_get_keys (model->priv->store_index); } -void -em_folder_tree_model_remove_folders (EMFolderTreeModel *model, - EMFolderTreeModelStoreInfo *si, - GtkTreeIter *toplevel) -{ - gchar *full_name; - gboolean is_store, go; - GtkTreeIter iter; - - if (gtk_tree_model_iter_children (GTK_TREE_MODEL (model), &iter, toplevel)) { - do { - GtkTreeIter next = iter; - - go = gtk_tree_model_iter_next (GTK_TREE_MODEL (model), &next); - em_folder_tree_model_remove_folders (model, si, &iter); - iter = next; - } while (go); - } - - gtk_tree_model_get ( - GTK_TREE_MODEL (model), toplevel, - COL_STRING_FULL_NAME, &full_name, - COL_BOOL_IS_STORE, &is_store, -1); - - if (full_name != NULL) - g_hash_table_remove (si->full_hash, full_name); - - gtk_tree_store_remove ((GtkTreeStore *) model, toplevel); - - /* Freeing the GtkTreeRowReference in the store info may finalize - * the model. Keep the model alive until the store info is fully - * removed from the hash table. */ - if (is_store) { - g_object_ref (model); - g_hash_table_remove (model->priv->store_index, si->store); - g_object_unref (model); - } - - g_free (full_name); -} - gboolean em_folder_tree_model_is_type_inbox (EMFolderTreeModel *model, CamelStore *store, diff --git a/mail/em-folder-tree-model.h b/mail/em-folder-tree-model.h index d33b385aab..75ef93fa48 100644 --- a/mail/em-folder-tree-model.h +++ b/mail/em-folder-tree-model.h @@ -137,10 +137,6 @@ void em_folder_tree_model_remove_store CamelStore *store); GList * em_folder_tree_model_list_stores (EMFolderTreeModel *model); -void em_folder_tree_model_remove_folders - (EMFolderTreeModel *model, - EMFolderTreeModelStoreInfo *si, - GtkTreeIter *toplevel); gboolean em_folder_tree_model_is_type_inbox (EMFolderTreeModel *model, CamelStore *store, |