[gnome-shell] keyboard: Use common code to create regular and extension key buttons
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] keyboard: Use common code to create regular and extension key buttons
- Date: Thu, 24 Jul 2014 17:40:11 +0000 (UTC)
commit 69d5cef3b240d9df3b5df74df320dff8c537616b
Author: Carlos Garnacho <carlosg gnome org>
Date: Tue Jul 22 12:38:44 2014 +0200
keyboard: Use common code to create regular and extension key buttons
The code is almost the same, so pull this out to a generic _makeKey(), and
use it from both places.
https://bugzilla.gnome.org/show_bug.cgi?id=733633
js/ui/keyboard.js | 23 ++++++-----------------
1 files changed, 6 insertions(+), 17 deletions(-)
---
diff --git a/js/ui/keyboard.js b/js/ui/keyboard.js
index 244b1d1..cfce861 100644
--- a/js/ui/keyboard.js
+++ b/js/ui/keyboard.js
@@ -52,8 +52,7 @@ const Key = new Lang.Class({
_init : function(key) {
this._key = key;
-
- this.actor = this._makeKey();
+ this.actor = this._makeKey(key, GLib.markup_escape_text(key.label, -1));
this._extended_keys = this._key.get_extended_keys();
this._extended_keyboard = null;
@@ -76,20 +75,19 @@ const Key = new Lang.Class({
}
},
- _makeKey: function () {
- let label = GLib.markup_escape_text(this._key.label, -1);
+ _makeKey: function (key, label) {
let button = new St.Button ({ label: label,
style_class: 'keyboard-key' });
button.key_width = this._key.width;
button.connect('button-press-event', Lang.bind(this,
function () {
- this._key.press();
+ key.press();
return Clutter.EVENT_PROPAGATE;
}));
button.connect('button-release-event', Lang.bind(this,
function () {
- this._key.release();
+ key.release();
return Clutter.EVENT_PROPAGATE;
}));
@@ -112,18 +110,9 @@ const Key = new Lang.Class({
for (let i = 0; i < this._extended_keys.length; ++i) {
let extended_key = this._extended_keys[i];
let label = this._getUnichar(extended_key);
- let key = new St.Button({ label: label, style_class: 'keyboard-key' });
+ let key = this._makeKey(extended_key, label);
+
key.extended_key = extended_key;
- key.connect('button-press-event', Lang.bind(this,
- function () {
- extended_key.press();
- return Clutter.EVENT_PROPAGATE;
- }));
- key.connect('button-release-event', Lang.bind(this,
- function () {
- extended_key.release();
- return Clutter.EVENT_PROPAGATE;
- }));
this._extended_keyboard.add(key);
}
this._boxPointer.bin.add_actor(this._extended_keyboard);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]