[dconf-editor] Allow to reload a search.



commit fb6a8a5c51a250c3334d95fae04ef3084c0c35c6
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date:   Sat Jan 5 17:39:53 2019 +0100

    Allow to reload a search.
    
    Having a "previous" functionality would be great, but it is
    hard to get. Instead, allowing to reload the last search is
    easy, and would solve most of the use cases. Let's do that.

 editor/browser-window.vala | 28 +++++++++++++----
 editor/dconf-editor.vala   | 78 ++++++++++++++++++++++++----------------------
 editor/help-overlay.ui     | 66 ++++++++++++++++++++++++++-------------
 3 files changed, 107 insertions(+), 65 deletions(-)
---
diff --git a/editor/browser-window.vala b/editor/browser-window.vala
index 40d2898..d223936 100644
--- a/editor/browser-window.vala
+++ b/editor/browser-window.vala
@@ -287,6 +287,9 @@ private abstract class BrowserWindow : BaseWindow
         else if (current_type == ViewType.OBJECT)
             saved_selection = "";
 
+        if (type == ViewType.SEARCH && path != "")
+            last_non_empty_search = path;
+
         current_type = type;
         current_path = path;
 
@@ -491,8 +494,8 @@ private abstract class BrowserWindow : BaseWindow
 
         { "toggle-config",      toggle_config           },  // <P>i
 
-        { "search-global",      toggle_search_global    },  // <P>f
-        { "search-local",       toggle_search_local     },  // <P>F
+        { "search-global",      search_global,  "b"     },  // <P>f, <P><A>f
+        { "search-local",       search_local,   "b"     },  // <P>F, <F><A>F
         { "edit-path-end",      edit_path_end           },  // <P>l
         { "edit-path-last",     edit_path_last          },  // <P>L
 
@@ -559,8 +562,10 @@ private abstract class BrowserWindow : BaseWindow
     \*/
 
     private bool search_is_local = false;
+    private string last_non_empty_search = "";
 
-    private void toggle_search_global                   (/* SimpleAction action, Variant? variant */)   // 
TODO unduplicate?
+    private void search_global                          (SimpleAction action, Variant? variant)
+        requires (variant != null)
     {
         if (is_in_in_window_mode ())        // TODO better
             return;
@@ -571,7 +576,10 @@ private abstract class BrowserWindow : BaseWindow
         if (!headerbar.search_mode_enabled)
         {
             init_next_search = true;
-            request_search (PathEntry.SearchMode.SEARCH);
+            if (((!) variant).get_boolean () && last_non_empty_search != "")
+                request_search (PathEntry.SearchMode.EDIT_PATH_SELECT_ALL, /* search term or null */ 
last_non_empty_search);
+            else
+                request_search (PathEntry.SearchMode.SEARCH);
         }
         else if (!headerbar.entry_has_focus)
             headerbar.entry_grab_focus (true);
@@ -589,7 +597,8 @@ private abstract class BrowserWindow : BaseWindow
             stop_search ();
     }
 
