[libnotify] notify-send: Handle Ctrl+C by closing the notification before exiting
- From: Marco Trevisan <marcotrevi src gnome org>
 
- To: commits-list gnome org
 
- Cc: 
 
- Subject: [libnotify] notify-send: Handle Ctrl+C by closing the notification before exiting
 
- Date: Thu, 14 Jul 2022 14:56:00 +0000 (UTC)
 
commit 74f87250a38e92f0f9db7610f3e316a86016b6e2
Author: Marco Trevisan (TreviƱo) <mail 3v1n0 net>
Date:   Tue May 17 00:31:59 2022 +0200
    notify-send: Handle Ctrl+C by closing the notification before exiting
    
    Avoid leaving notifications we're waiting for around on SIGNINT
 tools/notify-send.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
---
diff --git a/tools/notify-send.c b/tools/notify-send.c
index aea3435..667f9d5 100644
--- a/tools/notify-send.c
+++ b/tools/notify-send.c
@@ -26,6 +26,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <glib.h>
+#include <glib-unix.h>
 #include <glib/gprintf.h>
 
 #define N_(x) (x)
@@ -148,6 +149,19 @@ handle_closed (NotifyNotification *notify,
         g_main_loop_quit (loop);
 }
 
+static gboolean
+on_sigint (gpointer data)
+{
+        NotifyNotification *notification = data;
+
+        g_printerr ("Wait cancelled, closing notification\n");
+
+        notify_notification_close (notification, NULL);
+        g_main_loop_quit (loop);
+
+        return FALSE;
+}
+
 static void
 handle_action (NotifyNotification *notify,
                char               *action,
@@ -458,6 +472,7 @@ main (int argc, char *argv[])
         }
 
         if (wait) {
+                g_unix_signal_add (SIGINT, on_sigint, notify);
                 loop = g_main_loop_new (NULL, FALSE);
                 g_main_loop_run (loop);
                 g_main_loop_unref (loop);
[
Date Prev][
Date Next]   [
Thread Prev][
Thread Next]   
[
Thread Index]
[
Date Index]
[
Author Index]