[gnome-shell-extensions/wip/window-list: 7/13] Minimize to taskbar



commit 1df42203272a0ca3b71e23103eae79722ddb96f3
Author: Florian MÃllner <fmuellner gnome org>
Date:   Wed Jan 23 01:22:01 2013 +0100

    Minimize to taskbar

 extensions/window-list/extension.js |   49 +++++++++++++++++++++++++++++-----
 1 files changed, 41 insertions(+), 8 deletions(-)
---
diff --git a/extensions/window-list/extension.js b/extensions/window-list/extension.js
index f2383ab..ee06dd7 100644
--- a/extensions/window-list/extension.js
+++ b/extensions/window-list/extension.js
@@ -18,11 +18,15 @@ const WindowButton = new Lang.Class({
                                      child: box });
         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");
-        box.add(new St.Bin({ style_class: 'window-button-icon', child: icon }));
-
-        this._label = new St.Label({ text: metaWindow.title });
+        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));
@@ -35,16 +39,14 @@ const WindowButton = new Lang.Class({
 
         this._notifyTitleId =
             this.metaWindow.connect('notify::title',
-                                    Lang.bind(this, function() {
-                                        this._label.text = this.metaWindow.title;
-                                    }));
+                                    Lang.bind(this, this._updateTitle));
         this._notifyMinimizedId =
             this.metaWindow.connect('notify::minimized',
-                                    Lang.bind(this, this._updateStyle));
+                                    Lang.bind(this, this._minimizedChanged));
         this._notifyFocusId =
             global.display.connect('notify::focus-window',
                                    Lang.bind(this, this._updateStyle));
-        this._updateStyle();
+        this._minimizedChanged();
     },
 
     _onClicked: function() {
@@ -54,6 +56,19 @@ 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');
@@ -71,6 +86,19 @@ const WindowButton = new Lang.Class({
         this.actor.visible = this.metaWindow.located_on_workspace(workspace);
     },
 
+    _updateIconGeometry: function() {
+        let [x, y] = this.actor.get_transformed_position();
+        let [w, h] = this.actor.get_transformed_size();
+
+        let rect = new Meta.Rectangle();
+        rect.x = x + Math.floor(w / 2);
+        rect.y = y + Math.floor(h / 2);
+        rect.width = w;
+        rect.height = h;
+
+        this.metaWindow.set_icon_geometry(rect);
+    },
+
     _onDestroy: function() {
         global.window_manager.disconnect(this._switchWorkspaceId);
         this.metaWindow.disconnect(this._notifyTitleId);
@@ -261,6 +289,11 @@ const WindowList = new Lang.Class({
 
         Main.overview.disconnect(this._overviewShowingId);
         Main.overview.disconnect(this._overviewHidingId);
+
+        let windows = Meta.get_window_actors(global.screen);
+        for (let i = 0; i < windows.length; i++) {
+            windows[i].metaWindow.set_icon_geometry(null);
+        }
     }
 });
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]