[gnome-boxes] notificationbar: Limit concurrent notifications to 5



commit 66dcfb9ab7a4b6f7066dd55808228c23fcc1fb4a
Author: Radu Stochitoiu <radu stochitoiu gmail com>
Date:   Wed May 25 02:01:34 2016 +0300

    notificationbar: Limit concurrent notifications to 5
    
    Notification tray can currently hold an unlimited number of notifications
    at once, which can lead to a very crowded UI. E.g when trying to formulate
    a URL in URL entry but ending up entering wrong URLs repeatedly and very
    quickly.
    
    Let's limit the number of concurrent notifications to 5.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=763876

 src/notificationbar.vala |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)
---
diff --git a/src/notificationbar.vala b/src/notificationbar.vala
index c66fe66..2e20291 100644
--- a/src/notificationbar.vala
+++ b/src/notificationbar.vala
@@ -3,6 +3,7 @@ using Gtk;
 
 private class Boxes.Notificationbar: Gtk.Grid {
     public const int DEFAULT_TIMEOUT = 6;
+    private const int MAX_NOTIFICATIONS = 5;
 
     GLib.List<Widget> active_notifications;
 
@@ -98,6 +99,15 @@ private class Boxes.Notificationbar: Gtk.Grid {
                                                    (owned) dismiss_func,
                                                    timeout);
 
+        var excess_notifications = (int) active_notifications.length () - MAX_NOTIFICATIONS + 1;
+
+        for (var i = excess_notifications; i > 0; i--) {
+            var last_notification = active_notifications.nth_data (active_notifications.length () - i)
+                                    as Gd.Notification;
+
+            last_notification.dismiss ();
+        }
+
         active_notifications.prepend (notification);
 
         notification.dismissed.connect ( () => {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]