[dconf-editor] Handle context for objects.
- From: Arnaud Bonatti <arnaudb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dconf-editor] Handle context for objects.
- Date: Wed, 24 Jan 2018 21:44:53 +0000 (UTC)
commit 726a2bed919c7ace5e656a276d1c0b4ef9077780
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date: Wed Jan 24 22:35:13 2018 +0100
Handle context for objects.
editor/bookmarks.vala | 11 ++++++++---
editor/browser-view.vala | 2 +-
editor/dconf-model.vala | 10 +++++-----
editor/dconf-window.vala | 19 ++++++++++++-------
editor/key-list-box-row.vala | 4 ++--
editor/pathbar.ui | 2 +-
editor/pathbar.vala | 26 ++++++++++++++++++++------
editor/registry-search.vala | 4 +++-
editor/registry-view.vala | 4 +++-
9 files changed, 55 insertions(+), 27 deletions(-)
---
diff --git a/editor/bookmarks.vala b/editor/bookmarks.vala
index 3b8fd77..ed9ac9f 100644
--- a/editor/bookmarks.vala
+++ b/editor/bookmarks.vala
@@ -101,10 +101,15 @@ public class Bookmarks : MenuButton
Bookmark bookmark_row = new Bookmark (bookmark);
if (SettingsModel.is_key_path (bookmark))
- bookmark_row.action_name = "ui.open-object";
+ {
+ Variant variant = new Variant ("(ss)", bookmark, "");
+ bookmark_row.set_detailed_action_name ("ui.open-object(" + variant.print (false) + ")");
// TODO save context
+ }
else
- bookmark_row.action_name = "ui.open-folder";
- bookmark_row.action_target = bookmark;
+ {
+ Variant variant = new Variant.string (bookmark);
+ bookmark_row.set_detailed_action_name ("ui.open-folder(" + variant.print (false) + ")");
+ }
ulong destroy_button_clicked_handler = bookmark_row.destroy_button.clicked.connect (() =>
remove_bookmark (bookmark));
bookmark_row.destroy_button.destroy.connect (() => bookmark_row.destroy_button.disconnect
(destroy_button_clicked_handler));
bookmark_row.show ();
diff --git a/editor/browser-view.vala b/editor/browser-view.vala
index 63a80af..72c8b66 100644
--- a/editor/browser-view.vala
+++ b/editor/browser-view.vala
@@ -281,7 +281,7 @@ class BrowserView : Grid
}
else if (current_view_is_properties_view ())
{
- Key? fresh_key = model.get_key (path);
+ Key? fresh_key = model.get_key (path, "");
if (fresh_key != null && !properties_view.check_reload ((!) fresh_key, model.get_key_value ((!)
fresh_key)))
return false;
}
diff --git a/editor/dconf-model.vala b/editor/dconf-model.vala
index 5566438..6050cd4 100644
--- a/editor/dconf-model.vala
+++ b/editor/dconf-model.vala
@@ -137,12 +137,12 @@ public class SettingsModel : Object
public SettingObject? get_object (string path)
{
if (is_key_path (path))
- return (SettingObject?) get_key (path);
+ return (SettingObject?) get_key (path, "");
else
return (SettingObject?) get_directory (path);
}
- public Key? get_key (string path)
+ public Key? get_key (string path, string context)
{
GLib.ListStore? key_model = get_children (get_parent_path (path));
return get_key_from_path_and_name (key_model, get_name (path));
@@ -354,7 +354,7 @@ public class SettingsModel : Object
string fallback_path = path;
if (is_key_path (path))
{
- Key? key = get_key (path);
+ Key? key = get_key (path, "");
if (key != null)
{
warning_multiple_schemas = true; // TODO meaningless
@@ -377,9 +377,9 @@ public class SettingsModel : Object
* * Key value methods
\*/
- public string get_key_copy_text (string full_name)
+ public string get_key_copy_text (string full_name, string context = "")
{
- Key? key = get_key (full_name);
+ Key? key = get_key (full_name, context);
if (key == null)
return full_name;
diff --git a/editor/dconf-window.vala b/editor/dconf-window.vala
index b6f68d6..b73dbce 100644
--- a/editor/dconf-window.vala
+++ b/editor/dconf-window.vala
@@ -362,7 +362,7 @@ class DConfWindow : ApplicationWindow
private const GLib.ActionEntry [] action_entries =
{
{ "open-folder", open_folder, "s" },
- { "open-object", open_object, "s" },
+ { "open-object", open_object, "(ss)" },
{ "open-parent", open_parent, "s" },
{ "reload-folder", reload_folder },
@@ -396,9 +396,11 @@ class DConfWindow : ApplicationWindow
if (bookmarks_button.active)
bookmarks_button.active = false;
- string full_name = ((!) path_variant).get_string ();
+ string full_name;
+ string context;
+ ((!) path_variant).@get ("(ss)", out full_name, out context);
- request_object_path (full_name);
+ request_object_path (full_name, context);
}
private void open_parent (SimpleAction action, Variant? path_variant)
@@ -415,7 +417,7 @@ class DConfWindow : ApplicationWindow
private void reload_object (/* SimpleAction action, Variant? path_variant */)
{
- request_object_path (current_path, false);
+ request_object_path (current_path, "", false);
}
private void reload_search (/* SimpleAction action, Variant? path_variant */)
@@ -500,9 +502,12 @@ class DConfWindow : ApplicationWindow
search_bar.search_mode_enabled = false; // do last to avoid flickering RegistryView before
PropertiesView when selecting a search result
}
- private void request_object_path (string full_name, bool notify_missing = true)
+ private void request_object_path (string full_name, string context = "", bool notify_missing = true)
{
- Key? found_object = model.get_key (full_name);
+ Key? found_object = model.get_key (full_name, context);
+ if (found_object == null) // TODO warn about missing context
+ found_object = model.get_key (full_name, "");
+
if (found_object == null)
{
if (notify_missing)
@@ -530,7 +535,7 @@ class DConfWindow : ApplicationWindow
if (browser_view.current_view_is_browse_view ())
request_folder_path (current_path, browser_view.get_selected_row_name ());
else if (browser_view.current_view_is_properties_view ())
- request_object_path (current_path, false);
+ request_object_path (current_path, "", false);
else if (browser_view.current_view_is_search_results_view ())
browser_view.reload_search (current_path, bookmarks_button.get_bookmarks ());
}
diff --git a/editor/key-list-box-row.vala b/editor/key-list-box-row.vala
index 147af4c..87dfbae 100644
--- a/editor/key-list-box-row.vala
+++ b/editor/key-list-box-row.vala
@@ -362,7 +362,7 @@ private class KeyListBoxRowEditableNoSchema : KeyListBoxRow
popover.new_section ();
}
- variant = new Variant.string (key.full_name);
+ variant = new Variant ("(ss)", key.full_name, ".dconf");
popover.new_gaction ("customize", "ui.open-object(" + variant.print (false) + ")");
popover.new_copy_action (get_text ());
@@ -501,7 +501,7 @@ private class KeyListBoxRowEditable : KeyListBoxRow
bool planned_change = modifications_handler.key_has_planned_change (key);
Variant? planned_value = modifications_handler.get_key_planned_value (key);
- variant = new Variant.string (key.full_name);
+ variant = new Variant ("(ss)", key.full_name, key.schema_id);
popover.new_gaction ("customize", "ui.open-object(" + variant.print (false) + ")");
popover.new_copy_action (get_text ());
diff --git a/editor/pathbar.ui b/editor/pathbar.ui
index 0616aa2..6bd1315 100644
--- a/editor/pathbar.ui
+++ b/editor/pathbar.ui
@@ -10,7 +10,7 @@
<object class="PathBarItem" id="root_button">
<property name="visible">True</property>
<property name="action-name">ui.open-folder</property>
- <property name="default-action">ui.open-folder</property>
+ <property name="default-action">ui.open-folder('/')</property>
<property name="action-target">'/'</property>
<style>
<class name="root-button"/>
diff --git a/editor/pathbar.vala b/editor/pathbar.vala
index 5eaecf1..1cad0d4 100644
--- a/editor/pathbar.vala
+++ b/editor/pathbar.vala
@@ -126,7 +126,13 @@ public class PathBar : Box
Variant? variant = item.get_action_target_value ();
if (variant == null)
assert_not_reached ();
- action_target = ((!) variant).get_string ();
+ if (((!) variant).get_type_string () == "s") // directory
+ action_target = ((!) variant).get_string ();
+ else
+ {
+ string unused;
+ ((!) variant).get ("(ss)", out action_target, out unused);
+ }
}
StyleContext context = child.get_style_context ();
if (non_ghost_path.has_prefix (action_target))
@@ -147,9 +153,17 @@ public class PathBar : Box
private void add_path_bar_item (string label, string complete_path, bool is_folder, bool block)
{
- PathBarItem path_bar_item = new PathBarItem (label, is_folder ? "ui.open-folder" : "ui.open-object");
- path_bar_item.action_target = new Variant.string (complete_path);
-
+ PathBarItem path_bar_item;
+ if (is_folder)
+ {
+ Variant variant = new Variant.string (complete_path);
+ path_bar_item = new PathBarItem (label, "ui.open-folder(" + variant.print (false) + ")");
+ }
+ else
+ {
+ Variant variant = new Variant ("(ss)", complete_path, "");
+ path_bar_item = new PathBarItem (label, "ui.open-object(" + variant.print (false) + ")");
+ }
add (path_bar_item);
activate_item (path_bar_item, block); // has to be after add()
}
@@ -169,7 +183,7 @@ public class PathBar : Box
else
{
item.cursor_type = PathBarItem.CursorType.POINTER;
- item.set_action_name (item.default_action);
+ item.set_detailed_action_name (item.default_action);
context.remove_class ("active");
}
}
@@ -230,6 +244,6 @@ private class PathBarItem : Button
{
Object (text_string: label, default_action: action);
text_label.set_text (label);
- set_action_name (action);
+ set_detailed_action_name (action);
}
}
diff --git a/editor/registry-search.vala b/editor/registry-search.vala
index 0ffb911..d249379 100644
--- a/editor/registry-search.vala
+++ b/editor/registry-search.vala
@@ -171,13 +171,15 @@ class RegistrySearch : Grid, BrowsableView
{
wrapper.get_style_context ().add_class ("folder-row");
wrapper.action_name = "ui.open-folder";
+ wrapper.set_action_target ("s", setting_object.full_name);
}
else
{
wrapper.get_style_context ().add_class ("key-row");
wrapper.action_name = "ui.open-object";
+ string context = (setting_object is GSettingsKey) ? ((GSettingsKey) setting_object).schema_id :
".dconf";
+ wrapper.set_action_target ("(ss)", setting_object.full_name, context);
}
- wrapper.action_target = setting_object.full_name;
return wrapper;
}
diff --git a/editor/registry-view.vala b/editor/registry-view.vala
index 23812d7..3a42c24 100644
--- a/editor/registry-view.vala
+++ b/editor/registry-view.vala
@@ -209,13 +209,15 @@ class RegistryView : Grid, BrowsableView
{
wrapper.get_style_context ().add_class ("folder-row");
wrapper.action_name = "ui.open-folder";
+ wrapper.set_action_target ("s", setting_object.full_name);
}
else
{
wrapper.get_style_context ().add_class ("key-row");
wrapper.action_name = "ui.open-object";
+ string context = (setting_object is GSettingsKey) ? ((GSettingsKey) setting_object).schema_id :
".dconf";
+ wrapper.set_action_target ("(ss)", setting_object.full_name, context);
}
- wrapper.action_target = setting_object.full_name;
return wrapper;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]