[dconf] Drop libgee requirement for dconf-editor



commit 2b5ac96181cf634ad80d599e0c531adc3f48bead
Author: Robert Ancell <robert ancell canonical com>
Date:   Fri Sep 3 15:59:16 2010 +1000

    Drop libgee requirement for dconf-editor

 configure.ac             |    1 -
 editor/Makefile.am       |    4 +-
 editor/dconf-model.vala  |   94 ++++++++++++++++++++++++----------------------
 editor/dconf-schema.vala |   30 +++++++--------
 editor/dconf-view.vala   |    2 +-
 5 files changed, 66 insertions(+), 65 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index a8fb05b..12b00a4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -30,7 +30,6 @@ AM_CONDITIONAL(ENABLE_EDITOR, test "x$enable_editor" != "xno")
 
 if test "x$enable_editor" != "xno"; then
   PKG_CHECK_MODULES(gtk, gtk+-2.0)
-  PKG_CHECK_MODULES(gee, gee-1.0)
   PKG_CHECK_MODULES(libxml, libxml-2.0)
 fi
 
diff --git a/editor/Makefile.am b/editor/Makefile.am
index 3a0e744..cb65004 100644
--- a/editor/Makefile.am
+++ b/editor/Makefile.am
@@ -1,6 +1,6 @@
 bin_PROGRAMS = dconf-editor
 
-AM_CFLAGS = $(gtk_CFLAGS) $(gee_CFLAGS) $(libxml_CFLAGS) -I$(top_srcdir)/common -I$(top_srcdir)/client
-AM_VALAFLAGS = --vapidir ../client --pkg gee-1.0 --pkg gtk+-2.0 --pkg libxml-2.0 --pkg dconf
+AM_CFLAGS = $(gtk_CFLAGS) $(libxml_CFLAGS) -I$(top_srcdir)/common -I$(top_srcdir)/client
+AM_VALAFLAGS = --vapidir ../client --pkg gtk+-2.0 --pkg libxml-2.0 --pkg dconf
 dconf_editor_LDADD = ../client/libdconf.so.0 $(gtk_LIBS) $(gee_LIBS) $(libxml_LIBS)
 dconf_editor_SOURCES = dconf-editor.vala dconf-model.vala dconf-schema.vala dconf-view.vala
diff --git a/editor/dconf-model.vala b/editor/dconf-model.vala
index 4762720..d6ec9fe 100644
--- a/editor/dconf-model.vala
+++ b/editor/dconf-model.vala
@@ -1,5 +1,3 @@
-using Gee;
-
 public class Key : GLib.Object
 {
     private SettingsModel model;
@@ -72,7 +70,7 @@ public class Key : GLib.Object
         this.index = index;
         this.name = name;
         this.full_name = full_name;
-        this.schema = model.schemas.keys.get(full_name);
+        this.schema = model.schemas.keys.lookup(full_name);
     }
 
     private void update_value()
@@ -98,17 +96,17 @@ public class Directory : GLib.Object
         private set {}
     }
 
-    public HashMap<string, Directory> _child_map = new HashMap<string, Directory>();
-    public ArrayList<Directory> _children = new ArrayList<Directory>();
-    public ArrayList<Directory> children
+    public GLib.HashTable<string, Directory> _child_map = new GLib.HashTable<string, Directory>(str_hash, str_equal);
+    public GLib.List<Directory> _children = new GLib.List<Directory>();
+    public GLib.List<Directory> children
     {
         get { update_children(); return _children; }
         private set { }
     }
 
