[dconf-editor] Rework update.
- From: Arnaud B. <arnaudb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dconf-editor] Rework update.
- Date: Sun, 1 Jul 2018 18:26:51 +0000 (UTC)
commit 6ff7d55adb62ba97d681125664ac9cdd4da25c51
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date: Sun Jul 1 19:06:25 2018 +0200
Rework update.
editor/key-list-box-row.vala | 20 +++++++-------------
editor/registry-search.vala | 39 ++++++++++++++++++++++++++++++++-------
editor/registry-view.vala | 39 ++++++++++++++++++++++++++++++++-------
3 files changed, 71 insertions(+), 27 deletions(-)
---
diff --git a/editor/key-list-box-row.vala b/editor/key-list-box-row.vala
index 44821e4..2347288 100644
--- a/editor/key-list-box-row.vala
+++ b/editor/key-list-box-row.vala
@@ -237,10 +237,8 @@ private abstract class KeyListBoxRow : ClickableListBoxRow
key_name_and_value_grid.attach ((!) boolean_switch, 1, 0, 1, 2);
}
- update ();
key_name_label.set_label (search_result_mode ? full_name : key_name);
}
- public abstract void update ();
public void toggle_boolean_key ()
{
@@ -323,10 +321,9 @@ private class KeyListBoxRowEditableNoSchema : KeyListBoxRow
search_result_mode: search_result_mode);
}
- public override void update ()
+ public void update (Variant? key_value)
{
- SettingsModel model = modifications_handler.model;
- if (model.is_key_ghost (full_name))
+ if (key_value == null)
{
if (boolean_switch != null)
{
@@ -337,19 +334,18 @@ private class KeyListBoxRowEditableNoSchema : KeyListBoxRow
}
else
{
- Variant key_value = model.get_key_value (key);
if (boolean_switch != null)
{
key_value_label.hide ();
((!) boolean_switch).show ();
- bool key_value_boolean = key_value.get_boolean ();
+ bool key_value_boolean = ((!) key_value).get_boolean ();
Variant switch_variant = new Variant ("(sb)", full_name, !key_value_boolean);
((!) boolean_switch).set_action_name ("ui.empty");
((!) boolean_switch).set_active (key_value_boolean);
((!) boolean_switch).set_detailed_action_name ("bro.toggle-dconf-key-switch(" +
switch_variant.print (false) + ")");
}
- key_value_label.set_label (Key.cool_text_value_from_variant (key_value, type_string));
+ key_value_label.set_label (Key.cool_text_value_from_variant ((!) key_value, type_string));
}
}
@@ -478,21 +474,19 @@ private class KeyListBoxRowEditable : KeyListBoxRow
search_result_mode: search_result_mode);
}
- public override void update ()
+ public void update (Variant key_value, bool is_key_default, bool key_default_value_if_bool)
{
- SettingsModel model = modifications_handler.model;
- Variant key_value = model.get_key_value (key);
if (boolean_switch != null)
{
bool key_value_boolean = key_value.get_boolean ();
- Variant switch_variant = new Variant ("(ssbb)", full_name, schema_id, !key_value_boolean,
key.default_value.get_boolean ());
+ Variant switch_variant = new Variant ("(ssbb)", full_name, schema_id, !key_value_boolean,
key_default_value_if_bool);
((!) boolean_switch).set_action_name ("ui.empty");
((!) boolean_switch).set_active (key_value_boolean);
((!) boolean_switch).set_detailed_action_name ("bro.toggle-gsettings-key-switch(" +
switch_variant.print (false) + ")");
}
StyleContext css_context = get_style_context ();
- if (model.is_key_default (key))
+ if (is_key_default)
css_context.remove_class ("edited");
else
css_context.add_class ("edited");
diff --git a/editor/registry-search.vala b/editor/registry-search.vala
index 2923ea1..c551953 100644
--- a/editor/registry-search.vala
+++ b/editor/registry-search.vala
@@ -65,26 +65,51 @@ class RegistrySearch : RegistryList
}
else
{
+ SettingsModel model = modifications_handler.model;
Key key = (Key) setting_object;
+ ulong key_value_changed_handler;
if (setting_object is GSettingsKey)
+ {
+ GSettingsKey gkey = (GSettingsKey) key;
+ bool key_default_value_if_bool = key.type_string == "b" ? gkey.default_value.get_boolean ()
: false; // TODO better 4/6
row = new KeyListBoxRowEditable ( key.type_string,
- (GSettingsKey) setting_object,
- ((GSettingsKey) setting_object).schema_id,
+ gkey,
+ gkey.schema_id,
modifications_handler,
setting_object.name, full_name,
!is_local_result);
+ key_value_changed_handler = key.value_changed.connect (() => {
+ ((KeyListBoxRowEditable) row).update (model.get_key_value (key),
+ model.is_key_default (gkey),
+ key_default_value_if_bool);
// TODO better 5/6
+ row.destroy_popover ();
+ });
+ ((KeyListBoxRowEditable) row).update (model.get_key_value (key),
+ model.is_key_default (gkey),
+ key_default_value_if_bool);
// TODO better 6/6
+ }
else
+ {
+ DConfKey dkey = (DConfKey) setting_object;
row = new KeyListBoxRowEditableNoSchema ( key.type_string,
- (DConfKey) setting_object,
+ dkey,
modifications_handler,
setting_object.name, full_name,
!is_local_result);
+ key_value_changed_handler = key.value_changed.connect (() => {
+ if (model.is_key_ghost (full_name)) // fails with the ternary operator 3/4
+ ((KeyListBoxRowEditableNoSchema) row).update (null);
+ else
+ ((KeyListBoxRowEditableNoSchema) row).update (model.get_key_value (dkey));
+ row.destroy_popover ();
+ });
+ if (model.is_key_ghost (full_name)) // fails with the ternary operator 4/4
+ ((KeyListBoxRowEditableNoSchema) row).update (null);
+ else
+ ((KeyListBoxRowEditableNoSchema) row).update (model.get_key_value (dkey));
+ }
KeyListBoxRow key_row = (KeyListBoxRow) row;
key_row.small_keys_list_rows = _small_keys_list_rows;
- ulong key_value_changed_handler = key.value_changed.connect (() => {
- key_row.update ();
- key_row.destroy_popover ();
- });
ulong delayed_modifications_changed_handler =
modifications_handler.delayed_changes_changed.connect (() => set_delayed_icon (key_row));
set_delayed_icon (key_row);
row.destroy.connect (() => {
diff --git a/editor/registry-view.vala b/editor/registry-view.vala
index fc9857b..1ebd62d 100644
--- a/editor/registry-view.vala
+++ b/editor/registry-view.vala
@@ -303,26 +303,51 @@ class RegistryView : RegistryList
}
else
{
+ SettingsModel model = modifications_handler.model;
Key key = (Key) setting_object;
+ ulong key_value_changed_handler;
if (setting_object is GSettingsKey)
+ {
+ GSettingsKey gkey = (GSettingsKey) key;
+ bool key_default_value_if_bool = key.type_string == "b" ? gkey.default_value.get_boolean ()
: false; // TODO better 1/6
row = new KeyListBoxRowEditable ( key.type_string,
- (GSettingsKey) setting_object,
- ((GSettingsKey) setting_object).schema_id,
+ gkey,
+ gkey.schema_id,
modifications_handler,
setting_object.name, full_name);
+ key_value_changed_handler = key.value_changed.connect (() => {
+ ((KeyListBoxRowEditable) row).update (model.get_key_value (key),
+ model.is_key_default (gkey),
+ key_default_value_if_bool);
// TODO better 2/6
+ row.destroy_popover ();
+ });
+ ((KeyListBoxRowEditable) row).update (model.get_key_value (key),
+ model.is_key_default (gkey),
+ key_default_value_if_bool);
// TODO better 3/6
+ }
else
+ {
+ DConfKey dkey = (DConfKey) setting_object;
row = new KeyListBoxRowEditableNoSchema ( key.type_string,
- (DConfKey) setting_object,
+ dkey,
modifications_handler,
setting_object.name, full_name);
+ key_value_changed_handler = key.value_changed.connect (() => {
+ if (model.is_key_ghost (full_name)) // fails with the ternary operator 1/4
+ ((KeyListBoxRowEditableNoSchema) row).update (null);
+ else
+ ((KeyListBoxRowEditableNoSchema) row).update (model.get_key_value (dkey));
+ row.destroy_popover ();
+ });
+ if (model.is_key_ghost (full_name)) // fails with the ternary operator 2/4
+ ((KeyListBoxRowEditableNoSchema) row).update (null);
+ else
+ ((KeyListBoxRowEditableNoSchema) row).update (model.get_key_value (dkey));
+ }
KeyListBoxRow key_row = (KeyListBoxRow) row;
key_row.small_keys_list_rows = _small_keys_list_rows;
- ulong key_value_changed_handler = key.value_changed.connect (() => {
- key_row.update ();
- key_row.destroy_popover ();
- });
ulong delayed_modifications_changed_handler =
modifications_handler.delayed_changes_changed.connect (() => set_delayed_icon (key_row));
set_delayed_icon (key_row);
row.destroy.connect (() => {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]