[evolution] I#854 - Offer "Saved searches" submenu in the search bar



commit e7d88586c75cdefa60d54ad7466e8118b2f6976c
Author: Milan Crha <mcrha redhat com>
Date:   Fri Jun 26 09:01:39 2020 +0200

    I#854 - Offer "Saved searches" submenu in the search bar
    
    Closes https://gitlab.gnome.org/GNOME/evolution/-/issues/854

 data/ui/evolution-calendars.ui     |  3 +++
 data/ui/evolution-contacts.ui      |  3 +++
 data/ui/evolution-mail.ui          |  3 +++
 data/ui/evolution-memos.ui         |  3 +++
 data/ui/evolution-tasks.ui         |  3 +++
 src/shell/e-shell-view.c           |  4 ++++
 src/shell/e-shell-window-actions.c | 22 ++++++++++++++++++++++
 src/shell/e-shell-window-actions.h |  2 ++
 src/shell/e-shell-window-private.c |  4 ----
 9 files changed, 43 insertions(+), 4 deletions(-)
---
diff --git a/data/ui/evolution-calendars.ui b/data/ui/evolution-calendars.ui
index fbb97982dc..b7e85ec70b 100644
--- a/data/ui/evolution-calendars.ui
+++ b/data/ui/evolution-calendars.ui
@@ -164,5 +164,8 @@
     <menuitem action='calendar-search-any-field-contains'/>
     <separator/>
     <menuitem action='search-advanced'/>
+    <menu action='saved-searches'>
+      <placeholder name='custom-rules'/>
+    </menu>
   </popup>
 </ui>
diff --git a/data/ui/evolution-contacts.ui b/data/ui/evolution-contacts.ui
index 233a388de6..77e6e485f9 100644
--- a/data/ui/evolution-contacts.ui
+++ b/data/ui/evolution-contacts.ui
@@ -100,5 +100,8 @@
     <menuitem action='contact-search-any-field-contains'/>
     <separator/>
     <menuitem action='search-advanced'/>
+    <menu action='saved-searches'>
+      <placeholder name='custom-rules'/>
+    </menu>
   </popup>
 </ui>
diff --git a/data/ui/evolution-mail.ui b/data/ui/evolution-mail.ui
index 3cc2543259..f3b1fac0a2 100644
--- a/data/ui/evolution-mail.ui
+++ b/data/ui/evolution-mail.ui
@@ -173,5 +173,8 @@
     <menuitem action='mail-search-free-form-expr'/>
     <separator/>
     <menuitem action='search-advanced'/>
+    <menu action='saved-searches'>
+      <placeholder name='custom-rules'/>
+    </menu>
   </popup>
 </ui>
diff --git a/data/ui/evolution-memos.ui b/data/ui/evolution-memos.ui
index 1e8fc428ad..8810b91ce9 100644
--- a/data/ui/evolution-memos.ui
+++ b/data/ui/evolution-memos.ui
@@ -80,5 +80,8 @@
     <menuitem action='memo-search-any-field-contains'/>
     <separator/>
     <menuitem action='search-advanced'/>
+    <menu action='saved-searches'>
+      <placeholder name='custom-rules'/>
+    </menu>
   </popup>
 </ui>
diff --git a/data/ui/evolution-tasks.ui b/data/ui/evolution-tasks.ui
index 4d10964f8f..8fb655218f 100644
--- a/data/ui/evolution-tasks.ui
+++ b/data/ui/evolution-tasks.ui
@@ -93,5 +93,8 @@
     <menuitem action='task-search-any-field-contains'/>
     <separator/>
     <menuitem action='search-advanced'/>
+    <menu action='saved-searches'>
+      <placeholder name='custom-rules'/>
+    </menu>
   </popup>
 </ui>
diff --git a/src/shell/e-shell-view.c b/src/shell/e-shell-view.c
index 9975da9c7b..63025b1f69 100644
--- a/src/shell/e-shell-view.c
+++ b/src/shell/e-shell-view.c
@@ -34,6 +34,7 @@
 
 #include "e-shell-searchbar.h"
 #include "e-shell-window-actions.h"
+#include "e-shell-window-private.h"
 
 #define E_SHELL_VIEW_GET_PRIVATE(obj) \
        (G_TYPE_INSTANCE_GET_PRIVATE \
@@ -726,6 +727,9 @@ shell_view_toggled (EShellView *shell_view)
        }
 
        gtk_ui_manager_ensure_update (ui_manager);
