[dconf-editor] Allow local search.
- From: Arnaud B. <arnaudb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dconf-editor] Allow local search.
- Date: Sat, 5 Jan 2019 15:16:28 +0000 (UTC)
commit 4ac67811a2b204d03200240711e15d97231f327e
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date: Fri Jan 4 22:12:20 2019 +0100
Allow local search.
The "Show folder informations" functionality does not look right
as a browsable entry of the keys list. Instead, the local search
functionality is wanted, and having it there would probably make
it more discoverable and used than in a menu. Let's do that, so.
editor/browser-stack.vala | 4 +-
editor/browser-view.vala | 11 +-
editor/browser-window.vala | 167 ++++++++++++++++-----
editor/dconf-editor.css | 2 +-
editor/dconf-editor.gresource.xml | 2 +-
editor/dconf-editor.vala | 3 +-
editor/dconf-view.vala | 4 +-
editor/dconf-window.vala | 8 +-
...nfig-list-box-row.ui => filter-list-box-row.ui} | 4 +-
editor/help-overlay.ui | 111 +++++++-------
editor/key-list-box-row.vala | 20 ++-
editor/meson.build | 2 +-
editor/registry-list.vala | 62 ++++----
editor/registry-search.vala | 57 ++++---
14 files changed, 285 insertions(+), 172 deletions(-)
---
diff --git a/editor/browser-stack.vala b/editor/browser-stack.vala
index 27a823e..4ebb22c 100644
--- a/editor/browser-stack.vala
+++ b/editor/browser-stack.vala
@@ -197,9 +197,9 @@ private class BrowserStack : Grid, AdaptativeWidget, BrowserContent
* * Reload
\*/
- internal void set_search_parameters (string current_path, uint16 current_context_id, string []
bookmarks, SortingOptions sorting_options)
+ internal void set_search_parameters (bool local_search, string current_path, uint16 current_context_id,
string [] bookmarks, SortingOptions sorting_options)
{
- search_view.set_search_parameters (current_path, current_context_id, bookmarks, sorting_options);
+ search_view.set_search_parameters (local_search, current_path, current_context_id, bookmarks,
sorting_options);
}
internal bool check_reload_folder (Variant? fresh_key_model)
diff --git a/editor/browser-view.vala b/editor/browser-view.vala
index a4c890b..c01d558 100644
--- a/editor/browser-view.vala
+++ b/editor/browser-view.vala
@@ -20,8 +20,6 @@ using Gtk;
private class SimpleSettingObject : Object
{
[CCode (notify = false)] public bool is_pinned { internal get; internal construct; }
-
- [CCode (notify = false)] public bool is_config { internal get; private construct; }
[CCode (notify = false)] public bool is_search { internal get; internal construct; }
[CCode (notify = false)] public uint16 context_id { internal get; internal construct; }
@@ -32,19 +30,18 @@ private class SimpleSettingObject : Object
construct
{
- is_config = is_pinned && !is_search;
casefolded_name = name.casefold ();
}
- internal SimpleSettingObject.from_base_path (uint16 _context_id, string _name, string _base_path, bool
_is_search = false, bool _is_config_or_is_pinned_search = false)
+ internal SimpleSettingObject.from_base_path (uint16 _context_id, string _name, string _base_path, bool
_is_search = false, bool _is_pinned = false)
{
string _full_name = ModelUtils.recreate_full_name (_base_path, _name,
ModelUtils.is_folder_context_id (_context_id));
- Object (context_id: _context_id, name: _name, full_name: _full_name, is_search: _is_search,
is_pinned: _is_config_or_is_pinned_search);
+ Object (context_id: _context_id, name: _name, full_name: _full_name, is_search: _is_search,
is_pinned: _is_pinned);
}
- internal SimpleSettingObject.from_full_name (uint16 _context_id, string _name, string _full_name, bool
_is_search = false, bool _is_config_or_is_pinned_search = false)
+ internal SimpleSettingObject.from_full_name (uint16 _context_id, string _name, string _full_name, bool
_is_search = false, bool _is_pinned = false)
{
- Object (context_id: _context_id, name: _name, full_name: _full_name, is_search: _is_search,
is_pinned: _is_config_or_is_pinned_search);
+ Object (context_id: _context_id, name: _name, full_name: _full_name, is_search: _is_search,
is_pinned: _is_pinned);
}
}
diff --git a/editor/browser-window.vala b/editor/browser-window.vala
index 46265a6..d568818 100644
--- a/editor/browser-window.vala
+++ b/editor/browser-window.vala
@@ -58,7 +58,6 @@ private abstract class BrowserWindow : BaseWindow
private SimpleAction open_path_action;
protected SimpleAction reload_search_action;
- protected bool reload_search_next = true;
private void install_browser_action_entries ()
{
@@ -86,6 +85,8 @@ private abstract class BrowserWindow : BaseWindow
{ "open-config", open_config, "s" },
{ "open-config-local", open_config_local },
{ "open-search", open_search, "s" },
+ { "open-search-local", open_search_local },
+ { "open-search-global", open_search_global },
{ "next-search", next_search, "s" },
{ "open-parent", open_parent, "s" },
@@ -148,7 +149,27 @@ private abstract class BrowserWindow : BaseWindow
string search = ((!) search_variant).get_string ();
- request_search (true, PathEntry.SearchMode.EDIT_PATH_SELECT_ALL, search);
+ init_next_search = true;
+ request_search (PathEntry.SearchMode.EDIT_PATH_SELECT_ALL, /* search term or null */ search);
+ }
+
+ private void open_search_local (/* SimpleAction action, Variant? search_variant */)
+ {
+ close_in_window_panels ();
+
+ init_next_search = true;
+ if (main_view.current_view == ViewType.SEARCH) // possible call from keyboard, then do not clear
entry
+ request_search (PathEntry.SearchMode.UNCLEAR, /* search term or null */ null, /* local search */
true);
+ else
+ request_search (PathEntry.SearchMode.SEARCH, /* search term or null */ null, /* local search */
true);
+ }
+
+ private void open_search_global (/* SimpleAction action, Variant? search_variant */)
+ {
+ close_in_window_panels ();
+
+ init_next_search = true;
+ request_search ();
}
private void next_search (SimpleAction action, Variant? search_variant)
@@ -157,7 +178,8 @@ private abstract class BrowserWindow : BaseWindow
saved_type = ViewType.FOLDER;
saved_view = ((!) search_variant).get_string ();
- request_search (true, PathEntry.SearchMode.EDIT_PATH_MOVE_END, saved_view);
+ init_next_search = true;
+ request_search (PathEntry.SearchMode.EDIT_PATH_MOVE_END, /* search term or null */ saved_view);
}
private void open_parent (SimpleAction action, Variant? path_variant)
@@ -199,7 +221,8 @@ private abstract class BrowserWindow : BaseWindow
private void reload_search (/* SimpleAction action, Variant? path_variant */)
{
- request_search (true);
+ init_next_search = true;
+ request_search ();
}
private void hide_search (/* SimpleAction action, Variant? path_variant */)
@@ -214,7 +237,8 @@ private abstract class BrowserWindow : BaseWindow
private void show_search (/* SimpleAction action, Variant? path_variant */)
{
- request_search (true, PathEntry.SearchMode.EDIT_PATH_SELECT_ALL);
+ init_next_search = true;
+ request_search (PathEntry.SearchMode.EDIT_PATH_SELECT_ALL);
}
private void toggle_search (SimpleAction action, Variant? path_variant)
@@ -223,7 +247,10 @@ private abstract class BrowserWindow : BaseWindow
bool search_request = ((!) path_variant).get_boolean ();
action.change_state (search_request);
if (search_request && !headerbar.search_mode_enabled)
- request_search (true, PathEntry.SearchMode.EDIT_PATH_SELECT_ALL);
+ {
+ init_next_search = true;
+ request_search (PathEntry.SearchMode.EDIT_PATH_SELECT_ALL);
+ }
else if (!search_request && headerbar.search_mode_enabled)
stop_search ();
}
@@ -238,7 +265,7 @@ private abstract class BrowserWindow : BaseWindow
{
saved_type = type;
saved_view = path;
- reload_search_next = true;
+ init_next_search = true;
}
else if (current_type == ViewType.FOLDER)
saved_selection = main_view.get_selected_row_name ();
@@ -260,15 +287,12 @@ private abstract class BrowserWindow : BaseWindow
protected abstract void request_object (string full_name, uint16 context_id =
ModelUtils.undefined_context_id, bool notify_missing = true, string schema_id = "");
protected abstract void request_config (string full_name);
- protected void request_search (bool reload, PathEntry.SearchMode mode = PathEntry.SearchMode.UNCLEAR,
string? search = null)
+ private bool init_next_search = true;
+ private void request_search (PathEntry.SearchMode mode = PathEntry.SearchMode.UNCLEAR, string? search =
null, bool local_search = false)
{
string selected_row = main_view.get_selected_row_name ();
- if (reload)
- {
- reload_search_action.set_enabled (false);
- reconfigure_search ();
- reload_search_next = false;
- }
+ if (init_next_search)
+ init_search (local_search);
if (mode != PathEntry.SearchMode.UNCLEAR)
headerbar.prepare_search (mode, search);
string search_text = search == null ? headerbar.text : (!) search;
@@ -276,10 +300,16 @@ private abstract class BrowserWindow : BaseWindow
if (mode != PathEntry.SearchMode.UNCLEAR)
main_view.select_row (selected_row);
if (!headerbar.entry_has_focus)
- headerbar.entry_grab_focus (false);
+ headerbar.entry_grab_focus (/* select text */ false); // FIXME keep cursor position
}
-
- protected abstract void reconfigure_search ();
+ private void init_search (bool local_search)
+ {
+ reload_search_action.set_enabled (false);
+ reconfigure_search (local_search);
+ search_is_local = local_search;
+ init_next_search = false;
+ }
+ protected abstract void reconfigure_search (bool local_search);
/*\
* * window state
@@ -320,7 +350,7 @@ private abstract class BrowserWindow : BaseWindow
private void search_changed_cb ()
{
- request_search (reload_search_next);
+ request_search ();
}
private void search_stopped_cb ()
@@ -332,7 +362,7 @@ private abstract class BrowserWindow : BaseWindow
request_folder (saved_view, saved_selection);
else
update_current_path (saved_type, strdup (saved_view));
- reload_search_next = true;
+ init_next_search = true;
}
/*\
@@ -352,12 +382,18 @@ private abstract class BrowserWindow : BaseWindow
if (shift)
{
if (main_view.current_view == ViewType.SEARCH)
- request_search (true, PathEntry.SearchMode.EDIT_PATH_MOVE_END, "/");
+ {
+ init_next_search = true;
+ request_search (PathEntry.SearchMode.EDIT_PATH_MOVE_END, /* search term or null */ "/");
+ }
else
request_folder (root_path);
}
else if (main_view.current_view == ViewType.SEARCH)
- request_search (true, PathEntry.SearchMode.EDIT_PATH_MOVE_END, ModelUtils.get_parent_path
(current_path));
+ {
+ init_next_search = true;
+ request_search (PathEntry.SearchMode.EDIT_PATH_MOVE_END, /* search term or null */
ModelUtils.get_parent_path (current_path));
+ }
else if (main_view.current_view == ViewType.CONFIG)
request_folder (current_path);
else
@@ -374,7 +410,8 @@ private abstract class BrowserWindow : BaseWindow
if (main_view.current_view == ViewType.SEARCH)
{
- request_search (false, PathEntry.SearchMode.EDIT_PATH_MOVE_END); // TODO when (!shift), move
at next ‘/’
+ init_next_search = false;
+ request_search (PathEntry.SearchMode.EDIT_PATH_MOVE_END); // TODO when (!shift), move at next
‘/’
return;
}
@@ -415,7 +452,10 @@ private abstract class BrowserWindow : BaseWindow
else if (main_view.current_view == ViewType.OBJECT)
request_object (current_path, ModelUtils.undefined_context_id, false);
else if (main_view.current_view == ViewType.SEARCH)
- request_search (true);
+ {
+ init_next_search = true;
+ request_search ();
+ }
}
/*\
@@ -431,19 +471,20 @@ private abstract class BrowserWindow : BaseWindow
private const GLib.ActionEntry [] key_action_entries =
{
- { "next-match", next_match }, // <P>g // usual shortcut for "next-match" in a
SearchEntry; see also "Down"
- { "previous-match", previous_match }, // <P>G // usual shortcut for "previous-match" in a
SearchEntry; see also "Up"
+ { "next-match", next_match }, // <P>g, usual shortcut for "next-match" in
a SearchEntry; see also "Down"
+ { "previous-match", previous_match }, // <P>G, usual shortcut for "previous-match" in
a SearchEntry; see also "Up"
- { "toggle-config", toggle_config }, // <P>i
+ { "toggle-config", toggle_config }, // <P>i
- { "toggle-search", _toggle_search }, // <P>f // TODO unduplicate (at least name)
- { "edit-path-end", edit_path_end }, // <P>l
- { "edit-path-last", edit_path_last }, // <P>L
+ { "search-global", toggle_search_global }, // <P>f
+ { "search-local", toggle_search_local }, // <P>F
+ { "edit-path-end", edit_path_end }, // <P>l
+ { "edit-path-last", edit_path_last }, // <P>L
- { "open-root", open_root }, // <S><A>Up
- { "open-parent", open_current_parent }, // <A>Up
- { "open-child", open_child }, // <A>Down
- { "open-last-child", open_last_child }, // <S><A>Down
+ { "open-root", open_root }, // <S><A>Up
+ { "open-parent", open_current_parent }, // <A>Up
+ { "open-child", open_child }, // <A>Down
+ { "open-last-child", open_last_child }, // <S><A>Down
};
/*\
@@ -502,7 +543,9 @@ private abstract class BrowserWindow : BaseWindow
* * keyboard search actions
\*/
- private void _toggle_search (/* SimpleAction action, Variant? variant */) //
TODO unduplicate?
+ private bool search_is_local = false;
+
+ private void toggle_search_global (/* SimpleAction action, Variant? variant */) //
TODO unduplicate?
{
if (is_in_in_window_mode ()) // TODO better
return;
@@ -511,21 +554,63 @@ private abstract class BrowserWindow : BaseWindow
main_view.close_popovers (); // could be needed if headerbar.search_mode_enabled
if (!headerbar.search_mode_enabled)
- request_search (true, PathEntry.SearchMode.SEARCH);
+ {
+ init_next_search = true;
+ request_search (PathEntry.SearchMode.SEARCH);
+ }
else if (!headerbar.entry_has_focus)
headerbar.entry_grab_focus (true);
+ else if (search_is_local)
+ {
+ init_next_search = true;
+ request_search ();
+ }
else if (headerbar.text.has_prefix ("/"))
- request_search (true, PathEntry.SearchMode.SEARCH);
+ {
+ init_next_search = true;
+ request_search (PathEntry.SearchMode.SEARCH);
+ }
else
stop_search ();
}
+ private void toggle_search_local (/* SimpleAction action, Variant? variant */)
+ {
+ if (is_in_in_window_mode ()) // TODO better
+ return;
+
+ headerbar.close_popovers (); // should never be needed if headerbar.search_mode_enabled
+ main_view.close_popovers (); // could be needed if headerbar.search_mode_enabled
+
+ if (!headerbar.search_mode_enabled)
+ {
+ init_next_search = true;
+ 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);
+ else if (search_is_local)
+ stop_search ();
+ else if (headerbar.text.has_prefix ("/"))
+ {
+ init_next_search = true;
+ request_search (PathEntry.SearchMode.SEARCH, /* search term or null */ null, /* local search */
true);
+ }
+ else if (saved_view != root_path)
+ {
+ init_next_search = true;
+ request_search (PathEntry.SearchMode.UNCLEAR, /* search term or null */ null, /* local search */
true);
+ }
+ // do nothing if search is started from root path
+ }
+
private void edit_path_end (/* SimpleAction action, Variant? variant */)
{
if (is_in_in_window_mode ())
return;
- request_search (true, PathEntry.SearchMode.EDIT_PATH_MOVE_END);
+ init_next_search = true;
+ request_search (PathEntry.SearchMode.EDIT_PATH_MOVE_END);
}
private void edit_path_last (/* SimpleAction action, Variant? variant */)
@@ -533,7 +618,8 @@ private abstract class BrowserWindow : BaseWindow
if (is_in_in_window_mode ())
return;
- request_search (true, PathEntry.SearchMode.EDIT_PATH_SELECT_LAST_WORD);
+ init_next_search = true;
+ request_search (PathEntry.SearchMode.EDIT_PATH_SELECT_LAST_WORD);
}
/*\
@@ -542,10 +628,11 @@ private abstract class BrowserWindow : BaseWindow
protected override void paste_text (string? text)
{
+ init_next_search = true;
if (text != null)
- request_search (true, PathEntry.SearchMode.EDIT_PATH_MOVE_END, text);
+ request_search (PathEntry.SearchMode.EDIT_PATH_MOVE_END, /* search term or null */ text);
else
- request_search (true, PathEntry.SearchMode.SEARCH);
+ request_search (PathEntry.SearchMode.SEARCH);
}
/*\
diff --git a/editor/dconf-editor.css b/editor/dconf-editor.css
index 0b0526c..040f8ab 100644
--- a/editor/dconf-editor.css
+++ b/editor/dconf-editor.css
@@ -255,8 +255,8 @@ window:not(.extra-small-window) .keys-list:dir(rtl) > row > .key > grid >
row > .erase.folder {
background-image:-gtk-icontheme("action-unavailable-symbolic"); }
row > .search {
background-image:-gtk-icontheme("edit-find-symbolic"); }
+ /* row > .config {
background-image:-gtk-icontheme("dialog-information-symbolic"); } */
row > .return {
background-image:-gtk-icontheme("edit-undo-symbolic"); }
- row > .config {
background-image:-gtk-icontheme("dialog-information-symbolic"); }
row > .key.delayed,
row > .dconf-key.key.delayed,
diff --git a/editor/dconf-editor.gresource.xml b/editor/dconf-editor.gresource.xml
index 2c8495c..16076a5 100644
--- a/editor/dconf-editor.gresource.xml
+++ b/editor/dconf-editor.gresource.xml
@@ -10,9 +10,9 @@
<file preprocess="xml-stripblanks">bookmarks-controller.ui</file>
<file preprocess="xml-stripblanks">browser-infobar.ui</file>
<file preprocess="xml-stripblanks">browser-stack.ui</file>
- <file preprocess="xml-stripblanks">config-list-box-row.ui</file>
<file>dconf-editor.css</file>
<file preprocess="xml-stripblanks">delayed-setting-view.ui</file>
+ <file preprocess="xml-stripblanks">filter-list-box-row.ui</file>
<file preprocess="xml-stripblanks">folder-list-box-row.ui</file>
<file preprocess="xml-stripblanks">key-list-box-row.ui</file>
<file>large-pathbar.css</file>
diff --git a/editor/dconf-editor.vala b/editor/dconf-editor.vala
index 069d495..adfa99a 100644
--- a/editor/dconf-editor.vala
+++ b/editor/dconf-editor.vala
@@ -328,7 +328,8 @@ private class ConfigurationEditor : Gtk.Application
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.toggle-search", { "<Primary>f" }); // TODO
<Shift><Primary>f something?
+ 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
diff --git a/editor/dconf-view.vala b/editor/dconf-view.vala
index ba89df0..d85a779 100644
--- a/editor/dconf-view.vala
+++ b/editor/dconf-view.vala
@@ -338,10 +338,10 @@ private class DConfView : BrowserView, AdaptativeWidget
* * reload
\*/
- internal void set_search_parameters (string current_path, string [] bookmarks)
+ internal void set_search_parameters (bool local_search, string current_path, string [] bookmarks)
{
hide_reload_warning ();
- dconf_content.set_search_parameters (current_path, last_context_id, bookmarks, sorting_options);
+ dconf_content.set_search_parameters (local_search, current_path, last_context_id, bookmarks,
sorting_options);
}
internal bool check_reload (ViewType type, string path, bool show_infobar)
diff --git a/editor/dconf-window.vala b/editor/dconf-window.vala
index 185173a..905c108 100644
--- a/editor/dconf-window.vala
+++ b/editor/dconf-window.vala
@@ -910,9 +910,9 @@ private class DConfWindow : BrowserWindow
* * Path requests
\*/
- protected override void reconfigure_search ()
+ protected override void reconfigure_search (bool local_search)
{
- main_view.set_search_parameters (saved_view, ((DConfHeaderBar) headerbar).get_bookmarks ());
+ main_view.set_search_parameters (local_search, saved_view, ((DConfHeaderBar)
headerbar).get_bookmarks ());
}
protected override void close_in_window_panels ()
@@ -966,8 +966,8 @@ private class DConfWindow : BrowserWindow
SimpleSettingObject sso = new SimpleSettingObject.from_full_name (/* context id */
ModelUtils.folder_context_id,
/* name */ name,
/* base path */ base_path,
- /* is search */ false,
- /* is special */ true);
+ /* is search */ true,
+ /* is pinned */ true);
key_model.append (sso);
if (children != null)
diff --git a/editor/config-list-box-row.ui b/editor/filter-list-box-row.ui
similarity index 90%
rename from editor/config-list-box-row.ui
rename to editor/filter-list-box-row.ui
index 1b959cc..2254e1b 100644
--- a/editor/config-list-box-row.ui
+++ b/editor/filter-list-box-row.ui
@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<!-- interface-requires gtk+ 3.0 -->
- <template class="ConfigListBoxRow" parent="ClickableListBoxRow">
+ <template class="FilterListBoxRow" parent="ClickableListBoxRow">
<property name="visible">True</property>
<style>
<class name="managed"/>
- <class name="config"/>
+ <class name="search"/>
<class name="small"/>
</style>
<child>
diff --git a/editor/help-overlay.ui b/editor/help-overlay.ui
index 62eed26..fcbc787 100644
--- a/editor/help-overlay.ui
+++ b/editor/help-overlay.ui
@@ -4,7 +4,7 @@
<child>
<object class="GtkShortcutsSection">
<property name="visible">True</property>
- <property name="max-height">14</property>
+ <property name="max-height">11</property>
<child>
<object class="GtkShortcutsGroup">
<property name="visible">True</property>
@@ -46,6 +46,40 @@
</child>
</object>
</child>
+ <child>
+ <object class="GtkShortcutsGroup">
+ <property name="visible">True</property>
+ <property name="title" translatable="yes" context="shortcut window">Path bar
navigation</property>
+ <child>
+ <object class="GtkShortcutsShortcut">
+ <property name="visible">True</property>
+ <property name="title" translatable="yes" context="shortcut window">Open root
folder</property>
+ <property name="accelerator"><Alt><Shift>Up</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkShortcutsShortcut">
+ <property name="visible">True</property>
+ <property name="title" translatable="yes" context="shortcut window">Open parent
folder</property>
+ <property name="accelerator"><Alt>Up</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkShortcutsShortcut">
+ <property name="visible">True</property>
+ <property name="title" translatable="yes" context="shortcut window">Open active direct
child</property>
+ <property name="accelerator"><Alt>Down</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkShortcutsShortcut">
+ <property name="visible">True</property>
+ <property name="title" translatable="yes" context="shortcut window">Open active last
child</property>
+ <property name="accelerator"><Alt><Shift>Down</property>
+ </object>
+ </child>
+ </object>
+ </child>
<child>
<object class="GtkShortcutsGroup">
<property name="visible">True</property>
@@ -57,6 +91,13 @@
<property name="accelerator"><Primary>f</property>
</object>
</child>
+ <child>
+ <object class="GtkShortcutsShortcut">
+ <property name="visible">True</property>
+ <property name="title" translatable="yes" context="shortcut window">Toggle local
search</property>
+ <property name="accelerator"><Primary><Shift>f</property>
+ </object>
+ </child>
<child>
<object class="GtkShortcutsShortcut">
<property name="visible">True</property>
@@ -97,33 +138,19 @@
<child>
<object class="GtkShortcutsGroup">
<property name="visible">True</property>
- <property name="title" translatable="yes" context="shortcut window">Path bar
navigation</property>
- <child>
- <object class="GtkShortcutsShortcut">
- <property name="visible">True</property>
- <property name="title" translatable="yes" context="shortcut window">Open root
folder</property>
- <property name="accelerator"><Alt><Shift>Up</property>
- </object>
- </child>
- <child>
- <object class="GtkShortcutsShortcut">
- <property name="visible">True</property>
- <property name="title" translatable="yes" context="shortcut window">Open parent
folder</property>
- <property name="accelerator"><Alt>Up</property>
- </object>
- </child>
+ <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">Open active direct
child</property>
- <property name="accelerator"><Alt>Down</property>
+ <property name="title" translatable="yes" context="shortcut window">About</property>
+ <property name="accelerator"><Primary><Shift>F1</property>
</object>
</child>
<child>
<object class="GtkShortcutsShortcut">
<property name="visible">True</property>
- <property name="title" translatable="yes" context="shortcut window">Open active last
child</property>
- <property name="accelerator"><Alt><Shift>Down</property>
+ <property name="title" translatable="yes" context="shortcut window">Show this help</property>
+ <property name="accelerator"><Primary>question <Primary>F1</property>
</object>
</child>
</object>
@@ -179,39 +206,26 @@
<child>
<object class="GtkShortcutsGroup">
<property name="visible">True</property>
- <property name="title" translatable="yes" context="shortcut window">Generic</property>
+ <property name="title" translatable="yes" context="shortcut window">Modifications list
actions</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"><Primary>question <Primary>F1</property>
+ <property name="title" translatable="yes" context="shortcut window">Toggle modifications
list</property>
+ <property name="accelerator"><Alt>i</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"><Primary><Shift>F1</property>
- </object>
- </child>
- </object>
- </child>
- <child>
- <object class="GtkShortcutsGroup">
- <property name="visible">True</property>
- <property name="title" translatable="yes" context="shortcut window">Clipboard</property>
- <child>
- <object class="GtkShortcutsShortcut">
- <property name="visible">True</property>
- <property name="title" translatable="yes" context="shortcut window">Copy
descriptor</property>
- <property name="accelerator"><Primary>c</property>
+ <property name="title" translatable="yes" context="shortcut window">Open selected row
key</property>
+ <property name="accelerator">Return</property>
</object>
</child>
<child>
<object class="GtkShortcutsShortcut">
<property name="visible">True</property>
- <property name="title" translatable="yes" context="shortcut window">Copy path</property>
- <property name="accelerator"><Primary><Shift>c</property>
+ <property name="title" translatable="yes" context="shortcut window">Dismiss
modification</property>
+ <property name="accelerator"><Primary>Delete</property>
</object>
</child>
</object>
@@ -219,26 +233,19 @@
<child>
<object class="GtkShortcutsGroup">
<property name="visible">True</property>
- <property name="title" translatable="yes" context="shortcut window">Modifications list
actions</property>
- <child>
- <object class="GtkShortcutsShortcut">
- <property name="visible">True</property>
- <property name="title" translatable="yes" context="shortcut window">Toggle modifications
list</property>
- <property name="accelerator"><Alt>i</property>
- </object>
- </child>
+ <property name="title" translatable="yes" context="shortcut window">Clipboard</property>
<child>
<object class="GtkShortcutsShortcut">
<property name="visible">True</property>
- <property name="title" translatable="yes" context="shortcut window">Open selected row
key</property>
- <property name="accelerator">Return</property>
+ <property name="title" translatable="yes" context="shortcut window">Copy
descriptor</property>
+ <property name="accelerator"><Primary>c</property>
</object>
</child>
<child>
<object class="GtkShortcutsShortcut">
<property name="visible">True</property>
- <property name="title" translatable="yes" context="shortcut window">Dismiss
modification</property>
- <property name="accelerator"><Primary>Delete</property>
+ <property name="title" translatable="yes" context="shortcut window">Copy path</property>
+ <property name="accelerator"><Primary><Shift>c</property>
</object>
</child>
</object>
diff --git a/editor/key-list-box-row.vala b/editor/key-list-box-row.vala
index 83f6132..57de8a9 100644
--- a/editor/key-list-box-row.vala
+++ b/editor/key-list-box-row.vala
@@ -133,16 +133,24 @@ private class FolderListBoxRow : ClickableListBoxRow
}
}
-[GtkTemplate (ui = "/ca/desrt/dconf-editor/ui/config-list-box-row.ui")]
-private class ConfigListBoxRow : ClickableListBoxRow
+[GtkTemplate (ui = "/ca/desrt/dconf-editor/ui/filter-list-box-row.ui")]
+private class FilterListBoxRow : ClickableListBoxRow
{
+ public bool is_local_search { internal get; protected construct; }
+
[GtkChild] private Label folder_name_label;
- internal ConfigListBoxRow (string name, string path)
+ internal FilterListBoxRow (string name, string path)
{
- Object (full_name: path, context_id: ModelUtils.folder_context_id, search_result_mode: false);
- /* Translators: first item of the keys list displayed during browsing, the %s is the current folder
name */
- folder_name_label.set_text (_("Show “%s” folder properties").printf (name));
+ Object (is_local_search: name != "" && path != "/", full_name: path, context_id:
ModelUtils.folder_context_id, search_result_mode: true);
+
+ if (is_local_search)
+ /* Translators: first item of the keys list displayed during browsing, the %s is the current
folder name */
+ folder_name_label.set_text (_("Search in “%s” folder").printf (name));
+
+ else
+ /* Translators: last item of the keys list displayed during a local search */
+ folder_name_label.set_text (_("Search everywhere"));
}
}
diff --git a/editor/meson.build b/editor/meson.build
index 2938df8..a47164a 100644
--- a/editor/meson.build
+++ b/editor/meson.build
@@ -120,9 +120,9 @@ resource_data = files(
'bookmark.ui',
'browser-infobar.ui',
'browser-stack.ui',
- 'config-list-box-row.ui',
'dconf-editor.css',
'delayed-setting-view.ui',
+ 'filter-list-box-row.ui',
'folder-list-box-row.ui',
'help-overlay.ui',
'key-list-box-row.ui',
diff --git a/editor/registry-list.vala b/editor/registry-list.vala
index 33a0c6b..90aab7e 100644
--- a/editor/registry-list.vala
+++ b/editor/registry-list.vala
@@ -423,22 +423,24 @@ private abstract class RegistryList : Grid, BrowsableView, AdaptativeWidget
assert_not_reached ();
bool search_mode_non_local_result = search_mode && ModelUtils.get_parent_path (full_name) != (!)
current_path_if_search_mode;
- if (setting_object.is_config)
+ if (setting_object.is_pinned)
{
- row = new ConfigListBoxRow (setting_object.name, full_name);
+ if (setting_object.is_search)
+ row = new FilterListBoxRow (setting_object.name, full_name);
+ else
+ row = new ReturnListBoxRow (full_name, context_id);
}
- else if (setting_object.is_pinned) // setting_object.is_config == false
+ else if (setting_object.is_search) // setting_object.is_pinned == false
{
- row = new ReturnListBoxRow (full_name, context_id);
+ if (setting_object.name == "")
+ row = new FilterListBoxRow ("", full_name);
+ else
+ row = new SearchListBoxRow (full_name.slice (1, full_name.length));
}
else if (ModelUtils.is_folder_context_id (context_id))
{
row = new FolderListBoxRow (setting_object.name, full_name, search_mode &&
search_is_path_search, search_mode_non_local_result);
}
- else if (setting_object.is_search)
- {
- row = new SearchListBoxRow (full_name.slice (1, full_name.length));
- }
else
{
Variant properties = modifications_handler.model.get_key_properties (full_name, context_id,
(uint16) (PropertyQuery.HAS_SCHEMA & PropertyQuery.KEY_NAME & PropertyQuery.TYPE_CODE & PropertyQuery.SUMMARY
& PropertyQuery.KEY_CONFLICT));
@@ -540,18 +542,20 @@ private abstract class RegistryList : Grid, BrowsableView, AdaptativeWidget
}
}
- private static ListBoxRowWrapper put_row_in_wrapper (ClickableListBoxRow row)
+ private static inline ListBoxRowWrapper put_row_in_wrapper (ClickableListBoxRow row)
{
/* Wrapper ensures max width for rows */
ListBoxRowWrapper wrapper = new ListBoxRowWrapper ();
wrapper.set_halign (Align.CENTER);
wrapper.add (row);
- if (row is SearchListBoxRow)
+ if (row is FilterListBoxRow)
{
wrapper.get_style_context ().add_class ("f-or-s-row");
- wrapper.action_name = "browser.open-search";
- wrapper.set_action_target ("s", row.full_name);
+ if (((FilterListBoxRow) row).is_local_search)
+ wrapper.action_name = "browser.open-search-local";
+ else
+ wrapper.action_name = "browser.open-search-global";
}
else if (row is ReturnListBoxRow)
{
@@ -567,6 +571,12 @@ private abstract class RegistryList : Grid, BrowsableView, AdaptativeWidget
wrapper.set_action_target ("(sq)", row.full_name, row.context_id);
}
}
+ else if (row is SearchListBoxRow)
+ {
+ wrapper.get_style_context ().add_class ("f-or-s-row");
+ wrapper.action_name = "browser.open-search";
+ wrapper.set_action_target ("s", row.full_name);
+ }
else if (ModelUtils.is_folder_context_id (row.context_id))
{
wrapper.get_style_context ().add_class ("f-or-s-row");
@@ -577,8 +587,6 @@ private abstract class RegistryList : Grid, BrowsableView, AdaptativeWidget
else
wrapper.action_name = "browser.open-folder";
}
- else if (row is ConfigListBoxRow)
- wrapper.action_name = "browser.open-config";
else assert_not_reached ();
wrapper.set_action_target ("s", row.full_name);
}
@@ -847,11 +855,9 @@ private abstract class RegistryList : Grid, BrowsableView, AdaptativeWidget
else
return generate_dconf_popover ((KeyListBoxRow) row, modifications_handler,
_get_key_copy_text_variant (row, modifications_handler));
}
- else if (row is ConfigListBoxRow)
- return generate_config_popover (row);
else if (row is ReturnListBoxRow)
return generate_return_popover (row);
- else if (row is SearchListBoxRow)
+ else if (row is SearchListBoxRow || row is FilterListBoxRow)
return generate_search_popover (row);
else assert_not_reached ();
}
@@ -870,20 +876,6 @@ private abstract class RegistryList : Grid, BrowsableView, AdaptativeWidget
return true;
}
- private static bool generate_config_popover (ClickableListBoxRow row)
- {
- if (row.nullable_popover == null) // do not place in requires 2/7
- assert_not_reached ();
-
- ContextPopover popover = (!) row.nullable_popover;
- Variant variant = new Variant.string (row.full_name);
-
- popover.new_gaction ("open-config", "browser.open-config(" + variant.print (false) + ")");
-// popover.new_gaction ("copy", "app.copy(" + _get_folder_or_search_copy_text_variant (row).print
(false) + ")");
-
- return true;
- }
-
private static bool generate_return_popover (ClickableListBoxRow row)
{
if (row.nullable_popover == null) // do not place in requires 3/7
@@ -1193,11 +1185,15 @@ private abstract class RegistryList : Grid, BrowsableView, AdaptativeWidget
ClickableListBoxRow? before_content = (ClickableListBoxRow?) before.get_child ();
if (before_content == null)
assert_not_reached ();
- if ((!) before_content is ConfigListBoxRow || (!) before_content is ReturnListBoxRow)
+ if ((!) before_content is FilterListBoxRow || (!) before_content is ReturnListBoxRow)
/* Translators: header displayed in the keys list during a search or during browsing */
label_text = _("Subfolders");
}
- else if (!((!) row_content is ConfigListBoxRow || (!) row_content is ReturnListBoxRow || (!)
row_content is SearchListBoxRow))
+ else if ((!) row_content is FilterListBoxRow)
+ {
+ label_text = _("Other actions");
+ }
+ else if (!((!) row_content is SearchListBoxRow))
assert_not_reached ();
row.set_header (new ListBoxRowHeader (false, label_text));
diff --git a/editor/registry-search.vala b/editor/registry-search.vala
index a5a2f5d..aba7c94 100644
--- a/editor/registry-search.vala
+++ b/editor/registry-search.vala
@@ -64,11 +64,13 @@ private class RegistrySearch : RegistryList
old_term = null;
}
+ bool is_local = false;
uint16 fallback_context_id = ModelUtils.undefined_context_id;
- internal void set_search_parameters (string current_path, uint16 current_context_id, string []
_bookmarks, SortingOptions _sorting_options)
+ internal void set_search_parameters (bool local_search, string current_path, uint16 current_context_id,
string [] _bookmarks, SortingOptions _sorting_options)
{
clean ();
+ is_local = local_search;
current_path_if_search_mode = current_path;
fallback_context_id = current_context_id;
bookmarks = _bookmarks;
@@ -201,6 +203,7 @@ private class RegistrySearch : RegistryList
SettingsModel model = modifications_handler.model;
if (term.has_prefix ("/"))
{
+ is_local = false;
if (old_term_is_term_prefix && !(term.slice (((!) old_term).length, term.length).contains ("/")))
{
refine_paths_results (term, ref list_model, ref post_local);
@@ -237,7 +240,7 @@ private class RegistrySearch : RegistryList
start_global_search ((!) current_path_if_search_mode, term);
else
{
- refine_global_results (term, post_bookmarks, ref list_model, ref post_folders);
+ refine_global_results (term, post_bookmarks, is_local, ref list_model, ref post_folders);
resume_global_search ((!) current_path_if_search_mode, term); // update search term
}
@@ -257,7 +260,7 @@ private class RegistrySearch : RegistryList
local_search (model, sorting_options, ModelUtils.get_base_path ((!)
current_path_if_search_mode), term, ref list_model);
post_local = (int) list_model.get_n_items ();
post_bookmarks = post_local;
- bookmark_search (model, (!) current_path_if_search_mode, term, bookmarks, ref list_model,
ref post_bookmarks);
+ bookmark_search (model, (!) current_path_if_search_mode, term, bookmarks, is_local, ref
list_model, ref post_bookmarks);
post_folders = post_bookmarks;
key_list_box.bind_model (list_model, new_list_box_row);
@@ -267,6 +270,9 @@ private class RegistrySearch : RegistryList
if (term != "")
start_global_search ((!) current_path_if_search_mode, term);
+
+ if (is_local)
+ insert_global_search_row ((!) current_path_if_search_mode, fallback_context_id, ref
list_model);
}
}
old_term = term;
@@ -278,10 +284,20 @@ private class RegistrySearch : RegistryList
SimpleSettingObject sso = new SimpleSettingObject.from_full_name (/* context id */
fallback_context_id,
/* name */ name,
/* base path */ current_path,
- /* is search */ true,
- /* is special */ true);
+ /* is search */ false,
+ /* is pinned */ true);
list_model.insert (0, sso);
}
+ private static void insert_global_search_row (string current_path, uint16 _fallback_context_id, ref
GLib.ListStore list_model)
+ {
+ uint16 fallback_context_id = ModelUtils.is_folder_path (current_path) ? ModelUtils.folder_context_id
: _fallback_context_id;
+ SimpleSettingObject sso = new SimpleSettingObject.from_full_name (/* context id */
fallback_context_id,
+ /* name */ "",
+ /* base path */ current_path,
+ /* is search */ true,
+ /* is pinned */ false);
+ list_model.insert (list_model.get_n_items (), sso);
+ }
private static void refine_paths_results (string term, ref GLib.ListStore list_model, ref int post_local)
{
@@ -348,9 +364,9 @@ private class RegistrySearch : RegistryList
}
}
- private static void refine_global_results (string term, int post_bookmarks, ref GLib.ListStore
list_model, ref int post_folders)
+ private static void refine_global_results (string term, int post_bookmarks, bool is_local, ref
GLib.ListStore list_model, ref int post_folders)
{
- for (int i = (int) list_model.get_n_items () - 1; i >= post_folders; i--)
+ for (int i = (int) list_model.get_n_items () - (is_local ? 2 : 1); i >= post_folders; i--)
{
SimpleSettingObject item = (SimpleSettingObject) list_model.get_item (i);
if (!(term.casefold () in item.casefolded_name))
@@ -390,32 +406,30 @@ private class RegistrySearch : RegistryList
}
}
- private static void bookmark_search (SettingsModel model, string current_path, string term, string []
bookmarks, ref GLib.ListStore list_model, ref int post_bookmarks)
+ private static void bookmark_search (SettingsModel model, string current_path, string term, string []
bookmarks, bool is_local, ref GLib.ListStore list_model, ref int post_bookmarks)
{
foreach (string bookmark in bookmarks)
{
if (bookmark == current_path)
continue;
- if (ModelUtils.get_parent_path (bookmark) == ModelUtils.get_base_path (current_path))
+ string bookmark_parent_path = ModelUtils.get_parent_path (bookmark);
+ if (bookmark_parent_path == ModelUtils.get_base_path (current_path))
continue;
if (bookmark == "?" + term)
continue;
+ if (is_local && !(bookmark_parent_path.has_prefix (ModelUtils.get_base_path (current_path))))
+ continue;
uint16 context_id;
string name;
- bool is_search;
- if (bookmark.has_prefix ("?"))
+ bool is_search = bookmark.has_prefix ("?");
+ if (is_search)
{
context_id = ModelUtils.undefined_context_id;
name = ModelUtils.get_name (bookmark.slice (1, bookmark.length));
- is_search = true;
- }
- else
- {
- if (!model.get_object (bookmark, out context_id, out name, !(ModelUtils.get_parent_path
(bookmark) in bookmarks)))
- continue;
- is_search = false;
}
+ else if (!model.get_object (bookmark, out context_id, out name, !(bookmark_parent_path in
bookmarks)))
+ continue;
if (term.casefold () in name.casefold ())
{
@@ -435,7 +449,10 @@ private class RegistrySearch : RegistryList
private void start_global_search (string current_path, string term)
{
- search_nodes.push_head ("/");
+ if (is_local)
+ search_nodes.push_head (ModelUtils.get_base_path (current_path));
+ else
+ search_nodes.push_head ("/");
resume_global_search (current_path, term);
}
@@ -492,7 +509,7 @@ private class RegistrySearch : RegistryList
if (!local_again && !(full_name in bookmarks) && term.casefold () in name.casefold ())
{
SimpleSettingObject sso = new SimpleSettingObject.from_base_path (context_id, name,
next);
- list_model.append (sso);
+ list_model.insert (is_local ? list_model.get_n_items () - 1 : list_model.get_n_items (),
sso);
model.key_value_push (next + name, context_id);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]