messageTray: Expose Source icon as GObject property

As the notification redesign affects the API anyway, we can just
as well use the opportunity to modernize the code.

Turning the icon into a GObject property means we no longer need
a custom signal for change notifications, and the icon becomes
usable in bindings.

Since setting an `GThemedIcon` is common this also adds a convenience
property to set the icon name directly.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3103>
This commit is contained in:
Julian Sparber
2024-01-24 12:25:21 +01:00
committed by Marge Bot
parent 1b49cc643c
commit 00a375ce9b
9 changed files with 52 additions and 90 deletions

View File

@ -383,7 +383,7 @@ class ChatSource extends MessageTray.Source {
this._notification.appendAliasChange(oldAlias, newAlias);
}
getIcon() {
get icon() {
let file = this._contact.get_avatar_file();
if (file)
return new Gio.FileIcon({file});
@ -392,12 +392,12 @@ class ChatSource extends MessageTray.Source {
}
_updateAvatarIcon() {
this.iconUpdated();
this.notify('icon');
if (this._notification) {
this._notification.update(
this._notification.title,
this._notification.bannerBodyText,
{gicon: this.getIcon()});
{gicon: this.icon});
}
}