[gnome-shell-extensions/wip/window-list: 12/13] Factor out WindowTitle
- From: Florian MÃllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell-extensions/wip/window-list: 12/13] Factor out WindowTitle
- Date: Fri, 25 Jan 2013 02:15:03 +0000 (UTC)
commit 44d92f07cab394fc761c6519b00df50898766de2
Author: Florian MÃllner <fmuellner gnome org>
Date: Thu Jan 24 22:31:57 2013 +0100
Factor out WindowTitle
extensions/window-list/extension.js | 81 ++++++++++++++++++++--------------
1 files changed, 48 insertions(+), 33 deletions(-)
---
diff --git a/extensions/window-list/extension.js b/extensions/window-list/extension.js
index fef3da9..14935bb 100644
--- a/extensions/window-list/extension.js
+++ b/extensions/window-list/extension.js
@@ -7,29 +7,65 @@ const Lang = imports.lang;
const Main = imports.ui.main;
const MessageTray = imports.ui.messageTray;
+const WindowTitle = new Lang.Class({
+ Name: 'WindowTitle',
+
+ _init: function(metaWindow) {
+ this._metaWindow = metaWindow;
+ this.actor = new St.BoxLayout();
+
+ let textureCache = St.TextureCache.get_default();
+ let icon = textureCache.bind_pixbuf_property(this._metaWindow, "icon");
+ this._icon = new St.Bin({ style_class: 'window-button-icon',
+ child: icon });
+ this.actor.add(this._icon);
+ this._label = new St.Label();
+ this.actor.add(this._label);
+
+ this.actor.connect('destroy', Lang.bind(this, this._onDestroy));
+
+ this._notifyTitleId =
+ this._metaWindow.connect('notify::title',
+ Lang.bind(this, this._updateTitle));
+ this._notifyMinimizedId =
+ this._metaWindow.connect('notify::minimized',
+ Lang.bind(this, this._minimizedChanged));
+ this._minimizedChanged();
+ },
+
+ _minimizedChanged: function() {
+ this._icon.opacity = this._metaWindow.minimized ? 128 : 255;
+ this._updateTitle();
+ },
+
+ _updateTitle: function() {
+ if (this._metaWindow.minimized)
+ this._label.text = '[%s]'.format(this._metaWindow.title);
+ else
+ this._label.text = this._metaWindow.title;
+ },
+
+ _onDestroy: function() {
+ this._metaWindow.disconnect(this._notifyTitleId);
+ this._metaWindow.disconnect(this._notifyMinimizedId);
+ }
+});
+
+
const WindowButton = new Lang.Class({
Name: 'WindowButton',
_init: function(metaWindow) {
this.metaWindow = metaWindow;
- let box = new St.BoxLayout();
+ this._windowTitle = new WindowTitle(this.metaWindow);
this.actor = new St.Button({ style_class: 'window-button',
x_fill: true,
- child: box });
+ child: this._windowTitle.actor });
this.actor._delegate = this;
this.actor.connect('allocation-changed',
Lang.bind(this, this._updateIconGeometry));
-
- let textureCache = St.TextureCache.get_default();
- let icon = textureCache.bind_pixbuf_property(this.metaWindow, "icon");
- this._icon = new St.Bin({ style_class: 'window-button-icon',
- child: icon });
- box.add(this._icon);
- this._label = new St.Label();
- box.add(this._label);
-
this.actor.connect('clicked', Lang.bind(this, this._onClicked));
this.actor.connect('destroy', Lang.bind(this, this._onDestroy));
@@ -38,16 +74,10 @@ const WindowButton = new Lang.Class({
Lang.bind(this, this._updateVisibility));
this._updateVisibility();
- this._notifyTitleId =
- this.metaWindow.connect('notify::title',
- Lang.bind(this, this._updateTitle));
- this._notifyMinimizedId =
- this.metaWindow.connect('notify::minimized',
- Lang.bind(this, this._minimizedChanged));
this._notifyFocusId =
global.display.connect('notify::focus-window',
Lang.bind(this, this._updateStyle));
- this._minimizedChanged();
+ this._updateStyle();
},
_onClicked: function() {
@@ -57,19 +87,6 @@ const WindowButton = new Lang.Class({
this.metaWindow.activate(global.get_current_time());
},
- _minimizedChanged: function() {
- this._icon.opacity = this.metaWindow.minimized ? 128 : 255;
- this._updateTitle();
- this._updateStyle();
- },
-
- _updateTitle: function() {
- if (this.metaWindow.minimized)
- this._label.text = '[%s]'.format(this.metaWindow.title);
- else
- this._label.text = this.metaWindow.title;
- },
-
_updateStyle: function() {
if (this.metaWindow.minimized)
this.actor.add_style_class_name('minimized');
@@ -105,8 +122,6 @@ const WindowButton = new Lang.Class({
_onDestroy: function() {
global.window_manager.disconnect(this._switchWorkspaceId);
- this.metaWindow.disconnect(this._notifyTitleId);
- this.metaWindow.disconnect(this._notifyMinimizedId);
global.display.disconnect(this._notifyFocusId);
}
});
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]