-    public HashMap<string, Key> _key_map = new HashMap<string, Key>();
-    private ArrayList<Key> _keys = new ArrayList<Key>();
-    public ArrayList<Key> keys
+    public GLib.HashTable<string, Key> _key_map = new GLib.HashTable<string, Key>(str_hash, str_equal);
+    private GLib.List<Key> _keys = new GLib.List<Key>();
+    public GLib.List<Key> keys
     {
         get { update_children(); return _keys; }
         private set { }
@@ -127,23 +125,29 @@ public class Directory : GLib.Object
     
     public Directory get_child(string name)
     {
-        if (_child_map.has_key(name))
-            return _child_map[name];
+        Directory? directory = _child_map.lookup(name);
+
+        if (directory == null)
+        {
+            directory = new Directory(model, this, (int)_children.length(), name, full_name + name + "/");
+            _children.append(directory);
+            _child_map.insert(name, directory);
+        }
 
-        Directory directory = new Directory(model, this, _children.size, name, full_name + name + "/");
-        _children.add(directory);
-        _child_map.set(name, directory);
         return directory;
     }
 
     public Key get_key(string name)
     {
-        if (_key_map.has_key(name))
-            return _key_map[name];
+        Key? key = _key_map.lookup(name);
+
+        if (key == null)
+        {
+            key = new Key(model, this, (int)_keys.length(), name, full_name + name);
+            _keys.append(key);
+            _key_map.insert(name, key);
+        }
 
-        Key key = new Key(model, this, _keys.size, name, full_name + name);
-        _keys.add(key);
-        _key_map.set(name, key);
         return key;
     }
 
@@ -151,7 +155,7 @@ public class Directory : GLib.Object
     {
         if (path == "")
         {
-            foreach (var schema_key in schema.keys.values)
+            foreach (var schema_key in schema.keys.get_values())
                 get_key(schema_key.name);
         }
         else
@@ -272,17 +276,17 @@ public class KeyModel: GLib.Object, Gtk.TreeModel/*, Gtk.TreeSortable*/
     public bool iter_next(ref Gtk.TreeIter iter)
     {
         int index = get_key(iter).index;
-        if (index >= directory.keys.size - 1)
+        if (index >= directory.keys.length() - 1)
             return false;
-        set_iter(out iter, directory.keys[index+1]);
+        set_iter(out iter, directory.keys.nth_data(index+1));
         return true;
     }
 
     public bool iter_children(out Gtk.TreeIter iter, Gtk.TreeIter? parent)
     {
-        if (parent != null || directory.keys.size == 0)
+        if (parent != null || directory.keys.length() == 0)
             return false;
-        set_iter(out iter, directory.keys[0]);
+        set_iter(out iter, directory.keys.nth_data(0));
         return true;
     }
 
@@ -294,7 +298,7 @@ public class KeyModel: GLib.Object, Gtk.TreeModel/*, Gtk.TreeSortable*/
     public int iter_n_children(Gtk.TreeIter? iter)
     {
         if (iter == null)
-            return directory.keys.size;
+            return (int)directory.keys.length();
         else
             return 0;
     }
@@ -304,9 +308,9 @@ public class KeyModel: GLib.Object, Gtk.TreeModel/*, Gtk.TreeSortable*/
         if (parent != null)
             return false;
 
-        if (n >= directory.keys.size)
+        if (n >= directory.keys.length())
             return false;
-        set_iter(out iter, directory.keys[n]);
+        set_iter(out iter, directory.keys.nth_data(n));
         return true;
     }
 
@@ -379,7 +383,7 @@ public class EnumModel: GLib.Object, Gtk.TreeModel
     public Gtk.TreePath get_path(Gtk.TreeIter iter)
     {
         Gtk.TreePath path = new Gtk.TreePath();
-        path.append_index(get_enum_value(iter).index);
+        path.append_index((int)get_enum_value(iter).index);
         return path;
     }
 
@@ -393,18 +397,18 @@ public class EnumModel: GLib.Object, Gtk.TreeModel
 
     public bool iter_next(ref Gtk.TreeIter iter)
     {
-        int index = get_enum_value(iter).index;
-        if (index >= schema_enum.values.size - 1)
+        uint index = get_enum_value(iter).index;
+        if (index >= schema_enum.values.length () - 1)
             return false;
-        set_iter(out iter, schema_enum.values[index + 1]);
+        set_iter(out iter, schema_enum.values.nth_data(index + 1));
         return true;
     }
 
     public bool iter_children(out Gtk.TreeIter iter, Gtk.TreeIter? parent)
     {
-        if (parent != null || schema_enum.values.size == 0)
+        if (parent != null || schema_enum.values.length() == 0)
             return false;
-        set_iter(out iter, schema_enum.values[0]);
+        set_iter(out iter, schema_enum.values.nth_data(0));
         return true;
     }
 
@@ -416,7 +420,7 @@ public class EnumModel: GLib.Object, Gtk.TreeModel
     public int iter_n_children(Gtk.TreeIter? iter)
     {
         if (iter == null)
-            return schema_enum.values.size;
+            return (int) schema_enum.values.length();
         else
             return 0;
     }
@@ -426,9 +430,9 @@ public class EnumModel: GLib.Object, Gtk.TreeModel
         if (parent != null)
             return false;
 
-        if (n >= schema_enum.values.size)
+        if (n >= schema_enum.values.length())
             return false;
-        set_iter(out iter, schema_enum.values[n]);
+        set_iter(out iter, schema_enum.values.nth_data(n));
         return true;
     }
 
