diff options
author | Jason Conti <[email protected]> | 2019-06-11 14:54:11 -0400 |
---|---|---|
committer | lukefromdc <[email protected]> | 2019-09-02 04:05:21 +0000 |
commit | 5a7637ab6edb537ec341779dad3282616cd72ca7 (patch) | |
tree | 6816715e4537b4ae1033389992e579428104f69a /src/daemon | |
parent | 854e1724677916cfad13eb8a4a868d4779cf4a1e (diff) | |
download | mate-notification-daemon-5a7637ab6edb537ec341779dad3282616cd72ca7.tar.bz2 mate-notification-daemon-5a7637ab6edb537ec341779dad3282616cd72ca7.tar.xz |
src/daemon/daemon.c: check for do-not-disturb and skip notification
Diffstat (limited to 'src/daemon')
-rw-r--r-- | src/daemon/daemon.c | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/src/daemon/daemon.c b/src/daemon/daemon.c index c418809..d8bab28 100644 --- a/src/daemon/daemon.c +++ b/src/daemon/daemon.c @@ -873,9 +873,8 @@ static void _calculate_timeout(NotifyDaemon* daemon, NotifyTimeout* nt, int time } } -static NotifyTimeout* _store_notification(NotifyDaemon* daemon, GtkWindow* nw, int timeout) +static guint _generate_id(NotifyDaemon* daemon) { - NotifyTimeout* nt; guint id = 0; do { @@ -897,6 +896,14 @@ static NotifyTimeout* _store_notification(NotifyDaemon* daemon, GtkWindow* nw, i } while (id == 0); + return id; +} + +static NotifyTimeout* _store_notification(NotifyDaemon* daemon, GtkWindow* nw, int timeout) +{ + NotifyTimeout* nt; + guint id = _generate_id(daemon); + nt = g_new0(NotifyTimeout, 1); nt->id = id; nt->nw = nw; @@ -1311,6 +1318,7 @@ static gboolean notify_daemon_notify_handler(NotifyDaemonNotifications *object, guint return_id; char* sound_file = NULL; gboolean sound_enabled; + gboolean do_not_disturb; gint i; GdkPixbuf* pixbuf; GSettings* gsettings; @@ -1321,6 +1329,21 @@ static gboolean notify_daemon_notify_handler(NotifyDaemonNotifications *object, return FALSE; } + /* Grab the settings */ + gsettings = g_settings_new (GSETTINGS_SCHEMA); + sound_enabled = g_settings_get_boolean (gsettings, GSETTINGS_KEY_SOUND_ENABLED); + do_not_disturb = g_settings_get_boolean (gsettings, GSETTINGS_KEY_DO_NOT_DISTURB); + g_object_unref (gsettings); + + /* If we are in do-not-disturb mode, just grab a new id and close the notification */ + if (do_not_disturb) + { + /* FIXME: does this break things if we enable the option with an action notification up */ + return_id = _generate_id (daemon); + notify_daemon_notifications_complete_notify (object, invocation, return_id); + return TRUE; + } + if (id > 0) { nt = (NotifyTimeout *) g_hash_table_lookup (daemon->notification_hash, &id); @@ -1376,11 +1399,6 @@ static gboolean notify_daemon_notify_handler(NotifyDaemonNotifications *object, } } - /* Deal with sound hints */ - gsettings = g_settings_new (GSETTINGS_SCHEMA); - sound_enabled = g_settings_get_boolean (gsettings, GSETTINGS_KEY_SOUND_ENABLED); - g_object_unref (gsettings); - if (g_variant_lookup(hints, "suppress-sound", "v", &data)) { if (g_variant_get_type (data) == G_VARIANT_TYPE_BOOLEAN ) { |