diff options
author | Eitan Isaacson <eitan@monotonous.org> | 2011-06-02 11:08:49 -0700 |
---|---|---|
committer | Eitan Isaacson <eitan@monotonous.org> | 2011-06-02 11:08:49 -0700 |
commit | 843bb24cc3383ff11d76f81f956ef2cfe7ce13cb (patch) | |
tree | e6a939b465b9a12f70212cbc396d33dc289e0eb6 /libcaribou | |
parent | 33f0c869983b390ae4ba53c60f6cb17389c6739d (diff) | |
download | caribou-843bb24cc3383ff11d76f81f956ef2cfe7ce13cb.tar.gz |
Revert "libcaribou: Use GLib.List instead of arrays"
gjs learned to cope with arrays. Let's not introduce GLists, Vala hates them.
This reverts commit 33f0c869983b390ae4ba53c60f6cb17389c6739d.
Diffstat (limited to 'libcaribou')
-rw-r--r-- | libcaribou/column-model.vala | 4 | ||||
-rw-r--r-- | libcaribou/group-model.vala | 10 | ||||
-rw-r--r-- | libcaribou/ikeyboard-object.vala | 30 | ||||
-rw-r--r-- | libcaribou/key-model.vala | 20 | ||||
-rw-r--r-- | libcaribou/keyboard-model.vala | 12 | ||||
-rw-r--r-- | libcaribou/level-model.vala | 9 | ||||
-rw-r--r-- | libcaribou/row-model.vala | 8 |
7 files changed, 38 insertions, 55 deletions
diff --git a/libcaribou/column-model.vala b/libcaribou/column-model.vala index b1d2b57..b1db3cb 100644 --- a/libcaribou/column-model.vala +++ b/libcaribou/column-model.vala @@ -26,8 +26,8 @@ namespace Caribou { return (IScannableItem[]) keys.to_array (); } - public List<IKeyboardObject> get_children () { - return (List<IKeyboardObject>) collection_to_object_list (keys); + public IKeyboardObject[] get_children () { + return (IKeyboardObject[]) keys.to_array (); } } } diff --git a/libcaribou/group-model.vala b/libcaribou/group-model.vala index 5c20fd4..6b578d4 100644 --- a/libcaribou/group-model.vala +++ b/libcaribou/group-model.vala @@ -33,8 +33,8 @@ namespace Caribou { } } - public List<string> get_levels () { - return (List<string>) collection_to_string_list (levels.keys); + public string[] get_levels () { + return (string[]) levels.keys.to_array (); } public LevelModel get_level (string level_name) { @@ -48,9 +48,9 @@ namespace Caribou { active_level = new_level; } - public List<IKeyboardObject> get_children () { - return (List<IKeyboardObject>) - collection_to_object_list (levels.values); + public IKeyboardObject[] get_children () { + return (IKeyboardObject[]) levels.values.to_array (); } + } }
\ No newline at end of file diff --git a/libcaribou/ikeyboard-object.vala b/libcaribou/ikeyboard-object.vala index a76b604..f227492 100644 --- a/libcaribou/ikeyboard-object.vala +++ b/libcaribou/ikeyboard-object.vala @@ -1,32 +1,18 @@ namespace Caribou { public interface IKeyboardObject : Object { - public abstract List<IKeyboardObject> get_children (); + public abstract IKeyboardObject[] get_children (); public signal void key_activated (KeyModel key); - public virtual List<KeyModel> get_keys () { - var keys = new List<KeyModel> (); + public virtual KeyModel[] get_keys () { + Gee.ArrayList<KeyModel> keys = new Gee.ArrayList<KeyModel> (); foreach (IKeyboardObject obj in get_children ()) { - List<weak KeyModel> child_keys = obj.get_keys(); - keys.concat (child_keys.copy()); + KeyModel[] obj_keys = obj.get_keys(); + foreach (KeyModel key in obj_keys) { + keys.add(key); + } } - return keys; - } - - internal static List<Object> collection_to_object_list (Gee.Collection<Object> c) { - var l = new List<Object> (); - foreach (Object item in c) { - l.append (item); - } - return l; - } - - internal static List<string> collection_to_string_list (Gee.Collection<string> c) { - List<string> l = new List<string> (); - foreach (string item in c) { - l.append (item); - } - return l; + return (KeyModel[]) keys.to_array (); } } }
\ No newline at end of file diff --git a/libcaribou/key-model.vala b/libcaribou/key-model.vala index bae89bc..32ed771 100644 --- a/libcaribou/key-model.vala +++ b/libcaribou/key-model.vala @@ -79,21 +79,19 @@ namespace Caribou { return false; } - public List<KeyModel> get_extended_keys () { - return (List<KeyModel>) collection_to_object_list(extended_keys); + public KeyModel[] get_extended_keys () { + return (KeyModel[]) extended_keys.to_array (); } - public List<KeyModel> get_keys () { - List<KeyModel> all_keys = new List<KeyModel> (); - all_keys.append (this); - var ekeys = (List<weak KeyModel>) get_extended_keys (); - all_keys.concat (ekeys.copy()); - return all_keys; + public KeyModel[] get_keys () { + Gee.ArrayList<KeyModel> all_keys = new Gee.ArrayList<KeyModel> (); + all_keys.add (this); + all_keys.add_all (extended_keys); + return (KeyModel[]) all_keys.to_array (); } - public List<IKeyboardObject> get_children () { - return (List<IKeyboardObject>) - collection_to_object_list (extended_keys); + public IKeyboardObject[] get_children () { + return (IKeyboardObject[]) extended_keys.to_array (); } public void activate () { diff --git a/libcaribou/keyboard-model.vala b/libcaribou/keyboard-model.vala index 2d1ac7c..e34a3a3 100644 --- a/libcaribou/keyboard-model.vala +++ b/libcaribou/keyboard-model.vala @@ -49,8 +49,8 @@ namespace Caribou { key_activated (key); } - public List<string> get_groups () { - return (List<string>) collection_to_string_list (groups.keys); + public string[] get_groups () { + return (string[]) groups.keys.to_array (); } public GroupModel get_group (string group_name) { @@ -62,14 +62,12 @@ namespace Caribou { if (groups.get (group_name) != null) { active_group = group_name; } else { - string[] keys = (string[]) groups.keys.to_array(); - active_group = keys[0]; + active_group = get_groups ()[0]; } } - public List<IKeyboardObject> get_children () { - return (List<IKeyboardObject>) - collection_to_object_list (groups.values); + public IKeyboardObject[] get_children () { + return (IKeyboardObject[]) groups.values.to_array (); } } }
\ No newline at end of file diff --git a/libcaribou/level-model.vala b/libcaribou/level-model.vala index 6c041d8..0d209d3 100644 --- a/libcaribou/level-model.vala +++ b/libcaribou/level-model.vala @@ -30,8 +30,8 @@ namespace Caribou { row.add_key (colnum, key); } - public List<RowModel> get_rows () { - return (List<RowModel>) get_children (); + public RowModel[] get_rows () { + return (RowModel[]) rows.to_array (); } private void on_key_activated (KeyModel key) { @@ -49,8 +49,9 @@ namespace Caribou { return (IScannableItem[]) rows.to_array (); } - public List<IKeyboardObject> get_children () { - return (List<IKeyboardObject>) collection_to_object_list (rows); + public IKeyboardObject[] get_children () { + return (IKeyboardObject[]) get_rows (); } + } } diff --git a/libcaribou/row-model.vala b/libcaribou/row-model.vala index 4020fe3..7aac08e 100644 --- a/libcaribou/row-model.vala +++ b/libcaribou/row-model.vala @@ -27,8 +27,8 @@ namespace Caribou { column.add_key (key); } - public List<ColumnModel> get_columns () { - return (List<ColumnModel>) get_children (); + public ColumnModel[] get_columns () { + return (ColumnModel[]) columns.to_array (); } public override IScannableItem[] get_scan_children () { @@ -38,8 +38,8 @@ namespace Caribou { return (IScannableItem[]) columns.to_array (); } - public List<IKeyboardObject> get_children () { - return (List<IKeyboardObject>) collection_to_object_list (columns); + public IKeyboardObject[] get_children () { + return (IKeyboardObject[]) get_columns (); } } } |