[gnome-shell/wip/input-sources: 2/2] status/keyboard: Add the input source switcher keybindings
- From: Rui Matos <rtcm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/wip/input-sources: 2/2] status/keyboard: Add the input source switcher keybindings
- Date: Mon, 23 Apr 2012 21:10:14 +0000 (UTC)
commit 72eaa35ec6c7be48c5c3ffd3314d8f77796b1591
Author: Rui Matos <tiagomatos gmail com>
Date: Thu Apr 19 05:42:42 2012 +0200
status/keyboard: Add the input source switcher keybindings
js/ui/status/keyboard.js | 39 +++++++++++++++++++++++++++++++++++++++
1 files changed, 39 insertions(+), 0 deletions(-)
---
diff --git a/js/ui/status/keyboard.js b/js/ui/status/keyboard.js
index edad0f6..a0077ff 100644
--- a/js/ui/status/keyboard.js
+++ b/js/ui/status/keyboard.js
@@ -5,6 +5,7 @@ const GdkPixbuf = imports.gi.GdkPixbuf;
const Gio = imports.gi.Gio;
const GLib = imports.gi.GLib;
const Lang = imports.lang;
+const Meta = imports.gi.Meta;
const Shell = imports.gi.Shell;
const St = imports.gi.St;
@@ -13,6 +14,7 @@ const PopupMenu = imports.ui.popupMenu;
const PanelMenu = imports.ui.panelMenu;
const Util = imports.misc.util;
+const DESKTOP_INPUT_SOURCES_KEYBINDINGS_SCHEMA = 'org.gnome.desktop.input-sources.keybindings';
const DESKTOP_INPUT_SOURCES_SCHEMA = 'org.gnome.desktop.input-sources';
const KEY_CURRENT_IS = 'current';
const KEY_INPUT_SOURCES = 'sources';
@@ -66,6 +68,15 @@ const InputSourceIndicator = new Lang.Class({
}));
}
this.menu.addSettingsAction(_("Region and Language Settings"), 'gnome-region-panel.desktop');
+
+ global.display.add_keybinding('switch-next',
+ new Gio.Settings({ schema: DESKTOP_INPUT_SOURCES_KEYBINDINGS_SCHEMA }),
+ Meta.KeyBindingFlags.NONE,
+ Lang.bind(this, this._switchNext));
+ global.display.add_keybinding('switch-previous',
+ new Gio.Settings({ schema: DESKTOP_INPUT_SOURCES_KEYBINDINGS_SCHEMA }),
+ Meta.KeyBindingFlags.NONE,
+ Lang.bind(this, this._switchPrevious));
},
_currentISChanged: function() {
@@ -153,6 +164,34 @@ const InputSourceIndicator = new Lang.Class({
this._currentISChanged();
},
+ _switchNext: function() {
+ if (!this._selectedLayout || !this._selectedLabel) {
+ this._layoutItems[0].activate();
+ return;
+ }
+ for (let i = 0; i < this._layoutItems.length; ++i) {
+ let item = this._layoutItems[i];
+ if (item.name == this._selectedLayout.name) {
+ this._layoutItems[(++i == this._layoutItems.length) ? 0 : i].activate();
+ break;
+ }
+ }
+ },
+
+ _switchPrevious: function() {
+ if (!this._selectedLayout || !this._selectedLabel) {
+ this._layoutItems[0].activate();
+ return;
+ }
+ for (let i = 0; i < this._layoutItems.length; ++i) {
+ let item = this._layoutItems[i];
+ if (item.name == this._selectedLayout.name) {
+ this._layoutItems[(--i == -1) ? (this._layoutItems.length - 1) : i].activate();
+ break;
+ }
+ }
+ },
+
_containerGetPreferredWidth: function(container, for_height, alloc) {
// Here, and in _containerGetPreferredHeight, we need to query
// for the height of all children, but we ignore the results
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]