messageTray: Inherit Notification, Source and NotificationPolicy from GObject
Register notifications, sources and policies as GObject gtypes so that they can be passed in signals and use native properties and signals. Reimplement all the extending classes. https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/559
This commit is contained in:

committed by
Florian Müllner

parent
7059dcced3
commit
b5676a2a5c
@ -1,7 +1,7 @@
|
||||
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
|
||||
/* exported NotificationDaemon */
|
||||
|
||||
const { GdkPixbuf, Gio, GLib, Shell, St } = imports.gi;
|
||||
const { GdkPixbuf, Gio, GLib, GObject, Shell, St } = imports.gi;
|
||||
|
||||
const Config = imports.misc.config;
|
||||
const Main = imports.ui.main;
|
||||
@ -412,10 +412,10 @@ var FdoNotificationDaemon = class FdoNotificationDaemon {
|
||||
}
|
||||
};
|
||||
|
||||
var FdoNotificationDaemonSource =
|
||||
var FdoNotificationDaemonSource = GObject.registerClass(
|
||||
class FdoNotificationDaemonSource extends MessageTray.Source {
|
||||
constructor(title, pid, sender, appId) {
|
||||
super(title);
|
||||
_init(title, pid, sender, appId) {
|
||||
super._init(title);
|
||||
|
||||
this.pid = pid;
|
||||
this.app = this._getApp(appId);
|
||||
@ -464,7 +464,7 @@ class FdoNotificationDaemonSource extends MessageTray.Source {
|
||||
if (notification.resident && this.app && tracker.focus_app == this.app)
|
||||
this.pushNotification(notification);
|
||||
else
|
||||
this.notify(notification);
|
||||
this.showNotification(notification);
|
||||
}
|
||||
|
||||
_getApp(appId) {
|
||||
@ -526,7 +526,7 @@ class FdoNotificationDaemonSource extends MessageTray.Source {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
const PRIORITY_URGENCY_MAP = {
|
||||
low: MessageTray.Urgency.LOW,
|
||||
@ -535,10 +535,10 @@ const PRIORITY_URGENCY_MAP = {
|
||||
urgent: MessageTray.Urgency.CRITICAL
|
||||
};
|
||||
|
||||
var GtkNotificationDaemonNotification =
|
||||
var GtkNotificationDaemonNotification = GObject.registerClass(
|
||||
class GtkNotificationDaemonNotification extends MessageTray.Notification {
|
||||
constructor(source, notification) {
|
||||
super(source);
|
||||
_init(source, notification) {
|
||||
super._init(source);
|
||||
this._serialized = GLib.Variant.new('a{sv}', notification);
|
||||
|
||||
let { title,
|
||||
@ -602,7 +602,7 @@ class GtkNotificationDaemonNotification extends MessageTray.Notification {
|
||||
serialize() {
|
||||
return this._serialized;
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
const FdoApplicationIface = loadInterfaceXML('org.freedesktop.Application');
|
||||
const FdoApplicationProxy = Gio.DBusProxy.makeProxyWrapper(FdoApplicationIface);
|
||||
@ -618,9 +618,9 @@ function getPlatformData() {
|
||||
|
||||
function InvalidAppError() {}
|
||||
|
||||
var GtkNotificationDaemonAppSource =
|
||||
var GtkNotificationDaemonAppSource = GObject.registerClass(
|
||||
class GtkNotificationDaemonAppSource extends MessageTray.Source {
|
||||
constructor(appId) {
|
||||
_init(appId) {
|
||||
let objectPath = objectPathFromAppId(appId);
|
||||
if (!GLib.Variant.is_object_path(objectPath))
|
||||
throw new InvalidAppError();
|
||||
@ -629,7 +629,7 @@ class GtkNotificationDaemonAppSource extends MessageTray.Source {
|
||||
if (!app)
|
||||
throw new InvalidAppError();
|
||||
|
||||
super(app.get_name());
|
||||
super._init(app.get_name());
|
||||
|
||||
this._appId = appId;
|
||||
this._app = app;
|
||||
@ -690,7 +690,7 @@ class GtkNotificationDaemonAppSource extends MessageTray.Source {
|
||||
this._notifications[notificationId] = notification;
|
||||
|
||||
if (showBanner)
|
||||
this.notify(notification);
|
||||
this.showNotification(notification);
|
||||
else
|
||||
this.pushNotification(notification);
|
||||
|
||||
@ -716,7 +716,7 @@ class GtkNotificationDaemonAppSource extends MessageTray.Source {
|
||||
}
|
||||
return [this._appId, notifications];
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
const GtkNotificationsIface = loadInterfaceXML('org.gtk.Notifications');
|
||||
|
||||
@ -742,7 +742,7 @@ var GtkNotificationDaemon = class GtkNotificationDaemon {
|
||||
delete this._sources[appId];
|
||||
this._saveNotifications();
|
||||
});
|
||||
source.connect('count-updated', this._saveNotifications.bind(this));
|
||||
source.connect('notify::count', this._saveNotifications.bind(this));
|
||||
Main.messageTray.add(source);
|
||||
this._sources[appId] = source;
|
||||
return source;
|
||||
|
Reference in New Issue
Block a user