[dconf-editor] Handle bookmarks on small screens.
- From: Arnaud B. <arnaudb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dconf-editor] Handle bookmarks on small screens.
- Date: Wed, 14 Nov 2018 13:47:32 +0000 (UTC)
commit ad2b2c3ce10f68eaf067da62c20edb0137e4c571
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date: Wed Oct 24 17:09:09 2018 +0200
Handle bookmarks on small screens.
editor/bookmarks.vala | 20 ++----
editor/browser-headerbar.ui | 53 +++++++++++++--
editor/browser-headerbar.vala | 146 ++++++++++++++++++++++++++++++++++++++----
editor/browser-view.ui | 20 ++++--
editor/browser-view.vala | 77 +++++++++++++++++++++-
editor/dconf-editor.css | 7 ++
editor/dconf-window.vala | 62 +++++++++++++-----
editor/pathwidget.ui | 12 ----
editor/pathwidget.vala | 60 +----------------
9 files changed, 336 insertions(+), 121 deletions(-)
---
diff --git a/editor/bookmarks.vala b/editor/bookmarks.vala
index 20a5ceb..93b8478 100644
--- a/editor/bookmarks.vala
+++ b/editor/bookmarks.vala
@@ -248,14 +248,14 @@ private class Bookmarks : MenuButton
{
if (bookmarked_switch.get_active ())
return;
- append_bookmark (settings, current_path, current_type);
+ append_bookmark (settings, get_bookmark_name (current_path, current_type));
}
internal void unbookmark_current_path ()
{
if (!bookmarked_switch.get_active ())
return;
- remove_bookmark (settings, current_path, current_type);
+ remove_bookmark (settings, get_bookmark_name (current_path, current_type));
}
internal void update_bookmark_icon (string bookmark, BookmarkIcon icon)
@@ -599,7 +599,7 @@ private class Bookmarks : MenuButton
string bookmark;
uint8 type;
((!) path_variant).@get ("(sy)", out bookmark, out type);
- append_bookmark (settings, bookmark, ViewType.from_byte (type));
+ append_bookmark (settings, get_bookmark_name (bookmark, ViewType.from_byte (type)));
}
private void unbookmark (SimpleAction action, Variant? path_variant)
@@ -610,7 +610,7 @@ private class Bookmarks : MenuButton
string bookmark;
uint8 type;
((!) path_variant).@get ("(sy)", out bookmark, out type);
- remove_bookmark (settings, bookmark, ViewType.from_byte (type));
+ remove_bookmark (settings, get_bookmark_name (bookmark, ViewType.from_byte (type)));
}
/*\
@@ -742,9 +742,8 @@ private class Bookmarks : MenuButton
bookmarks_list_box.select_row ((!) selected_row);
}
- private static void append_bookmark (GLib.Settings settings, string path, ViewType type)
+ private static void append_bookmark (GLib.Settings settings, string bookmark_name)
{
- string bookmark_name = get_bookmark_name (path, type);
string [] bookmarks = settings.get_strv ("bookmarks");
if (bookmark_name in bookmarks)
return;
@@ -753,12 +752,7 @@ private class Bookmarks : MenuButton
settings.set_strv ("bookmarks", bookmarks);
}
- private static void remove_bookmark (GLib.Settings settings, string path, ViewType type)
- {
- string bookmark_name = get_bookmark_name (path, type);
- _remove_bookmark (settings, bookmark_name);
- }
- private static inline void _remove_bookmark (GLib.Settings settings, string bookmark_name)
+ private static void remove_bookmark (GLib.Settings settings, string bookmark_name)
{
string [] old_bookmarks = settings.get_strv ("bookmarks");
if (!(bookmark_name in old_bookmarks))
@@ -782,7 +776,7 @@ private class Bookmarks : MenuButton
settings.set_strv ("bookmarks", new_bookmarks);
}
- private static inline string get_bookmark_name (string path, ViewType type)
+ internal static inline string get_bookmark_name (string path, ViewType type)
{
if (type == ViewType.SEARCH)
return "?" + path;
diff --git a/editor/browser-headerbar.ui b/editor/browser-headerbar.ui
index baef4a6..fe61b3a 100644
--- a/editor/browser-headerbar.ui
+++ b/editor/browser-headerbar.ui
@@ -5,12 +5,55 @@
<property name="show-close-button">True</property>
<property name="has-subtitle">False</property>
<child type="title">
- <object class="PathWidget" id="path_widget">
+ <object class="GtkBox">
<property name="visible">True</property>
- <property name="hexpand">False</property>
- <signal name="search-changed" handler="search_changed_cb"/>
- <signal name="search-stopped" handler="search_stopped_cb"/>
- <signal name="update-bookmarks-icons" handler="update_bookmarks_icons_cb"/>
+ <property name="spacing">6</property>
+ <style>
+ <class name="centerwidget"/>
+ </style>
+ <child>
+ <object class="GtkStack" id="bookmarks_stack">
+ <property name="visible">True</property>
+ <property name="hhomogeneous">False</property>
+ <child>
+ <object class="PathWidget" id="path_widget">
+ <property name="visible">True</property>
+ <property name="hexpand">False</property>
+ <signal name="search-changed" handler="search_changed_cb"/>
+ <signal name="search-stopped" handler="search_stopped_cb"/>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel" id="bookmarks_label">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Bookmarks</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkRevealer" id="bookmarks_revealer">
+ <property name="visible">True</property>
+ <property name="transition-type">slide-left</property>
+ <property name="reveal-child">True</property>
+ <style>
+ <class name="headerbar-revealer"/>
+ </style>
+ <child>
+ <object class="Bookmarks" id="bookmarks_button">
+ <property name="visible">True</property>
+ <property name="valign">center</property>
+ <property name="focus-on-click">False</property>
+ <property name="schema-path">/ca/desrt/dconf-editor/</property>
+ <!-- <accelerator key="B" signal="activate" modifiers="GDK_CONTROL_MASK"/> TODO -->
+ <signal name="update-bookmarks-icons" handler="update_bookmarks_icons_cb"/>
+ <style>
+ <class name="image-button"/> <!-- TODO https://bugzilla.gnome.org/show_bug.cgi?id=756731
-->
+ </style>
+ </object>
+ </child>
+ </object>
+ </child>
</object>
</child>
<child>
diff --git a/editor/browser-headerbar.vala b/editor/browser-headerbar.vala
index c030b81..2c2b1a1 100644
--- a/editor/browser-headerbar.vala
+++ b/editor/browser-headerbar.vala
@@ -20,8 +20,11 @@ using Gtk;
[GtkTemplate (ui = "/ca/desrt/dconf-editor/ui/browser-headerbar.ui")]
private class BrowserHeaderBar : HeaderBar
{
- [GtkChild] private MenuButton info_button;
- [GtkChild] private PathWidget path_widget;
+ [GtkChild] private MenuButton info_button;
+ [GtkChild] private PathWidget path_widget;
+
+ [GtkChild] private Revealer bookmarks_revealer;
+ [GtkChild] private Bookmarks bookmarks_button;
private ViewType current_type = ViewType.FOLDER;
private string current_path = "/";
@@ -30,7 +33,28 @@ private class BrowserHeaderBar : HeaderBar
internal signal void search_stopped ();
internal signal void update_bookmarks_icons (Variant bookmarks_variant);
- internal bool extra_small_window { set { path_widget.extra_small_window = value; }}
+ private bool _extra_small_window = false;
+ internal bool extra_small_window
+ {
+ get { return _extra_small_window; }
+ set
+ {
+ _extra_small_window = value;
+ bookmarks_button.active = false;
+ if (value)
+ {
+ bookmarks_button.sensitive = false;
+ bookmarks_revealer.set_reveal_child (false);
+ }
+ else
+ {
+ bookmarks_button.sensitive = true;
+ bookmarks_revealer.set_reveal_child (true);
+ hide_in_window_bookmarks ();
+ }
+ update_hamburger_menu (delay_mode);
+ }
+ }
internal bool search_mode_enabled { get { return path_widget.search_mode_enabled; }}
internal string complete_path { get { return path_widget.complete_path; }}
@@ -38,9 +62,9 @@ private class BrowserHeaderBar : HeaderBar
internal string text { get { return path_widget.text; }}
internal void toggle_pathbar_menu () { path_widget.toggle_pathbar_menu (); }
- internal string [] get_bookmarks () { return path_widget.get_bookmarks (); }
+ internal string [] get_bookmarks () { return bookmarks_button.get_bookmarks (); }
- internal void update_bookmark_icon (string bookmark, BookmarkIcon icon) {
path_widget.update_bookmark_icon (bookmark, icon); }
+ internal void update_bookmark_icon (string bookmark, BookmarkIcon icon) {
bookmarks_button.update_bookmark_icon (bookmark, icon); }
internal void update_ghosts (string fallback_path) { path_widget.update_ghosts
(fallback_path); }
internal void prepare_search (PathEntry.SearchMode mode, string? search){ path_widget.prepare_search
(mode, search); }
internal string get_selected_child (string fallback_path) { return
path_widget.get_selected_child (fallback_path); }
@@ -59,10 +83,13 @@ private class BrowserHeaderBar : HeaderBar
current_path = path;
path_widget.set_path (type, path);
+ bookmarks_button.set_path (type, path);
}
internal bool has_popover ()
{
+ if (bookmarks_button.active)
+ return true;
if (info_button.active)
return true;
if (path_widget.has_popover ())
@@ -79,38 +106,100 @@ private class BrowserHeaderBar : HeaderBar
{
if (info_button.active)
return;
- path_widget.down_pressed ();
+ if (bookmarks_button.active)
+ bookmarks_button.down_pressed ();
}
internal void up_pressed ()
{
if (info_button.active)
return;
- path_widget.up_pressed ();
+ if (bookmarks_button.active)
+ bookmarks_button.up_pressed ();
}
internal void close_popovers ()
{
hide_hamburger_menu ();
+ if (bookmarks_button.active)
+ bookmarks_button.active = false;
path_widget.close_popovers ();
}
internal void click_bookmarks_button ()
{
hide_hamburger_menu ();
- path_widget.click_bookmarks_button ();
+ if (bookmarks_button.sensitive)
+ bookmarks_button.clicked ();
}
internal void bookmark_current_path ()
{
hide_hamburger_menu ();
- path_widget.bookmark_current_path ();
+ bookmarks_button.bookmark_current_path ();
+ update_hamburger_menu ();
}
internal void unbookmark_current_path ()
{
hide_hamburger_menu ();
- path_widget.unbookmark_current_path ();
+ bookmarks_button.unbookmark_current_path ();
+ update_hamburger_menu ();
+ }
+
+ construct
+ {
+ install_action_entries ();
+ }
+
+ /*\
+ * * in-window bookmarks
+ \*/
+
+ [GtkChild] private Stack bookmarks_stack;
+ [GtkChild] private Label bookmarks_label;
+
+ bool in_window_bookmarks = false;
+
+ internal void show_in_window_bookmarks ()
+ {
+ in_window_bookmarks = true;
+ bookmarks_stack.set_visible_child (bookmarks_label);
+ update_hamburger_menu ();
+ }
+
+ internal void hide_in_window_bookmarks ()
+ {
+ in_window_bookmarks = false;
+ bookmarks_stack.set_visible_child (path_widget);
+ update_hamburger_menu ();
+ }
+
+ /*\
+ * * action entries
+ \*/
+
+ private void install_action_entries ()
+ {
+ SimpleActionGroup action_group = new SimpleActionGroup ();
+ action_group.add_action_entries (action_entries, this);
+ insert_action_group ("headerbar", action_group);
+ }
+
+ private const GLib.ActionEntry [] action_entries =
+ {
+ { "bookmark-current", bookmark_current },
+ { "unbookmark-current", unbookmark_current }
+ };
+
+ private void bookmark_current (/* SimpleAction action, Variant? variant */)
+ {
+ bookmark_current_path ();
+ }
+
+ private void unbookmark_current (/* SimpleAction action, Variant? variant */)
+ {
+ unbookmark_current_path ();
}
/*\
@@ -132,8 +221,12 @@ private class BrowserHeaderBar : HeaderBar
info_button.active = !info_button.active;
}
- internal void update_hamburger_menu (bool delay_mode)
+ private bool delay_mode = false;
+ internal void update_hamburger_menu (bool? new_delay_mode = null)
{
+ if (new_delay_mode != null)
+ delay_mode = (!) new_delay_mode;
+
GLib.Menu menu = new GLib.Menu ();
/* if (current_type == ViewType.OBJECT && !ModelUtils.is_folder_path (current_path)) // TODO a
better way to copy various representations of a key name/value/path
@@ -143,13 +236,37 @@ private class BrowserHeaderBar : HeaderBar
}
else if (current_type != ViewType.SEARCH) */
- append_or_not_delay_mode_section (delay_mode, current_type == ViewType.FOLDER, current_path, ref
menu);
+ if (extra_small_window)
+ append_bookmark_section (current_type, current_path, Bookmarks.get_bookmark_name (current_path,
current_type) in get_bookmarks (), in_window_bookmarks, ref menu);
+
+ if (!in_window_bookmarks)
+ append_or_not_delay_mode_section (delay_mode, current_type == ViewType.FOLDER, current_path, ref
menu);
+
append_app_actions_section (night_time, dark_theme, automatic_night_mode, ref menu);
menu.freeze ();
info_button.set_menu_model ((MenuModel) menu);
}
+ private static void append_bookmark_section (ViewType current_type, string current_path, bool
is_in_bookmarks, bool in_window_bookmarks, ref GLib.Menu menu)
+ {
+ GLib.Menu section = new GLib.Menu ();
+
+ if (in_window_bookmarks)
+ section.append (_("Hide bookmarks"), "ui.hide-in-window-bookmarks");
+ else
+ {
+ if (is_in_bookmarks)
+ section.append (_("Unbookmark"), "headerbar.unbookmark-current");
+ else
+ section.append (_("Bookmark"), "headerbar.bookmark-current");
+
+ section.append (_("Show bookmarks"), "ui.show-in-window-bookmarks");
+ }
+ section.freeze ();
+ menu.append_section (null, section);
+ }
+
private static void append_or_not_delay_mode_section (bool delay_mode, bool is_folder_view, string
current_path, ref GLib.Menu menu)
{
if (delay_mode && !is_folder_view)
@@ -184,10 +301,15 @@ private class BrowserHeaderBar : HeaderBar
return;
if (dark_theme)
+ /* Translators: there are three related actions: "use", "reuse" and "pause" */
section.append (_("Pause night mode"), "app.set-use-night-mode(false)");
+
else if (auto_night)
+ /* Translators: there are three related actions: "use", "reuse" and "pause" */
section.append (_("Reuse night mode"), "app.set-use-night-mode(true)");
+
else
+ /* Translators: there are three related actions: "use", "reuse" and "pause" */
section.append (_("Use night mode"), "app.set-use-night-mode(true)");
}
diff --git a/editor/browser-view.ui b/editor/browser-view.ui
index 4f0de26..1c6f551 100644
--- a/editor/browser-view.ui
+++ b/editor/browser-view.ui
@@ -1,15 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface domain="dconf-editor">
<!-- interface-requires gtk+ 3.0 -->
- <template class="BrowserView" parent="GtkGrid">
- <property name="orientation">vertical</property>
+ <template class="BrowserView" parent="GtkStack">
+ <property name="transition-type">over-down-up</property>
+ <property name="transition-duration">300</property>
<child>
- <object class="BrowserInfoBar" id="info_bar">
+ <object class="GtkGrid" id="current_child_grid">
<property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="BrowserInfoBar" id="info_bar">
+ <property name="visible">True</property>
+ </object>
+ </child>
+ <child>
+ <object class="BrowserStack" id="current_child">
+ <property name="visible">True</property>
+ </object>
+ </child>
</object>
</child>
<child>
- <object class="BrowserStack" id="current_child">
+ <object class="GtkListBox" id="bookmarks_list_box">
<property name="visible">True</property>
</object>
</child>
diff --git a/editor/browser-view.vala b/editor/browser-view.vala
index cb96843..d482a52 100644
--- a/editor/browser-view.vala
+++ b/editor/browser-view.vala
@@ -49,7 +49,7 @@ private class SimpleSettingObject : Object
}
[GtkTemplate (ui = "/ca/desrt/dconf-editor/ui/browser-view.ui")]
-private class BrowserView : Grid
+private class BrowserView : Stack
{
internal uint16 last_context_id { get; private set; default = ModelUtils.undefined_context_id; }
@@ -60,7 +60,7 @@ private class BrowserView : Grid
private GLib.ListStore? key_model = null;
internal bool small_keys_list_rows { set { current_child.small_keys_list_rows = value; }}
- internal bool extra_small_window { set { current_child.extra_small_window = value; }}
+ internal bool extra_small_window { set { current_child.extra_small_window = value; if (!value)
hide_in_window_bookmarks (); }}
private ModificationsHandler _modifications_handler;
internal ModificationsHandler modifications_handler
@@ -192,6 +192,79 @@ private class BrowserView : Grid
modifications_handler.set_gsettings_key_value (full_name, context_id, new Variant.boolean
(key_value_request));
}
+ /*\
+ * * bookmarks
+ \*/
+
+ [GtkChild] private ListBox bookmarks_list_box;
+ [GtkChild] private Grid current_child_grid;
+
+ private HashTable<string, Bookmark> bookmarks_hashtable = new HashTable<string, Bookmark> (str_hash,
str_equal);
+ private string [] old_bookmarks = new string [0];
+
+ internal void show_in_window_bookmarks (string [] bookmarks)
+ {
+ if (bookmarks != old_bookmarks)
+ {
+ bookmarks_list_box.@foreach ((widget) => widget.destroy ());
+ bookmarks_hashtable.remove_all ();
+
+ foreach (string bookmark in bookmarks)
+ {
+ Bookmark bookmark_row = new Bookmark (bookmark);
+ bookmark_row.show ();
+ bookmarks_hashtable.insert (bookmark, bookmark_row);
+ bookmarks_list_box.add (bookmark_row);
+ }
+ }
+ old_bookmarks = bookmarks;
+ set_visible_child (bookmarks_list_box);
+ }
+
+ internal void update_bookmark_icon (string bookmark, BookmarkIcon icon)
+ {
+ Bookmark? bookmark_row = bookmarks_hashtable.lookup (bookmark);
+ if (bookmark_row == null)
+ return;
+ Widget? bookmark_grid = ((!) bookmark_row).get_child ();
+ if (bookmark_grid == null)
+ assert_not_reached ();
+ _update_bookmark_icon (((!) bookmark_grid).get_style_context (), icon);
+ }
+ private static inline void _update_bookmark_icon (StyleContext context, BookmarkIcon icon)
+ {
+ switch (icon)
+ {
+ case BookmarkIcon.VALID_FOLDER: context.add_class ("folder");
+ return;
+ case BookmarkIcon.EMPTY_FOLDER: context.add_class ("folder");
+ context.add_class ("erase");
+ return;
+ case BookmarkIcon.SEARCH: context.add_class ("search");
+ return;
+ case BookmarkIcon.EMPTY_OBJECT: context.add_class ("key");
+ context.add_class ("dconf-key");
+ context.add_class ("erase");
+ return;
+ case BookmarkIcon.DCONF_OBJECT: context.add_class ("key");
+ context.add_class ("dconf-key");
+ return;
+ case BookmarkIcon.KEY_DEFAULTS: context.add_class ("key");
+ context.add_class ("gsettings-key");
+ return;
+ case BookmarkIcon.EDITED_VALUE: context.add_class ("key");
+ context.add_class ("gsettings-key");
+ context.add_class ("edited");
+ return;
+ default: assert_not_reached ();
+ }
+ }
+
+ internal void hide_in_window_bookmarks ()
+ {
+ set_visible_child (current_child_grid);
+ }
+
/*\
* * Views
\*/
diff --git a/editor/dconf-editor.css b/editor/dconf-editor.css
index bcf0927..c0cd214 100644
--- a/editor/dconf-editor.css
+++ b/editor/dconf-editor.css
@@ -84,6 +84,13 @@
transition:all 0 ease;
}
+/* hack: fix the double space when the child of the revealer is hidden; 6px is the spacing of the
centerwidget box */
+.centerwidget:dir(ltr) .headerbar-revealer { padding-right:6px; }
+.centerwidget:dir(rtl) .headerbar-revealer { padding-left :6px; }
+
+.centerwidget:dir(ltr) { margin-right:-6px; }
+.centerwidget:dir(rtl) { margin-left :-6px; }
+
/*\
* * pending change list popover
\*/
diff --git a/editor/dconf-window.vala b/editor/dconf-window.vala
index 30f23ed..256b623 100644
--- a/editor/dconf-window.vala
+++ b/editor/dconf-window.vala
@@ -126,7 +126,7 @@ private class DConfWindow : ApplicationWindow
install_ui_action_entries ();
install_kbd_action_entries ();
- headerbar.update_bookmarks_icons.connect (_update_bookmarks_icons);
+ headerbar.update_bookmarks_icons.connect (update_bookmarks_icons_from_variant);
use_shortpaths_changed_handler = settings.changed ["use-shortpaths"].connect_after (reload_view);
settings.bind ("use-shortpaths", model, "use-shortpaths",
SettingsBindFlags.GET|SettingsBindFlags.NO_SENSITIVITY);
@@ -365,13 +365,13 @@ private class DConfWindow : ApplicationWindow
internal void night_time_changed (Object nlm, ParamSpec thing)
{
headerbar.night_time = NightLightMonitor.NightTime.should_use_dark_theme (((NightLightMonitor)
nlm).night_time);
- headerbar.update_hamburger_menu (modifications_handler.get_current_delay_mode ());
+ headerbar.update_hamburger_menu ();
}
internal void dark_theme_changed (Object nlm, ParamSpec thing)
{
headerbar.dark_theme = ((NightLightMonitor) nlm).dark_theme;
- headerbar.update_hamburger_menu (modifications_handler.get_current_delay_mode ());
+ headerbar.update_hamburger_menu ();
}
internal void automatic_night_mode_changed (Object nlm, ParamSpec thing)
@@ -543,7 +543,8 @@ private class DConfWindow : ApplicationWindow
private const GLib.ActionEntry [] ui_action_entries =
{
- { "empty", empty, "*" },
+ { "empty", empty, "*" },
+ { "empty-null", empty },
{ "notify-folder-emptied", notify_folder_emptied, "s" },
{ "notify-object-deleted", notify_object_deleted, "(sq)" },
@@ -561,6 +562,9 @@ private class DConfWindow : ApplicationWindow
{ "toggle-search", toggle_search, "b" },
{ "update-bookmarks-icons", update_bookmarks_icons, "as" },
+ { "show-in-window-bookmarks", show_in_window_bookmarks },
+ { "hide-in-window-bookmarks", hide_in_window_bookmarks },
+
{ "reset-recursive", reset_recursively, "s" },
{ "reset-visible", reset_visible, "s" },
@@ -597,6 +601,7 @@ private class DConfWindow : ApplicationWindow
private void open_folder (SimpleAction action, Variant? path_variant)
requires (path_variant != null)
{
+ hide_in_window_bookmarks ();
headerbar.close_popovers ();
string full_name = ((!) path_variant).get_string ();
@@ -607,6 +612,7 @@ private class DConfWindow : ApplicationWindow
private void open_object (SimpleAction action, Variant? path_variant)
requires (path_variant != null)
{
+ hide_in_window_bookmarks ();
headerbar.close_popovers ();
revealer.hide_modifications_list ();
@@ -630,6 +636,7 @@ private class DConfWindow : ApplicationWindow
private void open_search (SimpleAction action, Variant? search_variant)
requires (search_variant != null)
{
+ hide_in_window_bookmarks ();
headerbar.close_popovers ();
string search = ((!) search_variant).get_string ();
@@ -640,6 +647,8 @@ private class DConfWindow : ApplicationWindow
private void open_parent (SimpleAction action, Variant? path_variant)
requires (path_variant != null)
{
+ hide_in_window_bookmarks ();
+
string full_name = ((!) path_variant).get_string ();
request_folder (ModelUtils.get_parent_path (full_name), full_name);
}
@@ -672,12 +681,14 @@ private class DConfWindow : ApplicationWindow
private void update_bookmarks_icons (SimpleAction action, Variant? bookmarks_variant)
requires (bookmarks_variant != null)
{
- _update_bookmarks_icons ((!) bookmarks_variant);
+ update_bookmarks_icons_from_variant ((!) bookmarks_variant);
}
- private void _update_bookmarks_icons (Variant bookmarks_variant)
+ private void update_bookmarks_icons_from_variant (Variant variant)
+ {
+ update_bookmarks_icons_from_array (variant.get_strv ());
+ }
+ private void update_bookmarks_icons_from_array (string [] bookmarks)
{
- string [] bookmarks = ((!) bookmarks_variant).get_strv ();
-
if (bookmarks.length == 0)
return;
@@ -685,7 +696,7 @@ private class DConfWindow : ApplicationWindow
{
if (bookmark.has_prefix ("?")) // TODO broken search
{
- headerbar.update_bookmark_icon (bookmark, BookmarkIcon.SEARCH);
+ update_bookmark_icon (bookmark, BookmarkIcon.SEARCH);
continue;
}
if (is_path_invalid (bookmark)) // TODO broken folder and broken object
@@ -698,16 +709,16 @@ private class DConfWindow : ApplicationWindow
if (context_id == ModelUtils.folder_context_id)
{
if (bookmark_exists)
- headerbar.update_bookmark_icon (bookmark, BookmarkIcon.VALID_FOLDER);
+ update_bookmark_icon (bookmark, BookmarkIcon.VALID_FOLDER);
else
- headerbar.update_bookmark_icon (bookmark, BookmarkIcon.EMPTY_FOLDER);
+ update_bookmark_icon (bookmark, BookmarkIcon.EMPTY_FOLDER);
continue;
}
if (!bookmark_exists)
- headerbar.update_bookmark_icon (bookmark, BookmarkIcon.EMPTY_OBJECT);
+ update_bookmark_icon (bookmark, BookmarkIcon.EMPTY_OBJECT);
else if (context_id == ModelUtils.dconf_context_id)
- headerbar.update_bookmark_icon (bookmark, BookmarkIcon.DCONF_OBJECT);
+ update_bookmark_icon (bookmark, BookmarkIcon.DCONF_OBJECT);
else
{
RegistryVariantDict bookmark_properties = new RegistryVariantDict.from_aqv
(model.get_key_properties (bookmark, context_id, (uint16) PropertyQuery.IS_DEFAULT));
@@ -715,12 +726,33 @@ private class DConfWindow : ApplicationWindow
if (!bookmark_properties.lookup (PropertyQuery.IS_DEFAULT, "b", out is_default))
assert_not_reached ();
if (is_default)
- headerbar.update_bookmark_icon (bookmark, BookmarkIcon.KEY_DEFAULTS);
+ update_bookmark_icon (bookmark, BookmarkIcon.KEY_DEFAULTS);
else
- headerbar.update_bookmark_icon (bookmark, BookmarkIcon.EDITED_VALUE);
+ update_bookmark_icon (bookmark, BookmarkIcon.EDITED_VALUE);
}
}
}
+ private void update_bookmark_icon (string bookmark, BookmarkIcon icon)
+ {
+ if (extra_small_window)
+ browser_view.update_bookmark_icon (bookmark, icon);
+ else
+ headerbar.update_bookmark_icon (bookmark, icon);
+ }
+
+ private void show_in_window_bookmarks (/* SimpleAction action, Variant? path_variant */)
+ {
+ headerbar.show_in_window_bookmarks ();
+ string [] bookmarks = headerbar.get_bookmarks ();
+ browser_view.show_in_window_bookmarks (bookmarks);
+ update_bookmarks_icons_from_array (bookmarks);
+ }
+
+ private void hide_in_window_bookmarks (/* SimpleAction action, Variant? path_variant */)
+ {
+ headerbar.hide_in_window_bookmarks ();
+ browser_view.hide_in_window_bookmarks ();
+ }
private void reset_recursively (SimpleAction action, Variant? path_variant)
requires (path_variant != null)
diff --git a/editor/pathwidget.ui b/editor/pathwidget.ui
index edfd8a5..a4533a4 100644
--- a/editor/pathwidget.ui
+++ b/editor/pathwidget.ui
@@ -61,17 +61,5 @@
</child>
</object>
</child>
- <child>
- <object class="Bookmarks" id="bookmarks_button">
- <property name="visible">True</property>
- <property name="valign">center</property>
- <property name="focus-on-click">False</property>
- <property name="schema-path">/ca/desrt/dconf-editor/</property>
- <!-- <accelerator key="B" signal="activate" modifiers="GDK_CONTROL_MASK"/> TODO -->
- <style>
- <class name="image-button"/> <!-- TODO https://bugzilla.gnome.org/show_bug.cgi?id=756731 -->
- </style>
- </object>
- </child>
</template>
</interface>
diff --git a/editor/pathwidget.vala b/editor/pathwidget.vala
index b0ee513..bb2851a 100644
--- a/editor/pathwidget.vala
+++ b/editor/pathwidget.vala
@@ -25,17 +25,9 @@ private class PathWidget : Box
[GtkChild] private PathBar pathbar;
[GtkChild] private PathEntry searchentry;
- [GtkChild] private Bookmarks bookmarks_button;
-
internal signal void search_changed ();
internal signal void search_stopped ();
- internal signal void update_bookmarks_icons (Variant bookmarks_variant);
- construct
- {
- bookmarks_button.update_bookmarks_icons.connect ((bookmarks_variant) => update_bookmarks_icons
(bookmarks_variant));
- }
-
/*\
* * search mode
\*/
@@ -75,18 +67,6 @@ private class PathWidget : Box
search_stopped ();
}
- /*\
- * * phone mode
- \*/
-
- internal bool extra_small_window
- {
- set
- {
- bookmarks_button.active = false;
- }
- }
-
/*\
* * proxy calls
\*/
@@ -95,7 +75,6 @@ private class PathWidget : Box
{
pathbar.set_path (type, path);
searchentry.set_path (type, path);
- bookmarks_button.set_path (type, path);
if (type == ViewType.SEARCH && !search_mode_enabled)
enter_search_mode ();
@@ -105,31 +84,16 @@ private class PathWidget : Box
internal void close_popovers ()
{
- if (bookmarks_button.active)
- bookmarks_button.active = false;
pathbar.close_menu ();
}
internal bool has_popover ()
{
- if (bookmarks_button.active)
- return true;
if (pathbar.has_popover ())
return true;
return false;
}
- internal void down_pressed ()
- {
- if (bookmarks_button.active)
- bookmarks_button.down_pressed ();
- }
- internal void up_pressed ()
- {
- if (bookmarks_button.active)
- bookmarks_button.up_pressed ();
- }
-
/* path bar */
internal string complete_path { get { return pathbar.complete_path; }}
@@ -168,26 +132,6 @@ private class PathWidget : Box
searchentry.prepare (mode, search);
}
- /* bookmarks button */
- internal string [] get_bookmarks ()
- {
- return bookmarks_button.get_bookmarks ();
- }
-
- internal void click_bookmarks_button ()
- {
- if (bookmarks_button.sensitive)
- bookmarks_button.clicked ();
- }
-
- internal void bookmark_current_path () { bookmarks_button.bookmark_current_path (); }
- internal void unbookmark_current_path () { bookmarks_button.unbookmark_current_path (); }
-
- internal void update_bookmark_icon (string bookmark, BookmarkIcon icon)
- {
- bookmarks_button.update_bookmark_icon (bookmark, icon);
- }
-
/* string [] tokens = full_name.split (" ");
uint index = 0;
string token;
@@ -203,12 +147,12 @@ private class PathWidget : Box
} */
/*\
- * * sizing
+ * * sizing; TODO should be set by the center box of the headerbar, not by one of its child...
\*/
internal override void get_preferred_width (out int minimum_width, out int natural_width)
{
base.get_preferred_width (out minimum_width, out natural_width);
- natural_width = MAX_ROW_WIDTH; // see key-list-box-row.vala
+ natural_width = MAX_ROW_WIDTH - 38; // see key-list-box-row.vala
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]