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