diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2013-06-15 03:48:43 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2013-06-15 11:21:40 +0800 |
commit | cf669f10f22de13ab4ee9b323d274325af22b0b9 (patch) | |
tree | 0a373034b1ea555285640b280c446e3bd138f008 | |
parent | 4fb6020185c8e54f1674ebefaa5b9481272655bf (diff) | |
download | gsoc2013-evolution-cf669f10f22de13ab4ee9b323d274325af22b0b9.tar.gz gsoc2013-evolution-cf669f10f22de13ab4ee9b323d274325af22b0b9.tar.zst gsoc2013-evolution-cf669f10f22de13ab4ee9b323d274325af22b0b9.zip |
MessageList: Add a "group-by-threads" property.
Bind this to EMailReader's "group-by-threads" property.
New functions:
message_list_get_group_by_threads()
message_list_set_group_by_threads()
-rw-r--r-- | mail/e-mail-reader.c | 11 | ||||
-rw-r--r-- | mail/message-list.c | 125 | ||||
-rw-r--r-- | mail/message-list.h | 10 |
3 files changed, 99 insertions, 47 deletions
diff --git a/mail/e-mail-reader.c b/mail/e-mail-reader.c index 18d71b39de..057e9d9025 100644 --- a/mail/e-mail-reader.c +++ b/mail/e-mail-reader.c @@ -3759,6 +3759,11 @@ e_mail_reader_init (EMailReader *reader, g_slice_new0 (EMailReaderPrivate), (GDestroyNotify) mail_reader_private_free); + g_object_bind_property ( + reader, "group-by-threads", + message_list, "group-by-threads", + G_BINDING_SYNC_CREATE); + if (!init_actions) goto connect_signals; @@ -4493,7 +4498,6 @@ e_mail_reader_set_group_by_threads (EMailReader *reader, gboolean group_by_threads) { EMailReaderPrivate *priv; - GtkWidget *message_list; g_return_if_fail (E_IS_MAIL_READER (reader)); @@ -4504,11 +4508,6 @@ e_mail_reader_set_group_by_threads (EMailReader *reader, priv->group_by_threads = group_by_threads; - /* XXX MessageList should define a property for this. */ - message_list = e_mail_reader_get_message_list (reader); - message_list_set_threaded ( - MESSAGE_LIST (message_list), group_by_threads); - g_object_notify (G_OBJECT (reader), "group-by-threads"); } diff --git a/mail/message-list.c b/mail/message-list.c index 8bd77907d9..80b35c9d01 100644 --- a/mail/message-list.c +++ b/mail/message-list.c @@ -102,6 +102,7 @@ struct _MessageListPrivate { struct _MLSelection clipboard; gboolean destroyed; + gboolean group_by_threads; gboolean show_deleted; gboolean thread_latest; gboolean thread_subject; @@ -125,7 +126,7 @@ struct _RegenData { gchar *search; - gboolean threaded; + gboolean group_by_threads; gboolean thread_subject; CamelFolderThread *tree; @@ -153,6 +154,7 @@ enum { PROP_0, PROP_COPY_TARGET_LIST, PROP_FOLDER, + PROP_GROUP_BY_THREADS, PROP_PASTE_TARGET_LIST, PROP_SESSION, PROP_SHOW_DELETED, @@ -309,7 +311,8 @@ regen_data_new (MessageList *message_list, /* Capture MessageList state to use for this regen. */ regen_data->folder = message_list_ref_folder (message_list); - regen_data->threaded = message_list->threaded; + regen_data->group_by_threads = + message_list_get_group_by_threads (message_list); regen_data->thread_subject = message_list_get_thread_subject (message_list); @@ -874,7 +877,7 @@ message_list_select_all (MessageList *message_list) regen_data = message_list_ref_regen_data (message_list); - if (message_list->threaded && regen_data != NULL) { + if (regen_data != NULL && regen_data->group_by_threads) { regen_data->select_all = TRUE; } else { ETree *tree; @@ -2565,18 +2568,23 @@ on_model_row_changed (ETableModel *model, static gboolean ml_tree_sorting_changed (ETreeTableAdapter *adapter, - MessageList *ml) + MessageList *message_list) { - g_return_val_if_fail (ml != NULL, FALSE); + gboolean group_by_threads; - if (ml->threaded && ml->frozen == 0) { - if (ml->thread_tree) { + g_return_val_if_fail (message_list != NULL, FALSE); + + group_by_threads = message_list_get_group_by_threads (message_list); + + if (group_by_threads && message_list->frozen == 0) { + if (message_list->thread_tree != NULL) { /* free the previous thread_tree to recreate it fully */ - camel_folder_thread_messages_unref (ml->thread_tree); - ml->thread_tree = NULL; + camel_folder_thread_messages_unref ( + message_list->thread_tree); + message_list->thread_tree = NULL; } - mail_regen_list (ml, ml->search, FALSE); + mail_regen_list (message_list, message_list->search, FALSE); return TRUE; } @@ -2683,6 +2691,12 @@ message_list_set_property (GObject *object, g_value_get_object (value)); return; + case PROP_GROUP_BY_THREADS: + message_list_set_group_by_threads ( + MESSAGE_LIST (object), + g_value_get_boolean (value)); + return; + case PROP_SESSION: message_list_set_session ( MESSAGE_LIST (object), @@ -2732,6 +2746,13 @@ message_list_get_property (GObject *object, MESSAGE_LIST (object))); return; + case PROP_GROUP_BY_THREADS: + g_value_set_boolean ( + value, + message_list_get_group_by_threads ( + MESSAGE_LIST (object))); + return; + case PROP_PASTE_TARGET_LIST: g_value_set_boxed ( value, @@ -2935,6 +2956,18 @@ message_list_class_init (MessageListClass *class) G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + g_object_class_install_property ( + object_class, + PROP_GROUP_BY_THREADS, + g_param_spec_boolean ( + "group-by-threads", + "Group By Threads", + "Group messages into conversation threads", + FALSE, + G_PARAM_READWRITE | + G_PARAM_CONSTRUCT | + G_PARAM_STATIC_STRINGS)); + /* Inherited from ESelectableInterface */ g_object_class_override_property ( object_class, @@ -4090,6 +4123,32 @@ message_list_get_paste_target_list (MessageList *message_list) } gboolean +message_list_get_group_by_threads (MessageList *message_list) +{ + g_return_val_if_fail (IS_MESSAGE_LIST (message_list), FALSE); + + return message_list->priv->group_by_threads; +} + +void +message_list_set_group_by_threads (MessageList *message_list, + gboolean group_by_threads) +{ + g_return_if_fail (IS_MESSAGE_LIST (message_list)); + + if (group_by_threads == message_list->priv->group_by_threads) + return; + + message_list->priv->group_by_threads = group_by_threads; + + g_object_notify (G_OBJECT (message_list), "group-by-threads"); + + /* Changing this property triggers a message list regen. */ + if (message_list->frozen == 0) + mail_regen_list (message_list, message_list->search, FALSE); +} + +gboolean message_list_get_show_deleted (MessageList *message_list) { g_return_val_if_fail (IS_MESSAGE_LIST (message_list), FALSE); @@ -4569,36 +4628,30 @@ message_list_thaw (MessageList *ml) /* set whether we are in threaded view or flat view */ void -message_list_set_threaded_expand_all (MessageList *ml) +message_list_set_threaded_expand_all (MessageList *message_list) { - if (ml->threaded) { - ml->expand_all = 1; + g_return_if_fail (IS_MESSAGE_LIST (message_list)); - if (ml->frozen == 0) - mail_regen_list (ml, ml->search, FALSE); - } -} + if (message_list_get_group_by_threads (message_list)) { + message_list->expand_all = 1; -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, FALSE); + if (message_list->frozen == 0) + mail_regen_list ( + message_list, message_list->search, FALSE); } } void -message_list_set_threaded (MessageList *ml, - gboolean threaded) +message_list_set_threaded_collapse_all (MessageList *message_list) { - if (ml->threaded != threaded) { - ml->threaded = threaded; + g_return_if_fail (IS_MESSAGE_LIST (message_list)); + + if (message_list_get_group_by_threads (message_list)) { + message_list->collapse_all = 1; - if (ml->frozen == 0) - mail_regen_list (ml, ml->search, FALSE); + if (message_list->frozen == 0) + mail_regen_list ( + message_list, message_list->search, FALSE); } } @@ -4999,7 +5052,7 @@ message_list_regen_thread (GSimpleAsyncResult *simple, goto exit; /* update/build a new tree */ - if (regen_data->threaded) { + if (regen_data->group_by_threads) { ml_sort_uids_by_tree (message_list, uids, cancellable); if (regen_data->tree != NULL) @@ -5095,7 +5148,7 @@ message_list_regen_done_cb (GObject *source_object, (message_list->search != NULL) && (*message_list->search != '\0'); - if (regen_data->threaded) { + if (regen_data->group_by_threads) { gboolean forcing_expand_state; forcing_expand_state = @@ -5308,7 +5361,7 @@ mail_regen_list (MessageList *message_list, hide_deleted = message_list_get_hide_deleted ( message_list, new_regen_data->folder); - if (message_list->threaded && hide_deleted) { + if (new_regen_data->group_by_threads && hide_deleted) { new_regen_data->tree = thread_tree; camel_folder_thread_messages_ref (thread_tree); } else { @@ -5329,13 +5382,13 @@ mail_regen_list (MessageList *message_list, g_free (txt); } } else if (message_list->priv->any_row_changed && - message_list->threaded && + new_regen_data->group_by_threads && !message_list->just_set_folder && !searching) { /* Something changed. If it was an expand * state change, then save the expand state. */ message_list_save_state (message_list); - } else if (message_list->threaded && + } else if (new_regen_data->group_by_threads && !message_list->just_set_folder && !searching) { /* Remember the expand state and restore it after regen. */ diff --git a/mail/message-list.h b/mail/message-list.h index 7e55c1aadc..e633e20b57 100644 --- a/mail/message-list.h +++ b/mail/message-list.h @@ -115,9 +115,6 @@ struct _MessageList { * was just called? */ guint just_set_folder : 1; - /* Are we displaying threaded view? */ - guint threaded : 1; - guint expand_all :1; guint collapse_all :1; @@ -165,6 +162,11 @@ GtkTargetList * message_list_get_copy_target_list (MessageList *message_list); GtkTargetList * message_list_get_paste_target_list (MessageList *message_list); +gboolean message_list_get_group_by_threads + (MessageList *message_list); +void message_list_set_group_by_threads + (MessageList *message_list, + gboolean group_by_threads); gboolean message_list_get_show_deleted (MessageList *message_list); void message_list_set_show_deleted (MessageList *message_list, gboolean show_deleted); @@ -202,8 +204,6 @@ void message_list_copy (MessageList *message_list, void message_list_paste (MessageList *message_list); guint message_list_count (MessageList *message_list); guint message_list_selected_count (MessageList *message_list); -void message_list_set_threaded (MessageList *message_list, - gboolean threaded); void message_list_set_threaded_expand_all (MessageList *message_list); void message_list_set_threaded_collapse_all |