[caribou: 7/15] Don't fail when XKB group has no Caribou layout.



commit f01ca0a14fbed097ead474826559b98943678628
Author: Eitan Isaacson <eitan monotonous org>
Date:   Sat May 28 13:02:04 2011 -0700

    Don't fail when XKB group has no Caribou layout.

 libcaribou/keyboard-model.vala |   15 ++++++++++-----
 1 files changed, 10 insertions(+), 5 deletions(-)
---
diff --git a/libcaribou/keyboard-model.vala b/libcaribou/keyboard-model.vala
index 0e2fd1e..a1fa2fc 100644
--- a/libcaribou/keyboard-model.vala
+++ b/libcaribou/keyboard-model.vala
@@ -18,13 +18,13 @@ namespace Caribou {
             xadapter = XAdapter.get_default ();
             xadapter.group_changed.connect (on_group_changed);
 
-            grpid = xadapter.get_current_group (out group, out variant);
-            on_group_changed (grpid, group, variant);
-
             xadapter.get_groups (out grps, out variants);
 
             for (i=0;i<grps.length;i++)
                 populate_group (grps[i], variants[i]);
+
+            grpid = xadapter.get_current_group (out group, out variant);
+            on_group_changed (grpid, group, variant);
         }
 
         private void populate_group (string group, string variant) {
@@ -38,11 +38,16 @@ namespace Caribou {
         }
 
         public GroupModel get_group (string group_name) {
-            return groups.lookup(group_name);
+            return groups.lookup (group_name);
         }
 
         private void on_group_changed (uint grpid, string group, string variant) {
-            active_group = GroupModel.create_group_name (group, variant);
+            string group_name = GroupModel.create_group_name (group, variant);
+            if (groups.lookup (group_name) != null) {
+                active_group = group_name;
+            } else {
+                active_group = get_groups ()[0];
+            }
         }
 
     }



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