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