aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorWilliam Hua <william.hua@canonical.com>2013-03-21 01:11:51 -0400
committerWilliam Hua <william.hua@canonical.com>2013-03-21 01:11:51 -0400
commitbb5d7364fcc89d18a9c431344acf56f48fcbc684 (patch)
tree64d862276ec886ac9d2d5dd16833d9d3af069599 /lib
parent1eba4ec7bd2d3a746ff929363b8de05df8462965 (diff)
downloadayatana-indicator-keyboard-bb5d7364fcc89d18a9c431344acf56f48fcbc684.tar.gz
ayatana-indicator-keyboard-bb5d7364fcc89d18a9c431344acf56f48fcbc684.tar.bz2
ayatana-indicator-keyboard-bb5d7364fcc89d18a9c431344acf56f48fcbc684.zip
Integrate IBus and libgnomekbd.
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;
}