[gnome-boxes/obsessive-compulsive-disorder: 10/11] 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: 10/11] notification: Keep track of source IDs
- Date: Mon, 30 Mar 2020 09:24:08 +0000 (UTC)
commit a1be77232172de655e456be56c32c095987dc8d4
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]