aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--deps/README4
-rw-r--r--lib/main.vala37
2 files changed, 25 insertions, 16 deletions
diff --git a/deps/README b/deps/README
index 4d95b07b..05d5b780 100644
--- a/deps/README
+++ b/deps/README
@@ -13,3 +13,7 @@ vapigen --metadatadir . --pkg gtk+-3.0 --library libgnomekbd /path/to/Gkbd-3.0.g
To generate libgnomekbd.vapi docs:
valadoc --metadatadir . --vapidir /path/to/vapi/dir --pkg gtk+-3.0 --pkg Xkl-1.0 -o libgnomekbd libgnomekbd.vapi
+
+To generate ibus-1.0.vapi docs:
+
+valadoc --vapidir /path/to/vapi/dir -o ibus-1.0 /path/to/ibus-1.0.vapi
diff --git a/lib/main.vala b/lib/main.vala
index 84724b57..97315f96 100644
--- a/lib/main.vala
+++ b/lib/main.vala
@@ -5,6 +5,7 @@ public class Indicator.Keyboard.Service : Object {
private Settings settings;
private ActionGroup action_group;
private MenuModel menu_model;
+ private IBus.Bus ibus;
[DBus (visible = false)]
public Service (bool force) {
@@ -43,8 +44,9 @@ public class Indicator.Keyboard.Service : Object {
this.settings.get ("sources", "@a(ss)", out array);
array.get_child (current, "(ss)", out type, out name);
- if (type == "xkb")
+ if (type == "xkb") {
layout = name;
+ }
}
try {
@@ -64,6 +66,17 @@ public class Indicator.Keyboard.Service : Object {
}
[DBus (visible = false)]
+ private IBus.Bus get_ibus () {
+ if (this.ibus == null) {
+ IBus.init ();
+
+ this.ibus = new IBus.Bus ();
+ }
+
+ return this.ibus;
+ }
+
+ [DBus (visible = false)]
protected virtual ActionGroup create_action_group () {
var group = new SimpleActionGroup ();
@@ -92,21 +105,6 @@ public class Indicator.Keyboard.Service : Object {
[DBus (visible = false)]
protected virtual MenuModel create_menu_model () {
- /* IBus.init (); */
- /* var bus = new IBus.Bus (); */
- /* var engines = bus.list_engines (); */
- /* var context = new IBus.InputContext (bus.current_input_context (), bus.get_connection ()); */
-
- /* foreach (var engine in engines) { */
- /* stdout.printf (@"$(engine.name) $(engine.longname)\n"); */
- /* } */
-
- /* stdout.printf (@"global engine = $(bus.get_global_engine ().name)\n"); */
- /* stdout.printf (@"current engine = $(context.get_engine ().name)\n"); */
-
- /* bus.set_global_engine ("pinyin"); */
- /* context.set_engine ("pinyin"); */
-
var menu = new Menu ();
var submenu = new Menu ();
@@ -132,6 +130,13 @@ public class Indicator.Keyboard.Service : Object {
else if (country != null)
name = country;
}
+ else if (type == "ibus") {
+ var ibus = get_ibus ();
+ string[] names = { name, null };
+ var engines = ibus.get_engines_by_names (names);
+
+ name = engines[0].longname;
+ }
var menu_item = new MenuItem (name, "indicator.current");
menu_item.set_attribute (Menu.ATTRIBUTE_TARGET, "u", i);