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",
42 "eqpreset_default_file",
"",
43 "eqpreset_extension",
"",
44 "equalizer_active",
"FALSE",
45 "equalizer_autoload",
"FALSE",
46 "equalizer_bands",
"0,0,0,0,0,0,0,0,0,0",
47 "equalizer_preamp",
"0",
50 "cover_name_exclude",
"back",
51 "cover_name_include",
"album,cover,front,folder",
52 "filepopup_delay",
"5",
53 "filepopup_showprogressbar",
"TRUE",
54 "recurse_for_cover",
"FALSE",
55 "recurse_for_cover_depth",
"0",
56 "show_filepopup_for_tuple",
"TRUE",
57 "use_file_cover",
"FALSE",
61 "use_proxy_auth",
"FALSE",
65 "enable_replay_gain",
"TRUE",
66 "enable_clipping_prevention",
"TRUE",
67 "output_bit_depth",
"16",
68 "output_buffer_size",
"500",
69 "replay_gain_album",
"FALSE",
70 "replay_gain_preamp",
"0",
71 "soft_clipping",
"FALSE",
72 "software_volume_control",
"FALSE",
73 "sw_volume_left",
"100",
74 "sw_volume_right",
"100",
77 "no_playlist_advance",
"FALSE",
80 "stop_after_current_song",
"FALSE",
84 "convert_backslash",
"TRUE",
86 "convert_backslash",
"FALSE",
88 "generic_title_format",
"${?artist:${artist} - }${?album:${album} - }${title}",
89 "leading_zero",
"FALSE",
90 "metadata_on_play",
"FALSE",
91 "show_numbers_in_pl",
"FALSE",
95 static pthread_mutex_t
mutex = PTHREAD_MUTEX_INITIALIZER;
109 pthread_mutex_lock (&
mutex);
111 defaults = g_hash_table_new_full (g_str_hash, g_str_equal, g_free,
112 (GDestroyNotify) g_hash_table_destroy);
116 if (g_file_test (path, G_FILE_TEST_EXISTS))
119 if (! g_key_file_load_from_file (
keyfile, path, 0, & error))
121 fprintf (stderr,
"Error loading config: %s\n", error->message);
122 g_error_free (error);
128 pthread_mutex_unlock (&
mutex);
136 pthread_mutex_lock (&
mutex);
140 pthread_mutex_unlock (&
mutex);
148 if (! g_file_set_contents (path, data, -1, & error))
150 fprintf (stderr,
"Error saving config: %s\n", error->message);
151 g_error_free (error);
158 pthread_mutex_unlock (&
mutex);
164 pthread_mutex_lock (&
mutex);
171 pthread_mutex_unlock (&
mutex);
177 pthread_mutex_lock (&
mutex);
182 if (g_key_file_has_group (
keyfile, section))
188 pthread_mutex_unlock (&
mutex);
194 pthread_mutex_lock (&
mutex);
199 GHashTable *
table = g_hash_table_lookup (
defaults, section);
202 table = g_hash_table_new_full (g_str_hash, g_str_equal, g_free,
str_unref_cb);
203 g_hash_table_replace (
defaults, g_strdup (section), table);
208 const char *
name = * entries ++;
209 const char * value = * entries ++;
210 if (! name || ! value)
213 g_hash_table_replace (table, g_strdup (name),
str_get (value));
216 pthread_mutex_unlock (&
mutex);
221 GHashTable *
table = g_hash_table_lookup (
defaults, section);
222 const char * def = table ? g_hash_table_lookup (table, name) :
NULL;
223 return def ? def :
"";
229 g_return_if_fail (name && value);
230 pthread_mutex_lock (&
mutex);
238 if (! strcmp (value, def))
240 if (g_key_file_has_key (
keyfile, section, name,
NULL))
242 g_key_file_remove_key (
keyfile, section, name,
NULL);
248 char * old = g_key_file_has_key (
keyfile, section, name,
NULL) ?
251 if (! old || strcmp (value, old))
253 g_key_file_set_value (
keyfile, section, name, value);
266 char *
event = g_strdup_printf (
"set %s", name);
272 pthread_mutex_unlock (&
mutex);
278 g_return_val_if_fail (name, g_strdup (
""));
279 pthread_mutex_lock (&
mutex);
284 char * value = g_key_file_has_key (
keyfile, section, name,
NULL) ?
290 pthread_mutex_unlock (&
mutex);
296 set_string (section, name, value ?
"TRUE" :
"FALSE");
302 bool_t value = ! strcmp (
string,
"TRUE");
310 g_return_if_fail (
string);
327 g_return_if_fail (
string);