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