notify-send: Handle Ctrl+C by closing the notification before exiting
Avoid leaving notifications we're waiting for around on SIGNINT
This commit is contained in:
parent
07a2b2e32c
commit
74f87250a3
|
@ -26,6 +26,7 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
#include <glib-unix.h>
|
||||||
#include <glib/gprintf.h>
|
#include <glib/gprintf.h>
|
||||||
|
|
||||||
#define N_(x) (x)
|
#define N_(x) (x)
|
||||||
|
@ -148,6 +149,19 @@ handle_closed (NotifyNotification *notify,
|
||||||
g_main_loop_quit (loop);
|
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
|
static void
|
||||||
handle_action (NotifyNotification *notify,
|
handle_action (NotifyNotification *notify,
|
||||||
char *action,
|
char *action,
|
||||||
|
@ -458,6 +472,7 @@ main (int argc, char *argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wait) {
|
if (wait) {
|
||||||
|
g_unix_signal_add (SIGINT, on_sigint, notify);
|
||||||
loop = g_main_loop_new (NULL, FALSE);
|
loop = g_main_loop_new (NULL, FALSE);
|
||||||
g_main_loop_run (loop);
|
g_main_loop_run (loop);
|
||||||
g_main_loop_unref (loop);
|
g_main_loop_unref (loop);
|
||||||
|
|
Loading…
Reference in New Issue