[dconf-editor] Use the "is" keyword.
- From: Arnaud Bonatti <arnaudb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dconf-editor] Use the "is" keyword.
- Date: Sun, 24 Jul 2016 01:26:37 +0000 (UTC)
commit f5656a16306017b3eb1945be30cbdfbfe07f91f6
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date: Sun Jul 24 03:26:14 2016 +0200
Use the "is" keyword.
editor/dconf-model.vala | 12 +-----------
editor/dconf-view.vala | 4 ++--
editor/key-list-box-row.vala | 4 ++--
editor/modifications-revealer.vala | 4 ++--
editor/registry-view.vala | 31 ++++++++++++++++---------------
5 files changed, 23 insertions(+), 32 deletions(-)
---
diff --git a/editor/dconf-model.vala b/editor/dconf-model.vala
index aaf3d95..db0b464 100644
--- a/editor/dconf-model.vala
+++ b/editor/dconf-model.vala
@@ -17,22 +17,18 @@
public abstract class SettingObject : Object
{
- public abstract bool is_view { get; }
-
public Directory? parent { get; construct; } // TODO make protected or even remove
public string name { get; construct; }
public string full_name { get; private set; }
construct
{
- full_name = parent == null ? "/" : ((!) parent).full_name + name + (is_view ? "/" : "");
+ full_name = parent == null ? "/" : ((!) parent).full_name + name + ((this is Directory) ? "/" : "");
}
}
public class Directory : SettingObject
{
- public override bool is_view { get { return true; } }
-
public int index { get { return parent.children.index (this); }} // TODO remove
public HashTable<string, Directory> child_map = new HashTable<string, Directory> (str_hash, str_equal);
@@ -173,8 +169,6 @@ public class Directory : SettingObject
public abstract class Key : SettingObject
{
- public override bool is_view { get { return false; } }
- public abstract bool has_schema { get; }
public abstract string descriptor { owned get; }
public string type_string { get; protected set; default = "*"; }
@@ -327,8 +321,6 @@ public abstract class Key : SettingObject
public class DConfKey : Key
{
- public override bool has_schema { get { return false; } }
-
public override string descriptor { owned get { return full_name; } }
private DConf.Client client;
@@ -398,8 +390,6 @@ public class DConfKey : Key
public class GSettingsKey : Key
{
- public override bool has_schema { get { return true; } }
-
public string schema_id { get; construct; }
public string summary { get; construct; }
public string description { private get; construct; }
diff --git a/editor/dconf-view.vala b/editor/dconf-view.vala
index a8c5030..e5873e0 100644
--- a/editor/dconf-view.vala
+++ b/editor/dconf-view.vala
@@ -220,7 +220,7 @@ private class KeyEditorChildNumberDouble : SpinButton, KeyEditorChild
this.halign = Align.START;
double min, max;
- if (key.has_schema && ((GSettingsKey) key).range_type == "range")
+ if (key is GSettingsKey && ((GSettingsKey) key).range_type == "range")
{
min = (((GSettingsKey) key).range_content.get_child_value (0)).get_double ();
max = (((GSettingsKey) key).range_content.get_child_value (1)).get_double ();
@@ -272,7 +272,7 @@ private class KeyEditorChildNumberInt : SpinButton, KeyEditorChild
this.halign = Align.START;
double min, max;
- if (key.has_schema && ((GSettingsKey) key).range_type == "range")
+ if (key is GSettingsKey && ((GSettingsKey) key).range_type == "range")
{
min = get_variant_as_double (((GSettingsKey) key).range_content.get_child_value (0));
max = get_variant_as_double (((GSettingsKey) key).range_content.get_child_value (1));
diff --git a/editor/key-list-box-row.vala b/editor/key-list-box-row.vala
index 7d1fdd7..a1ae346 100644
--- a/editor/key-list-box-row.vala
+++ b/editor/key-list-box-row.vala
@@ -498,7 +498,7 @@ private class ContextPopover : Popover
else if (key.planned_change)
value_variant = key.planned_value;
else
- value_variant = key.has_schema && ((GSettingsKey) key).is_default ? null : key.value;
+ value_variant = key is GSettingsKey && ((GSettingsKey) key).is_default ? null : key.value;
Variant variant = new Variant.maybe (original_type, value_variant);
Variant nullable_variant = new Variant.maybe (nullable_type, delayed_apply_menu &&
!key.planned_change ? null : variant);
@@ -513,7 +513,7 @@ private class ContextPopover : Popover
/* Translators: "no change" option in the right-click menu on a key when on delayed mode */
current_section.append (_("No change"), @"$group_dot_action(@mm$type_string nothing)");
- if (key.has_schema)
+ if (key is GSettingsKey)
new_multi_default_action (@"$group_dot_action(@mm$type_string just nothing)");
else if (complete_menu)
/* Translators: "erase key" option in the right-click menu on a key without schema when on
delayed mode */
diff --git a/editor/modifications-revealer.vala b/editor/modifications-revealer.vala
index a566921..7516af3 100644
--- a/editor/modifications-revealer.vala
+++ b/editor/modifications-revealer.vala
@@ -96,7 +96,7 @@ class ModificationsRevealer : Revealer
key.planned_change = true;
key.planned_value = new_value;
- if (key.has_schema)
+ if (key is GSettingsKey)
gsettings_keys_awaiting_hashtable.insert (key.descriptor, (GSettingsKey) key);
else
dconf_keys_awaiting_hashtable.insert (key.descriptor, (DConfKey) key);
@@ -118,7 +118,7 @@ class ModificationsRevealer : Revealer
key.planned_change = false;
key.planned_value = null;
- if (key.has_schema)
+ if (key is GSettingsKey)
gsettings_keys_awaiting_hashtable.remove (key.descriptor);
else
dconf_keys_awaiting_hashtable.remove (key.descriptor);
diff --git a/editor/registry-view.vala b/editor/registry-view.vala
index 8123cff..0c16667 100644
--- a/editor/registry-view.vala
+++ b/editor/registry-view.vala
@@ -180,7 +180,7 @@ class RegistryView : Grid
while (position < key_model.get_n_items ())
{
SettingObject object = (SettingObject) key_model.get_object (position);
- if (!object.is_view && object.name == key_name)
+ if (object is Key && object.name == key_name)
return (Key) object;
position++;
}
@@ -206,22 +206,23 @@ class RegistryView : Grid
{
ClickableListBoxRow row;
ulong on_row_clicked_handler;
- if (((SettingObject) item).is_view)
+ if (item is Directory)
{
- row = new FolderListBoxRow (((SettingObject) item).name, ((SettingObject) item).full_name);
+ SettingObject setting_object = (SettingObject) item;
+ row = new FolderListBoxRow (setting_object.name, setting_object.full_name);
on_row_clicked_handler = row.on_row_clicked.connect (() => {
- if (!scroll_to_path (((SettingObject) item).full_name))
+ if (!scroll_to_path (setting_object.full_name))
warning ("Something got wrong with this folder.");
});
}
else
{
- Key key = (Key) item;
- if (key.has_schema)
- row = new KeyListBoxRowEditable ((GSettingsKey) key);
+ if (item is GSettingsKey)
+ row = new KeyListBoxRowEditable ((GSettingsKey) item);
else
- row = new KeyListBoxRowEditableNoSchema ((DConfKey) key);
+ row = new KeyListBoxRowEditableNoSchema ((DConfKey) item);
+ Key key = (Key) item;
KeyListBoxRow key_row = ((KeyListBoxRow) row);
ulong set_key_value_handler = key_row.set_key_value.connect ((variant) => { set_key_value (key,
variant); set_delayed_icon (row, key); });
ulong change_dismissed_handler = key_row.change_dismissed.connect (() => {
revealer.dismiss_change (key); });
@@ -260,7 +261,7 @@ class RegistryView : Grid
{
StyleContext context = row.get_style_context ();
context.add_class ("delayed");
- if (!key.has_schema)
+ if (key is DConfKey)
{
if (key.planned_value == null)
context.add_class ("erase");
@@ -331,7 +332,7 @@ class RegistryView : Grid
revealer.add_delayed_setting (key, new_value);
else if (new_value != null)
key.value = (!) new_value;
- else if (key.has_schema)
+ else if (key is GSettingsKey)
((GSettingsKey) key).set_to_default ();
else if (behaviour != Behaviour.UNSAFE)
{
@@ -365,13 +366,13 @@ class RegistryView : Grid
return;
SettingObject setting_object = (SettingObject) ((!) object);
- if (setting_object.is_view)
+ if (setting_object is Directory)
{
if (recursively)
reset_generic (((Directory) setting_object).key_model, true);
continue;
}
- if (!((Key) setting_object).has_schema)
+ if (setting_object is DConfKey)
{
if (!((DConfKey) setting_object).is_ghost)
revealer.add_delayed_setting ((Key) setting_object, null);
@@ -484,10 +485,10 @@ class RegistryView : Grid
enable_transition (true);
return;
}
- else if (!object.is_view)
+ else if (object is Key)
{
Key key = (Key) object;
- if ((key.has_schema || !((DConfKey) key).is_ghost) && key_matches (key,
search_entry.text) && properties_view.populate_properties_list_box (revealer, key))
+ if ((key is GSettingsKey || !((DConfKey) key).is_ghost) && key_matches (key,
search_entry.text) && properties_view.populate_properties_list_box (revealer, key))
{
dir_tree_selection.select_iter (iter);
update_current_path (object.full_name);
@@ -512,7 +513,7 @@ class RegistryView : Grid
private bool key_matches (Key key, string text)
{
/* Check in key's metadata */
- if (key.has_schema && ((GSettingsKey) key).search_for (text))
+ if (key is GSettingsKey && ((GSettingsKey) key).search_for (text))
return true;
/* Check key value */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]