33 #define DEFAULT_SECTION "audacious"
38 "advance_on_delete",
"FALSE",
39 "clear_playlist",
"TRUE",
40 "open_to_temporary",
"TRUE",
41 "resume_playback_on_startup",
"FALSE",
44 "eqpreset_default_file",
"",
45 "eqpreset_extension",
"",
46 "equalizer_active",
"FALSE",
47 "equalizer_autoload",
"FALSE",
48 "equalizer_bands",
"0,0,0,0,0,0,0,0,0,0",
49 "equalizer_preamp",
"0",
52 "cover_name_exclude",
"back",
53 "cover_name_include",
"album,cover,front,folder",
54 "filepopup_delay",
"5",
55 "filepopup_showprogressbar",
"TRUE",
56 "recurse_for_cover",
"FALSE",
57 "recurse_for_cover_depth",
"0",
58 "show_filepopup_for_tuple",
"TRUE",
59 "use_file_cover",
"FALSE",
63 "use_proxy_auth",
"FALSE",
67 "enable_replay_gain",
"TRUE",
68 "enable_clipping_prevention",
"TRUE",
69 "output_bit_depth",
"16",
70 "output_buffer_size",
"500",
71 "replay_gain_album",
"FALSE",
72 "replay_gain_preamp",
"0",
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",
84 "generic_title_format",
"${?artist:${artist} - }${?album:${album} - }${title}",
85 "leading_zero",
"FALSE",
86 "metadata_on_play",
"FALSE",
87 "show_numbers_in_pl",
"FALSE",
91 static pthread_mutex_t
mutex = PTHREAD_MUTEX_INITIALIZER;
105 pthread_mutex_lock (&
mutex);
107 defaults = g_hash_table_new_full (g_str_hash, g_str_equal, g_free,
108 (GDestroyNotify) g_hash_table_destroy);
112 if (g_file_test (path, G_FILE_TEST_EXISTS))
115 if (! g_key_file_load_from_file (
keyfile, path, 0, & error))
117 fprintf (stderr,
"Error loading config: %s\n", error->message);
118 g_error_free (error);
124 pthread_mutex_unlock (&
mutex);
132 pthread_mutex_lock (&
mutex);
136 pthread_mutex_unlock (&
mutex);
144 if (! g_file_set_contents (path, data, -1, & error))
146 fprintf (stderr,
"Error saving config: %s\n", error->message);
147 g_error_free (error);
154 pthread_mutex_unlock (&
mutex);
160 pthread_mutex_lock (&
mutex);
167 pthread_mutex_unlock (&
mutex);
173 pthread_mutex_lock (&
mutex);
178 if (g_key_file_has_group (
keyfile, section))
184 pthread_mutex_unlock (&
mutex);
190 pthread_mutex_lock (&
mutex);
195 GHashTable *
table = g_hash_table_lookup (
defaults, section);
198 table = g_hash_table_new_full (g_str_hash, g_str_equal, g_free,
str_unref_cb);
199 g_hash_table_replace (
defaults, g_strdup (section), table);
204 const char *
name = * entries ++;
205 const char * value = * entries ++;
206 if (! name || ! value)
209 g_hash_table_replace (table, g_strdup (name),
str_get (value));
212 pthread_mutex_unlock (&
mutex);
217 GHashTable *
table = g_hash_table_lookup (
defaults, section);
218 const char * def = table ? g_hash_table_lookup (table, name) :
NULL;
219 return def ? def :
"";
225 g_return_if_fail (name && value);
226 pthread_mutex_lock (&
mutex);
234 if (! strcmp (value, def))
236 if (g_key_file_has_key (
keyfile, section, name,
NULL))
238 g_key_file_remove_key (
keyfile, section, name,
NULL);
244 char * old = g_key_file_has_key (
keyfile, section, name,
NULL) ?
247 if (! old || strcmp (value, old))
249 g_key_file_set_value (
keyfile, section, name, value);
262 char *
event = g_strdup_printf (
"set %s", name);
268 pthread_mutex_unlock (&
mutex);
274 g_return_val_if_fail (name, g_strdup (
""));
275 pthread_mutex_lock (&
mutex);
280 char * value = g_key_file_has_key (
keyfile, section, name,
NULL) ?
286 pthread_mutex_unlock (&
mutex);
292 set_string (section, name, value ?
"TRUE" :
"FALSE");
298 bool_t value = ! strcmp (
string,
"TRUE");
306 g_return_if_fail (
string);
323 g_return_if_fail (
string);