diff options
author | Lukas Fleischer <calcurse@cryptocrack.de> | 2011-07-31 02:04:18 +0200 |
---|---|---|
committer | Lukas Fleischer <calcurse@cryptocrack.de> | 2011-07-31 03:23:32 +0200 |
commit | 45417bc6f0b6a38754bc707608c9b377d006cdfd (patch) | |
tree | 3afce6d731a33a60b6d82d207d5d18a0f87373f5 /src/notify.c | |
parent | 0884d62b2282b3ff5936f8d36f7f8d77c504938d (diff) | |
download | calcurse-45417bc6f0b6a38754bc707608c9b377d006cdfd.zip |
Add configuration option to notify all appointments
If "notify-all" is enabled, all non-flagged appointments will be
notified (instead of flagged ones). This is useful for users that want
to be notified of everything.
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
Diffstat (limited to 'src/notify.c')
-rw-r--r-- | src/notify.c | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/src/notify.c b/src/notify.c index 1b7e924..590a3e4 100644 --- a/src/notify.c +++ b/src/notify.c @@ -80,7 +80,8 @@ unsigned notify_needs_reminder (void) { if (notify_app.got_app - && (notify_app.state & APOINT_NOTIFY) + && (((notify_app.state & APOINT_NOTIFY) && !nbar.notify_all) || + (!(notify_app.state & APOINT_NOTIFY) && nbar.notify_all)) && !(notify_app.state & APOINT_NOTIFIED)) return 1; return 0; @@ -132,6 +133,8 @@ notify_init_vars (void) if ((nbar.shell = getenv ("SHELL")) == NULL) nbar.shell = "/bin/sh"; + nbar.notify_all = 0; + (void)pthread_attr_init (&detached_thread_attr); (void)pthread_attr_setdetachstate (&detached_thread_attr, PTHREAD_CREATE_DETACHED); @@ -281,7 +284,9 @@ notify_update_bar (void) minutes_left = (time_left - hours_left * HOURINSEC) / MININSEC; pthread_mutex_lock (&nbar.mutex); - if (time_left < nbar.cntdwn && (notify_app.state & APOINT_NOTIFY)) + if (time_left < nbar.cntdwn && + (((notify_app.state & APOINT_NOTIFY) && !nbar.notify_all) || + (!(notify_app.state & APOINT_NOTIFY) && nbar.notify_all))) blinking = 1; else blinking = 0; @@ -619,7 +624,7 @@ print_config_options (WINDOW *optwin) const int YOFF = 3; enum - { SHOW, DATE, CLOCK, WARN, CMD, DMON, DMON_LOG, NB_OPT }; + { SHOW, DATE, CLOCK, WARN, CMD, NOTIFY_ALL, DMON, DMON_LOG, NB_OPT }; struct opt_s { @@ -647,6 +652,9 @@ print_config_options (WINDOW *optwin) opt[CMD].name = _("notify-bar_command = "); opt[CMD].desc = _("(Command used to notify user of an upcoming appointment)"); + opt[NOTIFY_ALL].name = _("notify-all = "); + opt[NOTIFY_ALL].desc = _("(Notify all appointments instead of flagged ones only)"); + opt[DMON].name = _("notify-daemon_enable = "); opt[DMON].desc = _("(Run in background to get notifications after exiting)"); @@ -663,12 +671,14 @@ print_config_options (WINDOW *optwin) /* Boolean options */ opt[SHOW].valnum = nbar.show; + opt[NOTIFY_ALL].valnum = nbar.notify_all; pthread_mutex_unlock (&nbar.mutex); opt[DMON].valnum = dmon.enable; opt[DMON_LOG].valnum = dmon.log; - opt[SHOW].valstr[0] = opt[DMON].valstr[0] = opt[DMON_LOG].valstr[0] = '\0'; + opt[SHOW].valstr[0] = opt[NOTIFY_ALL].valstr[0] = opt[DMON].valstr[0] = + opt[DMON_LOG].valstr[0] = '\0'; for (i = 0; i < NB_OPT; i++) { @@ -797,9 +807,15 @@ notify_config_bar (void) } break; case '6': - dmon.enable = !dmon.enable; + pthread_mutex_lock (&nbar.mutex); + nbar.notify_all = !nbar.notify_all; + pthread_mutex_unlock (&nbar.mutex); + notify_check_next_app (1); break; case '7': + dmon.enable = !dmon.enable; + break; + case '8': dmon.log = !dmon.log; break; } |