[evolution-patches] Fix for http://bugzilla.gnome.org/show_bug.cgi?id=218570
- From: Srinivasa Ragavan <sragavan novell com>
- To: evolution-patches gnome org
- Subject: [evolution-patches] Fix for http://bugzilla.gnome.org/show_bug.cgi?id=218570
- Date: Mon, 16 Jan 2006 11:34:05 +0530
Hi,
I have implemented a thread expand/collapse all feature for mail.
Please review it.
-Srini
Index: mail/em-folder-browser.c
===================================================================
RCS file: /cvs/gnome/evolution/mail/em-folder-browser.c,v
retrieving revision 1.72
diff -u -p -r1.72 em-folder-browser.c
--- mail/em-folder-browser.c 13 Jan 2006 08:22:48 -0000 1.72
+++ mail/em-folder-browser.c 14 Jan 2006 16:34:26 -0000
@@ -597,6 +597,24 @@ emfb_folder_properties(BonoboUIComponent
em_folder_properties_show(NULL, emfb->view.folder, emfb->view.folder_uri);
}
+/* VIEWTHREADED*/
+static void
+emfb_expand_all_threads(BonoboUIComponent *uid, void *data, const char *path)
+{
+ EMFolderView *emfv = data;
+
+ message_list_set_threaded_expand_all(emfv->list);
+
+}
+
+static void
+emfb_collapse_all_threads(BonoboUIComponent *uid, void *data, const char *path)
+{
+ EMFolderView *emfv = data;
+
+ message_list_set_threaded_collapse_all(emfv->list);
+}
+
static void
emfb_folder_copy(BonoboUIComponent *uid, void *data, const char *path)
{
@@ -823,6 +841,9 @@ static BonoboUIVerb emfb_verbs[] = {
BONOBO_UI_UNSAFE_VERB ("ViewShowAll", emfb_view_show_all),
/* ViewThreaded is a toggle */
+ BONOBO_UI_UNSAFE_VERB ("ViewThreadsExpandAll", emfb_expand_all_threads),
+ BONOBO_UI_UNSAFE_VERB ("ViewThreadsCollapseAll", emfb_collapse_all_threads),
+
BONOBO_UI_UNSAFE_VERB ("FolderCopy", emfb_folder_copy),
BONOBO_UI_UNSAFE_VERB ("FolderMove", emfb_folder_move),
BONOBO_UI_UNSAFE_VERB ("FolderDelete", emfb_folder_delete),
@@ -861,6 +882,8 @@ static const EMFolderViewEnable emfb_ena
{ "MailPost", EM_POPUP_SELECT_FOLDER },
{ "MessageMarkAllAsRead", EM_POPUP_SELECT_FOLDER },
{ "ViewHideSelected", EM_POPUP_SELECT_MANY },
+ { "ViewThreadsCollapseAll", EM_FOLDER_VIEW_SELECT_THREADED},
+ { "ViewThreadsExpandAll", EM_FOLDER_VIEW_SELECT_THREADED},
{ NULL },
};
@@ -1091,8 +1114,11 @@ emfb_set_folder(EMFolderView *emfv, Came
} else
state = gconf_client_get_bool(gconf, "/apps/evolution/mail/display/thread_list", NULL);
message_list_set_threaded(emfv->list, state);
- if (emfv->uic)
+ if (emfv->uic) {
bonobo_ui_component_set_prop(emfv->uic, "/commands/ViewThreaded", "state", state?"1":"0", NULL);
+ bonobo_ui_component_set_prop(emfv->uic, "/commands/ViewThreadsCollapseAll", "sensitive", state?"1":"0", NULL);
+ bonobo_ui_component_set_prop(emfv->uic, "/commands/ViewThreadsExpandAll", "sensitive", state?"1":"0", NULL);
+ }
if (emfv->uic) {
state = (folder->folder_flags & CAMEL_FOLDER_IS_TRASH) == 0;
@@ -1189,6 +1215,8 @@ emfb_activate(EMFolderView *emfv, Bonobo
}
bonobo_ui_component_set_prop(uic, "/commands/ViewThreaded", "state", state?"1":"0", NULL);
+ bonobo_ui_component_set_prop(uic, "/commands/ViewThreadsCollapseAll", "sensitive", state?"1":"0", NULL);
+ bonobo_ui_component_set_prop(uic, "/commands/ViewThreadsExpandAll", "sensitive", state?"1":"0", NULL);
bonobo_ui_component_add_listener(uic, "ViewThreaded", emfb_view_threaded, emfv);
message_list_set_threaded(emfv->list, state);
Index: mail/message-list.c
===================================================================
RCS file: /cvs/gnome/evolution/mail/message-list.c,v
retrieving revision 1.421
diff -u -p -r1.421 message-list.c
--- mail/message-list.c 13 Jan 2006 08:22:48 -0000 1.421
+++ mail/message-list.c 14 Jan 2006 16:34:38 -0000
@@ -1479,6 +1479,16 @@ save_tree_state(MessageList *ml)
}
static void
+load_tree_expand_all (MessageList *ml, gboolean state)
+{
+
+ if (ml->folder == NULL || ml->tree == NULL)
+ return;
+
+ e_tree_load_all_expanded_state (ml->tree, state);
+ save_tree_state (ml);
+}
+static void
load_tree_state (MessageList *ml)
{
char *filename;
@@ -3102,6 +3112,28 @@ void message_list_free_uids(MessageList
}
/* set whether we are in threaded view or flat view */
+void
+message_list_set_threaded_expand_all (MessageList *ml)
+{
+ if (ml->threaded) {
+ ml->expand_all = 1;
+
+ if (ml->frozen == 0)
+ mail_regen_list (ml, ml->search, NULL, NULL);
+ }
+}
+
+void
+message_list_set_threaded_collapse_all (MessageList *ml)
+{
+ if (ml->threaded) {
+ ml->collapse_all = 1;
+
+ if (ml->frozen == 0)
+ mail_regen_list (ml, ml->search, NULL, NULL);
+ }
+}
+
void
message_list_set_threaded (MessageList *ml, gboolean threaded)
{
@@ -3114,6 +3146,17 @@ message_list_set_threaded (MessageList *
}
void
+message_list_set_expand_all (MessageList *ml, gboolean threaded)
+{
+ if (ml->threaded != threaded) {
+ ml->threaded = threaded;
+
+ if (ml->frozen == 0)
+ mail_regen_list (ml, ml->search, NULL, NULL);
+ }
+}
+
+void
message_list_set_hidedeleted (MessageList *ml, gboolean hidedeleted)
{
if (ml->hidedeleted != hidedeleted) {
@@ -3596,7 +3639,15 @@ regen_list_regened (struct _mail_msg *mm
m->ml->thread_tree = m->tree;
m->tree = NULL;
- load_tree_state (m->ml);
+ if (m->ml->expand_all)
+ load_tree_expand_all (m->ml, TRUE);
+ else if (m->ml->collapse_all)
+ load_tree_expand_all (m->ml, FALSE);
+ else
+ load_tree_state (m->ml);
+
+ m->ml->expand_all = FALSE;
+ m->ml->collapse_all = FALSE;
} else
build_flat (m->ml, m->summary, m->changes);
Index: mail/message-list.h
===================================================================
RCS file: /cvs/gnome/evolution/mail/message-list.h,v
retrieving revision 1.88
diff -u -p -r1.88 message-list.h
--- mail/message-list.h 17 Jun 2005 15:20:30 -0000 1.88
+++ mail/message-list.h 14 Jan 2006 16:34:38 -0000
@@ -114,6 +114,9 @@ struct _MessageList {
/* Are we displaying threaded view? */
guint threaded : 1;
+
+ guint expand_all :1;
+ guint collapse_all :1;
/* do we automatically hide deleted messages? */
guint hidedeleted : 1;
Index: ui/evolution-mail-list.xml
===================================================================
RCS file: /cvs/gnome/evolution/ui/evolution-mail-list.xml,v
retrieving revision 1.29
diff -u -p -r1.29 evolution-mail-list.xml
--- ui/evolution-mail-list.xml 22 Sep 2005 16:24:03 -0000 1.29
+++ ui/evolution-mail-list.xml 14 Jan 2006 16:34:44 -0000
@@ -57,6 +57,12 @@
accel="*Control*t"
type="toggle" />
+ <cmd name="ViewThreadsCollapseAll"
+ _tip="Collapse all message threads"/>
+
+ <cmd name="ViewThreadsExpandAll"
+ _tip="Expand all message threads"/>
+
</commands>
<keybindings>
@@ -68,7 +74,10 @@
<submenu name="View">
<placeholder name="MailMessageView">
- <menuitem name="ViewThreaded" verb="" _label="Group By _Threads"/>
+ <menuitem name="ViewThreaded" verb="" _label="_Group By Threads"/>
+ <menuitem name="ViewThreadsExpandAll" verb="" _label="E_xpand All Threads"/>
+ <menuitem name="ViewThreadsCollapseAll" verb="" _label="Collapse All _Threads"/>
+
<menuitem name="HideDeleted" verb="" _label="Hide _Deleted Messages"/>
<separator f="" name="emaillist"/>
<menuitem name="ViewHideSelected" verb="" _label="Hide S_elected Messages"/>
Index: widgets/table/e-tree-table-adapter.c
===================================================================
RCS file: /cvs/gnome/evolution/widgets/table/e-tree-table-adapter.c,v
retrieving revision 1.60
diff -u -p -r1.60 e-tree-table-adapter.c
--- widgets/table/e-tree-table-adapter.c 29 Sep 2005 18:00:17 -0000 1.60
+++ widgets/table/e-tree-table-adapter.c 14 Jan 2006 16:34:45 -0000
@@ -963,6 +963,44 @@ open_file (ETreeTableAdapter *etta, cons
return doc;
}
+static void
+set_expanded_state_func (gpointer keyp, gpointer value, gpointer data)
+{
+ ETreePath path = keyp;
+ node_t *node = ((GNode *)value)->data;
+ ETreeTableAdapter *etta = (ETreeTableAdapter *) data;
+
+ if (node->expanded != TRUE) {
+ e_tree_table_adapter_node_set_expanded(etta, path, TRUE);
+ node->expanded = TRUE;
+ }
+}
+
+static void
+set_collapsed_state_func (gpointer keyp, gpointer value, gpointer data)
+{
+ ETreePath path = keyp;
+ node_t *node = ((GNode *)value)->data;
+ ETreeTableAdapter *etta = (ETreeTableAdapter *) data;
+ xmlNode *xmlnode;
+
+ if (node->expanded != FALSE) {
+ e_tree_table_adapter_node_set_expanded(etta, path, FALSE);
+ node->expanded = FALSE;
+ }
+}
+void
+e_tree_table_adapter_load_all_expanded_state (ETreeTableAdapter *etta, gboolean state)
+{
+
+ g_return_if_fail(etta != NULL);
+
+ if (state)
+ g_hash_table_foreach (etta->priv->nodes, set_expanded_state_func, etta);
+ else
+ g_hash_table_foreach (etta->priv->nodes, set_collapsed_state_func, etta);
+}
+
void
e_tree_table_adapter_load_expanded_state (ETreeTableAdapter *etta, const char *filename)
{
Index: widgets/table/e-tree.c
===================================================================
RCS file: /cvs/gnome/evolution/widgets/table/e-tree.c,v
retrieving revision 1.117
diff -u -p -r1.117 e-tree.c
--- widgets/table/e-tree.c 7 Dec 2005 09:48:08 -0000 1.117
+++ widgets/table/e-tree.c 14 Jan 2006 16:34:46 -0000
@@ -2014,6 +2014,12 @@ e_tree_load_expanded_state (ETree *et, c
e_tree_table_adapter_load_expanded_state (et->priv->etta, filename);
}
+void
+e_tree_load_all_expanded_state (ETree *et, gboolean state)
+{
+ e_tree_table_adapter_load_all_expanded_state (et->priv->etta, state);
+}
+
gint
e_tree_row_count (ETree *et)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]