[dconf-editor] Random formating fixes.
- From: Arnaud Bonatti <arnaudb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dconf-editor] Random formating fixes.
- Date: Mon, 21 Sep 2015 10:12:13 +0000 (UTC)
commit 16919482ff443cb3144106a8e981bc73e5a2a14b
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date: Sat Sep 19 21:33:46 2015 +0200
Random formating fixes.
editor/dconf-editor.vala | 2 +-
editor/dconf-model.vala | 60 ++++++++++++++++-----------------------------
editor/dconf-window.vala | 30 ++++++++++-------------
3 files changed, 35 insertions(+), 57 deletions(-)
---
diff --git a/editor/dconf-editor.vala b/editor/dconf-editor.vala
index 2254d98..27d3d03 100644
--- a/editor/dconf-editor.vala
+++ b/editor/dconf-editor.vala
@@ -56,7 +56,7 @@ class ConfigurationEditor : Gtk.Application
Intl.bind_textdomain_codeset (Config.GETTEXT_PACKAGE, "UTF-8");
Intl.textdomain (Config.GETTEXT_PACKAGE);
- var app = new ConfigurationEditor ();
+ ConfigurationEditor app = new ConfigurationEditor ();
return app.run (args);
}
diff --git a/editor/dconf-model.vala b/editor/dconf-model.vala
index 2cf3539..91f375b 100644
--- a/editor/dconf-model.vala
+++ b/editor/dconf-model.vala
@@ -54,16 +54,13 @@ public class Key : GLib.Object
}
}
- private Variant? _value;
+ private Variant? _value = null;
public Variant value
{
get
{
update_value();
- if (_value != null)
- return _value;
- else
- return schema.default_value;
+ return _value ?? schema.default_value;
}
set
{
@@ -172,7 +169,9 @@ public class Directory : GLib.Object
get {
update_children ();
if (_key_model == null)
+ {
_key_model = new KeyModel (this);
+ }
return _key_model;
}
private set {}
@@ -199,7 +198,7 @@ public class Directory : GLib.Object
private set { }
}
- private bool have_children;
+ private bool have_children = false;
public Directory(SettingsModel model, Directory? parent, string name, string full_name)
{
@@ -209,44 +208,34 @@ public class Directory : GLib.Object
this.full_name = full_name;
}
- public Directory get_child(string name)
+ public Directory get_child (string name)
{
- Directory? directory = _child_map.lookup(name);
+ Directory? directory = _child_map.lookup (name);
if (directory == null)
{
- directory = new Directory(model, this, name, full_name + name + "/");
- _children.insert_sorted(directory, compare_directories);
- _child_map.insert(name, directory);
+ directory = new Directory (model, this, name, full_name + name + "/");
+ _children.insert_sorted (directory, (a, b) => { return strcmp (((Directory) a).name,
((Directory) b).name); });
+ _child_map.insert (name, directory);
}
return directory;
}
- private static int compare_directories(Directory a, Directory b)
- {
- return strcmp(a.name, b.name);
- }
-
- public Key get_key(string name)
+ public Key get_key (string name)
{
- Key? key = _key_map.lookup(name);
+ Key? key = _key_map.lookup (name);
if (key == null)
{
- key = new Key(model, this, name, full_name + name);
- _keys.insert_sorted(key, compare_keys);
- _key_map.insert(name, key);
+ key = new Key (model, this, name, full_name + name);
+ _keys.insert_sorted (key, (a, b) => { return strcmp (((Key) a).name, ((Key) b).name); });
+ _key_map.insert (name, key);
}
return key;
}
- public static int compare_keys(Key a, Key b)
- {
- return strcmp(a.name, b.name);
- }
-
public void load_schema(Schema schema, string path)
{
if (path == "")
@@ -583,9 +572,8 @@ public class SettingsModel: GLib.Object, Gtk.TreeModel
public signal void item_changed (string key);
void watch_func (DConf.Client client, string path, string[] items, string? tag) {
- foreach (var item in items) {
+ foreach (var item in items)
item_changed (path + item);
- }
}
public SettingsModel()
@@ -632,15 +620,12 @@ public class SettingsModel: GLib.Object, Gtk.TreeModel
return 2;
}
- public Type get_column_type(int index)
+ public Type get_column_type (int index)
{
- if (index == 0)
- return typeof(Directory);
- else
- return typeof(string);
+ return index == 0 ? typeof (Directory) : typeof (string);
}
- private void set_iter(ref Gtk.TreeIter iter, Directory directory)
+ private void set_iter (ref Gtk.TreeIter iter, Directory directory)
{
iter.stamp = 0;
iter.user_data = directory;
@@ -648,12 +633,9 @@ public class SettingsModel: GLib.Object, Gtk.TreeModel
iter.user_data3 = directory;
}
- public Directory get_directory(Gtk.TreeIter? iter)
+ public Directory get_directory (Gtk.TreeIter? iter)
{
- if (iter == null)
- return root;
- else
- return (Directory)iter.user_data;
+ return iter == null ? root : (Directory) iter.user_data;
}
public bool get_iter(out Gtk.TreeIter iter, Gtk.TreePath path)
diff --git a/editor/dconf-window.vala b/editor/dconf-window.vala
index 1e4eba4..1f4990c 100644
--- a/editor/dconf-window.vala
+++ b/editor/dconf-window.vala
@@ -22,10 +22,12 @@ using Gtk;
class DConfWindow : ApplicationWindow
{
private SettingsModel model;
- [GtkChild]
- private TreeView dir_tree_view;
- [GtkChild]
- private TreeSelection dir_tree_selection;
+ [GtkChild] private TreeView dir_tree_view;
+ [GtkChild] private TreeSelection dir_tree_selection;
+
+ [GtkChild] private Box search_box;
+ [GtkChild] private Entry search_entry;
+ [GtkChild] private Label search_label;
private TreeView key_tree_view;
[GtkChild]
@@ -44,13 +46,6 @@ class DConfWindow : ApplicationWindow
[GtkChild]
private Label default_label;
- [GtkChild]
- private Box search_box;
- [GtkChild]
- private Entry search_entry;
- [GtkChild]
- private Label search_label;
-
private Key? selected_key;
private const GLib.ActionEntry[] window_actions =
@@ -253,12 +248,12 @@ class DConfWindow : ApplicationWindow
[GtkCallback]
private void find_next_cb ()
{
- search_label.set_text ("");
+ search_label.label = "";
/* Get the current position in the tree */
TreeIter iter;
TreeIter key_iter = TreeIter ();
- var have_key_iter = false;
+ bool have_key_iter = false;
if (dir_tree_selection.get_selected (null, out iter))
{
if (key_tree_view.get_selection ().get_selected (null, out key_iter))
@@ -273,11 +268,11 @@ class DConfWindow : ApplicationWindow
else if (!model.get_iter_first (out iter))
return;
- var on_first_directory = true;
+ bool on_first_directory = true;
do
{
/* Select next directory that matches */
- var dir = model.get_directory (iter);
+ Directory dir = model.get_directory (iter);
if (!have_key_iter)
{
have_key_iter = dir.key_model.get_iter_first (out key_iter);
@@ -309,9 +304,10 @@ class DConfWindow : ApplicationWindow
} while (dir.key_model.iter_next (ref key_iter));
}
have_key_iter = false;
- } while (get_next_iter (ref iter));
+ }
+ while (get_next_iter (ref iter));
- search_label.set_text(_("Not found"));
+ search_label.label = _("Not found");
}
private bool key_matches (Key key, string text)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]