@@ -527,7 +531,7 @@ public class SettingsModel: GLib.Object, Gtk.TreeModel
     public Gtk.TreePath get_path(Gtk.TreeIter iter)
     {
         Gtk.TreePath path = new Gtk.TreePath();
-        path.append_index(get_directory(iter).index);
+        path.append_index((int)get_directory(iter).index);
         return path;
     }
 
@@ -542,37 +546,37 @@ public class SettingsModel: GLib.Object, Gtk.TreeModel
     public bool iter_next(ref Gtk.TreeIter iter)
     {
         Directory directory = get_directory(iter);
-        if (directory.index >= directory.parent.children.size - 1)
+        if (directory.index >= directory.parent.children.length() - 1)
             return false;
-        set_iter(out iter, directory.parent.children[directory.index+1]);
+        set_iter(out iter, directory.parent.children.nth_data(directory.index+1));
         return true;
     }
 
     public bool iter_children(out Gtk.TreeIter iter, Gtk.TreeIter? parent)
     {
         Directory directory = get_directory(parent);
-        if (directory.children.size == 0)
+        if (directory.children.length() == 0)
             return false;
-        set_iter(out iter, directory.children[0]);
+        set_iter(out iter, directory.children.nth_data(0));
         return true;
     }
 
     public bool iter_has_child(Gtk.TreeIter iter)
     {
-        return get_directory(iter).children.size > 0;
+        return get_directory(iter).children.length() > 0;
     }
 
     public int iter_n_children(Gtk.TreeIter? iter)
     {
-        return get_directory(iter).children.size;
+        return (int) get_directory(iter).children.length();
     }
 
     public bool iter_nth_child(out Gtk.TreeIter iter, Gtk.TreeIter? parent, int n)
     {
         Directory directory = get_directory(parent);
-        if (n >= directory.children.size)
+        if (n >= directory.children.length())
             return false;       
-        set_iter(out iter, directory.children[n]);
+        set_iter(out iter, directory.children.nth_data(n));
         return true;
     }
 
