[gnome-shell] aggregateMenu: Ignore ellipsizable items in width-request



commit f8e5e3e435fb151e46f6d5dfa34fb83de3b6a7fd
Author: Florian Müllner <fmuellner gnome org>
Date:   Sun Oct 4 03:07:32 2015 +0200

    aggregateMenu: Ignore ellipsizable items in width-request
    
    Some labels in the system status menu - namely network names - are out
    of our control, and may thus grow the width "infinitively" unless we
    restrict the menu width. So far we have been doing this by setting a
    fixed width or max-width, but any value we put there might end up
    being too restrictive in some locales. Instead, request a width that
    fits all the labels we want to show unellipsized and use that instead
    of an arbitrary limit.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=708472

 data/theme/gnome-shell-high-contrast.css |    3 +-
 data/theme/gnome-shell-sass              |    2 +-
 data/theme/gnome-shell.css               |    3 +-
 js/ui/panel.js                           |   41 ++++++++++++++++++++++++++++++
 4 files changed, 44 insertions(+), 5 deletions(-)
---
diff --git a/data/theme/gnome-shell-high-contrast.css b/data/theme/gnome-shell-high-contrast.css
index 1be7d64..feb2b50 100644
--- a/data/theme/gnome-shell-high-contrast.css
+++ b/data/theme/gnome-shell-high-contrast.css
@@ -823,8 +823,7 @@ StScrollBar {
     color: transparent; }
 
 .aggregate-menu {
-  min-width: 280px;
-  max-width: 400px; }
+  min-width: 280px; }
   .aggregate-menu .popup-menu-icon {
     padding: 0 4px; }
 
diff --git a/data/theme/gnome-shell-sass b/data/theme/gnome-shell-sass
index 01253d8..83b896b 160000
--- a/data/theme/gnome-shell-sass
+++ b/data/theme/gnome-shell-sass
@@ -1 +1 @@
-Subproject commit 01253d8545395de215c200cfe1be1b4667b9fa0b
+Subproject commit 83b896b0e13725d7045ba3708265f6689952586c
diff --git a/data/theme/gnome-shell.css b/data/theme/gnome-shell.css
index db9af9b..6ae2302 100644
--- a/data/theme/gnome-shell.css
+++ b/data/theme/gnome-shell.css
@@ -823,8 +823,7 @@ StScrollBar {
     color: transparent; }
 
 .aggregate-menu {
-  min-width: 280px;
-  max-width: 400px; }
+  min-width: 280px; }
   .aggregate-menu .popup-menu-icon {
     padding: 0 4px; }
 
diff --git a/js/ui/panel.js b/js/ui/panel.js
index 1933681..3127db0 100644
--- a/js/ui/panel.js
+++ b/js/ui/panel.js
@@ -652,6 +652,39 @@ const PanelCorner = new Lang.Class({
     }
 });
 
+const AggregateLayout = new Lang.Class({
+    Name: 'AggregateLayout',
+    Extends: Clutter.BoxLayout,
+
+    _init: function(params) {
+        if (!params)
+            params = {};
+        params['orientation'] = Clutter.Orientation.VERTICAL;
+        this.parent(params);
+
+        this._sizeChildren = [];
+    },
+
+    addSizeChild: function(actor) {
+        this._sizeChildren.push(actor);
+        this.layout_changed();
+    },
+
+    vfunc_get_preferred_width: function(container, forHeight) {
+        let themeNode = container.get_theme_node();
+        let minWidth = themeNode.get_min_width();
+        let natWidth = minWidth;
+
+        for (let i = 0; i < this._sizeChildren.length; i++) {
+            let child = this._sizeChildren[i];
+            let [childMin, childNat] = child.get_preferred_width(forHeight);
+            minWidth = Math.max(minWidth, childMin);
+            natWidth = Math.max(minWidth, childNat);
+        }
+        return [minWidth, natWidth];
+    }
+});
+
 const AggregateMenu = new Lang.Class({
     Name: 'AggregateMenu',
     Extends: PanelMenu.Button,
@@ -660,6 +693,9 @@ const AggregateMenu = new Lang.Class({
         this.parent(0.0, C_("System menu in the top bar", "System"), false);
         this.menu.actor.add_style_class_name('aggregate-menu');
 
+        let menuLayout = new AggregateLayout();
+        this.menu.box.set_layout_manager(menuLayout);
+
         this._indicators = new St.BoxLayout({ style_class: 'panel-status-indicators-box' });
         this.actor.add_child(this._indicators);
 
@@ -708,6 +744,11 @@ const AggregateMenu = new Lang.Class({
         this.menu.addMenuItem(this._rfkill.menu);
         this.menu.addMenuItem(this._power.menu);
         this.menu.addMenuItem(this._system.menu);
+
+        menuLayout.addSizeChild(this._location.menu.actor);
+        menuLayout.addSizeChild(this._rfkill.menu.actor);
+        menuLayout.addSizeChild(this._power.menu.actor);
+        menuLayout.addSizeChild(this._system.menu.actor);
     },
 });
 


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