-    private void toggle_search_local                    (/* SimpleAction action, Variant? variant */)
+    private void search_local                           (SimpleAction action, Variant? variant)
+        requires (variant != null)
     {
         if (is_in_in_window_mode ())        // TODO better
             return;
@@ -600,7 +609,14 @@ private abstract class BrowserWindow : BaseWindow
         if (!headerbar.search_mode_enabled)
         {
             init_next_search = true;
-            request_search (PathEntry.SearchMode.SEARCH, /* search term or null */ null, /* local search */ 
current_path != "/");
+            if (((!) variant).get_boolean () && last_non_empty_search != "")
+                request_search (PathEntry.SearchMode.EDIT_PATH_SELECT_ALL,
+                                /* search term or null */ last_non_empty_search,
+                                /* local search */ current_path != "/");
+            else
+                request_search (PathEntry.SearchMode.SEARCH,
+                                /* search term or null */ null,
+                                /* local search */ current_path != "/");
         }
         else if (!headerbar.entry_has_focus)
             headerbar.entry_grab_focus (true);
diff --git a/editor/dconf-editor.vala b/editor/dconf-editor.vala
index adfa99a..010c0db 100644
--- a/editor/dconf-editor.vala
+++ b/editor/dconf-editor.vala
@@ -322,44 +322,46 @@ private class ConfigurationEditor : Gtk.Application
         Gtk.Window.set_default_icon_name ("ca.desrt.dconf-editor");
 
         add_action_entries (action_entries, this);
-        set_accels_for_action ("kbd.toggle-bookmark",   {        "<Primary>b",
-                                                          "<Shift><Primary>b" });
-        set_accels_for_action ("base.copy",             {        "<Primary>c" });
-        set_accels_for_action ("base.copy-alt",         { "<Shift><Primary>c" });
-        set_accels_for_action ("kbd.bookmark",          {        "<Primary>d" });
-        set_accels_for_action ("kbd.unbookmark",        { "<Shift><Primary>d" });
-        set_accels_for_action ("key.search-global",     {        "<Primary>f" });   // TODO <Alt><Primary>f 
for using last search text?
-        set_accels_for_action ("key.search-local",      { "<Shift><Primary>f" });   // TODO similarly, 
<Shift><Alt><Primary>f also?
-        set_accels_for_action ("key.next-match",        {        "<Primary>g" });
-        set_accels_for_action ("key.previous-match",    { "<Shift><Primary>g" });
-        set_accels_for_action ("key.toggle-config",     {        "<Primary>i" });   // <Shift><Primary>i is 
gtk editor
-        set_accels_for_action ("kbd.modifications",     {        "<Alt>i"     });
-        set_accels_for_action ("key.edit-path-end",     {        "<Primary>l" });
-        set_accels_for_action ("key.edit-path-last",    { "<Shift><Primary>l" });
-        set_accels_for_action ("app.quit",              {        "<Primary>q" });
-        set_accels_for_action ("app.apply-and-quit",    { "<Shift><Primary>q" });
-        set_accels_for_action ("base.paste",            {        "<Primary>v" });   // 
https://bugzilla.gnome.org/show_bug.cgi?id=762257 is WONTFIX
-        set_accels_for_action ("base.paste-alt",        { "<Shift><Primary>v" });
-
-        set_accels_for_action ("key.open-root",         { "<Shift><Alt>Up"    });
-        set_accels_for_action ("key.open-parent",       {        "<Alt>Up"    });
-        set_accels_for_action ("key.open-child",        {        "<Alt>Down"  });
-        set_accels_for_action ("key.open-last-child",   { "<Shift><Alt>Down"  });
-
-        set_accels_for_action ("base.toggle-hamburger", {          "F10"      });
-        set_accels_for_action ("kbd.escape",            {          "Escape"   });
-        set_accels_for_action ("base.menu",             {          "Menu"     });
-
-        set_accels_for_action ("kbd.set-to-default",    { "<Primary>Delete",
-                                                          "<Primary>KP_Delete",
-                                                          "<Primary>decimalpoint",
-                                                          "<Primary>period",
-                                                          "<Primary>KP_Decimal" }); // TODO "BackSpace"?
-        set_accels_for_action ("kbd.toggle-boolean",    { "<Primary>Return",
-                                                          "<Primary>KP_Enter"   });
-
-     // set_accels_for_action ("app.about",             { "<Shift><Primary>F1"  }); // TODO report bug: 
needs a dance in the window
-        set_accels_for_action ("win.show-help-overlay", {                 "F1"  }); // "<Primary>F1" is 
automatically done
+        set_accels_for_action ("kbd.toggle-bookmark",       {        "<Primary>b",
+                                                              "<Shift><Primary>b"       });
+        set_accels_for_action ("base.copy",                 {        "<Primary>c"       });
+        set_accels_for_action ("base.copy-alt",             { "<Shift><Primary>c"       });
+        set_accels_for_action ("kbd.bookmark",              {        "<Primary>d"       });
+        set_accels_for_action ("kbd.unbookmark",            { "<Shift><Primary>d"       });
+        set_accels_for_action ("key.search-global(false)",  {        "<Primary>f"       });
+        set_accels_for_action ("key.search-local(false)",   { "<Shift><Primary>f"       });
+        set_accels_for_action ("key.search-global(true)",   {        "<Primary><Alt>f"  });
+        set_accels_for_action ("key.search-local(true)",    { "<Shift><Primary><Alt>f"  });
+        set_accels_for_action ("key.next-match",            {        "<Primary>g"       });
+        set_accels_for_action ("key.previous-match",        { "<Shift><Primary>g"       });
+        set_accels_for_action ("key.toggle-config",         {        "<Primary>i"       });   // 
<Shift><Primary>i is gtk editor
+        set_accels_for_action ("kbd.modifications",         {        "<Alt>i"           });
+        set_accels_for_action ("key.edit-path-end",         {        "<Primary>l"       });
+        set_accels_for_action ("key.edit-path-last",        { "<Shift><Primary>l"       });
+        set_accels_for_action ("app.quit",                  {        "<Primary>q"       });
+        set_accels_for_action ("app.apply-and-quit",        { "<Shift><Primary>q"       });
+        set_accels_for_action ("base.paste",                {        "<Primary>v"       });   // 
https://bugzilla.gnome.org/show_bug.cgi?id=762257 is WONTFIX
+        set_accels_for_action ("base.paste-alt",            { "<Shift><Primary>v"       });
+
+        set_accels_for_action ("key.open-root",             { "<Shift><Alt>Up"          });
+        set_accels_for_action ("key.open-parent",           {        "<Alt>Up"          });
+        set_accels_for_action ("key.open-child",            {        "<Alt>Down"        });
+        set_accels_for_action ("key.open-last-child",       { "<Shift><Alt>Down"        });
+
+        set_accels_for_action ("base.toggle-hamburger",     {          "F10"            });
+        set_accels_for_action ("kbd.escape",                {          "Escape"         });
+        set_accels_for_action ("base.menu",                 {          "Menu"           });
+
+        set_accels_for_action ("kbd.set-to-default",        { "<Primary>Delete",
+                                                              "<Primary>KP_Delete",
+                                                              "<Primary>decimalpoint",
+                                                              "<Primary>period",
+                                                              "<Primary>KP_Decimal"     }); // TODO 
"BackSpace"?
+        set_accels_for_action ("kbd.toggle-boolean",        { "<Primary>Return",
+                                                              "<Primary>KP_Enter"       });
+
+     // set_accels_for_action ("app.about",                 { "<Shift><Primary>F1"      }); // TODO bug: 
needs a dance in the window
+        set_accels_for_action ("win.show-help-overlay",     {                 "F1"      }); // "<Primary>F1" 
is automatically done
 
         init_night_mode ();
 
diff --git a/editor/help-overlay.ui b/editor/help-overlay.ui
index fcbc787..65ba6e4 100644
--- a/editor/help-overlay.ui
+++ b/editor/help-overlay.ui
@@ -13,7 +13,7 @@
               <object class="GtkShortcutsShortcut">
                 <property name="visible">True</property>
                 <property name="title" translatable="yes" context="shortcut window">Bookmarks menu</property>
-                <property name="accelerator">&lt;Primary&gt;b</property>
+                <property name="accelerator">&lt;Primary&gt;b</property> <!-- &lt;Primary&gt;&lt;Shift&gt;b 
does the same -->
               </object>
             </child>
             <child>
@@ -91,6 +91,14 @@
                 <property name="accelerator">&lt;Primary&gt;f</property>
               </object>
             </child>
+            <child>
+              <object class="GtkShortcutsShortcut">
+                <property name="visible">True</property>
+                <!-- Translators: does the same thing as "Toggle search", but loads the search entry with 
the last searched text -->
+                <property name="title" translatable="yes" context="shortcut window">Search again</property>
+                <property name="accelerator">&lt;Primary&gt;&lt;Alt&gt;f</property>
+              </object>
+            </child>
             <child>
               <object class="GtkShortcutsShortcut">
                 <property name="visible">True</property>
@@ -98,6 +106,14 @@
                 <property name="accelerator">&lt;Primary&gt;&lt;Shift&gt;f</property>
               </object>
             </child>
+            <child>
+              <object class="GtkShortcutsShortcut">
+                <property name="visible">False</property>
+                <!-- Translators: does the same thing as "Toggle local search", but loads the search entry 
with the last searched text; entry hidden for now -->
+                <property name="title" translatable="yes" context="shortcut window">Search locally 
again</property>
+                <property name="accelerator">&lt;Primary&gt;&lt;Shift&gt;&lt;Alt&gt;f</property>
+              </object>
+            </child>
             <child>
               <object class="GtkShortcutsShortcut">
                 <property name="visible">True</property>
@@ -105,6 +121,14 @@
                 <property name="accelerator">&lt;Primary&gt;v</property>
               </object>
             </child>
+            <child>
+              <object class="GtkShortcutsShortcut">
+                <property name="visible">False</property>
+                <!-- Translators: does the same thing as "Paste as search", but works even if an entry or 
textview is selected; entry hidden for now -->
+                <property name="title" translatable="yes" context="shortcut window">Paste as search 
(force)</property>
+                <property name="accelerator">&lt;Primary&gt;&lt;Shift&gt;v</property>
+              </object>
+            </child>
             <child>
               <object class="GtkShortcutsShortcut">
                 <property name="visible">True</property>
@@ -135,26 +159,6 @@
             </child>
           </object>
         </child>
-        <child>
-          <object class="GtkShortcutsGroup">
-            <property name="visible">True</property>
-            <property name="title" translatable="yes" context="shortcut window">Generic</property>
-            <child>
-              <object class="GtkShortcutsShortcut">
-                <property name="visible">True</property>
-                <property name="title" translatable="yes" context="shortcut window">About</property>
-                <property name="accelerator">&lt;Primary&gt;&lt;Shift&gt;F1</property>
-              </object>
-            </child>
-            <child>
-              <object class="GtkShortcutsShortcut">
-                <property name="visible">True</property>
-                <property name="title" translatable="yes" context="shortcut window">Show this help</property>
-                <property name="accelerator">&lt;Primary&gt;question &lt;Primary&gt;F1</property>
-              </object>
-            </child>
-          </object>
-        </child>
         <child>
           <object class="GtkShortcutsGroup">
             <property name="visible">True</property>
@@ -230,6 +234,26 @@
             </child>
           </object>
         </child>
+        <child>
+          <object class="GtkShortcutsGroup">
+            <property name="visible">True</property>
+            <property name="title" translatable="yes" context="shortcut window">Generic</property>
+            <child>
+              <object class="GtkShortcutsShortcut">
+                <property name="visible">True</property>
+                <property name="title" translatable="yes" context="shortcut window">Show this help</property>
+                <property name="accelerator">&lt;Primary&gt;question &lt;Primary&gt;F1</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkShortcutsShortcut">
+                <property name="visible">True</property>
+                <property name="title" translatable="yes" context="shortcut window">About</property>
+                <property name="accelerator">&lt;Primary&gt;&lt;Shift&gt;F1</property>
+              </object>
+            </child>
+          </object>
+        </child>
         <child>
           <object class="GtkShortcutsGroup">
             <property name="visible">True</property>


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