Mercurial > audlegacy
annotate libaudacious/configdb_xmlfile.c @ 484:fc968772e096 trunk
[svn] Remove ALL Xlib stuff from the skinning engine and use GDK where
applicable instead.
author | nenolod |
---|---|
date | Mon, 23 Jan 2006 12:24:48 -0800 |
parents | 6af6627e14f5 |
children | f12d7e208b43 |
rev | line source |
---|---|
0 | 1 /* This program is free software; you can redistribute it and/or modify |
2 * it under the terms of the GNU General Public License as published by | |
3 * the Free Software Foundation; either version 2 of the License, or | |
4 * (at your option) any later version. | |
5 * | |
6 * This program is distributed in the hope that it will be useful, | |
7 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
8 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
9 * GNU General Public License for more details. | |
10 * | |
11 * You should have received a copy of the GNU General Public License | |
12 * along with this program; if not, write to the Free Software | |
13 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
14 */ | |
15 | |
16 #ifdef HAVE_CONFIG_H | |
17 # include "config.h" | |
18 #endif | |
19 | |
20 #include "configdb.h" | |
21 | |
22 #include <string.h> | |
23 #include "rcfile.h" | |
24 | |
25 struct _ConfigDb | |
26 { | |
463
6af6627e14f5
[svn] Fork off the rcfile backend for conversion into an XML file-based preferences option using GMarkup. This does not work
nenolod
parents:
0
diff
changeset
|
27 BmpXmlDocument *file; |
0 | 28 gchar *filename; |
29 gboolean dirty; | |
30 }; | |
31 | |
463
6af6627e14f5
[svn] Fork off the rcfile backend for conversion into an XML file-based preferences option using GMarkup. This does not work
nenolod
parents:
0
diff
changeset
|
32 #define XMLFILE_DEFAULT_SECTION |
0 | 33 |
34 ConfigDb * | |
35 bmp_cfg_db_open() | |
36 { | |
37 ConfigDb *db; | |
463
6af6627e14f5
[svn] Fork off the rcfile backend for conversion into an XML file-based preferences option using GMarkup. This does not work
nenolod
parents:
0
diff
changeset
|
38 GError *err = NULL; |
0 | 39 |
40 db = g_new(ConfigDb, 1); | |
41 db->filename = g_build_filename(g_get_home_dir(), BMP_RCPATH, | |
463
6af6627e14f5
[svn] Fork off the rcfile backend for conversion into an XML file-based preferences option using GMarkup. This does not work
nenolod
parents:
0
diff
changeset
|
42 "preferences.xml", NULL); |
6af6627e14f5
[svn] Fork off the rcfile backend for conversion into an XML file-based preferences option using GMarkup. This does not work
nenolod
parents:
0
diff
changeset
|
43 bmp_xml_document_load(&db->file, db->filename, &err); |
0 | 44 if (!db->file) |
45 db->file = bmp_rcfile_new(); | |
46 | |
47 db->dirty = FALSE; | |
48 | |
49 return db; | |
50 } | |
51 | |
52 void | |
53 bmp_cfg_db_close(ConfigDb * db) | |
54 { | |
55 if (db->dirty) | |
56 bmp_rcfile_write(db->file, db->filename); | |
57 bmp_rcfile_free(db->file); | |
58 g_free(db->filename); | |
59 } | |
60 | |
61 gboolean | |
62 bmp_cfg_db_get_string(ConfigDb * db, | |
63 const gchar * section, | |
64 const gchar * key, | |
65 gchar ** value) | |
66 { | |
67 if (!section) | |
68 section = RCFILE_DEFAULT_SECTION_NAME; | |
69 | |
70 return bmp_rcfile_read_string(db->file, section, key, value); | |
71 } | |
72 | |
73 gboolean | |
74 bmp_cfg_db_get_int(ConfigDb * db, | |
75 const gchar * section, const gchar * key, gint * value) | |
76 { | |
77 if (!section) | |
78 section = RCFILE_DEFAULT_SECTION_NAME; | |
79 | |
80 return bmp_rcfile_read_int(db->file, section, key, value); | |
81 } | |
82 | |
83 gboolean | |
84 bmp_cfg_db_get_bool(ConfigDb * db, | |
85 const gchar * section, | |
86 const gchar * key, | |
87 gboolean * value) | |
88 { | |
89 if (!section) | |
90 section = RCFILE_DEFAULT_SECTION_NAME; | |
91 | |
92 return bmp_rcfile_read_bool(db->file, section, key, value); | |
93 } | |
94 | |
95 gboolean | |
96 bmp_cfg_db_get_float(ConfigDb * db, | |
97 const gchar * section, | |
98 const gchar * key, | |
99 gfloat * value) | |
100 { | |
101 if (!section) | |
102 section = RCFILE_DEFAULT_SECTION_NAME; | |
103 | |
104 return bmp_rcfile_read_float(db->file, section, key, value); | |
105 } | |
106 | |
107 gboolean | |
108 bmp_cfg_db_get_double(ConfigDb * db, | |
109 const gchar * section, | |
110 const gchar * key, | |
111 gdouble * value) | |
112 { | |
113 if (!section) | |
114 section = RCFILE_DEFAULT_SECTION_NAME; | |
115 | |
116 return bmp_rcfile_read_double(db->file, section, key, value); | |
117 } | |
118 | |
119 void | |
120 bmp_cfg_db_set_string(ConfigDb * db, | |
121 const gchar * section, | |
122 const gchar * key, | |
123 gchar * value) | |
124 { | |
125 db->dirty = TRUE; | |
126 | |
127 if (!section) | |
128 section = RCFILE_DEFAULT_SECTION_NAME; | |
129 | |
130 bmp_rcfile_write_string(db->file, section, key, value); | |
131 } | |
132 | |
133 void | |
134 bmp_cfg_db_set_int(ConfigDb * db, | |
135 const gchar * section, | |
136 const gchar * key, | |
137 gint value) | |
138 { | |
139 db->dirty = TRUE; | |
140 | |
141 if (!section) | |
142 section = RCFILE_DEFAULT_SECTION_NAME; | |
143 | |
144 bmp_rcfile_write_int(db->file, section, key, value); | |
145 } | |
146 | |
147 void | |
148 bmp_cfg_db_set_bool(ConfigDb * db, | |
149 const gchar * section, | |
150 const gchar * key, | |
151 gboolean value) | |
152 { | |
153 db->dirty = TRUE; | |
154 | |
155 if (!section) | |
156 section = RCFILE_DEFAULT_SECTION_NAME; | |
157 | |
158 bmp_rcfile_write_boolean(db->file, section, key, value); | |
159 } | |
160 | |
161 void | |
162 bmp_cfg_db_set_float(ConfigDb * db, | |
163 const gchar * section, | |
164 const gchar * key, | |
165 gfloat value) | |
166 { | |
167 db->dirty = TRUE; | |
168 | |
169 if (!section) | |
170 section = RCFILE_DEFAULT_SECTION_NAME; | |
171 | |
172 bmp_rcfile_write_float(db->file, section, key, value); | |
173 } | |
174 | |
175 void | |
176 bmp_cfg_db_set_double(ConfigDb * db, | |
177 const gchar * section, | |
178 const gchar * key, | |
179 gdouble value) | |
180 { | |
181 db->dirty = TRUE; | |
182 | |
183 if (!section) | |
184 section = RCFILE_DEFAULT_SECTION_NAME; | |
185 | |
186 bmp_rcfile_write_double(db->file, section, key, value); | |
187 } | |
188 | |
189 void | |
190 bmp_cfg_db_unset_key(ConfigDb * db, | |
191 const gchar * section, | |
192 const gchar * key) | |
193 { | |
194 db->dirty = TRUE; | |
195 | |
196 g_return_if_fail(db != NULL); | |
197 g_return_if_fail(key != NULL); | |
198 | |
199 if (!section) | |
200 section = RCFILE_DEFAULT_SECTION_NAME; | |
201 | |
202 bmp_rcfile_remove_key(db->file, section, key); | |
203 } |