[dconf-editor] Rework how path is updated.
- From: Arnaud Bonatti <arnaudb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dconf-editor] Rework how path is updated.
- Date: Wed, 10 Jan 2018 10:07:03 +0000 (UTC)
commit ffd6a4f4d3100ecfb943a269e6dc7d9b434ca3d9
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date: Wed Jan 10 00:54:22 2018 +0100
Rework how path is updated.
editor/browser-view.vala | 48 ++++++++++++++-------------------------------
editor/dconf-window.vala | 28 +++++++++++++++++++-------
2 files changed, 35 insertions(+), 41 deletions(-)
---
diff --git a/editor/browser-view.vala b/editor/browser-view.vala
index f4b0333..07cacff 100644
--- a/editor/browser-view.vala
+++ b/editor/browser-view.vala
@@ -31,7 +31,6 @@ class BrowserView : Grid
public string current_path { get; private set; default = "/"; }
private GLib.Settings settings = new GLib.Settings ("ca.desrt.dconf-editor.Settings");
- private Directory current_directory;
[GtkChild] private BrowserInfoBar info_bar;
@@ -119,47 +118,28 @@ class BrowserView : Grid
return null;
}
- public void set_directory (Directory directory, string? selected)
+ public void prepare_browse_view (GLib.ListStore key_model, string full_name, bool
warning_multiple_schemas)
{
- SettingsModel model = modifications_handler.model;
- GLib.ListStore? key_model = model.get_children (directory);
- if (key_model != null)
- {
- current_directory = directory;
- sorting_options.sort_key_model ((!) key_model);
+ sorting_options.sort_key_model (key_model);
+ browse_view.set_key_model (key_model);
- browse_view.set_key_model ((!) key_model);
-
- show_browse_view (directory.full_name, selected);
- properties_view.clean ();
- }
- }
-
- private void show_browse_view (string path, string? selected)
- {
- _show_browse_view (path);
- select_row (selected);
- }
- private void _show_browse_view (string path)
- {
- stack.set_transition_type (current_path.has_prefix (path) && pre_search_view == null ?
StackTransitionType.CROSSFADE : StackTransitionType.NONE);
+ stack.set_transition_type (current_path.has_prefix (full_name) && pre_search_view == null ?
StackTransitionType.CROSSFADE : StackTransitionType.NONE);
pre_search_view = null;
hide_reload_warning ();
- browse_view.show_multiple_schemas_warning (current_directory.warning_multiple_schemas);
-
- update_current_path (path);
- stack.set_visible_child (browse_view);
+ browse_view.show_multiple_schemas_warning (warning_multiple_schemas);
}
- private void select_row (string? selected)
+
+ public void select_row (string? selected)
{
bool grab_focus = true; // unused, for now
if (selected != null)
browse_view.select_row_named ((!) selected, grab_focus);
else
browse_view.select_first_row (grab_focus);
+ properties_view.clean ();
}
- public void show_properties_view (Key key, string path, bool warning_multiple_schemas)
+ public void prepare_properties_view (Key key, string path, bool warning_multiple_schemas)
{
properties_view.populate_properties_list_box (key, warning_multiple_schemas);
@@ -168,8 +148,6 @@ class BrowserView : Grid
stack.set_transition_type (current_path == SettingsModel.get_parent_path (path) && pre_search_view
== null ? StackTransitionType.CROSSFADE : StackTransitionType.NONE);
pre_search_view = null;
- update_current_path (path);
- stack.set_visible_child (properties_view);
}
public void show_search_view (string term)
@@ -197,11 +175,15 @@ class BrowserView : Grid
search_results_view.stop_search ();
}
- private void update_current_path (string path)
+ public void set_path (string path)
{
+ if (path.has_suffix ("/"))
+ stack.set_visible_child (browse_view);
+ else
+ stack.set_visible_child (properties_view);
+
modifications_handler.path_changed ();
current_path = path;
- main_window.update_path_elements ();
invalidate_popovers ();
}
diff --git a/editor/dconf-window.vala b/editor/dconf-window.vala
index d3a79da..1b26f0a 100644
--- a/editor/dconf-window.vala
+++ b/editor/dconf-window.vala
@@ -312,10 +312,11 @@ class DConfWindow : ApplicationWindow
if (found_object is Key)
{
Directory parent_directory = (!) model.get_directory (SettingsModel.get_parent_path (full_name));
- browser_view.show_properties_view ((Key) found_object, full_name,
parent_directory.warning_multiple_schemas);
+ browser_view.prepare_properties_view ((Key) found_object, full_name,
parent_directory.warning_multiple_schemas);
+ update_current_path (full_name);
}
else
- browser_view.set_directory ((Directory) found_object, pathbar.get_selected_child (full_name));
+ set_directory ((Directory) found_object, pathbar.get_selected_child (full_name));
if (not_found && notify_missing)
{
@@ -328,6 +329,16 @@ class DConfWindow : ApplicationWindow
search_bar.search_mode_enabled = false; // do last to avoid flickering RegistryView before
PropertiesView when selecting a search result
}
+ private void set_directory (Directory directory, string? selected)
+ {
+ GLib.ListStore? key_model = model.get_children (directory);
+ if (key_model == null)
+ return;
+ browser_view.prepare_browse_view ((!) key_model, directory.full_name,
directory.warning_multiple_schemas);
+ update_current_path (directory.full_name);
+ browser_view.select_row (selected);
+ }
+
private void reload_view (bool notify_missing)
{
if (browser_view.current_view_is_browse_view ())
@@ -338,7 +349,7 @@ class DConfWindow : ApplicationWindow
else
{
string? saved_selection = browser_view.get_selected_row_name ();
- browser_view.set_directory ((!) directory, saved_selection);
+ set_directory ((!) directory, saved_selection);
}
}
else if (browser_view.current_view_is_properties_view ())
@@ -351,10 +362,11 @@ class DConfWindow : ApplicationWindow
* * Path changing
\*/
- public void update_path_elements ()
+ private void update_current_path (string path)
{
- bookmarks_button.set_path (current_path);
- pathbar.set_path (current_path);
+ browser_view.set_path (path);
+ bookmarks_button.set_path (path);
+ pathbar.set_path (path);
}
public void update_hamburger_menu ()
@@ -705,12 +717,12 @@ class DConfWindow : ApplicationWindow
private void cannot_find_folder (string folder_name)
{
- browser_view.set_directory ((!) model.get_directory ("/"), null);
+ set_directory ((!) model.get_directory ("/"), null);
show_notification (_("Cannot find folder ā%sā.").printf (folder_name));
}
private void cannot_find_key (string key_name, Directory fallback_dir)
{
- browser_view.set_directory (fallback_dir, null);
+ set_directory (fallback_dir, null);
show_notification (_("Cannot find key ā%sā here.").printf (key_name));
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]