[gnome-shell/wip/sass: 6/52] theme: scale down the app menu icon to fit



commit f3b6ad0961c8f0b41e265f8e7607075c9e77eb88
Author: Jakub Steiner <jimmac gmail com>
Date:   Fri Jan 9 13:31:03 2015 +0100

    theme: scale down the app menu icon to fit

 js/ui/panel.js |   24 +++++++++++++++++++++++-
 1 files changed, 23 insertions(+), 1 deletions(-)
---
diff --git a/js/ui/panel.js b/js/ui/panel.js
index 89fd5e6..8edd46b 100644
--- a/js/ui/panel.js
+++ b/js/ui/panel.js
@@ -198,6 +198,10 @@ const AppMenuButton = new Lang.Class({
                              Lang.bind(this, this._onIconThemeChanged));
 
         this._iconBox = new Shell.Slicer({ name: 'appMenuIcon' });
+        this._iconBox.connect('style-changed',
+                              Lang.bind(this, this._onIconBoxStyleChanged));
+        this._iconBox.connect('notify::allocation',
+                              Lang.bind(this, this._updateIconBoxClip));
         this._container.add_actor(this._iconBox);
 
         this._label = new TextShadower();
@@ -206,6 +210,8 @@ const AppMenuButton = new Lang.Class({
         this._arrow = PopupMenu.arrowIcon(St.Side.BOTTOM);
         this._container.add_actor(this._arrow);
 
+        this._iconBottomClip = 0;
+
         this._visible = !Main.overview.visible;
         if (!this._visible)
             this.actor.hide();
@@ -270,11 +276,17 @@ const AppMenuButton = new Lang.Class({
         this._spinner.actor.hide();
     },
 
+    _onIconBoxStyleChanged: function() {
+        let node = this._iconBox.get_theme_node();
+        this._iconBottomClip = node.get_length('app-icon-bottom-clip');
+        this._updateIconBoxClip();
+    },
+
     _syncIcon: function() {
         if (!this._targetApp)
             return;
 
-        let icon = this._targetApp.create_icon_texture(PANEL_ICON_SIZE);
+        let icon = this._targetApp.create_icon_texture(PANEL_ICON_SIZE - 2);
         this._iconBox.set_child(icon);
     },
 
@@ -285,6 +297,16 @@ const AppMenuButton = new Lang.Class({
         this._syncIcon();
     },
 
+    _updateIconBoxClip: function() {
+        let allocation = this._iconBox.allocation;
+        if (this._iconBottomClip > 0)
+            this._iconBox.set_clip(0, 0,
+                                   allocation.x2 - allocation.x1,
+                                   allocation.y2 - allocation.y1 - this._iconBottomClip);
+        else
+            this._iconBox.remove_clip();
+    },
+
     stopAnimation: function() {
         if (this._stop)
             return;


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