keyboard: create and destroy this.actor

Rather than having Main.keyboard.actor always exist, and creating and
destroying only its contents, create and destroy that actor as well.

https://bugzilla.gnome.org/show_bug.cgi?id=657986
This commit is contained in:
Dan Winship 2011-09-01 11:01:48 -04:00
parent d99f08b9c4
commit 9752fda1f6

View File

@ -200,10 +200,9 @@ Keyboard.prototype = {
_init: function () { _init: function () {
DBus.session.exportObject('/org/gnome/Caribou/Keyboard', this); DBus.session.exportObject('/org/gnome/Caribou/Keyboard', this);
this.actor = null;
this._timestamp = global.get_current_time(); this._timestamp = global.get_current_time();
this.actor = new St.BoxLayout({ name: 'keyboard', vertical: true, reactive: true });
Main.layoutManager.keyboardBox.add_actor(this.actor);
Main.layoutManager.trackChrome(this.actor);
Main.layoutManager.connect('monitors-changed', Lang.bind(this, this._redraw)); Main.layoutManager.connect('monitors-changed', Lang.bind(this, this._redraw));
this._keyboardSettings = new Gio.Settings({ schema: KEYBOARD_SCHEMA }); this._keyboardSettings = new Gio.Settings({ schema: KEYBOARD_SCHEMA });
@ -212,8 +211,7 @@ Keyboard.prototype = {
}, },
init: function () { init: function () {
if (this._enableKeyboard) this._redraw();
this._redraw();
}, },
_settingsChanged: function () { _settingsChanged: function () {
@ -238,12 +236,17 @@ Keyboard.prototype = {
if (this._focusNotifyId) if (this._focusNotifyId)
global.stage.disconnect(this._focusNotifyId); global.stage.disconnect(this._focusNotifyId);
this._keyboard = null; this._keyboard = null;
this.actor.destroy_children(); this.actor.destroy();
this.actor = null;
this._destroySource(); this._destroySource();
}, },
_setupKeyboard: function() { _setupKeyboard: function() {
this.actor = new St.BoxLayout({ name: 'keyboard', vertical: true, reactive: true });
Main.layoutManager.keyboardBox.add_actor(this.actor);
Main.layoutManager.trackChrome(this.actor);
this._keyboard = new Caribou.KeyboardModel({ keyboard_type: this._keyboardSettings.get_string(KEYBOARD_TYPE) }); this._keyboard = new Caribou.KeyboardModel({ keyboard_type: this._keyboardSettings.get_string(KEYBOARD_TYPE) });
this._groups = {}; this._groups = {};
this._current_page = null; this._current_page = null;
@ -358,6 +361,9 @@ Keyboard.prototype = {
}, },
_redraw: function () { _redraw: function () {
if (!this._enableKeyboard)
return;
let monitor = Main.layoutManager.bottomMonitor; let monitor = Main.layoutManager.bottomMonitor;
let maxHeight = monitor.height / 3; let maxHeight = monitor.height / 3;
this.actor.width = monitor.width; this.actor.width = monitor.width;