X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=gui_theme.c;h=4abc45ec6e7a0cd60872d840a04d4f2659ca5119;hp=a33df3d27710987491c3c647cef2aec60958221b;hb=a7a72ca4acf7f44abca866d410e2bc80590e7fab;hpb=383d1bfb5084ea5a475e408d3cc9d2e2a3de5b88 diff --git a/gui_theme.c b/gui_theme.c index a33df3d2..4abc45ec 100644 --- a/gui_theme.c +++ b/gui_theme.c @@ -1,22 +1,17 @@ /* - * Copyright (C) 2005-2009 Andre Noll + * Copyright (C) 2005-2011 Andre Noll * * Licensed under the GPL v2. For licencing details see COPYING. */ +#include #include "para.h" #include "gui.h" #include -#define NUM_THEMES 2 - - -static int current_theme_num; - static void init_theme_simple(struct gui_theme *t) { struct stat_item_data *d = t->data; - t->name = "simple"; t->author = "Andre Noll"; t->lines_min = 5; t->top_lines_min = 2; @@ -72,7 +67,6 @@ static void init_theme_simple(struct gui_theme *t) static void init_theme_colorful_blackness(struct gui_theme *t) { struct stat_item_data *d = t->data; - t->name = "colorful blackness"; t->author = "Andre Noll"; /* minimal number of lines that is needed to display all * information provided by this theme @@ -318,19 +312,19 @@ static void init_theme_colorful_blackness(struct gui_theme *t) d[SI_YEAR].len = 10; d[SI_ALBUM].prefix = "A: "; - d[SI_ALBUM].postfix = ""; + d[SI_ALBUM].postfix = ","; d[SI_ALBUM].fg = COLOR_GREEN; d[SI_ALBUM].bg = COLOR_BLACK; - d[SI_ALBUM].align = CENTER; + d[SI_ALBUM].align = RIGHT; d[SI_ALBUM].x = 0; d[SI_ALBUM].y = 63; d[SI_ALBUM].len = 50; - d[SI_COMMENT].prefix = "C: "; + d[SI_COMMENT].prefix = " C: "; d[SI_COMMENT].postfix = ""; d[SI_COMMENT].fg = COLOR_GREEN; d[SI_COMMENT].bg = COLOR_BLACK; - d[SI_COMMENT].align = CENTER; + d[SI_COMMENT].align = LEFT; d[SI_COMMENT].x = 50; d[SI_COMMENT].y = 63; d[SI_COMMENT].len = 50; @@ -363,24 +357,58 @@ static void init_theme_colorful_blackness(struct gui_theme *t) d[SI_DIRECTORY].len = 100; } -void init_theme(int num, struct gui_theme *t) +struct theme_description { + const char *name; + void (*init)(struct gui_theme *t); +}; + +static struct theme_description themes[] = { + { + .name = "colorful blackness", + .init = init_theme_colorful_blackness, + }, + { + .name = "simple", + .init = init_theme_simple, + }, +}; + +#define NUM_THEMES (ARRAY_SIZE(themes)) + +static int current_theme_num; + +static void set_theme(int num, struct gui_theme *t) { int i; FOR_EACH_STATUS_ITEM(i) t->data[i].len = 0; + num %= NUM_THEMES; + t->name = themes[num].name; + themes[num].init(t); current_theme_num = num; +} - return (num % NUM_THEMES)? - init_theme_simple(t) : init_theme_colorful_blackness(t); +void init_theme_or_die(const char *name, struct gui_theme *t) +{ + int i; + + if (!name) + return set_theme(0, t); + for (i = 0; i < NUM_THEMES; i++) + if (strcmp(name, themes[i].name) == 0) + return set_theme(i, t); + fprintf(stderr, "Available themes:\n"); + for (i = 0; i < NUM_THEMES; i++) + fprintf(stderr, "\t%s\n", themes[i].name); + exit(EXIT_FAILURE); } void prev_theme(struct gui_theme *t) { - return init_theme(++current_theme_num, t); + return set_theme(++current_theme_num, t); } void next_theme(struct gui_theme *t) { - return init_theme(--current_theme_num, t); + return set_theme(--current_theme_num, t); } -