diff options
author | Guido Günther <agx@sigxcpu.org> | 2012-02-29 22:17:47 +0100 |
---|---|---|
committer | Guido Günther <agx@sigxcpu.org> | 2012-02-29 23:34:45 +0100 |
commit | 6a58153b89dbdeff33745c226442e63d7f92c775 (patch) | |
tree | 7ae18eca10e55a21e7c1ad73f80244e3eb83e612 /extension.js |
Initial commit
Diffstat (limited to 'extension.js')
-rw-r--r-- | extension.js | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/extension.js b/extension.js new file mode 100644 index 0000000..ac9e4de --- /dev/null +++ b/extension.js @@ -0,0 +1,44 @@ +const Gio = imports.gi.Gio; +const GLib = imports.gi.GLib; +const Lang = imports.lang; +const St = imports.gi.St; +const Shell = imports.gi.Shell; +const Main = imports.ui.main; + +function OnScreenKeyboardButton() { + this._init(); +} + +OnScreenKeyboardButton.prototype = { + _init: function() { + label = GLib.markup_escape_text('Keyboard', -1); + this.actor = new St.Button ({ label: label }); + this.actor.connect("clicked", Lang.bind(this, this._toggleShowOnScreenKeyboard)); + this._onScreenKeyboardShown = false; + }, + + _toggleShowOnScreenKeyboard: function() { + if (this._onScreenKeyboardShown) { + Main.keyboard.hide(); + } else { + Main.keyboard.show(); + } + this._onScreenKeyboardShown = !this._onScreenKeyboardShown; + }, +}; + +let button; + +function init() { + button = new OnScreenKeyboardButton(); +} + +function enable() { + let _children = Main.panel._centerBox.get_children(); + Main.panel._centerBox.insert_actor(button.actor, _children.length - 1); + Main.panel._centerBox.add(button.actor); +} + +function disable() { + Main.panel._centerBoxBox.remove_actor(button.actor); +} |