aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorWilliam Hua <william.hua@canonical.com>2013-04-02 11:03:10 -0400
committerWilliam Hua <william.hua@canonical.com>2013-04-02 11:03:10 -0400
commit9d04807fffd9ed6eda2cbbb0d65eeb64a209c3bd (patch)
tree6d19450282dccd97248f82ec26c4f4affaf2c9bb /lib
parent961446aefd28debf647c67aeda152d9b1b65ca92 (diff)
downloadayatana-indicator-keyboard-9d04807fffd9ed6eda2cbbb0d65eeb64a209c3bd.tar.gz
ayatana-indicator-keyboard-9d04807fffd9ed6eda2cbbb0d65eeb64a209c3bd.tar.bz2
ayatana-indicator-keyboard-9d04807fffd9ed6eda2cbbb0d65eeb64a209c3bd.zip
Use long name of engine in menu.
Diffstat (limited to 'lib')
-rw-r--r--lib/main.vala37
1 files changed, 21 insertions, 16 deletions
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);