[gnome-boxes/obsessive-compulsive-disorder: 9/10] notification: Keep track of source IDs
- From: Felipe Borges <felipeborges src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes/obsessive-compulsive-disorder: 9/10] notification: Keep track of source IDs
- Date: Thu, 26 Mar 2020 12:03:55 +0000 (UTC)
commit 6308bb58739c21467aa3426ad9da73a24322e8ad
Author: Felipe Borges <felipeborges gnome org>
Date: Thu Mar 26 12:53:32 2020 +0100
notification: Keep track of source IDs
src/notification.vala | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
---
diff --git a/src/notification.vala b/src/notification.vala
index 32c5228a..627f4953 100644
--- a/src/notification.vala
+++ b/src/notification.vala
@@ -20,6 +20,8 @@
[GtkChild]
private Gtk.Button close_button;
+ private uint notification_timeout_id = 0;
+
public Notification (string message,
MessageType message_type,
string? ok_label,
@@ -31,10 +33,12 @@ public Notification (string message,
* lets use the respective property setter method.
*/
set_reveal_child (true);
- uint notification_timeout_id = 0;
this.timeout = timeout;
+
notification_timeout_id = Timeout.add_seconds (this.timeout, () => {
+ notification_timeout_id = 0;
+
dismissed ();
return Source.REMOVE;
});
@@ -43,7 +47,11 @@ public Notification (string message,
if (dismiss_func != null)
dismiss_func ();
set_reveal_child(false);
- Source.remove(notification_timeout_id);
+
+ if (notification_timeout_id != 0) {
+ Source.remove (notification_timeout_id);
+ notification_timeout_id = 0;
+ }
});
message_label.label = message;
@@ -55,7 +63,11 @@ public Notification (string message,
if (ok_func != null)
ok_func ();
set_reveal_child(false);
- Source.remove(notification_timeout_id);
+
+ if (notification_timeout_id != 0) {
+ Source.remove(notification_timeout_id);
+ notification_timeout_id = 0;
+ }
});
ok_button.show_all ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]