Skip to content

Commit 7cd9b74

Browse files
committed
Make notifications applet multi-instance
1 parent 501a250 commit 7cd9b74

3 files changed

Lines changed: 14 additions & 12 deletions

File tree

files/usr/share/cinnamon/applets/notifications@cinnamon.org/applet.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,18 @@ class CinnamonNotificationsApplet extends Applet.TextIconApplet {
6565

6666
_openMenu() {
6767
this._update_timestamp();
68+
69+
this.notifications.forEach(notification => {
70+
global.reparentActor(notification.actor, this._notificationbin);
71+
});
72+
6873
this.menu.toggle();
6974
}
7075

76+
_onMenuClosed() {
77+
this._notificationbin.remove_all_children();
78+
}
79+
7180
_display() {
7281
// Always start the applet empty, void of any notifications.
7382
this.set_applet_icon_symbolic_name("empty-notif");
@@ -138,8 +147,6 @@ class CinnamonNotificationsApplet extends Applet.TextIconApplet {
138147
if (notification._destroyed) {
139148
this.notifications.splice(existing_index, 1);
140149
} else {
141-
notification._inNotificationBin = true;
142-
global.reparentActor(notification.actor, this._notificationbin);
143150
notification._timeLabel.show();
144151
}
145152
this.update_list();
@@ -148,11 +155,8 @@ class CinnamonNotificationsApplet extends Applet.TextIconApplet {
148155
return;
149156
}
150157
// Add notification to list.
151-
notification._inNotificationBin = true;
152158
this.notifications.push(notification);
153-
// Steal the notification panel.
154-
this._notificationbin.add(notification.actor);
155-
notification.actor._parent_container = this._notificationbin;
159+
156160
notification.actor.add_style_class_name('notification-applet-padding');
157161
// Register for destruction.
158162
notification.connect('scrolling-changed', (notif, scrolling) => { this.menu.passEvents = scrolling });

files/usr/share/cinnamon/applets/notifications@cinnamon.org/metadata.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22
"uuid": "notifications@cinnamon.org",
33
"name": "Notifications",
44
"description": "Click to display and manage system notifications",
5-
"icon": "cs-notifications"
5+
"icon": "cs-notifications",
6+
"max-instances": -1
67
}

js/ui/messageTray.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -262,12 +262,10 @@ var Notification = class Notification {
262262
this._actionArea = null;
263263
this._imageBin = null;
264264
this._timestamp = new Date();
265-
this._inNotificationBin = false;
266265

267266
source.connect('destroy', (source, reason) => { this.destroy(reason) });
268267

269268
this.actor = new St.Button({ accessible_role: Atk.Role.NOTIFICATION });
270-
this.actor._parent_container = null;
271269
this.actor.connect('clicked', () => this._onClicked());
272270
this.actor.connect('destroy', () => this._onDestroy());
273271

@@ -348,7 +346,6 @@ var Notification = class Notification {
348346
*/
349347
update(title, body, params) {
350348
this._timestamp = new Date();
351-
this._inNotificationBin = false;
352349
params = Params.parse(params, {
353350
icon: null,
354351
titleMarkup: false,
@@ -929,8 +926,8 @@ MessageTray.prototype = {
929926

930927
_showNotification: function () {
931928
this._notification = this._notificationQueue.shift();
932-
if (this._notification.actor._parent_container) {
933-
this._notification.actor._parent_container.remove_actor(this._notification.actor);
929+
if (this._notification.actor.get_parent()) {
930+
this._notification.actor.get_parent().remove_actor(this._notification.actor);
934931
}
935932

936933
this._notificationBin.child = this._notification.actor;

0 commit comments

Comments
 (0)