[evolution] I#1502 - Mail: Option to make search scope global



commit c8c5191b9ea6d9a306476d991b476782df672ed0
Author: Milan Crha <mcrha redhat com>
Date:   Thu May 27 14:05:38 2021 +0200

    I#1502 - Mail: Option to make search scope global
    
    Closes https://gitlab.gnome.org/GNOME/evolution/-/issues/1502

 data/org.gnome.evolution.mail.gschema.xml.in |  5 +++++
 src/modules/mail/e-mail-shell-view-private.c | 25 +++++++++++++++++--------
 2 files changed, 22 insertions(+), 8 deletions(-)
---
diff --git a/data/org.gnome.evolution.mail.gschema.xml.in b/data/org.gnome.evolution.mail.gschema.xml.in
index dbb9b70435..fe122c14ad 100644
--- a/data/org.gnome.evolution.mail.gschema.xml.in
+++ b/data/org.gnome.evolution.mail.gschema.xml.in
@@ -294,6 +294,11 @@
       <_summary>Enable to use a similar message list view settings for all folders</_summary>
       <_description>Enable to use a similar message list view settings for all folders.</_description>
     </key>
+    <key name="global-view-search" type="b">
+      <default>true</default>
+      <_summary>Enable to use the same search settings for all folders</_summary>
+      <_description>This is considered only in combination with the 'global-view-setting'.</_description>
+    </key>
     <key name="mark-citations" type="b">
       <default>true</default>
       <_summary>Mark citations in the message “Preview”</_summary>
diff --git a/src/modules/mail/e-mail-shell-view-private.c b/src/modules/mail/e-mail-shell-view-private.c
index 077c74fe9f..44dd24c26a 100644
--- a/src/modules/mail/e-mail-shell-view-private.c
+++ b/src/modules/mail/e-mail-shell-view-private.c
@@ -777,9 +777,10 @@ e_mail_shell_view_restore_state (EMailShellView *mail_shell_view)
        EMailView *mail_view;
        CamelFolder *folder;
        CamelVeeFolder *vee_folder;
-       const gchar *old_state_group;
+       const gchar *old_state_group, *new_state_group;
        gchar *folder_uri;
-       gchar *new_state_group;
+       gchar *tmp = NULL;
+       GSettings *settings;
 
        /* XXX Move this to EMailShellContent. */
 
@@ -816,18 +817,26 @@ e_mail_shell_view_restore_state (EMailShellView *mail_shell_view)
        if (vee_folder != NULL && folder == CAMEL_FOLDER (vee_folder))
                goto exit;
 
-       folder_uri = e_mail_folder_uri_from_folder (folder);
-       new_state_group = g_strdup_printf ("Folder %s", folder_uri);
+       settings = e_util_ref_settings ("org.gnome.evolution.mail");
+       if (g_settings_get_boolean (settings, "global-view-setting") &&
+           g_settings_get_boolean (settings, "global-view-search")) {
+                   new_state_group = "GlobalSearch";
+       } else {
+               folder_uri = e_mail_folder_uri_from_folder (folder);
+               tmp = g_strdup_printf ("Folder %s", folder_uri);
+               new_state_group = tmp;
+               g_free (folder_uri);
+       }
+
        old_state_group = e_shell_searchbar_get_state_group (searchbar);
-       g_free (folder_uri);
 
-       /* Avoid loading search state unnecessarily. */
-       if (g_strcmp0 (new_state_group, old_state_group) != 0) {
+       /* Avoid loading search state unnecessarily, unless it's the global search. */
+       if (!tmp || g_strcmp0 (new_state_group, old_state_group) != 0) {
                e_shell_searchbar_set_state_group (searchbar, new_state_group);
                e_shell_searchbar_load_state (searchbar);
        }
 
-       g_free (new_state_group);
+       g_free (tmp);
 
 exit:
        g_clear_object (&folder);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]