aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/Makefile.am6
-rw-r--r--lib/main.vala38
2 files changed, 33 insertions, 11 deletions
diff --git a/lib/Makefile.am b/lib/Makefile.am
index eea05532..df1cb0cc 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -1,6 +1,6 @@
libexec_PROGRAMS = indicator-keyboard-service
indicator_keyboard_service_SOURCES = main.vala
-indicator_keyboard_service_VALAFLAGS = --pkg gio-2.0 $(AM_VALAFLAGS)
-indicator_keyboard_service_CFLAGS = $(GIO_CFLAGS) $(AM_CFLAGS)
-indicator_keyboard_service_LDFLAGS = $(GIO_LIBS) $(AM_LDFLAGS)
+indicator_keyboard_service_VALAFLAGS = --pkg gio-2.0 --pkg ibus-1.0 $(AM_VALAFLAGS)
+indicator_keyboard_service_CFLAGS = $(GIO_CFLAGS) $(IBUS_CFLAGS) $(AM_CFLAGS)
+indicator_keyboard_service_LDFLAGS = $(GIO_LIBS) $(IBUS_LIBS) $(AM_LDFLAGS)
diff --git a/lib/main.vala b/lib/main.vala
index a149a522..09e1c7f4 100644
--- a/lib/main.vala
+++ b/lib/main.vala
@@ -32,16 +32,36 @@ public class Indicator.Keyboard.Service : GLib.Object {
[DBus (visible = false)]
protected virtual GLib.MenuModel create_menu_model () {
+ IBus.init ();
+ var ibus = new IBus.Bus ();
+ var engines = ibus.list_engines ();
+
var menu = new GLib.Menu ();
var submenu = new GLib.Menu ();
var section = new GLib.Menu ();
- section.append ("Chinese - Chewing", null);
- section.append ("Chinese - Pinyin", null);
- section.append ("Chinese - tonepy", null);
- section.append ("USA - Macintosh", null);
- section.append ("USA - Dvorak", null);
+
+ foreach (var engine in engines) {
+ GLib.stdout.printf ("author = %s\n", engine.author);
+ GLib.stdout.printf ("description = %s\n", engine.description);
+ GLib.stdout.printf ("hotkeys = %s\n", engine.hotkeys);
+ GLib.stdout.printf ("icon = %s\n", engine.icon);
+ GLib.stdout.printf ("language = %s\n", engine.language);
+ GLib.stdout.printf ("layout = %s\n", engine.layout);
+ GLib.stdout.printf ("license = %s\n", engine.license);
+ GLib.stdout.printf ("longname = %s\n", engine.longname);
+ GLib.stdout.printf ("name = %s\n", engine.name);
+ GLib.stdout.printf ("rank = %u\n", engine.rank);
+ GLib.stdout.printf ("setup = %s\n", engine.setup);
+ GLib.stdout.printf ("symbol = %s\n", engine.symbol);
+ GLib.stdout.printf ("---\n");
+ }
+
+ foreach (var engine in engines) {
+ section.append (@"$(engine.language) - $(engine.name)", null);
+ }
+
submenu.append_section (null, section);
section = new GLib.Menu ();
@@ -52,7 +72,7 @@ public class Indicator.Keyboard.Service : GLib.Object {
var indicator = new GLib.MenuItem.submenu ("x", submenu);
indicator.set_attribute ("x-canonical-type", "s", "com.canonical.indicator.root");
- indicator.set_detailed_action ("indicator");
+ indicator.set_detailed_action ("indicator.indicator");
menu.append_item (indicator);
return menu;
@@ -60,16 +80,18 @@ public class Indicator.Keyboard.Service : GLib.Object {
[DBus (visible = false)]
public GLib.ActionGroup get_action_group () {
- if (this.action_group == null)
+ if (this.action_group == null) {
this.action_group = create_action_group ();
+ }
return this.action_group;
}
[DBus (visible = false)]
public GLib.MenuModel get_menu_model () {
- if (this.menu_model == null)
+ if (this.menu_model == null) {
this.menu_model = create_menu_model ();
+ }
return this.menu_model;
}