Use system source for update notifications

This commit is contained in:
Charles Gagnon
2025-02-21 15:28:26 -05:00
parent 2ebf3cee16
commit bf38380999
2 changed files with 14 additions and 6 deletions

View File

@@ -88,6 +88,9 @@ export default class DashToPanelExtension extends Extension {
_('Dash to Panel has been updated!'),
_(`You are now running version ${this.metadata.version}.`),
'software-update-available-symbolic',
Gio.icon_new_for_string(
`${this.path}/img/dash-to-panel-logo-light.svg`,
),
{
text: _(`See what's new`),
func: () =>

View File

@@ -528,18 +528,24 @@ export const getPoint = function (coords) {
return new Graphene.Point(coords)
}
export const notify = function (title, body, iconName, action, isTransient) {
let source = new MessageTray.Source({
title: 'Dash to Panel',
})
export const notify = function (
title,
body,
sourceIconName,
notificationIcon,
action,
isTransient,
) {
let source = MessageTray.getSystemSource()
let notification = new MessageTray.Notification({
source,
title,
body,
isTransient: isTransient || false,
gicon: notificationIcon || null,
})
if (iconName) source.iconName = iconName
if (sourceIconName) source.iconName = sourceIconName
if (action) {
if (!(action instanceof Array)) {
@@ -549,7 +555,6 @@ export const notify = function (title, body, iconName, action, isTransient) {
action.forEach((a) => notification.addAction(a.text, a.func))
}
Main.messageTray.add(source)
source.addNotification(notification)
}