aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorWilliam Hua <william.hua@canonical.com>2013-03-25 17:03:40 -0400
committerWilliam Hua <william.hua@canonical.com>2013-03-25 17:03:40 -0400
commit500d2d52aed27712843f8648c728332caf960f6f (patch)
treec51ccc577c1d9c86d4736627456d0a0fb6af0faa /lib
parentc81a708527ac25eb81db3bd919d7f96176ef9d7a (diff)
downloadayatana-indicator-keyboard-500d2d52aed27712843f8648c728332caf960f6f.tar.gz
ayatana-indicator-keyboard-500d2d52aed27712843f8648c728332caf960f6f.tar.bz2
ayatana-indicator-keyboard-500d2d52aed27712843f8648c728332caf960f6f.zip
Fiddle with GSettings.
Diffstat (limited to 'lib')
-rw-r--r--lib/main.vala52
1 files changed, 18 insertions, 34 deletions
diff --git a/lib/main.vala b/lib/main.vala
index 601a0e40..e1aa8e7f 100644
--- a/lib/main.vala
+++ b/lib/main.vala
@@ -2,6 +2,7 @@
public class Indicator.Keyboard.Service : GLib.Object {
private GLib.MainLoop loop;
+ private GLib.Settings settings;
private GLib.ActionGroup action_group;
private GLib.MenuModel menu_model;
@@ -13,6 +14,8 @@ public class Indicator.Keyboard.Service : GLib.Object {
null,
this.handle_name_lost);
+ this.settings = new GLib.Settings ("org.gnome.desktop.input-sources");
+
this.loop = new GLib.MainLoop ();
this.loop.run ();
}
@@ -27,6 +30,10 @@ public class Indicator.Keyboard.Service : GLib.Object {
group.add_entries (entries, null);
+ if (this.settings != null) {
+ group.insert (this.settings.create_action ("current"));
+ }
+
return group;
}
@@ -38,42 +45,19 @@ public class Indicator.Keyboard.Service : GLib.Object {
var section = new GLib.Menu ();
- IBus.init ();
- var ibus = new IBus.Bus ();
- var engines = ibus.list_active_engines ();
- var context = IBus.InputContext.get_input_context (ibus.current_input_context (), ibus.get_connection ());
-
- ibus.connected.connect (() => {
- GLib.stdout.printf ("connected\n");
- });
- ibus.disconnected.connect (() => {
- GLib.stdout.printf ("disconnected\n");
- });
- ibus.global_engine_changed.connect ((name) => {
- GLib.stdout.printf ("global engine changed %s\n", name);
- });
- ibus.name_owner_changed.connect ((name, old_owner, new_owner) => {
- GLib.stdout.printf ("name owner changed %s %s %s\n", name, old_owner, new_owner);
- });
-
- GLib.stdout.printf ("%p\n", context);
- GLib.stdout.printf ("%d\n", (int) context.is_enabled ());
- GLib.stdout.printf ("%p\n", context.get_engine ());
-
- context.set_engine ("emoji-table");
-
- var configuration = Gkbd.Configuration.get ();
-
- GLib.stdout.printf ("----------\n");
-
- foreach (var group in configuration.get_group_names ())
- GLib.stdout.printf ("%s\n", group);
+ if (this.settings != null) {
+ GLib.VariantIter iter;
+ string type;
+ string name;
+ uint i;
- GLib.stdout.printf ("----------\n");
- GLib.stdout.printf ("current group = %u\n", configuration.get_current_group ());
+ this.settings.get ("sources", "a(ss)", out iter);
- foreach (var engine in engines) {
- section.append (@"$(engine.language) - $(engine.longname)", null);
+ for (i = 0; iter.next ("(ss)", out type, out name); i++) {
+ GLib.MenuItem menu_item = new GLib.MenuItem (name, "indicator.current");
+ menu_item.set_attribute (GLib.Menu.ATTRIBUTE_TARGET, "u", i);
+ section.append_item (menu_item);
+ }
}
submenu.append_section (null, section);