+
+       if (view_is_active)
+               e_shell_window_update_search_menu (shell_window);
 }
 
 static void
diff --git a/src/shell/e-shell-window-actions.c b/src/shell/e-shell-window-actions.c
index db7c078f66..c3eeaa7efb 100644
--- a/src/shell/e-shell-window-actions.c
+++ b/src/shell/e-shell-window-actions.c
@@ -961,6 +961,13 @@ static GtkActionEntry shell_entries[] = {
          N_("Exit the program"),
          G_CALLBACK (action_quit_cb) },
 
+       { "saved-searches",
+         NULL,
+         N_("_Saved Searches"),
+         NULL,
+         NULL,
+         NULL },
+
        { "search-advanced",
          NULL,
          N_("_Advanced Search…"),
@@ -1825,6 +1832,7 @@ e_shell_window_update_search_menu (EShellWindow *shell_window)
        GtkActionGroup *action_group;
        const gchar *source;
        const gchar *view_name;
+       gchar *search_options_path;
        gboolean sensitive;
        guint merge_id;
        gint ii = 0;
@@ -1842,6 +1850,7 @@ e_shell_window_update_search_menu (EShellWindow *shell_window)
 
        shell_view_class = E_SHELL_VIEW_GET_CLASS (shell_view);
        context = shell_view_class->search_context;
+       search_options_path = g_strconcat (shell_view_class->search_options, "/saved-searches/custom-rules", 
NULL);
 
        source = E_FILTER_SOURCE_INCOMING;
 
@@ -1859,6 +1868,9 @@ e_shell_window_update_search_menu (EShellWindow *shell_window)
        e_action_group_remove_all_actions (action_group);
        gtk_ui_manager_ensure_update (ui_manager);
 
+       if (!gtk_ui_manager_get_widget (ui_manager, search_options_path))
+               g_clear_pointer (&search_options_path, g_free);
+
        rule = e_rule_context_next_rule (context, NULL, source);
        while (rule != NULL) {
                GtkAction *action;
@@ -1900,9 +1912,19 @@ e_shell_window_update_search_menu (EShellWindow *shell_window)
                        action_name, action_name,
                        GTK_UI_MANAGER_AUTO, FALSE);
 
+               if (search_options_path) {
+                       gtk_ui_manager_add_ui (
+                               ui_manager, merge_id,
+                               search_options_path,
+                               action_name, action_name,
+                               GTK_UI_MANAGER_AUTO, FALSE);
+               }
+
                g_free (action_name);
                g_free (action_label);
 
                rule = e_rule_context_next_rule (context, rule, source);
        }
+
+       g_clear_pointer (&search_options_path, g_free);
 }
diff --git a/src/shell/e-shell-window-actions.h b/src/shell/e-shell-window-actions.h
index 06a106af94..3d55c7fe15 100644
--- a/src/shell/e-shell-window-actions.h
+++ b/src/shell/e-shell-window-actions.h
@@ -64,6 +64,8 @@
        E_SHELL_WINDOW_ACTION ((window), "quit")
 #define E_SHELL_WINDOW_ACTION_SEARCH_ADVANCED(window) \
        E_SHELL_WINDOW_ACTION ((window), "search-advanced")
+#define E_SHELL_WINDOW_ACTION_SAVED_SEARCHES(window) \
+       E_SHELL_WINDOW_ACTION ((window), "saved-searches")
 #define E_SHELL_WINDOW_ACTION_SEARCH_CLEAR(window) \
        E_SHELL_WINDOW_ACTION ((window), "search-clear")
 #define E_SHELL_WINDOW_ACTION_SEARCH_EDIT(window) \
diff --git a/src/shell/e-shell-window-private.c b/src/shell/e-shell-window-private.c
index 008eeb6890..059e7b57c6 100644
--- a/src/shell/e-shell-window-private.c
+++ b/src/shell/e-shell-window-private.c
@@ -487,10 +487,6 @@ e_shell_window_private_constructed (EShellWindow *shell_window)
                shell_window, "notify::active-view",
                G_CALLBACK (e_shell_window_update_view_menu), NULL);
 
-       e_signal_connect_notify (
-               shell_window, "notify::active-view",
-               G_CALLBACK (e_shell_window_update_search_menu), NULL);
-
 #ifndef G_OS_WIN32
        /* Support lockdown. */
 


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