2 * Copyright (C) 2012-2013 Andy Spencer <andy753421@gmail.com>
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
33 /* Helper functions */
34 static void heading(WINDOW *win, char *label)
37 wprintw(win, "%s", label);
38 wattroff(win, A_BOLD);
41 static void checkbox(WINDOW *win, char *label, int *value)
43 wprintw(win, PAD "[%c] %s", *value?'x':' ', label);
47 void settings_init(WINDOW *_win)
53 void settings_size(int rows, int cols)
58 void settings_draw(void)
60 int wtype = 0, wname = 0;
62 /* Figure out cal widths */
63 for (cal_t *cal = CALS; cal; cal = cal->next) {
64 if (strlen(cal->type) > wtype)
65 wtype = strlen(cal->type);
66 if (strlen(cal->name) > wname)
67 wname = strlen(cal->name);
70 heading(win, "Current Settings\n");
71 checkbox(win, "Compact layout\n", &COMPACT);
73 heading(win, "\nLoaded Calendars\n");
74 for (cal_t *cal = CALS; cal; cal = cal->next)
75 wprintw(win, PAD "%s:%*s \"%s\"%*s - %s\n",
76 cal->type, wtype-strlen(cal->type), "",
77 cal->name, wname-strlen(cal->name), "",
78 cal->desc ?: "(no description)");
82 int settings_run(int key, mmask_t btn, int row, int col)