aboutsummaryrefslogtreecommitdiff
path: root/lib/main.vala
diff options
context:
space:
mode:
authorWilliam Hua <william.hua@canonical.com>2013-06-20 12:17:43 -0400
committerWilliam Hua <william.hua@canonical.com>2013-06-20 12:17:43 -0400
commit06e0f0bc54df3a706ea2f71077ca986af37016d9 (patch)
tree2adb685e748110316686e0eb04ac9d06656303c4 /lib/main.vala
parentd7406e9bd98cc85cf7d294a46d4d1e51e269e992 (diff)
downloadayatana-indicator-keyboard-06e0f0bc54df3a706ea2f71077ca986af37016d9.tar.gz
ayatana-indicator-keyboard-06e0f0bc54df3a706ea2f71077ca986af37016d9.tar.bz2
ayatana-indicator-keyboard-06e0f0bc54df3a706ea2f71077ca986af37016d9.zip
Migrate old keyboard layouts and IM engines.
Diffstat (limited to 'lib/main.vala')
-rw-r--r--lib/main.vala49
1 files changed, 49 insertions, 0 deletions
diff --git a/lib/main.vala b/lib/main.vala
index ec4ceafa..e06c7794 100644
--- a/lib/main.vala
+++ b/lib/main.vala
@@ -41,6 +41,8 @@ public class Indicator.Keyboard.Service : Object {
this.xkb_info = new Gnome.XkbInfo ();
+ migrate_keyboard_layouts ();
+
update_window_sources ();
this.loop = new MainLoop ();
@@ -48,6 +50,53 @@ public class Indicator.Keyboard.Service : Object {
}
[DBus (visible = false)]
+ private void migrate_keyboard_layouts () {
+ if (!this.indicator_settings.get_boolean ("migrated")) {
+ var builder = new VariantBuilder (new VariantType ("a(ss)"));
+ var length = 0;
+
+ var layout_settings = new Settings ("org.gnome.libgnomekbd.keyboard");
+ var layouts = layout_settings.get_strv ("layouts");
+
+ foreach (var layout in layouts) {
+ var source = layout;
+
+ source = source.replace (" ", "+");
+ source = source.replace ("\t", "+");
+
+ builder.add ("(ss)", "xkb", source);
+ length++;
+ }
+
+ var ibus = get_ibus ();
+ var engines = ibus.list_active_engines ();
+
+ foreach (var engine in engines) {
+ if (length == 0) {
+ var source = "us";
+ var layout = engine.get_layout ();
+ var variant = engine.get_layout_variant ();
+
+ if (layout != null && variant != null) {
+ source = @"$layout+$variant";
+ } else if (layout != null) {
+ source = layout;
+ }
+
+ builder.add ("(ss)", "xkb", source);
+ }
+
+ builder.add ("(ss)", "ibus", engine.name);
+ length++;
+ }
+
+ this.source_settings.set_value ("sources", builder.end ());
+
+ this.indicator_settings.set_boolean ("migrated", true);
+ }
+ }
+
+ [DBus (visible = false)]
private void update_window_sources () {
var group_per_window = this.per_window_settings.get_boolean ("group-per-window");