[dconf-editor] Populate Pathbar interface.
- From: Arnaud B. <arnaudb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dconf-editor] Populate Pathbar interface.
- Date: Wed, 14 Nov 2018 13:47:52 +0000 (UTC)
commit 06a0b44495fe598fa157f717811bde4de60dfdce
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date: Thu Oct 18 15:04:59 2018 +0200
Populate Pathbar interface.
editor/adaptative-pathbar.vala | 34 ++++++++++++++++++++++++++++------
editor/browser-headerbar.vala | 2 +-
editor/dconf-window.vala | 8 ++++----
editor/large-pathbar.vala | 14 +++++---------
editor/pathwidget.vala | 5 ++++-
editor/short-pathbar.vala | 16 +++++++++++++---
6 files changed, 55 insertions(+), 24 deletions(-)
---
diff --git a/editor/adaptative-pathbar.vala b/editor/adaptative-pathbar.vala
index 32d63a6..5da9659 100644
--- a/editor/adaptative-pathbar.vala
+++ b/editor/adaptative-pathbar.vala
@@ -38,7 +38,10 @@ private class AdaptativePathbar : Stack, Pathbar
}
}
- internal string complete_path { get { return large_pathbar.complete_path; }}
+ internal string get_complete_path ()
+ {
+ return large_pathbar.get_complete_path (); // or the short_pathbar one; do not require their
equality, it warns on window closing
+ }
/*\
* * keyboard
@@ -78,15 +81,34 @@ private class AdaptativePathbar : Stack, Pathbar
large_pathbar.update_ghosts (non_ghost_path, is_search);
short_pathbar.update_ghosts (non_ghost_path, is_search);
}
-
- internal string get_selected_child (string current_path)
- {
- return large_pathbar.get_selected_child (current_path);
- }
}
private interface Pathbar
{
+ /* simple proxy calls */
+ internal abstract bool has_popover ();
+ internal abstract void close_menu ();
+ internal abstract void toggle_menu ();
+
+ internal abstract void set_path (ViewType type, string path);
+ internal abstract void update_ghosts (string non_ghost_path, bool is_search);
+
+ /* complex proxy calls */
+ internal abstract string get_complete_path ();
+
+ internal virtual string get_selected_child (string current_path)
+ {
+ return _get_selected_child (current_path, get_complete_path ());
+ }
+ private static string _get_selected_child (string current_path, string complete_path)
+ {
+ if (!complete_path.has_prefix (current_path) || complete_path == current_path)
+ return "";
+ int index_of_last_slash = complete_path.index_of ("/", current_path.length);
+ return index_of_last_slash == -1 ? complete_path : complete_path.slice (0, index_of_last_slash + 1);
+ }
+
+ /* called from inside the pathbar, by ShortPathbar and LargePathbarItem (so cannot make "protected") */
internal static void add_copy_path_entry (ref GLib.Menu section)
{
section.append (_("Copy current path"), "kbd.copy-path"); // or "app.copy(\"" +
get_action_target_value ().get_string () + "\")"
diff --git a/editor/browser-headerbar.vala b/editor/browser-headerbar.vala
index fdd6aa9..19e072b 100644
--- a/editor/browser-headerbar.vala
+++ b/editor/browser-headerbar.vala
@@ -60,10 +60,10 @@ private class BrowserHeaderBar : HeaderBar
}
internal bool search_mode_enabled { get { return path_widget.search_mode_enabled; }}
- internal string complete_path { get { return path_widget.complete_path; }}
internal bool entry_has_focus { get { return path_widget.entry_has_focus; }}
internal string text { get { return path_widget.text; }}
+ internal string get_complete_path () { return path_widget.get_complete_path (); }
internal void toggle_pathbar_menu () { path_widget.toggle_pathbar_menu (); }
internal string [] get_bookmarks () { return bookmarks_button.get_bookmarks (); }
diff --git a/editor/dconf-window.vala b/editor/dconf-window.vala
index edb6b24..d8f95ca 100644
--- a/editor/dconf-window.vala
+++ b/editor/dconf-window.vala
@@ -290,7 +290,7 @@ private class DConfWindow : ApplicationWindow
else if (browser_view.check_reload (current_type, current_path, !internal_changes)) // handle
infobars in needed
reload_view ();
- headerbar.update_ghosts (((SettingsModel) _model).get_fallback_path (headerbar.complete_path));
+ headerbar.update_ghosts (((SettingsModel) _model).get_fallback_path (headerbar.get_complete_path
()));
}
private void propagate_gkey_value_push (string full_name, uint16 context, Variant key_value, bool
is_key_default)
{
@@ -513,7 +513,7 @@ private class DConfWindow : ApplicationWindow
settings.delay ();
settings.set_string ("saved-view", saved_view);
- settings.set_string ("saved-pathbar-path", headerbar.complete_path);
+ settings.set_string ("saved-pathbar-path", headerbar.get_complete_path ());
if (window_width <= 630) settings.set_int ("window-width", 630);
else settings.set_int ("window-width", window_width);
if (window_height <= 420) settings.set_int ("window-height", 420);
@@ -1103,7 +1103,7 @@ private class DConfWindow : ApplicationWindow
cannot_find_folder (full_name);
}
request_folder (ModelUtils.get_parent_path (full_name), full_name, false);
- headerbar.update_ghosts (model.get_fallback_path (headerbar.complete_path));
+ headerbar.update_ghosts (model.get_fallback_path (headerbar.get_complete_path ()));
}
else
{
@@ -1371,7 +1371,7 @@ private class DConfWindow : ApplicationWindow
if (headerbar.search_mode_enabled)
return;
- string complete_path = headerbar.complete_path;
+ string complete_path = headerbar.get_complete_path ();
browser_view.discard_row_popover ();
if (current_path == complete_path) // TODO something?
diff --git a/editor/large-pathbar.vala b/editor/large-pathbar.vala
index 00b3bd4..1eea3a0 100644
--- a/editor/large-pathbar.vala
+++ b/editor/large-pathbar.vala
@@ -23,7 +23,11 @@ private class LargePathbar : Box, Pathbar
[GtkChild] private LargePathbarItem root_button;
private LargePathbarItem active_button;
- internal string complete_path { get; private set; default = ""; }
+ private string complete_path = "";
+ internal string get_complete_path ()
+ {
+ return complete_path;
+ }
construct
{
@@ -144,14 +148,6 @@ private class LargePathbar : Box, Pathbar
context.remove_class ("config");
}
- internal string get_selected_child (string current_path)
- {
- if (!complete_path.has_prefix (current_path) || complete_path == current_path)
- return "";
- int index_of_last_slash = complete_path.index_of ("/", current_path.length);
- return index_of_last_slash == -1 ? complete_path : complete_path.slice (0, index_of_last_slash + 1);
- }
-
internal void update_ghosts (string non_ghost_path, bool is_search)
{
string action_target = "";
diff --git a/editor/pathwidget.vala b/editor/pathwidget.vala
index 7919e4f..dd5a1f3 100644
--- a/editor/pathwidget.vala
+++ b/editor/pathwidget.vala
@@ -127,7 +127,10 @@ private class PathWidget : Box
}
/* path bar */
- internal string complete_path { get { return pathbar.complete_path; }}
+ internal string get_complete_path ()
+ {
+ return pathbar.get_complete_path ();
+ }
internal void update_ghosts (string fallback_path)
{
diff --git a/editor/short-pathbar.vala b/editor/short-pathbar.vala
index c512670..e285bbb 100644
--- a/editor/short-pathbar.vala
+++ b/editor/short-pathbar.vala
@@ -20,6 +20,12 @@ using Gtk;
[GtkTemplate (ui = "/ca/desrt/dconf-editor/ui/short-pathbar.ui")]
private class ShortPathbar : Grid, Pathbar
{
+ private string complete_path = "";
+ internal string get_complete_path ()
+ {
+ return complete_path;
+ }
+
[GtkChild] private MenuButton menu_button;
[GtkChild] private Label view_label;
@@ -51,6 +57,10 @@ private class ShortPathbar : Grid, Pathbar
if (type == ViewType.SEARCH)
return;
+ if (!path.has_suffix ("/")
+ || !complete_path.has_prefix (path))
+ complete_path = path;
+
view_label.set_text (ModelUtils.get_name (path));
GLib.Menu menu = new GLib.Menu ();
@@ -62,7 +72,7 @@ private class ShortPathbar : Grid, Pathbar
split = split [1:split.length - 1]; // excludes initial and last ""
// slash folder
- string complete_path = "/";
+ string tmp_path = "/";
if (path != "/")
menu.append ("/", "ui.open-folder('/')");
@@ -70,8 +80,8 @@ private class ShortPathbar : Grid, Pathbar
// parent folders
foreach (string item in split)
{
- complete_path += item + "/";
- menu.append (item, "ui.open-folder('" + complete_path + "')"); // TODO append or prepend?
+ tmp_path += item + "/";
+ menu.append (item, "ui.open-folder('" + tmp_path + "')"); // TODO append or prepend?
}
section.freeze ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]