avatar: Use Property bindings to sync reactivity

Instead of manually updating properties on change, use native properties
bindings to keep the them synchronized.

Disable hover-tracking and focus-ability when the avatar is not sensitive.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/559
This commit is contained in:
Marco Trevisan (Treviño) 2019-08-31 01:32:03 +02:00 committed by Florian Müllner
parent 0b91dee5a9
commit db7726c5bf

View File

@ -25,7 +25,6 @@ var Avatar = GObject.registerClass({
super._init({ super._init({
style_class: params.styleClass, style_class: params.styleClass,
track_hover: params.reactive,
reactive: params.reactive, reactive: params.reactive,
width: params.iconSize * themeContext.scaleFactor, width: params.iconSize * themeContext.scaleFactor,
height: params.iconSize * themeContext.scaleFactor height: params.iconSize * themeContext.scaleFactor
@ -34,6 +33,11 @@ var Avatar = GObject.registerClass({
this._iconSize = params.iconSize; this._iconSize = params.iconSize;
this._user = user; this._user = user;
this.bind_property('reactive', this, 'track-hover',
GObject.BindingFlags.SYNC_CREATE);
this.bind_property('reactive', this, 'can-focus',
GObject.BindingFlags.SYNC_CREATE);
// Monitor the scaling factor to make sure we recreate the avatar when needed. // Monitor the scaling factor to make sure we recreate the avatar when needed.
this._scaleFactorChangeId = this._scaleFactorChangeId =
themeContext.connect('notify::scale-factor', this.update.bind(this)); themeContext.connect('notify::scale-factor', this.update.bind(this));
@ -50,7 +54,6 @@ var Avatar = GObject.registerClass({
} }
setSensitive(sensitive) { setSensitive(sensitive) {
this.can_focus = sensitive;
this.reactive = sensitive; this.reactive = sensitive;
} }