[dconf-editor] Make request_path private.
- From: Arnaud Bonatti <arnaudb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dconf-editor] Make request_path private.
- Date: Wed, 10 Jan 2018 10:06:48 +0000 (UTC)
commit f0706528fd9ec5c899baa2a719b988ffbeb69a02
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date: Tue Jan 9 15:43:26 2018 +0100
Make request_path private.
editor/browser-view.vala | 64 +++++++++++++------------------------------
editor/dconf-editor.ui | 1 -
editor/dconf-window.vala | 43 +++++++++++++++++++++++++----
editor/registry-search.vala | 6 ++--
4 files changed, 59 insertions(+), 55 deletions(-)
---
diff --git a/editor/browser-view.vala b/editor/browser-view.vala
index d93450f..57c960a 100644
--- a/editor/browser-view.vala
+++ b/editor/browser-view.vala
@@ -28,13 +28,6 @@ public enum Behaviour {
[GtkTemplate (ui = "/ca/desrt/dconf-editor/ui/browser-view.ui")]
class BrowserView : Grid
{
- public signal void request_path (string path, bool notify_missing = true, bool strict = true);
-
- private const GLib.ActionEntry [] action_entries =
- {
- { "reload", reload }
- };
-
public string current_path { get; private set; default = "/"; }
private GLib.Settings settings = new GLib.Settings ("ca.desrt.dconf-editor.Settings");
@@ -90,14 +83,10 @@ class BrowserView : Grid
construct
{
- SimpleActionGroup action_group = new SimpleActionGroup ();
- action_group.add_action_entries (action_entries, this);
- insert_action_group ("browser", action_group);
-
info_bar.add_label ("soft-reload", _("Sort preferences have changed. Do you want to reload the
view?"),
- _("Refresh"), "browser.reload");
+ _("Refresh"), "ui.reload");
info_bar.add_label ("hard-reload", _("This content has changed. Do you want to reload the view?"),
- _("Reload"), "browser.reload");
+ _("Reload"), "ui.reload");
ulong behaviour_changed_handler = settings.changed ["behaviour"].connect (invalidate_popovers);
settings.bind ("behaviour", browse_view, "behaviour",
SettingsBindFlags.GET|SettingsBindFlags.NO_SENSITIVITY);
@@ -121,6 +110,15 @@ class BrowserView : Grid
});
}
+ public string? get_selected_row_name ()
+ {
+ if (current_view_is_browse_view ())
+ return browse_view.get_selected_row_name ();
+ if (current_view_is_search_results_view ())
+ return search_results_view.get_selected_row_name ();
+ return null;
+ }
+
public void set_directory (Directory directory, string? selected)
{
SettingsModel model = modifications_handler.model;
@@ -282,58 +280,34 @@ class BrowserView : Grid
info_bar.show_warning ("soft-reload");
}
- private void show_hard_reload_warning ()
+ public void show_hard_reload_warning ()
{
info_bar.show_warning ("hard-reload");
}
- private void reload (/* SimpleAction action, Variant? path_variant */)
+ public void reload_search ()
{
- reload_view (true);
- }
-
- private void reload_view (bool notify_missing)
- {
- SettingsModel model = modifications_handler.model;
- if (current_view_is_browse_view ())
- {
- string? saved_selection = browse_view.get_selected_row_name ();
- Directory? directory = model.get_directory (current_path);
- if (directory == null)
- request_path (current_path, notify_missing); // rely on fallback detection
- else
- set_directory ((!) directory, saved_selection);
- }
- else if (current_view_is_properties_view ())
- request_path (current_path, notify_missing);
- else if (current_view_is_search_results_view ())
- {
- hide_reload_warning ();
- search_results_view.reload_search ();
- }
+ hide_reload_warning ();
+ search_results_view.reload_search ();
}
- public void check_reload (bool internal_changes)
+ public bool check_reload ()
{
SettingsModel model = modifications_handler.model;
if (current_view_is_properties_view ())
{
Key? fresh_key = (Key?) model.get_object (current_path);
if (fresh_key != null && !properties_view.check_reload ((!) fresh_key, model.get_key_value ((!)
fresh_key)))
- return;
+ return false;
}
else if (current_view_is_browse_view ())
{
Directory? fresh_dir = (Directory?) model.get_directory (current_path);
GLib.ListStore? fresh_key_model = model.get_children (fresh_dir);
if (fresh_key_model != null && !browse_view.check_reload ((!) fresh_dir, (!) fresh_key_model))
- return;
+ return false;
} // search_results_view always reloads
-
- if (internal_changes)
- reload_view (false);
- else
- show_hard_reload_warning ();
+ return true;
}
/*\
diff --git a/editor/dconf-editor.ui b/editor/dconf-editor.ui
index 91a47be..14086bb 100644
--- a/editor/dconf-editor.ui
+++ b/editor/dconf-editor.ui
@@ -157,7 +157,6 @@
<object class="BrowserView" id="browser_view">
<property name="visible">True</property>
<property name="vexpand">True</property>
- <signal name="request_path" handler="request_path"/>
</object>
</child>
</object>
diff --git a/editor/dconf-window.vala b/editor/dconf-window.vala
index 04ea498..1f91666 100644
--- a/editor/dconf-window.vala
+++ b/editor/dconf-window.vala
@@ -24,6 +24,7 @@ class DConfWindow : ApplicationWindow
{
{ "open-path", open_path, "s" },
{ "open-path-with-selection", open_path_with_selection, "(ss)" },
+ { "reload", reload },
{ "reset-recursive", reset_recursively },
{ "reset-visible", reset_visible },
@@ -84,7 +85,14 @@ class DConfWindow : ApplicationWindow
modifications_handler = new ModificationsHandler (model);
browser_view.modifications_handler = modifications_handler;
model.paths_changed.connect ((_model, modified_path_specs, internal_changes) => {
- browser_view.check_reload (internal_changes);
+ bool need_reload = browser_view.check_reload ();
+ if (need_reload)
+ {
+ if (internal_changes)
+ reload_view (false);
+ else
+ browser_view.show_hard_reload_warning ();
+ }
pathbar.set_path (current_path); // update "ghost" status
});
@@ -284,7 +292,6 @@ class DConfWindow : ApplicationWindow
* * Directories tree
\*/
- [GtkCallback]
private void request_path (string full_name, bool notify_missing = true, bool strict = true)
{
// browser_view.set_search_mode (false); // TODO not useful when called from bookmark
@@ -321,6 +328,25 @@ class DConfWindow : ApplicationWindow
search_bar.search_mode_enabled = false; // do last to avoid flickering RegistryView before
PropertiesView when selecting a search result
}
+ private void reload_view (bool notify_missing)
+ {
+ if (browser_view.current_view_is_browse_view ())
+ {
+ Directory? directory = model.get_directory (current_path);
+ if (directory == null)
+ request_path (current_path, notify_missing); // rely on fallback detection
+ else
+ {
+ string? saved_selection = browser_view.get_selected_row_name ();
+ browser_view.set_directory ((!) directory, saved_selection);
+ }
+ }
+ 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 ();
+ }
+
/*\
* * Path changing
\*/
@@ -388,17 +414,22 @@ class DConfWindow : ApplicationWindow
request_path (full_name);
}
- private void reset_visible ()
+ private void reload (/* SimpleAction action, Variant? path_variant */)
{
- browser_view.reset (false);
+ reload_view (true);
}
- private void reset_recursively ()
+ private void reset_recursively (/* SimpleAction action, Variant? path_variant */)
{
browser_view.reset (true);
}
- private void enter_delay_mode ()
+ private void reset_visible (/* SimpleAction action, Variant? path_variant */)
+ {
+ browser_view.reset (false);
+ }
+
+ private void enter_delay_mode (/* SimpleAction action, Variant? path_variant */)
{
browser_view.enter_delay_mode ();
}
diff --git a/editor/registry-search.vala b/editor/registry-search.vala
index da29483..35cf1ef 100644
--- a/editor/registry-search.vala
+++ b/editor/registry-search.vala
@@ -285,17 +285,17 @@ class RegistrySearch : Grid, BrowsableView
rows_possibly_with_popover.remove_all ();
}
- /*public string? get_selected_row_name ()
+ public string? get_selected_row_name ()
{
ListBoxRow? selected_row = key_list_box.get_selected_row ();
if (selected_row != null)
{
int position = ((!) selected_row).get_index ();
- return ((SettingObject) ((!) key_model).get_object (position)).full_name;
+ return ((SettingObject) ((!) search_results_model).get_object (position)).full_name;
}
else
return null;
- }*/
+ }
/*\
* * Keyboard calls
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]