[gnome-shell] userWidget: Simplify icon size setting a bit



commit 38b38732d3c744cc25f7270c7e22946e6da8d19a
Author: Jonas Dreßler <verdre v0yd nl>
Date:   Sun Feb 16 23:03:14 2020 +0100

    userWidget: Simplify icon size setting a bit
    
    Remove the default icon size of -1 and always set the container StBin to
    a real size. This fixes an error where the "width" and "height"
    properties get set to -2 (which is -1 * scaleFactor) in the `_init`
    function.
    
    https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/1018

 js/ui/userWidget.js | 18 ++++--------------
 1 file changed, 4 insertions(+), 14 deletions(-)
---
diff --git a/js/ui/userWidget.js b/js/ui/userWidget.js
index e5f7883381..d749ceebe2 100644
--- a/js/ui/userWidget.js
+++ b/js/ui/userWidget.js
@@ -7,7 +7,6 @@ const { Clutter, GLib, GObject, St } = imports.gi;
 
 const Params = imports.misc.params;
 
-const UNKNOWN_AVATAR_ICON_SIZE = -1;
 var AVATAR_ICON_SIZE = 64;
 
 // Adapted from gdm/gui/user-switch-applet/applet.c
@@ -22,7 +21,7 @@ class Avatar extends St.Bin {
         params = Params.parse(params, {
             styleClass: 'user-icon',
             reactive: false,
-            iconSize: UNKNOWN_AVATAR_ICON_SIZE,
+            iconSize: AVATAR_ICON_SIZE,
         });
 
         super._init({
@@ -72,20 +71,11 @@ class Avatar extends St.Bin {
         }
     }
 
-    _getIconSize() {
-        if (this._iconSize !== UNKNOWN_AVATAR_ICON_SIZE)
-            return this._iconSize;
-        else
-            return AVATAR_ICON_SIZE;
-    }
-
     setSensitive(sensitive) {
         this.reactive = sensitive;
     }
 
     update() {
-        let iconSize = this._getIconSize();
-
         let iconFile = null;
         if (this._user) {
             iconFile = this._user.get_icon_file();
@@ -98,8 +88,8 @@ class Avatar extends St.Bin {
 
             let { scaleFactor } = St.ThemeContext.get_for_stage(global.stage);
             this.set_size(
-                iconSize * scaleFactor,
-                iconSize * scaleFactor);
+                this._iconSize * scaleFactor,
+                this._iconSize * scaleFactor);
             this.style = `
                 background-image: url("${iconFile}");
                 background-size: cover;`;
@@ -107,7 +97,7 @@ class Avatar extends St.Bin {
             this.style = null;
             this.child = new St.Icon({
                 icon_name: 'avatar-default-symbolic',
-                icon_size: iconSize,
+                icon_size: this._iconSize,
             });
         }
     }


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