gui: Remove change_theme().
[paraslash.git] / gui_theme.c
1 /*
2 * Copyright (C) 2005-2014 Andre Noll <maan@systemlinux.org>
3 *
4 * Licensed under the GPL v2. For licencing details see COPYING.
5 */
6
7 #include "para.h"
8 #include "gui.h"
9 #include <curses.h>
10
11 static void init_theme_simple(struct gui_theme *t)
12 {
13 struct stat_item_data *d = t->data;
14 t->author = "Andre Noll";
15 t->lines_min = 5;
16 t->top_lines_min = 2;
17 t->cols_min = 40;
18 t->top_lines_default = 2;
19 t->sb_bg = COLOR_CYAN;
20 t->sb_fg = COLOR_BLACK;
21 t->cmd_bg = COLOR_WHITE;
22 t->cmd_fg = COLOR_BLACK;
23 t->output_bg = COLOR_BLUE;
24 t->output_fg = COLOR_WHITE;
25 t->msg_bg = COLOR_BLUE;
26 t->msg_fg = COLOR_YELLOW;
27 t->err_msg_bg = COLOR_RED;
28 t->err_msg_fg = COLOR_WHITE;
29 t->sep_bg = COLOR_BLUE;
30 t->sep_fg = COLOR_CYAN;
31 t->default_fg = COLOR_WHITE;
32 t->default_bg = COLOR_BLUE;
33 t->sep_char = '*';
34
35 d[SI_BASENAME].prefix = "";
36 d[SI_BASENAME].postfix = "";
37 d[SI_BASENAME].fg = COLOR_WHITE;
38 d[SI_BASENAME].bg = COLOR_BLUE;
39 d[SI_BASENAME].align = CENTER;
40 d[SI_BASENAME].x = 0;
41 d[SI_BASENAME].y = 7;
42 d[SI_BASENAME].len = 100;
43
44 d[SI_STATUS].prefix = "para_server: ";
45 d[SI_STATUS].postfix = "";
46 d[SI_STATUS].fg = COLOR_WHITE;
47 d[SI_STATUS].bg = COLOR_BLUE;
48 d[SI_STATUS].align = CENTER;
49 d[SI_STATUS].x = 0;
50 d[SI_STATUS].y = 60;
51 d[SI_STATUS].len = 50;
52
53 d[SI_AUDIOD_STATUS].prefix = "para_audiod: ";
54 d[SI_AUDIOD_STATUS].postfix = "";
55 d[SI_AUDIOD_STATUS].fg = COLOR_WHITE;
56 d[SI_AUDIOD_STATUS].bg = COLOR_BLUE;
57 d[SI_AUDIOD_STATUS].align = CENTER;
58 d[SI_AUDIOD_STATUS].x = 50;
59 d[SI_AUDIOD_STATUS].y = 60;
60 d[SI_AUDIOD_STATUS].len = 50;
61
62 }
63
64 static void init_theme_colorful_blackness(struct gui_theme *t)
65 {
66 struct stat_item_data *d = t->data;
67 t->author = "Andre Noll";
68 /* minimal number of lines that is needed to display all
69 * information provided by this theme
70 */
71 t->lines_min = 15;
72 t->cols_min = 80;
73 t->top_lines_min = 9;
74 t->top_lines_default = 11; /* default number of lines */
75
76 t->sb_bg = COLOR_GREEN; /* status bar background */
77 t->sb_fg = COLOR_BLACK; /* status bar foreground */
78 t->cmd_bg = COLOR_BLACK;
79 t->cmd_fg = COLOR_YELLOW;
80 t->output_bg = COLOR_BLACK;
81 t->output_fg = COLOR_CYAN;
82 t->msg_bg = COLOR_BLACK;
83 t->msg_fg = COLOR_WHITE;
84 t->err_msg_bg = COLOR_RED;
85 t->err_msg_fg = COLOR_WHITE;
86 t->sep_bg = COLOR_BLACK; /* color of the separator */
87 t->sep_fg = COLOR_BLUE;
88 t->sep_char = 0; /* default (ACS_HLINE) */
89 t->default_bg = COLOR_BLACK;
90 t->default_fg = COLOR_MAGENTA;
91
92
93 d[SI_PLAY_TIME].prefix = "";
94 d[SI_PLAY_TIME].postfix = "";
95 d[SI_PLAY_TIME].fg = COLOR_CYAN;
96 d[SI_PLAY_TIME].bg = COLOR_BLACK;
97 d[SI_PLAY_TIME].align = CENTER;
98 d[SI_PLAY_TIME].x = 0;
99 d[SI_PLAY_TIME].y = 7;
100 d[SI_PLAY_TIME].len = 35;
101
102 d[SI_BASENAME].prefix = "";
103 d[SI_BASENAME].postfix = "";
104 d[SI_BASENAME].fg = COLOR_CYAN;
105 d[SI_BASENAME].bg = COLOR_BLACK;
106 d[SI_BASENAME].align = LEFT;
107 d[SI_BASENAME].x = 35;
108 d[SI_BASENAME].y = 7;
109 d[SI_BASENAME].len = 65;
110
111 d[SI_STATUS].prefix = "";
112 d[SI_STATUS].postfix = " ";
113 d[SI_STATUS].fg = COLOR_RED;
114 d[SI_STATUS].bg = COLOR_BLACK;
115 d[SI_STATUS].align = RIGHT;
116 d[SI_STATUS].x = 0;
117 d[SI_STATUS].y = 17;
118 d[SI_STATUS].len = 11;
119
120 d[SI_STATUS_FLAGS].prefix = "(";
121 d[SI_STATUS_FLAGS].postfix = ")";
122 d[SI_STATUS_FLAGS].fg = COLOR_RED;
123 d[SI_STATUS_FLAGS].bg = COLOR_BLACK;
124 d[SI_STATUS_FLAGS].align = LEFT;
125 d[SI_STATUS_FLAGS].x = 11;
126 d[SI_STATUS_FLAGS].y = 17;
127 d[SI_STATUS_FLAGS].len = 10;
128
129 d[SI_IMAGE_ID].prefix = "img: ";
130 d[SI_IMAGE_ID].postfix = "";
131 d[SI_IMAGE_ID].fg = COLOR_RED;
132 d[SI_IMAGE_ID].bg = COLOR_BLACK;
133 d[SI_IMAGE_ID].align = CENTER;
134 d[SI_IMAGE_ID].x = 21;
135 d[SI_IMAGE_ID].y = 17;
136 d[SI_IMAGE_ID].len = 10;
137
138 d[SI_LYRICS_ID].prefix = "lyr: ";
139 d[SI_LYRICS_ID].postfix = "";
140 d[SI_LYRICS_ID].fg = COLOR_RED;
141 d[SI_LYRICS_ID].bg = COLOR_BLACK;
142 d[SI_LYRICS_ID].align = CENTER;
143 d[SI_LYRICS_ID].x = 31;
144 d[SI_LYRICS_ID].y = 17;
145 d[SI_LYRICS_ID].len = 11;
146
147 d[SI_FORMAT].prefix = "format: ";
148 d[SI_FORMAT].postfix = "";
149 d[SI_FORMAT].fg = COLOR_RED;
150 d[SI_FORMAT].bg = COLOR_BLACK;
151 d[SI_FORMAT].align = CENTER;
152 d[SI_FORMAT].x = 42;
153 d[SI_FORMAT].y = 17;
154 d[SI_FORMAT].len = 18;
155
156 d[SI_NUM_PLAYED].prefix = "#";
157 d[SI_NUM_PLAYED].postfix = "";
158 d[SI_NUM_PLAYED].fg = COLOR_RED;
159 d[SI_NUM_PLAYED].bg = COLOR_BLACK;
160 d[SI_NUM_PLAYED].align = LEFT;
161 d[SI_NUM_PLAYED].x = 60;
162 d[SI_NUM_PLAYED].y = 17;
163 d[SI_NUM_PLAYED].len = 5;
164
165 d[SI_BITRATE].prefix = "";
166 d[SI_BITRATE].postfix = "";
167 d[SI_BITRATE].fg = COLOR_RED;
168 d[SI_BITRATE].bg = COLOR_BLACK;
169 d[SI_BITRATE].align = CENTER;
170 d[SI_BITRATE].x = 65;
171 d[SI_BITRATE].y = 17;
172 d[SI_BITRATE].len = 13;
173
174 d[SI_FREQUENCY].prefix = "";
175 d[SI_FREQUENCY].postfix = "";
176 d[SI_FREQUENCY].fg = COLOR_RED;
177 d[SI_FREQUENCY].bg = COLOR_BLACK;
178 d[SI_FREQUENCY].align = CENTER;
179 d[SI_FREQUENCY].x = 78;
180 d[SI_FREQUENCY].y = 17;
181 d[SI_FREQUENCY].len = 10;
182
183 d[SI_SCORE].prefix = "sc: ";
184 d[SI_SCORE].postfix = "";
185 d[SI_SCORE].fg = COLOR_RED;
186 d[SI_SCORE].bg = COLOR_BLACK;
187 d[SI_SCORE].align = CENTER;
188 d[SI_SCORE].x = 88;
189 d[SI_SCORE].y = 17;
190 d[SI_SCORE].len = 10;
191
192 d[SI_AUDIOD_STATUS].prefix = "";
193 d[SI_AUDIOD_STATUS].postfix = "";
194 d[SI_AUDIOD_STATUS].fg = COLOR_MAGENTA;
195 d[SI_AUDIOD_STATUS].bg = COLOR_BLACK;
196 d[SI_AUDIOD_STATUS].align = CENTER;
197 d[SI_AUDIOD_STATUS].x = 0;
198 d[SI_AUDIOD_STATUS].y = 27;
199 d[SI_AUDIOD_STATUS].len = 5;
200
201 d[SI_DECODER_FLAGS].prefix = "[";
202 d[SI_DECODER_FLAGS].postfix = "]";
203 d[SI_DECODER_FLAGS].fg = COLOR_MAGENTA;
204 d[SI_DECODER_FLAGS].bg = COLOR_BLACK;
205 d[SI_DECODER_FLAGS].align = CENTER;
206 d[SI_DECODER_FLAGS].x = 5;
207 d[SI_DECODER_FLAGS].y = 27;
208 d[SI_DECODER_FLAGS].len = 10;
209
210 d[SI_MTIME].prefix = "mod: ";
211 d[SI_MTIME].postfix = "";
212 d[SI_MTIME].fg = COLOR_MAGENTA;
213 d[SI_MTIME].bg = COLOR_BLACK;
214 d[SI_MTIME].align = CENTER;
215 d[SI_MTIME].x = 15;
216 d[SI_MTIME].y = 27;
217 d[SI_MTIME].len = 22;
218
219 d[SI_FILE_SIZE].prefix = "";
220 d[SI_FILE_SIZE].postfix = "kb";
221 d[SI_FILE_SIZE].fg = COLOR_MAGENTA;
222 d[SI_FILE_SIZE].bg = COLOR_BLACK;
223 d[SI_FILE_SIZE].align = CENTER;
224 d[SI_FILE_SIZE].x = 37;
225 d[SI_FILE_SIZE].y = 27;
226 d[SI_FILE_SIZE].len = 10;
227
228 d[SI_CHANNELS].prefix = "";
229 d[SI_CHANNELS].postfix = "ch";
230 d[SI_CHANNELS].fg = COLOR_MAGENTA;
231 d[SI_CHANNELS].bg = COLOR_BLACK;
232 d[SI_CHANNELS].align = CENTER;
233 d[SI_CHANNELS].x = 47;
234 d[SI_CHANNELS].y = 27;
235 d[SI_CHANNELS].len = 5;
236
237 d[SI_LAST_PLAYED].prefix = "lp: ";
238 d[SI_LAST_PLAYED].postfix = "";
239 d[SI_LAST_PLAYED].fg = COLOR_MAGENTA;
240 d[SI_LAST_PLAYED].bg = COLOR_BLACK;
241 d[SI_LAST_PLAYED].align = CENTER;
242 d[SI_LAST_PLAYED].x = 52;
243 d[SI_LAST_PLAYED].y = 27;
244 d[SI_LAST_PLAYED].len = 21;
245
246 d[SI_NUM_CHUNKS].prefix = "";
247 d[SI_NUM_CHUNKS].postfix = "x";
248 d[SI_NUM_CHUNKS].fg = COLOR_MAGENTA;
249 d[SI_NUM_CHUNKS].bg = COLOR_BLACK;
250 d[SI_NUM_CHUNKS].align = RIGHT;
251 d[SI_NUM_CHUNKS].x = 73;
252 d[SI_NUM_CHUNKS].y = 27;
253 d[SI_NUM_CHUNKS].len = 11;
254
255 d[SI_CHUNK_TIME].prefix = "";
256 d[SI_CHUNK_TIME].postfix = "ms";
257 d[SI_CHUNK_TIME].fg = COLOR_MAGENTA;
258 d[SI_CHUNK_TIME].bg = COLOR_BLACK;
259 d[SI_CHUNK_TIME].align = LEFT;
260 d[SI_CHUNK_TIME].x = 84;
261 d[SI_CHUNK_TIME].y = 27;
262 d[SI_CHUNK_TIME].len = 8;
263
264 d[SI_AMPLIFICATION].prefix = "amp:";
265 d[SI_AMPLIFICATION].postfix = "";
266 d[SI_AMPLIFICATION].fg = COLOR_MAGENTA;
267 d[SI_AMPLIFICATION].bg = COLOR_BLACK;
268 d[SI_AMPLIFICATION].align = RIGHT;
269 d[SI_AMPLIFICATION].x = 92;
270 d[SI_AMPLIFICATION].y = 27;
271 d[SI_AMPLIFICATION].len = 8;
272
273 d[SI_TECHINFO].prefix = "";
274 d[SI_TECHINFO].postfix = "";
275 d[SI_TECHINFO].fg = COLOR_GREEN;
276 d[SI_TECHINFO].bg = COLOR_BLACK;
277 d[SI_TECHINFO].align = CENTER;
278 d[SI_TECHINFO].x = 0;
279 d[SI_TECHINFO].y = 43;
280 d[SI_TECHINFO].len = 100;
281
282 d[SI_TITLE].prefix = "";
283 d[SI_TITLE].postfix = ",";
284 d[SI_TITLE].fg = COLOR_GREEN;
285 d[SI_TITLE].bg = COLOR_BLACK;
286 d[SI_TITLE].align = RIGHT;
287 d[SI_TITLE].x = 0;
288 d[SI_TITLE].y = 53;
289 d[SI_TITLE].len = 45;
290
291 d[SI_ARTIST].prefix = " by ";
292 d[SI_ARTIST].postfix = "";
293 d[SI_ARTIST].fg = COLOR_GREEN;
294 d[SI_ARTIST].bg = COLOR_BLACK;
295 d[SI_ARTIST].align = LEFT;
296 d[SI_ARTIST].x = 45;
297 d[SI_ARTIST].y = 53;
298 d[SI_ARTIST].len = 45;
299
300 d[SI_YEAR].prefix = "(";
301 d[SI_YEAR].postfix = ")";
302 d[SI_YEAR].fg = COLOR_GREEN;
303 d[SI_YEAR].bg = COLOR_BLACK;
304 d[SI_YEAR].align = RIGHT;
305 d[SI_YEAR].x = 90;
306 d[SI_YEAR].y = 53;
307 d[SI_YEAR].len = 10;
308
309 d[SI_ALBUM].prefix = "A: ";
310 d[SI_ALBUM].postfix = ",";
311 d[SI_ALBUM].fg = COLOR_GREEN;
312 d[SI_ALBUM].bg = COLOR_BLACK;
313 d[SI_ALBUM].align = RIGHT;
314 d[SI_ALBUM].x = 0;
315 d[SI_ALBUM].y = 63;
316 d[SI_ALBUM].len = 50;
317
318 d[SI_COMMENT].prefix = " C: ";
319 d[SI_COMMENT].postfix = "";
320 d[SI_COMMENT].fg = COLOR_GREEN;
321 d[SI_COMMENT].bg = COLOR_BLACK;
322 d[SI_COMMENT].align = LEFT;
323 d[SI_COMMENT].x = 50;
324 d[SI_COMMENT].y = 63;
325 d[SI_COMMENT].len = 50;
326
327 d[SI_AFS_MODE].prefix = "";
328 d[SI_AFS_MODE].postfix = "";
329 d[SI_AFS_MODE].fg = COLOR_YELLOW;
330 d[SI_AFS_MODE].bg = COLOR_BLACK;
331 d[SI_AFS_MODE].align = CENTER;
332 d[SI_AFS_MODE].x = 0;
333 d[SI_AFS_MODE].y = 77;
334 d[SI_AFS_MODE].len = 100;
335
336 d[SI_ATTRIBUTES_TXT].prefix = "";
337 d[SI_ATTRIBUTES_TXT].postfix = "";
338 d[SI_ATTRIBUTES_TXT].fg = COLOR_YELLOW;
339 d[SI_ATTRIBUTES_TXT].bg = COLOR_BLACK;
340 d[SI_ATTRIBUTES_TXT].align = CENTER;
341 d[SI_ATTRIBUTES_TXT].x = 0;
342 d[SI_ATTRIBUTES_TXT].y = 87;
343 d[SI_ATTRIBUTES_TXT].len = 100;
344
345 d[SI_DIRECTORY].prefix = "dir: ";
346 d[SI_DIRECTORY].postfix = "";
347 d[SI_DIRECTORY].fg = COLOR_YELLOW;
348 d[SI_DIRECTORY].bg = COLOR_BLACK;
349 d[SI_DIRECTORY].align = CENTER;
350 d[SI_DIRECTORY].x = 0;
351 d[SI_DIRECTORY].y = 97;
352 d[SI_DIRECTORY].len = 100;
353 }
354
355 struct theme_description {
356 const char *name;
357 void (*init)(struct gui_theme *t);
358 };
359
360 static struct theme_description themes[] = {
361 {
362 .name = "colorful blackness",
363 .init = init_theme_colorful_blackness,
364 },
365 {
366 .name = "simple",
367 .init = init_theme_simple,
368 },
369 };
370
371 #define NUM_THEMES (ARRAY_SIZE(themes))
372
373 static int current_theme_num;
374
375 static void set_theme(int num, struct gui_theme *t)
376 {
377 int i;
378 FOR_EACH_STATUS_ITEM(i)
379 t->data[i].len = 0;
380 num %= NUM_THEMES;
381 t->name = themes[num].name;
382 themes[num].init(t);
383 current_theme_num = num;
384 PARA_NOTICE_LOG("theme: %s\n", t->name);
385 }
386
387 void theme_init(const char *name, struct gui_theme *t)
388 {
389 int i;
390
391 if (!name)
392 return set_theme(0, t);
393 for (i = 0; i < NUM_THEMES; i++)
394 if (strcmp(name, themes[i].name) == 0)
395 return set_theme(i, t);
396 fprintf(stderr, "Available themes:\n");
397 for (i = 0; i < NUM_THEMES; i++)
398 fprintf(stderr, "\t%s\n", themes[i].name);
399 exit(EXIT_FAILURE);
400 }
401
402 void theme_prev(struct gui_theme *t)
403 {
404 return set_theme(++current_theme_num, t);
405 }
406
407 void theme_next(struct gui_theme *t)
408 {
409 return set_theme(--current_theme_num, t);
410 }