[dconf-editor] Add 'use-shortpaths' setting.
- From: Arnaud B. <arnaudb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dconf-editor] Add 'use-shortpaths' setting.
- Date: Tue, 10 Jul 2018 16:33:06 +0000 (UTC)
commit cec55da9618b6e9a9e37fb41eb6a475b7db770f8
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date: Tue Jul 10 18:31:14 2018 +0200
Add 'use-shortpaths' setting.
When a folder only contains one subfolder and no keys,
Dconf Editor can now jump to that subfolder directly.
That can be enabled with the 'use-shortpaths' setting,
but is disabled by default, because of UI concerns.
editor/ca.desrt.dconf-editor.gschema.xml | 5 ++++
editor/dconf-model.vala | 39 +++++++++++++++++++++++++++++++-
editor/dconf-window.vala | 7 +++++-
3 files changed, 49 insertions(+), 2 deletions(-)
---
diff --git a/editor/ca.desrt.dconf-editor.gschema.xml b/editor/ca.desrt.dconf-editor.gschema.xml
index dad3ccb..a6db6a6 100644
--- a/editor/ca.desrt.dconf-editor.gschema.xml
+++ b/editor/ca.desrt.dconf-editor.gschema.xml
@@ -178,6 +178,11 @@
<summary>Mapping of paths to manually associated schemas</summary>
<description>A dictionary that maps schema IDs with path specifications. It is used to allow the user
to associate a relocatable schema to certain paths. Path specifications may contain wildcards in the form of
empty segments (e.g. /ca/desrt/dconf-editor//), defining possibly multiple paths. The same schema ID may be
associated with multiple path specifications.</description>
</key>
+ <key name="use-shortpaths" type="b">
+ <default>false</default>
+ <summary>A flag for skipping unnecessary subfolders</summary>
+ <description>When a folder only contains one subfolder and no keys, Dconf Editor can jump to that
subfolder directly. This flag enables that behaviour.</description>
+ </key>
</schema>
<schema id="ca.desrt.dconf-editor.Bookmarks">
<key name="bookmarks" type="as">
diff --git a/editor/dconf-model.vala b/editor/dconf-model.vala
index c99e2d3..a508f55 100644
--- a/editor/dconf-model.vala
+++ b/editor/dconf-model.vala
@@ -24,6 +24,8 @@ public class SettingsModel : Object
private string? last_change_tag = null;
public bool copy_action = false;
+ public bool use_shortpaths { private get; set; default = false; }
+
public signal void paths_changed (GenericSet<string> modified_path_specs, bool internal_changes);
public void refresh_relocatable_schema_paths (bool user_schemas,
@@ -130,7 +132,42 @@ public class SettingsModel : Object
Object? object = list_store.get_item (0);
do
{
- keys_array += (SettingObject) (!) object;
+ SettingObject base_object = (SettingObject) (!) object;
+ if (!use_shortpaths)
+ keys_array += base_object; // 1/4
+ else
+ {
+ string base_full_name = base_object.full_name;
+ if (is_key_path (base_full_name))
+ keys_array += base_object; // 2/4
+ else
+ {
+ GLib.ListStore child_list_store = get_children_as_liststore (base_full_name);
+ if (child_list_store.get_n_items () != 1)
+ keys_array += base_object; // 3/4
+ else
+ {
+ SettingObject test_object = (SettingObject) child_list_store.get_item (0);
+ string test_full_name = test_object.full_name;
+ if (is_key_path (test_full_name))
+ keys_array += base_object; // 4/4
+ else
+ {
+ string name = base_object.name;
+ do
+ {
+ base_full_name = test_full_name;
+ name += "/" + test_object.name;
+ child_list_store = get_children_as_liststore (test_object.full_name);
+ test_object = (SettingObject) child_list_store.get_item (0);
+ test_full_name = test_object.full_name;
+ }
+ while (!is_key_path (test_full_name) && child_list_store.get_n_items () == 1);
+ keys_array += new Directory (base_full_name, name);
+ }
+ }
+ }
+ }
position++;
object = list_store.get_item (position);
}
diff --git a/editor/dconf-window.vala b/editor/dconf-window.vala
index d59d35d..54b066f 100644
--- a/editor/dconf-window.vala
+++ b/editor/dconf-window.vala
@@ -67,12 +67,16 @@ class DConfWindow : ApplicationWindow
[GtkChild] private Revealer notification_revealer;
[GtkChild] private Label notification_label;
+ private ulong use_shortpaths_changed_handler = 0;
private ulong behaviour_changed_handler = 0;
public DConfWindow (bool disable_warning, string? schema, string? path, string? key_name)
{
install_action_entries ();
+ use_shortpaths_changed_handler = settings.changed ["use-shortpaths"].connect_after (reload_view);
+ settings.bind ("use-shortpaths", model, "use-shortpaths",
SettingsBindFlags.GET|SettingsBindFlags.NO_SENSITIVITY);
+
modifications_handler = new ModificationsHandler (model);
revealer.modifications_handler = modifications_handler;
browser_view.modifications_handler = modifications_handler;
@@ -343,6 +347,7 @@ class DConfWindow : ApplicationWindow
((ConfigurationEditor) get_application ()).clean_copy_notification ();
settings.disconnect (behaviour_changed_handler);
+ settings.disconnect (use_shortpaths_changed_handler);
settings.disconnect (small_keys_list_rows_handler);
settings.disconnect (small_bookmarks_rows_handler);
@@ -753,7 +758,7 @@ class DConfWindow : ApplicationWindow
Widget? focus = get_focus ();
bool focus_is_text_widget = focus != null && (((!) focus is Entry) || ((!) focus is TextView));
if (!focus_is_text_widget)
- if (name != "F10") // else <Shift>F10 toggles the search_entry popup
+ if (name != "F10") // else <Shift>F10 toggles the search_entry popup; see if a976aa9740 fixes
that in Gtk+ 4
if (search_bar.handle_event (event))
return true;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]