diff options
author | Sankar P <psankar@novell.com> | 2007-12-14 20:37:56 +0800 |
---|---|---|
committer | Sankarasivasubramanian Pasupathilingam <psankar@src.gnome.org> | 2007-12-14 20:37:56 +0800 |
commit | 1e2bc8d38c0a6a5b3f6a5390873570cb10da2425 (patch) | |
tree | c26e69ba47927b51ead0cdd337a669c4a7487d41 | |
parent | 1ef77c8fc42463c2109cd98b2ec25775a9dfeb0d (diff) | |
download | gsoc2013-evolution-1e2bc8d38c0a6a5b3f6a5390873570cb10da2425.tar gsoc2013-evolution-1e2bc8d38c0a6a5b3f6a5390873570cb10da2425.tar.gz gsoc2013-evolution-1e2bc8d38c0a6a5b3f6a5390873570cb10da2425.tar.bz2 gsoc2013-evolution-1e2bc8d38c0a6a5b3f6a5390873570cb10da2425.tar.lz gsoc2013-evolution-1e2bc8d38c0a6a5b3f6a5390873570cb10da2425.tar.xz gsoc2013-evolution-1e2bc8d38c0a6a5b3f6a5390873570cb10da2425.tar.zst gsoc2013-evolution-1e2bc8d38c0a6a5b3f6a5390873570cb10da2425.zip |
Moving some code from tree to model where it belongs. Fixes some CPU usage
2007-12-14 Sankar P <psankar@novell.com>
* em-folder-tree-model.c: (emft_model_unread_count_changed),
(em_folder_tree_model_init),
(em_folder_tree_model_set_unread_count):
* em-folder-tree.c: (em_folder_tree_construct):
Moving some code from tree to model where it belongs.
Fixes some CPU usage issue whenever (un)read count is updated.
Hopefully no regresssions.
svn path=/trunk/; revision=34698
-rw-r--r-- | mail/ChangeLog | 10 | ||||
-rw-r--r-- | mail/em-folder-tree-model.c | 28 | ||||
-rw-r--r-- | mail/em-folder-tree.c | 26 |
3 files changed, 38 insertions, 26 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog index 507dd28299..a5a9961e03 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,3 +1,13 @@ +2007-12-14 Sankar P <psankar@novell.com> + + * em-folder-tree-model.c: (emft_model_unread_count_changed), + (em_folder_tree_model_init), + (em_folder_tree_model_set_unread_count): + * em-folder-tree.c: (em_folder_tree_construct): + Moving some code from tree to model where it belongs. + Fixes some CPU usage issue whenever (un)read count is updated. + Hopefully no regresssions. + 2007-12-13 Matthew Barnes <mbarnes@redhat.com> * mail-send-recv.c: diff --git a/mail/em-folder-tree-model.c b/mail/em-folder-tree-model.c index 5f4c67fc6e..69b9c55f3b 100644 --- a/mail/em-folder-tree-model.c +++ b/mail/em-folder-tree-model.c @@ -251,6 +251,30 @@ store_info_free (struct _EMFolderTreeModelStoreInfo *si) } static void +emft_model_unread_count_changed (GtkTreeModel *model, GtkTreeIter *iter) +{ + GtkTreeIter parent_iter; + GtkTreeIter child_iter = *iter; + + g_signal_handler_block (model, emft_model_unread_count_changed); + + /* Folders are displayed with a bold weight to indicate that + they contain unread messages. We signal that parent rows + have changed here to update them. */ + + while (gtk_tree_model_iter_parent (model, &parent_iter, &child_iter)) { + GtkTreePath *parent_path; + + parent_path = gtk_tree_model_get_path (model, &parent_iter); + gtk_tree_model_row_changed (model, parent_path, &parent_iter); + gtk_tree_path_free (parent_path); + child_iter = parent_iter; + } + + g_signal_handler_unblock (model, emft_model_unread_count_changed); +} + +static void em_folder_tree_model_init (EMFolderTreeModel *model) { model->store_hash = g_hash_table_new_full ( @@ -269,6 +293,7 @@ em_folder_tree_model_init (EMFolderTreeModel *model) model->account_hash = g_hash_table_new (g_direct_hash, g_direct_equal); model->account_changed_id = g_signal_connect (model->accounts, "account-changed", G_CALLBACK (account_changed), model); model->account_removed_id = g_signal_connect (model->accounts, "account-removed", G_CALLBACK (account_removed), model); + //g_signal_connect (model, "row-changed", G_CALLBACK (emft_model_unread_count_changed), NULL); } static void @@ -1255,6 +1280,9 @@ em_folder_tree_model_set_unread_count (EMFolderTreeModel *model, CamelStore *sto gtk_tree_path_free (tree_path); gtk_tree_store_set ((GtkTreeStore *) model, &iter, COL_UINT_UNREAD, unread, -1); + + /* May be this is from where we should probagate unread count to parents etc. */ + emft_model_unread_count_changed (model, &iter); } diff --git a/mail/em-folder-tree.c b/mail/em-folder-tree.c index 8104ac5f2e..714da2ef86 100644 --- a/mail/em-folder-tree.c +++ b/mail/em-folder-tree.c @@ -162,7 +162,6 @@ static void emft_queue_save_state (EMFolderTree *emft); static void emft_update_model_expanded_state (struct _EMFolderTreePrivate *priv, GtkTreeIter *iter, gboolean expanded); -static void emft_model_row_changed (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, EMFolderTree *emft); static void emft_tree_row_activated (GtkTreeView *treeview, GtkTreePath *path, GtkTreeViewColumn *column, EMFolderTree *emft); static gboolean emft_tree_test_collapse_row (GtkTreeView *treeview, GtkTreeIter *root, GtkTreePath *path, EMFolderTree *emft); static void emft_tree_row_expanded (GtkTreeView *treeview, GtkTreeIter *root, GtkTreePath *path, EMFolderTree *emft); @@ -546,7 +545,6 @@ em_folder_tree_construct (EMFolderTree *emft, EMFolderTreeModel *model) priv->treeview = folder_tree_new (emft, model); gtk_widget_show ((GtkWidget *) priv->treeview); - g_signal_connect (priv->model, "row-changed", G_CALLBACK (emft_model_row_changed), emft); g_signal_connect (priv->treeview, "row-expanded", G_CALLBACK (emft_tree_row_expanded), emft); g_signal_connect (priv->treeview, "test-collapse-row", G_CALLBACK (emft_tree_test_collapse_row), emft); g_signal_connect (priv->treeview, "row-activated", G_CALLBACK (emft_tree_row_activated), emft); @@ -1859,30 +1857,6 @@ emft_update_model_expanded_state (struct _EMFolderTreePrivate *priv, GtkTreeIter } static void -emft_model_row_changed (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, EMFolderTree *emft) -{ - GtkTreeIter parent_iter; - GtkTreeIter child_iter = *iter; - - g_signal_handlers_block_by_func (model, emft_model_row_changed, emft); - - /* Folders are displayed with a bold weight to indicate that - they contain unread messages. We signal that parent rows - have changed here to update them. */ - - while (gtk_tree_model_iter_parent (model, &parent_iter, &child_iter)) { - GtkTreePath *parent_path; - - parent_path = gtk_tree_model_get_path (model, &parent_iter); - gtk_tree_model_row_changed (model, parent_path, &parent_iter); - gtk_tree_path_free (parent_path); - child_iter = parent_iter; - } - - g_signal_handlers_unblock_by_func (model, emft_model_row_changed, emft); -} - -static void emft_tree_row_expanded (GtkTreeView *treeview, GtkTreeIter *root, GtkTreePath *tree_path, EMFolderTree *emft) { struct _EMFolderTreePrivate *priv = emft->priv; |