Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class CinnamonNotificationsApplet extends Applet.TextIconApplet {
this.settings.bind("keyOpen", "keyOpen", this._setKeybinding);
this.settings.bind("keyClear", "keyClear", this._setKeybinding);
this.settings.bind("showNotificationCount", "showNotificationCount", this.update_list);
this.settings.bind("showNewestFirst", "showNewestFirst", this.update_list);
this.settings.bind("showNewestFirst", "showNewestFirst", null);
this._setKeybinding();

// Layout
Expand Down Expand Up @@ -65,6 +65,18 @@ class CinnamonNotificationsApplet extends Applet.TextIconApplet {

_openMenu() {
this._update_timestamp();

this._notificationbin.remove_all_children();
if (this.showNewestFirst) {
for (let i = this.notifications.length - 1; i >= 0; i--) {
global.reparentActor(this.notifications[i].actor, this._notificationbin);
}
} else {
this.notifications.forEach(notification => {
global.reparentActor(notification.actor, this._notificationbin);
});
}

this.menu.toggle();
}

Expand Down Expand Up @@ -132,14 +144,11 @@ class CinnamonNotificationsApplet extends Applet.TextIconApplet {
return;
}

notification.actor.unparent();
let existing_index = this.notifications.indexOf(notification);
if (existing_index != -1) { // This notification is already listed.
if (notification._destroyed) {
this.notifications.splice(existing_index, 1);
} else {
notification._inNotificationBin = true;
global.reparentActor(notification.actor, this._notificationbin);
notification._timeLabel.show();
}
this.update_list();
Expand All @@ -148,11 +157,8 @@ class CinnamonNotificationsApplet extends Applet.TextIconApplet {
return;
}
// Add notification to list.
notification._inNotificationBin = true;
this.notifications.push(notification);
// Steal the notification panel.
this._notificationbin.add(notification.actor);
notification.actor._parent_container = this._notificationbin;

notification.actor.add_style_class_name('notification-applet-padding');
// Register for destruction.
notification.connect('scrolling-changed', (notif, scrolling) => { this.menu.passEvents = scrolling });
Expand All @@ -174,7 +180,6 @@ class CinnamonNotificationsApplet extends Applet.TextIconApplet {
this.actor.show();
this.clear_action.actor.show();
this.set_applet_label(count.toString());
this._reorderNotifications();
// Find max urgency and derive list icon.
let max_urgency = -1;
for (let i = 0; i < count; i++) {
Expand Down Expand Up @@ -233,25 +238,6 @@ class CinnamonNotificationsApplet extends Applet.TextIconApplet {
this.update_list();
}

_reorderNotifications() {
let orderedNotifications = this.notifications.slice();

if (this.showNewestFirst) {
orderedNotifications.reverse();
}

// Remove all children without destroying them.
let children = this._notificationbin.get_children();
for (let i = 0; i < children.length; i++) {
this._notificationbin.remove_child(children[i]);
}

// Add them back in desired order.
for (let i = 0; i < orderedNotifications.length; i++) {
this._notificationbin.add_child(orderedNotifications[i].actor);
}
}

_show_hide_tray() { // Show or hide the notification tray.
if(!global.settings.get_boolean(PANEL_EDIT_MODE_KEY)) {
if (this.notifications.length || this.showEmptyTray) {
Expand Down Expand Up @@ -287,7 +273,11 @@ class CinnamonNotificationsApplet extends Applet.TextIconApplet {
}

on_applet_clicked(event) {
this._openMenu();
if (!this.menu.isOpen){
this._openMenu();
} else {
this.menu.toggle();
}
}

on_btn_open_system_settings_clicked() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
"uuid": "notifications@cinnamon.org",
"name": "Notifications",
"description": "Click to display and manage system notifications",
"icon": "cs-notifications"
"icon": "cs-notifications",
"max-instances": -1
}
7 changes: 2 additions & 5 deletions js/ui/messageTray.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,12 +262,10 @@ var Notification = class Notification {
this._actionArea = null;
this._imageBin = null;
this._timestamp = new Date();
this._inNotificationBin = false;

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

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

Expand Down Expand Up @@ -348,7 +346,6 @@ var Notification = class Notification {
*/
update(title, body, params) {
this._timestamp = new Date();
this._inNotificationBin = false;
params = Params.parse(params, {
icon: null,
titleMarkup: false,
Expand Down Expand Up @@ -929,8 +926,8 @@ MessageTray.prototype = {

_showNotification: function () {
this._notification = this._notificationQueue.shift();
if (this._notification.actor._parent_container) {
this._notification.actor._parent_container.remove_actor(this._notification.actor);
if (this._notification.actor.get_parent()) {
this._notification.actor.get_parent().remove_actor(this._notification.actor);
}

this._notificationBin.child = this._notification.actor;
Expand Down
Loading