[dconf-editor] Take care of "bookmarks" key writability.
- From: Arnaud B. <arnaudb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dconf-editor] Take care of "bookmarks" key writability.
- Date: Tue, 25 Sep 2018 07:24:18 +0000 (UTC)
commit 9c020b160202b9cd587f5210f0ece9d1f04dc61a
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date: Tue Sep 25 09:22:50 2018 +0200
Take care of "bookmarks" key writability.
editor/bookmark.ui | 1 +
editor/bookmarks.ui | 30 +++++++++++++++++++++++++++++-
editor/bookmarks.vala | 34 ++++++++++++++++++++++++++++++----
editor/dconf-editor.css | 4 ++++
4 files changed, 64 insertions(+), 5 deletions(-)
---
diff --git a/editor/bookmark.ui b/editor/bookmark.ui
index a8e0bc0..3c89ae7 100644
--- a/editor/bookmark.ui
+++ b/editor/bookmark.ui
@@ -16,6 +16,7 @@
<property name="visible">True</property>
<property name="hexpand">True</property>
<property name="halign">start</property>
+ <property name="vexpand">True</property>
<property name="max-width-chars">42</property>
<property name="ellipsize">PANGO_ELLIPSIZE_START</property>
</object>
diff --git a/editor/bookmarks.ui b/editor/bookmarks.ui
index ad1cdad..7440647 100644
--- a/editor/bookmarks.ui
+++ b/editor/bookmarks.ui
@@ -11,7 +11,7 @@
<object class="GtkGrid">
<property name="visible">True</property>
<property name="column-spacing">12</property>
- <property name="row-spacing">6</property>
+ <property name="row-spacing">0</property>
<property name="margin">4</property>
<child>
<object class="GtkLabel" id="switch_label">
@@ -52,6 +52,9 @@
<property name="max-content-height">300</property>
<property name="propagate-natural-width">True</property>
<property name="propagate-natural-height">True</property>
+ <style>
+ <class name="margin-top-6px"/>
+ </style>
<child>
<object class="GtkListBox" id="bookmarks_list_box">
<property name="visible">True</property>
@@ -74,6 +77,31 @@ be added here</property> <!-- line wrap wanted -->
<property name="height">1</property>
</packing>
</child>
+ <child>
+ <object class="GtkRevealer" id="bookmarks_editable_revealer">
+ <property name="visible">True</property>
+ <property name="transition-type">slide-down</property>
+ <property name="transition-duration">300</property>
+ <property name="reveal-child">False</property>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="hexpand">True</property>
+ <property name="label" translatable="yes">The bookmarks list is not editable.</property>
+ <style>
+ <class name="italic-label"/>
+ <class name="margin-top-6px"/>
+ </style>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="left-attach">0</property>
+ <property name="top-attach">2</property>
+ <property name="width">2</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
</object>
</child>
</object>
diff --git a/editor/bookmarks.vala b/editor/bookmarks.vala
index 08d27e8..da62e38 100644
--- a/editor/bookmarks.vala
+++ b/editor/bookmarks.vala
@@ -26,6 +26,7 @@ private class Bookmarks : MenuButton
[GtkChild] private Image bookmarks_icon;
[GtkChild] private Switch bookmarked_switch;
[GtkChild] private Label switch_label;
+ [GtkChild] private Revealer bookmarks_editable_revealer;
private string current_path = "/";
private ViewType current_type = ViewType.FOLDER;
@@ -44,13 +45,19 @@ private class Bookmarks : MenuButton
settings = new GLib.Settings.with_path (schema_id, schema_path);
+ enable_remove = settings.is_writable ("bookmarks");
+
ulong bookmarks_changed_handler = settings.changed ["bookmarks"].connect (on_bookmarks_changed);
update_bookmarks (settings.get_value ("bookmarks"));
+ ulong bookmarks_writable_handler = settings.writable_changed ["bookmarks"].connect
(set_switch_sensitivity);
+ set_switch_sensitivity ();
+
ulong clicked_handler = clicked.connect (() => { if (active) bookmarked_switch.grab_focus (); });
destroy.connect (() => {
settings.disconnect (bookmarks_changed_handler);
+ settings.disconnect (bookmarks_writable_handler);
disconnect (clicked_handler);
});
}
@@ -60,6 +67,17 @@ private class Bookmarks : MenuButton
Variant bookmarks_variant = _settings.get_value ("bookmarks");
update_bookmarks (bookmarks_variant);
update_icon_and_switch (bookmarks_variant);
+ set_switch_sensitivity ();
+ }
+
+ bool enable_remove = true;
+ private void set_switch_sensitivity ()
+ {
+ enable_remove = settings.is_writable ("bookmarks");
+ switch_label.set_sensitive (enable_remove);
+ bookmarked_switch.set_sensitive (enable_remove);
+ bookmarks_editable_revealer.set_reveal_child (!enable_remove);
+ bookmarks_list_box.@foreach ((widget) => ((Bookmark) widget).set_enable_remove (enable_remove));
}
/*\
@@ -199,6 +217,7 @@ private class Bookmarks : MenuButton
bookmarks_icon.icon_name = "starred-symbolic";
update_switch_state (true, ref bookmarked_switch);
bookmarked_switch.set_detailed_action_name ("bookmarks.unbookmark(" + variant.print (true) +
")");
+ bookmarked_switch.set_sensitive (enable_remove);
}
else
{
@@ -206,6 +225,7 @@ private class Bookmarks : MenuButton
bookmarks_icon.icon_name = "non-starred-symbolic";
update_switch_state (false, ref bookmarked_switch);
bookmarked_switch.set_detailed_action_name ("bookmarks.bookmark(" + variant.print (true) + ")");
+ bookmarked_switch.set_sensitive (enable_remove);
}
}
private static void update_switch_state (bool bookmarked, ref Switch bookmarked_switch)
@@ -219,9 +239,9 @@ private class Bookmarks : MenuButton
private void update_bookmarks (Variant bookmarks_variant)
{
set_detailed_action_name ("ui.update-bookmarks-icons(" + bookmarks_variant.print (true) + ")"); //
TODO disable action on popover closed
- create_bookmark_rows (bookmarks_variant, ref bookmarks_list_box, ref bookmarks_hashtable);
+ create_bookmark_rows (bookmarks_variant, enable_remove, ref bookmarks_list_box, ref
bookmarks_hashtable);
}
- private static void create_bookmark_rows (Variant bookmarks_variant, ref ListBox bookmarks_list_box, ref
HashTable<string, Bookmark> bookmarks_hashtable)
+ private static void create_bookmark_rows (Variant bookmarks_variant, bool enable_remove, ref ListBox
bookmarks_list_box, ref HashTable<string, Bookmark> bookmarks_hashtable)
{
bookmarks_list_box.@foreach ((widget) => widget.destroy ());
bookmarks_hashtable.remove_all ();
@@ -236,7 +256,7 @@ private class Bookmarks : MenuButton
continue;
unduplicated_bookmarks += bookmark;
- Bookmark bookmark_row = create_bookmark_row (bookmark);
+ Bookmark bookmark_row = create_bookmark_row (bookmark, enable_remove);
bookmarks_list_box.add (bookmark_row);
bookmarks_hashtable.insert (bookmark, bookmark_row);
}
@@ -244,7 +264,7 @@ private class Bookmarks : MenuButton
if (first_row != null)
bookmarks_list_box.select_row ((!) first_row);
}
- private static inline Bookmark create_bookmark_row (string bookmark)
+ private static inline Bookmark create_bookmark_row (string bookmark, bool enable_remove)
{
Bookmark bookmark_row = new Bookmark (bookmark);
if (bookmark.has_prefix ("?"))
@@ -262,6 +282,7 @@ private class Bookmarks : MenuButton
Variant variant = new Variant.string (bookmark);
bookmark_row.set_detailed_action_name ("ui.open-folder(" + variant.print (false) + ")");
}
+ bookmark_row.set_enable_remove (enable_remove); // put it here as setting detailed action name makes
the button sensitive
bookmark_row.show ();
return bookmark_row;
}
@@ -332,4 +353,9 @@ private class Bookmark : ListBoxRow
Variant variant = new Variant ("(sy)", bookmark_text, ViewType.to_byte (bookmark_type));
destroy_button.set_detailed_action_name ("bookmarks.unbookmark(" + variant.print (true) + ")");
}
+
+ internal void set_enable_remove (bool new_sensitivity)
+ {
+ destroy_button.set_sensitive (new_sensitivity);
+ }
}
diff --git a/editor/dconf-editor.css b/editor/dconf-editor.css
index 93da5c6..0043daa 100644
--- a/editor/dconf-editor.css
+++ b/editor/dconf-editor.css
@@ -438,3 +438,7 @@
.big-popover {
font-size:144%;
}
+
+.margin-top-6px {
+ margin-top:6px;
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]