[dconf-editor] Do not link modifications_handler from rows.
- From: Arnaud B. <arnaudb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dconf-editor] Do not link modifications_handler from rows.
- Date: Sat, 7 Jul 2018 10:44:54 +0000 (UTC)
commit 7f41c11240e11ff823e3d1a7a5d73d976be877ee
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date: Sat Jul 7 09:36:43 2018 +0200
Do not link modifications_handler from rows.
editor/key-list-box-row.vala | 89 +++++++++++++++++++++++++++-----------------
editor/registry-search.vala | 24 +++++-------
editor/registry-view.vala | 28 ++++++--------
3 files changed, 74 insertions(+), 67 deletions(-)
---
diff --git a/editor/key-list-box-row.vala b/editor/key-list-box-row.vala
index 6452eb8..4d4598c 100644
--- a/editor/key-list-box-row.vala
+++ b/editor/key-list-box-row.vala
@@ -106,7 +106,9 @@ private abstract class ClickableListBoxRow : EventBox
\*/
private ContextPopover? nullable_popover = null;
- protected virtual bool generate_popover (ContextPopover popover, Variant copy_text_variant) // use
Variant to sanitize text
+ protected virtual bool generate_popover (ContextPopover popover,
+ Variant copy_text_variant, // use Variant to sanitize text
+ ModificationsHandler modifications_handler)
{
return false; // no popover should be created
}
@@ -128,12 +130,14 @@ private abstract class ClickableListBoxRow : EventBox
return (nullable_popover != null) && (((!) nullable_popover).visible);
}
- public void show_right_click_popover (Variant copy_text_variant, int event_x = (int)
(get_allocated_width () / 2.0))
+ public void show_right_click_popover (Variant copy_text_variant,
+ ModificationsHandler modifications_handler,
+ int event_x = (int) (get_allocated_width () / 2.0))
{
if (nullable_popover == null)
{
nullable_popover = new ContextPopover ();
- if (!generate_popover ((!) nullable_popover, copy_text_variant))
+ if (!generate_popover ((!) nullable_popover, copy_text_variant, modifications_handler))
{
((!) nullable_popover).destroy (); // TODO better, again
nullable_popover = null;
@@ -169,7 +173,9 @@ private class FolderListBoxRow : ClickableListBoxRow
folder_name_label.set_text (search_result_mode ? path : label);
}
- protected override bool generate_popover (ContextPopover popover, Variant copy_text_variant) // TODO
better
+ protected override bool generate_popover (ContextPopover popover,
+ Variant copy_text_variant,
+ ModificationsHandler modifications_handler)
{
Variant variant = new Variant.string (full_name);
@@ -201,6 +207,32 @@ private abstract class KeyListBoxRow : ClickableListBoxRow
public string key_name { get; construct; }
public string type_string { get; construct; }
+ private bool _delay_mode = false;
+ public bool delay_mode
+ {
+ protected get
+ {
+ return _delay_mode;
+ }
+ set
+ {
+ _delay_mode = value;
+ if (boolean_switch != null)
+ {
+ if (value)
+ {
+ ((!) boolean_switch).hide ();
+ key_value_label.show ();
+ }
+ else
+ {
+ key_value_label.hide ();
+ ((!) boolean_switch).show ();
+ }
+ }
+ }
+ }
+
public bool small_keys_list_rows
{
set
@@ -218,8 +250,6 @@ private abstract class KeyListBoxRow : ClickableListBoxRow
}
}
- public ModificationsHandler modifications_handler { protected get; construct; }
-
construct
{
if (type_string == "b")
@@ -227,10 +257,10 @@ private abstract class KeyListBoxRow : ClickableListBoxRow
boolean_switch = new Switch ();
((!) boolean_switch).can_focus = false;
((!) boolean_switch).valign = Align.CENTER;
- if (!modifications_handler.get_current_delay_mode ())
+ if (!delay_mode)
{
- ((!) boolean_switch).show ();
key_value_label.hide ();
+ ((!) boolean_switch).show ();
}
key_name_and_value_grid.attach ((!) boolean_switch, 1, 0, 1, 2);
}
@@ -238,21 +268,6 @@ private abstract class KeyListBoxRow : ClickableListBoxRow
key_name_label.set_label (search_result_mode ? full_name : key_name);
}
- public void hide_or_show_toggles (bool show)
- requires (boolean_switch != null)
- {
- if (show)
- {
- key_value_label.hide ();
- ((!) boolean_switch).show ();
- }
- else
- {
- ((!) boolean_switch).hide ();
- key_value_label.show ();
- }
- }
-
public void toggle_boolean_key ()
{
if (boolean_switch == null)
@@ -323,20 +338,20 @@ private class KeyListBoxRowEditableNoSchema : KeyListBoxRow
public KeyListBoxRowEditableNoSchema (string _type_string,
DConfKey _key,
- ModificationsHandler modifications_handler,
+ bool _delay_mode,
string _key_name,
string _full_name,
- bool search_result_mode = false)
+ bool _search_result_mode = false)
{
Object (type_string: _type_string,
key: _key,
- modifications_handler: modifications_handler,
key_name: _key_name,
+ delay_mode: _delay_mode,
full_name: _full_name,
- search_result_mode: search_result_mode);
+ search_result_mode: _search_result_mode);
}
- public void update (Variant? key_value, bool delay_mode)
+ public void update (Variant? key_value)
{
StyleContext context = key_value_label.get_style_context ();
if (key_value == null)
@@ -370,7 +385,9 @@ private class KeyListBoxRowEditableNoSchema : KeyListBoxRow
}
}
- protected override bool generate_popover (ContextPopover popover, Variant copy_text_variant)
+ protected override bool generate_popover (ContextPopover popover,
+ Variant copy_text_variant,
+ ModificationsHandler modifications_handler)
{
SettingsModel model = modifications_handler.model;
Variant variant_s = new Variant.string (full_name);
@@ -475,21 +492,21 @@ private class KeyListBoxRowEditable : KeyListBoxRow
public KeyListBoxRowEditable (string _type_string,
GSettingsKey _key,
string _schema_id,
- ModificationsHandler modifications_handler,
+ bool _delay_mode,
string _key_name,
string _full_name,
- bool search_result_mode = false)
+ bool _search_result_mode = false)
{
Object (type_string: _type_string,
key: _key,
schema_id: _schema_id,
- modifications_handler: modifications_handler,
+ delay_mode: _delay_mode,
key_name: _key_name,
full_name: _full_name,
- search_result_mode: search_result_mode);
+ search_result_mode: _search_result_mode);
}
- public void update (Variant key_value, bool is_key_default, bool key_default_value_if_bool, bool
delay_mode)
+ public void update (Variant key_value, bool is_key_default, bool key_default_value_if_bool)
{
if (boolean_switch != null)
{
@@ -508,7 +525,9 @@ private class KeyListBoxRowEditable : KeyListBoxRow
key_value_label.set_label (Key.cool_text_value_from_variant (key_value, type_string));
}
- protected override bool generate_popover (ContextPopover popover, Variant copy_text_variant)
+ protected override bool generate_popover (ContextPopover popover,
+ Variant copy_text_variant,
+ ModificationsHandler modifications_handler)
{
SettingsModel model = modifications_handler.model;
Variant variant_s = new Variant.string (full_name);
diff --git a/editor/registry-search.vala b/editor/registry-search.vala
index b3320e6..010669d 100644
--- a/editor/registry-search.vala
+++ b/editor/registry-search.vala
@@ -75,42 +75,36 @@ class RegistrySearch : RegistryList
row = new KeyListBoxRowEditable ( key.type_string,
gkey,
gkey.schema_id,
- modifications_handler,
+ modifications_handler.get_current_delay_mode (),
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
- modifications_handler.get_current_delay_mode
());
+ 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
- modifications_handler.get_current_delay_mode ());
+ key_default_value_if_bool);
// TODO better 6/6
}
else
{
DConfKey dkey = (DConfKey) setting_object;
row = new KeyListBoxRowEditableNoSchema ( key.type_string,
dkey,
- modifications_handler,
+ modifications_handler.get_current_delay_mode (),
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,
-
modifications_handler.get_current_delay_mode ());
+ ((KeyListBoxRowEditableNoSchema) row).update (null);
else
- ((KeyListBoxRowEditableNoSchema) row).update (model.get_key_value (dkey),
-
modifications_handler.get_current_delay_mode ());
+ ((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,
-
modifications_handler.get_current_delay_mode ());
+ ((KeyListBoxRowEditableNoSchema) row).update (null);
else
- ((KeyListBoxRowEditableNoSchema) row).update (model.get_key_value (dkey),
-
modifications_handler.get_current_delay_mode ());
+ ((KeyListBoxRowEditableNoSchema) row).update (model.get_key_value (dkey));
}
KeyListBoxRow key_row = (KeyListBoxRow) row;
@@ -170,7 +164,7 @@ class RegistrySearch : RegistryList
event_x += widget_x;
}
- row.show_right_click_popover (get_copy_text_variant (row), event_x);
+ row.show_right_click_popover (get_copy_text_variant (row), modifications_handler, event_x);
rows_possibly_with_popover.append (row);
}
else
diff --git a/editor/registry-view.vala b/editor/registry-view.vala
index eff49e1..31a09ef 100644
--- a/editor/registry-view.vala
+++ b/editor/registry-view.vala
@@ -76,7 +76,7 @@ private abstract class RegistryList : Grid, BrowsableView
if (row == null)
assert_not_reached ();
if ((!) row is KeyListBoxRow && ((KeyListBoxRow) (!) row).type_string == "b")
- ((KeyListBoxRow) row).hide_or_show_toggles (show);
+ ((KeyListBoxRow) row).delay_mode = !show;
});
}
@@ -164,7 +164,7 @@ private abstract class RegistryList : Grid, BrowsableView
row.hide_right_click_popover ();
else
{
- row.show_right_click_popover (get_copy_text_variant (row));
+ row.show_right_click_popover (get_copy_text_variant (row), modifications_handler);
rows_possibly_with_popover.append (row);
}
return true;
@@ -339,42 +339,36 @@ class RegistryView : RegistryList
row = new KeyListBoxRowEditable ( key.type_string,
gkey,
gkey.schema_id,
- modifications_handler,
+ modifications_handler.get_current_delay_mode (),
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
- modifications_handler.get_current_delay_mode
());
+ 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
- modifications_handler.get_current_delay_mode ());
+ key_default_value_if_bool);
// TODO better 3/6
}
else
{
DConfKey dkey = (DConfKey) setting_object;
row = new KeyListBoxRowEditableNoSchema ( key.type_string,
dkey,
- modifications_handler,
+ modifications_handler.get_current_delay_mode (),
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,
-
modifications_handler.get_current_delay_mode ());
+ ((KeyListBoxRowEditableNoSchema) row).update (null);
else
- ((KeyListBoxRowEditableNoSchema) row).update (model.get_key_value (dkey),
-
modifications_handler.get_current_delay_mode ());
+ ((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,
-
modifications_handler.get_current_delay_mode ());
+ ((KeyListBoxRowEditableNoSchema) row).update (null);
else
- ((KeyListBoxRowEditableNoSchema) row).update (model.get_key_value (dkey),
-
modifications_handler.get_current_delay_mode ());
+ ((KeyListBoxRowEditableNoSchema) row).update (model.get_key_value (dkey));
}
KeyListBoxRow key_row = (KeyListBoxRow) row;
@@ -431,7 +425,7 @@ class RegistryView : RegistryList
event_x += widget_x;
}
- row.show_right_click_popover (get_copy_text_variant (row), event_x);
+ row.show_right_click_popover (get_copy_text_variant (row), modifications_handler, event_x);
rows_possibly_with_popover.append (row);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]