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