aboutsummaryrefslogtreecommitdiffstats
path: root/src/config.c
diff options
context:
space:
mode:
authorLukas Fleischer <lfleischer@calcurse.org>2016-01-27 08:03:09 +0100
committerLukas Fleischer <lfleischer@calcurse.org>2016-01-27 08:29:33 +0100
commitebe483c0584c839a2890db1e4a43b0526ed738d8 (patch)
tree463cd681143cfee29b30beec1dab5436016a0165 /src/config.c
parente1bffdb52daa50468d2b730a51d1717cafb70705 (diff)
downloadcalcurse-ebe483c0584c839a2890db1e4a43b0526ed738d8.tar.gz
calcurse-ebe483c0584c839a2890db1e4a43b0526ed738d8.zip
Support sending notifications for all appointments
In 45417bc (Add configuration option to notify all appointments, 2011-07-31), we added an option that allows for choosing whether the user receives notifications only for flagged or only for unflagged appointments. Convert this setting into a three-state option and allow the user to additionally enable notifications for *all* appointments. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
Diffstat (limited to 'src/config.c')
-rw-r--r--src/config.c30
1 files changed, 29 insertions, 1 deletions
diff --git a/src/config.c b/src/config.c
index 8b65740..86277e8 100644
--- a/src/config.c
+++ b/src/config.c
@@ -75,6 +75,8 @@ static int config_parse_output_datefmt(void *, const char *);
static int config_serialize_output_datefmt(char **, void *);
static int config_parse_input_datefmt(void *, const char *);
static int config_serialize_input_datefmt(char **, void *);
+static int config_parse_notifyall(void *, const char *);
+static int config_serialize_notifyall(char **, void *);
#define CONFIG_HANDLER_BOOL(var) (config_fn_parse_t) config_parse_bool, \
(config_fn_serialize_t) config_serialize_bool, &(var)
@@ -109,7 +111,7 @@ static const struct confvar confmap[] = {
{"general.progressbar", CONFIG_HANDLER_BOOL(conf.progress_bar)},
{"general.systemdialogs", CONFIG_HANDLER_BOOL(conf.system_dialogs)},
{"notification.command", CONFIG_HANDLER_STR(nbar.cmd)},
- {"notification.notifyall", CONFIG_HANDLER_BOOL(nbar.notify_all)},
+ {"notification.notifyall", config_parse_notifyall, config_serialize_notifyall, NULL},
{"notification.warning", CONFIG_HANDLER_INT(nbar.cntdwn)}
};
@@ -291,6 +293,19 @@ static int config_parse_input_datefmt(void *dummy, const char *val)
}
}
+static int config_parse_notifyall(void *dummy, const char *val)
+{
+ if (strcmp(val, "flagged-only") == 0)
+ nbar.notify_all = NOTIFY_FLAGGED_ONLY;
+ else if (strcmp(val, "unflagged-only") == 0)
+ nbar.notify_all = NOTIFY_UNFLAGGED_ONLY;
+ else if (strcmp(val, "all") == 0)
+ nbar.notify_all = NOTIFY_ALL;
+ else
+ return config_parse_bool(&nbar.notify_all, val);
+ return 1;
+}
+
/* Set a configuration variable. */
static int config_set_conf(const char *key, const char *value)
{
@@ -453,6 +468,19 @@ static int config_serialize_input_datefmt(char **buf, void *dummy)
return config_serialize_int(buf, &conf.input_datefmt);
}
+static int config_serialize_notifyall(char **buf, void *dummy)
+{
+ if (nbar.notify_all == NOTIFY_FLAGGED_ONLY)
+ *buf = mem_strdup("flagged-only");
+ else if (nbar.notify_all == NOTIFY_UNFLAGGED_ONLY)
+ *buf = mem_strdup("unflagged-only");
+ else if (nbar.notify_all == NOTIFY_ALL)
+ *buf = mem_strdup("all");
+ else
+ return 0;
+ return 1;
+}
+
/* Serialize the value of a configuration variable. */
static int
config_serialize_conf(char **buf, const char *key,