[dconf-editor] Use BookmarksList in extra-small window.
- From: Arnaud B. <arnaudb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dconf-editor] Use BookmarksList in extra-small window.
- Date: Wed, 14 Nov 2018 13:48:43 +0000 (UTC)
commit ec9407e46c83f63c7cee8a404007adce275522c5
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date: Thu Oct 25 17:04:42 2018 +0200
Use BookmarksList in extra-small window.
editor/bookmarks-list.ui | 3 +-
editor/bookmarks-list.vala | 8 ++++
editor/bookmarks.ui | 2 +
editor/browser-view.ui | 4 +-
editor/browser-view.vala | 82 +++++++++++++++-------------------------
editor/registry-placeholder.vala | 23 +++++++----
6 files changed, 60 insertions(+), 62 deletions(-)
---
diff --git a/editor/bookmarks-list.ui b/editor/bookmarks-list.ui
index 575e977..62c2318 100644
--- a/editor/bookmarks-list.ui
+++ b/editor/bookmarks-list.ui
@@ -24,10 +24,9 @@
<class name="padding-bottom"/>
</style>
<child type="placeholder">
- <object class="RegistryPlaceholder">
+ <object class="RegistryPlaceholder" id="placeholder">
<property name="label" translatable="yes">Bookmarks will
be added here</property>
<property name="icon-name">starred-symbolic</property> <!-- or starred-symbolic? or
dconf-editor-symbolic? -->
- <property name="big">False</property>
</object>
</child>
</object>
diff --git a/editor/bookmarks-list.vala b/editor/bookmarks-list.vala
index c7d3d89..c7eb2ee 100644
--- a/editor/bookmarks-list.vala
+++ b/editor/bookmarks-list.vala
@@ -24,6 +24,11 @@ private class BookmarksList : Overlay
[GtkChild] private ListBox bookmarks_list_box;
[GtkChild] private Box edit_mode_box;
+ public bool allow_edit { private get; internal construct; }
+
+ [GtkChild] private RegistryPlaceholder placeholder;
+ public bool big_placeholder { internal construct { placeholder.big = value; }}
+
private HashTable<string, Bookmark> bookmarks_hashtable = new HashTable<string, Bookmark> (str_hash,
str_equal);
private Bookmark? last_row = null;
private uint n_bookmarks = 0;
@@ -427,6 +432,9 @@ private class BookmarksList : Overlay
[GtkCallback]
private void on_content_changed ()
{
+ if (!allow_edit)
+ return;
+
List<weak Widget> widgets = bookmarks_list_box.get_children ();
if (widgets.length () == 0)
edit_mode_box.hide ();
diff --git a/editor/bookmarks.ui b/editor/bookmarks.ui
index 04381a0..ff11b84 100644
--- a/editor/bookmarks.ui
+++ b/editor/bookmarks.ui
@@ -87,6 +87,8 @@
<child>
<object class="BookmarksList" id="bookmarks_list">
<property name="visible">True</property>
+ <property name="allow-edit">True</property>
+ <property name="big-placeholder">False</property>
<signal name="selection-changed" handler="on_selection_changed"/>
</object>
</child>
diff --git a/editor/browser-view.ui b/editor/browser-view.ui
index 1c6f551..e1ee41e 100644
--- a/editor/browser-view.ui
+++ b/editor/browser-view.ui
@@ -21,8 +21,10 @@
</object>
</child>
<child>
- <object class="GtkListBox" id="bookmarks_list_box">
+ <object class="BookmarksList" id="bookmarks_list">
<property name="visible">True</property>
+ <property name="allow-edit">False</property>
+ <property name="big-placeholder">True</property>
</object>
</child>
</template>
diff --git a/editor/browser-view.vala b/editor/browser-view.vala
index 1959bde..10088c4 100644
--- a/editor/browser-view.vala
+++ b/editor/browser-view.vala
@@ -202,72 +202,34 @@ private class BrowserView : Stack, AdaptativeWidget
* * bookmarks
\*/
- [GtkChild] private ListBox bookmarks_list_box;
- [GtkChild] private Grid current_child_grid;
+ private bool in_window_bookmarks = false;
+
+ [GtkChild] private BookmarksList bookmarks_list;
+ [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 ();
+ Variant variant = new Variant.strv (bookmarks);
+ bookmarks_list.create_bookmark_rows (variant);
- 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;
}
- old_bookmarks = bookmarks;
- set_visible_child (bookmarks_list_box);
+ set_visible_child (bookmarks_list);
+ in_window_bookmarks = true;
}
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 ();
- }
+ bookmarks_list.update_bookmark_icon (bookmark, icon);
}
internal void hide_in_window_bookmarks ()
{
+ in_window_bookmarks = false;
set_visible_child (current_child_grid);
}
@@ -382,8 +344,26 @@ private class BrowserView : Stack, AdaptativeWidget
// keyboard
internal bool return_pressed () { return current_child.return_pressed (); }
- internal bool up_pressed () { return current_child.up_pressed (); }
- internal bool down_pressed () { return current_child.down_pressed (); }
+ internal bool up_pressed ()
+ {
+ if (in_window_bookmarks)
+ {
+ bookmarks_list.up_pressed ();
+ return true;
+ }
+ else
+ return current_child.up_pressed ();
+ }
+ internal bool down_pressed ()
+ {
+ if (in_window_bookmarks)
+ {
+ bookmarks_list.down_pressed ();
+ return true;
+ }
+ else
+ return current_child.down_pressed ();
+ }
internal bool toggle_row_popover () { return current_child.toggle_row_popover (); } // Menu
diff --git a/editor/registry-placeholder.vala b/editor/registry-placeholder.vala
index 63306aa..dc7b181 100644
--- a/editor/registry-placeholder.vala
+++ b/editor/registry-placeholder.vala
@@ -25,18 +25,25 @@ private class RegistryPlaceholder : Grid
public string label { internal construct set { placeholder_label.label = value; }}
public string icon_name { private get; internal construct; }
- public bool big { private get; internal construct; default = false; }
-
- construct
+ public bool big
{
- if (big)
+ internal construct set
{
- placeholder_image.pixel_size = 72;
- get_style_context ().add_class ("big-popover");
+ if (value)
+ {
+ placeholder_image.pixel_size = 72;
+ get_style_context ().add_class ("big-popover");
+ }
+ else
+ {
+ placeholder_image.pixel_size = 36;
+ get_style_context ().remove_class ("big-popover");
+ }
}
- else
- placeholder_image.pixel_size = 36;
+ }
+ construct
+ {
placeholder_image.icon_name = icon_name;
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]