Mercurial > audlegacy-plugins
annotate src/skins/skins_cfg.c @ 2582:9b4dfc007b87
use more local configuration options
author | Tomasz Mon <desowin@gmail.com> |
---|---|
date | Tue, 20 May 2008 15:36:47 +0200 |
parents | 6a0755e8c1b3 |
children | 294232665cb0 |
rev | line source |
---|---|
2572
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
1 /* |
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
2 * Audacious - a cross-platform multimedia player |
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
3 * Copyright (c) 2008 Tomasz Moń |
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
4 * |
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
5 * This program is free software; you can redistribute it and/or modify |
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
6 * it under the terms of the GNU General Public License as published by |
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
7 * the Free Software Foundation; under version 3 of the License. |
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
8 * |
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
9 * This program is distributed in the hope that it will be useful, |
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
12 * GNU General Public License for more details. |
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
13 * |
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
14 * You should have received a copy of the GNU General Public License |
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
15 * along with this program. If not, see <http://www.gnu.org/licenses>. |
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
16 * |
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
17 * The Audacious team does not consider modular code linking to |
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
18 * Audacious or using our public API to be a derived work. |
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
19 */ |
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
20 |
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
21 |
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
22 #include "skins_cfg.h" |
2581 | 23 #include "ui_skin.h" |
2572
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
24 #include <glib.h> |
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
25 #include <stdlib.h> |
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
26 #include <audacious/plugin.h> |
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
27 |
2582
9b4dfc007b87
use more local configuration options
Tomasz Mon <desowin@gmail.com>
parents:
2581
diff
changeset
|
28 skins_cfg_t config; |
9b4dfc007b87
use more local configuration options
Tomasz Mon <desowin@gmail.com>
parents:
2581
diff
changeset
|
29 |
9b4dfc007b87
use more local configuration options
Tomasz Mon <desowin@gmail.com>
parents:
2581
diff
changeset
|
30 skins_cfg_t skins_default_config = { |
9b4dfc007b87
use more local configuration options
Tomasz Mon <desowin@gmail.com>
parents:
2581
diff
changeset
|
31 .scaled = FALSE, |
9b4dfc007b87
use more local configuration options
Tomasz Mon <desowin@gmail.com>
parents:
2581
diff
changeset
|
32 .always_on_top = FALSE, |
9b4dfc007b87
use more local configuration options
Tomasz Mon <desowin@gmail.com>
parents:
2581
diff
changeset
|
33 .scale_factor = 2.0, |
9b4dfc007b87
use more local configuration options
Tomasz Mon <desowin@gmail.com>
parents:
2581
diff
changeset
|
34 .always_show_cb = TRUE, |
9b4dfc007b87
use more local configuration options
Tomasz Mon <desowin@gmail.com>
parents:
2581
diff
changeset
|
35 .skin = NULL, |
9b4dfc007b87
use more local configuration options
Tomasz Mon <desowin@gmail.com>
parents:
2581
diff
changeset
|
36 .player_shaded = FALSE, |
9b4dfc007b87
use more local configuration options
Tomasz Mon <desowin@gmail.com>
parents:
2581
diff
changeset
|
37 .equalizer_shaded = FALSE, |
9b4dfc007b87
use more local configuration options
Tomasz Mon <desowin@gmail.com>
parents:
2581
diff
changeset
|
38 .playlist_shaded = FALSE, |
9b4dfc007b87
use more local configuration options
Tomasz Mon <desowin@gmail.com>
parents:
2581
diff
changeset
|
39 .dim_titlebar = TRUE, |
9b4dfc007b87
use more local configuration options
Tomasz Mon <desowin@gmail.com>
parents:
2581
diff
changeset
|
40 .show_wm_decorations = FALSE, |
9b4dfc007b87
use more local configuration options
Tomasz Mon <desowin@gmail.com>
parents:
2581
diff
changeset
|
41 .easy_move = TRUE, |
9b4dfc007b87
use more local configuration options
Tomasz Mon <desowin@gmail.com>
parents:
2581
diff
changeset
|
42 }; |
9b4dfc007b87
use more local configuration options
Tomasz Mon <desowin@gmail.com>
parents:
2581
diff
changeset
|
43 |
9b4dfc007b87
use more local configuration options
Tomasz Mon <desowin@gmail.com>
parents:
2581
diff
changeset
|
44 typedef struct skins_cfg_boolent_t { |
9b4dfc007b87
use more local configuration options
Tomasz Mon <desowin@gmail.com>
parents:
2581
diff
changeset
|
45 char const *be_vname; |
9b4dfc007b87
use more local configuration options
Tomasz Mon <desowin@gmail.com>
parents:
2581
diff
changeset
|
46 gboolean *be_vloc; |
9b4dfc007b87
use more local configuration options
Tomasz Mon <desowin@gmail.com>
parents:
2581
diff
changeset
|
47 gboolean be_wrt; |
9b4dfc007b87
use more local configuration options
Tomasz Mon <desowin@gmail.com>
parents:
2581
diff
changeset
|
48 } skins_cfg_boolent; |
9b4dfc007b87
use more local configuration options
Tomasz Mon <desowin@gmail.com>
parents:
2581
diff
changeset
|
49 |
9b4dfc007b87
use more local configuration options
Tomasz Mon <desowin@gmail.com>
parents:
2581
diff
changeset
|
50 static skins_cfg_boolent skins_boolents[] = { |
9b4dfc007b87
use more local configuration options
Tomasz Mon <desowin@gmail.com>
parents:
2581
diff
changeset
|
51 {"always_show_cb", &config.always_show_cb, TRUE}, |
9b4dfc007b87
use more local configuration options
Tomasz Mon <desowin@gmail.com>
parents:
2581
diff
changeset
|
52 {"always_on_top", &config.always_on_top, TRUE}, |
9b4dfc007b87
use more local configuration options
Tomasz Mon <desowin@gmail.com>
parents:
2581
diff
changeset
|
53 {"always_show_cb", &config.always_show_cb, TRUE}, |
9b4dfc007b87
use more local configuration options
Tomasz Mon <desowin@gmail.com>
parents:
2581
diff
changeset
|
54 {"scaled", &config.scaled, TRUE}, |
9b4dfc007b87
use more local configuration options
Tomasz Mon <desowin@gmail.com>
parents:
2581
diff
changeset
|
55 {"player_shaded", &config.player_shaded, TRUE}, |
9b4dfc007b87
use more local configuration options
Tomasz Mon <desowin@gmail.com>
parents:
2581
diff
changeset
|
56 {"equalizer_shaded", &config.equalizer_shaded, TRUE}, |
9b4dfc007b87
use more local configuration options
Tomasz Mon <desowin@gmail.com>
parents:
2581
diff
changeset
|
57 {"playlist_shaded", &config.playlist_shaded, TRUE}, |
9b4dfc007b87
use more local configuration options
Tomasz Mon <desowin@gmail.com>
parents:
2581
diff
changeset
|
58 {"dim_titlebar", &config.dim_titlebar, TRUE}, |
9b4dfc007b87
use more local configuration options
Tomasz Mon <desowin@gmail.com>
parents:
2581
diff
changeset
|
59 {"show_wm_decorations", &config.show_wm_decorations, TRUE}, |
9b4dfc007b87
use more local configuration options
Tomasz Mon <desowin@gmail.com>
parents:
2581
diff
changeset
|
60 {"easy_move", &config.easy_move, TRUE}, |
9b4dfc007b87
use more local configuration options
Tomasz Mon <desowin@gmail.com>
parents:
2581
diff
changeset
|
61 }; |
9b4dfc007b87
use more local configuration options
Tomasz Mon <desowin@gmail.com>
parents:
2581
diff
changeset
|
62 |
9b4dfc007b87
use more local configuration options
Tomasz Mon <desowin@gmail.com>
parents:
2581
diff
changeset
|
63 static gint ncfgbent = G_N_ELEMENTS(skins_boolents); |
9b4dfc007b87
use more local configuration options
Tomasz Mon <desowin@gmail.com>
parents:
2581
diff
changeset
|
64 |
9b4dfc007b87
use more local configuration options
Tomasz Mon <desowin@gmail.com>
parents:
2581
diff
changeset
|
65 void skins_cfg_free() { |
9b4dfc007b87
use more local configuration options
Tomasz Mon <desowin@gmail.com>
parents:
2581
diff
changeset
|
66 if (config.skin) { g_free(config.skin); config.skin = NULL; } |
2572
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
67 } |
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
68 |
2582
9b4dfc007b87
use more local configuration options
Tomasz Mon <desowin@gmail.com>
parents:
2581
diff
changeset
|
69 void skins_cfg_load() { |
9b4dfc007b87
use more local configuration options
Tomasz Mon <desowin@gmail.com>
parents:
2581
diff
changeset
|
70 mcs_handle_t *cfgfile = aud_cfg_db_open(); |
2572
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
71 |
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
72 /* if (!aud_cfg_db_get_int(cfgfile, "skins", "field_name", &(cfg->where))) |
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
73 cfg->where = default value |
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
74 if (!aud_cfg_db_get_string(cfgfile, "skins", "field_name", &(cfg->where))) |
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
75 cfg->where = g_strdup("defaul"); |
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
76 if (!aud_cfg_db_get_bool(cfgfile, "skins", "field_name", &(cfg->where))) |
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
77 cfg->where = FALSE / TRUE; |
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
78 */ |
2582
9b4dfc007b87
use more local configuration options
Tomasz Mon <desowin@gmail.com>
parents:
2581
diff
changeset
|
79 |
9b4dfc007b87
use more local configuration options
Tomasz Mon <desowin@gmail.com>
parents:
2581
diff
changeset
|
80 memcpy(&config, &skins_default_config, sizeof(skins_cfg_t)); |
9b4dfc007b87
use more local configuration options
Tomasz Mon <desowin@gmail.com>
parents:
2581
diff
changeset
|
81 int i; |
9b4dfc007b87
use more local configuration options
Tomasz Mon <desowin@gmail.com>
parents:
2581
diff
changeset
|
82 |
9b4dfc007b87
use more local configuration options
Tomasz Mon <desowin@gmail.com>
parents:
2581
diff
changeset
|
83 for (i = 0; i < ncfgbent; ++i) { |
9b4dfc007b87
use more local configuration options
Tomasz Mon <desowin@gmail.com>
parents:
2581
diff
changeset
|
84 aud_cfg_db_get_bool(cfgfile, "skins", |
9b4dfc007b87
use more local configuration options
Tomasz Mon <desowin@gmail.com>
parents:
2581
diff
changeset
|
85 skins_boolents[i].be_vname, |
9b4dfc007b87
use more local configuration options
Tomasz Mon <desowin@gmail.com>
parents:
2581
diff
changeset
|
86 skins_boolents[i].be_vloc); |
9b4dfc007b87
use more local configuration options
Tomasz Mon <desowin@gmail.com>
parents:
2581
diff
changeset
|
87 } |
2581 | 88 |
2582
9b4dfc007b87
use more local configuration options
Tomasz Mon <desowin@gmail.com>
parents:
2581
diff
changeset
|
89 if (!aud_cfg_db_get_string(cfgfile, "skins", "skin", &(config.skin))) |
9b4dfc007b87
use more local configuration options
Tomasz Mon <desowin@gmail.com>
parents:
2581
diff
changeset
|
90 config.skin = g_strdup(BMP_DEFAULT_SKIN_PATH); |
2573
c0b08527b121
allow loading compressed skins
Tomasz Mon <desowin@gmail.com>
parents:
2572
diff
changeset
|
91 |
2582
9b4dfc007b87
use more local configuration options
Tomasz Mon <desowin@gmail.com>
parents:
2581
diff
changeset
|
92 if (!aud_cfg_db_get_float(cfgfile, "skins", "scale_factor", &(config.scale_factor))) |
9b4dfc007b87
use more local configuration options
Tomasz Mon <desowin@gmail.com>
parents:
2581
diff
changeset
|
93 config.scale_factor = 2.0; |
2572
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
94 |
2582
9b4dfc007b87
use more local configuration options
Tomasz Mon <desowin@gmail.com>
parents:
2581
diff
changeset
|
95 aud_cfg_db_close(cfgfile); |
2572
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
96 } |
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
97 |
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
98 |
2582
9b4dfc007b87
use more local configuration options
Tomasz Mon <desowin@gmail.com>
parents:
2581
diff
changeset
|
99 void skins_cfg_save(skins_cfg_t * cfg) { |
2572
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
100 mcs_handle_t *cfgfile = aud_cfg_db_open(); |
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
101 |
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
102 /* |
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
103 aud_cfg_db_set_int(cfgfile, "skins", "field_name", cfg->where); |
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
104 aud_cfg_db_set_string(cfgfile, "skins", "field_name", cfg->where); |
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
105 aud_cfg_db_set_bool(cfgfile, "skins", "field_name", cfg->where); |
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
106 */ |
2573
c0b08527b121
allow loading compressed skins
Tomasz Mon <desowin@gmail.com>
parents:
2572
diff
changeset
|
107 aud_cfg_db_set_string(cfgfile, "skins", "skin", cfg->skin); |
2572
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
108 |
2582
9b4dfc007b87
use more local configuration options
Tomasz Mon <desowin@gmail.com>
parents:
2581
diff
changeset
|
109 int i; |
2572
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
110 |
2582
9b4dfc007b87
use more local configuration options
Tomasz Mon <desowin@gmail.com>
parents:
2581
diff
changeset
|
111 for (i = 0; i < ncfgbent; ++i) |
9b4dfc007b87
use more local configuration options
Tomasz Mon <desowin@gmail.com>
parents:
2581
diff
changeset
|
112 if (skins_boolents[i].be_wrt) |
9b4dfc007b87
use more local configuration options
Tomasz Mon <desowin@gmail.com>
parents:
2581
diff
changeset
|
113 aud_cfg_db_set_bool(cfgfile, "skins", |
9b4dfc007b87
use more local configuration options
Tomasz Mon <desowin@gmail.com>
parents:
2581
diff
changeset
|
114 skins_boolents[i].be_vname, |
9b4dfc007b87
use more local configuration options
Tomasz Mon <desowin@gmail.com>
parents:
2581
diff
changeset
|
115 *skins_boolents[i].be_vloc); |
9b4dfc007b87
use more local configuration options
Tomasz Mon <desowin@gmail.com>
parents:
2581
diff
changeset
|
116 |
9b4dfc007b87
use more local configuration options
Tomasz Mon <desowin@gmail.com>
parents:
2581
diff
changeset
|
117 aud_cfg_db_close(cfgfile); |
2572
d0daee216c8d
stub (really incomplete) for skin engine plugin
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
118 } |