From bc6b4b01ea37687604c39b62d2467676f5ee665a Mon Sep 17 00:00:00 2001 From: Giovanni Campagna Date: Sat, 24 Nov 2012 15:56:06 +0100 Subject: [PATCH] status/keyboard: implement remaining property types Input methods other than Anthy need different property types, so we should support all those exposed by the IBus protocol. https://bugzilla.gnome.org/show_bug.cgi?id=682318 --- js/ui/status/keyboard.js | 42 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 38 insertions(+), 4 deletions(-) diff --git a/js/ui/status/keyboard.js b/js/ui/status/keyboard.js index f12c787d5..cf036ac57 100644 --- a/js/ui/status/keyboard.js +++ b/js/ui/status/keyboard.js @@ -484,11 +484,13 @@ const InputSourceIndicator = new Lang.Class({ } let item; - let type = prop.get_prop_type(); - if (type == IBus.PropType.MENU) { + switch (prop.get_prop_type()) { + case IBus.PropType.MENU: item = new PopupMenu.PopupSubMenuMenuItem(prop.get_label().get_text()); this._buildPropSubMenu(item.menu, prop.get_sub_props()); - } else if (type == IBus.PropType.RADIO) { + break; + + case IBus.PropType.RADIO: item = new PopupMenu.PopupMenuItem(prop.get_label().get_text()); item.prop = prop; radioGroup.push(item); @@ -513,7 +515,39 @@ const InputSourceIndicator = new Lang.Class({ } } })); - } else { + break; + + case IBus.PropType.TOGGLE: + item = new PopupMenu.PopupSwitchMenuItem(prop.get_label().get_text(), prop.get_state() == IBus.PropState.CHECKED); + item.prop = prop; + item.connect('toggled', Lang.bind(this, function() { + if (item.state) { + item.prop.set_state(IBus.PropState.CHECKED); + this._ibusManager.activateProperty(item.prop.get_key(), + IBus.PropState.CHECKED); + } else { + item.prop.set_state(IBus.PropState.UNCHECKED); + this._ibusManager.activateProperty(item.prop.get_key(), + IBus.PropState.UNCHECKED); + } + })); + break; + + case IBus.PropType.NORMAL: + item = new PopupMenu.PopupMenuItem(prop.get_label().get_text()); + item.prop = prop; + item.connect('activate', Lang.bind(this, function() { + this._ibusManager.activateProperty(item.prop.get_key(), + IBus.PropState.CHECKED); + })); + break; + + case IBus.PropType.SEPARATOR: + item = new PopupMenu.PopupSeparatorMenuItem(); + break; + + default: + log ('IBus property %s has invalid type %d'.format(prop.get_key(), type)); continue; }