Mercurial > audlegacy
annotate audacious/main.c @ 913:dff18ce367ab trunk
[svn] object files in Plugins/General/scrobbler/tags/ should be deleted too on clean requests
author | giacomo |
---|---|
date | Sun, 02 Apr 2006 17:53:30 -0700 |
parents | c800beaac0f9 |
children | 0606d7908abb |
rev | line source |
---|---|
680
8282b365f6cb
[svn] - Add some sanity checking to make sure we can't do X11 stuff when running headless.
nenolod
parents:
625
diff
changeset
|
1 /* Audacious - Cross-platform multimedia player |
8282b365f6cb
[svn] - Add some sanity checking to make sure we can't do X11 stuff when running headless.
nenolod
parents:
625
diff
changeset
|
2 * Copyright (C) 2005-2006 Audacious development team. |
197
ccd034857702
[svn] Split up generic events into audcore_generic_events(), and client-specific stuff remains in mainwin_idle_func().
nenolod
parents:
196
diff
changeset
|
3 * |
ccd034857702
[svn] Split up generic events into audcore_generic_events(), and client-specific stuff remains in mainwin_idle_func().
nenolod
parents:
196
diff
changeset
|
4 * Based on BMP: |
0 | 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; either version 2 of the License, or | |
13 * (at your option) any later version. | |
14 * | |
15 * This program is distributed in the hope that it will be useful, | |
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 * GNU General Public License for more details. | |
19 * | |
20 * You should have received a copy of the GNU General Public License | |
21 * along with this program; if not, write to the Free Software | |
22 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
23 */ | |
24 | |
25 #ifdef HAVE_CONFIG_H | |
26 # include "config.h" | |
27 #endif | |
28 | |
29 #include "main.h" | |
30 | |
31 #include <glib.h> | |
32 #include <glib/gi18n.h> | |
33 #include <glib/gprintf.h> | |
34 #include <gdk/gdk.h> | |
35 #include <stdlib.h> | |
36 #include <string.h> | |
37 #include <getopt.h> | |
38 #include <ctype.h> | |
39 #include <time.h> | |
40 | |
41 #include <unistd.h> | |
42 #include <errno.h> | |
43 #include <sys/types.h> | |
44 #include <sys/stat.h> | |
45 #include <signal.h> | |
46 #include <gdk/gdkx.h> | |
47 #include <X11/Xlib.h> | |
48 #include <X11/Xatom.h> | |
49 | |
50 #include "libaudacious/configdb.h" | |
51 #include "libaudacious/beepctrl.h" | |
52 #include "libaudacious/util.h" | |
53 #include "libaudacious/vfs.h" | |
54 | |
55 #include "controlsocket.h" | |
56 #include "dnd.h" | |
57 #include "dock.h" | |
58 #include "effect.h" | |
59 #include "equalizer.h" | |
60 #include "general.h" | |
197
ccd034857702
[svn] Split up generic events into audcore_generic_events(), and client-specific stuff remains in mainwin_idle_func().
nenolod
parents:
196
diff
changeset
|
61 #include "genevent.h" |
0 | 62 #include "hints.h" |
63 #include "input.h" | |
64 #include "logger.h" | |
65 #include "mainwin.h" | |
66 #include "output.h" | |
538
e4e897d20791
[svn] remove libaudcore, we never did anything with it
nenolod
parents:
534
diff
changeset
|
67 #include "playback.h" |
0 | 68 #include "playlist.h" |
383 | 69 #include "ui_playlist.h" |
0 | 70 #include "pluginenum.h" |
71 #include "prefswin.h" | |
72 #include "skin.h" | |
73 #include "skinwin.h" | |
74 #include "util.h" | |
75 #include "visualization.h" | |
530
1947144093bc
[svn] When running SVN, make a note of the SVN version. The SVN version is stored in build_stamp.c.
nenolod
parents:
486
diff
changeset
|
76 #include "build_stamp.h" |
0 | 77 |
78 #include "pixmaps.h" | |
120 | 79 #include "images/audacious_player.xpm" |
0 | 80 |
680
8282b365f6cb
[svn] - Add some sanity checking to make sure we can't do X11 stuff when running headless.
nenolod
parents:
625
diff
changeset
|
81 gboolean has_x11_connection = FALSE; /* do we have an X11 connection? */ |
0 | 82 |
83 /* Translatable string for beep.desktop's comment field */ | |
85
8c8a20f72ace
[svn] s/static GTKItemFactoryEntry/GTKItemFactoryEntry/g.
nenolod
parents:
80
diff
changeset
|
84 const gchar *desktop_comment = N_("Audacious"); |
0 | 85 |
85
8c8a20f72ace
[svn] s/static GTKItemFactoryEntry/GTKItemFactoryEntry/g.
nenolod
parents:
80
diff
changeset
|
86 const gchar *application_name = N_("Audacious"); |
0 | 87 |
88 | |
89 struct _BmpCmdLineOpt { | |
90 GList *filenames; | |
91 gint session; | |
92 gboolean play, stop, pause, fwd, rew, play_pause, playcd; | |
93 gboolean enqueue, mainwin, remote, activate; | |
94 gboolean load_skins; | |
191 | 95 gboolean headless; |
0 | 96 gchar *previous_session_id; |
97 }; | |
98 | |
99 typedef struct _BmpCmdLineOpt BmpCmdLineOpt; | |
100 | |
781
12c47704b4b5
[svn] Add error reporting for many places, patch by external contributor Derek
nenolod
parents:
749
diff
changeset
|
101 BmpCmdLineOpt options; |
0 | 102 |
103 BmpConfig cfg; | |
104 | |
105 BmpConfig bmp_default_config = { | |
106 MAINWIN_DEFAULT_POS_X, /* mainwin x position */ | |
107 MAINWIN_DEFAULT_POS_Y, /* mainwin y position */ | |
108 EQUALIZER_DEFAULT_POS_X, /* equalizer x position */ | |
109 EQUALIZER_DEFAULT_POS_Y, /* equalizer y position */ | |
110 PLAYLISTWIN_DEFAULT_POS_X, /* playlistwin x position */ | |
111 PLAYLISTWIN_DEFAULT_POS_Y, /* playlistwin y position */ | |
112 PLAYLISTWIN_DEFAULT_WIDTH, /* playlistwin width */ | |
113 PLAYLISTWIN_DEFAULT_HEIGHT, /* playlistwin height */ | |
114 10, /* snap distance */ | |
115 FALSE, /* real-time priority */ | |
116 FALSE, FALSE, /* shuffle, repeat */ | |
117 FALSE, /* UNUSED (double size) */ | |
118 TRUE, /* autoscroll */ | |
898 | 119 FALSE, /* stop after current song */ |
0 | 120 TRUE, /* analyzer peaks */ |
121 FALSE, /* equalizer autoload */ | |
122 FALSE, /* easy move */ | |
123 FALSE, /* equalizer active */ | |
124 FALSE, /* playlistwin visible */ | |
125 FALSE, /* equalizer visible */ | |
126 TRUE, /* player visible */ | |
127 FALSE, /* player shaded */ | |
128 FALSE, /* playlistwin shaded */ | |
129 FALSE, /* equalizer shaded */ | |
130 FALSE, /* allow multiple instances */ | |
131 TRUE, /* always show cb */ | |
132 TRUE, TRUE, /* convert '_' and %20 */ | |
133 TRUE, /* show numbers in playlist */ | |
134 TRUE, /* snap windows */ | |
135 TRUE, /* save window positions */ | |
136 TRUE, /* dim titlebar */ | |
137 FALSE, /* get playlist info on load */ | |
138 TRUE, /* get playlist info on demand */ | |
139 TRUE, /* UNUSED (equalizer doublesize linked) */ | |
140 FALSE, /* sort jump to file */ | |
141 FALSE, /* use effect plugins */ | |
142 FALSE, /* always on top */ | |
143 FALSE, /* sticky */ | |
144 FALSE, /* no playlist advance */ | |
893
6afdd0d7e1e1
[svn] Make refreshing optional, default to disabled if Gnome VFS available.
nemo
parents:
887
diff
changeset
|
145 #ifdef HAVE_GNOME_VFS |
6afdd0d7e1e1
[svn] Make refreshing optional, default to disabled if Gnome VFS available.
nemo
parents:
887
diff
changeset
|
146 FALSE, /* refresh file list - should be unneeded with VFS */ |
6afdd0d7e1e1
[svn] Make refreshing optional, default to disabled if Gnome VFS available.
nemo
parents:
887
diff
changeset
|
147 #else |
6afdd0d7e1e1
[svn] Make refreshing optional, default to disabled if Gnome VFS available.
nemo
parents:
887
diff
changeset
|
148 TRUE, /* refresh file list */ |
6afdd0d7e1e1
[svn] Make refreshing optional, default to disabled if Gnome VFS available.
nemo
parents:
887
diff
changeset
|
149 #endif |
0 | 150 TRUE, /* UNUSED (smooth title scrolling) */ |
151 TRUE, /* use playlist metadata */ | |
152 TRUE, /* warn about unplayables */ | |
153 FALSE, /* use \ as directory delimiter */ | |
154 FALSE, /* random skin on play */ | |
155 FALSE, /* use fontsets */ | |
156 FALSE, /* use X font for mainwin */ | |
157 TRUE, /* use custom cursors */ | |
158 TRUE, /* close dialog on open */ | |
159 TRUE, /* close dialog on add */ | |
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 VU_SMOOTH, /* VU mode */ | |
182 REFRESH_FULL, /* visualizer refresh rate */ | |
183 FALLOFF_FAST, /* analyzer fall off rate */ | |
184 FALLOFF_SLOW, /* peaks fall off rate */ | |
185 0, /* playlist position */ | |
186 2, /* pause between songs time */ | |
187 FALSE, /* pause between songs */ | |
188 FALSE, /* show window decorations */ | |
189 8, /* mouse wheel scroll step */ | |
190 FALSE, /* playlist transparent */ | |
534
ba0608cbbdaa
[svn] artist - album - title is now the default title format.
nenolod
parents:
530
diff
changeset
|
191 2, /* 2nd preset (ARTIST - TITLE) */ |
0 | 192 NULL, /* title format */ |
193 FALSE, /* software volume control enabled */ | |
194 TRUE, /* UNUSED (XMMS compatibility mode) */ | |
195 TRUE, /* extra eq filtering */ | |
196 3 /* scroll pl by */ | |
197 }; | |
198 | |
199 typedef struct bmp_cfg_boolent_t { | |
200 char const *be_vname; | |
201 gboolean *be_vloc; | |
202 gboolean be_wrt; | |
203 } bmp_cfg_boolent; | |
204 | |
205 typedef struct bmp_cfg_nument_t { | |
206 char const *ie_vname; | |
207 gint *ie_vloc; | |
208 gboolean ie_wrt; | |
209 } bmp_cfg_nument; | |
210 | |
211 typedef struct bmp_cfg_strent_t { | |
212 char const *se_vname; | |
213 char **se_vloc; | |
214 gboolean se_wrt; | |
215 } bmp_cfg_strent; | |
216 | |
217 const gchar *bmp_titlestring_presets[] = { | |
218 "%t", | |
219 "%p - %t", | |
220 "%p - %a - %t", | |
221 "%a - %t" | |
222 }; | |
223 | |
224 const guint n_titlestring_presets = G_N_ELEMENTS(bmp_titlestring_presets); | |
225 | |
226 static bmp_cfg_boolent bmp_boolents[] = { | |
227 {"allow_multiple_instances", &cfg.allow_multiple_instances, TRUE}, | |
228 {"use_realtime", &cfg.use_realtime, TRUE}, | |
229 {"always_show_cb", &cfg.always_show_cb, TRUE}, | |
230 {"convert_underscore", &cfg.convert_underscore, TRUE}, | |
231 {"convert_twenty", &cfg.convert_twenty, TRUE}, | |
232 {"show_numbers_in_pl", &cfg.show_numbers_in_pl, TRUE}, | |
233 {"snap_windows", &cfg.snap_windows, TRUE}, | |
234 {"save_window_positions", &cfg.save_window_position, TRUE}, | |
235 {"dim_titlebar", &cfg.dim_titlebar, TRUE}, | |
236 {"get_info_on_load", &cfg.get_info_on_load, TRUE}, | |
237 {"get_info_on_demand", &cfg.get_info_on_demand, TRUE}, | |
238 {"no_playlist_advance", &cfg.no_playlist_advance, TRUE}, | |
893
6afdd0d7e1e1
[svn] Make refreshing optional, default to disabled if Gnome VFS available.
nemo
parents:
887
diff
changeset
|
239 {"refresh_file_list", &cfg.refresh_file_list, TRUE}, |
0 | 240 {"sort_jump_to_file", &cfg.sort_jump_to_file, TRUE}, |
241 {"use_pl_metadata", &cfg.use_pl_metadata, TRUE}, | |
242 {"warn_about_unplayables", &cfg.warn_about_unplayables, TRUE}, | |
243 {"use_backslash_as_dir_delimiter", &cfg.use_backslash_as_dir_delimiter, TRUE}, | |
244 {"player_shaded", &cfg.player_shaded, TRUE}, | |
245 {"player_visible", &cfg.player_visible, TRUE}, | |
246 {"shuffle", &cfg.shuffle, TRUE}, | |
247 {"repeat", &cfg.repeat, TRUE}, | |
248 {"autoscroll_songname", &cfg.autoscroll, TRUE}, | |
898 | 249 {"stop_after_current_song", &cfg.stopaftersong, TRUE}, |
0 | 250 {"playlist_shaded", &cfg.playlist_shaded, TRUE}, |
251 {"playlist_visible", &cfg.playlist_visible, TRUE}, | |
252 {"playlist_transparent", &cfg.playlist_transparent, TRUE}, | |
253 {"use_fontsets", &cfg.use_fontsets, TRUE}, | |
85
8c8a20f72ace
[svn] s/static GTKItemFactoryEntry/GTKItemFactoryEntry/g.
nenolod
parents:
80
diff
changeset
|
254 {"mainwin_use_xfont", &cfg.mainwin_use_xfont, FALSE}, |
0 | 255 {"equalizer_visible", &cfg.equalizer_visible, TRUE}, |
256 {"equalizer_active", &cfg.equalizer_active, TRUE}, | |
257 {"equalizer_shaded", &cfg.equalizer_shaded, TRUE}, | |
258 {"equalizer_autoload", &cfg.equalizer_autoload, TRUE}, | |
259 {"use_eplugins", &cfg.use_eplugins, TRUE}, | |
260 {"always_on_top", &cfg.always_on_top, TRUE}, | |
261 {"sticky", &cfg.sticky, TRUE}, | |
262 {"random_skin_on_play", &cfg.random_skin_on_play, TRUE}, | |
263 {"pause_between_songs", &cfg.pause_between_songs, TRUE}, | |
264 {"show_wm_decorations", &cfg.show_wm_decorations, TRUE}, | |
265 {"eq_extra_filtering", &cfg.eq_extra_filtering, TRUE}, | |
266 {"analyzer_peaks", &cfg.analyzer_peaks, TRUE}, | |
267 {"custom_cursors", &cfg.custom_cursors, TRUE}, | |
268 {"close_dialog_open", &cfg.close_dialog_open, TRUE}, | |
269 {"close_dialog_add", &cfg.close_dialog_add, TRUE} | |
270 }; | |
271 | |
272 static gint ncfgbent = G_N_ELEMENTS(bmp_boolents); | |
273 | |
274 static bmp_cfg_nument bmp_numents[] = { | |
275 {"player_x", &cfg.player_x, TRUE}, | |
276 {"player_y", &cfg.player_y, TRUE}, | |
277 {"timer_mode", &cfg.timer_mode, TRUE}, | |
278 {"vis_type", &cfg.vis_type, TRUE}, | |
279 {"analyzer_mode", &cfg.analyzer_mode, TRUE}, | |
280 {"analyzer_type", &cfg.analyzer_type, TRUE}, | |
281 {"scope_mode", &cfg.scope_mode, TRUE}, | |
282 {"vu_mode", &cfg.vu_mode, TRUE}, | |
283 {"vis_refresh_rate", &cfg.vis_refresh, TRUE}, | |
284 {"analyzer_falloff", &cfg.analyzer_falloff, TRUE}, | |
285 {"peaks_falloff", &cfg.peaks_falloff, TRUE}, | |
286 {"playlist_x", &cfg.playlist_x, TRUE}, | |
287 {"playlist_y", &cfg.playlist_y, TRUE}, | |
288 {"playlist_width", &cfg.playlist_width, TRUE}, | |
289 {"playlist_height", &cfg.playlist_height, TRUE}, | |
290 {"playlist_position", &cfg.playlist_position, TRUE}, | |
291 {"equalizer_x", &cfg.equalizer_x, TRUE}, | |
292 {"equalizer_y", &cfg.equalizer_y, TRUE}, | |
293 {"snap_distance", &cfg.snap_distance, TRUE}, | |
294 {"pause_between_songs_time", &cfg.pause_between_songs_time, TRUE}, | |
295 {"mouse_wheel_change", &cfg.mouse_change, TRUE}, | |
296 {"scroll_pl_by", &cfg.scroll_pl_by, TRUE}, | |
297 {"titlestring_preset", &cfg.titlestring_preset, TRUE}, | |
298 }; | |
299 | |
300 static gint ncfgient = G_N_ELEMENTS(bmp_numents); | |
301 | |
302 static bmp_cfg_strent bmp_strents[] = { | |
303 {"playlist_font", &cfg.playlist_font, TRUE}, | |
304 {"mainwin_font", &cfg.mainwin_font, TRUE}, | |
305 {"eqpreset_default_file", &cfg.eqpreset_default_file, TRUE}, | |
306 {"eqpreset_extension", &cfg.eqpreset_extension, TRUE}, | |
307 {"skin", &cfg.skin, FALSE}, | |
308 {"output_plugin", &cfg.outputplugin, FALSE}, | |
309 {"disabled_iplugins", &cfg.disabled_iplugins, TRUE}, | |
310 {"enabled_gplugins", &cfg.enabled_gplugins, FALSE}, | |
311 {"enabled_vplugins", &cfg.enabled_vplugins, FALSE}, | |
312 {"enabled_eplugins", &cfg.enabled_eplugins, FALSE}, | |
313 {"filesel_path", &cfg.filesel_path, FALSE}, | |
314 {"playlist_path", &cfg.playlist_path, FALSE}, | |
315 {"generic_title_format", &cfg.gentitle_format, TRUE}, | |
316 }; | |
317 | |
318 static gint ncfgsent = G_N_ELEMENTS(bmp_strents); | |
319 | |
320 gchar *bmp_paths[BMP_PATH_COUNT] = {}; | |
321 | |
322 GList *dock_window_list = NULL; | |
323 | |
324 gboolean pposition_broken = FALSE; | |
325 | |
486 | 326 gboolean starting_up = TRUE; |
0 | 327 |
328 static GSList * | |
329 get_feature_list(void) | |
330 { | |
331 GSList *features = NULL; | |
332 | |
333 #ifdef HAVE_GNOME_VFS | |
334 features = g_slist_append(features, "GNOME VFS"); | |
335 #endif | |
336 | |
337 #ifdef HAVE_GCONF | |
338 features = g_slist_append(features, "GConf"); | |
339 #endif | |
340 | |
341 return features; | |
342 } | |
343 | |
344 static void | |
345 dump_version(void) | |
346 { | |
347 GSList *features; | |
348 | |
530
1947144093bc
[svn] When running SVN, make a note of the SVN version. The SVN version is stored in build_stamp.c.
nenolod
parents:
486
diff
changeset
|
349 g_printf("%s %s [%s]", _(application_name), VERSION, svn_stamp); |
0 | 350 |
351 features = get_feature_list(); | |
352 | |
353 if (features) { | |
354 GSList *item; | |
355 | |
356 g_printf(" ("); | |
357 | |
358 for (item = features; g_slist_next(item); item = g_slist_next(item)) | |
359 g_printf("%s, ", (const gchar *) item->data); | |
360 | |
361 g_printf("%s)", (const gchar *) item->data); | |
362 | |
363 g_slist_free(features); | |
364 } | |
365 | |
366 g_printf("\n"); | |
367 } | |
368 | |
369 const gchar * | |
370 xmms_get_gentitle_format(void) | |
371 { | |
625
0a73d1faeb4e
[svn] GCC 4.1 warning fixes by Diego 'Flameeyes' Petteno from Gentoo.
chainsaw
parents:
538
diff
changeset
|
372 guint titlestring_preset = cfg.titlestring_preset; |
0 | 373 |
374 if (titlestring_preset < n_titlestring_presets) | |
375 return bmp_titlestring_presets[titlestring_preset]; | |
376 | |
377 return cfg.gentitle_format; | |
378 } | |
379 | |
887 | 380 void |
0 | 381 make_directory(const gchar * path, mode_t mode) |
382 { | |
383 if (mkdir(path, mode) == 0) | |
384 return; | |
385 | |
386 if (errno == EEXIST) | |
387 return; | |
388 | |
389 g_printerr(_("Could not create directory (%s): %s"), path, | |
390 g_strerror(errno)); | |
391 } | |
392 | |
393 static void | |
394 bmp_make_user_dir(void) | |
395 { | |
396 const mode_t mode755 = S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH; | |
397 | |
398 make_directory(bmp_paths[BMP_PATH_USER_DIR], mode755); | |
399 make_directory(bmp_paths[BMP_PATH_USER_PLUGIN_DIR], mode755); | |
400 make_directory(bmp_paths[BMP_PATH_USER_SKIN_DIR], mode755); | |
401 make_directory(bmp_paths[BMP_PATH_SKIN_THUMB_DIR], mode755); | |
402 } | |
403 | |
404 static void | |
405 bmp_free_paths(void) | |
406 { | |
407 int i; | |
408 | |
409 for (i = 0; i < BMP_PATH_COUNT; i++) | |
410 { | |
411 g_free(bmp_paths[i]); | |
412 bmp_paths[i] = 0; | |
413 } | |
414 } | |
415 | |
416 | |
417 #define USER_PATH(path) \ | |
418 g_build_filename(bmp_paths[BMP_PATH_USER_DIR], path, NULL); | |
419 | |
420 static void | |
421 bmp_init_paths(void) | |
422 { | |
734 | 423 bmp_paths[BMP_PATH_USER_DIR] = g_build_filename(g_get_home_dir(), BMP_RCPATH, NULL); |
0 | 424 |
425 bmp_paths[BMP_PATH_USER_PLUGIN_DIR] = USER_PATH(BMP_USER_PLUGIN_DIR_BASENAME); | |
426 bmp_paths[BMP_PATH_USER_SKIN_DIR] = USER_PATH(BMP_SKIN_DIR_BASENAME); | |
427 bmp_paths[BMP_PATH_SKIN_THUMB_DIR] = USER_PATH(BMP_SKIN_THUMB_DIR_BASENAME); | |
428 bmp_paths[BMP_PATH_CONFIG_FILE] = USER_PATH(BMP_CONFIG_BASENAME); | |
429 bmp_paths[BMP_PATH_PLAYLIST_FILE] = USER_PATH(BMP_PLAYLIST_BASENAME); | |
430 bmp_paths[BMP_PATH_ACCEL_FILE] = USER_PATH(BMP_ACCEL_BASENAME); | |
431 bmp_paths[BMP_PATH_LOG_FILE] = USER_PATH(BMP_LOG_BASENAME); | |
432 | |
433 g_atexit(bmp_free_paths); | |
434 } | |
435 | |
436 | |
437 void | |
438 bmp_config_load(void) | |
439 { | |
440 ConfigDb *db; | |
441 gint i, length; | |
442 | |
443 memcpy(&cfg, &bmp_default_config, sizeof(BmpConfig)); | |
444 | |
445 db = bmp_cfg_db_open(); | |
446 for (i = 0; i < ncfgbent; ++i) { | |
447 bmp_cfg_db_get_bool(db, NULL, | |
448 bmp_boolents[i].be_vname, | |
449 bmp_boolents[i].be_vloc); | |
450 } | |
451 | |
452 for (i = 0; i < ncfgient; ++i) { | |
453 bmp_cfg_db_get_int(db, NULL, | |
454 bmp_numents[i].ie_vname, | |
455 bmp_numents[i].ie_vloc); | |
456 } | |
457 | |
458 for (i = 0; i < ncfgsent; ++i) { | |
459 bmp_cfg_db_get_string(db, NULL, | |
460 bmp_strents[i].se_vname, | |
461 bmp_strents[i].se_vloc); | |
462 } | |
463 | |
464 /* Preset */ | |
465 bmp_cfg_db_get_float(db, NULL, "equalizer_preamp", &cfg.equalizer_preamp); | |
466 for (i = 0; i < 10; i++) { | |
467 gchar eqtext[18]; | |
468 | |
469 g_snprintf(eqtext, sizeof(eqtext), "equalizer_band%d", i); | |
470 bmp_cfg_db_get_float(db, NULL, eqtext, &cfg.equalizer_bands[i]); | |
471 } | |
472 | |
473 /* History */ | |
474 if (bmp_cfg_db_get_int(db, NULL, "url_history_length", &length)) { | |
475 for (i = 1; i <= length; i++) { | |
476 gchar str[19], *tmp; | |
477 | |
478 g_snprintf(str, sizeof(str), "url_history%d", i); | |
479 if (bmp_cfg_db_get_string(db, NULL, str, &tmp)) | |
480 cfg.url_history = g_list_append(cfg.url_history, tmp); | |
481 } | |
482 } | |
483 | |
484 bmp_cfg_db_close(db); | |
485 | |
486 | |
487 if (cfg.playlist_font && strlen(cfg.playlist_font) == 0) { | |
488 g_free(cfg.playlist_font); | |
489 cfg.playlist_font = NULL; | |
490 } | |
491 | |
492 if (cfg.mainwin_font && strlen(cfg.mainwin_font) == 0) { | |
493 g_free(cfg.mainwin_font); | |
494 cfg.mainwin_font = NULL; | |
495 } | |
496 | |
497 if (!cfg.playlist_font) | |
498 cfg.playlist_font = g_strdup(PLAYLISTWIN_DEFAULT_FONT); | |
499 | |
500 if (!cfg.mainwin_font) | |
501 cfg.mainwin_font = g_strdup(MAINWIN_DEFAULT_FONT); | |
502 | |
503 if (!cfg.gentitle_format) | |
534
ba0608cbbdaa
[svn] artist - album - title is now the default title format.
nenolod
parents:
530
diff
changeset
|
504 cfg.gentitle_format = g_strdup("%p - %a - %t"); |
0 | 505 |
506 if (!cfg.outputplugin) { | |
507 #ifdef HAVE_OSS | |
508 cfg.outputplugin = g_build_filename(PLUGIN_DIR, plugin_dir_list[0], | |
509 PLUGIN_FILENAME("OSS"), NULL); | |
510 #else | |
511 /* FIXME: This implicitly means the output plugin that is | |
512 * first in the alphabet will be used (usually the disk writer | |
513 * plugin) */ | |
514 cfg.outputplugin = g_strdup(""); | |
515 #endif | |
516 } | |
517 | |
518 if (!cfg.eqpreset_default_file) | |
519 cfg.eqpreset_default_file = g_strdup(EQUALIZER_DEFAULT_DIR_PRESET); | |
520 | |
521 if (!cfg.eqpreset_extension) | |
522 cfg.eqpreset_extension = g_strdup(EQUALIZER_DEFAULT_PRESET_EXT); | |
523 } | |
524 | |
525 | |
526 void | |
527 bmp_config_save(void) | |
528 { | |
529 GList *node; | |
530 gchar *str; | |
531 gint i; | |
532 ConfigDb *db; | |
533 | |
534 cfg.disabled_iplugins = input_stringify_disabled_list(); | |
535 | |
536 | |
537 db = bmp_cfg_db_open(); | |
538 | |
539 for (i = 0; i < ncfgbent; ++i) | |
540 if (bmp_boolents[i].be_wrt) | |
541 bmp_cfg_db_set_bool(db, NULL, | |
542 bmp_boolents[i].be_vname, | |
543 *bmp_boolents[i].be_vloc); | |
544 | |
545 /* HACK: Work-around for bug #129 */ | |
80 | 546 /* |
0 | 547 bmp_cfg_db_set_bool(db, NULL, "playlist_shaded", |
548 FALSE); | |
80 | 549 */ |
0 | 550 for (i = 0; i < ncfgient; ++i) |
551 if (bmp_numents[i].ie_wrt) | |
552 bmp_cfg_db_set_int(db, NULL, | |
553 bmp_numents[i].ie_vname, | |
554 *bmp_numents[i].ie_vloc); | |
555 | |
556 /* This is a bit lame .. it'll end up being written twice, | |
557 * could do with being done a bit neater. -larne */ | |
558 bmp_cfg_db_set_int(db, NULL, "playlist_position", | |
559 playlist_get_position()); | |
560 | |
207
e152a92d3f45
[svn] Save the preference to enable or disable bitmap fonts.
nenolod
parents:
198
diff
changeset
|
561 bmp_cfg_db_set_bool(db, NULL, "mainwin_use_xfont", |
e152a92d3f45
[svn] Save the preference to enable or disable bitmap fonts.
nenolod
parents:
198
diff
changeset
|
562 cfg.mainwin_use_xfont); |
e152a92d3f45
[svn] Save the preference to enable or disable bitmap fonts.
nenolod
parents:
198
diff
changeset
|
563 |
0 | 564 for (i = 0; i < ncfgsent; ++i) { |
565 if (bmp_strents[i].se_wrt) | |
566 bmp_cfg_db_set_string(db, NULL, | |
567 bmp_strents[i].se_vname, | |
568 *bmp_strents[i].se_vloc); | |
569 } | |
570 | |
571 bmp_cfg_db_set_float(db, NULL, "equalizer_preamp", cfg.equalizer_preamp); | |
572 | |
573 for (i = 0; i < 10; i++) { | |
574 str = g_strdup_printf("equalizer_band%d", i); | |
575 bmp_cfg_db_set_float(db, NULL, str, cfg.equalizer_bands[i]); | |
576 g_free(str); | |
577 } | |
578 | |
196 | 579 if (bmp_active_skin != NULL) |
580 { | |
581 if (bmp_active_skin->path) | |
582 bmp_cfg_db_set_string(db, NULL, "skin", bmp_active_skin->path); | |
583 else | |
584 bmp_cfg_db_unset_key(db, NULL, "skin"); | |
585 } | |
0 | 586 |
587 if (get_current_output_plugin()) | |
588 bmp_cfg_db_set_string(db, NULL, "output_plugin", | |
589 get_current_output_plugin()->filename); | |
590 else | |
591 bmp_cfg_db_unset_key(db, NULL, "output_plugin"); | |
592 | |
593 str = general_stringify_enabled_list(); | |
594 if (str) { | |
595 bmp_cfg_db_set_string(db, NULL, "enabled_gplugins", str); | |
596 g_free(str); | |
597 } | |
598 else | |
599 bmp_cfg_db_unset_key(db, NULL, "enabled_gplugins"); | |
600 | |
601 str = vis_stringify_enabled_list(); | |
602 if (str) { | |
603 bmp_cfg_db_set_string(db, NULL, "enabled_vplugins", str); | |
604 g_free(str); | |
605 } | |
606 else | |
607 bmp_cfg_db_unset_key(db, NULL, "enabled_vplugins"); | |
608 | |
609 str = effect_stringify_enabled_list(); | |
610 if (str) { | |
611 bmp_cfg_db_set_string(db, NULL, "enabled_eplugins", str); | |
612 g_free(str); | |
613 } | |
614 else | |
615 bmp_cfg_db_unset_key(db, NULL, "enabled_eplugins"); | |
616 | |
617 if (cfg.filesel_path) | |
618 bmp_cfg_db_set_string(db, NULL, "filesel_path", cfg.filesel_path); | |
619 | |
620 if (cfg.playlist_path) | |
621 bmp_cfg_db_set_string(db, NULL, "playlist_path", cfg.playlist_path); | |
622 | |
623 bmp_cfg_db_set_int(db, NULL, "url_history_length", | |
624 g_list_length(cfg.url_history)); | |
625 | |
626 for (node = cfg.url_history, i = 1; node; node = g_list_next(node), i++) { | |
627 str = g_strdup_printf("url_history%d", i); | |
628 bmp_cfg_db_set_string(db, NULL, str, node->data); | |
629 g_free(str); | |
630 } | |
631 | |
632 bmp_cfg_db_close(db); | |
633 | |
634 playlist_save(bmp_paths[BMP_PATH_PLAYLIST_FILE], FALSE); | |
635 } | |
636 | |
637 static void | |
638 bmp_set_default_icon(void) | |
639 { | |
640 GdkPixbuf *icon; | |
641 | |
120 | 642 icon = gdk_pixbuf_new_from_xpm_data((const gchar **) audacious_player_xpm); |
0 | 643 gtk_window_set_default_icon(icon); |
644 g_object_unref(icon); | |
645 } | |
646 | |
647 static void | |
648 display_usage(void) | |
649 { | |
44 | 650 g_print(_("Usage: audacious [options] [files] ...\n\n" |
0 | 651 "Options:\n" |
652 "--------\n")); | |
653 g_print("\n-h, --help "); | |
654 /* -h, --help switch */ | |
655 g_print(_("Display this text and exit")); | |
656 g_print("\n-n, --session "); | |
657 /* -n, --session switch */ | |
257
256b3acc87d4
[svn] Properly report Audacious instead of XMMS or BMP in all places. Patch by laci; closes bug #379.
chainsaw
parents:
216
diff
changeset
|
658 g_print(_("Select Audacious/BMP/XMMS session (Default: 0)")); |
0 | 659 g_print("\n-r, --rew "); |
660 /* -r, --rew switch */ | |
661 g_print(_("Skip backwards in playlist")); | |
662 g_print("\n-p, --play "); | |
663 /* -p, --play switch */ | |
664 g_print(_("Start playing current playlist")); | |
665 g_print("\n-u, --pause "); | |
666 /* -u, --pause switch */ | |
667 g_print(_("Pause current song")); | |
668 g_print("\n-s, --stop "); | |
669 /* -s, --stop switch */ | |
670 g_print(_("Stop current song")); | |
671 g_print("\n-t, --play-pause "); | |
672 /* -t, --play-pause switch */ | |
673 g_print(_("Pause if playing, play otherwise")); | |
674 g_print("\n-f, --fwd "); | |
675 /* -f, --fwd switch */ | |
676 g_print(_("Skip forward in playlist")); | |
677 g_print("\n-e, --enqueue "); | |
678 /* -e, --enqueue switch */ | |
679 g_print(_("Don't clear the playlist")); | |
680 g_print("\n-m, --show-main-window "); | |
681 /* -m, --show-main-window switch */ | |
682 g_print(_("Show the main window")); | |
683 g_print("\n-a, --activate "); | |
684 /* -a, --activate switch */ | |
257
256b3acc87d4
[svn] Properly report Audacious instead of XMMS or BMP in all places. Patch by laci; closes bug #379.
chainsaw
parents:
216
diff
changeset
|
685 g_print(_("Activate Audacious")); |
0 | 686 g_print("\n-i, --sm-client-id "); |
687 /* -i, --sm-client-id switch */ | |
688 g_print(_("Previous session ID")); | |
316
950f104f2e11
[svn] Fix spacing in --help output, patch by Mikachu.
chainsaw
parents:
284
diff
changeset
|
689 g_print("\n-H, --headless "); |
193 | 690 /* -h, --headless switch */ |
691 g_print(_("Headless operation [experimental]")); | |
0 | 692 g_print("\n-v, --version "); |
693 /* -v, --version switch */ | |
694 g_print(_("Print version number and exit\n")); | |
695 | |
696 exit(EXIT_SUCCESS); | |
697 } | |
698 | |
699 static void | |
700 parse_cmd_line(gint argc, | |
701 gchar ** argv, | |
702 BmpCmdLineOpt * options) | |
703 { | |
704 static struct option long_options[] = { | |
705 {"help", 0, NULL, 'h'}, | |
706 {"session", 1, NULL, 'n'}, | |
707 {"rew", 0, NULL, 'r'}, | |
708 {"play", 0, NULL, 'p'}, | |
709 {"pause", 0, NULL, 'u'}, | |
710 {"play-pause", 0, NULL, 't'}, | |
711 {"stop", 0, NULL, 's'}, | |
712 {"fwd", 0, NULL, 'f'}, | |
713 {"enqueue", 0, NULL, 'e'}, | |
714 {"show-main-window", 0, NULL, 'm'}, | |
715 {"activate", 0, NULL, 'a'}, | |
716 {"version", 0, NULL, 'v'}, | |
717 {"sm-client-id", 1, NULL, 'i'}, | |
718 {"xmms", 0, NULL, 'x'}, | |
191 | 719 {"headless", 0, NULL, 'H'}, |
0 | 720 {0, 0, 0, 0} |
721 }; | |
722 | |
723 gchar *filename, *current_dir; | |
724 gint c, i; | |
725 | |
726 memset(options, 0, sizeof(BmpCmdLineOpt)); | |
727 options->session = -1; | |
728 | |
191 | 729 while ((c = getopt_long(argc, argv, "chn:HrpusfemavtLS", long_options, |
0 | 730 NULL)) != -1) { |
731 switch (c) { | |
732 case 'h': | |
733 display_usage(); | |
734 break; | |
735 case 'n': | |
736 options->session = atoi(optarg); | |
737 break; | |
191 | 738 case 'H': |
739 options->headless = TRUE; | |
740 break; | |
0 | 741 case 'r': |
742 options->rew = TRUE; | |
743 break; | |
744 case 'p': | |
745 options->play = TRUE; | |
746 break; | |
747 case 'u': | |
748 options->pause = TRUE; | |
749 break; | |
750 case 's': | |
751 options->stop = TRUE; | |
752 break; | |
753 case 'f': | |
754 options->fwd = TRUE; | |
755 break; | |
756 case 't': | |
757 options->play_pause = TRUE; | |
758 break; | |
759 case 'm': | |
760 options->mainwin = TRUE; | |
761 break; | |
762 case 'a': | |
763 options->activate = TRUE; | |
764 break; | |
765 case 'e': | |
766 options->enqueue = TRUE; | |
767 break; | |
768 case 'v': | |
769 dump_version(); | |
770 exit(EXIT_SUCCESS); | |
771 break; | |
772 case 'i': | |
773 options->previous_session_id = g_strdup(optarg); | |
774 break; | |
775 case 'c': | |
776 options->playcd = TRUE; | |
777 break; | |
778 case 'S': | |
779 options->load_skins = TRUE; | |
780 break; | |
781 } | |
782 } | |
783 | |
784 current_dir = g_get_current_dir(); | |
785 | |
786 for (i = optind; i < argc; i++) { | |
787 if (argv[i][0] == '/' || strstr(argv[i], "://")) | |
788 filename = g_strdup(argv[i]); | |
789 else | |
790 filename = g_build_filename(current_dir, argv[i], NULL); | |
791 | |
792 options->filenames = g_list_prepend(options->filenames, filename); | |
793 } | |
794 | |
795 options->filenames = g_list_reverse(options->filenames); | |
796 | |
797 g_free(current_dir); | |
798 } | |
799 | |
800 static void | |
801 handle_cmd_line_options(BmpCmdLineOpt * options, | |
802 gboolean remote) | |
803 { | |
804 GList *filenames = options->filenames; | |
805 gint session = options->session; | |
806 | |
807 if (session == -1) { | |
808 if (!remote) | |
809 session = ctrlsocket_get_session_id(); | |
810 else | |
811 session = 0; | |
812 } | |
813 | |
814 if (filenames) { | |
815 gint pos = 0; | |
816 | |
817 if (options->load_skins) { | |
818 xmms_remote_set_skin(session, filenames->data); | |
819 skin_install_skin(filenames->data); | |
820 } | |
821 else { | |
822 if (options->enqueue && options->play) | |
823 pos = xmms_remote_get_playlist_length(session); | |
824 | |
825 if (!options->enqueue) | |
826 xmms_remote_playlist_clear(session); | |
827 | |
828 xmms_remote_playlist_add(session, filenames); | |
829 | |
830 if (options->enqueue && options->play && | |
831 xmms_remote_get_playlist_length(session) > pos) | |
832 xmms_remote_set_playlist_pos(session, pos); | |
833 | |
834 if (!options->enqueue) | |
835 xmms_remote_play(session); | |
836 } | |
837 | |
838 g_list_foreach(filenames, (GFunc) g_free, NULL); | |
839 g_list_free(filenames); | |
840 } | |
841 | |
842 if (options->rew) | |
843 xmms_remote_playlist_prev(session); | |
844 | |
845 if (options->play) | |
846 xmms_remote_play(session); | |
847 | |
848 if (options->pause) | |
849 xmms_remote_pause(session); | |
850 | |
851 if (options->stop) | |
852 xmms_remote_stop(session); | |
853 | |
854 if (options->fwd) | |
855 xmms_remote_playlist_next(session); | |
856 | |
857 if (options->play_pause) | |
858 xmms_remote_play_pause(session); | |
859 | |
860 if (options->mainwin) | |
861 xmms_remote_main_win_toggle(session, TRUE); | |
862 | |
863 if (options->activate) | |
864 xmms_remote_activate(session); | |
865 | |
866 if (options->playcd) | |
867 play_medium(); | |
868 } | |
869 | |
870 static void | |
871 segfault_handler(gint sig) | |
872 { | |
873 g_printerr(_("\nReceived SIGSEGV\n\n" | |
27
d160ae2251e9
[svn] Update SIGSEGV message, contained the BMP mailing information.
nenolod
parents:
0
diff
changeset
|
874 "This could be a bug in Audacious. If you don't know why this happened, " |
d160ae2251e9
[svn] Update SIGSEGV message, contained the BMP mailing information.
nenolod
parents:
0
diff
changeset
|
875 "file a bug at http://bugs.nenolod.net/\n\n")); |
0 | 876 #ifdef HANDLE_SIGSEGV |
877 exit(EXIT_FAILURE); | |
878 #else | |
879 abort(); | |
880 #endif | |
881 } | |
882 | |
883 static void | |
884 bmp_setup_logger(void) | |
885 { | |
886 if (!bmp_logger_start(bmp_paths[BMP_PATH_LOG_FILE])) | |
887 return; | |
888 | |
889 g_atexit(bmp_logger_stop); | |
890 } | |
891 | |
892 static void | |
893 run_load_skin_error_dialog(const gchar * skin_path) | |
894 { | |
895 const gchar *markup = | |
896 N_("<b><big>Unable to load skin.</big></b>\n" | |
897 "\n" | |
898 "Check that skin at '%s' is usable and default skin is properly " | |
899 "installed at '%s'\n"); | |
900 | |
901 GtkWidget *dialog = | |
902 gtk_message_dialog_new_with_markup(NULL, | |
903 GTK_DIALOG_MODAL, | |
904 GTK_MESSAGE_ERROR, | |
905 GTK_BUTTONS_CLOSE, | |
906 _(markup), | |
907 skin_path, | |
908 BMP_DEFAULT_SKIN_PATH); | |
909 gtk_dialog_run(GTK_DIALOG(dialog)); | |
910 gtk_widget_destroy(dialog); | |
911 } | |
912 | |
781
12c47704b4b5
[svn] Add error reporting for many places, patch by external contributor Derek
nenolod
parents:
749
diff
changeset
|
913 // use a format string? |
12c47704b4b5
[svn] Add error reporting for many places, patch by external contributor Derek
nenolod
parents:
749
diff
changeset
|
914 void report_error(const gchar *error_text) |
12c47704b4b5
[svn] Add error reporting for many places, patch by external contributor Derek
nenolod
parents:
749
diff
changeset
|
915 { |
12c47704b4b5
[svn] Add error reporting for many places, patch by external contributor Derek
nenolod
parents:
749
diff
changeset
|
916 fprintf(stderr,error_text); |
12c47704b4b5
[svn] Add error reporting for many places, patch by external contributor Derek
nenolod
parents:
749
diff
changeset
|
917 if (options.headless!=1) { |
813
c8cf439179b8
[svn] - Fix a ton and a half of memory leaks, via the wonderful Leonardo Boshell <leonardop -at- gentoo.org>.
nenolod
parents:
781
diff
changeset
|
918 gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(err), |
c8cf439179b8
[svn] - Fix a ton and a half of memory leaks, via the wonderful Leonardo Boshell <leonardop -at- gentoo.org>.
nenolod
parents:
781
diff
changeset
|
919 error_text); |
781
12c47704b4b5
[svn] Add error reporting for many places, patch by external contributor Derek
nenolod
parents:
749
diff
changeset
|
920 gtk_dialog_run(GTK_DIALOG(err)); |
813
c8cf439179b8
[svn] - Fix a ton and a half of memory leaks, via the wonderful Leonardo Boshell <leonardop -at- gentoo.org>.
nenolod
parents:
781
diff
changeset
|
921 gtk_widget_hide(err); |
781
12c47704b4b5
[svn] Add error reporting for many places, patch by external contributor Derek
nenolod
parents:
749
diff
changeset
|
922 } |
12c47704b4b5
[svn] Add error reporting for many places, patch by external contributor Derek
nenolod
parents:
749
diff
changeset
|
923 } |
12c47704b4b5
[svn] Add error reporting for many places, patch by external contributor Derek
nenolod
parents:
749
diff
changeset
|
924 |
0 | 925 gint |
926 main(gint argc, gchar ** argv) | |
927 { | |
44 | 928 gboolean gtk_init_check_ok; |
0 | 929 |
930 /* Setup l10n early so we can print localized error messages */ | |
931 gtk_set_locale(); | |
749 | 932 bindtextdomain(PACKAGE_NAME, LOCALEDIR); |
933 bind_textdomain_codeset(PACKAGE_NAME, "UTF-8"); | |
934 textdomain(PACKAGE_NAME); | |
0 | 935 |
936 bmp_init_paths(); | |
937 bmp_make_user_dir(); | |
938 bmp_setup_logger(); | |
939 | |
940 /* Check GTK version. Really, this is only needed for binary | |
941 * distribution since configure already checks. */ | |
680
8282b365f6cb
[svn] - Add some sanity checking to make sure we can't do X11 stuff when running headless.
nenolod
parents:
625
diff
changeset
|
942 if (!GTK_CHECK_VERSION(2, 6, 0)) { |
257
256b3acc87d4
[svn] Properly report Audacious instead of XMMS or BMP in all places. Patch by laci; closes bug #379.
chainsaw
parents:
216
diff
changeset
|
943 g_printerr(_("Sorry, your GTK+ version (%d.%d.%d) does not work with Audacious.\n" |
0 | 944 "Please use GTK+ %s or newer.\n"), |
945 gtk_major_version, gtk_minor_version, gtk_micro_version, | |
680
8282b365f6cb
[svn] - Add some sanity checking to make sure we can't do X11 stuff when running headless.
nenolod
parents:
625
diff
changeset
|
946 "2.6.0"); |
0 | 947 exit(EXIT_FAILURE); |
948 } | |
949 | |
950 g_set_application_name(_(application_name)); | |
951 | |
952 g_thread_init(NULL); | |
953 if (!g_thread_supported()) { | |
954 g_printerr(_("Sorry, threads isn't supported on your platform.\n\n" | |
955 "If you're on a libc5 based linux system and installed Glib & GTK+ before you\n" | |
956 "installed LinuxThreads you need to recompile Glib & GTK+.\n")); | |
957 exit(EXIT_FAILURE); | |
958 } | |
959 | |
960 gdk_threads_init(); | |
961 | |
44 | 962 gtk_init_check_ok = gtk_init_check(&argc, &argv); |
963 /* Now let's parse the command line options first. */ | |
964 parse_cmd_line(argc, argv, &options); | |
965 if (!gtk_init_check_ok) { | |
0 | 966 if (argc < 2) { |
967 /* GTK check failed, and no arguments passed to indicate | |
968 that user is intending to only remote control a running | |
969 session */ | |
44 | 970 g_printerr(_("audacious: Unable to open display, exiting.\n")); |
0 | 971 exit(EXIT_FAILURE); |
972 } | |
973 | |
974 handle_cmd_line_options(&options, TRUE); | |
191 | 975 |
976 /* we could be running headless, so GTK probably wont matter */ | |
977 if (options.headless != 1) | |
978 exit(EXIT_SUCCESS); | |
0 | 979 } |
980 | |
981 if (!vfs_init()) { | |
982 g_printerr(Q_("Could not initialize VFS.\n")); | |
983 exit(EXIT_FAILURE); | |
984 } | |
985 | |
986 signal(SIGPIPE, SIG_IGN); /* for controlsocket.c */ | |
987 signal(SIGSEGV, segfault_handler); | |
988 | |
989 g_random_set_seed(time(NULL)); | |
990 | |
991 bmp_config_load(); | |
992 | |
993 if (options.session != -1 || !ctrlsocket_setup()) { | |
994 handle_cmd_line_options(&options, TRUE); | |
995 exit(EXIT_SUCCESS); | |
996 } | |
997 | |
191 | 998 if (options.headless != 1) |
999 { | |
781
12c47704b4b5
[svn] Add error reporting for many places, patch by external contributor Derek
nenolod
parents:
749
diff
changeset
|
1000 |
191 | 1001 bmp_set_default_icon(); |
0 | 1002 |
191 | 1003 gtk_accel_map_load(bmp_paths[BMP_PATH_ACCEL_FILE]); |
0 | 1004 |
191 | 1005 mainwin_create(); |
781
12c47704b4b5
[svn] Add error reporting for many places, patch by external contributor Derek
nenolod
parents:
749
diff
changeset
|
1006 |
191 | 1007 playlistwin_create(); |
1008 equalizerwin_create(); | |
0 | 1009 |
191 | 1010 if (!init_skins(cfg.skin)) { |
1011 run_load_skin_error_dialog(cfg.skin); | |
1012 exit(EXIT_FAILURE); | |
1013 } | |
1014 | |
1015 GDK_THREADS_ENTER(); | |
0 | 1016 } |
1017 | |
1018 plugin_system_init(); | |
1019 | |
1020 playlist_load(bmp_paths[BMP_PATH_PLAYLIST_FILE]); | |
1021 playlist_set_position(cfg.playlist_position); | |
1022 | |
1023 /* this needs to be called after all 3 windows are created and | |
191 | 1024 * input plugins are setup'ed |
1025 * but not if we're running headless --nenolod | |
1026 */ | |
0 | 1027 mainwin_setup_menus(); |
1028 | |
191 | 1029 if (options.headless != 1) |
1030 GDK_THREADS_LEAVE(); | |
0 | 1031 |
1032 ctrlsocket_start(); | |
1033 | |
1034 handle_cmd_line_options(&options, FALSE); | |
1035 | |
191 | 1036 if (options.headless != 1) |
1037 { | |
1038 GDK_THREADS_ENTER(); | |
0 | 1039 |
191 | 1040 read_volume(VOLSET_STARTUP); |
1041 mainwin_set_info_text(); | |
1042 | |
1043 /* FIXME: delayed, because it deals directly with the plugin | |
1044 * interface to set menu items */ | |
1045 create_prefs_window(); | |
0 | 1046 |
191 | 1047 if (cfg.player_visible) |
1048 mainwin_show(TRUE); | |
1049 else if (!cfg.playlist_visible && !cfg.equalizer_visible) | |
1050 mainwin_show(TRUE); | |
125 | 1051 |
191 | 1052 if (cfg.equalizer_visible) |
1053 equalizerwin_show(TRUE); | |
1054 | |
1055 if (cfg.playlist_visible) | |
1056 playlistwin_show(); | |
0 | 1057 |
191 | 1058 hint_set_always(cfg.always_on_top); |
0 | 1059 |
191 | 1060 playlist_start_get_info_thread(); |
1061 mainwin_attach_idle_func(); | |
1062 | |
486 | 1063 starting_up = FALSE; |
1064 | |
680
8282b365f6cb
[svn] - Add some sanity checking to make sure we can't do X11 stuff when running headless.
nenolod
parents:
625
diff
changeset
|
1065 has_x11_connection = TRUE; |
8282b365f6cb
[svn] - Add some sanity checking to make sure we can't do X11 stuff when running headless.
nenolod
parents:
625
diff
changeset
|
1066 |
191 | 1067 gtk_main(); |
1068 | |
1069 GDK_THREADS_LEAVE(); | |
0 | 1070 |
191 | 1071 return EXIT_SUCCESS; |
1072 } | |
1073 else | |
1074 { | |
1075 mainwin_set_info_text(); | |
1076 playlist_start_get_info_thread(); | |
0 | 1077 |
486 | 1078 starting_up = FALSE; |
1079 | |
191 | 1080 for (;;) |
192
0ee0b9b6db7e
[svn] headless now working, use --headless if you wish to experiment.
nenolod
parents:
191
diff
changeset
|
1081 { |
197
ccd034857702
[svn] Split up generic events into audcore_generic_events(), and client-specific stuff remains in mainwin_idle_func().
nenolod
parents:
196
diff
changeset
|
1082 /* headless eventloop */ |
ccd034857702
[svn] Split up generic events into audcore_generic_events(), and client-specific stuff remains in mainwin_idle_func().
nenolod
parents:
196
diff
changeset
|
1083 audcore_generic_events(); |
198 | 1084 free_vis_data(); /* to prevent buffer overflow -- paranoia */ |
191 | 1085 xmms_usleep(10000); |
192
0ee0b9b6db7e
[svn] headless now working, use --headless if you wish to experiment.
nenolod
parents:
191
diff
changeset
|
1086 } |
0ee0b9b6db7e
[svn] headless now working, use --headless if you wish to experiment.
nenolod
parents:
191
diff
changeset
|
1087 |
191 | 1088 return EXIT_SUCCESS; |
1089 } | |
0 | 1090 } |