[dconf-editor] Improve path navigation on small screens.
- From: Arnaud B. <arnaudb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dconf-editor] Improve path navigation on small screens.
- Date: Wed, 14 Nov 2018 13:48:07 +0000 (UTC)
commit 39a727e901ea73d1546ce4bb74200c52fdc242e5
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date: Thu Oct 18 18:50:24 2018 +0200
Improve path navigation on small screens.
editor/dconf-window.vala | 28 ++++++++++++++++++++++++++++
editor/model-utils.vala | 4 ++++
editor/short-pathbar.vala | 26 ++++++++++++++++++++------
3 files changed, 52 insertions(+), 6 deletions(-)
---
diff --git a/editor/dconf-window.vala b/editor/dconf-window.vala
index 9c4d799..8473895 100644
--- a/editor/dconf-window.vala
+++ b/editor/dconf-window.vala
@@ -536,6 +536,8 @@ private class DConfWindow : ApplicationWindow
* * Main UI action entries
\*/
+ private SimpleAction open_path_action;
+
private SimpleAction reload_search_action;
private bool reload_search_next = true;
@@ -545,6 +547,8 @@ private class DConfWindow : ApplicationWindow
action_group.add_action_entries (ui_action_entries, this);
insert_action_group ("ui", action_group);
+ open_path_action = (SimpleAction) action_group.lookup_action ("open-path");
+
reload_search_action = (SimpleAction) action_group.lookup_action ("reload-search");
reload_search_action.set_enabled (false);
}
@@ -563,6 +567,8 @@ private class DConfWindow : ApplicationWindow
{ "open-search", open_search, "s" },
{ "open-parent", open_parent, "s" },
+ { "open-path", open_path, "(sq)", "('/',uint16 " + ModelUtils.folder_context_id_string + ")" },
+
{ "reload-folder", reload_folder },
{ "reload-object", reload_object },
{ "reload-search", reload_search },
@@ -664,6 +670,25 @@ private class DConfWindow : ApplicationWindow
request_folder (ModelUtils.get_parent_path (full_name), full_name);
}
+ private void open_path (SimpleAction action, Variant? path_variant)
+ requires (path_variant != null)
+ {
+ hide_in_window_bookmarks ();
+ headerbar.close_popovers ();
+ revealer.hide_modifications_list ();
+
+ string full_name;
+ uint16 context_id;
+ ((!) path_variant).@get ("(sq)", out full_name, out context_id);
+
+ action.set_state ((!) path_variant);
+
+ if (ModelUtils.is_folder_context_id (context_id))
+ request_folder (full_name, "");
+ else
+ request_object (full_name, context_id);
+ }
+
private void reload_folder (/* SimpleAction action, Variant? path_variant */)
{
request_folder (current_path, browser_view.get_selected_row_name ());
@@ -1176,6 +1201,9 @@ private class DConfWindow : ApplicationWindow
browser_view.set_path (type, path);
headerbar.set_path (type, path);
headerbar.update_hamburger_menu (modifications_handler.get_current_delay_mode ());
+
+ Variant variant = new Variant ("(sq)", path, (type == ViewType.FOLDER) || (type == ViewType.CONFIG)
? ModelUtils.folder_context_id : ModelUtils.undefined_context_id);
+ open_path_action.set_state (variant);
}
private void invalidate_popovers_with_ui_reload ()
diff --git a/editor/model-utils.vala b/editor/model-utils.vala
index 6618e40..39c90b8 100644
--- a/editor/model-utils.vala
+++ b/editor/model-utils.vala
@@ -146,6 +146,10 @@ namespace ModelUtils
internal const uint16 folder_context_id = 1;
internal const uint16 dconf_context_id = 2;
+ internal const string undefined_context_id_string = "0";
+ internal const string folder_context_id_string = "1";
+ internal const string dconf_context_id_string = "2";
+
internal static inline bool is_undefined_context_id (uint16 context_id) { return context_id ==
undefined_context_id; }
internal static inline bool is_folder_context_id (uint16 context_id) { return context_id ==
folder_context_id; }
internal static inline bool is_dconf_context_id (uint16 context_id) { return context_id ==
dconf_context_id; }
diff --git a/editor/short-pathbar.vala b/editor/short-pathbar.vala
index e285bbb..0bfbb5e 100644
--- a/editor/short-pathbar.vala
+++ b/editor/short-pathbar.vala
@@ -66,22 +66,36 @@ private class ShortPathbar : Grid, Pathbar
GLib.Menu menu = new GLib.Menu ();
GLib.Menu section = new GLib.Menu ();
- string [] split = ModelUtils.get_parent_path (path).split ("/", /* max tokens disabled */ 0);
+ string [] split = complete_path.split ("/", /* max tokens disabled */ 0);
if (split.length < 2)
assert_not_reached ();
- split = split [1:split.length - 1]; // excludes initial and last ""
+ string last = split [split.length - 1];
+ split = split [1:split.length - 1]; // excludes initial "" and either last "" or key name
// slash folder
string tmp_path = "/";
- if (path != "/")
- menu.append ("/", "ui.open-folder('/')");
+ if (complete_path != "/")
+ menu.append ("/", "ui.open-path(('/',uint16 " + ModelUtils.folder_context_id_string + "))");
- // parent folders
+ // other folders
foreach (string item in split)
{
tmp_path += item + "/";
- menu.append (item, "ui.open-folder('" + tmp_path + "')"); // TODO append or prepend?
+ Variant variant = new Variant ("(sq)", tmp_path, ModelUtils.folder_context_id);
+ menu.append (item, "ui.open-path(" + variant.print (true) + ")"); // TODO append or prepend?
+ }
+
+ // key or nothing
+ if (last != "")
+ {
+ bool is_folder = ModelUtils.is_folder_path (complete_path);
+ uint16 context_id = is_folder ? ModelUtils.folder_context_id : ModelUtils.undefined_context_id;
+ tmp_path += last;
+ if (is_folder)
+ tmp_path += "/";
+ Variant variant = new Variant ("(sq)", tmp_path, context_id);
+ menu.append (last, "ui.open-path(" + variant.print (true) + ")");
}
section.freeze ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]