[dconf-editor] Only show reload button for external DConf changes
- From: Arnaud Bonatti <arnaudb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dconf-editor] Only show reload button for external DConf changes
- Date: Sun, 17 Dec 2017 01:46:20 +0000 (UTC)
commit 7ab8b1971bd56e734165ae6916d6c80704a8e945
Author: Davi da Silva Böger <dsboger gmail com>
Date: Sun Dec 10 18:00:42 2017 -0200
Only show reload button for external DConf changes
Takes notice of DConf.Client tags to differentiate Dconf Editor
triggered changes from external ones.
Also, reload automatically for internal DConf changes.
paths_changed signal gained a new argument to indicate if the changes
are internal, in which case the view is reloaded without asking.
editor/browser-view.vala | 2 +-
editor/dconf-model.vala | 18 +++++++++++++-----
editor/dconf-window.vala | 9 +++++++--
3 files changed, 21 insertions(+), 8 deletions(-)
---
diff --git a/editor/browser-view.vala b/editor/browser-view.vala
index 3b75dae..ab2f43b 100644
--- a/editor/browser-view.vala
+++ b/editor/browser-view.vala
@@ -380,7 +380,7 @@ class BrowserView : Grid, PathElement
}
[GtkCallback]
- private void reload ()
+ public void reload ()
{
string? saved_selection = browse_view.get_selected_row_name ();
Directory? directory = window.model.get_directory (current_path);
diff --git a/editor/dconf-model.vala b/editor/dconf-model.vala
index de1fda5..29098f3 100644
--- a/editor/dconf-model.vala
+++ b/editor/dconf-model.vala
@@ -376,8 +376,9 @@ public class SettingsModel : Object
private SchemaPathTree cached_schemas = new SchemaPathTree ("/"); // prefix tree for quick lookup and
diff'ing on changes
private DConf.Client client = new DConf.Client ();
+ private string? last_change_tag = null;
- public signal void paths_changed (GenericSet<string> modified_path_specs);
+ public signal void paths_changed (GenericSet<string> modified_path_specs, bool internal_changes);
public SettingsModel (Settings application_settings)
{
@@ -418,6 +419,13 @@ public class SettingsModel : Object
});
client.changed.connect ((client, prefix, changes, tag) => {
+ bool internal_changes = false;
+ if (last_change_tag != null && tag != null && (!) last_change_tag == (!) tag)
+ {
+ last_change_tag = null;
+ internal_changes = true;
+ }
+
GenericSet<string> modified_path_specs = new GenericSet<string> (str_hash, str_equal);
modified_path_specs.add (prefix);
foreach (string change in changes)
@@ -435,7 +443,7 @@ public class SettingsModel : Object
if (cached_schemas.get_schema_count ((!) path_spec) > 0)
iter.remove ();
}
- paths_changed (modified_path_specs);
+ paths_changed (modified_path_specs, internal_changes);
});
client.watch_sync ("/");
}
@@ -479,7 +487,7 @@ public class SettingsModel : Object
this.settings_schema_source = settings_schema_source;
if (modified_path_specs.length > 0)
- paths_changed (modified_path_specs);
+ paths_changed (modified_path_specs, false);
}
private void parse_relocatable_schemas_user_paths ()
@@ -945,7 +953,7 @@ public class SettingsModel : Object
{
try
{
- client.write_sync (key.full_name, value);
+ client.write_sync (key.full_name, value, out last_change_tag);
}
catch (Error error)
{
@@ -1022,7 +1030,7 @@ public class SettingsModel : Object
delayed_settings_hashtable.foreach_remove ((key_descriptor, schema_settings) => {
schema_settings.apply (); return true; });
try {
- client.change_sync (dconf_changeset);
+ client.change_sync (dconf_changeset, out last_change_tag);
} catch (Error error) {
warning (error.message);
}
diff --git a/editor/dconf-window.vala b/editor/dconf-window.vala
index 958b3c5..3869fec 100644
--- a/editor/dconf-window.vala
+++ b/editor/dconf-window.vala
@@ -81,7 +81,7 @@ class DConfWindow : ApplicationWindow
model = new SettingsModel (settings);
modifications_handler = new ModificationsHandler (model);
browser_view.modifications_handler = modifications_handler;
- model.paths_changed.connect ((_model, modified_path_specs) => {
+ model.paths_changed.connect ((_model, modified_path_specs, internal_changes) => {
bool current_path_modified = false;
bool is_key_path = SettingsModel.is_key_path (current_path);
string[] current_path_segments = is_key_path ? SettingsModel.to_segments
(SettingsModel.get_parent_path (current_path)) : SettingsModel.to_segments (current_path);
@@ -91,7 +91,12 @@ class DConfWindow : ApplicationWindow
current_path_modified = true;
});
if (current_path_modified)
- browser_view.show_hard_reload_warning ();
+ {
+ if (internal_changes)
+ browser_view.reload ();
+ else
+ browser_view.show_hard_reload_warning ();
+ }
});
if (!disable_warning && settings.get_boolean ("show-warning"))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]