diff options
author | Eitan Isaacson <eitan@monotonous.org> | 2011-04-27 20:32:35 -0700 |
---|---|---|
committer | Eitan Isaacson <eitan@monotonous.org> | 2011-05-02 10:18:49 -0700 |
commit | 6294dab42aec83a4e9edd314544903a67152b7fb (patch) | |
tree | e44d70f016e22510032935816be3d58014bb847c /libcaribou/group-model.vala | |
parent | 1242c1ea37f30109609c041de3572f5b900a2a3b (diff) | |
download | caribou-6294dab42aec83a4e9edd314544903a67152b7fb.tar.gz |
libcaribou: Implemented CaribouKeyboardModel.
Diffstat (limited to 'libcaribou/group-model.vala')
-rw-r--r-- | libcaribou/group-model.vala | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/libcaribou/group-model.vala b/libcaribou/group-model.vala new file mode 100644 index 0000000..564dbd8 --- /dev/null +++ b/libcaribou/group-model.vala @@ -0,0 +1,50 @@ +using GLib; + +namespace Caribou { + public class GroupModel : GLib.Object { + public string active_level { get; private set; } + + public string group; + public string variant; + private string default_level; + private HashTable<string, LevelModel> levels; + + public GroupModel (string group, string variant) { + this.group = group; + this.variant = variant; + levels = new HashTable<string, LevelModel> (str_hash, str_equal); + active_level = default_level; + } + + public static string create_group_name (string group, string variant) { + if (variant != "") + return @"$(group)_$(variant)"; + else + return group; + } + + public void add_level (string lname, LevelModel level) { + levels.insert (lname, level); + level.level_toggled.connect(on_level_toggled); + if (level.mode == "default") { + default_level = lname; + active_level = lname; + } + } + + public string[] get_levels () { + return Util.list_to_array (levels.get_keys ()); + } + + public LevelModel get_level (string level_name) { + return levels.lookup(level_name); + } + + private void on_level_toggled (string new_level) { + if (new_level == "default") + active_level = default_level; + else + active_level = new_level; + } + } +}
\ No newline at end of file |