comparison gui/cfg.c @ 34596:04feb00f91be

Prefer static const char arrays for string constants to #defines.
author ib
date Fri, 10 Feb 2012 15:40:53 +0000
parents 97bf974e7623
children 4ff933a89818
comparison
equal deleted inserted replaced
34595:97bf974e7623 34596:04feb00f91be
42 #include "stream/stream.h" 42 #include "stream/stream.h"
43 #include "sub/ass_mp.h" 43 #include "sub/ass_mp.h"
44 #include "sub/font_load.h" 44 #include "sub/font_load.h"
45 #include "sub/sub.h" 45 #include "sub/sub.h"
46 46
47 #define GUI_CONFIGURATION "gui.conf"
48 #define GUI_HISTORY "gui.history"
49 #define GUI_PLAYLIST "gui.pl"
50 #define GUI_URLLIST "gui.url"
51
52 m_config_t *gui_conf; 47 m_config_t *gui_conf;
53 48
54 int gtkCacheOn; 49 int gtkCacheOn;
55 int gtkCacheSize = 2048; 50 int gtkCacheSize = 2048;
56 51
100 int guiWinID = -1; 95 int guiWinID = -1;
101 96
102 char *skinName; 97 char *skinName;
103 98
104 char *fsHistory[5]; 99 char *fsHistory[5];
100
101 static const char gui_configuration[] = "gui.conf";
102 static const char gui_history[] = "gui.history";
103 static const char gui_playlist[] = "gui.pl";
104 static const char gui_urllist[] = "gui.url";
105 105
106 static const m_option_t gui_opts[] = { 106 static const m_option_t gui_opts[] = {
107 { "cache", &gtkCacheOn, CONF_TYPE_FLAG, 0, 0, 1, NULL }, 107 { "cache", &gtkCacheOn, CONF_TYPE_FLAG, 0, 0, 1, NULL },
108 { "cache_size", &gtkCacheSize, CONF_TYPE_INT, CONF_RANGE, 32, 1048576, NULL }, 108 { "cache_size", &gtkCacheSize, CONF_TYPE_INT, CONF_RANGE, 32, 1048576, NULL },
109 109
246 246
247 player_idle_mode = 1; // GUI is in idle mode by default 247 player_idle_mode = 1; // GUI is in idle mode by default
248 248
249 // configuration 249 // configuration
250 250
251 fname = get_path(GUI_CONFIGURATION); 251 fname = get_path(gui_configuration);
252 252
253 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[cfg] file: %s\n", fname); 253 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[cfg] file: %s\n", fname);
254 254
255 gui_conf = m_config_new(); 255 gui_conf = m_config_new();
256 256
268 268
269 free(fname); 269 free(fname);
270 270
271 // playlist 271 // playlist
272 272
273 fname = get_path(GUI_PLAYLIST); 273 fname = get_path(gui_playlist);
274 file = fopen(fname, "rt"); 274 file = fopen(fname, "rt");
275 275
276 if (file) { 276 if (file) {
277 while (fgetstr(line, sizeof(line), file)) { 277 while (fgetstr(line, sizeof(line), file)) {
278 plItem *item; 278 plItem *item;
303 303
304 free(fname); 304 free(fname);
305 305
306 // URL list 306 // URL list
307 307
308 fname = get_path(GUI_URLLIST); 308 fname = get_path(gui_urllist);
309 file = fopen(fname, "rt"); 309 file = fopen(fname, "rt");
310 310
311 if (file) { 311 if (file) {
312 while (fgetstr(line, sizeof(line), file)) { 312 while (fgetstr(line, sizeof(line), file)) {
313 urlItem *item; 313 urlItem *item;
331 331
332 free(fname); 332 free(fname);
333 333
334 // directory history 334 // directory history
335 335
336 fname = get_path(GUI_HISTORY); 336 fname = get_path(gui_history);
337 file = fopen(fname, "rt"); 337 file = fopen(fname, "rt");
338 338
339 if (file) { 339 if (file) {
340 unsigned int i = 0; 340 unsigned int i = 0;
341 341
355 FILE *file; 355 FILE *file;
356 unsigned int i; 356 unsigned int i;
357 357
358 // configuration 358 // configuration
359 359
360 fname = get_path(GUI_CONFIGURATION); 360 fname = get_path(gui_configuration);
361 file = fopen(fname, "wt+"); 361 file = fopen(fname, "wt+");
362 362
363 if (file) { 363 if (file) {
364 for (i = 0; gui_opts[i].name; i++) { 364 for (i = 0; gui_opts[i].name; i++) {
365 char *val = m_option_print(&gui_opts[i], gui_opts[i].p); 365 char *val = m_option_print(&gui_opts[i], gui_opts[i].p);
385 385
386 free(fname); 386 free(fname);
387 387
388 // playlist 388 // playlist
389 389
390 fname = get_path(GUI_PLAYLIST); 390 fname = get_path(gui_playlist);
391 file = fopen(fname, "wt+"); 391 file = fopen(fname, "wt+");
392 392
393 if (file) { 393 if (file) {
394 plItem *item = plList; 394 plItem *item = plList;
395 395
407 407
408 free(fname); 408 free(fname);
409 409
410 // URL list 410 // URL list
411 411
412 fname = get_path(GUI_URLLIST); 412 fname = get_path(gui_urllist);
413 file = fopen(fname, "wt+"); 413 file = fopen(fname, "wt+");
414 414
415 if (file) { 415 if (file) {
416 urlItem *item = urlList; 416 urlItem *item = urlList;
417 417
427 427
428 free(fname); 428 free(fname);
429 429
430 // directory history 430 // directory history
431 431
432 fname = get_path(GUI_HISTORY); 432 fname = get_path(gui_history);
433 file = fopen(fname, "wt+"); 433 file = fopen(fname, "wt+");
434 434
435 if (file) { 435 if (file) {
436 for (i = 0; i < FF_ARRAY_ELEMS(fsHistory); i++) 436 for (i = 0; i < FF_ARRAY_ELEMS(fsHistory); i++)
437 if (fsHistory[i]) 437 if (fsHistory[i])