~ubuntu-branches/ubuntu/trusty/gnome-shell/trusty-proposed

« back to all changes in this revision

Viewing changes to .pc/git_remove_dbus_import.patch/js/ui/keyboard.js

  • Committer: Package Import Robot
  • Author(s): Tim Lunn
  • Date: 2013-05-01 12:06:16 UTC
  • Revision ID: package-import@ubuntu.com-20130501120616-ezmnooln3cmit4ix
Tags: 3.6.3.1-0ubuntu8
* debian/patches/git_remove_dbus_import.patch:
  - required for gnome-shell to work with gjs 1.36

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
 
2
 
 
3
const Caribou = imports.gi.Caribou;
 
4
const Clutter = imports.gi.Clutter;
 
5
const DBus = imports.dbus;
 
6
const Gdk = imports.gi.Gdk;
 
7
const Gio = imports.gi.Gio;
 
8
const GLib = imports.gi.GLib;
 
9
const Lang = imports.lang;
 
10
const Shell = imports.gi.Shell;
 
11
const St = imports.gi.St;
 
12
 
 
13
const BoxPointer = imports.ui.boxpointer;
 
14
const Main = imports.ui.main;
 
15
const MessageTray = imports.ui.messageTray;
 
16
 
 
17
const KEYBOARD_SCHEMA = 'org.gnome.shell.keyboard';
 
18
const KEYBOARD_TYPE = 'keyboard-type';
 
19
 
 
20
const A11Y_APPLICATIONS_SCHEMA = 'org.gnome.desktop.a11y.applications';
 
21
const SHOW_KEYBOARD = 'screen-keyboard-enabled';
 
22
 
 
23
// Key constants taken from Antler
 
24
// FIXME: ought to be moved into libcaribou
 
25
const PRETTY_KEYS = {
 
26
    'BackSpace': '\u232b',
 
27
    'space': ' ',
 
28
    'Return': '\u23ce',
 
29
    'Caribou_Prefs': '\u2328',
 
30
    'Caribou_ShiftUp': '\u2b06',
 
31
    'Caribou_ShiftDown': '\u2b07',
 
32
    'Caribou_Emoticons': '\u263a',
 
33
    'Caribou_Symbols': '123',
 
34
    'Caribou_Symbols_More': '{#*',
 
35
    'Caribou_Alpha': 'Abc',
 
36
    'Tab': 'Tab',
 
37
    'Escape': 'Esc',
 
38
    'Control_L': 'Ctrl',
 
39
    'Alt_L': 'Alt'
 
40
};
 
41
 
 
42
const CaribouKeyboardIface = <interface name='org.gnome.Caribou.Keyboard'>
 
43
<method name='Show'>
 
44
    <arg type='u' direction='in' />
 
45
</method>
 
46
<method name='Hide'>
 
47
    <arg type='u' direction='in' />
 
48
</method>
 
49
<method name='SetCursorLocation'>
 
50
    <arg type='i' direction='in' />
 
51
    <arg type='i' direction='in' />
 
52
    <arg type='i' direction='in' />
 
53
    <arg type='i' direction='in' />
 
54
</method>
 
55
<method name='SetEntryLocation'>
 
56
    <arg type='i' direction='in' />
 
57
    <arg type='i' direction='in' />
 
58
    <arg type='i' direction='in' />
 
59
    <arg type='i' direction='in' />
 
60
</method>
 
61
<property name='Name' access='read' type='s' />
 
62
</interface>;
 
