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
This commit is contained in:
parent
508e751ffd
commit
f8e5e3e435
@ -823,8 +823,7 @@ StScrollBar {
|
|||||||
color: transparent; }
|
color: transparent; }
|
||||||
|
|
||||||
.aggregate-menu {
|
.aggregate-menu {
|
||||||
min-width: 280px;
|
min-width: 280px; }
|
||||||
max-width: 400px; }
|
|
||||||
.aggregate-menu .popup-menu-icon {
|
.aggregate-menu .popup-menu-icon {
|
||||||
padding: 0 4px; }
|
padding: 0 4px; }
|
||||||
|
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit 01253d8545395de215c200cfe1be1b4667b9fa0b
|
Subproject commit 83b896b0e13725d7045ba3708265f6689952586c
|
@ -823,8 +823,7 @@ StScrollBar {
|
|||||||
color: transparent; }
|
color: transparent; }
|
||||||
|
|
||||||
.aggregate-menu {
|
.aggregate-menu {
|
||||||
min-width: 280px;
|
min-width: 280px; }
|
||||||
max-width: 400px; }
|
|
||||||
.aggregate-menu .popup-menu-icon {
|
.aggregate-menu .popup-menu-icon {
|
||||||
padding: 0 4px; }
|
padding: 0 4px; }
|
||||||
|
|
||||||
|
@ -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({
|
const AggregateMenu = new Lang.Class({
|
||||||
Name: 'AggregateMenu',
|
Name: 'AggregateMenu',
|
||||||
Extends: PanelMenu.Button,
|
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.parent(0.0, C_("System menu in the top bar", "System"), false);
|
||||||
this.menu.actor.add_style_class_name('aggregate-menu');
|
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._indicators = new St.BoxLayout({ style_class: 'panel-status-indicators-box' });
|
||||||
this.actor.add_child(this._indicators);
|
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._rfkill.menu);
|
||||||
this.menu.addMenuItem(this._power.menu);
|
this.menu.addMenuItem(this._power.menu);
|
||||||
this.menu.addMenuItem(this._system.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);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user