From 1b75acf01b2f5a8d828aca3376022e156f1444ff Mon Sep 17 00:00:00 2001 From: Lukas Fleischer Date: Mon, 18 Jan 2016 18:09:23 +0100 Subject: Save active view on the todo panel Add a configuration option appearance.todoview and use it to automatically save the currently active todo panel view and restore it when restarting calcurse. Signed-off-by: Lukas Fleischer --- src/config.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'src/config.c') diff --git a/src/config.c b/src/config.c index a26bd1f..8b65740 100644 --- a/src/config.c +++ b/src/config.c @@ -59,6 +59,8 @@ static int config_parse_str(char *, const char *); static int config_serialize_str(char **, const char *); static int config_parse_calendar_view(void *, const char *); static int config_serialize_calendar_view(char **, void *); +static int config_parse_todo_view(void *, const char *); +static int config_serialize_todo_view(char **, void *); static int config_parse_default_panel(void *, const char *); static int config_serialize_default_panel(char **, void *); static int config_parse_first_day_of_week(void *, const char *); @@ -91,6 +93,7 @@ static const struct confvar confmap[] = { {"appearance.notifybar", CONFIG_HANDLER_BOOL(nbar.show)}, {"appearance.sidebarwidth", config_parse_sidebar_width, config_serialize_sidebar_width, NULL}, {"appearance.theme", config_parse_color_theme, config_serialize_color_theme, NULL}, + {"appearance.todoview", config_parse_todo_view, config_serialize_todo_view, NULL}, {"daemon.enable", CONFIG_HANDLER_BOOL(dmon.enable)}, {"daemon.log", CONFIG_HANDLER_BOOL(dmon.log)}, {"format.inputdate", config_parse_input_datefmt, config_serialize_input_datefmt, NULL}, @@ -206,6 +209,18 @@ static int config_parse_calendar_view(void *dummy, const char *val) return 1; } +static int config_parse_todo_view(void *dummy, const char *val) +{ + if (!strcmp(val, "show-completed")) + ui_todo_set_view(TODO_SHOW_COMPLETED_VIEW); + else if (!strcmp(val, "hide-completed")) + ui_todo_set_view(TODO_HIDE_COMPLETED_VIEW); + else + return 0; + + return 1; +} + static int config_parse_default_panel(void *dummy, const char *val) { if (!strcmp(val, "calendar")) @@ -378,6 +393,16 @@ static int config_serialize_calendar_view(char **buf, void *dummy) return 1; } +static int config_serialize_todo_view(char **buf, void *dummy) +{ + if (ui_todo_get_view() == TODO_SHOW_COMPLETED_VIEW) + *buf = mem_strdup("show-completed"); + else + *buf = mem_strdup("hide-completed"); + + return 1; +} + static int config_serialize_default_panel(char **buf, void *dummy) { if (conf.default_panel == CAL) -- cgit v1.2.3-54-g00ecf