[gnome-shell] popupMenu: fix a few width-for-height cases



commit ed7d4928e5e0263562d114c92b79586cd6f3ad63
Author: Dan Winship <danw gnome org>
Date:   Mon Sep 19 16:46:38 2011 -0400

    popupMenu: fix a few width-for-height cases
    
    specifically, non-columned menus, and span==-1
    
    https://bugzilla.gnome.org/show_bug.cgi?id=652837

 js/ui/popupMenu.js |   24 +++++++++++++++++++++---
 1 files changed, 21 insertions(+), 3 deletions(-)
---
diff --git a/js/ui/popupMenu.js b/js/ui/popupMenu.js
index ac831e2..0ce16f9 100644
--- a/js/ui/popupMenu.js
+++ b/js/ui/popupMenu.js
@@ -244,10 +244,25 @@ PopupBaseMenuItem.prototype = {
     },
 
     _getPreferredHeight: function(actor, forWidth, alloc) {
-        let height = 0;
+        let height = 0, x = 0, minWidth, childWidth;
         for (let i = 0; i < this._children.length; i++) {
             let child = this._children[i];
-            let [min, natural] = child.actor.get_preferred_height(forWidth);
+            if (this._columnWidths) {
+                if (child.span == -1) {
+                    childWidth = 0;
+                    for (let j = i; j < this._columnWidths.length; j++)
+                        childWidth += this._columnWidths[j]
+                } else
+                    childWidth = this._columnWidths[i];
+            } else {
+                if (child.span == -1)
+                    childWidth = forWidth - x;
+                else
+                    [minWidth, childWidth] = child.actor.get_preferred_width(-1);
+            }
+            x += childWidth;
+
+            let [min, natural] = child.actor.get_preferred_height(childWidth);
             if (natural > height)
                 height = natural;
         }
@@ -305,7 +320,10 @@ PopupBaseMenuItem.prototype = {
                 }
                 extraWidth = availWidth - naturalWidth;
             } else {
-                availWidth = naturalWidth;
+                if (child.span == -1)
+                    availWidth = box.x2 - x;
+                else
+                    availWidth = naturalWidth;
                 extraWidth = 0;
             }
 



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