diff --git a/editor/dconf-schema.vala b/editor/dconf-schema.vala
index 5e2c7bf..c60e8da 100644
--- a/editor/dconf-schema.vala
+++ b/editor/dconf-schema.vala
@@ -1,5 +1,3 @@
-using Gee;
-
 public class SchemaKey
 {
     public Schema schema;
@@ -63,11 +61,11 @@ public class SchemaKey
 public class SchemaEnumValue : GLib.Object
 {
     public SchemaEnum schema_enum;
-    public int index;
+    public uint index;
     public string nick;
     public int value;
 
-    public SchemaEnumValue(SchemaEnum schema_enum, int index, string nick, int value)
+    public SchemaEnumValue(SchemaEnum schema_enum, uint index, string nick, int value)
     {
         this.schema_enum = schema_enum;
         this.index = index;
@@ -80,7 +78,7 @@ public class SchemaEnum
 {
     public SchemaList list;
     public string id;
-    public ArrayList<SchemaEnumValue> values = new ArrayList<SchemaEnumValue>();
+    public GLib.List<SchemaEnumValue> values = new GLib.List<SchemaEnumValue>();
 
     public SchemaEnum(SchemaList list, Xml.Node* node)
     {
@@ -117,8 +115,8 @@ public class SchemaEnum
                 //if (value < 0 || nick == null)
                 //    ?
 
-                SchemaEnumValue schema_value = new SchemaEnumValue(this, values.size, nick, value);
-                values.add(schema_value);
+                SchemaEnumValue schema_value = new SchemaEnumValue(this, values.length(), nick, value);
+                values.append(schema_value);
             }
             //else
             //   ?
@@ -134,7 +132,7 @@ public class Schema
     public SchemaList list;
     public string id;
     public string? path;
-    public HashMap<string, SchemaKey> keys = new HashMap<string, SchemaKey>();
+    public GLib.HashTable<string, SchemaKey> keys = new GLib.HashTable<string, SchemaKey>(str_hash, str_equal);
 
     public Schema(SchemaList list, Xml.Node* node, string? gettext_domain)
     {
@@ -160,16 +158,16 @@ public class Schema
             if (child->name != "key")
                continue;
             SchemaKey key = new SchemaKey(child, this, gettext_domain);
-            keys.set(key.name, key);
+            keys.insert(key.name, key);
         }
     }
 }
 
 public class SchemaList
 {
-    public ArrayList<Schema> schemas = new ArrayList<Schema>();
-    public HashMap<string, SchemaKey> keys = new HashMap<string, SchemaKey>();
-    public HashMap<string, SchemaEnum> enums = new HashMap<string, SchemaEnum>();
+    public GLib.List<Schema> schemas = new GLib.List<Schema>();
+    public GLib.HashTable<string, SchemaKey> keys = new GLib.HashTable<string, SchemaKey>(str_hash, str_equal);
+    public GLib.HashTable<string, SchemaEnum> enums = new GLib.HashTable<string, SchemaEnum>(str_hash, str_equal);
 
     public void parse_file(string path)
     {
@@ -195,23 +193,23 @@ public class SchemaList
             if (node->name == "schema")
             {
                 Schema schema = new Schema(this, node, gettext_domain);
-                schemas.add(schema);
+                schemas.append(schema);
                 if (schema.path == null)
                 {
                     // FIXME: What to do here?
                     continue;
                 }
 
-                foreach (var key in schema.keys.values)
+                foreach (var key in schema.keys.get_values())
                 {
                     string full_name = schema.path + key.name;
-                    keys.set(full_name, key);
+                    keys.insert(full_name, key);
                 }
             }
             else if (node->name == "enum")
             {
                 SchemaEnum enum = new SchemaEnum(this, node);
-                enums.set(enum.id, enum);
+                enums.insert(enum.id, enum);
             }
             //else
             //    ?
diff --git a/editor/dconf-view.vala b/editor/dconf-view.vala
index 1d6e388..fc6a1ef 100644
--- a/editor/dconf-view.vala
+++ b/editor/dconf-view.vala
@@ -20,7 +20,7 @@ private class KeyValueRenderer: Gtk.CellRenderer
             else if (key.type_string == "<enum>")
             {
                 combo_renderer.text = key.value.get_string();
-                combo_renderer.model = new EnumModel(key.schema.schema.list.enums[key.schema.enum_name]);
+                combo_renderer.model = new EnumModel(key.schema.schema.list.enums.lookup(key.schema.enum_name));
                 mode = Gtk.CellRendererMode.EDITABLE;
             }
             else if (key.type_string == "b")



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]