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