[gnome-shell] popupMenu: Remove non-all-spanning versions of colspan in popup menus
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] popupMenu: Remove non-all-spanning versions of colspan in popup menus
- Date: Wed, 17 Jul 2013 16:52:58 +0000 (UTC)
commit 126f0ed95d5b25531b395988533d84692e46e648
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Mon Jul 15 19:05:46 2013 -0400
popupMenu: Remove non-all-spanning versions of colspan in popup menus
This simplifies the code considerably, and makes 'expand' behave as expected.
https://bugzilla.gnome.org/show_bug.cgi?id=704336
js/ui/popupMenu.js | 36 ++++++++++++------------------------
js/ui/userMenu.js | 2 +-
2 files changed, 13 insertions(+), 25 deletions(-)
---
diff --git a/js/ui/popupMenu.js b/js/ui/popupMenu.js
index 7aaecf5..53f9a31 100644
--- a/js/ui/popupMenu.js
+++ b/js/ui/popupMenu.js
@@ -172,14 +172,11 @@ const PopupBaseMenuItem = new Lang.Class({
this.emit('destroy');
},
- // adds an actor to the menu item; @params can contain %span
- // (column span; defaults to 1, -1 means "all the remaining width"),
+ // adds an actor to the menu item; @params can contain
// %expand (defaults to #false), and %align (defaults to
// #St.Align.START)
addActor: function(child, params) {
- params = Params.parse(params, { span: 1,
- expand: false,
- align: St.Align.START });
+ params = Params.parse(params, { expand: false, align: St.Align.START });
params.actor = child;
this._children.push(params);
this.actor.connect('destroy', Lang.bind(this, function () { this._removeChild(child); }));
@@ -226,10 +223,6 @@ const PopupBaseMenuItem = new Lang.Class({
let child = this._children[i];
let [min, natural] = child.actor.get_preferred_width(-1);
widths[col++] = natural;
- if (child.span > 1) {
- for (let j = 1; j < child.span; j++)
- widths[col++] = 0;
- }
}
return widths;
},
@@ -263,14 +256,14 @@ const PopupBaseMenuItem = new Lang.Class({
for (let i = 0; i < this._children.length; i++) {
let child = this._children[i];
if (this._columnWidths) {
- if (child.span == -1) {
+ if (child.expand) {
childWidth = 0;
for (let j = i; j < this._columnWidths.length; j++)
- childWidth += this._columnWidths[j]
+ childWidth += this._columnWidths[j];
} else
childWidth = this._columnWidths[i];
} else {
- if (child.span == -1)
+ if (child.expand)
childWidth = forWidth - x;
else
[minWidth, childWidth] = child.actor.get_preferred_width(-1);
@@ -316,16 +309,13 @@ const PopupBaseMenuItem = new Lang.Class({
let [minWidth, naturalWidth] = child.actor.get_preferred_width(-1);
let availWidth;
- if (child.span == -1) {
+ if (child.expand) {
availWidth = box.x2 - x;
} else {
- if (this._columnWidths) {
- availWidth = 0;
- for (let j = 0; j < child.span; j++)
- availWidth += this._columnWidths[col++];
- } else {
+ if (this._columnWidths)
+ availWidth += this._columnWidths[col++];
+ else
availWidth = naturalWidth;
- }
}
if (direction == Clutter.TextDirection.RTL)
@@ -375,7 +365,7 @@ const PopupSeparatorMenuItem = new Lang.Class({
can_focus: false});
this._box = new St.BoxLayout();
- this.addActor(this._box, { span: -1, expand: true });
+ this.addActor(this._box, { expand: true });
this.label = new St.Label({ text: text || '' });
this._box.add(this.label);
@@ -558,8 +548,7 @@ const PopupSwitchMenuItem = new Lang.Class({
this.addActor(this.label);
this._statusBin = new St.Bin({ x_align: St.Align.END });
- this.addActor(this._statusBin,
- { expand: true, span: -1, align: St.Align.END });
+ this.addActor(this._statusBin, { expand: true, align: St.Align.END });
this._statusLabel = new St.Label({ text: '',
style_class: 'popup-status-menu-item'
@@ -1546,8 +1535,7 @@ const PopupComboBoxMenuItem = new Lang.Class({
this.addActor(this._itemBox);
let expander = new St.Label({ text: '\u2304' });
- this.addActor(expander, { align: St.Align.END,
- span: -1 });
+ this.addActor(expander, { align: St.Align.END });
this._menu = new PopupComboMenu(this.actor);
Main.uiGroup.add_actor(this._menu.actor);
diff --git a/js/ui/userMenu.js b/js/ui/userMenu.js
index 68a300a..820a0b8 100644
--- a/js/ui/userMenu.js
+++ b/js/ui/userMenu.js
@@ -92,7 +92,7 @@ const IMUserNameItem = new Lang.Class({
Lang.bind(this, this._wrapperGetPreferredHeight));
this._wrapper.connect('allocate',
Lang.bind(this, this._wrapperAllocate));
- this.addActor(this._wrapper, { expand: true, span: -1 });
+ this.addActor(this._wrapper, { expand: true });
this.label = new St.Label();
this.label.clutter_text.set_line_wrap(true);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]