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