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