From 7ade227e6409c98a4010992450e111cf7bb10520 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Thu, 14 Aug 2008 20:19:12 +0000 Subject: Merge revisions 35951:35992 from trunk. svn path=/branches/kill-bonobo/; revision=35994 --- mail/message-list.c | 106 ++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 78 insertions(+), 28 deletions(-) (limited to 'mail/message-list.c') diff --git a/mail/message-list.c b/mail/message-list.c index 9149fd673b..19e017e211 100644 --- a/mail/message-list.c +++ b/mail/message-list.c @@ -110,6 +110,7 @@ struct _MessageListPrivate { gboolean destroyed; gboolean thread_latest; + gboolean any_row_changed; /* save state before regen list when this is set to true */ }; static struct { @@ -1797,32 +1798,29 @@ save_tree_state(MessageList *ml) filename = mail_config_folder_to_cachename(ml->folder, "et-expanded-"); e_tree_save_expanded_state(ml->tree, filename); g_free(filename); + + ml->priv->any_row_changed = FALSE; } static void -load_tree_expand_all (MessageList *ml, gboolean state) +load_tree_state (MessageList *ml, xmlDoc *expand_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; + if (expand_state) { + e_tree_load_expanded_state_xml (ml->tree, expand_state); + } else { + char *filename; - if (ml->folder == NULL || ml->tree == NULL) - return; + filename = mail_config_folder_to_cachename (ml->folder, "et-expanded-"); + e_tree_load_expanded_state (ml->tree, filename); + g_free (filename); + } - filename = mail_config_folder_to_cachename (ml->folder, "et-expanded-"); - e_tree_load_expanded_state (ml->tree, filename); - g_free (filename); + ml->priv->any_row_changed = FALSE; } - void message_list_save_state (MessageList *ml) { @@ -2172,6 +2170,12 @@ ml_scrolled (GtkAdjustment *adj, MessageList *ml) g_signal_emit (ml, message_list_signals[MESSAGE_LIST_SCROLLED], 0); } +static void +on_model_row_changed (ETableModel *model, int row, MessageList *ml) +{ + ml->priv->any_row_changed = TRUE; +} + /* * GObject::init */ @@ -2212,6 +2216,7 @@ message_list_init (MessageList *message_list) p->invisible = gtk_invisible_new(); p->destroyed = FALSE; g_object_ref_sink(p->invisible); + p->any_row_changed = FALSE; matom = gdk_atom_intern ("x-uid-list", FALSE); gtk_selection_add_target(p->invisible, GDK_SELECTION_CLIPBOARD, matom, 0); @@ -2367,6 +2372,25 @@ message_list_class_init (MessageListClass *message_list_class) message_list_init_images (); } +static gboolean +read_boolean_with_default (GConfClient *gconf, const char *key, gboolean def_value) +{ + GConfValue *value; + gboolean res; + + g_return_val_if_fail (gconf != NULL, def_value); + g_return_val_if_fail (key != NULL, def_value); + + value = gconf_client_get (gconf, key, NULL); + if (!value) + return def_value; + + res = gconf_value_get_bool (value); + gconf_value_free (value); + + return res; +} + static void message_list_construct (MessageList *message_list) { @@ -2400,11 +2424,11 @@ message_list_construct (MessageList *message_list) message_list); e_tree_memory_set_expanded_default(E_TREE_MEMORY(message_list->model), - gconf_client_get_bool (gconf, - "/apps/evolution/mail/display/thread_expand", - NULL)); + read_boolean_with_default (gconf, + "/apps/evolution/mail/display/thread_expand", + TRUE)); - message_list->priv->thread_latest = gconf_client_get_bool (gconf, "/apps/evolution/mail/display/thread_latest", NULL); + message_list->priv->thread_latest = read_boolean_with_default (gconf, "/apps/evolution/mail/display/thread_latest", TRUE); /* * The etree @@ -2429,6 +2453,8 @@ message_list_construct (MessageList *message_list) atk_object_set_name(a11y, _("Messages")); } + g_signal_connect (e_tree_get_table_adapter (message_list->tree), "model_row_changed", G_CALLBACK (on_model_row_changed), message_list); + g_signal_connect((message_list->tree), "cursor_activated", G_CALLBACK (on_cursor_activated_cmd), message_list); @@ -3869,6 +3895,8 @@ struct _regen_list_msg { GPtrArray *summary; int last_row; /* last selected (cursor) row */ + + xmlDoc *expand_state; /* stored expanded state of the previous view */ }; /* @@ -4116,10 +4144,19 @@ regen_list_done (struct _regen_list_msg *m) e_profile_event_emit("list.buildtree", m->folder->full_name, 0); if (m->dotree) { - if (m->ml->just_set_folder) + gboolean forcing_expand_state = m->ml->expand_all || m->ml->collapse_all; + + if (m->ml->just_set_folder) { m->ml->just_set_folder = FALSE; - else /* Saving the tree state causes bug 352695 but fixes bug 387312 */ - save_tree_state (m->ml); + if (m->expand_state) { + /* rather load state from disk than use the memory data when changing folders */ + xmlFreeDoc (m->expand_state); + m->expand_state = NULL; + } + } + + if (forcing_expand_state) + e_tree_force_expanded_state (m->ml->tree, m->ml->expand_all ? 1 : -1); build_tree (m->ml, m->tree, m->changes); if (m->ml->thread_tree) @@ -4127,12 +4164,13 @@ regen_list_done (struct _regen_list_msg *m) m->ml->thread_tree = m->tree; m->tree = NULL; - 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); + if (forcing_expand_state) { + if (m->ml->folder != NULL && m->ml->tree != NULL) + save_tree_state (m->ml); + /* do not forget to set this back to use the default value... */ + e_tree_force_expanded_state (m->ml->tree, 0); + } else + load_tree_state (m->ml, m->expand_state); m->ml->expand_all = 0; m->ml->collapse_all = 0; @@ -4177,6 +4215,7 @@ regen_list_done (struct _regen_list_msg *m) e_tree_set_info_message (m->ml->tree, NULL); g_signal_emit (m->ml, message_list_signals[MESSAGE_LIST_BUILT], 0); + m->ml->priv->any_row_changed = FALSE; } static void @@ -4206,6 +4245,9 @@ regen_list_free (struct _regen_list_msg *m) /* we have to poke this here as well since we might've been cancelled and regened wont get called */ m->ml->regen = g_list_remove(m->ml->regen, m); + if (m->expand_state) + xmlFreeDoc (m->expand_state); + g_object_unref(m->ml); } @@ -4304,6 +4346,7 @@ mail_regen_list (MessageList *ml, const char *search, const char *hideexpr, Came m->folder = ml->folder; camel_object_ref(m->folder); m->last_row = -1; + m->expand_state = NULL; if ((!m->hidedel || !m->dotree) && ml->thread_tree) { camel_folder_thread_messages_unref(ml->thread_tree); @@ -4320,6 +4363,13 @@ mail_regen_list (MessageList *ml, const char *search, const char *hideexpr, Came e_tree_set_info_message (m->ml->tree, txt); g_free (txt); + } else if (ml->priv->any_row_changed && m->dotree && !ml->just_set_folder && (!ml->search || g_str_equal (ml->search, " "))) { + /* there has been some change on any row, if it was an expand state change, + then let it save; if not, then nothing happen. */ + message_list_save_state (ml); + } else if (m->dotree && !ml->just_set_folder) { + /* remember actual expand state and restore it after regen */ + m->expand_state = e_tree_save_expanded_state_xml (ml->tree); } /* if we're busy already kick off timeout processing, so normal updates are immediate */ -- cgit