diff --git a/files/usr/share/cinnamon/applets/notifications@cinnamon.org/applet.js b/files/usr/share/cinnamon/applets/notifications@cinnamon.org/applet.js index 8aa2d6778a..7828533c34 100644 --- a/files/usr/share/cinnamon/applets/notifications@cinnamon.org/applet.js +++ b/files/usr/share/cinnamon/applets/notifications@cinnamon.org/applet.js @@ -27,6 +27,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._setKeybinding(); // Layout @@ -166,6 +167,7 @@ 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++) { @@ -224,6 +226,25 @@ 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) { diff --git a/files/usr/share/cinnamon/applets/notifications@cinnamon.org/settings-schema.json b/files/usr/share/cinnamon/applets/notifications@cinnamon.org/settings-schema.json index 5285b3bcaa..575fa98e37 100644 --- a/files/usr/share/cinnamon/applets/notifications@cinnamon.org/settings-schema.json +++ b/files/usr/share/cinnamon/applets/notifications@cinnamon.org/settings-schema.json @@ -24,6 +24,11 @@ "default": true, "description": "Show the number of notifications" }, + "showNewestFirst": { + "type": "switch", + "default": false, + "description": "Show newest notifications first" + }, "section3": { "type": "section", "description": "Keyboard shortcuts"