aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2012-12-27 17:38:17 +0100
committerGuido Günther <agx@sigxcpu.org>2012-12-27 17:38:17 +0100
commit8b2fb765f9f6b5086f0021b89fe0fcdde6306432 (patch)
treeb897ea32d90577548bf73a2a3b70c87d62414c30
parente286aa5215bb44b554bff5bb821669bef13e7960 (diff)
Use signals to detect keyboard visibility changes
this makes sure button title and keyboard status are in sync.
-rw-r--r--extension.js20
1 files changed, 16 insertions, 4 deletions
diff --git a/extension.js b/extension.js
index 1a457fd..7d3d813 100644
--- a/extension.js
+++ b/extension.js
@@ -1,4 +1,5 @@
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
+
const Gio = imports.gi.Gio;
const Lang = imports.lang;
const St = imports.gi.St;
@@ -12,9 +13,23 @@ function OnScreenKeyboardButton() {
OnScreenKeyboardButton.prototype = {
_init: function() {
- this.actor = new St.Button ({ label: 'Keyboard' });
+ this.actor = new St.Button ({ label: 'Show Keyboard' });
this.actor.connect("clicked", Lang.bind(this, this._toggleShowOnScreenKeyboard));
this._onScreenKeyboardShown = false;
+
+ this._keyboardVisibleId = Main.layoutManager.connect('keyboard-visible-changed',
+ Lang.bind(this,
+ this._onKeyboardVisibleChanged));
+ },
+
+ _onKeyboardVisibleChanged: function (layoutManager, visible) {
+ if (visible) {
+ this.actor.set_label("Hide keyboard");
+ this._onScreenKeyboardShown = true;
+ } else {
+ this.actor.set_label("Show keyboard");
+ this._onScreenKeyboardShown = false;
+ }
},
_activateOnScreenKeyboard: function () {
@@ -29,14 +44,11 @@ OnScreenKeyboardButton.prototype = {
_toggleShowOnScreenKeyboard: function() {
if (this._onScreenKeyboardShown) {
- this.actor.set_label("Show keyboard");
Main.keyboard.hide();
} else {
this._activateOnScreenKeyboard();
- this.actor.set_label("Hide keyboard");
Main.keyboard.show();
}
- this._onScreenKeyboardShown = !this._onScreenKeyboardShown;
},
};