31 #define DEFAULT_SECTION "audacious"
36 "advance_on_delete",
"FALSE",
37 "clear_playlist",
"TRUE",
38 "open_to_temporary",
"TRUE",
39 "resume_playback_on_startup",
"FALSE",
40 "show_interface",
"TRUE",
43 "eqpreset_default_file",
"",
44 "eqpreset_extension",
"",
45 "equalizer_active",
"FALSE",
46 "equalizer_autoload",
"FALSE",
47 "equalizer_bands",
"0,0,0,0,0,0,0,0,0,0",
48 "equalizer_preamp",
"0",
51 "cover_name_exclude",
"back",
52 "cover_name_include",
"album,cover,front,folder",
53 "filepopup_delay",
"5",
54 "filepopup_showprogressbar",
"TRUE",
55 "recurse_for_cover",
"FALSE",
56 "recurse_for_cover_depth",
"0",
57 "show_filepopup_for_tuple",
"TRUE",
58 "use_file_cover",
"FALSE",
62 "use_proxy_auth",
"FALSE",
66 "enable_replay_gain",
"TRUE",
67 "enable_clipping_prevention",
"TRUE",
68 "output_bit_depth",
"16",
69 "output_buffer_size",
"500",
70 "replay_gain_album",
"FALSE",
71 "replay_gain_preamp",
"0",
72 "soft_clipping",
"FALSE",
73 "software_volume_control",
"FALSE",
74 "sw_volume_left",
"100",
75 "sw_volume_right",
"100",
78 "no_playlist_advance",
"FALSE",
81 "stop_after_current_song",
"FALSE",
85 "convert_backslash",
"TRUE",
87 "convert_backslash",
"FALSE",
89 "generic_title_format",
"${?artist:${artist} - }${?album:${album} - }${title}",
90 "leading_zero",
"FALSE",
91 "metadata_on_play",
"FALSE",
92 "show_numbers_in_pl",
"FALSE",
96 static pthread_mutex_t
mutex = PTHREAD_MUTEX_INITIALIZER;
110 pthread_mutex_lock (&
mutex);
112 defaults = g_hash_table_new_full (g_str_hash, g_str_equal, g_free,
113 (GDestroyNotify) g_hash_table_destroy);
117 if (g_file_test (path, G_FILE_TEST_EXISTS))
120 if (! g_key_file_load_from_file (
keyfile, path, 0, & error))
122 fprintf (stderr,
"Error loading config: %s\n", error->message);
123 g_error_free (error);
129 pthread_mutex_unlock (&
mutex);
137 pthread_mutex_lock (&
mutex);
141 pthread_mutex_unlock (&
mutex);
149 if (! g_file_set_contents (path, data, -1, & error))
151 fprintf (stderr,
"Error saving config: %s\n", error->message);
152 g_error_free (error);
159 pthread_mutex_unlock (&
mutex);
165 pthread_mutex_lock (&
mutex);
172 pthread_mutex_unlock (&
mutex);
178 pthread_mutex_lock (&
mutex);
183 if (g_key_file_has_group (
keyfile, section))
189 pthread_mutex_unlock (&
mutex);
195 pthread_mutex_lock (&
mutex);
200 GHashTable *
table = g_hash_table_lookup (
defaults, section);
203 table = g_hash_table_new_full (g_str_hash, g_str_equal, g_free,
str_unref_cb);
204 g_hash_table_replace (
defaults, g_strdup (section), table);
209 const char *
name = * entries ++;
210 const char * value = * entries ++;
211 if (! name || ! value)
214 g_hash_table_replace (table, g_strdup (name),
str_get (value));
217 pthread_mutex_unlock (&
mutex);
222 GHashTable *
table = g_hash_table_lookup (
defaults, section);
223 const char * def = table ? g_hash_table_lookup (table, name) :
NULL;
224 return def ? def :
"";
230 g_return_if_fail (name && value);
231 pthread_mutex_lock (&
mutex);
239 if (! strcmp (value, def))
241 if (g_key_file_has_key (
keyfile, section, name,
NULL))
243 g_key_file_remove_key (
keyfile, section, name,
NULL);
249 char * old = g_key_file_has_key (
keyfile, section, name,
NULL) ?
252 if (! old || strcmp (value, old))
254 g_key_file_set_value (
keyfile, section, name, value);
267 char *
event = g_strdup_printf (
"set %s", name);
273 pthread_mutex_unlock (&
mutex);
279 g_return_val_if_fail (name, g_strdup (
""));
280 pthread_mutex_lock (&
mutex);
285 char * value = g_key_file_has_key (
keyfile, section, name,
NULL) ?
291 pthread_mutex_unlock (&
mutex);
297 set_string (section, name, value ?
"TRUE" :
"FALSE");
303 bool_t value = ! strcmp (
string,
"TRUE");
311 g_return_if_fail (
string);
328 g_return_if_fail (
string);