X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=gui_theme.c;h=ffa5d792ee199f16e5bb26c5e6557054520f8e5c;hp=9345f0ed5e10c0860801d455977a00be0a29082e;hb=ab273892c54e29087d2a6b0d52de8081be1b905f;hpb=002731cd3938f3be6b71651e56c062af1adcdec0 diff --git a/gui_theme.c b/gui_theme.c index 9345f0ed..ffa5d792 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 @@ -281,32 +275,59 @@ static void init_theme_colorful_blackness(struct gui_theme *t) d[SI_AMPLIFICATION].y = 27; d[SI_AMPLIFICATION].len = 8; - d[SI_AUDIO_FILE_INFO].prefix = ""; - d[SI_AUDIO_FILE_INFO].postfix = ""; - d[SI_AUDIO_FILE_INFO].fg = COLOR_GREEN; - d[SI_AUDIO_FILE_INFO].bg = COLOR_BLACK; - d[SI_AUDIO_FILE_INFO].align = CENTER; - d[SI_AUDIO_FILE_INFO].x = 0; - d[SI_AUDIO_FILE_INFO].y = 43; - d[SI_AUDIO_FILE_INFO].len = 100; - - d[SI_TAGINFO1].prefix = ""; - d[SI_TAGINFO1].postfix = ""; - d[SI_TAGINFO1].fg = COLOR_GREEN; - d[SI_TAGINFO1].bg = COLOR_BLACK; - d[SI_TAGINFO1].align = CENTER; - d[SI_TAGINFO1].x = 0; - d[SI_TAGINFO1].y = 53; - d[SI_TAGINFO1].len = 100; - - d[SI_TAGINFO2].prefix = ""; - d[SI_TAGINFO2].postfix = ""; - d[SI_TAGINFO2].fg = COLOR_GREEN; - d[SI_TAGINFO2].bg = COLOR_BLACK; - d[SI_TAGINFO2].align = CENTER; - d[SI_TAGINFO2].x = 0; - d[SI_TAGINFO2].y = 63; - d[SI_TAGINFO2].len = 100; + d[SI_TECHINFO].prefix = ""; + d[SI_TECHINFO].postfix = ""; + d[SI_TECHINFO].fg = COLOR_GREEN; + d[SI_TECHINFO].bg = COLOR_BLACK; + d[SI_TECHINFO].align = CENTER; + d[SI_TECHINFO].x = 0; + d[SI_TECHINFO].y = 43; + d[SI_TECHINFO].len = 100; + + d[SI_TITLE].prefix = ""; + d[SI_TITLE].postfix = ","; + d[SI_TITLE].fg = COLOR_GREEN; + d[SI_TITLE].bg = COLOR_BLACK; + d[SI_TITLE].align = RIGHT; + d[SI_TITLE].x = 0; + d[SI_TITLE].y = 53; + d[SI_TITLE].len = 45; + + d[SI_ARTIST].prefix = " by "; + d[SI_ARTIST].postfix = ""; + d[SI_ARTIST].fg = COLOR_GREEN; + d[SI_ARTIST].bg = COLOR_BLACK; + d[SI_ARTIST].align = LEFT; + d[SI_ARTIST].x = 45; + d[SI_ARTIST].y = 53; + d[SI_ARTIST].len = 45; + + d[SI_YEAR].prefix = "("; + d[SI_YEAR].postfix = ")"; + d[SI_YEAR].fg = COLOR_GREEN; + d[SI_YEAR].bg = COLOR_BLACK; + d[SI_YEAR].align = RIGHT; + d[SI_YEAR].x = 90; + d[SI_YEAR].y = 53; + d[SI_YEAR].len = 10; + + d[SI_ALBUM].prefix = "A: "; + d[SI_ALBUM].postfix = ","; + d[SI_ALBUM].fg = COLOR_GREEN; + d[SI_ALBUM].bg = COLOR_BLACK; + 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].postfix = ""; + d[SI_COMMENT].fg = COLOR_GREEN; + d[SI_COMMENT].bg = COLOR_BLACK; + d[SI_COMMENT].align = LEFT; + d[SI_COMMENT].x = 50; + d[SI_COMMENT].y = 63; + d[SI_COMMENT].len = 50; d[SI_AFS_MODE].prefix = ""; d[SI_AFS_MODE].postfix = ""; @@ -336,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); +}; + +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); } -