diff options
author | Georges Basile Stavracas Neto <georges.stavracas@gmail.com> | 2019-02-07 17:54:35 -0200 |
---|---|---|
committer | Georges Basile Stavracas Neto <georges.stavracas@gmail.com> | 2019-02-07 17:54:35 -0200 |
commit | 5813850fe14f5e18397e26da20531f357b459e55 (patch) | |
tree | 34978121d3d7709af72a9c7ad2597e30ce2edd58 | |
parent | 1ee73ac3577b90d42456104bbe98e815002347ba (diff) | |
download | gnome-shell-gbsneto/fix-long-user-names.tar.gz |
system: Use username if full name is longer than 100 charactersgbsneto/fix-long-user-names
The current code relies on unstable behavior of ClutterText, and
does not really work as expected. Still, limiting the label size
is important.
Use a hardcoded limit of 100 characters instead of checking if
the layout is ellipsized already.
-rw-r--r-- | js/ui/status/system.js | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/js/ui/status/system.js b/js/ui/status/system.js index b4110782e..825011e70 100644 --- a/js/ui/status/system.js +++ b/js/ui/status/system.js @@ -164,18 +164,15 @@ var Indicator = class extends PanelMenu.SystemIndicator { } _updateSwitchUserSubMenu() { - this._switchUserSubMenu.label.text = this._user.get_real_name(); - let clutterText = this._switchUserSubMenu.label.clutter_text; + let realName = this._user.get_real_name(); - // 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()) + // In theory, GNOME allows creating users with names up to 255 + // characters, but such long names look terribly bad, so limit + // to 100 and it should fit the vast majority of screen sizes. + if (realName.length > 100) this._switchUserSubMenu.label.text = this._user.get_user_name(); + else + this._switchUserSubMenu.label.text = realName; let iconFile = this._user.get_icon_file(); if (iconFile && !GLib.file_test(iconFile, GLib.FileTest.EXISTS)) |