[gnome-shell/user-status-update: 1/5] popup-menu-item: Add option to ignore columns



commit 5ec4042e7eca7837e33033f13c0063089f7c0e79
Author: Florian MÃllner <fmuellner gnome org>
Date:   Fri Jul 1 18:23:33 2011 +0200

    popup-menu-item: Add option to ignore columns
    
    Currently all items in a popup menu share a common column layout,
    i.e. the width of any child actor of an item is determined by the
    widest actor in the menu at the same horizontal position.
    As it makes sense for some items to be independent from other items
    in the menu, add an option to excempt items from the overall layout.

 js/ui/popupMenu.js |   17 +++++++++++++----
 1 files changed, 13 insertions(+), 4 deletions(-)
---
diff --git a/js/ui/popupMenu.js b/js/ui/popupMenu.js
index 9e256b5..a643745 100644
--- a/js/ui/popupMenu.js
+++ b/js/ui/popupMenu.js
@@ -24,6 +24,7 @@ PopupBaseMenuItem.prototype = {
         params = Params.parse (params, { reactive: true,
                                          activate: true,
                                          hover: true,
+                                         ignoreColumns: false,
                                          style_class: null
                                        });
         this.actor = new Shell.GenericContainer({ style_class: 'popup-menu-item',
@@ -39,6 +40,7 @@ PopupBaseMenuItem.prototype = {
         this._children = [];
         this._dot = null;
         this._columnWidths = null;
+        this._ignoreColumns = params.ignoreColumns;
         this._spacing = 0;
         this.active = false;
 
@@ -174,6 +176,8 @@ PopupBaseMenuItem.prototype = {
     // to the image), not in visual order (left to right)
     getColumnWidths: function() {
         let widths = [];
+        if (this._ignoreColumns)
+            return widths;
         for (let i = 0, col = 0; i < this._children.length; i++) {
             let child = this._children[i];
             let [min, natural] = child.actor.get_preferred_width(-1);
@@ -192,7 +196,7 @@ PopupBaseMenuItem.prototype = {
 
     _getPreferredWidth: function(actor, forHeight, alloc) {
         let width = 0;
-        if (this._columnWidths) {
+        if (!this._ignoreColumns && this._columnWidths) {
             for (let i = 0; i < this._columnWidths.length; i++) {
                 if (i > 0)
                     width += this._spacing;
@@ -250,6 +254,7 @@ PopupBaseMenuItem.prototype = {
             x = box.x1;
         else
             x = box.x2;
+
         // if direction is ltr, x is the right edge of the last added
         // actor, and it's constantly increasing, whereas if rtl, x is
         // the left edge and it decreases
@@ -266,9 +271,13 @@ PopupBaseMenuItem.prototype = {
                     else
                         availWidth = x - box.x1;
                 } else {
-                    availWidth = 0;
-                    for (let j = 0; j < child.span; j++)
-                        availWidth += this._columnWidths[col++];
+                    if (this._ignoreColumns) {
+                        availWidth = naturalWidth;
+                    } else {
+                        availWidth = 0;
+                        for (let j = 0; j < child.span; j++)
+                            availWidth += this._columnWidths[col++];
+                    }
                 }
                 extraWidth = availWidth - naturalWidth;
             } else {



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