[gnome-shell] system: Use the username if the user's name is too long
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] system: Use the username if the user's name is too long
- Date: Tue, 13 Aug 2013 10:51:20 +0000 (UTC)
commit 3e4d0954b532f2f4973306627c0a72a299b3cc68
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Mon Aug 12 06:56:51 2013 -0400
system: Use the username if the user's name is too long
This is a part of the new system status design, see
https://wiki.gnome.org/GnomeShell/Design/Guidelines/SystemStatus/
for design details.
https://bugzilla.gnome.org/show_bug.cgi?id=705845
js/ui/status/system.js | 20 ++++++++++++++++++++
1 files changed, 20 insertions(+), 0 deletions(-)
---
diff --git a/js/ui/status/system.js b/js/ui/status/system.js
index a4674c7..74eb002 100644
--- a/js/ui/status/system.js
+++ b/js/ui/status/system.js
@@ -152,6 +152,17 @@ const Indicator = new Lang.Class({
_updateSwitchUserSubMenu: function() {
this._switchUserSubMenu.label.text = this._user.get_real_name();
+ let clutterText = this._switchUserSubMenu.label.clutter_text;
+
+ // XXX -- for some reason, the ClutterText's width changes
+ // rapidly unless we force a relayout of the actor. Probably
+ // a size cache issue or something. Moving this to be a layout
+ // manager would be a much better idea.
+ clutterText.get_allocation_box();
+
+ let layout = clutterText.get_layout();
+ if (layout.is_ellipsized())
+ this._switchUserSubMenu.label.text = this._user.get_user_name();
let iconFile = this._user.get_icon_file();
if (iconFile && !GLib.file_test(iconFile, GLib.FileTest.EXISTS))
@@ -210,6 +221,15 @@ const Indicator = new Lang.Class({
this._switchUserSubMenu = new PopupMenu.PopupSubMenuMenuItem('', true);
this._switchUserSubMenu.icon.style_class = 'system-switch-user-submenu-icon';
+ // Since the label of the switch user submenu depends on the width of
+ // the popup menu, and we can't easily connect on allocation-changed
+ // or notify::width without creating layout cycles, simply update the
+ // label whenever the menu is opened.
+ this.menu.connect('open-state-changed', Lang.bind(this, function(menu, isOpen) {
+ if (isOpen)
+ this._updateSwitchUserSubMenu();
+ }));
+
item = new PopupMenu.PopupMenuItem(_("Switch User"));
item.connect('activate', Lang.bind(this, this._onLoginScreenActivate));
this._switchUserSubMenu.menu.addMenuItem(item);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]