]> Pileus Git - lackey/blobdiff - views/settings.c
Bump copyright on files modified in 2013
[lackey] / views / settings.c
index 29aa2c7d34069b3e4e821cc733ed1488abd3991a..b70cb459ef309121d18b22ff817295d5c7d1565f 100644 (file)
@@ -1,25 +1,48 @@
 /*
- * Copyright (C) 2012 Andy Spencer <andy753421@gmail.com>
- * 
+ * Copyright (C) 2012-2013 Andy Spencer <andy753421@gmail.com>
+ *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation, either version 3 of the License, or
  * (at your option) any later version.
- * 
+ *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU General Public License
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+#include <string.h>
 #include <ncurses.h>
 
+#include "util.h"
+#include "conf.h"
+#include "date.h"
+#include "cal.h"
+#include "view.h"
+
+/* Constant data */
+#define PAD "    "
+
 /* Static data */
 static WINDOW *win;
 
+/* Helper functions */
+static void heading(WINDOW *win, char *label)
+{
+       wattron(win, A_BOLD);
+       wprintw(win, "%s", label);
+       wattroff(win, A_BOLD);
+}
+
+static void checkbox(WINDOW *win, char *label, int *value)
+{
+       wprintw(win, PAD "[%c] %s", *value?'x':' ', label);
+}
+
 /* Settings init */
 void settings_init(WINDOW *_win)
 {
@@ -34,7 +57,25 @@ void settings_size(int rows, int cols)
 /* Settings draw */
 void settings_draw(void)
 {
-       mvwprintw(win, 0, 1, "%s\n", "settings");
+       int wtype = 0, wname = 0;
+
+       /* Figure out cal widths */
+       for (cal_t *cal = CALS; cal; cal = cal->next) {
+               if (strlen(cal->type) > wtype)
+                       wtype = strlen(cal->type);
+               if (strlen(cal->name) > wname)
+                       wname = strlen(cal->name);
+       }
+
+       heading(win, "Current Settings\n");
+       checkbox(win, "Compact layout\n", &COMPACT);
+
+       heading(win, "\nLoaded Calendars\n");
+       for (cal_t *cal = CALS; cal; cal = cal->next)
+               wprintw(win, PAD "%s:%*s \"%s\"%*s - %s\n",
+                       cal->type, wtype-strlen(cal->type), "",
+                       cal->name, wname-strlen(cal->name), "",
+                       cal->desc ?: "(no description)");
 }
 
 /* Settings run */