aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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;
},
};