aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLukas Fleischer <lfleischer@calcurse.org>2016-01-18 18:09:23 +0100
committerLukas Fleischer <lfleischer@calcurse.org>2016-01-18 18:09:23 +0100
commit1b75acf01b2f5a8d828aca3376022e156f1444ff (patch)
tree49a5481d8322fa50cfc9a480c2ee3da307bdc89f /src
parente3ac5542aa1be85ae1116eea44142f85c80b4a34 (diff)
downloadcalcurse-1b75acf01b2f5a8d828aca3376022e156f1444ff.tar.gz
calcurse-1b75acf01b2f5a8d828aca3376022e156f1444ff.zip
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 <lfleischer@calcurse.org>
Diffstat (limited to 'src')
-rw-r--r--src/calcurse.h2
-rw-r--r--src/config.c25
-rw-r--r--src/ui-todo.c11
3 files changed, 38 insertions, 0 deletions
diff --git a/src/calcurse.h b/src/calcurse.h
index 67f95fa..d2ee80b 100644
--- a/src/calcurse.h
+++ b/src/calcurse.h
@@ -1072,6 +1072,8 @@ void ui_todo_view_note(void);
void ui_todo_edit_note(void);
void ui_todo_view_prev(void);
void ui_todo_view_next(void);
+int ui_todo_get_view(void);
+void ui_todo_set_view(int);
/* utf8.c */
int utf8_width(char *);
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)
diff --git a/src/ui-todo.c b/src/ui-todo.c
index de19272..971c69d 100644
--- a/src/ui-todo.c
+++ b/src/ui-todo.c
@@ -327,3 +327,14 @@ void ui_todo_view_prev(void)
ui_todo_view--;
ui_todo_load_items();
}
+
+void ui_todo_set_view(int view)
+{
+ ui_todo_view = (view < 0 || view >= TODO_VIEWS) ?
+ TODO_SHOW_COMPLETED_VIEW : view;
+}
+
+int ui_todo_get_view(void)
+{
+ return (int)ui_todo_view;
+}