63
 
 
64
const Key = new Lang.Class({
 
65
    Name: 'Key',
 
66
 
 
67
    _init : function(key) {
 
68
        this._key = key;
 
69
 
 
70
        this.actor = this._makeKey();
 
71
 
 
72
        this._extended_keys = this._key.get_extended_keys();
 
73
        this._extended_keyboard = null;
 
74
 
 
75
        if (this._key.name == 'Control_L' || this._key.name == 'Alt_L')
 
76
            this._key.latch = true;
 
77
 
 
78
        this._key.connect('key-pressed', Lang.bind(this, function ()
 
79
                                                   { this.actor.checked = true }));
 
80
        this._key.connect('key-released', Lang.bind(this, function ()
 
81
                                                    { this.actor.checked = false; }));
 
82
 
 
83
        if (this._extended_keys.length > 0) {
 
84
            this._grabbed = false;
 
85
            this._eventCaptureId = 0;
 
86
            this._key.connect('notify::show-subkeys', Lang.bind(this, this._onShowSubkeysChanged));
 
87
            this._boxPointer = new BoxPointer.BoxPointer(St.Side.BOTTOM,
 
88
                                                         { x_fill: true,
 
89
                                                           y_fill: true,
 
90
                                                           x_align: St.Align.START });
 
91
            // Adds style to existing keyboard style to avoid repetition
 
92
            this._boxPointer.actor.add_style_class_name('keyboard-subkeys');
 
93
            this._getExtendedKeys();
 
94
            this.actor._extended_keys = this._extended_keyboard;
 
95
            this._boxPointer.actor.hide();
 
96
            Main.layoutManager.addChrome(this._boxPointer.actor);
 
97
        }
 
98
    },
 
99
 
 
100
    _makeKey: function () {
 
101
        let label = this._key.name;
 
102
 
 
103
        if (label.length > 1) {
 
104
            let pretty = PRETTY_KEYS[label];
 
105
            if (pretty)
 
106
                label = pretty;
 
107
            else
 
108
                label = this._getUnichar(this._key);
 
109
        }
 
110
 
 
111
        label = GLib.markup_escape_text(label, -1);
 
112
        let button = new St.Button ({ label: label,
 
113
                                      style_class: 'keyboard-key' });
 
114
 
 
115
        button.key_width = this._key.width;
 
116
        button.connect('button-press-event', Lang.bind(this, function () { this._key.press(); }));
 
117
        button.connect('button-release-event', Lang.bind(this, function () { this._key.release(); }));
 
118
 
 
119
        return button;
 
120
    },
 
121
 
 
122
    _getUnichar: function(key) {
 
123
        let keyval = key.keyval;
 
124
        let unichar = Gdk.keyval_to_unicode(keyval);
 
125
        if (unichar) {
 
126
            return String.fromCharCode(unichar);
 
127
        } else {
 
128
            return key.name;
 
129
        }
 
130
    },
 
131
 
 
132
    _getExtendedKeys: function () {
 
133
        this._extended_keyboard = new St.BoxLayout({ style_class: 'keyboard-layout',
 
134
                                                     vertical: false });
 
135
        for (let i = 0; i < this._extended_keys.length; ++i) {
 
136
            let extended_key = this._extended_keys[i];
 
137
            let label = this._getUnichar(extended_key);
 
138
            let key = new St.Button({ label: label, style_class: 'keyboard-key' });
 
139
            key.extended_key = extended_key;
 
140
            key.connect('button-press-event', Lang.bind(this, function () { extended_key.press(); }));
 
141
            key.connect('button-release-event', Lang.bind(this, function () { extended_key.release(); }));
 
142
            this._extended_keyboard.add(key);
 
143
        }
 
144
        this._boxPointer.bin.add_actor(this._extended_keyboard);
 
145
    },
 
146
 
 
147
    _onEventCapture: function (actor, event) {
 
148
        let source = event.get_source();
 
149
        let type = event.type();
 
150
 
 
151
        if ((type == Clutter.EventType.BUTTON_PRESS ||
 
152
             type == Clutter.EventType.BUTTON_RELEASE) &&
 
153
            this._extended_keyboard.contains(source)) {
 
154
            source.extended_key.press();
 
155
            source.extended_key.release();
 
156
            return false;
 
157
        }
 
158
        if (type == Clutter.EventType.BUTTON_PRESS) {
 
159
            this._boxPointer.actor.hide();
 
160
            this._ungrab();
 
161
            return true;
 
162
        }
 
163
        return false;
 
164
    },
 
165
 
 
166
    _ungrab: function () {
 
167
        global.stage.disconnect(this._eventCaptureId);
 
168
        this._eventCaptureId = 0;
 
169
        this._grabbed = false;
 
170
        Main.popModal(this.actor);
 
171
    },
 
172
 
 
173
    _onShowSubkeysChanged: function () {
 
174
        if (this._key.show_subkeys) {
 
175
            this.actor.fake_release();
 
176
            this._boxPointer.actor.raise_top();
 
177
            this._boxPointer.setPosition(this.actor, 0.5);
 
178
            this._boxPointer.show(BoxPointer.PopupAnimation.FULL);
 
179
            this.actor.set_hover(false);
 
180
            if (!this._grabbed) {
 
181
                 Main.pushModal(this.actor);
 
182
                 this._eventCaptureId = global.stage.connect('captured-event', Lang.bind(this, this._onEventCapture));
 
183
                 this._grabbed = true;
 
184
            }
 
185
            this._key.release();
 
186
        } else {
 
187
            if (this._grabbed)
 
188
                this._ungrab();
 
189
            this._boxPointer.hide(BoxPointer.PopupAnimation.FULL);
 
190
        }
 
191
    }
 
192
});
 
