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