[gnome-boxes] notificationbar: Don't timeout if main window isn't active



commit 21d406218de96f70f32290383d6a31f248b5c5aa
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Thu Mar 29 19:10:39 2012 +0300

    notificationbar: Don't timeout if main window isn't active
    
    https://bugzilla.gnome.org/show_bug.cgi?id=672983

 src/notificationbar.vala |   25 ++++++++++++++++++++-----
 1 files changed, 20 insertions(+), 5 deletions(-)
---
diff --git a/src/notificationbar.vala b/src/notificationbar.vala
index 0b36e8f..5d507ab 100644
--- a/src/notificationbar.vala
+++ b/src/notificationbar.vala
@@ -59,11 +59,7 @@ private class Boxes.Notificationbar: GLib.Object {
             info_bar.disconnect (response_id);
         }
 
-        timeout_id = Timeout.add_seconds (6, () => {
-            info_bar.response (ResponseType.CANCEL);
-
-            return false;
-        });
+        add_timeout ();
 
         response_id = info_bar.response.connect ((response) => {
             hide ();
@@ -85,6 +81,25 @@ private class Boxes.Notificationbar: GLib.Object {
         show ();
     }
 
+    private void add_timeout () {
+        if (!app.window.is_active) {
+            // Don't timeout before user gets a chance to see's the notification
+            ulong active_id = 0;
+            active_id = app.window.notify["is-active"].connect (() => {
+                add_timeout ();
+                app.window.disconnect (active_id);
+            });
+
+            return;
+        }
+
+        timeout_id = Timeout.add_seconds (6, () => {
+            info_bar.response (ResponseType.CANCEL);
+
+            return false;
+        });
+    }
+
     private void setup_action_notify () {
         info_bar = new InfoBar ();
         info_bar.get_style_context ().add_class ("osd");



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