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
This commit is contained in:
parent
24c8f5bb70
commit
38b38732d3
@ -7,7 +7,6 @@ const { Clutter, GLib, GObject, St } = imports.gi;
|
|||||||
|
|
||||||
const Params = imports.misc.params;
|
const Params = imports.misc.params;
|
||||||
|
|
||||||
const UNKNOWN_AVATAR_ICON_SIZE = -1;
|
|
||||||
var AVATAR_ICON_SIZE = 64;
|
var AVATAR_ICON_SIZE = 64;
|
||||||
|
|
||||||
// Adapted from gdm/gui/user-switch-applet/applet.c
|
// Adapted from gdm/gui/user-switch-applet/applet.c
|
||||||
@ -22,7 +21,7 @@ class Avatar extends St.Bin {
|
|||||||
params = Params.parse(params, {
|
params = Params.parse(params, {
|
||||||
styleClass: 'user-icon',
|
styleClass: 'user-icon',
|
||||||
reactive: false,
|
reactive: false,
|
||||||
iconSize: UNKNOWN_AVATAR_ICON_SIZE,
|
iconSize: AVATAR_ICON_SIZE,
|
||||||
});
|
});
|
||||||
|
|
||||||
super._init({
|
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) {
|
setSensitive(sensitive) {
|
||||||
this.reactive = sensitive;
|
this.reactive = sensitive;
|
||||||
}
|
}
|
||||||
|
|
||||||
update() {
|
update() {
|
||||||
let iconSize = this._getIconSize();
|
|
||||||
|
|
||||||
let iconFile = null;
|
let iconFile = null;
|
||||||
if (this._user) {
|
if (this._user) {
|
||||||
iconFile = this._user.get_icon_file();
|
iconFile = this._user.get_icon_file();
|
||||||
@ -98,8 +88,8 @@ class Avatar extends St.Bin {
|
|||||||
|
|
||||||
let { scaleFactor } = St.ThemeContext.get_for_stage(global.stage);
|
let { scaleFactor } = St.ThemeContext.get_for_stage(global.stage);
|
||||||
this.set_size(
|
this.set_size(
|
||||||
iconSize * scaleFactor,
|
this._iconSize * scaleFactor,
|
||||||
iconSize * scaleFactor);
|
this._iconSize * scaleFactor);
|
||||||
this.style = `
|
this.style = `
|
||||||
background-image: url("${iconFile}");
|
background-image: url("${iconFile}");
|
||||||
background-size: cover;`;
|
background-size: cover;`;
|
||||||
@ -107,7 +97,7 @@ class Avatar extends St.Bin {
|
|||||||
this.style = null;
|
this.style = null;
|
||||||
this.child = new St.Icon({
|
this.child = new St.Icon({
|
||||||
icon_name: 'avatar-default-symbolic',
|
icon_name: 'avatar-default-symbolic',
|
||||||
icon_size: iconSize,
|
icon_size: this._iconSize,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user