messageTray: Allow settings gobject properties of Source on creation

This also makes the `icon` property of `Source` writable so that it can
be set during creation instead of overriding the getter of the icon
property.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3103>
This commit is contained in:
Julian Sparber
2024-01-25 21:52:34 +01:00
committed by Marge Bot
parent c63d67c9af
commit 932ccac1c2
11 changed files with 69 additions and 69 deletions

View File

@ -309,10 +309,13 @@ class FdoNotificationDaemonSource extends MessageTray.Source {
this.pid = pid;
this.initialTitle = title;
this.app = this._getApp(appId);
this._appIcon = null;
// Use app name as title if available, instead of whatever is provided
// through libnotify (usually garbage)
super._init(this.app ? this.app.get_name() : title);
super._init({
title: this.app?.get_name() ?? title,
});
if (sender) {
this._nameWatcherId = Gio.DBus.session.watch_name(sender,
@ -349,6 +352,7 @@ class FdoNotificationDaemonSource extends MessageTray.Source {
this.notify('icon');
}
let tracker = Shell.WindowTracker.get_default();
if (notification.resident && this.app && tracker.focus_app === this.app)
this.pushNotification(notification);
@ -397,12 +401,7 @@ class FdoNotificationDaemonSource extends MessageTray.Source {
}
get icon() {
if (this.app)
return this.app.get_icon();
else if (this._appIcon)
return this._appIcon;
else
return null;
return this.app?.get_icon() ?? this._appIcon;
}
});
@ -519,16 +518,15 @@ class GtkNotificationDaemonAppSource extends MessageTray.Source {
this._app = app;
this._objectPath = objectPath;
super._init(app.get_name());
super._init({
title: app.get_name(),
icon: app.get_icon(),
});
this._notifications = {};
this._notificationPending = false;
}
get icon() {
return this._app.get_icon();
}
_createPolicy() {
return new MessageTray.NotificationApplicationPolicy(this._appId);
}