[evolution] I#550 - Mail: Compress flat thread indentation
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution] I#550 - Mail: Compress flat thread indentation
- Date: Tue, 1 Dec 2020 10:39:44 +0000 (UTC)
commit c86f63fb1489764257dd1eeb3c5054030b695b82
Author: Milan Crha <mcrha redhat com>
Date: Tue Dec 1 11:38:27 2020 +0100
I#550 - Mail: Compress flat thread indentation
Closes https://gitlab.gnome.org/GNOME/evolution/-/issues/550
data/org.gnome.evolution.mail.gschema.xml.in | 5 ++
src/mail/message-list.c | 73 +++++++++++++++++++++++++-
src/mail/message-list.h | 3 ++
src/modules/settings/e-settings-message-list.c | 5 ++
4 files changed, 84 insertions(+), 2 deletions(-)
---
diff --git a/data/org.gnome.evolution.mail.gschema.xml.in b/data/org.gnome.evolution.mail.gschema.xml.in
index 353d0cf3af..b692ef2825 100644
--- a/data/org.gnome.evolution.mail.gschema.xml.in
+++ b/data/org.gnome.evolution.mail.gschema.xml.in
@@ -467,6 +467,11 @@
<_summary>Whether sort thread children always ascending</_summary>
<_description>This setting specifies whether the thread children should be sorted always ascending,
rather than using the same sort order as in the thread root level.</_description>
</key>
+ <key name="thread-compress" type="b">
+ <default>true</default>
+ <_summary>Whether to compress thread level</_summary>
+ <_description>Set to true to compress thread levels for flat conversations, to make the level not so
deep.</_description>
+ </key>
<key name="sort-accounts-alpha" type="b">
<default>true</default>
<_summary>Sort accounts alphabetically in a folder tree</_summary>
diff --git a/src/mail/message-list.c b/src/mail/message-list.c
index 7da8992cfd..9ab9c6c4a5 100644
--- a/src/mail/message-list.c
+++ b/src/mail/message-list.c
@@ -106,6 +106,7 @@ struct _MessageListPrivate {
gboolean show_junk;
gboolean thread_latest;
gboolean thread_subject;
+ gboolean thread_compress;
gboolean any_row_changed; /* save state before regen list when this is set to true */
gboolean show_subject_above_sender;
gboolean regen_selects_unread;
@@ -194,7 +195,8 @@ enum {
PROP_SHOW_JUNK,
PROP_SHOW_SUBJECT_ABOVE_SENDER,
PROP_THREAD_LATEST,
- PROP_THREAD_SUBJECT
+ PROP_THREAD_SUBJECT,
+ PROP_THREAD_COMPRESS
};
/* Forward Declarations */
@@ -3132,6 +3134,12 @@ message_list_set_property (GObject *object,
MESSAGE_LIST (object),
g_value_get_boolean (value));
return;
+
+ case PROP_THREAD_COMPRESS:
+ message_list_set_thread_compress (
+ MESSAGE_LIST (object),
+ g_value_get_boolean (value));
+ return;
}
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -3213,6 +3221,13 @@ message_list_get_property (GObject *object,
message_list_get_thread_subject (
MESSAGE_LIST (object)));
return;
+
+ case PROP_THREAD_COMPRESS:
+ g_value_set_boolean (
+ value,
+ message_list_get_thread_compress (
+ MESSAGE_LIST (object)));
+ return;
}
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -3426,7 +3441,25 @@ static guint
message_list_depth (ETreeModel *tree_model,
ETreePath path)
{
- return g_node_depth ((GNode *) path);
+ guint depth;
+
+ depth = g_node_depth ((GNode *) path);
+
+ if (depth > 1 && message_list_get_thread_compress (MESSAGE_LIST (tree_model))) {
+ GNode *node = ((GNode *) path)->parent;
+
+ while (node && !G_NODE_IS_ROOT (node)) {
+ if (G_NODE_IS_ROOT (node->parent))
+ break;
+
+ if (!node->prev && !node->next)
+ depth--;
+
+ node = node->parent;
+ }
+ }
+
+ return depth;
}
static gboolean
@@ -3928,6 +3961,18 @@ message_list_class_init (MessageListClass *class)
G_PARAM_CONSTRUCT |
G_PARAM_STATIC_STRINGS));
+ g_object_class_install_property (
+ object_class,
+ PROP_THREAD_COMPRESS,
+ g_param_spec_boolean (
+ "thread-compress",
+ "Thread Compress",
+ "Compress flat threads",
+ TRUE,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT |
+ G_PARAM_STATIC_STRINGS));
+
gtk_widget_class_install_style_property (
GTK_WIDGET_CLASS (class),
g_param_spec_boxed (
@@ -5517,6 +5562,30 @@ message_list_set_thread_subject (MessageList *message_list,
g_object_notify (G_OBJECT (message_list), "thread-subject");
}
+gboolean
+message_list_get_thread_compress (MessageList *message_list)
+{
+ g_return_val_if_fail (IS_MESSAGE_LIST (message_list), FALSE);
+
+ return message_list->priv->thread_compress;
+}
+
+void
+message_list_set_thread_compress (MessageList *message_list,
+ gboolean thread_compress)
+{
+ g_return_if_fail (IS_MESSAGE_LIST (message_list));
+
+ if ((thread_compress ? 1 : 0) == (message_list->priv->thread_compress ? 1 : 0))
+ return;
+
+ message_list->priv->thread_compress = thread_compress;
+
+ g_object_notify (G_OBJECT (message_list), "thread-compress");
+
+ gtk_widget_queue_draw (GTK_WIDGET (message_list));
+}
+
gboolean
message_list_get_regen_selects_unread (MessageList *message_list)
{
diff --git a/src/mail/message-list.h b/src/mail/message-list.h
index bbb7100fad..0244250024 100644
--- a/src/mail/message-list.h
+++ b/src/mail/message-list.h
@@ -190,6 +190,9 @@ void message_list_set_thread_latest (MessageList *message_list,
gboolean message_list_get_thread_subject (MessageList *message_list);
void message_list_set_thread_subject (MessageList *message_list,
gboolean thread_subject);
+gboolean message_list_get_thread_compress(MessageList *message_list);
+void message_list_set_thread_compress(MessageList *message_list,
+ gboolean thread_compress);
gboolean message_list_get_regen_selects_unread
(MessageList *message_list);
void message_list_set_regen_selects_unread
diff --git a/src/modules/settings/e-settings-message-list.c b/src/modules/settings/e-settings-message-list.c
index 22018c7b54..febcddbb5e 100644
--- a/src/modules/settings/e-settings-message-list.c
+++ b/src/modules/settings/e-settings-message-list.c
@@ -76,6 +76,11 @@ settings_message_list_constructed (GObject *object)
message_list, "sort-children-ascending",
G_SETTINGS_BIND_GET);
+ g_settings_bind (
+ settings, "thread-compress",
+ message_list, "thread-compress",
+ G_SETTINGS_BIND_GET);
+
/* This setting only controls the initial message list
* state when in threaded mode, so just apply it here. */
message_list_set_expanded_default (
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]