Mercurial > audlegacy
annotate audacious/main.c @ 976:4dfb85985fe0 trunk
[svn] - Let's not forget the year and track number!
author | nhjm449 |
---|---|
date | Wed, 26 Apr 2006 21:14:48 -0700 |
parents | 8cfe13fcd0c7 |
children | 8c6949ffd7f8 |
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 */ | |
946
8cfe13fcd0c7
[svn] - Forgot a few things regarding titlestrings!
nhjm449
parents:
943
diff
changeset
|
191 4, /* 5th preset (ARTIST [ ALBUM ] - TRACK. 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", | |
946
8cfe13fcd0c7
[svn] - Forgot a few things regarding titlestrings!
nhjm449
parents:
943
diff
changeset
|
219 "%{p:%p - %}%t", |
8cfe13fcd0c7
[svn] - Forgot a few things regarding titlestrings!
nhjm449
parents:
943
diff
changeset
|
220 "%{p:%p - %}%{a:%a - %}%t", |
943 | 221 "%{p:%p - %}%{a:%a - %}%{n:%n. %}%t", |
222 "%{p:%p %}%{a:[ %a ] %}%{p:- %}%{n:%n. %}%{t:%t%}", | |
946
8cfe13fcd0c7
[svn] - Forgot a few things regarding titlestrings!
nhjm449
parents:
943
diff
changeset
|
223 "%{a:%a - %}%t" |
0 | 224 }; |
225 | |
226 const guint n_titlestring_presets = G_N_ELEMENTS(bmp_titlestring_presets); | |
227 | |
228 static bmp_cfg_boolent bmp_boolents[] = { | |
229 {"allow_multiple_instances", &cfg.allow_multiple_instances, TRUE}, | |
230 {"use_realtime", &cfg.use_realtime, TRUE}, | |
231 {"always_show_cb", &cfg.always_show_cb, TRUE}, | |
232 {"convert_underscore", &cfg.convert_underscore, TRUE}, | |
233 {"convert_twenty", &cfg.convert_twenty, TRUE}, | |
234 {"show_numbers_in_pl", &cfg.show_numbers_in_pl, TRUE}, | |
235 {"snap_windows", &cfg.snap_windows, TRUE}, | |
236 {"save_window_positions", &cfg.save_window_position, TRUE}, | |
237 {"dim_titlebar", &cfg.dim_titlebar, TRUE}, | |
238 {"get_info_on_load", &cfg.get_info_on_load, TRUE}, | |
239 {"get_info_on_demand", &cfg.get_info_on_demand, TRUE}, | |
240 {"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
|
241 {"refresh_file_list", &cfg.refresh_file_list, TRUE}, |
0 | 242 {"sort_jump_to_file", &cfg.sort_jump_to_file, TRUE}, |
243 {"use_pl_metadata", &cfg.use_pl_metadata, TRUE}, | |
244 {"warn_about_unplayables", &cfg.warn_about_unplayables, TRUE}, | |
245 {"use_backslash_as_dir_delimiter", &cfg.use_backslash_as_dir_delimiter, TRUE}, | |
246 {"player_shaded", &cfg.player_shaded, TRUE}, | |
247 {"player_visible", &cfg.player_visible, TRUE}, | |
248 {"shuffle", &cfg.shuffle, TRUE}, | |
249 {"repeat", &cfg.repeat, TRUE}, | |
250 {"autoscroll_songname", &cfg.autoscroll, TRUE}, | |
898 | 251 {"stop_after_current_song", &cfg.stopaftersong, TRUE}, |
0 | 252 {"playlist_shaded", &cfg.playlist_shaded, TRUE}, |
253 {"playlist_visible", &cfg.playlist_visible, TRUE}, | |
254 {"playlist_transparent", &cfg.playlist_transparent, TRUE}, | |
255 {"use_fontsets", &cfg.use_fontsets, TRUE}, | |
85
8c8a20f72ace
[svn] s/static GTKItemFactoryEntry/GTKItemFactoryEntry/g.
nenolod
parents:
80
diff
changeset
|
256 {"mainwin_use_xfont", &cfg.mainwin_use_xfont, FALSE}, |
0 | 257 {"equalizer_visible", &cfg.equalizer_visible, TRUE}, |
258 {"equalizer_active", &cfg.equalizer_active, TRUE}, | |
259 {"equalizer_shaded", &cfg.equalizer_shaded, TRUE}, | |
260 {"equalizer_autoload", &cfg.equalizer_autoload, TRUE}, | |
261 {"use_eplugins", &cfg.use_eplugins, TRUE}, | |
262 {"always_on_top", &cfg.always_on_top, TRUE}, | |
263 {"sticky", &cfg.sticky, TRUE}, | |
264 {"random_skin_on_play", &cfg.random_skin_on_play, TRUE}, | |
265 {"pause_between_songs", &cfg.pause_between_songs, TRUE}, | |
266 {"show_wm_decorations", &cfg.show_wm_decorations, TRUE}, | |
267 {"eq_extra_filtering", &cfg.eq_extra_filtering, TRUE}, | |
268 {"analyzer_peaks", &cfg.analyzer_peaks, TRUE}, | |
269 {"custom_cursors", &cfg.custom_cursors, TRUE}, | |
270 {"close_dialog_open", &cfg.close_dialog_open, TRUE}, | |
271 {"close_dialog_add", &cfg.close_dialog_add, TRUE} | |
272 }; | |
273 | |
274 static gint ncfgbent = G_N_ELEMENTS(bmp_boolents); | |
275 | |
276 static bmp_cfg_nument bmp_numents[] = { | |
277 {"player_x", &cfg.player_x, TRUE}, | |
278 {"player_y", &cfg.player_y, TRUE}, | |
279 {"timer_mode", &cfg.timer_mode, TRUE}, | |
280 {"vis_type", &cfg.vis_type, TRUE}, | |
281 {"analyzer_mode", &cfg.analyzer_mode, TRUE}, | |
282 {"analyzer_type", &cfg.analyzer_type, TRUE}, | |
283 {"scope_mode", &cfg.scope_mode, TRUE}, | |
284 {"vu_mode", &cfg.vu_mode, TRUE}, | |
285 {"vis_refresh_rate", &cfg.vis_refresh, TRUE}, | |
286 {"analyzer_falloff", &cfg.analyzer_falloff, TRUE}, | |
287 {"peaks_falloff", &cfg.peaks_falloff, TRUE}, | |
288 {"playlist_x", &cfg.playlist_x, TRUE}, | |
289 {"playlist_y", &cfg.playlist_y, TRUE}, | |
290 {"playlist_width", &cfg.playlist_width, TRUE}, | |
291 {"playlist_height", &cfg.playlist_height, TRUE}, | |
292 {"playlist_position", &cfg.playlist_position, TRUE}, | |
293 {"equalizer_x", &cfg.equalizer_x, TRUE}, | |
294 {"equalizer_y", &cfg.equalizer_y, TRUE}, | |
295 {"snap_distance", &cfg.snap_distance, TRUE}, | |
296 {"pause_between_songs_time", &cfg.pause_between_songs_time, TRUE}, | |
297 {"mouse_wheel_change", &cfg.mouse_change, TRUE}, | |
298 {"scroll_pl_by", &cfg.scroll_pl_by, TRUE}, | |
299 {"titlestring_preset", &cfg.titlestring_preset, TRUE}, | |
300 }; | |
301 | |
302 static gint ncfgient = G_N_ELEMENTS(bmp_numents); | |
303 | |
304 static bmp_cfg_strent bmp_strents[] = { | |
305 {"playlist_font", &cfg.playlist_font, TRUE}, | |
306 {"mainwin_font", &cfg.mainwin_font, TRUE}, | |
307 {"eqpreset_default_file", &cfg.eqpreset_default_file, TRUE}, | |
308 {"eqpreset_extension", &cfg.eqpreset_extension, TRUE}, | |
309 {"skin", &cfg.skin, FALSE}, | |
310 {"output_plugin", &cfg.outputplugin, FALSE}, | |
311 {"disabled_iplugins", &cfg.disabled_iplugins, TRUE}, | |
312 {"enabled_gplugins", &cfg.enabled_gplugins, FALSE}, | |
313 {"enabled_vplugins", &cfg.enabled_vplugins, FALSE}, | |
314 {"enabled_eplugins", &cfg.enabled_eplugins, FALSE}, | |
315 {"filesel_path", &cfg.filesel_path, FALSE}, | |
316 {"playlist_path", &cfg.playlist_path, FALSE}, | |
317 {"generic_title_format", &cfg.gentitle_format, TRUE}, | |
318 }; | |
319 | |
320 static gint ncfgsent = G_N_ELEMENTS(bmp_strents); | |
321 | |
322 gchar *bmp_paths[BMP_PATH_COUNT] = {}; | |
323 | |
324 GList *dock_window_list = NULL; | |
325 | |
326 gboolean pposition_broken = FALSE; | |
327 | |
486 | 328 gboolean starting_up = TRUE; |
0 | 329 |
330 static GSList * | |
331 get_feature_list(void) | |
332 { | |
333 GSList *features = NULL; | |
334 | |
335 #ifdef HAVE_GNOME_VFS | |
336 features = g_slist_append(features, "GNOME VFS"); | |
337 #endif | |
338 | |
339 #ifdef HAVE_GCONF | |
340 features = g_slist_append(features, "GConf"); | |
341 #endif | |
342 | |
343 return features; | |
344 } | |
345 | |
346 static void | |
347 dump_version(void) | |
348 { | |
349 GSList *features; | |
350 | |
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
|
351 g_printf("%s %s [%s]", _(application_name), VERSION, svn_stamp); |
0 | 352 |
353 features = get_feature_list(); | |
354 | |
355 if (features) { | |
356 GSList *item; | |
357 | |
358 g_printf(" ("); | |
359 | |
360 for (item = features; g_slist_next(item); item = g_slist_next(item)) | |
361 g_printf("%s, ", (const gchar *) item->data); | |
362 | |
363 g_printf("%s)", (const gchar *) item->data); | |
364 | |
365 g_slist_free(features); | |
366 } | |
367 | |
368 g_printf("\n"); | |
369 } | |
370 | |
371 const gchar * | |
372 xmms_get_gentitle_format(void) | |
373 { | |
625
0a73d1faeb4e
[svn] GCC 4.1 warning fixes by Diego 'Flameeyes' Petteno from Gentoo.
chainsaw
parents:
538
diff
changeset
|
374 guint titlestring_preset = cfg.titlestring_preset; |
0 | 375 |
376 if (titlestring_preset < n_titlestring_presets) | |
377 return bmp_titlestring_presets[titlestring_preset]; | |
378 | |
379 return cfg.gentitle_format; | |
380 } | |
381 | |
887 | 382 void |
0 | 383 make_directory(const gchar * path, mode_t mode) |
384 { | |
385 if (mkdir(path, mode) == 0) | |
386 return; | |
387 | |
388 if (errno == EEXIST) | |
389 return; | |
390 | |
391 g_printerr(_("Could not create directory (%s): %s"), path, | |
392 g_strerror(errno)); | |
393 } | |
394 | |
395 static void | |
396 bmp_make_user_dir(void) | |
397 { | |
398 const mode_t mode755 = S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH; | |
399 | |
400 make_directory(bmp_paths[BMP_PATH_USER_DIR], mode755); | |
401 make_directory(bmp_paths[BMP_PATH_USER_PLUGIN_DIR], mode755); | |
402 make_directory(bmp_paths[BMP_PATH_USER_SKIN_DIR], mode755); | |
403 make_directory(bmp_paths[BMP_PATH_SKIN_THUMB_DIR], mode755); | |
404 } | |
405 | |
406 static void | |
407 bmp_free_paths(void) | |
408 { | |
409 int i; | |
410 | |
411 for (i = 0; i < BMP_PATH_COUNT; i++) | |
412 { | |
413 g_free(bmp_paths[i]); | |
414 bmp_paths[i] = 0; | |
415 } | |
416 } | |
417 | |
418 | |
419 #define USER_PATH(path) \ | |
420 g_build_filename(bmp_paths[BMP_PATH_USER_DIR], path, NULL); | |
421 | |
422 static void | |
423 bmp_init_paths(void) | |
424 { | |
734 | 425 bmp_paths[BMP_PATH_USER_DIR] = g_build_filename(g_get_home_dir(), BMP_RCPATH, NULL); |
0 | 426 |
427 bmp_paths[BMP_PATH_USER_PLUGIN_DIR] = USER_PATH(BMP_USER_PLUGIN_DIR_BASENAME); | |
428 bmp_paths[BMP_PATH_USER_SKIN_DIR] = USER_PATH(BMP_SKIN_DIR_BASENAME); | |
429 bmp_paths[BMP_PATH_SKIN_THUMB_DIR] = USER_PATH(BMP_SKIN_THUMB_DIR_BASENAME); | |
430 bmp_paths[BMP_PATH_CONFIG_FILE] = USER_PATH(BMP_CONFIG_BASENAME); | |
431 bmp_paths[BMP_PATH_PLAYLIST_FILE] = USER_PATH(BMP_PLAYLIST_BASENAME); | |
432 bmp_paths[BMP_PATH_ACCEL_FILE] = USER_PATH(BMP_ACCEL_BASENAME); | |
433 bmp_paths[BMP_PATH_LOG_FILE] = USER_PATH(BMP_LOG_BASENAME); | |
434 | |
435 g_atexit(bmp_free_paths); | |
436 } | |
437 | |
438 | |
439 void | |
440 bmp_config_load(void) | |
441 { | |
442 ConfigDb *db; | |
443 gint i, length; | |
444 | |
445 memcpy(&cfg, &bmp_default_config, sizeof(BmpConfig)); | |
446 | |
447 db = bmp_cfg_db_open(); | |
448 for (i = 0; i < ncfgbent; ++i) { | |
449 bmp_cfg_db_get_bool(db, NULL, | |
450 bmp_boolents[i].be_vname, | |
451 bmp_boolents[i].be_vloc); | |
452 } | |
453 | |
454 for (i = 0; i < ncfgient; ++i) { | |
455 bmp_cfg_db_get_int(db, NULL, | |
456 bmp_numents[i].ie_vname, | |
457 bmp_numents[i].ie_vloc); | |
458 } | |
459 | |
460 for (i = 0; i < ncfgsent; ++i) { | |
461 bmp_cfg_db_get_string(db, NULL, | |
462 bmp_strents[i].se_vname, | |
463 bmp_strents[i].se_vloc); | |
464 } | |
465 | |
466 /* Preset */ | |
467 bmp_cfg_db_get_float(db, NULL, "equalizer_preamp", &cfg.equalizer_preamp); | |
468 for (i = 0; i < 10; i++) { | |
469 gchar eqtext[18]; | |
470 | |
471 g_snprintf(eqtext, sizeof(eqtext), "equalizer_band%d", i); | |
472 bmp_cfg_db_get_float(db, NULL, eqtext, &cfg.equalizer_bands[i]); | |
473 } | |
474 | |
475 /* History */ | |
476 if (bmp_cfg_db_get_int(db, NULL, "url_history_length", &length)) { | |
477 for (i = 1; i <= length; i++) { | |
478 gchar str[19], *tmp; | |
479 | |
480 g_snprintf(str, sizeof(str), "url_history%d", i); | |
481 if (bmp_cfg_db_get_string(db, NULL, str, &tmp)) | |
482 cfg.url_history = g_list_append(cfg.url_history, tmp); | |
483 } | |
484 } | |
485 | |
486 bmp_cfg_db_close(db); | |
487 | |
488 | |
489 if (cfg.playlist_font && strlen(cfg.playlist_font) == 0) { | |
490 g_free(cfg.playlist_font); | |
491 cfg.playlist_font = NULL; | |
492 } | |
493 | |
494 if (cfg.mainwin_font && strlen(cfg.mainwin_font) == 0) { | |
495 g_free(cfg.mainwin_font); | |
496 cfg.mainwin_font = NULL; | |
497 } | |
498 | |
499 if (!cfg.playlist_font) | |
500 cfg.playlist_font = g_strdup(PLAYLISTWIN_DEFAULT_FONT); | |
501 | |
502 if (!cfg.mainwin_font) | |
503 cfg.mainwin_font = g_strdup(MAINWIN_DEFAULT_FONT); | |
504 | |
505 if (!cfg.gentitle_format) | |
943 | 506 cfg.gentitle_format = g_strdup("%{p:%p %}%{a:[ %a ] %}%{p:- %}%{n:%n. %}%{t:%t%}"); |
0 | 507 |
508 if (!cfg.outputplugin) { | |
509 #ifdef HAVE_OSS | |
510 cfg.outputplugin = g_build_filename(PLUGIN_DIR, plugin_dir_list[0], | |
511 PLUGIN_FILENAME("OSS"), NULL); | |
512 #else | |
513 /* FIXME: This implicitly means the output plugin that is | |
514 * first in the alphabet will be used (usually the disk writer | |
515 * plugin) */ | |
516 cfg.outputplugin = g_strdup(""); | |
517 #endif | |
518 } | |
519 | |
520 if (!cfg.eqpreset_default_file) | |
521 cfg.eqpreset_default_file = g_strdup(EQUALIZER_DEFAULT_DIR_PRESET); | |
522 | |
523 if (!cfg.eqpreset_extension) | |
524 cfg.eqpreset_extension = g_strdup(EQUALIZER_DEFAULT_PRESET_EXT); | |
525 } | |
526 | |
527 | |
528 void | |
529 bmp_config_save(void) | |
530 { | |
531 GList *node; | |
532 gchar *str; | |
533 gint i; | |
534 ConfigDb *db; | |
535 | |
536 cfg.disabled_iplugins = input_stringify_disabled_list(); | |
537 | |
538 | |
539 db = bmp_cfg_db_open(); | |
540 | |
541 for (i = 0; i < ncfgbent; ++i) | |
542 if (bmp_boolents[i].be_wrt) | |
543 bmp_cfg_db_set_bool(db, NULL, | |
544 bmp_boolents[i].be_vname, | |
545 *bmp_boolents[i].be_vloc); | |
546 | |
547 /* HACK: Work-around for bug #129 */ | |
80 | 548 /* |
0 | 549 bmp_cfg_db_set_bool(db, NULL, "playlist_shaded", |
550 FALSE); | |
80 | 551 */ |
0 | 552 for (i = 0; i < ncfgient; ++i) |
553 if (bmp_numents[i].ie_wrt) | |
554 bmp_cfg_db_set_int(db, NULL, | |
555 bmp_numents[i].ie_vname, | |
556 *bmp_numents[i].ie_vloc); | |
557 | |
558 /* This is a bit lame .. it'll end up being written twice, | |
559 * could do with being done a bit neater. -larne */ | |
560 bmp_cfg_db_set_int(db, NULL, "playlist_position", | |
561 playlist_get_position()); | |
562 | |
207
e152a92d3f45
[svn] Save the preference to enable or disable bitmap fonts.
nenolod
parents:
198
diff
changeset
|
563 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
|
564 cfg.mainwin_use_xfont); |
e152a92d3f45
[svn] Save the preference to enable or disable bitmap fonts.
nenolod
parents:
198
diff
changeset
|
565 |
0 | 566 for (i = 0; i < ncfgsent; ++i) { |
567 if (bmp_strents[i].se_wrt) | |
568 bmp_cfg_db_set_string(db, NULL, | |
569 bmp_strents[i].se_vname, | |
570 *bmp_strents[i].se_vloc); | |
571 } | |
572 | |
573 bmp_cfg_db_set_float(db, NULL, "equalizer_preamp", cfg.equalizer_preamp); | |
574 | |
575 for (i = 0; i < 10; i++) { | |
576 str = g_strdup_printf("equalizer_band%d", i); | |
577 bmp_cfg_db_set_float(db, NULL, str, cfg.equalizer_bands[i]); | |
578 g_free(str); | |
579 } | |
580 | |
196 | 581 if (bmp_active_skin != NULL) |
582 { | |
583 if (bmp_active_skin->path) | |
584 bmp_cfg_db_set_string(db, NULL, "skin", bmp_active_skin->path); | |
585 else | |
586 bmp_cfg_db_unset_key(db, NULL, "skin"); | |
587 } | |
0 | 588 |
589 if (get_current_output_plugin()) | |
590 bmp_cfg_db_set_string(db, NULL, "output_plugin", | |
591 get_current_output_plugin()->filename); | |
592 else | |
593 bmp_cfg_db_unset_key(db, NULL, "output_plugin"); | |
594 | |
595 str = general_stringify_enabled_list(); | |
596 if (str) { | |
597 bmp_cfg_db_set_string(db, NULL, "enabled_gplugins", str); | |
598 g_free(str); | |
599 } | |
600 else | |
601 bmp_cfg_db_unset_key(db, NULL, "enabled_gplugins"); | |
602 | |
603 str = vis_stringify_enabled_list(); | |
604 if (str) { | |
605 bmp_cfg_db_set_string(db, NULL, "enabled_vplugins", str); | |
606 g_free(str); | |
607 } | |
608 else | |
609 bmp_cfg_db_unset_key(db, NULL, "enabled_vplugins"); | |
610 | |
611 str = effect_stringify_enabled_list(); | |
612 if (str) { | |
613 bmp_cfg_db_set_string(db, NULL, "enabled_eplugins", str); | |
614 g_free(str); | |
615 } | |
616 else | |
617 bmp_cfg_db_unset_key(db, NULL, "enabled_eplugins"); | |
618 | |
619 if (cfg.filesel_path) | |
620 bmp_cfg_db_set_string(db, NULL, "filesel_path", cfg.filesel_path); | |
621 | |
622 if (cfg.playlist_path) | |
623 bmp_cfg_db_set_string(db, NULL, "playlist_path", cfg.playlist_path); | |
624 | |
625 bmp_cfg_db_set_int(db, NULL, "url_history_length", | |
626 g_list_length(cfg.url_history)); | |
627 | |
628 for (node = cfg.url_history, i = 1; node; node = g_list_next(node), i++) { | |
629 str = g_strdup_printf("url_history%d", i); | |
630 bmp_cfg_db_set_string(db, NULL, str, node->data); | |
631 g_free(str); | |
632 } | |
633 | |
634 bmp_cfg_db_close(db); | |
635 | |
636 playlist_save(bmp_paths[BMP_PATH_PLAYLIST_FILE], FALSE); | |
637 } | |
638 | |
639 static void | |
640 bmp_set_default_icon(void) | |
641 { | |
642 GdkPixbuf *icon; | |
643 | |
120 | 644 icon = gdk_pixbuf_new_from_xpm_data((const gchar **) audacious_player_xpm); |
0 | 645 gtk_window_set_default_icon(icon); |
646 g_object_unref(icon); | |
647 } | |
648 | |
649 static void | |
650 display_usage(void) | |
651 { | |
44 | 652 g_print(_("Usage: audacious [options] [files] ...\n\n" |
0 | 653 "Options:\n" |
654 "--------\n")); | |
655 g_print("\n-h, --help "); | |
656 /* -h, --help switch */ | |
657 g_print(_("Display this text and exit")); | |
658 g_print("\n-n, --session "); | |
659 /* -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
|
660 g_print(_("Select Audacious/BMP/XMMS session (Default: 0)")); |
0 | 661 g_print("\n-r, --rew "); |
662 /* -r, --rew switch */ | |
663 g_print(_("Skip backwards in playlist")); | |
664 g_print("\n-p, --play "); | |
665 /* -p, --play switch */ | |
666 g_print(_("Start playing current playlist")); | |
667 g_print("\n-u, --pause "); | |
668 /* -u, --pause switch */ | |
669 g_print(_("Pause current song")); | |
670 g_print("\n-s, --stop "); | |
671 /* -s, --stop switch */ | |
672 g_print(_("Stop current song")); | |
673 g_print("\n-t, --play-pause "); | |
674 /* -t, --play-pause switch */ | |
675 g_print(_("Pause if playing, play otherwise")); | |
676 g_print("\n-f, --fwd "); | |
677 /* -f, --fwd switch */ | |
678 g_print(_("Skip forward in playlist")); | |
679 g_print("\n-e, --enqueue "); | |
680 /* -e, --enqueue switch */ | |
681 g_print(_("Don't clear the playlist")); | |
682 g_print("\n-m, --show-main-window "); | |
683 /* -m, --show-main-window switch */ | |
684 g_print(_("Show the main window")); | |
685 g_print("\n-a, --activate "); | |
686 /* -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
|
687 g_print(_("Activate Audacious")); |
0 | 688 g_print("\n-i, --sm-client-id "); |
689 /* -i, --sm-client-id switch */ | |
690 g_print(_("Previous session ID")); | |
316
950f104f2e11
[svn] Fix spacing in --help output, patch by Mikachu.
chainsaw
parents:
284
diff
changeset
|
691 g_print("\n-H, --headless "); |
193 | 692 /* -h, --headless switch */ |
693 g_print(_("Headless operation [experimental]")); | |
0 | 694 g_print("\n-v, --version "); |
695 /* -v, --version switch */ | |
696 g_print(_("Print version number and exit\n")); | |
697 | |
698 exit(EXIT_SUCCESS); | |
699 } | |
700 | |
701 static void | |
702 parse_cmd_line(gint argc, | |
703 gchar ** argv, | |
704 BmpCmdLineOpt * options) | |
705 { | |
706 static struct option long_options[] = { | |
707 {"help", 0, NULL, 'h'}, | |
708 {"session", 1, NULL, 'n'}, | |
709 {"rew", 0, NULL, 'r'}, | |
710 {"play", 0, NULL, 'p'}, | |
711 {"pause", 0, NULL, 'u'}, | |
712 {"play-pause", 0, NULL, 't'}, | |
713 {"stop", 0, NULL, 's'}, | |
714 {"fwd", 0, NULL, 'f'}, | |
715 {"enqueue", 0, NULL, 'e'}, | |
716 {"show-main-window", 0, NULL, 'm'}, | |
717 {"activate", 0, NULL, 'a'}, | |
718 {"version", 0, NULL, 'v'}, | |
719 {"sm-client-id", 1, NULL, 'i'}, | |
720 {"xmms", 0, NULL, 'x'}, | |
191 | 721 {"headless", 0, NULL, 'H'}, |
0 | 722 {0, 0, 0, 0} |
723 }; | |
724 | |
725 gchar *filename, *current_dir; | |
726 gint c, i; | |
727 | |
728 memset(options, 0, sizeof(BmpCmdLineOpt)); | |
729 options->session = -1; | |
730 | |
191 | 731 while ((c = getopt_long(argc, argv, "chn:HrpusfemavtLS", long_options, |
0 | 732 NULL)) != -1) { |
733 switch (c) { | |
734 case 'h': | |
735 display_usage(); | |
736 break; | |
737 case 'n': | |
738 options->session = atoi(optarg); | |
739 break; | |
191 | 740 case 'H': |
741 options->headless = TRUE; | |
742 break; | |
0 | 743 case 'r': |
744 options->rew = TRUE; | |
745 break; | |
746 case 'p': | |
747 options->play = TRUE; | |
748 break; | |
749 case 'u': | |
750 options->pause = TRUE; | |
751 break; | |
752 case 's': | |
753 options->stop = TRUE; | |
754 break; | |
755 case 'f': | |
756 options->fwd = TRUE; | |
757 break; | |
758 case 't': | |
759 options->play_pause = TRUE; | |
760 break; | |
761 case 'm': | |
762 options->mainwin = TRUE; | |
763 break; | |
764 case 'a': | |
765 options->activate = TRUE; | |
766 break; | |
767 case 'e': | |
768 options->enqueue = TRUE; | |
769 break; | |
770 case 'v': | |
771 dump_version(); | |
772 exit(EXIT_SUCCESS); | |
773 break; | |
774 case 'i': | |
775 options->previous_session_id = g_strdup(optarg); | |
776 break; | |
777 case 'c': | |
778 options->playcd = TRUE; | |
779 break; | |
780 case 'S': | |
781 options->load_skins = TRUE; | |
782 break; | |
783 } | |
784 } | |
785 | |
786 current_dir = g_get_current_dir(); | |
787 | |
788 for (i = optind; i < argc; i++) { | |
789 if (argv[i][0] == '/' || strstr(argv[i], "://")) | |
790 filename = g_strdup(argv[i]); | |
791 else | |
792 filename = g_build_filename(current_dir, argv[i], NULL); | |
793 | |
794 options->filenames = g_list_prepend(options->filenames, filename); | |
795 } | |
796 | |
797 options->filenames = g_list_reverse(options->filenames); | |
798 | |
799 g_free(current_dir); | |
800 } | |
801 | |
802 static void | |
803 handle_cmd_line_options(BmpCmdLineOpt * options, | |
804 gboolean remote) | |
805 { | |
806 GList *filenames = options->filenames; | |
807 gint session = options->session; | |
808 | |
809 if (session == -1) { | |
810 if (!remote) | |
811 session = ctrlsocket_get_session_id(); | |
812 else | |
813 session = 0; | |
814 } | |
815 | |
816 if (filenames) { | |
817 gint pos = 0; | |
818 | |
819 if (options->load_skins) { | |
820 xmms_remote_set_skin(session, filenames->data); | |
821 skin_install_skin(filenames->data); | |
822 } | |
823 else { | |
824 if (options->enqueue && options->play) | |
825 pos = xmms_remote_get_playlist_length(session); | |
826 | |
827 if (!options->enqueue) | |
828 xmms_remote_playlist_clear(session); | |
829 | |
830 xmms_remote_playlist_add(session, filenames); | |
831 | |
832 if (options->enqueue && options->play && | |
833 xmms_remote_get_playlist_length(session) > pos) | |
834 xmms_remote_set_playlist_pos(session, pos); | |
835 | |
836 if (!options->enqueue) | |
837 xmms_remote_play(session); | |
838 } | |
839 | |
840 g_list_foreach(filenames, (GFunc) g_free, NULL); | |
841 g_list_free(filenames); | |
842 } | |
843 | |
844 if (options->rew) | |
845 xmms_remote_playlist_prev(session); | |
846 | |
847 if (options->play) | |
848 xmms_remote_play(session); | |
849 | |
850 if (options->pause) | |
851 xmms_remote_pause(session); | |
852 | |
853 if (options->stop) | |
854 xmms_remote_stop(session); | |
855 | |
856 if (options->fwd) | |
857 xmms_remote_playlist_next(session); | |
858 | |
859 if (options->play_pause) | |
860 xmms_remote_play_pause(session); | |
861 | |
862 if (options->mainwin) | |
863 xmms_remote_main_win_toggle(session, TRUE); | |
864 | |
865 if (options->activate) | |
866 xmms_remote_activate(session); | |
867 | |
868 if (options->playcd) | |
869 play_medium(); | |
870 } | |
871 | |
872 static void | |
873 segfault_handler(gint sig) | |
874 { | |
875 g_printerr(_("\nReceived SIGSEGV\n\n" | |
27
d160ae2251e9
[svn] Update SIGSEGV message, contained the BMP mailing information.
nenolod
parents:
0
diff
changeset
|
876 "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
|
877 "file a bug at http://bugs.nenolod.net/\n\n")); |
0 | 878 #ifdef HANDLE_SIGSEGV |
879 exit(EXIT_FAILURE); | |
880 #else | |
881 abort(); | |
882 #endif | |
883 } | |
884 | |
885 static void | |
886 bmp_setup_logger(void) | |
887 { | |
888 if (!bmp_logger_start(bmp_paths[BMP_PATH_LOG_FILE])) | |
889 return; | |
890 | |
891 g_atexit(bmp_logger_stop); | |
892 } | |
893 | |
894 static void | |
895 run_load_skin_error_dialog(const gchar * skin_path) | |
896 { | |
897 const gchar *markup = | |
898 N_("<b><big>Unable to load skin.</big></b>\n" | |
899 "\n" | |
900 "Check that skin at '%s' is usable and default skin is properly " | |
901 "installed at '%s'\n"); | |
902 | |
903 GtkWidget *dialog = | |
904 gtk_message_dialog_new_with_markup(NULL, | |
905 GTK_DIALOG_MODAL, | |
906 GTK_MESSAGE_ERROR, | |
907 GTK_BUTTONS_CLOSE, | |
908 _(markup), | |
909 skin_path, | |
910 BMP_DEFAULT_SKIN_PATH); | |
911 gtk_dialog_run(GTK_DIALOG(dialog)); | |
912 gtk_widget_destroy(dialog); | |
913 } | |
914 | |
781
12c47704b4b5
[svn] Add error reporting for many places, patch by external contributor Derek
nenolod
parents:
749
diff
changeset
|
915 // use a format string? |
12c47704b4b5
[svn] Add error reporting for many places, patch by external contributor Derek
nenolod
parents:
749
diff
changeset
|
916 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
|
917 { |
12c47704b4b5
[svn] Add error reporting for many places, patch by external contributor Derek
nenolod
parents:
749
diff
changeset
|
918 fprintf(stderr,error_text); |
12c47704b4b5
[svn] Add error reporting for many places, patch by external contributor Derek
nenolod
parents:
749
diff
changeset
|
919 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
|
920 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
|
921 error_text); |
781
12c47704b4b5
[svn] Add error reporting for many places, patch by external contributor Derek
nenolod
parents:
749
diff
changeset
|
922 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
|
923 gtk_widget_hide(err); |
781
12c47704b4b5
[svn] Add error reporting for many places, patch by external contributor Derek
nenolod
parents:
749
diff
changeset
|
924 } |
12c47704b4b5
[svn] Add error reporting for many places, patch by external contributor Derek
nenolod
parents:
749
diff
changeset
|
925 } |
12c47704b4b5
[svn] Add error reporting for many places, patch by external contributor Derek
nenolod
parents:
749
diff
changeset
|
926 |
0 | 927 gint |
928 main(gint argc, gchar ** argv) | |
929 { | |
44 | 930 gboolean gtk_init_check_ok; |
0 | 931 |
932 /* Setup l10n early so we can print localized error messages */ | |
933 gtk_set_locale(); | |
749 | 934 bindtextdomain(PACKAGE_NAME, LOCALEDIR); |
935 bind_textdomain_codeset(PACKAGE_NAME, "UTF-8"); | |
936 textdomain(PACKAGE_NAME); | |
0 | 937 |
938 bmp_init_paths(); | |
939 bmp_make_user_dir(); | |
940 bmp_setup_logger(); | |
941 | |
942 /* Check GTK version. Really, this is only needed for binary | |
943 * 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
|
944 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
|
945 g_printerr(_("Sorry, your GTK+ version (%d.%d.%d) does not work with Audacious.\n" |
0 | 946 "Please use GTK+ %s or newer.\n"), |
947 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
|
948 "2.6.0"); |
0 | 949 exit(EXIT_FAILURE); |
950 } | |
951 | |
952 g_set_application_name(_(application_name)); | |
953 | |
954 g_thread_init(NULL); | |
955 if (!g_thread_supported()) { | |
956 g_printerr(_("Sorry, threads isn't supported on your platform.\n\n" | |
957 "If you're on a libc5 based linux system and installed Glib & GTK+ before you\n" | |
958 "installed LinuxThreads you need to recompile Glib & GTK+.\n")); | |
959 exit(EXIT_FAILURE); | |
960 } | |
961 | |
962 gdk_threads_init(); | |
963 | |
44 | 964 gtk_init_check_ok = gtk_init_check(&argc, &argv); |
965 /* Now let's parse the command line options first. */ | |
966 parse_cmd_line(argc, argv, &options); | |
967 if (!gtk_init_check_ok) { | |
0 | 968 if (argc < 2) { |
969 /* GTK check failed, and no arguments passed to indicate | |
970 that user is intending to only remote control a running | |
971 session */ | |
44 | 972 g_printerr(_("audacious: Unable to open display, exiting.\n")); |
0 | 973 exit(EXIT_FAILURE); |
974 } | |
975 | |
976 handle_cmd_line_options(&options, TRUE); | |
191 | 977 |
978 /* we could be running headless, so GTK probably wont matter */ | |
979 if (options.headless != 1) | |
980 exit(EXIT_SUCCESS); | |
0 | 981 } |
982 | |
983 if (!vfs_init()) { | |
984 g_printerr(Q_("Could not initialize VFS.\n")); | |
985 exit(EXIT_FAILURE); | |
986 } | |
987 | |
988 signal(SIGPIPE, SIG_IGN); /* for controlsocket.c */ | |
989 signal(SIGSEGV, segfault_handler); | |
990 | |
991 g_random_set_seed(time(NULL)); | |
992 | |
993 bmp_config_load(); | |
994 | |
995 if (options.session != -1 || !ctrlsocket_setup()) { | |
996 handle_cmd_line_options(&options, TRUE); | |
997 exit(EXIT_SUCCESS); | |
998 } | |
999 | |
191 | 1000 if (options.headless != 1) |
1001 { | |
781
12c47704b4b5
[svn] Add error reporting for many places, patch by external contributor Derek
nenolod
parents:
749
diff
changeset
|
1002 |
191 | 1003 bmp_set_default_icon(); |
0 | 1004 |
191 | 1005 gtk_accel_map_load(bmp_paths[BMP_PATH_ACCEL_FILE]); |
0 | 1006 |
191 | 1007 mainwin_create(); |
781
12c47704b4b5
[svn] Add error reporting for many places, patch by external contributor Derek
nenolod
parents:
749
diff
changeset
|
1008 |
191 | 1009 playlistwin_create(); |
1010 equalizerwin_create(); | |
0 | 1011 |
191 | 1012 if (!init_skins(cfg.skin)) { |
1013 run_load_skin_error_dialog(cfg.skin); | |
1014 exit(EXIT_FAILURE); | |
1015 } | |
1016 | |
1017 GDK_THREADS_ENTER(); | |
0 | 1018 } |
1019 | |
1020 plugin_system_init(); | |
1021 | |
1022 playlist_load(bmp_paths[BMP_PATH_PLAYLIST_FILE]); | |
1023 playlist_set_position(cfg.playlist_position); | |
1024 | |
1025 /* this needs to be called after all 3 windows are created and | |
191 | 1026 * input plugins are setup'ed |
1027 * but not if we're running headless --nenolod | |
1028 */ | |
0 | 1029 mainwin_setup_menus(); |
1030 | |
191 | 1031 if (options.headless != 1) |
1032 GDK_THREADS_LEAVE(); | |
0 | 1033 |
1034 ctrlsocket_start(); | |
1035 | |
1036 handle_cmd_line_options(&options, FALSE); | |
1037 | |
191 | 1038 if (options.headless != 1) |
1039 { | |
1040 GDK_THREADS_ENTER(); | |
0 | 1041 |
191 | 1042 read_volume(VOLSET_STARTUP); |
1043 mainwin_set_info_text(); | |
1044 | |
1045 /* FIXME: delayed, because it deals directly with the plugin | |
1046 * interface to set menu items */ | |
1047 create_prefs_window(); | |
0 | 1048 |
191 | 1049 if (cfg.player_visible) |
1050 mainwin_show(TRUE); | |
1051 else if (!cfg.playlist_visible && !cfg.equalizer_visible) | |
1052 mainwin_show(TRUE); | |
125 | 1053 |
191 | 1054 if (cfg.equalizer_visible) |
1055 equalizerwin_show(TRUE); | |
1056 | |
1057 if (cfg.playlist_visible) | |
1058 playlistwin_show(); | |
0 | 1059 |
191 | 1060 hint_set_always(cfg.always_on_top); |
0 | 1061 |
191 | 1062 playlist_start_get_info_thread(); |
1063 mainwin_attach_idle_func(); | |
1064 | |
486 | 1065 starting_up = FALSE; |
1066 | |
680
8282b365f6cb
[svn] - Add some sanity checking to make sure we can't do X11 stuff when running headless.
nenolod
parents:
625
diff
changeset
|
1067 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
|
1068 |
191 | 1069 gtk_main(); |
1070 | |
1071 GDK_THREADS_LEAVE(); | |
0 | 1072 |
191 | 1073 return EXIT_SUCCESS; |
1074 } | |
1075 else | |
1076 { | |
1077 mainwin_set_info_text(); | |
1078 playlist_start_get_info_thread(); | |
0 | 1079 |
486 | 1080 starting_up = FALSE; |
1081 | |
191 | 1082 for (;;) |
192
0ee0b9b6db7e
[svn] headless now working, use --headless if you wish to experiment.
nenolod
parents:
191
diff
changeset
|
1083 { |
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
|
1084 /* 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
|
1085 audcore_generic_events(); |
198 | 1086 free_vis_data(); /* to prevent buffer overflow -- paranoia */ |
191 | 1087 xmms_usleep(10000); |
192
0ee0b9b6db7e
[svn] headless now working, use --headless if you wish to experiment.
nenolod
parents:
191
diff
changeset
|
1088 } |
0ee0b9b6db7e
[svn] headless now working, use --headless if you wish to experiment.
nenolod
parents:
191
diff
changeset
|
1089 |
191 | 1090 return EXIT_SUCCESS; |
1091 } | |
0 | 1092 } |