[dconf-editor] "Grey-out" pathbar items that do not exist
- From: Arnaud Bonatti <arnaudb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dconf-editor] "Grey-out" pathbar items that do not exist
- Date: Sun, 17 Dec 2017 23:15:53 +0000 (UTC)
commit 3a31e7e78d67bfe085077209c01a9cac2224f651
Author: Davi da Silva Böger <dsboger gmail com>
Date: Sat Dec 16 17:34:34 2017 -0200
"Grey-out" pathbar items that do not exist
Also do not change cursor for greyed items.
editor/dconf-editor.css | 5 ++++
editor/dconf-window.vala | 2 +
editor/pathbar.vala | 51 +++++++++++++++++++++++++++++++++++----------
3 files changed, 46 insertions(+), 12 deletions(-)
---
diff --git a/editor/dconf-editor.css b/editor/dconf-editor.css
index 40dcbd5..a79e35b 100644
--- a/editor/dconf-editor.css
+++ b/editor/dconf-editor.css
@@ -215,6 +215,11 @@
border-bottom-color:@theme_selected_bg_color;
}
+.pathbar > button.dim-label:backdrop,
+.pathbar > label.dim-label:backdrop {
+ opacity: 1;
+}
+
/* search changes */
#search-toggle:checked ~ .pathbar {
color:@insensitive_fg_color;
diff --git a/editor/dconf-window.vala b/editor/dconf-window.vala
index 3e63cc8..043d367 100644
--- a/editor/dconf-window.vala
+++ b/editor/dconf-window.vala
@@ -79,10 +79,12 @@ class DConfWindow : ApplicationWindow
insert_action_group ("ui", action_group);
model = new SettingsModel (settings);
+ pathbar.model = model;
modifications_handler = new ModificationsHandler (model);
browser_view.modifications_handler = modifications_handler;
model.paths_changed.connect ((_model, modified_path_specs, internal_changes) => {
browser_view.check_reload (internal_changes);
+ pathbar.set_path (current_path); // update "ghost" status
});
if (!disable_warning && settings.get_boolean ("show-warning"))
diff --git a/editor/pathbar.vala b/editor/pathbar.vala
index 9837acf..750ee31 100644
--- a/editor/pathbar.vala
+++ b/editor/pathbar.vala
@@ -22,6 +22,8 @@ public class PathBar : Box, PathElement
{
[GtkChild] private PathBarItem root_button;
+ public SettingsModel model { private get; set; }
+
private string complete_path = "";
construct
@@ -43,6 +45,7 @@ public class PathBar : Box, PathElement
string last = split [split.length - 1];
bool is_key_path = last != "";
+ PathBarItem? last_item = null;
bool destroy_all = false;
bool maintain_all = false;
@foreach ((child) => {
@@ -51,11 +54,21 @@ public class PathBar : Box, PathElement
if (destroy_all)
child.destroy ();
else
+ {
complete_path += "/";
+ if (last_item != null)
+ {
+ bool is_ghost = model.get_directory (complete_path) == null;
+ set_is_ghost ((!) last_item, is_ghost);
+ last_item = null;
+ set_is_ghost (child, is_ghost);
+ }
+ }
return;
}
PathBarItem item = (PathBarItem) child;
+ last_item = item;
if (maintain_all)
{
@@ -82,6 +95,13 @@ public class PathBar : Box, PathElement
destroy_all = true;
});
+ if (last_item != null)
+ {
+ bool is_ghost = !(model.get_object (complete_path) is Key);
+ set_is_ghost ((!) last_item, is_ghost);
+ last_item = null;
+ }
+
if (split.length > 0)
{
/* add one item per folder */
@@ -91,8 +111,9 @@ public class PathBar : Box, PathElement
foreach (string item in split [0:split.length - 1])
{
complete_path += item + "/";
- add_path_bar_item (item, complete_path, !is_key_path && (index == split.length - 2));
- add_slash_label ();
+ bool is_ghost = model.get_directory (complete_path) == null;
+ set_is_ghost (add_path_bar_item (item, complete_path, !is_key_path && (index ==
split.length - 2)), is_ghost);
+ set_is_ghost (add_slash_label (), is_ghost);
index++;
}
}
@@ -101,7 +122,8 @@ public class PathBar : Box, PathElement
if (is_key_path)
{
complete_path += last;
- add_path_bar_item (last, complete_path, true);
+ bool is_ghost = !(model.get_object (complete_path) is Key);
+ set_is_ghost (add_path_bar_item (last, complete_path, true), is_ghost);
}
}
@@ -134,25 +156,34 @@ public class PathBar : Box, PathElement
* * widgets management
\*/
- private void add_slash_label ()
+ private Label add_slash_label ()
{
- add (new Label ("/"));
+ Label slash_label = new Label ("/");
+ add (slash_label);
+ return slash_label;
}
- private void add_path_bar_item (string label, string complete_path, bool block)
+ private PathBarItem add_path_bar_item (string label, string complete_path, bool block)
{
PathBarItem path_bar_item = new PathBarItem (label);
path_bar_item.action_target = new Variant.string (complete_path);
add (path_bar_item);
activate_item (path_bar_item, block); // has to be after add()
+ return path_bar_item;
+ }
+
+ private void set_is_ghost (Widget child, bool is_ghost)
+ {
+ if (is_ghost)
+ child.get_style_context ().add_class ("dim-label");
+ else
+ child.get_style_context ().remove_class ("dim-label");
}
private void activate_item (PathBarItem item, bool state)
{
StyleContext context = item.get_style_context ();
- if (state == context.has_class ("active"))
- return;
if (state)
{
item.cursor_type = PathBarItem.CursorType.CONTEXT;
@@ -209,11 +240,7 @@ private class PathBarItem : Button
private void update_cursor ()
{
if (cursor_type != CursorType.CONTEXT)
- {
- cursor_type = CursorType.CONTEXT;
- set_new_cursor_type (cursor_type);
return;
- }
GLib.Menu menu = new GLib.Menu ();
menu.append (_("Copy current path"), "app.copy(\"" + get_action_target_value ().get_string () +
"\")");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]