193
 
 
194
const Keyboard = new Lang.Class({
 
195
    // HACK: we can't set Name, because it collides with Name dbus property
 
196
    // Name: 'Keyboard',
 
197
 
 
198
    _init: function () {
 
199
        this._impl = Gio.DBusExportedObject.wrapJSObject(CaribouKeyboardIface, this);
 
200
        this._impl.export(Gio.DBus.session, '/org/gnome/Caribou/Keyboard');
 
201
 
 
202
        this.actor = null;
 
203
        this._focusInTray = false;
 
204
        this._focusInExtendedKeys = false;
 
205
 
 
206
        this._timestamp = global.display.get_current_time_roundtrip();
 
207
        Main.layoutManager.connect('monitors-changed', Lang.bind(this, this._redraw));
 
208
 
 
209
        this._keyboardSettings = new Gio.Settings({ schema: KEYBOARD_SCHEMA });
 
210
        this._keyboardSettings.connect('changed', Lang.bind(this, this._settingsChanged));
 
211
        this._a11yApplicationsSettings = new Gio.Settings({ schema: A11Y_APPLICATIONS_SCHEMA });
 
212
        this._a11yApplicationsSettings.connect('changed', Lang.bind(this, this._settingsChanged));
 
213
        this._settingsChanged();
 
214
    },
 
215
 
 
216
    init: function () {
 
217
        this._redraw();
 
218
    },
 
219
 
 
220
    _settingsChanged: function (settings, key) {
 
221
        this._enableKeyboard = this._a11yApplicationsSettings.get_boolean(SHOW_KEYBOARD);
 
222
        if (!this._enableKeyboard && !this._keyboard)
 
223
            return;
 
224
        if (this._enableKeyboard && this._keyboard &&
 
225
            this._keyboard.keyboard_type == this._keyboardSettings.get_string(KEYBOARD_TYPE))
 
226
            return;
 
227
 
 
228
        if (this._keyboard)
 
229
            this._destroyKeyboard();
 
230
 
 
231
        if (this._enableKeyboard) {
 
232
            // If we've been called because the setting actually just
 
233
            // changed to true (as opposed to being called from
 
234
            // this._init()), then we want to pop up the keyboard.
 
235
            let showKeyboard = (settings != null);
 
236
 
 
237
            // However, caribou-gtk-module or this._onKeyFocusChanged
 
238
            // will probably immediately tell us to hide it, so we
 
239
            // have to fake things out so we'll ignore that request.
 
240
            if (showKeyboard)
 
241
                this._timestamp = global.display.get_current_time_roundtrip() + 1;
 
242
            this._setupKeyboard(showKeyboard);
 
243
        } else
 
244
            Main.layoutManager.hideKeyboard(true);
 
245
    },
 
246
 
 
247
    _destroyKeyboard: function() {
 
248
        if (this._keyboardNotifyId)
 
249
            this._keyboard.disconnect(this._keyboardNotifyId);
 
250
        if (this._focusNotifyId)
 
251
            global.stage.disconnect(this._focusNotifyId);
 
252
        this._keyboard = null;
 
253
        this.actor.destroy();
 
254
        this.actor = null;
 
255
 
 
256
        this._destroySource();
 
257
    },
 
258
 
 
259
    _setupKeyboard: function(show) {
 
260
        this.actor = new St.BoxLayout({ name: 'keyboard', vertical: true, reactive: true });
 
261
        Main.layoutManager.keyboardBox.add_actor(this.actor);
 
262
        Main.layoutManager.trackChrome(this.actor);
 
263
 
 
264
        this._keyboard = new Caribou.KeyboardModel({ keyboard_type: this._keyboardSettings.get_string(KEYBOARD_TYPE) });
 
265
        this._groups = {};
 
266
        this._current_page = null;
 
267
 
 
268
        // Initialize keyboard key measurements
 
269
        this._numOfHorizKeys = 0;
 
270
        this._numOfVertKeys = 0;
 
271
 
 
272
        this._addKeys();
 
273
 
 
274
        // Keys should be layout according to the group, not the
 
275
        // locale; as Caribou already provides the expected layout,
 
276
        // this means enforcing LTR for all locales.
 
277
        this.actor.text_direction = Clutter.TextDirection.LTR;
 
278
 
 
279
        this._keyboardNotifyId = this._keyboard.connect('notify::active-group', Lang.bind(this, this._onGroupChanged));
 
280
        this._focusNotifyId = global.stage.connect('notify::key-focus', Lang.bind(this, this._onKeyFocusChanged));
 
281
 
 
282
        if (show)
 
283
            this.show();
 
284
        else
 
285
            this._createSource();
 
286
    },
 
287
 
 
288
    _onKeyFocusChanged: function () {
 
289
        let focus = global.stage.key_focus;
 
290
 
 
291
        // Showing an extended key popup and clicking a key from the extended keys
 
292
        // will grab focus, but ignore that
 
293
        let extendedKeysWereFocused = this._focusInExtendedKeys;
 
294
        this._focusInExtendedKeys = focus && (focus._extended_keys || focus.extended_key);
 
295
        if (this._focusInExtendedKeys || extendedKeysWereFocused)
 
296
            return;
 
297
 
 
298
        // Ignore focus changes caused by message tray showing/hiding
 
299
        let trayWasFocused = this._focusInTray;
 
300
        this._focusInTray = (focus && Main.messageTray.actor.contains(focus));
 
301
        if (this._focusInTray || trayWasFocused)
 
302
            return;
 
303
 
 
304
        let time = global.get_current_time();
 
305
        if (focus instanceof Clutter.Text)
 
306
            this.Show(time);
 
307
        else
 
308
            this.Hide(time);
 
309
    },
 
310
 
 
311
    _addKeys: function () {
 
312
        let groups = this._keyboard.get_groups();
 
313
        for (let i = 0; i < groups.length; ++i) {
 
314
             let gname = groups[i];
 
315
             let group = this._keyboard.get_group(gname);
 
316
             group.connect('notify::active-level', Lang.bind(this, this._onLevelChanged));
 
317
             let layers = {};
 
318
             let levels = group.get_levels();
 
319
             for (let j = 0; j < levels.length; ++j) {
 
320
                 let lname = levels[j];
 
321
                 let level = group.get_level(lname);
 
322
                 let layout = new St.BoxLayout({ style_class: 'keyboard-layout',
 
323
                                                 vertical: true });
 
324
                 this._loadRows(level, layout);
 
325
                 layers[lname] = layout;
 
326
                 this.actor.add(layout, { x_fill: false });
 
327
 
 
328
                 layout.hide();
 
329
             }
 
330
             this._groups[gname] = layers;
 
331
        }
 
332
 
 
333
        this._setActiveLayer();
 
334
    },
 
335
 
 
336
    _getTrayIcon: function () {
 
337
        let trayButton = new St.Button ({ label: _("tray"),
 
338
                                          style_class: 'keyboard-key' });
 
339
        trayButton.key_width = 1;
 
340
        trayButton.connect('button-press-event', Lang.bind(this, function () {
 
341
            Main.messageTray.toggle();
 
342
        }));
 
343
 
 
344
        Main.overview.connect('showing', Lang.bind(this, function () {
 
345
            trayButton.reactive = false;
 
346
            trayButton.add_style_pseudo_class('grayed');
 
347
        }));
 
348
        Main.overview.connect('hiding', Lang.bind(this, function () {
 
349
            trayButton.reactive = true;
 
350
            trayButton.remove_style_pseudo_class('grayed');
 
351
        }));
 
352
        Main.sessionMode.connect('updated', Lang.bind(this, function() {
 
353
            trayButton.reactive = !Main.sessionMode.isLocked;
 
354
            if (Main.sessionMode.isLocked)
 
355
                trayButton.add_style_pseudo_class('grayed');
 
356
            else
 
357
                trayButton.remove_style_pseudo_class('grayed');
 
358
        }));
 
359
 
 
360
        return trayButton;
 
361
    },
 
362
 
 
363
    _addRows : function (keys, layout) {
 
364
        let keyboard_row = new St.BoxLayout();
 
365
        for (let i = 0; i < keys.length; ++i) {
 
366
            let children = keys[i].get_children();
 
367
            let right_box = new St.BoxLayout({ style_class: 'keyboard-row' });
 
368
            let left_box = new St.BoxLayout({ style_class: 'keyboard-row' });
 
369
            for (let j = 0; j < children.length; ++j) {
 
370
                if (this._numOfHorizKeys == 0)
 
371
                    this._numOfHorizKeys = children.length;
 
372
                let key = children[j];
 
373
                let button = new Key(key);
 
374
 
 
375
                if (key.align == 'right')
 
376
                    right_box.add(button.actor);
 
377
                else
 
378
                    left_box.add(button.actor);
 
379
                if (key.name == 'Caribou_Prefs') {
 
380
                    key.connect('key-released', Lang.bind(this, this.hide));
 
381
 
 
382
                    // Add new key for hiding message tray
 
383
                    right_box.add(this._getTrayIcon());
 
384
                }
 
385
            }
 
386
            keyboard_row.add(left_box, { expand: true, x_fill: false, x_align: St.Align.START });
 
387
            keyboard_row.add(right_box, { expand: true, x_fill: false, x_align: St.Align.END });
 
388
        }
 
389
        layout.add(keyboard_row);
 
390
    },
 
391
 
 
392
    _loadRows : function (level, layout) {
 
393
        let rows = level.get_rows();
 
394
        for (let i = 0; i < rows.length; ++i) {
 
395
            let row = rows[i];
 
396
            if (this._numOfVertKeys == 0)
 
397
                this._numOfVertKeys = rows.length;
 
398
            this._addRows(row.get_columns(), layout);
 
399
        }
 
400
 
 
401
    },
 
402
 
 
403
    _redraw: function () {
 
404
        if (!this._enableKeyboard)
 
405
            return;
 
406
 
 
407
        let monitor = Main.layoutManager.bottomMonitor;
 
408
        let maxHeight = monitor.height / 3;
 
409
        this.actor.width = monitor.width;
 
410
 
 
411
        let layout = this._current_page;
 
412
        let verticalSpacing = layout.get_theme_node().get_length('spacing');
 
413
        let padding = layout.get_theme_node().get_length('padding');
 
414
 
 
415
        let box = layout.get_children()[0].get_children()[0];
 
416
        let horizontalSpacing = box.get_theme_node().get_length('spacing');
 
417
        let allHorizontalSpacing = (this._numOfHorizKeys - 1) * horizontalSpacing;
 
418
        let keyWidth = Math.floor((this.actor.width - allHorizontalSpacing - 2 * padding) / this._numOfHorizKeys);
 
419
 
 
420
        let allVerticalSpacing = (this._numOfVertKeys - 1) * verticalSpacing;
 
421
        let keyHeight = Math.floor((maxHeight - allVerticalSpacing - 2 * padding) / this._numOfVertKeys);
 
422
 
 
423
        let keySize = Math.min(keyWidth, keyHeight);
 
424
        this.actor.height = keySize * this._numOfVertKeys + allVerticalSpacing + 2 * padding;
 
425
 
 
426
        let rows = this._current_page.get_children();
 
427
        for (let i = 0; i < rows.length; ++i) {
 
428
            let keyboard_row = rows[i];
 
429
            let boxes = keyboard_row.get_children();
 
430
            for (let j = 0; j < boxes.length; ++j) {
 
431
                let keys = boxes[j].get_children();
 
432
                for (let k = 0; k < keys.length; ++k) {
 
433
                    let child = keys[k];
 
434
                    child.width = keySize * child.key_width;
 
435
                    child.height = keySize;
 
436
                    if (child._extended_keys) {
 
437
                        let extended_keys = child._extended_keys.get_children();
 
438
                        for (let n = 0; n < extended_keys.length; ++n) {
 
439
                            let extended_key = extended_keys[n];
 
440
                            extended_key.width = keySize;
 
441
                            extended_key.height = keySize;
 
442
                        }
 
443
                    }
 
444
                }
 
445
            }
 
446
        }
 
447
    },
 
448
 
 
449
    _onLevelChanged: function () {
 
450
        this._setActiveLayer();
 
451
        this._redraw();
 
452
    },
 
453
 
 
454
    _onGroupChanged: function () {
 
455
        this._setActiveLayer();
 
456
        this._redraw();
 
457
    },
 
458
 
 
459
    _setActiveLayer: function () {
 
460
        let active_group_name = this._keyboard.active_group;
 
461
        let active_group = this._keyboard.get_group(active_group_name);
 
462
        let active_level = active_group.active_level;
 
463
        let layers = this._groups[active_group_name];
 
464
 
 
465
        if (this._current_page != null) {
 
466
            this._current_page.hide();
 
467
        }
 
468
 
 
469
        this._current_page = layers[active_level];
 
470
        this._current_page.show();
 
471
    },
 
472
 
 
473
    _createSource: function () {
 
474
        if (this._source == null) {
 
475
            this._source = new KeyboardSource(this);
 
476
            this._source.setTransient(true);
 
477
            Main.messageTray.add(this._source);
 
478
        }
 
479
    },
 
480
 
 
481
    _destroySource: function () {
 
482
        if (this._source) {
 
483
            this._source.destroy();
 
484
            this._source = null;
 
485
        }
 
486
    },
 
487
 
 
488
    shouldTakeEvent: function(event) {
 
489
        let actor = event.get_source();
 
490
        return Main.layoutManager.keyboardBox.contains(actor) ||
 
491
               actor._extended_keys || actor.extended_key;
 
492
    },
 
493
 
 
494
    show: function () {
 
495
        this._redraw();
 
496
 
 
497
        Main.layoutManager.showKeyboard();
 
498
        this._destroySource();
 
499
    },
 
500
 
 
501
    hide: function () {
 
502
        Main.layoutManager.hideKeyboard();
 
503
        this._createSource();
 
504
    },
 
505
 
 
506
    _moveTemporarily: function () {
 
507
        let currentWindow = global.screen.get_display().focus_window;
 
508
        let rect = currentWindow.get_outer_rect();
 
509
 
 
510
        let newX = rect.x;
 
511
        let newY = 3 * this.actor.height / 2;
 
512
        currentWindow.move_frame(true, newX, newY);
 
513
    },
 
514
 
 
515
    _setLocation: function (x, y) {
 
516
        if (y >= 2 * this.actor.height)
 
517
            this._moveTemporarily();
 
518
    },
 
519
 
 
520
    // _compareTimestamp:
 
521
    //
 
522
    // Compare two timestamps taking into account
 
523
    // CURRENT_TIME (0)
 
524
    _compareTimestamp: function(one, two) {
 
525
        if (one == two)
 
526
            return 0;
 
527
        if (one == Clutter.CURRENT_TIME)
 
528
            return 1;
 
529
        if (two == Clutter.CURRENT_TIME)
 
530
            return -1;
 
531
        return one - two;
 
532
    },
 
533
 
 
534
    // D-Bus methods
 
535
    Show: function(timestamp) {
 
536
        if (!this._enableKeyboard)
 
537
            return;
 
538
 
 
539
        if (this._compareTimestamp(timestamp, this._timestamp) < 0)
 
540
            return;
 
541
 
 
542
        if (timestamp != Clutter.CURRENT_TIME)
 
543
            this._timestamp = timestamp;
 
544
        this.show();
 
545
    },
 
546
 
 
547
    Hide: function(timestamp) {
 
548
        if (!this._enableKeyboard)
 
549
            return;
 
550
 
 
551
        if (this._compareTimestamp(timestamp, this._timestamp) < 0)
 
552
            return;
 
553
 
 
554
        if (timestamp != Clutter.CURRENT_TIME)
 
555
            this._timestamp = timestamp;
 
556
        this.hide();
 
557
    },
 
558
 
 
559
    SetCursorLocation: function(x, y, w, h) {
 
560
        if (!this._enableKeyboard)
 
561
            return;
 
562
 
 
563
//        this._setLocation(x, y);
 
564
    },
 
565
 
 
566
    SetEntryLocation: function(x, y, w, h) {
 
567
        if (!this._enableKeyboard)
 
568
            return;
 
569
 
 
570
//        this._setLocation(x, y);
 
571
    },
 
572
 
 
573
    get Name() {
 
574
        return 'gnome-shell';
 
575
    }
 
576
});
 
577
 
 
578
const KeyboardSource = new Lang.Class({
 
579
    Name: 'KeyboardSource',
 
580
    Extends: MessageTray.Source,
 
581
 
 
582
    _init: function(keyboard) {
 
583
        this._keyboard = keyboard;
 
584
        this.parent(_("Keyboard"), 'input-keyboard-symbolic');
 
585
        this.keepTrayOnSummaryClick = true;
 
586
    },
 
587
 
 
588
    handleSummaryClick: function() {
 
589
        let event = Clutter.get_current_event();
 
590
        if (event.type() != Clutter.EventType.BUTTON_RELEASE)
 
591
            return false;
 
592
 
 
593
        this.open();
 
594
        return true;
 
595
    },
 
596
 
 
597
    open: function() {
 
598
        this._keyboard.show();
 
599
    }
 
600
});