[dconf-editor] Allow erasing a DConfKey when not in delay mode.
- From: Arnaud Bonatti <arnaudb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dconf-editor] Allow erasing a DConfKey when not in delay mode.
- Date: Tue, 19 Jul 2016 22:56:37 +0000 (UTC)
commit 80f64f0f5ca7ae71bdfaf10602084d2b8186b666
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date: Wed Jul 20 00:55:57 2016 +0200
Allow erasing a DConfKey when not in delay mode.
editor/dconf-model.vala | 14 ++++++++++++++
editor/key-list-box-row.vala | 36 ++++++++++++++++++++++++++++++------
editor/registry-view.vala | 7 ++++++-
3 files changed, 50 insertions(+), 7 deletions(-)
---
diff --git a/editor/dconf-model.vala b/editor/dconf-model.vala
index f276310..aaf3d95 100644
--- a/editor/dconf-model.vala
+++ b/editor/dconf-model.vala
@@ -334,6 +334,20 @@ public class DConfKey : Key
private DConf.Client client;
public bool is_ghost { get; set; default = false; }
+ public void erase ()
+ {
+ try
+ {
+ client.write_sync (full_name, null);
+ }
+ catch (Error error)
+ {
+ warning (error.message);
+ }
+ is_ghost = true;
+ planned_change = false;
+ value_changed ();
+ }
public override Variant value
{
diff --git a/editor/key-list-box-row.vala b/editor/key-list-box-row.vala
index 9986cf4..23f2309 100644
--- a/editor/key-list-box-row.vala
+++ b/editor/key-list-box-row.vala
@@ -201,14 +201,35 @@ private class KeyListBoxRowEditableNoSchema : KeyListBoxRow
action.change_state (new Variant.maybe (null, new Variant.maybe (new VariantType
(key.type_string), gvariant)));
set_key_value (gvariant);
});
+
+ if (!delayed_apply_menu)
+ {
+ popover.new_section ();
+ popover.new_action ("erase", () => {
+ destroy_popover ();
+ set_key_value (null);
+ });
+ }
}
- else if (key.planned_change)
+ else
{
- popover.new_section ();
- popover.new_action ("dismiss", () => {
- destroy_popover ();
- change_dismissed ();
- });
+ if (key.planned_change)
+ {
+ popover.new_section ();
+ popover.new_action ("dismiss", () => {
+ destroy_popover ();
+ change_dismissed ();
+ });
+ }
+
+ if (!key.planned_change || key.planned_value != null)
+ {
+ popover.new_section ();
+ popover.new_action ("erase", () => {
+ destroy_popover ();
+ set_key_value (null);
+ });
+ }
}
return true;
}
@@ -368,6 +389,9 @@ private class ContextPopover : Popover
else if (action_action == "open")
/* Translators: "open folder" action in the right-click menu on a folder */
current_section.append (_("Open"), group_dot_action);
+ else if (action_action == "erase")
+ /* Translators: "erase key" action in the right-click menu on a key without schema */
+ current_section.append (_("Erase key"), group_dot_action);
else assert_not_reached ();
}
diff --git a/editor/registry-view.vala b/editor/registry-view.vala
index 94418c5..b1036ad 100644
--- a/editor/registry-view.vala
+++ b/editor/registry-view.vala
@@ -301,8 +301,13 @@ class RegistryView : Grid
key.value = (!) new_value;
else if (key.has_schema)
((GSettingsKey) key).set_to_default ();
+ else if (behaviour != Behaviour.UNSAFE)
+ {
+ revealer.enter_delay_mode ();
+ revealer.add_delayed_setting (key, null);
+ }
else
- assert_not_reached ();
+ ((DConfKey) key).erase ();
}
/*\
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]