[evolution/gnome-3-36] MessageList: Update localized re values only if the setting changed
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution/gnome-3-36] MessageList: Update localized re values only if the setting changed
- Date: Wed, 20 May 2020 08:44:49 +0000 (UTC)
commit 5c00166ce553b8594fab85b82bef4afd824472c2
Author: Milan Crha <mcrha redhat com>
Date: Wed May 20 10:44:02 2020 +0200
MessageList: Update localized re values only if the setting changed
Or better when it could change, according to GSettings. There is no need
to re-read the value whenever the message list content is regenerated,
especially because the option doesn't change that often. This also avoids
unnecessary memory allocations.
src/mail/message-list.c | 78 +++++++++++++++++++++++++++++++++++++------------
1 file changed, 60 insertions(+), 18 deletions(-)
---
diff --git a/src/mail/message-list.c b/src/mail/message-list.c
index 082d1f3783..8f385f4a3a 100644
--- a/src/mail/message-list.c
+++ b/src/mail/message-list.c
@@ -3028,6 +3028,48 @@ message_list_get_preferred_width (GtkWidget *widget,
*out_natural_width = *out_minimum_width;
}
+static void
+message_list_localized_re_changed_cb (GSettings *settings,
+ const gchar *key,
+ gpointer user_data)
+{
+ MessageList *message_list = user_data;
+ gchar *prefixes;
+
+ g_return_if_fail (IS_MESSAGE_LIST (message_list));
+
+ g_mutex_lock (&message_list->priv->re_prefixes_lock);
+
+ g_strfreev (message_list->priv->re_prefixes);
+ prefixes = g_settings_get_string (settings, "composer-localized-re");
+ message_list->priv->re_prefixes = g_strsplit (prefixes ? prefixes : "", ",", -1);
+ g_free (prefixes);
+
+ g_mutex_unlock (&message_list->priv->re_prefixes_lock);
+}
+
+static void
+message_list_localized_re_separators_changed_cb (GSettings *settings,
+ const gchar *key,
+ gpointer user_data)
+{
+ MessageList *message_list = user_data;
+
+ g_return_if_fail (IS_MESSAGE_LIST (message_list));
+
+ g_mutex_lock (&message_list->priv->re_prefixes_lock);
+
+ g_strfreev (message_list->priv->re_separators);
+ message_list->priv->re_separators = g_settings_get_strv (settings,
"composer-localized-re-separators");
+
+ if (message_list->priv->re_separators && !*message_list->priv->re_separators) {
+ g_strfreev (message_list->priv->re_separators);
+ message_list->priv->re_separators = NULL;
+ }
+
+ g_mutex_unlock (&message_list->priv->re_prefixes_lock);
+}
+
static void
message_list_set_session (MessageList *message_list,
EMailSession *session)
@@ -3226,6 +3268,14 @@ message_list_dispose (GObject *object)
message_list->uid_nodemap = NULL;
}
+ if (priv->mail_settings) {
+ g_signal_handlers_disconnect_by_func (priv->mail_settings,
+ G_CALLBACK (message_list_localized_re_changed_cb), message_list);
+
+ g_signal_handlers_disconnect_by_func (priv->mail_settings,
+ G_CALLBACK (message_list_localized_re_separators_changed_cb), message_list);
+ }
+
g_clear_object (&priv->session);
g_clear_object (&priv->folder);
g_clear_object (&priv->invisible);
@@ -4030,6 +4080,15 @@ message_list_init (MessageList *message_list)
message_list->priv->group_by_threads = TRUE;
message_list->priv->new_mail_bg_color = NULL;
message_list->priv->new_mail_fg_color = NULL;
+
+ g_signal_connect (message_list->priv->mail_settings, "changed::composer-localized-re",
+ G_CALLBACK (message_list_localized_re_changed_cb), message_list);
+
+ g_signal_connect (message_list->priv->mail_settings, "changed::composer-localized-re-separators",
+ G_CALLBACK (message_list_localized_re_separators_changed_cb), message_list);
+
+ message_list_localized_re_changed_cb (message_list->priv->mail_settings, NULL, message_list);
+ message_list_localized_re_separators_changed_cb (message_list->priv->mail_settings, NULL,
message_list);
}
static void
@@ -6859,7 +6918,7 @@ mail_regen_list (MessageList *message_list,
GCancellable *cancellable;
RegenData *new_regen_data;
RegenData *old_regen_data;
- gchar *prefixes, *tmp_search_copy = NULL;
+ gchar *tmp_search_copy = NULL;
if (!search) {
old_regen_data = message_list_ref_regen_data (message_list);
@@ -6890,23 +6949,6 @@ mail_regen_list (MessageList *message_list,
return;
}
- g_mutex_lock (&message_list->priv->re_prefixes_lock);
-
- g_strfreev (message_list->priv->re_prefixes);
- prefixes = g_settings_get_string (message_list->priv->mail_settings, "composer-localized-re");
- message_list->priv->re_prefixes = g_strsplit (prefixes ? prefixes : "", ",", -1);
- g_free (prefixes);
-
- g_strfreev (message_list->priv->re_separators);
- message_list->priv->re_separators = g_settings_get_strv (message_list->priv->mail_settings,
"composer-localized-re-separators");
-
- if (message_list->priv->re_separators && !*message_list->priv->re_separators) {
- g_strfreev (message_list->priv->re_separators);
- message_list->priv->re_separators = NULL;
- }
-
- g_mutex_unlock (&message_list->priv->re_prefixes_lock);
-
g_mutex_lock (&message_list->priv->regen_lock);
old_regen_data = message_list->priv->regen_data;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]