[dconf-editor] Fix interactions between window and search.
- From: Arnaud Bonatti <arnaudb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dconf-editor] Fix interactions between window and search.
- Date: Wed, 10 Jan 2018 23:54:25 +0000 (UTC)
commit d30052d7b092f5d9eb2cb5749bb733c5ef75c5e4
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date: Thu Jan 11 00:53:06 2018 +0100
Fix interactions between window and search.
editor/browser-view.vala | 20 ++++++++--------
editor/dconf-window.vala | 22 ++++--------------
editor/key-list-box-row.vala | 1 -
editor/registry-search.vala | 51 ++++++++++++++++++-----------------------
editor/registry-view.vala | 4 +-
5 files changed, 39 insertions(+), 59 deletions(-)
---
diff --git a/editor/browser-view.vala b/editor/browser-view.vala
index a155eb1..063fa37 100644
--- a/editor/browser-view.vala
+++ b/editor/browser-view.vala
@@ -129,9 +129,9 @@ class BrowserView : Grid
pre_search_view = null;
}
- public void show_search_view (string term)
+ public void show_search_view (string term, string current_path, string [] bookmarks)
{
- search_results_view.start_search (term);
+ search_results_view.start_search (term, current_path, bookmarks);
if (pre_search_view == null)
{
pre_search_view = stack.visible_child;
@@ -243,10 +243,10 @@ class BrowserView : Grid
info_bar.show_warning ("hard-reload");
}
- public void reload_search ()
+ public void reload_search (string current_path, string [] bookmarks)
{
hide_reload_warning ();
- search_results_view.reload_search ();
+ search_results_view.reload_search (current_path, bookmarks);
}
public bool check_reload (string path)
@@ -280,21 +280,21 @@ class BrowserView : Grid
return search_results_view.return_pressed ();
}
- public bool up_pressed (bool grab_focus)
+ public bool up_pressed ()
{
if (current_view_is_browse_view ())
- return browse_view.up_or_down_pressed (grab_focus, false);
+ return browse_view.up_or_down_pressed (false);
else if (current_view_is_search_results_view ())
- return search_results_view.up_or_down_pressed (grab_focus, false);
+ return search_results_view.up_or_down_pressed (false);
return false;
}
- public bool down_pressed (bool grab_focus)
+ public bool down_pressed ()
{
if (current_view_is_browse_view ())
- return browse_view.up_or_down_pressed (grab_focus, true);
+ return browse_view.up_or_down_pressed (true);
else if (current_view_is_search_results_view ())
- return search_results_view.up_or_down_pressed (grab_focus, true);
+ return search_results_view.up_or_down_pressed (true);
return false;
}
diff --git a/editor/dconf-window.vala b/editor/dconf-window.vala
index fddd8f7..c470a62 100644
--- a/editor/dconf-window.vala
+++ b/editor/dconf-window.vala
@@ -20,7 +20,7 @@ using Gtk;
[GtkTemplate (ui = "/ca/desrt/dconf-editor/ui/dconf-editor.ui")]
class DConfWindow : ApplicationWindow
{
- public string current_path { get; private set; default = "/"; }
+ private string current_path = "/";
private SettingsModel model;
private ModificationsHandler modifications_handler;
@@ -196,11 +196,6 @@ class DConfWindow : ApplicationWindow
return (!) parent;
}
- public string[] get_bookmarks ()
- {
- return settings.get_strv ("bookmarks");
- }
-
/*\
* * Window management callbacks
\*/
@@ -417,7 +412,7 @@ class DConfWindow : ApplicationWindow
else if (browser_view.current_view_is_properties_view ())
request_path (current_path, notify_missing);
else if (browser_view.current_view_is_search_results_view ())
- browser_view.reload_search ();
+ browser_view.reload_search (current_path, settings.get_strv ("bookmarks"));
}
/*\
@@ -484,18 +479,11 @@ class DConfWindow : ApplicationWindow
* * Search
\*/
- public void select_search_entry ()
- {
- if (!browser_view.current_view_is_search_results_view ())
- return;
- search_entry.grab_focus_without_selecting ();
- }
-
[GtkCallback]
private void search_changed ()
{
if (search_bar.search_mode_enabled)
- browser_view.show_search_view (search_entry.text);
+ browser_view.show_search_view (search_entry.text, current_path, settings.get_strv ("bookmarks"));
else
browser_view.hide_search_view ();
}
@@ -661,11 +649,11 @@ class DConfWindow : ApplicationWindow
if (name == "Up"
&& bookmarks_button.active == false
&& info_button.active == false)
- return browser_view.up_pressed (!search_bar.get_search_mode ());
+ return browser_view.up_pressed ();
if (name == "Down"
&& bookmarks_button.active == false
&& info_button.active == false)
- return browser_view.down_pressed (!search_bar.get_search_mode ());
+ return browser_view.down_pressed ();
if ((name == "Return" || name == "KP_Enter")
&& browser_view.current_view_is_search_results_view ()
diff --git a/editor/key-list-box-row.vala b/editor/key-list-box-row.vala
index 3a7d10c..354bc78 100644
--- a/editor/key-list-box-row.vala
+++ b/editor/key-list-box-row.vala
@@ -77,7 +77,6 @@ private class ListBoxRowHeader : Grid
private abstract class ClickableListBoxRow : EventBox
{
public signal void on_popover_disappear ();
- public ulong on_popover_disappear_handler = 0; // used by registry-search
public abstract string get_text ();
diff --git a/editor/registry-search.vala b/editor/registry-search.vala
index 2fe6945..41200e1 100644
--- a/editor/registry-search.vala
+++ b/editor/registry-search.vala
@@ -20,6 +20,8 @@ using Gtk;
[GtkTemplate (ui = "/ca/desrt/dconf-editor/ui/registry-search.ui")]
class RegistrySearch : Grid, BrowsableView
{
+ private string current_path;
+
public Behaviour behaviour { private get; set; }
[GtkChild] private ScrolledWindow scrolled;
@@ -53,15 +55,6 @@ class RegistrySearch : Grid, BrowsableView
}
}
- private DConfWindow? _main_window = null;
- private DConfWindow main_window {
- get {
- if (_main_window == null)
- _main_window = (DConfWindow) DConfWindow._get_parent (DConfWindow._get_parent
(DConfWindow._get_parent (browser_view)));
- return (!) _main_window;
- }
- }
-
private GLib.ListStore search_results_model = new GLib.ListStore (typeof (SettingObject));
construct
@@ -141,7 +134,7 @@ class RegistrySearch : Grid, BrowsableView
parent_path = SettingsModel.get_base_path (full_name [0:full_name.length - 1]);
else
parent_path = SettingsModel.get_base_path (full_name);
- bool is_local_result = parent_path == main_window.current_path;
+ bool is_local_result = parent_path == current_path;
if (setting_object is Directory)
{
@@ -199,11 +192,14 @@ class RegistrySearch : Grid, BrowsableView
private bool on_button_pressed (Widget widget, Gdk.EventButton event)
{
ListBoxRow list_box_row = (ListBoxRow) widget.get_parent ();
+ Container list_box = (Container) list_box_row.get_parent ();
key_list_box.select_row (list_box_row);
- list_box_row.grab_focus ();
if (event.button == Gdk.BUTTON_SECONDARY)
{
+ if (list_box.get_focus_child () != null)
+ list_box_row.grab_focus ();
+
ClickableListBoxRow row = (ClickableListBoxRow) widget;
int event_x = (int) event.x;
@@ -215,10 +211,10 @@ class RegistrySearch : Grid, BrowsableView
}
row.show_right_click_popover (event_x);
- if (row.on_popover_disappear_handler == 0)
- row.on_popover_disappear_handler = row.on_popover_disappear.connect
(main_window.select_search_entry);
rows_possibly_with_popover.append (row);
}
+ else
+ list_box_row.grab_focus ();
return false;
}
@@ -234,7 +230,7 @@ class RegistrySearch : Grid, BrowsableView
return true;
}
- public bool up_or_down_pressed (bool grab_focus, bool is_down)
+ public bool up_or_down_pressed (bool is_down)
{
ListBoxRow? selected_row = key_list_box.get_selected_row ();
uint n_items = search_results_model.get_n_items ();
@@ -253,7 +249,10 @@ class RegistrySearch : Grid, BrowsableView
row = key_list_box.get_row_at_index (position + 1);
if (row != null)
- scroll_to_row ((!) row, grab_focus);
+ {
+ Container list_box = (Container) ((!) selected_row).get_parent ();
+ scroll_to_row ((!) row, list_box.get_focus_child () != null);
+ }
return true;
}
@@ -271,11 +270,6 @@ class RegistrySearch : Grid, BrowsableView
ClickableListBoxRow? row = (ClickableListBoxRow?) rows_possibly_with_popover.get_item (0);
while (row != null)
{
- if (((!) row).on_popover_disappear_handler != 0)
- {
- ((!) row).disconnect (((!) row).on_popover_disappear_handler);
- ((!) row).on_popover_disappear_handler = 0;
- }
((!) row).destroy_popover ();
position++;
row = (ClickableListBoxRow?) rows_possibly_with_popover.get_item (position);
@@ -307,8 +301,6 @@ class RegistrySearch : Grid, BrowsableView
ClickableListBoxRow row = (ClickableListBoxRow) ((!) selected_row).get_child ();
row.show_right_click_popover ();
- if (row.on_popover_disappear_handler == 0)
- row.on_popover_disappear_handler = row.on_popover_disappear.connect
(main_window.select_search_entry);
rows_possibly_with_popover.append (row);
return true;
}
@@ -379,8 +371,10 @@ class RegistrySearch : Grid, BrowsableView
old_term = null;
}
- public void start_search (string term)
+ public void start_search (string term, string _current_path, string [] bookmarks)
{
+ current_path = _current_path;
+
if (old_term != null && term == (!) old_term)
{
ensure_selection ();
@@ -388,7 +382,6 @@ class RegistrySearch : Grid, BrowsableView
}
SettingsModel model = modifications_handler.model;
- string current_path = main_window.current_path;
if (old_term != null && term.has_prefix ((!) old_term))
{
pause_global_search ();
@@ -412,7 +405,7 @@ class RegistrySearch : Grid, BrowsableView
post_folders = -1;
local_search (model, SettingsModel.get_base_path (current_path), term);
- bookmark_search (model, current_path, term);
+ bookmark_search (model, current_path, term, bookmarks);
key_list_box.bind_model (search_results_model, new_list_box_row);
select_first_row ();
@@ -496,10 +489,10 @@ class RegistrySearch : Grid, BrowsableView
return true;
}
- private bool bookmark_search (SettingsModel model, string current_path, string term)
+ private bool bookmark_search (SettingsModel model, string current_path, string term, string [] bookmarks)
{
string [] installed_bookmarks = {}; // TODO move check in Bookmarks
- foreach (string bookmark in main_window.get_bookmarks ())
+ foreach (string bookmark in bookmarks)
{
if (bookmark in installed_bookmarks)
continue;
@@ -607,10 +600,10 @@ class RegistrySearch : Grid, BrowsableView
row.set_header (header);
}
- public void reload_search ()
+ public void reload_search (string current_path, string [] bookmarks)
{
string term = old_term ?? "";
stop_search ();
- start_search (term);
+ start_search (term, current_path, bookmarks);
}
}
diff --git a/editor/registry-view.vala b/editor/registry-view.vala
index 266fed1..58fdcac 100644
--- a/editor/registry-view.vala
+++ b/editor/registry-view.vala
@@ -254,7 +254,7 @@ class RegistryView : Grid, BrowsableView
return false;
}
- public bool up_or_down_pressed (bool grab_focus, bool is_down)
+ public bool up_or_down_pressed (bool is_down)
{
if (key_model == null)
return false;
@@ -276,7 +276,7 @@ class RegistryView : Grid, BrowsableView
row = key_list_box.get_row_at_index (position + 1);
if (row != null)
- scroll_to_row ((!) row, grab_focus);
+ scroll_to_row ((!) row, true);
return true;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]