Mercurial > audlegacy
annotate src/audacious/main.c @ 2711:c35913222440 trunk
[svn] Initial commit of dbus client library for plugins. Various changes were made to the plugin structure to support dbus.
author | magma |
---|---|
date | Wed, 09 May 2007 14:36:37 -0700 |
parents | 47ea8eedd428 |
children | 6884a2144a01 |
rev | line source |
---|---|
2313 | 1 /* Audacious - Cross-platform multimedia player |
2 * Copyright (C) 2005-2007 Audacious development team. | |
3 * | |
4 * Based on BMP: | |
5 * Copyright (C) 2003-2004 BMP development team. | |
6 * | |
7 * Based on XMMS: | |
8 * Copyright (C) 1998-2003 XMMS development team. | |
9 * | |
10 * This program is free software; you can redistribute it and/or modify | |
11 * it under the terms of the GNU General Public License as published by | |
12 * the Free Software Foundation; under version 2 of the License. | |
13 * | |
14 * This program is distributed in the hope that it will be useful, | |
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 * GNU General Public License for more details. | |
18 * | |
19 * You should have received a copy of the GNU General Public License | |
20 * along with this program; if not, write to the Free Software | |
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
22 */ | |
23 | |
24 #ifdef HAVE_CONFIG_H | |
25 # include "config.h" | |
26 #endif | |
27 | |
28 #include "main.h" | |
29 | |
30 #include <glib.h> | |
31 #include <glib/gi18n.h> | |
32 #include <glib/gprintf.h> | |
33 #include <gdk/gdk.h> | |
34 #include <stdlib.h> | |
35 #include <string.h> | |
36 #include <getopt.h> | |
37 #include <ctype.h> | |
38 #include <time.h> | |
39 | |
40 #include <unistd.h> | |
41 #include <errno.h> | |
42 #include <sys/types.h> | |
43 #include <sys/stat.h> | |
44 #include <signal.h> | |
45 | |
46 #include "platform/smartinclude.h" | |
47 | |
48 #include "libaudacious/configdb.h" | |
49 #include "libaudacious/beepctrl.h" | |
50 #include "vfs.h" | |
51 | |
2694
c2b82432c1b6
[svn] Added basic DBus support, disabled by default with a configuration option to enable it. The general and playback information/manipulation methods are currently the only ones implemented. That is version, play, pause, stop, playing, paused, stopped, status, and seek. There are stubs for many unimplemented methods.
magma
parents:
2682
diff
changeset
|
52 #ifdef USE_DBUS |
2711
c35913222440
[svn] Initial commit of dbus client library for plugins. Various changes were made to the plugin structure to support dbus.
magma
parents:
2709
diff
changeset
|
53 # include "dbus-service.h" |
2694
c2b82432c1b6
[svn] Added basic DBus support, disabled by default with a configuration option to enable it. The general and playback information/manipulation methods are currently the only ones implemented. That is version, play, pause, stop, playing, paused, stopped, status, and seek. There are stubs for many unimplemented methods.
magma
parents:
2682
diff
changeset
|
54 #endif |
c2b82432c1b6
[svn] Added basic DBus support, disabled by default with a configuration option to enable it. The general and playback information/manipulation methods are currently the only ones implemented. That is version, play, pause, stop, playing, paused, stopped, status, and seek. There are stubs for many unimplemented methods.
magma
parents:
2682
diff
changeset
|
55 |
2313 | 56 #include "dnd.h" |
57 #include "effect.h" | |
58 #include "ui_equalizer.h" | |
59 #include "general.h" | |
60 #include "genevent.h" | |
61 #include "hints.h" | |
62 #include "input.h" | |
63 #include "logger.h" | |
64 #include "ui_main.h" | |
65 #include "ui_manager.h" | |
66 #include "output.h" | |
67 #include "playback.h" | |
68 #include "playlist.h" | |
69 #include "ui_playlist.h" | |
70 #include "ui_preferences.h" | |
71 #include "pluginenum.h" | |
72 #include "ui_skinselector.h" | |
73 #include "util.h" | |
74 #include "visualization.h" | |
75 #include "build_stamp.h" | |
76 #include "ui_fileinfo.h" | |
77 #include "signals.h" | |
2530 | 78 #include "ui_skinned_window.h" |
2313 | 79 |
80 #include "icons-csource.h" | |
81 #include "icons-stock.h" | |
82 #include "images/audacious_player.xpm" | |
83 | |
2364 | 84 gboolean has_x11_connection = FALSE; /* do we have an X11 connection? */ |
2313 | 85 |
86 /* Translatable string for beep.desktop's comment field */ | |
87 const gchar *desktop_comment = N_("Audacious"); | |
88 | |
89 const gchar *application_name = N_("Audacious"); | |
90 | |
91 | |
92 struct _BmpCmdLineOpt { | |
2411 | 93 gchar **filenames; |
2313 | 94 gint session; |
95 gboolean play, stop, pause, fwd, rew, play_pause, playcd, show_jump_box; | |
96 gboolean enqueue, mainwin, remote, activate; | |
97 gboolean load_skins; | |
98 gboolean headless; | |
99 gboolean no_log; | |
100 gboolean enqueue_to_temp; | |
2411 | 101 gboolean version; |
2313 | 102 gchar *previous_session_id; |
103 }; | |
104 | |
105 typedef struct _BmpCmdLineOpt BmpCmdLineOpt; | |
106 | |
107 BmpCmdLineOpt options; | |
108 | |
109 BmpConfig cfg; | |
110 | |
111 BmpConfig bmp_default_config = { | |
112 MAINWIN_DEFAULT_POS_X, /* mainwin x position */ | |
113 MAINWIN_DEFAULT_POS_Y, /* mainwin y position */ | |
114 EQUALIZER_DEFAULT_POS_X, /* equalizer x position */ | |
115 EQUALIZER_DEFAULT_POS_Y, /* equalizer y position */ | |
116 PLAYLISTWIN_DEFAULT_POS_X, /* playlistwin x position */ | |
117 PLAYLISTWIN_DEFAULT_POS_Y, /* playlistwin y position */ | |
118 PLAYLISTWIN_DEFAULT_WIDTH, /* playlistwin width */ | |
119 PLAYLISTWIN_DEFAULT_HEIGHT, /* playlistwin height */ | |
120 10, /* snap distance */ | |
121 FALSE, /* real-time priority */ | |
122 FALSE, FALSE, /* shuffle, repeat */ | |
123 FALSE, /* UNUSED (double size) */ | |
124 TRUE, /* autoscroll */ | |
125 TRUE, /* analyzer peaks */ | |
126 FALSE, /* equalizer autoload */ | |
127 FALSE, /* easy move */ | |
128 FALSE, /* equalizer active */ | |
129 FALSE, /* playlistwin visible */ | |
130 FALSE, /* equalizer visible */ | |
131 TRUE, /* player visible */ | |
132 FALSE, /* player shaded */ | |
133 FALSE, /* playlistwin shaded */ | |
134 FALSE, /* equalizer shaded */ | |
135 FALSE, /* allow multiple instances */ | |
136 TRUE, /* always show cb */ | |
137 TRUE, TRUE, TRUE, /* convert '_', %20 and '\' */ | |
138 TRUE, /* show numbers in playlist */ | |
139 TRUE, /* snap windows */ | |
140 TRUE, /* save window positions */ | |
141 TRUE, /* dim titlebar */ | |
142 FALSE, /* get playlist info on load */ | |
143 TRUE, /* get playlist info on demand */ | |
144 TRUE, /* UNUSED (equalizer doublesize linked) */ | |
145 FALSE, /* sort jump to file */ | |
146 FALSE, /* use effect plugins */ | |
147 FALSE, /* always on top */ | |
148 FALSE, /* sticky */ | |
149 FALSE, /* no playlist advance */ | |
150 FALSE, /* stop after current song */ | |
151 TRUE, /* refresh file list */ | |
152 TRUE, /* UNUSED (smooth title scrolling) */ | |
153 TRUE, /* use playlist metadata */ | |
2662
09b404d61ebd
[svn] - remove the unplayable files dialog. it is more annoying than useful.
nenolod
parents:
2651
diff
changeset
|
154 TRUE, /* deprecated */ |
2651
4d5e6a8717dd
[svn] - allow the player to start with all of its windows hidden (but give a warning to the user, whose display can be disabled); also, try to remember player windows positions when they stay hidden between sessions
giacomo
parents:
2644
diff
changeset
|
155 TRUE, /* warn about windows visibility */ |
2313 | 156 FALSE, /* use \ as directory delimiter */ |
157 FALSE, /* random skin on play */ | |
158 FALSE, /* use fontsets */ | |
159 FALSE, /* use X font for mainwin */ | |
2364 | 160 TRUE, /* use custom cursors */ |
161 TRUE, /* close dialog on open */ | |
162 TRUE, /* close dialog on add */ | |
2313 | 163 0.0, /* equalizer preamp */ |
164 {0, 0, 0, 0, 0, /* equalizer bands */ | |
165 0, 0, 0, 0, 0}, | |
166 NULL, /* skin */ | |
167 NULL, /* output plugin */ | |
168 NULL, /* file selector path */ | |
169 NULL, /* playlist path */ | |
170 NULL, /* playlist font */ | |
171 NULL, /* mainwin font */ | |
172 NULL, /* disabled input plugins */ | |
173 NULL, /* enabled general plugins */ | |
174 NULL, /* enabled visualization plugins */ | |
175 NULL, /* enabled effect plugins */ | |
176 NULL, /* equalizer preset default file */ | |
177 NULL, /* equalizer preset extension */ | |
178 NULL, /* URL history */ | |
179 0, /* timer mode */ | |
180 VIS_ANALYZER, /* visualizer type */ | |
181 ANALYZER_NORMAL, /* analyzer mode */ | |
182 ANALYZER_BARS, /* analyzer type */ | |
183 SCOPE_DOT, /* scope mode */ | |
184 VOICEPRINT_NORMAL, /* voiceprint mode */ | |
185 VU_SMOOTH, /* VU mode */ | |
186 REFRESH_FULL, /* visualizer refresh rate */ | |
187 FALLOFF_FAST, /* analyzer fall off rate */ | |
188 FALLOFF_SLOW, /* peaks fall off rate */ | |
189 0, /* playlist position */ | |
190 2, /* pause between songs time */ | |
191 FALSE, /* pause between songs */ | |
192 FALSE, /* show window decorations */ | |
193 8, /* mouse wheel scroll step */ | |
194 FALSE, /* playlist transparent */ | |
195 2, /* 3rd preset (ARTIST - ALBUM - TITLE) */ | |
196 NULL, /* title format */ | |
197 FALSE, /* software volume control enabled */ | |
198 TRUE, /* UNUSED (XMMS compatibility mode) */ | |
199 TRUE, /* extra eq filtering */ | |
200 3, /* scroll pl by */ | |
201 FALSE, /* resume playback on startup */ | |
202 -1, /* resume playback on startup time */ | |
2364 | 203 TRUE, /* show seperators in pl */ |
2313 | 204 NULL, |
205 NULL, | |
2364 | 206 3000, /* audio buffer size */ |
207 FALSE, /* whether or not to postpone format detection on initial add */ | |
208 TRUE, /* show filepopup for tuple */ | |
209 NULL, /* words identifying covers */ | |
210 NULL, /* words that might not show up in cover names */ | |
2313 | 211 FALSE, |
212 0, | |
2364 | 213 NULL, /* default session uri base (non-NULL = custom session uri base) */ |
214 150, /* short side length of the picture in the filepopup */ | |
215 20, /* delay until the filepopup comes up */ | |
216 FALSE, /* use filename.jpg for coverart */ | |
217 FALSE, /* use XMMS-style file selection */ | |
218 TRUE, /* use extension probing */ | |
219 255, 255, 255, /* colorize r, g, b */ | |
220 FALSE, /* internal: whether or not to terminate */ | |
2405 | 221 TRUE, /* whether show progress bar in filepopup or not */ |
2313 | 222 }; |
223 | |
224 typedef struct bmp_cfg_boolent_t { | |
225 char const *be_vname; | |
226 gboolean *be_vloc; | |
227 gboolean be_wrt; | |
228 } bmp_cfg_boolent; | |
229 | |
230 typedef struct bmp_cfg_nument_t { | |
231 char const *ie_vname; | |
232 gint *ie_vloc; | |
233 gboolean ie_wrt; | |
234 } bmp_cfg_nument; | |
235 | |
236 typedef struct bmp_cfg_strent_t { | |
237 char const *se_vname; | |
238 char **se_vloc; | |
239 gboolean se_wrt; | |
240 } bmp_cfg_strent; | |
241 | |
242 const gchar *bmp_titlestring_presets[] = { | |
243 "%t", | |
244 "%{p:%p - %}%t", | |
245 "%{p:%p - %}%{a:%a - %}%t", | |
246 "%{p:%p - %}%{a:%a - %}%{n:%n. %}%t", | |
247 "%{p:%p %}%{a:[ %a ] %}%{p:- %}%{n:%n. %}%{t:%t%}", | |
248 "%{a:%a - %}%t" | |
249 }; | |
250 | |
251 const guint n_titlestring_presets = G_N_ELEMENTS(bmp_titlestring_presets); | |
252 | |
253 const gchar *chardet_detector_presets[] = { | |
2364 | 254 "None", |
255 "Japanese", | |
256 "Taiwanese", | |
257 "Chinese", | |
258 "Korean", | |
259 "Russian", | |
2313 | 260 #ifdef HAVE_UDET |
2364 | 261 "Universal" |
2313 | 262 #endif |
263 }; | |
264 | |
2364 | 265 const guint n_chardet_detector_presets = G_N_ELEMENTS(chardet_detector_presets); |
2313 | 266 |
267 static bmp_cfg_boolent bmp_boolents[] = { | |
268 {"allow_multiple_instances", &cfg.allow_multiple_instances, TRUE}, | |
269 {"use_realtime", &cfg.use_realtime, TRUE}, | |
270 {"always_show_cb", &cfg.always_show_cb, TRUE}, | |
271 {"convert_underscore", &cfg.convert_underscore, TRUE}, | |
272 {"convert_twenty", &cfg.convert_twenty, TRUE}, | |
273 {"convert_slash", &cfg.convert_slash, TRUE }, | |
274 {"show_numbers_in_pl", &cfg.show_numbers_in_pl, TRUE}, | |
275 {"show_separator_in_pl", &cfg.show_separator_in_pl, TRUE}, | |
276 {"snap_windows", &cfg.snap_windows, TRUE}, | |
277 {"save_window_positions", &cfg.save_window_position, TRUE}, | |
278 {"dim_titlebar", &cfg.dim_titlebar, TRUE}, | |
279 {"get_info_on_load", &cfg.get_info_on_load, TRUE}, | |
280 {"get_info_on_demand", &cfg.get_info_on_demand, TRUE}, | |
281 {"eq_doublesize_linked", &cfg.eq_doublesize_linked, TRUE}, | |
282 {"no_playlist_advance", &cfg.no_playlist_advance, TRUE}, | |
283 {"refresh_file_list", &cfg.refresh_file_list, TRUE}, | |
284 {"sort_jump_to_file", &cfg.sort_jump_to_file, TRUE}, | |
285 {"use_pl_metadata", &cfg.use_pl_metadata, TRUE}, | |
2651
4d5e6a8717dd
[svn] - allow the player to start with all of its windows hidden (but give a warning to the user, whose display can be disabled); also, try to remember player windows positions when they stay hidden between sessions
giacomo
parents:
2644
diff
changeset
|
286 {"warn_about_win_visibility", &cfg.warn_about_win_visibility, TRUE}, |
2313 | 287 {"use_backslash_as_dir_delimiter", &cfg.use_backslash_as_dir_delimiter, TRUE}, |
288 {"player_shaded", &cfg.player_shaded, TRUE}, | |
289 {"player_visible", &cfg.player_visible, TRUE}, | |
290 {"shuffle", &cfg.shuffle, TRUE}, | |
291 {"repeat", &cfg.repeat, TRUE}, | |
292 {"doublesize", &cfg.doublesize, TRUE}, | |
293 {"autoscroll_songname", &cfg.autoscroll, TRUE}, | |
294 {"stop_after_current_song", &cfg.stopaftersong, TRUE}, | |
295 {"playlist_shaded", &cfg.playlist_shaded, TRUE}, | |
296 {"playlist_visible", &cfg.playlist_visible, TRUE}, | |
297 {"use_fontsets", &cfg.use_fontsets, TRUE}, | |
298 {"mainwin_use_xfont", &cfg.mainwin_use_xfont, FALSE}, | |
299 {"equalizer_visible", &cfg.equalizer_visible, TRUE}, | |
300 {"equalizer_active", &cfg.equalizer_active, TRUE}, | |
301 {"equalizer_shaded", &cfg.equalizer_shaded, TRUE}, | |
302 {"equalizer_autoload", &cfg.equalizer_autoload, TRUE}, | |
303 {"easy_move", &cfg.easy_move, TRUE}, | |
304 {"use_eplugins", &cfg.use_eplugins, TRUE}, | |
305 {"always_on_top", &cfg.always_on_top, TRUE}, | |
306 {"sticky", &cfg.sticky, TRUE}, | |
307 {"random_skin_on_play", &cfg.random_skin_on_play, TRUE}, | |
308 {"pause_between_songs", &cfg.pause_between_songs, TRUE}, | |
309 {"show_wm_decorations", &cfg.show_wm_decorations, TRUE}, | |
310 {"eq_extra_filtering", &cfg.eq_extra_filtering, TRUE}, | |
311 {"analyzer_peaks", &cfg.analyzer_peaks, TRUE}, | |
312 {"custom_cursors", &cfg.custom_cursors, TRUE}, | |
313 {"close_dialog_open", &cfg.close_dialog_open, TRUE}, | |
314 {"close_dialog_add", &cfg.close_dialog_add, TRUE}, | |
315 {"resume_playback_on_startup", &cfg.resume_playback_on_startup, TRUE}, | |
316 {"playlist_detect", &cfg.playlist_detect, TRUE}, | |
317 {"show_filepopup_for_tuple", &cfg.show_filepopup_for_tuple, TRUE}, | |
318 {"recurse_for_cover", &cfg.recurse_for_cover, TRUE}, | |
319 {"use_file_cover", &cfg.use_file_cover, TRUE}, | |
320 {"use_xmms_style_fileselector", &cfg.use_xmms_style_fileselector, TRUE}, | |
321 {"use_extension_probing", &cfg.use_extension_probing, TRUE}, | |
2405 | 322 {"filepopup_showprogressbar", &cfg.filepopup_showprogressbar, TRUE}, |
2313 | 323 }; |
324 | |
325 static gint ncfgbent = G_N_ELEMENTS(bmp_boolents); | |
326 | |
327 static bmp_cfg_nument bmp_numents[] = { | |
328 {"player_x", &cfg.player_x, TRUE}, | |
329 {"player_y", &cfg.player_y, TRUE}, | |
330 {"timer_mode", &cfg.timer_mode, TRUE}, | |
331 {"vis_type", &cfg.vis_type, TRUE}, | |
332 {"analyzer_mode", &cfg.analyzer_mode, TRUE}, | |
333 {"analyzer_type", &cfg.analyzer_type, TRUE}, | |
334 {"scope_mode", &cfg.scope_mode, TRUE}, | |
335 {"vu_mode", &cfg.vu_mode, TRUE}, | |
336 {"voiceprint_mode", &cfg.voiceprint_mode, TRUE}, | |
337 {"vis_refresh_rate", &cfg.vis_refresh, TRUE}, | |
338 {"analyzer_falloff", &cfg.analyzer_falloff, TRUE}, | |
339 {"peaks_falloff", &cfg.peaks_falloff, TRUE}, | |
340 {"playlist_x", &cfg.playlist_x, TRUE}, | |
341 {"playlist_y", &cfg.playlist_y, TRUE}, | |
342 {"playlist_width", &cfg.playlist_width, TRUE}, | |
343 {"playlist_height", &cfg.playlist_height, TRUE}, | |
344 {"playlist_position", &cfg.playlist_position, TRUE}, | |
345 {"equalizer_x", &cfg.equalizer_x, TRUE}, | |
346 {"equalizer_y", &cfg.equalizer_y, TRUE}, | |
347 {"snap_distance", &cfg.snap_distance, TRUE}, | |
348 {"pause_between_songs_time", &cfg.pause_between_songs_time, TRUE}, | |
349 {"mouse_wheel_change", &cfg.mouse_change, TRUE}, | |
350 {"scroll_pl_by", &cfg.scroll_pl_by, TRUE}, | |
351 {"titlestring_preset", &cfg.titlestring_preset, TRUE}, | |
352 {"resume_playback_on_startup_time", &cfg.resume_playback_on_startup_time, TRUE}, | |
353 {"output_buffer_size", &cfg.output_buffer_size, TRUE}, | |
354 {"recurse_for_cover_depth", &cfg.recurse_for_cover_depth, TRUE}, | |
355 {"filepopup_pixelsize", &cfg.filepopup_pixelsize, TRUE}, | |
356 {"filepopup_delay", &cfg.filepopup_delay, TRUE}, | |
357 {"colorize_r", &cfg.colorize_r, TRUE}, | |
358 {"colorize_g", &cfg.colorize_g, TRUE}, | |
359 {"colorize_b", &cfg.colorize_b, TRUE}, | |
360 }; | |
361 | |
362 static gint ncfgient = G_N_ELEMENTS(bmp_numents); | |
363 | |
364 static bmp_cfg_strent bmp_strents[] = { | |
365 {"playlist_font", &cfg.playlist_font, TRUE}, | |
366 {"mainwin_font", &cfg.mainwin_font, TRUE}, | |
367 {"eqpreset_default_file", &cfg.eqpreset_default_file, TRUE}, | |
368 {"eqpreset_extension", &cfg.eqpreset_extension, TRUE}, | |
369 {"skin", &cfg.skin, FALSE}, | |
370 {"output_plugin", &cfg.outputplugin, FALSE}, | |
371 {"disabled_iplugins", &cfg.disabled_iplugins, TRUE}, | |
372 {"enabled_gplugins", &cfg.enabled_gplugins, FALSE}, | |
373 {"enabled_vplugins", &cfg.enabled_vplugins, FALSE}, | |
374 {"enabled_eplugins", &cfg.enabled_eplugins, FALSE}, | |
375 {"filesel_path", &cfg.filesel_path, FALSE}, | |
376 {"playlist_path", &cfg.playlist_path, FALSE}, | |
377 {"generic_title_format", &cfg.gentitle_format, TRUE}, | |
378 {"chardet_detector", &cfg.chardet_detector, TRUE}, | |
379 {"chardet_fallback", &cfg.chardet_fallback, TRUE}, | |
380 {"cover_name_include", &cfg.cover_name_include, TRUE}, | |
381 {"cover_name_exclude", &cfg.cover_name_exclude, TRUE}, | |
382 {"session_uri_base", &cfg.session_uri_base, TRUE} | |
383 }; | |
384 | |
385 static gint ncfgsent = G_N_ELEMENTS(bmp_strents); | |
386 | |
387 gchar *bmp_paths[BMP_PATH_COUNT] = {}; | |
388 | |
389 GList *dock_window_list = NULL; | |
390 | |
391 gboolean pposition_broken = FALSE; | |
392 | |
393 gboolean starting_up = TRUE; | |
394 | |
395 /* XXX: case-sensitivity is bad for lazy nenolods. :( -nenolod */ | |
396 static gchar *pl_candidates[] = { | |
2364 | 397 PLUGIN_FILENAME("ALSA"), |
398 PLUGIN_FILENAME("coreaudio"), | |
399 PLUGIN_FILENAME("OSS"), | |
400 PLUGIN_FILENAME("sun"), | |
401 PLUGIN_FILENAME("ESD"), | |
402 PLUGIN_FILENAME("pulse_audio"), | |
403 PLUGIN_FILENAME("disk_writer"), | |
404 NULL | |
2313 | 405 }; |
406 | |
407 GCond *cond_scan; | |
408 GMutex *mutex_scan; | |
409 | |
410 static GSList * | |
411 get_feature_list(void) | |
412 { | |
413 GSList *features = NULL; | |
414 | |
415 #ifdef HAVE_GCONF | |
416 features = g_slist_append(features, "GConf"); | |
417 #endif | |
418 | |
419 return features; | |
420 } | |
421 | |
422 static void | |
423 dump_version(void) | |
424 { | |
425 GSList *features; | |
426 | |
427 g_printf("%s %s [%s]", _(application_name), VERSION, svn_stamp); | |
428 | |
429 features = get_feature_list(); | |
430 | |
431 if (features) { | |
432 GSList *item; | |
433 | |
434 g_printf(" ("); | |
435 | |
436 for (item = features; g_slist_next(item); item = g_slist_next(item)) | |
437 g_printf("%s, ", (const gchar *) item->data); | |
438 | |
439 g_printf("%s)", (const gchar *) item->data); | |
440 | |
441 g_slist_free(features); | |
442 } | |
443 | |
444 g_printf("\n"); | |
445 } | |
446 | |
447 const gchar * | |
448 xmms_get_gentitle_format(void) | |
449 { | |
450 guint titlestring_preset = cfg.titlestring_preset; | |
451 | |
452 if (titlestring_preset < n_titlestring_presets) | |
2364 | 453 return bmp_titlestring_presets[titlestring_preset]; |
2313 | 454 |
455 return cfg.gentitle_format; | |
456 } | |
457 | |
458 void | |
459 make_directory(const gchar * path, mode_t mode) | |
460 { | |
2317
49d285f6008b
[svn] Full support for XDG basedir added. The old config doesn't get automatically converted yet.
js
parents:
2313
diff
changeset
|
461 if (g_mkdir_with_parents(path, mode) == 0) |
2313 | 462 return; |
463 | |
2317
49d285f6008b
[svn] Full support for XDG basedir added. The old config doesn't get automatically converted yet.
js
parents:
2313
diff
changeset
|
464 g_printerr(_("Could not create directory (%s): %s\n"), path, |
2313 | 465 g_strerror(errno)); |
466 } | |
467 | |
468 static void | |
469 bmp_make_user_dir(void) | |
470 { | |
471 const mode_t mode755 = S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH; | |
472 | |
473 make_directory(bmp_paths[BMP_PATH_USER_DIR], mode755); | |
474 make_directory(bmp_paths[BMP_PATH_USER_PLUGIN_DIR], mode755); | |
475 make_directory(bmp_paths[BMP_PATH_USER_SKIN_DIR], mode755); | |
476 make_directory(bmp_paths[BMP_PATH_SKIN_THUMB_DIR], mode755); | |
477 } | |
478 | |
479 static void | |
480 bmp_free_paths(void) | |
481 { | |
482 int i; | |
483 | |
484 for (i = 0; i < BMP_PATH_COUNT; i++) | |
485 { | |
486 g_free(bmp_paths[i]); | |
487 bmp_paths[i] = 0; | |
488 } | |
489 } | |
490 | |
2317
49d285f6008b
[svn] Full support for XDG basedir added. The old config doesn't get automatically converted yet.
js
parents:
2313
diff
changeset
|
491 static void |
49d285f6008b
[svn] Full support for XDG basedir added. The old config doesn't get automatically converted yet.
js
parents:
2313
diff
changeset
|
492 bmp_init_paths() |
49d285f6008b
[svn] Full support for XDG basedir added. The old config doesn't get automatically converted yet.
js
parents:
2313
diff
changeset
|
493 { |
2364 | 494 char *xdg_config_home; |
495 char *xdg_data_home; | |
496 char *xdg_cache_home; | |
2313 | 497 |
2364 | 498 xdg_config_home = (getenv("XDG_CONFIG_HOME") == NULL |
499 ? g_build_filename(g_get_home_dir(), ".config", NULL) | |
500 : g_strdup(getenv("XDG_CONFIG_HOME"))); | |
501 xdg_data_home = (getenv("XDG_DATA_HOME") == NULL | |
502 ? g_build_filename(g_get_home_dir(), ".local", "share", NULL) | |
503 : g_strdup(getenv("XDG_DATA_HOME"))); | |
504 xdg_cache_home = (getenv("XDG_CACHE_HOME") == NULL | |
505 ? g_build_filename(g_get_home_dir(), ".cache", NULL) | |
506 : g_strdup(getenv("XDG_CACHE_HOME"))); | |
2313 | 507 |
2364 | 508 bmp_paths[BMP_PATH_USER_DIR] = |
509 g_build_filename(xdg_config_home, "audacious", NULL); | |
510 bmp_paths[BMP_PATH_USER_SKIN_DIR] = | |
511 g_build_filename(xdg_data_home, "audacious", "Skins", NULL); | |
512 bmp_paths[BMP_PATH_USER_PLUGIN_DIR] = | |
2506
630910fd140f
[svn] - changed plugin directory to ~/.local/share/audacious/Plugins (seems more logical to me)
mf0102
parents:
2475
diff
changeset
|
513 g_build_filename(xdg_data_home, "audacious", "Plugins", NULL); |
630910fd140f
[svn] - changed plugin directory to ~/.local/share/audacious/Plugins (seems more logical to me)
mf0102
parents:
2475
diff
changeset
|
514 |
2364 | 515 bmp_paths[BMP_PATH_SKIN_THUMB_DIR] = |
516 g_build_filename(xdg_cache_home, "audacious", "thumbs", NULL); | |
2313 | 517 |
2364 | 518 bmp_paths[BMP_PATH_CONFIG_FILE] = |
519 g_build_filename(bmp_paths[BMP_PATH_USER_DIR], "config", NULL); | |
2317
49d285f6008b
[svn] Full support for XDG basedir added. The old config doesn't get automatically converted yet.
js
parents:
2313
diff
changeset
|
520 #ifdef HAVE_XSPF_PLAYLIST |
2364 | 521 bmp_paths[BMP_PATH_PLAYLIST_FILE] = |
522 g_build_filename(bmp_paths[BMP_PATH_USER_DIR], | |
523 "playlist.xspf", NULL); | |
2317
49d285f6008b
[svn] Full support for XDG basedir added. The old config doesn't get automatically converted yet.
js
parents:
2313
diff
changeset
|
524 #else |
2364 | 525 bmp_paths[BMP_PATH_PLAYLIST_FILE] = |
526 g_build_filename(bmp_paths[BMP_PATH_USER_DIR], | |
527 "playlist.m3u", NULL); | |
2317
49d285f6008b
[svn] Full support for XDG basedir added. The old config doesn't get automatically converted yet.
js
parents:
2313
diff
changeset
|
528 #endif |
2364 | 529 bmp_paths[BMP_PATH_ACCEL_FILE] = |
530 g_build_filename(bmp_paths[BMP_PATH_USER_DIR], "accels", NULL); | |
531 bmp_paths[BMP_PATH_LOG_FILE] = | |
532 g_build_filename(bmp_paths[BMP_PATH_USER_DIR], "log", NULL); | |
2317
49d285f6008b
[svn] Full support for XDG basedir added. The old config doesn't get automatically converted yet.
js
parents:
2313
diff
changeset
|
533 |
2463 | 534 bmp_paths[BMP_PATH_GTKRC_FILE] = |
2570 | 535 g_build_filename(bmp_paths[BMP_PATH_USER_DIR], "gtkrc", NULL); |
2463 | 536 |
2364 | 537 g_free(xdg_config_home); |
538 g_free(xdg_data_home); | |
539 g_free(xdg_cache_home); | |
2317
49d285f6008b
[svn] Full support for XDG basedir added. The old config doesn't get automatically converted yet.
js
parents:
2313
diff
changeset
|
540 |
2364 | 541 g_atexit(bmp_free_paths); |
2313 | 542 } |
543 | |
544 void | |
2682
c3cd6e47faf6
[svn] - make the evil 'reload plugins' button behave a bit better
giacomo
parents:
2662
diff
changeset
|
545 bmp_config_free(void) |
c3cd6e47faf6
[svn] - make the evil 'reload plugins' button behave a bit better
giacomo
parents:
2662
diff
changeset
|
546 { |
c3cd6e47faf6
[svn] - make the evil 'reload plugins' button behave a bit better
giacomo
parents:
2662
diff
changeset
|
547 gint i; |
c3cd6e47faf6
[svn] - make the evil 'reload plugins' button behave a bit better
giacomo
parents:
2662
diff
changeset
|
548 for (i = 0; i < ncfgsent; ++i) { |
c3cd6e47faf6
[svn] - make the evil 'reload plugins' button behave a bit better
giacomo
parents:
2662
diff
changeset
|
549 if ( *(bmp_strents[i].se_vloc) != NULL ) |
c3cd6e47faf6
[svn] - make the evil 'reload plugins' button behave a bit better
giacomo
parents:
2662
diff
changeset
|
550 { |
c3cd6e47faf6
[svn] - make the evil 'reload plugins' button behave a bit better
giacomo
parents:
2662
diff
changeset
|
551 g_free( *(bmp_strents[i].se_vloc) ); |
c3cd6e47faf6
[svn] - make the evil 'reload plugins' button behave a bit better
giacomo
parents:
2662
diff
changeset
|
552 *(bmp_strents[i].se_vloc) = NULL; |
c3cd6e47faf6
[svn] - make the evil 'reload plugins' button behave a bit better
giacomo
parents:
2662
diff
changeset
|
553 } |
c3cd6e47faf6
[svn] - make the evil 'reload plugins' button behave a bit better
giacomo
parents:
2662
diff
changeset
|
554 } |
c3cd6e47faf6
[svn] - make the evil 'reload plugins' button behave a bit better
giacomo
parents:
2662
diff
changeset
|
555 } |
c3cd6e47faf6
[svn] - make the evil 'reload plugins' button behave a bit better
giacomo
parents:
2662
diff
changeset
|
556 |
c3cd6e47faf6
[svn] - make the evil 'reload plugins' button behave a bit better
giacomo
parents:
2662
diff
changeset
|
557 void |
2313 | 558 bmp_config_load(void) |
559 { | |
560 ConfigDb *db; | |
561 gint i, length; | |
562 | |
563 memcpy(&cfg, &bmp_default_config, sizeof(BmpConfig)); | |
564 | |
565 db = bmp_cfg_db_open(); | |
566 for (i = 0; i < ncfgbent; ++i) { | |
567 bmp_cfg_db_get_bool(db, NULL, | |
568 bmp_boolents[i].be_vname, | |
569 bmp_boolents[i].be_vloc); | |
570 } | |
571 | |
572 for (i = 0; i < ncfgient; ++i) { | |
573 bmp_cfg_db_get_int(db, NULL, | |
574 bmp_numents[i].ie_vname, | |
575 bmp_numents[i].ie_vloc); | |
576 } | |
577 | |
578 for (i = 0; i < ncfgsent; ++i) { | |
579 bmp_cfg_db_get_string(db, NULL, | |
580 bmp_strents[i].se_vname, | |
581 bmp_strents[i].se_vloc); | |
582 } | |
583 | |
584 /* Preset */ | |
585 bmp_cfg_db_get_float(db, NULL, "equalizer_preamp", &cfg.equalizer_preamp); | |
586 for (i = 0; i < 10; i++) { | |
587 gchar eqtext[18]; | |
588 | |
589 g_snprintf(eqtext, sizeof(eqtext), "equalizer_band%d", i); | |
590 bmp_cfg_db_get_float(db, NULL, eqtext, &cfg.equalizer_bands[i]); | |
591 } | |
592 | |
593 /* History */ | |
594 if (bmp_cfg_db_get_int(db, NULL, "url_history_length", &length)) { | |
595 for (i = 1; i <= length; i++) { | |
596 gchar str[19], *tmp; | |
597 | |
598 g_snprintf(str, sizeof(str), "url_history%d", i); | |
599 if (bmp_cfg_db_get_string(db, NULL, str, &tmp)) | |
600 cfg.url_history = g_list_append(cfg.url_history, tmp); | |
601 } | |
602 } | |
603 | |
604 bmp_cfg_db_close(db); | |
605 | |
606 | |
607 if (cfg.playlist_font && strlen(cfg.playlist_font) == 0) { | |
608 g_free(cfg.playlist_font); | |
609 cfg.playlist_font = NULL; | |
610 } | |
611 | |
612 if (cfg.mainwin_font && strlen(cfg.mainwin_font) == 0) { | |
613 g_free(cfg.mainwin_font); | |
614 cfg.mainwin_font = NULL; | |
615 } | |
616 | |
617 if (!cfg.playlist_font) | |
618 cfg.playlist_font = g_strdup(PLAYLISTWIN_DEFAULT_FONT); | |
619 | |
620 if (!cfg.mainwin_font) | |
621 cfg.mainwin_font = g_strdup(MAINWIN_DEFAULT_FONT); | |
622 | |
623 if (!cfg.gentitle_format) | |
624 cfg.gentitle_format = g_strdup("%{p:%p - %}%{a:%a - %}%t"); | |
625 | |
626 if (!cfg.outputplugin) { | |
2364 | 627 gint iter; |
2313 | 628 gchar *pl_path = g_build_filename(PLUGIN_DIR, plugin_dir_list[0], NULL); |
629 | |
630 for (iter = 0; pl_candidates[iter] != NULL && cfg.outputplugin == NULL; iter++) | |
2364 | 631 { |
632 cfg.outputplugin = find_file_recursively(pl_path, pl_candidates[iter]); | |
633 } | |
2313 | 634 |
635 g_free(pl_path); | |
636 } | |
637 | |
638 if (!cfg.eqpreset_default_file) | |
639 cfg.eqpreset_default_file = g_strdup(EQUALIZER_DEFAULT_DIR_PRESET); | |
640 | |
641 if (!cfg.eqpreset_extension) | |
642 cfg.eqpreset_extension = g_strdup(EQUALIZER_DEFAULT_PRESET_EXT); | |
643 | |
644 if (!cfg.chardet_detector) | |
645 cfg.chardet_detector = g_strdup(""); | |
646 | |
647 if (!cfg.chardet_fallback) | |
648 cfg.chardet_fallback = g_strdup(""); | |
649 | |
650 if (!cfg.cover_name_include) | |
2364 | 651 cfg.cover_name_include = g_strdup(""); |
2313 | 652 |
653 if (!cfg.cover_name_exclude) | |
2364 | 654 cfg.cover_name_exclude = g_strdup("back"); |
2313 | 655 |
656 if (!cfg.session_uri_base) | |
657 cfg.session_uri_base = g_strdup(""); | |
658 | |
659 /* at least one of these should be true */ | |
660 if ((!cfg.get_info_on_demand) && (!cfg.get_info_on_load)) | |
661 cfg.get_info_on_demand = TRUE; | |
662 } | |
663 | |
664 | |
665 void | |
666 bmp_config_save(void) | |
667 { | |
668 GList *node; | |
669 gchar *str; | |
670 gint i, cur_pb_time; | |
671 ConfigDb *db; | |
672 Playlist *playlist = playlist_get_active(); | |
673 | |
674 cfg.disabled_iplugins = input_stringify_disabled_list(); | |
675 | |
676 | |
677 db = bmp_cfg_db_open(); | |
678 | |
679 for (i = 0; i < ncfgbent; ++i) | |
680 if (bmp_boolents[i].be_wrt) | |
681 bmp_cfg_db_set_bool(db, NULL, | |
682 bmp_boolents[i].be_vname, | |
683 *bmp_boolents[i].be_vloc); | |
684 | |
685 for (i = 0; i < ncfgient; ++i) | |
686 if (bmp_numents[i].ie_wrt) | |
687 bmp_cfg_db_set_int(db, NULL, | |
688 bmp_numents[i].ie_vname, | |
689 *bmp_numents[i].ie_vloc); | |
690 | |
691 /* This is a bit lame .. it'll end up being written twice, | |
692 * could do with being done a bit neater. -larne */ | |
693 bmp_cfg_db_set_int(db, NULL, "playlist_position", | |
694 playlist_get_position(playlist)); | |
695 | |
2530 | 696 /* FIXME: we're looking up SkinnedWindow::x &c ourselves here. |
697 * this isn't exactly right. -nenolod | |
698 */ | |
2651
4d5e6a8717dd
[svn] - allow the player to start with all of its windows hidden (but give a warning to the user, whose display can be disabled); also, try to remember player windows positions when they stay hidden between sessions
giacomo
parents:
2644
diff
changeset
|
699 if ( SKINNED_WINDOW(playlistwin)->x != -1 && |
4d5e6a8717dd
[svn] - allow the player to start with all of its windows hidden (but give a warning to the user, whose display can be disabled); also, try to remember player windows positions when they stay hidden between sessions
giacomo
parents:
2644
diff
changeset
|
700 SKINNED_WINDOW(playlistwin)->y != -1 ) |
4d5e6a8717dd
[svn] - allow the player to start with all of its windows hidden (but give a warning to the user, whose display can be disabled); also, try to remember player windows positions when they stay hidden between sessions
giacomo
parents:
2644
diff
changeset
|
701 { |
4d5e6a8717dd
[svn] - allow the player to start with all of its windows hidden (but give a warning to the user, whose display can be disabled); also, try to remember player windows positions when they stay hidden between sessions
giacomo
parents:
2644
diff
changeset
|
702 bmp_cfg_db_set_int(db, NULL, "playlist_x", |
4d5e6a8717dd
[svn] - allow the player to start with all of its windows hidden (but give a warning to the user, whose display can be disabled); also, try to remember player windows positions when they stay hidden between sessions
giacomo
parents:
2644
diff
changeset
|
703 SKINNED_WINDOW(playlistwin)->x); |
4d5e6a8717dd
[svn] - allow the player to start with all of its windows hidden (but give a warning to the user, whose display can be disabled); also, try to remember player windows positions when they stay hidden between sessions
giacomo
parents:
2644
diff
changeset
|
704 bmp_cfg_db_set_int(db, NULL, "playlist_y", |
4d5e6a8717dd
[svn] - allow the player to start with all of its windows hidden (but give a warning to the user, whose display can be disabled); also, try to remember player windows positions when they stay hidden between sessions
giacomo
parents:
2644
diff
changeset
|
705 SKINNED_WINDOW(playlistwin)->y); |
4d5e6a8717dd
[svn] - allow the player to start with all of its windows hidden (but give a warning to the user, whose display can be disabled); also, try to remember player windows positions when they stay hidden between sessions
giacomo
parents:
2644
diff
changeset
|
706 } |
4d5e6a8717dd
[svn] - allow the player to start with all of its windows hidden (but give a warning to the user, whose display can be disabled); also, try to remember player windows positions when they stay hidden between sessions
giacomo
parents:
2644
diff
changeset
|
707 |
4d5e6a8717dd
[svn] - allow the player to start with all of its windows hidden (but give a warning to the user, whose display can be disabled); also, try to remember player windows positions when they stay hidden between sessions
giacomo
parents:
2644
diff
changeset
|
708 if ( SKINNED_WINDOW(mainwin)->x != -1 && |
4d5e6a8717dd
[svn] - allow the player to start with all of its windows hidden (but give a warning to the user, whose display can be disabled); also, try to remember player windows positions when they stay hidden between sessions
giacomo
parents:
2644
diff
changeset
|
709 SKINNED_WINDOW(mainwin)->y != -1 ) |
4d5e6a8717dd
[svn] - allow the player to start with all of its windows hidden (but give a warning to the user, whose display can be disabled); also, try to remember player windows positions when they stay hidden between sessions
giacomo
parents:
2644
diff
changeset
|
710 { |
4d5e6a8717dd
[svn] - allow the player to start with all of its windows hidden (but give a warning to the user, whose display can be disabled); also, try to remember player windows positions when they stay hidden between sessions
giacomo
parents:
2644
diff
changeset
|
711 bmp_cfg_db_set_int(db, NULL, "player_x", |
4d5e6a8717dd
[svn] - allow the player to start with all of its windows hidden (but give a warning to the user, whose display can be disabled); also, try to remember player windows positions when they stay hidden between sessions
giacomo
parents:
2644
diff
changeset
|
712 SKINNED_WINDOW(mainwin)->x); |
4d5e6a8717dd
[svn] - allow the player to start with all of its windows hidden (but give a warning to the user, whose display can be disabled); also, try to remember player windows positions when they stay hidden between sessions
giacomo
parents:
2644
diff
changeset
|
713 bmp_cfg_db_set_int(db, NULL, "player_y", |
4d5e6a8717dd
[svn] - allow the player to start with all of its windows hidden (but give a warning to the user, whose display can be disabled); also, try to remember player windows positions when they stay hidden between sessions
giacomo
parents:
2644
diff
changeset
|
714 SKINNED_WINDOW(mainwin)->y); |
4d5e6a8717dd
[svn] - allow the player to start with all of its windows hidden (but give a warning to the user, whose display can be disabled); also, try to remember player windows positions when they stay hidden between sessions
giacomo
parents:
2644
diff
changeset
|
715 } |
2530 | 716 |
2651
4d5e6a8717dd
[svn] - allow the player to start with all of its windows hidden (but give a warning to the user, whose display can be disabled); also, try to remember player windows positions when they stay hidden between sessions
giacomo
parents:
2644
diff
changeset
|
717 if ( SKINNED_WINDOW(equalizerwin)->x != -1 && |
4d5e6a8717dd
[svn] - allow the player to start with all of its windows hidden (but give a warning to the user, whose display can be disabled); also, try to remember player windows positions when they stay hidden between sessions
giacomo
parents:
2644
diff
changeset
|
718 SKINNED_WINDOW(equalizerwin)->y != -1 ) |
4d5e6a8717dd
[svn] - allow the player to start with all of its windows hidden (but give a warning to the user, whose display can be disabled); also, try to remember player windows positions when they stay hidden between sessions
giacomo
parents:
2644
diff
changeset
|
719 { |
4d5e6a8717dd
[svn] - allow the player to start with all of its windows hidden (but give a warning to the user, whose display can be disabled); also, try to remember player windows positions when they stay hidden between sessions
giacomo
parents:
2644
diff
changeset
|
720 bmp_cfg_db_set_int(db, NULL, "equalizer_x", |
4d5e6a8717dd
[svn] - allow the player to start with all of its windows hidden (but give a warning to the user, whose display can be disabled); also, try to remember player windows positions when they stay hidden between sessions
giacomo
parents:
2644
diff
changeset
|
721 SKINNED_WINDOW(equalizerwin)->x); |
4d5e6a8717dd
[svn] - allow the player to start with all of its windows hidden (but give a warning to the user, whose display can be disabled); also, try to remember player windows positions when they stay hidden between sessions
giacomo
parents:
2644
diff
changeset
|
722 bmp_cfg_db_set_int(db, NULL, "equalizer_y", |
4d5e6a8717dd
[svn] - allow the player to start with all of its windows hidden (but give a warning to the user, whose display can be disabled); also, try to remember player windows positions when they stay hidden between sessions
giacomo
parents:
2644
diff
changeset
|
723 SKINNED_WINDOW(equalizerwin)->y); |
4d5e6a8717dd
[svn] - allow the player to start with all of its windows hidden (but give a warning to the user, whose display can be disabled); also, try to remember player windows positions when they stay hidden between sessions
giacomo
parents:
2644
diff
changeset
|
724 } |
2530 | 725 |
2313 | 726 bmp_cfg_db_set_bool(db, NULL, "mainwin_use_xfont", |
2364 | 727 cfg.mainwin_use_xfont); |
2313 | 728 |
729 for (i = 0; i < ncfgsent; ++i) { | |
730 if (bmp_strents[i].se_wrt) | |
731 bmp_cfg_db_set_string(db, NULL, | |
732 bmp_strents[i].se_vname, | |
733 *bmp_strents[i].se_vloc); | |
734 } | |
735 | |
736 bmp_cfg_db_set_float(db, NULL, "equalizer_preamp", cfg.equalizer_preamp); | |
737 | |
738 for (i = 0; i < 10; i++) { | |
739 str = g_strdup_printf("equalizer_band%d", i); | |
740 bmp_cfg_db_set_float(db, NULL, str, cfg.equalizer_bands[i]); | |
741 g_free(str); | |
742 } | |
743 | |
744 if (bmp_active_skin != NULL) | |
745 { | |
746 if (bmp_active_skin->path) | |
747 bmp_cfg_db_set_string(db, NULL, "skin", bmp_active_skin->path); | |
748 else | |
749 bmp_cfg_db_unset_key(db, NULL, "skin"); | |
750 } | |
751 | |
752 if (get_current_output_plugin()) | |
753 bmp_cfg_db_set_string(db, NULL, "output_plugin", | |
754 get_current_output_plugin()->filename); | |
755 else | |
756 bmp_cfg_db_unset_key(db, NULL, "output_plugin"); | |
757 | |
758 str = general_stringify_enabled_list(); | |
759 if (str) { | |
760 bmp_cfg_db_set_string(db, NULL, "enabled_gplugins", str); | |
761 g_free(str); | |
762 } | |
763 else | |
764 bmp_cfg_db_unset_key(db, NULL, "enabled_gplugins"); | |
765 | |
766 str = vis_stringify_enabled_list(); | |
767 if (str) { | |
768 bmp_cfg_db_set_string(db, NULL, "enabled_vplugins", str); | |
769 g_free(str); | |
770 } | |
771 else | |
772 bmp_cfg_db_unset_key(db, NULL, "enabled_vplugins"); | |
773 | |
774 str = effect_stringify_enabled_list(); | |
775 if (str) { | |
776 bmp_cfg_db_set_string(db, NULL, "enabled_eplugins", str); | |
777 g_free(str); | |
778 } | |
779 else | |
780 bmp_cfg_db_unset_key(db, NULL, "enabled_eplugins"); | |
781 | |
782 if (cfg.filesel_path) | |
783 bmp_cfg_db_set_string(db, NULL, "filesel_path", cfg.filesel_path); | |
784 | |
785 if (cfg.playlist_path) | |
786 bmp_cfg_db_set_string(db, NULL, "playlist_path", cfg.playlist_path); | |
787 | |
788 bmp_cfg_db_set_int(db, NULL, "url_history_length", | |
789 g_list_length(cfg.url_history)); | |
790 | |
791 for (node = cfg.url_history, i = 1; node; node = g_list_next(node), i++) { | |
792 str = g_strdup_printf("url_history%d", i); | |
793 bmp_cfg_db_set_string(db, NULL, str, node->data); | |
794 g_free(str); | |
795 } | |
796 | |
797 if (playback_get_playing()) { | |
2364 | 798 cur_pb_time = playback_get_time(); |
2313 | 799 } else |
2364 | 800 cur_pb_time = -1; |
2313 | 801 cfg.resume_playback_on_startup_time = cur_pb_time; |
802 bmp_cfg_db_set_int(db, NULL, "resume_playback_on_startup_time", | |
2364 | 803 cfg.resume_playback_on_startup_time); |
2313 | 804 |
805 bmp_cfg_db_close(db); | |
806 | |
807 playlist_save(playlist, bmp_paths[BMP_PATH_PLAYLIST_FILE]); | |
808 } | |
809 | |
810 static void | |
811 bmp_set_default_icon(void) | |
812 { | |
813 GdkPixbuf *icon; | |
814 | |
815 icon = gdk_pixbuf_new_from_xpm_data((const gchar **) audacious_player_xpm); | |
816 gtk_window_set_default_icon(icon); | |
817 g_object_unref(icon); | |
818 } | |
819 | |
820 static void | |
821 register_aud_stock_icons(void) | |
822 { | |
823 GtkIconFactory *iconfactory = gtk_icon_factory_new(); | |
824 GtkIconSet *iconset; | |
825 GdkPixbuf *pixbuf; | |
826 | |
827 /* pick images in icons-csource.h */ | |
828 pixbuf = gdk_pixbuf_new_from_inline( -1 , removedups_pixbuf , FALSE , NULL ); | |
829 iconset = gtk_icon_set_new_from_pixbuf( pixbuf ); g_object_unref( pixbuf ); | |
830 gtk_icon_factory_add( iconfactory , AUD_STOCK_REMOVEDUPS , iconset ); | |
831 pixbuf = gdk_pixbuf_new_from_inline( -1 , removeunavail_pixbuf , FALSE , NULL ); | |
832 iconset = gtk_icon_set_new_from_pixbuf( pixbuf ); g_object_unref( pixbuf ); | |
833 gtk_icon_factory_add( iconfactory , AUD_STOCK_REMOVEUNAVAIL , iconset ); | |
834 pixbuf = gdk_pixbuf_new_from_inline( -1 , randomizepl_pixbuf , FALSE , NULL ); | |
835 iconset = gtk_icon_set_new_from_pixbuf( pixbuf ); g_object_unref( pixbuf ); | |
836 gtk_icon_factory_add( iconfactory , AUD_STOCK_RANDOMIZEPL , iconset ); | |
837 pixbuf = gdk_pixbuf_new_from_inline( -1 , sortbytitle_pixbuf , FALSE , NULL ); | |
838 iconset = gtk_icon_set_new_from_pixbuf( pixbuf ); g_object_unref( pixbuf ); | |
839 gtk_icon_factory_add( iconfactory , AUD_STOCK_SORTBYTITLE , iconset ); | |
840 pixbuf = gdk_pixbuf_new_from_inline( -1 , sortbyfilename_pixbuf , FALSE , NULL ); | |
841 iconset = gtk_icon_set_new_from_pixbuf( pixbuf ); g_object_unref( pixbuf ); | |
842 gtk_icon_factory_add( iconfactory , AUD_STOCK_SORTBYFILENAME , iconset ); | |
843 pixbuf = gdk_pixbuf_new_from_inline( -1 , sortbyartist_pixbuf , FALSE , NULL ); | |
844 iconset = gtk_icon_set_new_from_pixbuf( pixbuf ); g_object_unref( pixbuf ); | |
845 gtk_icon_factory_add( iconfactory , AUD_STOCK_SORTBYARTIST , iconset ); | |
846 pixbuf = gdk_pixbuf_new_from_inline( -1 , sortbypathfile_pixbuf , FALSE , NULL ); | |
847 iconset = gtk_icon_set_new_from_pixbuf( pixbuf ); g_object_unref( pixbuf ); | |
848 gtk_icon_factory_add( iconfactory , AUD_STOCK_SORTBYPATHFILE , iconset ); | |
849 pixbuf = gdk_pixbuf_new_from_inline( -1 , selectnone_pixbuf , FALSE , NULL ); | |
850 iconset = gtk_icon_set_new_from_pixbuf( pixbuf ); g_object_unref( pixbuf ); | |
851 gtk_icon_factory_add( iconfactory , AUD_STOCK_SELECTNONE , iconset ); | |
852 pixbuf = gdk_pixbuf_new_from_inline( -1 , selectall_pixbuf , FALSE , NULL ); | |
853 iconset = gtk_icon_set_new_from_pixbuf( pixbuf ); g_object_unref( pixbuf ); | |
854 gtk_icon_factory_add( iconfactory , AUD_STOCK_SELECTALL , iconset ); | |
855 pixbuf = gdk_pixbuf_new_from_inline( -1 , selectinvert_pixbuf , FALSE , NULL ); | |
856 iconset = gtk_icon_set_new_from_pixbuf( pixbuf ); g_object_unref( pixbuf ); | |
857 gtk_icon_factory_add( iconfactory , AUD_STOCK_SELECTINVERT , iconset ); | |
858 pixbuf = gdk_pixbuf_new_from_inline( -1 , invertpl_pixbuf , FALSE , NULL ); | |
859 iconset = gtk_icon_set_new_from_pixbuf( pixbuf ); g_object_unref( pixbuf ); | |
860 gtk_icon_factory_add( iconfactory , AUD_STOCK_INVERTPL , iconset ); | |
861 pixbuf = gdk_pixbuf_new_from_inline( -1 , queuetoggle_pixbuf , FALSE , NULL ); | |
862 iconset = gtk_icon_set_new_from_pixbuf( pixbuf ); g_object_unref( pixbuf ); | |
863 gtk_icon_factory_add( iconfactory , AUD_STOCK_QUEUETOGGLE , iconset ); | |
864 pixbuf = gdk_pixbuf_new_from_inline( -1 , info_pixbuf , FALSE , NULL ); | |
865 iconset = gtk_icon_set_new_from_pixbuf( pixbuf ); g_object_unref( pixbuf ); | |
866 gtk_icon_factory_add( iconfactory , AUD_STOCK_INFO , iconset ); | |
867 pixbuf = gdk_pixbuf_new_from_inline( -1 , playlist_pixbuf , FALSE , NULL ); | |
868 iconset = gtk_icon_set_new_from_pixbuf( pixbuf ); g_object_unref( pixbuf ); | |
869 gtk_icon_factory_add( iconfactory , AUD_STOCK_PLAYLIST , iconset ); | |
870 | |
871 gtk_icon_factory_add_default( iconfactory ); | |
872 g_object_unref( iconfactory ); | |
873 } | |
874 | |
2411 | 875 static GOptionEntry cmd_entries[] = { |
2448
ff135e2ba10e
[svn] - mark some strings used by GOption as translatable
nenolod
parents:
2420
diff
changeset
|
876 {"session", 'n', 0, G_OPTION_ARG_INT, &options.session, N_("Select which Audacious session ID to use"), NULL}, |
ff135e2ba10e
[svn] - mark some strings used by GOption as translatable
nenolod
parents:
2420
diff
changeset
|
877 {"rew", 'r', 0, G_OPTION_ARG_NONE, &options.rew, N_("Skip backwards in playlist"), NULL}, |
ff135e2ba10e
[svn] - mark some strings used by GOption as translatable
nenolod
parents:
2420
diff
changeset
|
878 {"play", 'p', 0, G_OPTION_ARG_NONE, &options.play, N_("Start playing current playlist"), NULL}, |
ff135e2ba10e
[svn] - mark some strings used by GOption as translatable
nenolod
parents:
2420
diff
changeset
|
879 {"pause", 'u', 0, G_OPTION_ARG_NONE, &options.pause, N_("Pause current song"), NULL}, |
2475 | 880 {"stop", 's', 0, G_OPTION_ARG_NONE, &options.stop, N_("Stop current song"), NULL}, |
2551
cea3528b2996
[svn] Fix --play-pause commandline option, by Alex "Monkey" Maclean in #gentoo-x86
chainsaw
parents:
2530
diff
changeset
|
881 {"play-pause", 't', 0, G_OPTION_ARG_NONE, &options.play_pause, N_("Pause if playing, play otherwise"), NULL}, |
2448
ff135e2ba10e
[svn] - mark some strings used by GOption as translatable
nenolod
parents:
2420
diff
changeset
|
882 {"fwd", 'f', 0, G_OPTION_ARG_NONE, &options.fwd, N_("Skip forward in playlist"), NULL}, |
ff135e2ba10e
[svn] - mark some strings used by GOption as translatable
nenolod
parents:
2420
diff
changeset
|
883 {"show-jump-box", 'j', 0, G_OPTION_ARG_NONE, &options.show_jump_box, N_("Display Jump to File dialog"), NULL}, |
ff135e2ba10e
[svn] - mark some strings used by GOption as translatable
nenolod
parents:
2420
diff
changeset
|
884 {"enqueue", 'e', 0, G_OPTION_ARG_NONE, &options.enqueue, N_("Don't clear the playlist"), NULL}, |
ff135e2ba10e
[svn] - mark some strings used by GOption as translatable
nenolod
parents:
2420
diff
changeset
|
885 {"enqueue-to-temp", 'E', 0, G_OPTION_ARG_NONE, &options.enqueue_to_temp, N_("Add new files to a temporary playlist"), NULL}, |
ff135e2ba10e
[svn] - mark some strings used by GOption as translatable
nenolod
parents:
2420
diff
changeset
|
886 {"show-main-window", 'm', 0, G_OPTION_ARG_NONE, &options.mainwin, N_("Display the main window"), NULL}, |
ff135e2ba10e
[svn] - mark some strings used by GOption as translatable
nenolod
parents:
2420
diff
changeset
|
887 {"activate", 'a', 0, G_OPTION_ARG_NONE, &options.activate, N_("Display all open Audacious windows"), NULL}, |
ff135e2ba10e
[svn] - mark some strings used by GOption as translatable
nenolod
parents:
2420
diff
changeset
|
888 {"headless", 'H', 0, G_OPTION_ARG_NONE, &options.headless, N_("Enable headless operation"), NULL}, |
ff135e2ba10e
[svn] - mark some strings used by GOption as translatable
nenolod
parents:
2420
diff
changeset
|
889 {"no-log", 'N', 0, G_OPTION_ARG_NONE, &options.no_log, N_("Print all errors and warnings to stdout"), NULL}, |
ff135e2ba10e
[svn] - mark some strings used by GOption as translatable
nenolod
parents:
2420
diff
changeset
|
890 {"version", 'v', 0, G_OPTION_ARG_NONE, &options.version, N_("Show version and builtin features"), NULL}, |
2411 | 891 {G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &options.filenames, N_("FILE..."), NULL}, |
892 {NULL}, | |
893 }; | |
2313 | 894 |
895 static void | |
896 handle_cmd_line_options(BmpCmdLineOpt * options, | |
897 gboolean remote) | |
898 { | |
2411 | 899 gchar **filenames = options->filenames; |
2313 | 900 gint session = options->session; |
901 | |
2411 | 902 if (options->version) |
903 { | |
904 dump_version(); | |
905 exit(EXIT_SUCCESS); | |
906 } | |
907 | |
908 if (filenames != NULL) | |
909 { | |
2313 | 910 gint pos = 0; |
2411 | 911 gint i = 0; |
2605
1ceaf00f9c6d
[svn] - fix handling of multiple files on the command line.
nenolod
parents:
2574
diff
changeset
|
912 GList *fns = NULL; |
2313 | 913 |
2411 | 914 for (i = 0; filenames[i] != NULL; i++) |
915 { | |
2570 | 916 gchar *filename; |
2512
3a1fc6f7c187
[svn] - unbreak relative path support. closes #791.
nenolod
parents:
2506
diff
changeset
|
917 gchar *current_dir = g_get_current_dir(); |
3a1fc6f7c187
[svn] - unbreak relative path support. closes #791.
nenolod
parents:
2506
diff
changeset
|
918 |
3a1fc6f7c187
[svn] - unbreak relative path support. closes #791.
nenolod
parents:
2506
diff
changeset
|
919 if (filenames[i][0] == '/' || strstr(filenames[i], "://")) |
3a1fc6f7c187
[svn] - unbreak relative path support. closes #791.
nenolod
parents:
2506
diff
changeset
|
920 filename = g_strdup(filenames[i]); |
3a1fc6f7c187
[svn] - unbreak relative path support. closes #791.
nenolod
parents:
2506
diff
changeset
|
921 else |
3a1fc6f7c187
[svn] - unbreak relative path support. closes #791.
nenolod
parents:
2506
diff
changeset
|
922 filename = g_build_filename(current_dir, filenames[i], NULL); |
3a1fc6f7c187
[svn] - unbreak relative path support. closes #791.
nenolod
parents:
2506
diff
changeset
|
923 |
2605
1ceaf00f9c6d
[svn] - fix handling of multiple files on the command line.
nenolod
parents:
2574
diff
changeset
|
924 fns = g_list_prepend(fns, filename); |
2313 | 925 |
2605
1ceaf00f9c6d
[svn] - fix handling of multiple files on the command line.
nenolod
parents:
2574
diff
changeset
|
926 g_free(current_dir); |
1ceaf00f9c6d
[svn] - fix handling of multiple files on the command line.
nenolod
parents:
2574
diff
changeset
|
927 } |
1ceaf00f9c6d
[svn] - fix handling of multiple files on the command line.
nenolod
parents:
2574
diff
changeset
|
928 |
1ceaf00f9c6d
[svn] - fix handling of multiple files on the command line.
nenolod
parents:
2574
diff
changeset
|
929 fns = g_list_reverse(fns); |
2411 | 930 |
2605
1ceaf00f9c6d
[svn] - fix handling of multiple files on the command line.
nenolod
parents:
2574
diff
changeset
|
931 if (options->load_skins) |
1ceaf00f9c6d
[svn] - fix handling of multiple files on the command line.
nenolod
parents:
2574
diff
changeset
|
932 { |
1ceaf00f9c6d
[svn] - fix handling of multiple files on the command line.
nenolod
parents:
2574
diff
changeset
|
933 xmms_remote_set_skin(session, filenames[0]); |
1ceaf00f9c6d
[svn] - fix handling of multiple files on the command line.
nenolod
parents:
2574
diff
changeset
|
934 skin_install_skin(filenames[0]); |
1ceaf00f9c6d
[svn] - fix handling of multiple files on the command line.
nenolod
parents:
2574
diff
changeset
|
935 } |
1ceaf00f9c6d
[svn] - fix handling of multiple files on the command line.
nenolod
parents:
2574
diff
changeset
|
936 else |
1ceaf00f9c6d
[svn] - fix handling of multiple files on the command line.
nenolod
parents:
2574
diff
changeset
|
937 { |
1ceaf00f9c6d
[svn] - fix handling of multiple files on the command line.
nenolod
parents:
2574
diff
changeset
|
938 if (options->enqueue_to_temp) |
1ceaf00f9c6d
[svn] - fix handling of multiple files on the command line.
nenolod
parents:
2574
diff
changeset
|
939 xmms_remote_playlist_enqueue_to_temp(session, filenames[0]); |
2411 | 940 |
2605
1ceaf00f9c6d
[svn] - fix handling of multiple files on the command line.
nenolod
parents:
2574
diff
changeset
|
941 if (options->enqueue && options->play) |
1ceaf00f9c6d
[svn] - fix handling of multiple files on the command line.
nenolod
parents:
2574
diff
changeset
|
942 pos = xmms_remote_get_playlist_length(session); |
2313 | 943 |
2605
1ceaf00f9c6d
[svn] - fix handling of multiple files on the command line.
nenolod
parents:
2574
diff
changeset
|
944 if (!options->enqueue) |
1ceaf00f9c6d
[svn] - fix handling of multiple files on the command line.
nenolod
parents:
2574
diff
changeset
|
945 { |
1ceaf00f9c6d
[svn] - fix handling of multiple files on the command line.
nenolod
parents:
2574
diff
changeset
|
946 xmms_remote_playlist_clear(session); |
1ceaf00f9c6d
[svn] - fix handling of multiple files on the command line.
nenolod
parents:
2574
diff
changeset
|
947 xmms_remote_stop(session); |
2411 | 948 } |
2512
3a1fc6f7c187
[svn] - unbreak relative path support. closes #791.
nenolod
parents:
2506
diff
changeset
|
949 |
2605
1ceaf00f9c6d
[svn] - fix handling of multiple files on the command line.
nenolod
parents:
2574
diff
changeset
|
950 xmms_remote_playlist_add(session, fns); |
1ceaf00f9c6d
[svn] - fix handling of multiple files on the command line.
nenolod
parents:
2574
diff
changeset
|
951 |
1ceaf00f9c6d
[svn] - fix handling of multiple files on the command line.
nenolod
parents:
2574
diff
changeset
|
952 if (options->enqueue && options->play && |
1ceaf00f9c6d
[svn] - fix handling of multiple files on the command line.
nenolod
parents:
2574
diff
changeset
|
953 xmms_remote_get_playlist_length(session) > pos) |
1ceaf00f9c6d
[svn] - fix handling of multiple files on the command line.
nenolod
parents:
2574
diff
changeset
|
954 xmms_remote_set_playlist_pos(session, pos); |
1ceaf00f9c6d
[svn] - fix handling of multiple files on the command line.
nenolod
parents:
2574
diff
changeset
|
955 |
1ceaf00f9c6d
[svn] - fix handling of multiple files on the command line.
nenolod
parents:
2574
diff
changeset
|
956 if (!options->enqueue) |
1ceaf00f9c6d
[svn] - fix handling of multiple files on the command line.
nenolod
parents:
2574
diff
changeset
|
957 xmms_remote_play(session); |
2313 | 958 } |
959 | |
2605
1ceaf00f9c6d
[svn] - fix handling of multiple files on the command line.
nenolod
parents:
2574
diff
changeset
|
960 g_list_foreach(fns, (GFunc) g_free, NULL); |
1ceaf00f9c6d
[svn] - fix handling of multiple files on the command line.
nenolod
parents:
2574
diff
changeset
|
961 g_list_free(fns); |
1ceaf00f9c6d
[svn] - fix handling of multiple files on the command line.
nenolod
parents:
2574
diff
changeset
|
962 |
2411 | 963 g_strfreev(filenames); |
2313 | 964 } |
965 | |
966 if (options->rew) | |
967 xmms_remote_playlist_prev(session); | |
968 | |
969 if (options->play) | |
970 xmms_remote_play(session); | |
971 | |
972 if (options->pause) | |
973 xmms_remote_pause(session); | |
974 | |
975 if (options->stop) | |
976 xmms_remote_stop(session); | |
977 | |
978 if (options->fwd) | |
979 xmms_remote_playlist_next(session); | |
980 | |
981 if (options->play_pause) | |
982 xmms_remote_play_pause(session); | |
983 | |
984 if (options->show_jump_box) | |
985 xmms_remote_show_jtf_box(session); | |
986 | |
987 if (options->mainwin) | |
988 xmms_remote_main_win_toggle(session, TRUE); | |
989 | |
990 if (options->activate) | |
991 xmms_remote_activate(session); | |
992 | |
993 if (options->playcd) | |
994 play_medium(); | |
995 } | |
996 | |
997 static void | |
998 bmp_setup_logger(void) | |
999 { | |
1000 if (!bmp_logger_start(bmp_paths[BMP_PATH_LOG_FILE])) | |
1001 return; | |
1002 | |
1003 g_atexit(bmp_logger_stop); | |
1004 } | |
1005 | |
1006 static void | |
1007 run_load_skin_error_dialog(const gchar * skin_path) | |
1008 { | |
1009 const gchar *markup = | |
1010 N_("<b><big>Unable to load skin.</big></b>\n" | |
1011 "\n" | |
1012 "Check that skin at '%s' is usable and default skin is properly " | |
1013 "installed at '%s'\n"); | |
1014 | |
1015 GtkWidget *dialog = | |
1016 gtk_message_dialog_new_with_markup(NULL, | |
1017 GTK_DIALOG_MODAL, | |
1018 GTK_MESSAGE_ERROR, | |
1019 GTK_BUTTONS_CLOSE, | |
1020 _(markup), | |
1021 skin_path, | |
1022 BMP_DEFAULT_SKIN_PATH); | |
1023 gtk_dialog_run(GTK_DIALOG(dialog)); | |
1024 gtk_widget_destroy(dialog); | |
1025 } | |
1026 | |
1027 // use a format string? | |
1028 void report_error(const gchar *error_text) | |
1029 { | |
2364 | 1030 fprintf(stderr, error_text); |
2570 | 1031 |
1032 if (options.headless != 1) | |
1033 { | |
2313 | 1034 gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(err), |
1035 error_text); | |
1036 gtk_dialog_run(GTK_DIALOG(err)); | |
1037 gtk_widget_hide(err); | |
1038 } | |
1039 } | |
1040 | |
2369 | 1041 static gboolean |
1042 aud_headless_iteration(gpointer unused) | |
1043 { | |
2506
630910fd140f
[svn] - changed plugin directory to ~/.local/share/audacious/Plugins (seems more logical to me)
mf0102
parents:
2475
diff
changeset
|
1044 audcore_generic_events(); |
630910fd140f
[svn] - changed plugin directory to ~/.local/share/audacious/Plugins (seems more logical to me)
mf0102
parents:
2475
diff
changeset
|
1045 free_vis_data(); |
630910fd140f
[svn] - changed plugin directory to ~/.local/share/audacious/Plugins (seems more logical to me)
mf0102
parents:
2475
diff
changeset
|
1046 return TRUE; |
2369 | 1047 } |
1048 | |
2313 | 1049 gint |
1050 main(gint argc, gchar ** argv) | |
1051 { | |
1052 gboolean gtk_init_check_ok; | |
1053 Playlist *playlist; | |
2411 | 1054 GOptionContext *context; |
1055 GError *error = NULL; | |
2313 | 1056 |
2644
67082557b2c4
[svn] - glib-2.13.0 requires g_thread_init() to be called before all other GLib functions.
yaz
parents:
2605
diff
changeset
|
1057 /* glib-2.13.0 requires g_thread_init() to be called before all |
67082557b2c4
[svn] - glib-2.13.0 requires g_thread_init() to be called before all other GLib functions.
yaz
parents:
2605
diff
changeset
|
1058 other GLib functions */ |
67082557b2c4
[svn] - glib-2.13.0 requires g_thread_init() to be called before all other GLib functions.
yaz
parents:
2605
diff
changeset
|
1059 g_thread_init(NULL); |
67082557b2c4
[svn] - glib-2.13.0 requires g_thread_init() to be called before all other GLib functions.
yaz
parents:
2605
diff
changeset
|
1060 if (!g_thread_supported()) { |
67082557b2c4
[svn] - glib-2.13.0 requires g_thread_init() to be called before all other GLib functions.
yaz
parents:
2605
diff
changeset
|
1061 g_printerr(_("Sorry, threads isn't supported on your platform.\n\n" |
67082557b2c4
[svn] - glib-2.13.0 requires g_thread_init() to be called before all other GLib functions.
yaz
parents:
2605
diff
changeset
|
1062 "If you're on a libc5 based linux system and installed Glib & GTK+ before you\n" |
67082557b2c4
[svn] - glib-2.13.0 requires g_thread_init() to be called before all other GLib functions.
yaz
parents:
2605
diff
changeset
|
1063 "installed LinuxThreads you need to recompile Glib & GTK+.\n")); |
67082557b2c4
[svn] - glib-2.13.0 requires g_thread_init() to be called before all other GLib functions.
yaz
parents:
2605
diff
changeset
|
1064 exit(EXIT_FAILURE); |
67082557b2c4
[svn] - glib-2.13.0 requires g_thread_init() to be called before all other GLib functions.
yaz
parents:
2605
diff
changeset
|
1065 } |
67082557b2c4
[svn] - glib-2.13.0 requires g_thread_init() to be called before all other GLib functions.
yaz
parents:
2605
diff
changeset
|
1066 |
67082557b2c4
[svn] - glib-2.13.0 requires g_thread_init() to be called before all other GLib functions.
yaz
parents:
2605
diff
changeset
|
1067 gdk_threads_init(); |
67082557b2c4
[svn] - glib-2.13.0 requires g_thread_init() to be called before all other GLib functions.
yaz
parents:
2605
diff
changeset
|
1068 |
2313 | 1069 /* Setup l10n early so we can print localized error messages */ |
1070 gtk_set_locale(); | |
1071 bindtextdomain(PACKAGE_NAME, LOCALEDIR); | |
1072 bind_textdomain_codeset(PACKAGE_NAME, "UTF-8"); | |
2388
52bcc18eb8bb
[svn] - attempt to bind the audacious-plugins domain
nenolod
parents:
2369
diff
changeset
|
1073 bindtextdomain(PACKAGE_NAME "-plugins", LOCALEDIR); |
52bcc18eb8bb
[svn] - attempt to bind the audacious-plugins domain
nenolod
parents:
2369
diff
changeset
|
1074 bind_textdomain_codeset(PACKAGE_NAME "-plugins", "UTF-8"); |
2313 | 1075 textdomain(PACKAGE_NAME); |
1076 | |
1077 bmp_init_paths(); | |
1078 bmp_make_user_dir(); | |
1079 | |
1080 /* Check GTK version. Really, this is only needed for binary | |
1081 * distribution since configure already checks. */ | |
1082 if (!GTK_CHECK_VERSION(2, 6, 0)) { | |
1083 g_printerr(_("Sorry, your GTK+ version (%d.%d.%d) does not work with Audacious.\n" | |
1084 "Please use GTK+ %s or newer.\n"), | |
1085 gtk_major_version, gtk_minor_version, gtk_micro_version, | |
1086 "2.6.0"); | |
1087 exit(EXIT_FAILURE); | |
1088 } | |
1089 | |
1090 g_set_application_name(_(application_name)); | |
1091 | |
1092 cond_scan = g_cond_new(); | |
1093 mutex_scan = g_mutex_new(); | |
1094 | |
2463 | 1095 gtk_rc_add_default_file(bmp_paths[BMP_PATH_GTKRC_FILE]); |
1096 | |
2313 | 1097 gtk_init_check_ok = gtk_init_check(&argc, &argv); |
2411 | 1098 |
2413 | 1099 memset(&options, '\0', sizeof(BmpCmdLineOpt)); |
1100 options.session = -1; | |
1101 | |
2411 | 1102 context = g_option_context_new(_("- play multimedia files")); |
1103 g_option_context_add_main_entries(context, cmd_entries, PACKAGE_NAME); | |
1104 g_option_context_add_group(context, gtk_get_option_group(TRUE)); | |
1105 g_option_context_parse(context, &argc, &argv, &error); | |
1106 | |
2412 | 1107 if (error != NULL) |
1108 { | |
1109 g_printerr(_("%s: %s\nTry `%s --help' for more information.\n"), argv[0], error->message, argv[0]); | |
1110 exit(EXIT_FAILURE); | |
1111 } | |
1112 | |
2313 | 1113 if (!gtk_init_check_ok) { |
1114 if (argc < 2) { | |
1115 /* GTK check failed, and no arguments passed to indicate | |
1116 that user is intending to only remote control a running | |
1117 session */ | |
2412 | 1118 g_printerr(_("%s: Unable to open display, exiting.\n"), argv[0]); |
2313 | 1119 exit(EXIT_FAILURE); |
1120 } | |
1121 | |
1122 handle_cmd_line_options(&options, TRUE); | |
1123 | |
1124 /* we could be running headless, so GTK probably wont matter */ | |
1125 if (options.headless != 1) | |
1126 exit(EXIT_SUCCESS); | |
1127 } | |
1128 | |
1129 if (options.no_log == FALSE) | |
1130 bmp_setup_logger(); | |
1131 | |
1132 signal_handlers_init(); | |
1133 | |
1134 g_random_set_seed(time(NULL)); | |
1135 | |
1136 bmp_config_load(); | |
1137 | |
2709
47ea8eedd428
[svn] - drop controlsocket code. this probably does not compile yet.
nenolod
parents:
2700
diff
changeset
|
1138 if (options.session != -1) { |
2313 | 1139 handle_cmd_line_options(&options, TRUE); |
1140 exit(EXIT_SUCCESS); | |
1141 } | |
1142 | |
1143 plugin_system_init(); | |
1144 | |
1145 /* Initialize the playlist system. */ | |
1146 playlist_init(); | |
1147 | |
1148 if (options.headless != 1) | |
1149 { | |
1150 /* register icons in stock */ | |
1151 register_aud_stock_icons(); | |
1152 | |
1153 bmp_set_default_icon(); | |
1154 | |
1155 gtk_accel_map_load(bmp_paths[BMP_PATH_ACCEL_FILE]); | |
1156 | |
1157 /* uimanager */ | |
1158 ui_manager_init(); | |
1159 ui_manager_create_menus(); | |
1160 | |
1161 if (!init_skins(cfg.skin)) { | |
1162 run_load_skin_error_dialog(cfg.skin); | |
1163 exit(EXIT_FAILURE); | |
1164 } | |
1165 | |
1166 GDK_THREADS_ENTER(); | |
1167 } | |
1168 | |
1169 /* Load the default playlist in. */ | |
1170 playlist = playlist_get_active(); | |
1171 playlist_load(playlist, bmp_paths[BMP_PATH_PLAYLIST_FILE]); | |
1172 playlist_set_position(playlist, cfg.playlist_position); | |
1173 | |
1174 /* this needs to be called after all 3 windows are created and | |
1175 * input plugins are setup'ed | |
1176 * but not if we're running headless --nenolod | |
1177 */ | |
1178 mainwin_setup_menus(); | |
1179 | |
1180 if (options.headless != 1) | |
1181 GDK_THREADS_LEAVE(); | |
1182 | |
2694
c2b82432c1b6
[svn] Added basic DBus support, disabled by default with a configuration option to enable it. The general and playback information/manipulation methods are currently the only ones implemented. That is version, play, pause, stop, playing, paused, stopped, status, and seek. There are stubs for many unimplemented methods.
magma
parents:
2682
diff
changeset
|
1183 #ifdef USE_DBUS |
2700
2d1837805ca4
[svn] Improved DBus initialization and fixed a warning.
magma
parents:
2695
diff
changeset
|
1184 init_dbus(); |
2694
c2b82432c1b6
[svn] Added basic DBus support, disabled by default with a configuration option to enable it. The general and playback information/manipulation methods are currently the only ones implemented. That is version, play, pause, stop, playing, paused, stopped, status, and seek. There are stubs for many unimplemented methods.
magma
parents:
2682
diff
changeset
|
1185 #endif |
c2b82432c1b6
[svn] Added basic DBus support, disabled by default with a configuration option to enable it. The general and playback information/manipulation methods are currently the only ones implemented. That is version, play, pause, stop, playing, paused, stopped, status, and seek. There are stubs for many unimplemented methods.
magma
parents:
2682
diff
changeset
|
1186 |
2313 | 1187 handle_cmd_line_options(&options, FALSE); |
1188 | |
1189 if (options.headless != 1) | |
1190 { | |
1191 GDK_THREADS_ENTER(); | |
1192 | |
1193 read_volume(VOLSET_STARTUP); | |
1194 mainwin_set_info_text(); | |
1195 | |
1196 /* FIXME: delayed, because it deals directly with the plugin | |
1197 * interface to set menu items */ | |
1198 create_prefs_window(); | |
1199 | |
2364 | 1200 create_fileinfo_window(); |
1201 | |
2313 | 1202 |
1203 if (cfg.player_visible) | |
1204 mainwin_show(TRUE); | |
1205 else if (!cfg.playlist_visible && !cfg.equalizer_visible) | |
2651
4d5e6a8717dd
[svn] - allow the player to start with all of its windows hidden (but give a warning to the user, whose display can be disabled); also, try to remember player windows positions when they stay hidden between sessions
giacomo
parents:
2644
diff
changeset
|
1206 { |
4d5e6a8717dd
[svn] - allow the player to start with all of its windows hidden (but give a warning to the user, whose display can be disabled); also, try to remember player windows positions when they stay hidden between sessions
giacomo
parents:
2644
diff
changeset
|
1207 /* all of the windows are hidden... warn user about this */ |
4d5e6a8717dd
[svn] - allow the player to start with all of its windows hidden (but give a warning to the user, whose display can be disabled); also, try to remember player windows positions when they stay hidden between sessions
giacomo
parents:
2644
diff
changeset
|
1208 mainwin_show_visibility_warning(); |
4d5e6a8717dd
[svn] - allow the player to start with all of its windows hidden (but give a warning to the user, whose display can be disabled); also, try to remember player windows positions when they stay hidden between sessions
giacomo
parents:
2644
diff
changeset
|
1209 } |
2313 | 1210 |
1211 if (cfg.equalizer_visible) | |
1212 equalizerwin_show(TRUE); | |
1213 | |
1214 if (cfg.playlist_visible) | |
1215 playlistwin_show(); | |
1216 | |
1217 hint_set_always(cfg.always_on_top); | |
1218 | |
1219 playlist_start_get_info_thread(); | |
1220 mainwin_attach_idle_func(); | |
1221 | |
1222 | |
2364 | 1223 starting_up = FALSE; |
1224 has_x11_connection = TRUE; | |
2313 | 1225 |
2364 | 1226 if (cfg.resume_playback_on_startup) |
1227 { | |
1228 if (cfg.resume_playback_on_startup_time != -1 && | |
1229 playlist_get_length(playlist) > 0) | |
1230 { | |
1231 int i; | |
1232 gint l = 0, r = 0; | |
1233 while (gtk_events_pending()) gtk_main_iteration(); | |
1234 output_get_volume(&l, &r); | |
1235 output_set_volume(0,0); | |
1236 playback_initiate(); | |
2313 | 1237 |
2364 | 1238 /* Busy wait; loop is fairly tight to minimize duration of |
1239 * "frozen" GUI. Feel free to tune. --chainsaw */ | |
1240 for (i = 0; i < 20; i++) | |
1241 { | |
1242 g_usleep(1000); | |
1243 if (!ip_data.playing) | |
1244 break; | |
1245 } | |
1246 playback_seek(cfg.resume_playback_on_startup_time / 1000); | |
1247 output_set_volume(l, r); | |
1248 } | |
1249 } | |
1250 | |
2313 | 1251 gtk_main(); |
1252 | |
1253 GDK_THREADS_LEAVE(); | |
1254 | |
2711
c35913222440
[svn] Initial commit of dbus client library for plugins. Various changes were made to the plugin structure to support dbus.
magma
parents:
2709
diff
changeset
|
1255 #ifdef USE_DBUS |
c35913222440
[svn] Initial commit of dbus client library for plugins. Various changes were made to the plugin structure to support dbus.
magma
parents:
2709
diff
changeset
|
1256 free_dbus(); |
c35913222440
[svn] Initial commit of dbus client library for plugins. Various changes were made to the plugin structure to support dbus.
magma
parents:
2709
diff
changeset
|
1257 #endif |
c35913222440
[svn] Initial commit of dbus client library for plugins. Various changes were made to the plugin structure to support dbus.
magma
parents:
2709
diff
changeset
|
1258 |
2313 | 1259 g_cond_free(cond_scan); |
1260 g_mutex_free(mutex_scan); | |
1261 | |
1262 return EXIT_SUCCESS; | |
1263 } | |
2364 | 1264 // if we are running headless |
2313 | 1265 else |
1266 { | |
2506
630910fd140f
[svn] - changed plugin directory to ~/.local/share/audacious/Plugins (seems more logical to me)
mf0102
parents:
2475
diff
changeset
|
1267 GMainLoop *loop; |
2369 | 1268 |
2313 | 1269 mainwin_set_info_text(); |
1270 playlist_start_get_info_thread(); | |
1271 | |
2364 | 1272 starting_up = FALSE; |
2313 | 1273 |
2506
630910fd140f
[svn] - changed plugin directory to ~/.local/share/audacious/Plugins (seems more logical to me)
mf0102
parents:
2475
diff
changeset
|
1274 loop = g_main_loop_new(NULL, TRUE); |
630910fd140f
[svn] - changed plugin directory to ~/.local/share/audacious/Plugins (seems more logical to me)
mf0102
parents:
2475
diff
changeset
|
1275 g_timeout_add(10, aud_headless_iteration, NULL); |
630910fd140f
[svn] - changed plugin directory to ~/.local/share/audacious/Plugins (seems more logical to me)
mf0102
parents:
2475
diff
changeset
|
1276 g_main_loop_run(loop); |
2313 | 1277 |
2711
c35913222440
[svn] Initial commit of dbus client library for plugins. Various changes were made to the plugin structure to support dbus.
magma
parents:
2709
diff
changeset
|
1278 #ifdef USE_DBUS |
c35913222440
[svn] Initial commit of dbus client library for plugins. Various changes were made to the plugin structure to support dbus.
magma
parents:
2709
diff
changeset
|
1279 free_dbus(); |
c35913222440
[svn] Initial commit of dbus client library for plugins. Various changes were made to the plugin structure to support dbus.
magma
parents:
2709
diff
changeset
|
1280 #endif |
c35913222440
[svn] Initial commit of dbus client library for plugins. Various changes were made to the plugin structure to support dbus.
magma
parents:
2709
diff
changeset
|
1281 |
2313 | 1282 return EXIT_SUCCESS; |
1283 } | |
1284 } |