[gitg] Remove delay auto-close timeouts if explicitly closed



commit 5145fbc8054fad9a3297a6ede1764fed83ac2794
Author: Jesse van den Kieboom <jessevdk gnome org>
Date:   Thu Aug 13 20:02:13 2015 +0200

    Remove delay auto-close timeouts if explicitly closed

 gitg/gitg-notifications.vala |   17 +++++++++--------
 1 files changed, 9 insertions(+), 8 deletions(-)
---
diff --git a/gitg/gitg-notifications.vala b/gitg/gitg-notifications.vala
index 2f33db2..0463447 100644
--- a/gitg/gitg-notifications.vala
+++ b/gitg/gitg-notifications.vala
@@ -23,14 +23,14 @@ namespace Gitg
 public class Notifications : Object, GitgExt.Notifications
 {
        private Gtk.Overlay d_overlay;
-       private Gee.HashSet<uint> d_delay_handles;
+       private Gee.HashMap<GitgExt.Notification, uint> d_delay_handles;
        private Gtk.Box d_box;
        private Gee.HashMap<GitgExt.Notification, ulong> d_handles;
 
        public Notifications(Gtk.Overlay overlay)
        {
                d_overlay = overlay;
-               d_delay_handles = new Gee.HashSet<uint>();
+               d_delay_handles = new Gee.HashMap<GitgExt.Notification, uint>();
                d_handles = new Gee.HashMap<GitgExt.Notification, ulong>();
 
                d_box = new Gtk.Box(Gtk.Orientation.VERTICAL, 3);
@@ -43,7 +43,7 @@ public class Notifications : Object, GitgExt.Notifications
 
        public override void dispose()
        {
-               foreach (var id in d_delay_handles)
+               foreach (var id in d_delay_handles.values)
                {
                        Source.remove(id);
                }
@@ -96,16 +96,17 @@ public class Notifications : Object, GitgExt.Notifications
 
        public void remove(GitgExt.Notification notification, uint delay)
        {
-               uint id = 0;
+               if (d_delay_handles.has_key(notification))
+               {
+                       Source.remove(d_delay_handles[notification]);
+               }
 
-               id = Timeout.add(delay, () => {
-                       d_delay_handles.remove(id);
+               d_delay_handles[notification] = Timeout.add(delay, () => {
+                       d_delay_handles.unset(notification);
                        remove_now(notification);
 
                        return false;
                });
-
-               d_delay_handles.add(id);
        }
 }
 


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