[gnome-shell] app-menu: Update clip on icon size changes



commit d97657b15140cba41e079aa41ca355a97f10eee8
Author: Florian Müllner <fmuellner gnome org>
Date:   Tue Mar 29 11:49:50 2011 +0200

    app-menu: Update clip on icon size changes
    
    To keep the app icon from overlapping the panel's (border-image)
    border, a custom property for clipping the app menu icon's bottom
    was introduced. But if the clip region is set before the initial
    icon is set, the entire actor ends up clipped. Also due to the double
    meaning of clutter_actor_get_height() (e.g. preferred height versus
    allocated height), the clip region may end up too large and the icon
    overlaps the panel's border-image.
    Fix both problems by updating the clip region on size changes as
    well, rather than on style changes only.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=644122

 js/ui/panel.js |   17 +++++++++++++----
 1 files changed, 13 insertions(+), 4 deletions(-)
---
diff --git a/js/ui/panel.js b/js/ui/panel.js
index 8aa3265..74183a0 100644
--- a/js/ui/panel.js
+++ b/js/ui/panel.js
@@ -260,10 +260,14 @@ AppMenuButton.prototype = {
         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();
         this._container.add_actor(this._label.actor);
 
+        this._iconBottomClip = 0;
+
         this._quitMenu = new PopupMenu.PopupMenuItem('');
         this.menu.addMenuItem(this._quitMenu);
         this._quitMenu.connect('activate', Lang.bind(this, this._onQuit));
@@ -334,11 +338,16 @@ AppMenuButton.prototype = {
 
     _onIconBoxStyleChanged: function() {
         let node = this._iconBox.get_theme_node();
-        let bottomClip = node.get_length('app-icon-bottom-clip');
-        if (bottomClip > 0)
+        this._iconBottomClip = node.get_length('app-icon-bottom-clip');
+        this._updateIconBoxClip();
+    },
+
+    _updateIconBoxClip: function() {
+        let allocation = this._iconBox.allocation;
+        if (this._iconBottomClip > 0)
             this._iconBox.set_clip(0, 0,
-                                   this._iconBox.width,
-                                   this._iconBox.height - bottomClip);
+                                   allocation.x2 - allocation.x1,
+                                   allocation.y2 - allocation.y1 - this._iconBottomClip);
         else
             this._iconBox.remove_clip();
     },



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