[dconf-editor] Add icons to bookmarks.
- From: Arnaud B. <arnaudb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dconf-editor] Add icons to bookmarks.
- Date: Thu, 13 Sep 2018 16:41:06 +0000 (UTC)
commit 3f7852a5fc294ee49168a8556d64657b73078107
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date: Wed Sep 12 23:54:59 2018 +0200
Add icons to bookmarks.
editor/bookmark.ui | 5 ++++-
editor/bookmarks.vala | 40 ++++++++++++++++++++++++++++++++++++++--
editor/dconf-editor.css | 42 +++++++++++++++++++++++++++---------------
editor/dconf-window.vala | 32 ++++++++++++++++++++++++++++++++
editor/pathwidget.vala | 5 +++++
5 files changed, 106 insertions(+), 18 deletions(-)
---
diff --git a/editor/bookmark.ui b/editor/bookmark.ui
index 5e4c1f6..a8e0bc0 100644
--- a/editor/bookmark.ui
+++ b/editor/bookmark.ui
@@ -3,11 +3,14 @@
<!-- interface-requires gtk+ 3.0 -->
<template class="Bookmark" parent="GtkListBoxRow">
<child>
- <object class="GtkGrid">
+ <object class="GtkGrid" id="main_grid">
<property name="visible">True</property>
<property name="orientation">horizontal</property>
<property name="column-spacing">2</property>
<property name="margin-start">8</property>
+ <style>
+ <class name="bookmark"/>
+ </style>
<child>
<object class="GtkLabel" id="bookmark_label">
<property name="visible">True</property>
diff --git a/editor/bookmarks.vala b/editor/bookmarks.vala
index bce9cfd..efd12e2 100644
--- a/editor/bookmarks.vala
+++ b/editor/bookmarks.vala
@@ -95,6 +95,33 @@ private class Bookmarks : MenuButton
remove_bookmark (path);
}
+ internal void update_bookmark_icon (string bookmark, bool bookmark_exists, bool bookmark_has_schema,
bool bookmark_is_default)
+ {
+ bookmarks_list_box.@foreach ((widget) => {
+ Bookmark bookmark_row = (Bookmark) (!) widget;
+
+ if (bookmark_row.bookmark_name != bookmark)
+ return; // TODO probably doesn't stop other row to be checked
+
+ StyleContext context = ((!) bookmark_row.get_child ()).get_style_context ();
+ context.add_class ("key");
+ if (!bookmark_exists)
+ {
+ context.add_class ("dconf-key");
+ context.add_class ("erase");
+ return;
+ }
+ if (!bookmark_has_schema)
+ {
+ context.add_class ("dconf-key");
+ return;
+ }
+ context.add_class ("gsettings-key");
+ if (!bookmark_is_default)
+ context.add_class ("edited");
+ });
+ }
+
/*\
* * Action entries
\*/
@@ -162,7 +189,10 @@ private class Bookmarks : MenuButton
{
bookmarks_list_box.@foreach ((widget) => widget.destroy ());
- string [] bookmarks = settings.get_strv ("bookmarks");
+ Variant bookmarks_variant = settings.get_value ("bookmarks");
+ set_detailed_action_name ("ui.update-bookmarks-icons(" + bookmarks_variant.print (false) + ")"); //
TODO disable action on popover closed
+
+ string [] bookmarks = bookmarks_variant.get_strv ();
string [] unduplicated_bookmarks = new string [0];
foreach (string bookmark in bookmarks)
{
@@ -215,11 +245,17 @@ private class Bookmarks : MenuButton
[GtkTemplate (ui = "/ca/desrt/dconf-editor/ui/bookmark.ui")]
private class Bookmark : ListBoxRow
{
+ [GtkChild] private Grid main_grid;
[GtkChild] private Label bookmark_label;
[GtkChild] private Button destroy_button;
- internal Bookmark (string bookmark_name)
+ public string bookmark_name { get; construct; }
+
+ internal Bookmark (string _bookmark_name)
{
+ Object (bookmark_name: _bookmark_name);
+ if (ModelUtils.is_folder_path (bookmark_name))
+ main_grid.get_style_context ().add_class ("folder");
bookmark_label.set_label (bookmark_name);
Variant variant = new Variant.string (bookmark_name);
destroy_button.set_detailed_action_name ("bookmarks.unbookmark(" + variant.print (false) + ")");
diff --git a/editor/dconf-editor.css b/editor/dconf-editor.css
index d673cf2..88f2c99 100644
--- a/editor/dconf-editor.css
+++ b/editor/dconf-editor.css
@@ -37,6 +37,18 @@
margin-bottom:-2px;
}
+ .bookmark {
+ background-repeat:no-repeat;
+ background-size:1.5rem;
+}
+.small-bookmarks-rows .bookmark {
+ background-size:1.1rem;
+}
+ .bookmark:dir(ltr) { padding-left :2.2rem; background-position:0 center; }
+ .bookmark:dir(rtl) { padding-right:2.2rem; background-position:100% center; }
+.small-bookmarks-rows .bookmark:dir(ltr) { padding-left :1.7rem; }
+.small-bookmarks-rows .bookmark:dir(rtl) { padding-right:1.7rem; }
+
/*\
* * pending change list popover
\*/
@@ -138,26 +150,26 @@ list.keys-list > grid.big-popover.dim-label.vertical + grid.vertical {
/* icon choice */
-.keys-list > row > .folder {
background-image:-gtk-icontheme("folder-symbolic"); }
-.keys-list > row:active > .folder {
background-image:-gtk-icontheme("folder-open-symbolic"); }
+ row > .folder {
background-image:-gtk-icontheme("folder-symbolic"); }
+ row:active > .folder {
background-image:-gtk-icontheme("folder-open-symbolic"); }
-.keys-list > row > .key.delayed,
-.keys-list > row > .dconf-key.key.delayed,
-.keys-list > row > .edited.gsettings-key.key.delayed {
background-image:-gtk-icontheme("document-open-recent-symbolic"); }
+ row > .key.delayed,
+ row > .dconf-key.key.delayed,
+ row > .edited.gsettings-key.key.delayed {
background-image:-gtk-icontheme("document-open-recent-symbolic"); }
-.keys-list > row > .gsettings-key.key.delayed.conflict,
-.keys-list > row > .edited.gsettings-key.key.delayed.conflict {
background-image:-gtk-icontheme("document-open-recent-symbolic"); }
+ row > .gsettings-key.key.delayed.conflict,
+ row > .edited.gsettings-key.key.delayed.conflict {
background-image:-gtk-icontheme("document-open-recent-symbolic"); }
-.keys-list > row > .gsettings-key.key.conflict,
-.keys-list > row > .edited.gsettings-key.key.conflict {
background-image:-gtk-icontheme("dialog-warning-symbolic"); }
-.keys-list > row > .gsettings-key.key.hard-conflict,
-.keys-list > row > .edited.gsettings-key.key.hard-conflict {
background-image:-gtk-icontheme("dialog-error-symbolic"); }
+ row > .gsettings-key.key.conflict,
+ row > .edited.gsettings-key.key.conflict {
background-image:-gtk-icontheme("dialog-warning-symbolic"); }
+ row > .gsettings-key.key.hard-conflict,
+ row > .edited.gsettings-key.key.hard-conflict {
background-image:-gtk-icontheme("dialog-error-symbolic"); }
-.keys-list > row > .edited.gsettings-key.key {
background-image:-gtk-icontheme("document-edit-symbolic"); }
+ row > .edited.gsettings-key.key {
background-image:-gtk-icontheme("document-edit-symbolic"); }
-.keys-list > row > .dconf-key.key {
background-image:-gtk-icontheme("dialog-question-symbolic"); }
-.keys-list > row > .erase.dconf-key.key.delayed {
background-image:-gtk-icontheme("user-trash-symbolic"); }
-.keys-list > row > .erase.dconf-key.key {
background-image:-gtk-icontheme("action-unavailable-symbolic"); }
+ row > .dconf-key.key {
background-image:-gtk-icontheme("dialog-question-symbolic"); }
+ row > .erase.dconf-key.key.delayed {
background-image:-gtk-icontheme("user-trash-symbolic"); }
+ row > .erase.dconf-key.key {
background-image:-gtk-icontheme("action-unavailable-symbolic"); }
/* text styling */
diff --git a/editor/dconf-window.vala b/editor/dconf-window.vala
index 08d9644..06fba37 100644
--- a/editor/dconf-window.vala
+++ b/editor/dconf-window.vala
@@ -429,6 +429,7 @@ private class DConfWindow : ApplicationWindow
{ "reload-search", reload_search },
{ "toggle-search", toggle_search, "b" },
+ { "update-bookmarks-icons", update_bookmarks_icons, "as" },
{ "reset-recursive", reset_recursively, "s" },
{ "reset-visible", reset_visible, "s" },
@@ -519,6 +520,37 @@ private class DConfWindow : ApplicationWindow
stop_search ();
}
+ private void update_bookmarks_icons (SimpleAction action, Variant? bookmarks_variant)
+ requires (bookmarks_variant != null)
+ {
+ string [] bookmarks = ((!) bookmarks_variant).get_strv ();
+
+ if (bookmarks.length == 0)
+ return;
+
+ foreach (string bookmark in bookmarks)
+ {
+ if (ModelUtils.is_folder_path (bookmark))
+ continue; // TODO check folder existence
+
+ uint16 context_id;
+ string name;
+ bool bookmark_exists = model.get_object (bookmark, out context_id, out name, false);
+ if (!bookmark_exists)
+ path_widget.update_bookmark_icon (bookmark, false);
+ else if (context_id == ModelUtils.dconf_context_id)
+ path_widget.update_bookmark_icon (bookmark, true, false);
+ else
+ {
+ RegistryVariantDict bookmark_properties = new RegistryVariantDict.from_aqv
(model.get_key_properties (bookmark, context_id, (uint16) PropertyQuery.IS_DEFAULT));
+ bool is_default;
+ if (!bookmark_properties.lookup (PropertyQuery.IS_DEFAULT, "b", out is_default))
+ assert_not_reached ();
+ path_widget.update_bookmark_icon (bookmark, true, true, is_default);
+ }
+ }
+ }
+
private void reset_recursively (SimpleAction action, Variant? path_variant)
requires (path_variant != null)
{
diff --git a/editor/pathwidget.vala b/editor/pathwidget.vala
index db20651..d0fe5f8 100644
--- a/editor/pathwidget.vala
+++ b/editor/pathwidget.vala
@@ -168,6 +168,11 @@ private class PathWidget : Box
bookmarks_button.clicked ();
}
+ internal void update_bookmark_icon (string bookmark, bool bookmark_exists, bool bookmark_has_schema =
false, bool bookmark_is_default = false)
+ {
+ bookmarks_button.update_bookmark_icon (bookmark, bookmark_exists, bookmark_has_schema,
bookmark_is_default);
+ }
+
/*\
* * sizing
\*/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]