Mercurial > audlegacy
annotate src/audacious/main.c @ 3229:5e12e740c66c trunk
default value for "enabled discovery plugins" was missing.
author | Yoshiki Yazawa <yaz@cc.rim.or.jp> |
---|---|
date | Fri, 03 Aug 2007 22:28:18 +0900 |
parents | e91acf24afbc |
children | f02623377013 |
rev | line source |
---|---|
2313 | 1 /* Audacious - Cross-platform multimedia player |
2 * Copyright (C) 2005-2007 Audacious development team. | |
3 * | |
4 * Based on BMP: | |
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 | |
3121
3b6d316f8b09
GPL3 relicensing.
William Pitcock <nenolod@atheme-project.org>
parents:
2973
diff
changeset
|
12 * the Free Software Foundation; under version 3 of the License. |
2313 | 13 * |
14 * This program is distributed in the hope that it will be useful, | |
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 * GNU General Public License for more details. | |
18 * | |
19 * You should have received a copy of the GNU General Public License | |
3121
3b6d316f8b09
GPL3 relicensing.
William Pitcock <nenolod@atheme-project.org>
parents:
2973
diff
changeset
|
20 * along with this program. If not, see <http://www.gnu.org/licenses>. |
3123
f1c756f39e6c
Invoke "Plugins are not derived work" clause provided by GPL3.
William Pitcock <nenolod@atheme-project.org>
parents:
3121
diff
changeset
|
21 * |
f1c756f39e6c
Invoke "Plugins are not derived work" clause provided by GPL3.
William Pitcock <nenolod@atheme-project.org>
parents:
3121
diff
changeset
|
22 * The Audacious team does not consider modular code linking to |
f1c756f39e6c
Invoke "Plugins are not derived work" clause provided by GPL3.
William Pitcock <nenolod@atheme-project.org>
parents:
3121
diff
changeset
|
23 * Audacious or using our public API to be a derived work. |
2313 | 24 */ |
25 | |
26 #ifdef HAVE_CONFIG_H | |
27 # include "config.h" | |
28 #endif | |
29 | |
30 #include "main.h" | |
31 | |
32 #include <glib.h> | |
33 #include <glib/gi18n.h> | |
34 #include <glib/gprintf.h> | |
35 #include <gdk/gdk.h> | |
36 #include <stdlib.h> | |
37 #include <string.h> | |
38 #include <getopt.h> | |
39 #include <ctype.h> | |
40 #include <time.h> | |
41 | |
42 #include <unistd.h> | |
43 #include <errno.h> | |
44 #include <sys/types.h> | |
45 #include <sys/stat.h> | |
46 #include <signal.h> | |
47 | |
48 #include "platform/smartinclude.h" | |
49 | |
2717 | 50 #include "configdb.h" |
2313 | 51 #include "vfs.h" |
52 | |
2694
c2b82432c1b6
[svn] Added basic DBus support, disabled by default with a configuration option to enable it. The general and playback information/manipulation methods are currently the only ones implemented. That is version, play, pause, stop, playing, paused, stopped, status, and seek. There are stubs for many unimplemented methods.
magma
parents:
2682
diff
changeset
|
53 #ifdef USE_DBUS |
2711
c35913222440
[svn] Initial commit of dbus client library for plugins. Various changes were made to the plugin structure to support dbus.
magma
parents:
2709
diff
changeset
|
54 # include "dbus-service.h" |
2785 | 55 # include "audctrl.h" |
2694
c2b82432c1b6
[svn] Added basic DBus support, disabled by default with a configuration option to enable it. The general and playback information/manipulation methods are currently the only ones implemented. That is version, play, pause, stop, playing, paused, stopped, status, and seek. There are stubs for many unimplemented methods.
magma
parents:
2682
diff
changeset
|
56 #endif |
c2b82432c1b6
[svn] Added basic DBus support, disabled by default with a configuration option to enable it. The general and playback information/manipulation methods are currently the only ones implemented. That is version, play, pause, stop, playing, paused, stopped, status, and seek. There are stubs for many unimplemented methods.
magma
parents:
2682
diff
changeset
|
57 |
2845
a124656d4423
added handlers for cmd line args when remote == false
Ben Tucker <ben.tucker@gmail.com>
parents:
2838
diff
changeset
|
58 #include "auddrct.h" |
2313 | 59 #include "dnd.h" |
60 #include "effect.h" | |
61 #include "ui_equalizer.h" | |
62 #include "general.h" | |
63 #include "hints.h" | |
64 #include "input.h" | |
65 #include "logger.h" | |
66 #include "ui_main.h" | |
67 #include "ui_manager.h" | |
68 #include "output.h" | |
69 #include "playback.h" | |
70 #include "playlist.h" | |
71 #include "ui_playlist.h" | |
72 #include "ui_preferences.h" | |
73 #include "pluginenum.h" | |
74 #include "ui_skinselector.h" | |
75 #include "util.h" | |
76 #include "visualization.h" | |
77 #include "build_stamp.h" | |
78 #include "ui_fileinfo.h" | |
79 #include "signals.h" | |
2530 | 80 #include "ui_skinned_window.h" |
2313 | 81 |
82 #include "icons-csource.h" | |
83 #include "icons-stock.h" | |
84 #include "images/audacious_player.xpm" | |
85 | |
2364 | 86 gboolean has_x11_connection = FALSE; /* do we have an X11 connection? */ |
2313 | 87 |
88 /* Translatable string for beep.desktop's comment field */ | |
89 const gchar *desktop_comment = N_("Audacious"); | |
90 | |
91 const gchar *application_name = N_("Audacious"); | |
92 | |
93 | |
94 struct _BmpCmdLineOpt { | |
2411 | 95 gchar **filenames; |
2313 | 96 gint session; |
97 gboolean play, stop, pause, fwd, rew, play_pause, playcd, show_jump_box; | |
98 gboolean enqueue, mainwin, remote, activate; | |
99 gboolean load_skins; | |
100 gboolean headless; | |
101 gboolean no_log; | |
102 gboolean enqueue_to_temp; | |
2411 | 103 gboolean version; |
2313 | 104 gchar *previous_session_id; |
105 }; | |
106 | |
107 typedef struct _BmpCmdLineOpt BmpCmdLineOpt; | |
108 | |
109 BmpCmdLineOpt options; | |
110 | |
111 BmpConfig cfg; | |
112 | |
113 BmpConfig bmp_default_config = { | |
114 MAINWIN_DEFAULT_POS_X, /* mainwin x position */ | |
115 MAINWIN_DEFAULT_POS_Y, /* mainwin y position */ | |
116 EQUALIZER_DEFAULT_POS_X, /* equalizer x position */ | |
117 EQUALIZER_DEFAULT_POS_Y, /* equalizer y position */ | |
118 PLAYLISTWIN_DEFAULT_POS_X, /* playlistwin x position */ | |
119 PLAYLISTWIN_DEFAULT_POS_Y, /* playlistwin y position */ | |
120 PLAYLISTWIN_DEFAULT_WIDTH, /* playlistwin width */ | |
121 PLAYLISTWIN_DEFAULT_HEIGHT, /* playlistwin height */ | |
122 10, /* snap distance */ | |
123 FALSE, /* real-time priority */ | |
124 FALSE, FALSE, /* shuffle, repeat */ | |
125 FALSE, /* UNUSED (double size) */ | |
126 TRUE, /* autoscroll */ | |
127 TRUE, /* analyzer peaks */ | |
128 FALSE, /* equalizer autoload */ | |
129 FALSE, /* easy move */ | |
130 FALSE, /* equalizer active */ | |
131 FALSE, /* playlistwin visible */ | |
132 FALSE, /* equalizer visible */ | |
133 TRUE, /* player visible */ | |
134 FALSE, /* player shaded */ | |
135 FALSE, /* playlistwin shaded */ | |
136 FALSE, /* equalizer shaded */ | |
137 FALSE, /* allow multiple instances */ | |
138 TRUE, /* always show cb */ | |
139 TRUE, TRUE, TRUE, /* convert '_', %20 and '\' */ | |
140 TRUE, /* show numbers in playlist */ | |
141 TRUE, /* snap windows */ | |
142 TRUE, /* save window positions */ | |
143 TRUE, /* dim titlebar */ | |
144 FALSE, /* get playlist info on load */ | |
145 TRUE, /* get playlist info on demand */ | |
146 TRUE, /* UNUSED (equalizer doublesize linked) */ | |
147 FALSE, /* sort jump to file */ | |
148 FALSE, /* use effect plugins */ | |
149 FALSE, /* always on top */ | |
150 FALSE, /* sticky */ | |
151 FALSE, /* no playlist advance */ | |
152 FALSE, /* stop after current song */ | |
153 TRUE, /* refresh file list */ | |
154 TRUE, /* UNUSED (smooth title scrolling) */ | |
155 TRUE, /* use playlist metadata */ | |
2662
09b404d61ebd
[svn] - remove the unplayable files dialog. it is more annoying than useful.
nenolod
parents:
2651
diff
changeset
|
156 TRUE, /* deprecated */ |
2651
4d5e6a8717dd
[svn] - allow the player to start with all of its windows hidden (but give a warning to the user, whose display can be disabled); also, try to remember player windows positions when they stay hidden between sessions
giacomo
parents:
2644
diff
changeset
|
157 TRUE, /* warn about windows visibility */ |
2313 | 158 FALSE, /* use \ as directory delimiter */ |
159 FALSE, /* random skin on play */ | |
160 FALSE, /* use fontsets */ | |
161 FALSE, /* use X font for mainwin */ | |
2364 | 162 TRUE, /* use custom cursors */ |
163 TRUE, /* close dialog on open */ | |
164 TRUE, /* close dialog on add */ | |
2313 | 165 0.0, /* equalizer preamp */ |
3229
5e12e740c66c
default value for "enabled discovery plugins" was missing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3216
diff
changeset
|
166 {0.0, 0.0, 0.0, 0.0, 0.0, /* equalizer bands */ |
5e12e740c66c
default value for "enabled discovery plugins" was missing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3216
diff
changeset
|
167 0.0, 0.0, 0.0, 0.0, 0.0}, |
2313 | 168 NULL, /* skin */ |
169 NULL, /* output plugin */ | |
170 NULL, /* file selector path */ | |
171 NULL, /* playlist path */ | |
172 NULL, /* playlist font */ | |
173 NULL, /* mainwin font */ | |
174 NULL, /* disabled input plugins */ | |
175 NULL, /* enabled general plugins */ | |
176 NULL, /* enabled visualization plugins */ | |
177 NULL, /* enabled effect plugins */ | |
3229
5e12e740c66c
default value for "enabled discovery plugins" was missing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3216
diff
changeset
|
178 NULL, /* enabled discovery plugins */ |
2313 | 179 NULL, /* equalizer preset default file */ |
180 NULL, /* equalizer preset extension */ | |
181 NULL, /* URL history */ | |
182 0, /* timer mode */ | |
183 VIS_ANALYZER, /* visualizer type */ | |
184 ANALYZER_NORMAL, /* analyzer mode */ | |
185 ANALYZER_BARS, /* analyzer type */ | |
186 SCOPE_DOT, /* scope mode */ | |
187 VOICEPRINT_NORMAL, /* voiceprint mode */ | |
188 VU_SMOOTH, /* VU mode */ | |
189 REFRESH_FULL, /* visualizer refresh rate */ | |
190 FALLOFF_FAST, /* analyzer fall off rate */ | |
191 FALLOFF_SLOW, /* peaks fall off rate */ | |
192 0, /* playlist position */ | |
193 2, /* pause between songs time */ | |
194 FALSE, /* pause between songs */ | |
195 FALSE, /* show window decorations */ | |
196 8, /* mouse wheel scroll step */ | |
197 FALSE, /* playlist transparent */ | |
198 2, /* 3rd preset (ARTIST - ALBUM - TITLE) */ | |
199 NULL, /* title format */ | |
200 FALSE, /* software volume control enabled */ | |
201 TRUE, /* UNUSED (XMMS compatibility mode) */ | |
202 TRUE, /* extra eq filtering */ | |
203 3, /* scroll pl by */ | |
204 FALSE, /* resume playback on startup */ | |
205 -1, /* resume playback on startup time */ | |
2364 | 206 TRUE, /* show seperators in pl */ |
3229
5e12e740c66c
default value for "enabled discovery plugins" was missing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3216
diff
changeset
|
207 NULL, /* chardet_detector */ |
5e12e740c66c
default value for "enabled discovery plugins" was missing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3216
diff
changeset
|
208 NULL, /* chardet_fallback */ |
2364 | 209 3000, /* audio buffer size */ |
210 FALSE, /* whether or not to postpone format detection on initial add */ | |
211 TRUE, /* show filepopup for tuple */ | |
212 NULL, /* words identifying covers */ | |
213 NULL, /* words that might not show up in cover names */ | |
2313 | 214 FALSE, |
215 0, | |
2364 | 216 NULL, /* default session uri base (non-NULL = custom session uri base) */ |
217 150, /* short side length of the picture in the filepopup */ | |
218 20, /* delay until the filepopup comes up */ | |
219 FALSE, /* use filename.jpg for coverart */ | |
220 FALSE, /* use XMMS-style file selection */ | |
221 TRUE, /* use extension probing */ | |
222 255, 255, 255, /* colorize r, g, b */ | |
223 FALSE, /* internal: whether or not to terminate */ | |
2405 | 224 TRUE, /* whether show progress bar in filepopup or not */ |
2806 | 225 TRUE, /* close jtf dialog on jump */ |
2973
8463de0cf728
Use back and forth scroll by default.
William Pitcock <nenolod@atheme-project.org>
parents:
2968
diff
changeset
|
226 TRUE, /* use back and forth scroll */ |
2313 | 227 }; |
228 | |
229 typedef struct bmp_cfg_boolent_t { | |
230 char const *be_vname; | |
231 gboolean *be_vloc; | |
232 gboolean be_wrt; | |
233 } bmp_cfg_boolent; | |
234 | |
235 typedef struct bmp_cfg_nument_t { | |
236 char const *ie_vname; | |
237 gint *ie_vloc; | |
238 gboolean ie_wrt; | |
239 } bmp_cfg_nument; | |
240 | |
241 typedef struct bmp_cfg_strent_t { | |
242 char const *se_vname; | |
243 char **se_vloc; | |
244 gboolean se_wrt; | |
245 } bmp_cfg_strent; | |
246 | |
247 const gchar *bmp_titlestring_presets[] = { | |
248 "%t", | |
249 "%{p:%p - %}%t", | |
250 "%{p:%p - %}%{a:%a - %}%t", | |
251 "%{p:%p - %}%{a:%a - %}%{n:%n. %}%t", | |
252 "%{p:%p %}%{a:[ %a ] %}%{p:- %}%{n:%n. %}%{t:%t%}", | |
253 "%{a:%a - %}%t" | |
254 }; | |
255 | |
256 const guint n_titlestring_presets = G_N_ELEMENTS(bmp_titlestring_presets); | |
257 | |
258 const gchar *chardet_detector_presets[] = { | |
2364 | 259 "None", |
260 "Japanese", | |
261 "Taiwanese", | |
262 "Chinese", | |
263 "Korean", | |
264 "Russian", | |
3216
e91acf24afbc
Expose new libguess-ng character detectors in preferences.
William Pitcock <nenolod@atheme-project.org>
parents:
3165
diff
changeset
|
265 "Greek", |
e91acf24afbc
Expose new libguess-ng character detectors in preferences.
William Pitcock <nenolod@atheme-project.org>
parents:
3165
diff
changeset
|
266 "Hebrew", |
e91acf24afbc
Expose new libguess-ng character detectors in preferences.
William Pitcock <nenolod@atheme-project.org>
parents:
3165
diff
changeset
|
267 "Turkish", |
e91acf24afbc
Expose new libguess-ng character detectors in preferences.
William Pitcock <nenolod@atheme-project.org>
parents:
3165
diff
changeset
|
268 "Arabic", |
2313 | 269 #ifdef HAVE_UDET |
2364 | 270 "Universal" |
2313 | 271 #endif |
272 }; | |
273 | |
2364 | 274 const guint n_chardet_detector_presets = G_N_ELEMENTS(chardet_detector_presets); |
2313 | 275 |
276 static bmp_cfg_boolent bmp_boolents[] = { | |
277 {"allow_multiple_instances", &cfg.allow_multiple_instances, TRUE}, | |
278 {"use_realtime", &cfg.use_realtime, TRUE}, | |
279 {"always_show_cb", &cfg.always_show_cb, TRUE}, | |
280 {"convert_underscore", &cfg.convert_underscore, TRUE}, | |
281 {"convert_twenty", &cfg.convert_twenty, TRUE}, | |
282 {"convert_slash", &cfg.convert_slash, TRUE }, | |
283 {"show_numbers_in_pl", &cfg.show_numbers_in_pl, TRUE}, | |
284 {"show_separator_in_pl", &cfg.show_separator_in_pl, TRUE}, | |
285 {"snap_windows", &cfg.snap_windows, TRUE}, | |
286 {"save_window_positions", &cfg.save_window_position, TRUE}, | |
287 {"dim_titlebar", &cfg.dim_titlebar, TRUE}, | |
288 {"get_info_on_load", &cfg.get_info_on_load, TRUE}, | |
289 {"get_info_on_demand", &cfg.get_info_on_demand, TRUE}, | |
290 {"eq_doublesize_linked", &cfg.eq_doublesize_linked, TRUE}, | |
291 {"no_playlist_advance", &cfg.no_playlist_advance, TRUE}, | |
292 {"refresh_file_list", &cfg.refresh_file_list, TRUE}, | |
293 {"sort_jump_to_file", &cfg.sort_jump_to_file, TRUE}, | |
294 {"use_pl_metadata", &cfg.use_pl_metadata, TRUE}, | |
2651
4d5e6a8717dd
[svn] - allow the player to start with all of its windows hidden (but give a warning to the user, whose display can be disabled); also, try to remember player windows positions when they stay hidden between sessions
giacomo
parents:
2644
diff
changeset
|
295 {"warn_about_win_visibility", &cfg.warn_about_win_visibility, TRUE}, |
2313 | 296 {"use_backslash_as_dir_delimiter", &cfg.use_backslash_as_dir_delimiter, TRUE}, |
297 {"player_shaded", &cfg.player_shaded, TRUE}, | |
298 {"player_visible", &cfg.player_visible, TRUE}, | |
299 {"shuffle", &cfg.shuffle, TRUE}, | |
300 {"repeat", &cfg.repeat, TRUE}, | |
301 {"doublesize", &cfg.doublesize, TRUE}, | |
302 {"autoscroll_songname", &cfg.autoscroll, TRUE}, | |
303 {"stop_after_current_song", &cfg.stopaftersong, TRUE}, | |
304 {"playlist_shaded", &cfg.playlist_shaded, TRUE}, | |
305 {"playlist_visible", &cfg.playlist_visible, TRUE}, | |
306 {"use_fontsets", &cfg.use_fontsets, TRUE}, | |
307 {"mainwin_use_xfont", &cfg.mainwin_use_xfont, FALSE}, | |
308 {"equalizer_visible", &cfg.equalizer_visible, TRUE}, | |
309 {"equalizer_active", &cfg.equalizer_active, TRUE}, | |
310 {"equalizer_shaded", &cfg.equalizer_shaded, TRUE}, | |
311 {"equalizer_autoload", &cfg.equalizer_autoload, TRUE}, | |
312 {"easy_move", &cfg.easy_move, TRUE}, | |
313 {"use_eplugins", &cfg.use_eplugins, TRUE}, | |
314 {"always_on_top", &cfg.always_on_top, TRUE}, | |
315 {"sticky", &cfg.sticky, TRUE}, | |
316 {"random_skin_on_play", &cfg.random_skin_on_play, TRUE}, | |
317 {"pause_between_songs", &cfg.pause_between_songs, TRUE}, | |
318 {"show_wm_decorations", &cfg.show_wm_decorations, TRUE}, | |
319 {"eq_extra_filtering", &cfg.eq_extra_filtering, TRUE}, | |
320 {"analyzer_peaks", &cfg.analyzer_peaks, TRUE}, | |
321 {"custom_cursors", &cfg.custom_cursors, TRUE}, | |
322 {"close_dialog_open", &cfg.close_dialog_open, TRUE}, | |
323 {"close_dialog_add", &cfg.close_dialog_add, TRUE}, | |
324 {"resume_playback_on_startup", &cfg.resume_playback_on_startup, TRUE}, | |
325 {"playlist_detect", &cfg.playlist_detect, TRUE}, | |
326 {"show_filepopup_for_tuple", &cfg.show_filepopup_for_tuple, TRUE}, | |
327 {"recurse_for_cover", &cfg.recurse_for_cover, TRUE}, | |
328 {"use_file_cover", &cfg.use_file_cover, TRUE}, | |
329 {"use_xmms_style_fileselector", &cfg.use_xmms_style_fileselector, TRUE}, | |
330 {"use_extension_probing", &cfg.use_extension_probing, TRUE}, | |
2405 | 331 {"filepopup_showprogressbar", &cfg.filepopup_showprogressbar, TRUE}, |
2805
6295535fbf49
[svn] - add toggle button to keep jtf dialog opened on jump.
yaz
parents:
2788
diff
changeset
|
332 {"close_jtf_dialog", &cfg.close_jtf_dialog, TRUE}, |
2968
83f03505f819
add support for one-way text scroll.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2938
diff
changeset
|
333 {"twoway_scroll", &cfg.twoway_scroll, TRUE}, |
2313 | 334 }; |
335 | |
336 static gint ncfgbent = G_N_ELEMENTS(bmp_boolents); | |
337 | |
338 static bmp_cfg_nument bmp_numents[] = { | |
339 {"player_x", &cfg.player_x, TRUE}, | |
340 {"player_y", &cfg.player_y, TRUE}, | |
341 {"timer_mode", &cfg.timer_mode, TRUE}, | |
342 {"vis_type", &cfg.vis_type, TRUE}, | |
343 {"analyzer_mode", &cfg.analyzer_mode, TRUE}, | |
344 {"analyzer_type", &cfg.analyzer_type, TRUE}, | |
345 {"scope_mode", &cfg.scope_mode, TRUE}, | |
346 {"vu_mode", &cfg.vu_mode, TRUE}, | |
347 {"voiceprint_mode", &cfg.voiceprint_mode, TRUE}, | |
348 {"vis_refresh_rate", &cfg.vis_refresh, TRUE}, | |
349 {"analyzer_falloff", &cfg.analyzer_falloff, TRUE}, | |
350 {"peaks_falloff", &cfg.peaks_falloff, TRUE}, | |
351 {"playlist_x", &cfg.playlist_x, TRUE}, | |
352 {"playlist_y", &cfg.playlist_y, TRUE}, | |
353 {"playlist_width", &cfg.playlist_width, TRUE}, | |
354 {"playlist_height", &cfg.playlist_height, TRUE}, | |
355 {"playlist_position", &cfg.playlist_position, TRUE}, | |
356 {"equalizer_x", &cfg.equalizer_x, TRUE}, | |
357 {"equalizer_y", &cfg.equalizer_y, TRUE}, | |
358 {"snap_distance", &cfg.snap_distance, TRUE}, | |
359 {"pause_between_songs_time", &cfg.pause_between_songs_time, TRUE}, | |
360 {"mouse_wheel_change", &cfg.mouse_change, TRUE}, | |
361 {"scroll_pl_by", &cfg.scroll_pl_by, TRUE}, | |
362 {"titlestring_preset", &cfg.titlestring_preset, TRUE}, | |
363 {"resume_playback_on_startup_time", &cfg.resume_playback_on_startup_time, TRUE}, | |
364 {"output_buffer_size", &cfg.output_buffer_size, TRUE}, | |
365 {"recurse_for_cover_depth", &cfg.recurse_for_cover_depth, TRUE}, | |
366 {"filepopup_pixelsize", &cfg.filepopup_pixelsize, TRUE}, | |
367 {"filepopup_delay", &cfg.filepopup_delay, TRUE}, | |
368 {"colorize_r", &cfg.colorize_r, TRUE}, | |
369 {"colorize_g", &cfg.colorize_g, TRUE}, | |
370 {"colorize_b", &cfg.colorize_b, TRUE}, | |
371 }; | |
372 | |
373 static gint ncfgient = G_N_ELEMENTS(bmp_numents); | |
374 | |
375 static bmp_cfg_strent bmp_strents[] = { | |
376 {"playlist_font", &cfg.playlist_font, TRUE}, | |
377 {"mainwin_font", &cfg.mainwin_font, TRUE}, | |
378 {"eqpreset_default_file", &cfg.eqpreset_default_file, TRUE}, | |
379 {"eqpreset_extension", &cfg.eqpreset_extension, TRUE}, | |
380 {"skin", &cfg.skin, FALSE}, | |
381 {"output_plugin", &cfg.outputplugin, FALSE}, | |
382 {"disabled_iplugins", &cfg.disabled_iplugins, TRUE}, | |
383 {"enabled_gplugins", &cfg.enabled_gplugins, FALSE}, | |
384 {"enabled_vplugins", &cfg.enabled_vplugins, FALSE}, | |
385 {"enabled_eplugins", &cfg.enabled_eplugins, FALSE}, | |
386 {"filesel_path", &cfg.filesel_path, FALSE}, | |
387 {"playlist_path", &cfg.playlist_path, FALSE}, | |
388 {"generic_title_format", &cfg.gentitle_format, TRUE}, | |
389 {"chardet_detector", &cfg.chardet_detector, TRUE}, | |
390 {"chardet_fallback", &cfg.chardet_fallback, TRUE}, | |
391 {"cover_name_include", &cfg.cover_name_include, TRUE}, | |
392 {"cover_name_exclude", &cfg.cover_name_exclude, TRUE}, | |
393 {"session_uri_base", &cfg.session_uri_base, TRUE} | |
394 }; | |
395 | |
396 static gint ncfgsent = G_N_ELEMENTS(bmp_strents); | |
397 | |
398 gchar *bmp_paths[BMP_PATH_COUNT] = {}; | |
399 | |
400 GList *dock_window_list = NULL; | |
401 | |
402 /* XXX: case-sensitivity is bad for lazy nenolods. :( -nenolod */ | |
403 static gchar *pl_candidates[] = { | |
2364 | 404 PLUGIN_FILENAME("ALSA"), |
405 PLUGIN_FILENAME("coreaudio"), | |
406 PLUGIN_FILENAME("OSS"), | |
407 PLUGIN_FILENAME("sun"), | |
408 PLUGIN_FILENAME("ESD"), | |
409 PLUGIN_FILENAME("pulse_audio"), | |
410 PLUGIN_FILENAME("disk_writer"), | |
411 NULL | |
2313 | 412 }; |
413 | |
414 GCond *cond_scan; | |
415 GMutex *mutex_scan; | |
416 | |
417 static GSList * | |
418 get_feature_list(void) | |
419 { | |
420 GSList *features = NULL; | |
421 | |
422 #ifdef HAVE_GCONF | |
423 features = g_slist_append(features, "GConf"); | |
424 #endif | |
425 | |
426 return features; | |
427 } | |
428 | |
429 static void | |
430 dump_version(void) | |
431 { | |
432 GSList *features; | |
433 | |
434 g_printf("%s %s [%s]", _(application_name), VERSION, svn_stamp); | |
435 | |
436 features = get_feature_list(); | |
437 | |
438 if (features) { | |
439 GSList *item; | |
440 | |
441 g_printf(" ("); | |
442 | |
443 for (item = features; g_slist_next(item); item = g_slist_next(item)) | |
444 g_printf("%s, ", (const gchar *) item->data); | |
445 | |
446 g_printf("%s)", (const gchar *) item->data); | |
447 | |
448 g_slist_free(features); | |
449 } | |
450 | |
451 g_printf("\n"); | |
452 } | |
453 | |
454 const gchar * | |
455 xmms_get_gentitle_format(void) | |
456 { | |
457 guint titlestring_preset = cfg.titlestring_preset; | |
458 | |
459 if (titlestring_preset < n_titlestring_presets) | |
2364 | 460 return bmp_titlestring_presets[titlestring_preset]; |
2313 | 461 |
462 return cfg.gentitle_format; | |
463 } | |
464 | |
465 void | |
466 make_directory(const gchar * path, mode_t mode) | |
467 { | |
2317
49d285f6008b
[svn] Full support for XDG basedir added. The old config doesn't get automatically converted yet.
js
parents:
2313
diff
changeset
|
468 if (g_mkdir_with_parents(path, mode) == 0) |
2313 | 469 return; |
470 | |
2317
49d285f6008b
[svn] Full support for XDG basedir added. The old config doesn't get automatically converted yet.
js
parents:
2313
diff
changeset
|
471 g_printerr(_("Could not create directory (%s): %s\n"), path, |
2313 | 472 g_strerror(errno)); |
473 } | |
474 | |
475 static void | |
476 bmp_make_user_dir(void) | |
477 { | |
478 const mode_t mode755 = S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH; | |
479 | |
480 make_directory(bmp_paths[BMP_PATH_USER_DIR], mode755); | |
481 make_directory(bmp_paths[BMP_PATH_USER_PLUGIN_DIR], mode755); | |
482 make_directory(bmp_paths[BMP_PATH_USER_SKIN_DIR], mode755); | |
483 make_directory(bmp_paths[BMP_PATH_SKIN_THUMB_DIR], mode755); | |
484 } | |
485 | |
486 static void | |
487 bmp_free_paths(void) | |
488 { | |
489 int i; | |
490 | |
491 for (i = 0; i < BMP_PATH_COUNT; i++) | |
492 { | |
493 g_free(bmp_paths[i]); | |
494 bmp_paths[i] = 0; | |
495 } | |
496 } | |
497 | |
2317
49d285f6008b
[svn] Full support for XDG basedir added. The old config doesn't get automatically converted yet.
js
parents:
2313
diff
changeset
|
498 static void |
49d285f6008b
[svn] Full support for XDG basedir added. The old config doesn't get automatically converted yet.
js
parents:
2313
diff
changeset
|
499 bmp_init_paths() |
49d285f6008b
[svn] Full support for XDG basedir added. The old config doesn't get automatically converted yet.
js
parents:
2313
diff
changeset
|
500 { |
2364 | 501 char *xdg_config_home; |
502 char *xdg_data_home; | |
503 char *xdg_cache_home; | |
2313 | 504 |
2364 | 505 xdg_config_home = (getenv("XDG_CONFIG_HOME") == NULL |
506 ? g_build_filename(g_get_home_dir(), ".config", NULL) | |
507 : g_strdup(getenv("XDG_CONFIG_HOME"))); | |
508 xdg_data_home = (getenv("XDG_DATA_HOME") == NULL | |
509 ? g_build_filename(g_get_home_dir(), ".local", "share", NULL) | |
510 : g_strdup(getenv("XDG_DATA_HOME"))); | |
511 xdg_cache_home = (getenv("XDG_CACHE_HOME") == NULL | |
512 ? g_build_filename(g_get_home_dir(), ".cache", NULL) | |
513 : g_strdup(getenv("XDG_CACHE_HOME"))); | |
2313 | 514 |
2364 | 515 bmp_paths[BMP_PATH_USER_DIR] = |
516 g_build_filename(xdg_config_home, "audacious", NULL); | |
517 bmp_paths[BMP_PATH_USER_SKIN_DIR] = | |
518 g_build_filename(xdg_data_home, "audacious", "Skins", NULL); | |
519 bmp_paths[BMP_PATH_USER_PLUGIN_DIR] = | |
2506
630910fd140f
[svn] - changed plugin directory to ~/.local/share/audacious/Plugins (seems more logical to me)
mf0102
parents:
2475
diff
changeset
|
520 g_build_filename(xdg_data_home, "audacious", "Plugins", NULL); |
630910fd140f
[svn] - changed plugin directory to ~/.local/share/audacious/Plugins (seems more logical to me)
mf0102
parents:
2475
diff
changeset
|
521 |
2364 | 522 bmp_paths[BMP_PATH_SKIN_THUMB_DIR] = |
523 g_build_filename(xdg_cache_home, "audacious", "thumbs", NULL); | |
2313 | 524 |
2364 | 525 bmp_paths[BMP_PATH_CONFIG_FILE] = |
526 g_build_filename(bmp_paths[BMP_PATH_USER_DIR], "config", NULL); | |
2317
49d285f6008b
[svn] Full support for XDG basedir added. The old config doesn't get automatically converted yet.
js
parents:
2313
diff
changeset
|
527 #ifdef HAVE_XSPF_PLAYLIST |
2364 | 528 bmp_paths[BMP_PATH_PLAYLIST_FILE] = |
529 g_build_filename(bmp_paths[BMP_PATH_USER_DIR], | |
530 "playlist.xspf", NULL); | |
2317
49d285f6008b
[svn] Full support for XDG basedir added. The old config doesn't get automatically converted yet.
js
parents:
2313
diff
changeset
|
531 #else |
2364 | 532 bmp_paths[BMP_PATH_PLAYLIST_FILE] = |
533 g_build_filename(bmp_paths[BMP_PATH_USER_DIR], | |
534 "playlist.m3u", NULL); | |
2317
49d285f6008b
[svn] Full support for XDG basedir added. The old config doesn't get automatically converted yet.
js
parents:
2313
diff
changeset
|
535 #endif |
2364 | 536 bmp_paths[BMP_PATH_ACCEL_FILE] = |
537 g_build_filename(bmp_paths[BMP_PATH_USER_DIR], "accels", NULL); | |
538 bmp_paths[BMP_PATH_LOG_FILE] = | |
539 g_build_filename(bmp_paths[BMP_PATH_USER_DIR], "log", NULL); | |
2317
49d285f6008b
[svn] Full support for XDG basedir added. The old config doesn't get automatically converted yet.
js
parents:
2313
diff
changeset
|
540 |
2463 | 541 bmp_paths[BMP_PATH_GTKRC_FILE] = |
2570 | 542 g_build_filename(bmp_paths[BMP_PATH_USER_DIR], "gtkrc", NULL); |
2463 | 543 |
2364 | 544 g_free(xdg_config_home); |
545 g_free(xdg_data_home); | |
546 g_free(xdg_cache_home); | |
2317
49d285f6008b
[svn] Full support for XDG basedir added. The old config doesn't get automatically converted yet.
js
parents:
2313
diff
changeset
|
547 |
2364 | 548 g_atexit(bmp_free_paths); |
2313 | 549 } |
550 | |
551 void | |
2682
c3cd6e47faf6
[svn] - make the evil 'reload plugins' button behave a bit better
giacomo
parents:
2662
diff
changeset
|
552 bmp_config_free(void) |
c3cd6e47faf6
[svn] - make the evil 'reload plugins' button behave a bit better
giacomo
parents:
2662
diff
changeset
|
553 { |
c3cd6e47faf6
[svn] - make the evil 'reload plugins' button behave a bit better
giacomo
parents:
2662
diff
changeset
|
554 gint i; |
c3cd6e47faf6
[svn] - make the evil 'reload plugins' button behave a bit better
giacomo
parents:
2662
diff
changeset
|
555 for (i = 0; i < ncfgsent; ++i) { |
c3cd6e47faf6
[svn] - make the evil 'reload plugins' button behave a bit better
giacomo
parents:
2662
diff
changeset
|
556 if ( *(bmp_strents[i].se_vloc) != NULL ) |
c3cd6e47faf6
[svn] - make the evil 'reload plugins' button behave a bit better
giacomo
parents:
2662
diff
changeset
|
557 { |
c3cd6e47faf6
[svn] - make the evil 'reload plugins' button behave a bit better
giacomo
parents:
2662
diff
changeset
|
558 g_free( *(bmp_strents[i].se_vloc) ); |
c3cd6e47faf6
[svn] - make the evil 'reload plugins' button behave a bit better
giacomo
parents:
2662
diff
changeset
|
559 *(bmp_strents[i].se_vloc) = NULL; |
c3cd6e47faf6
[svn] - make the evil 'reload plugins' button behave a bit better
giacomo
parents:
2662
diff
changeset
|
560 } |
c3cd6e47faf6
[svn] - make the evil 'reload plugins' button behave a bit better
giacomo
parents:
2662
diff
changeset
|
561 } |
c3cd6e47faf6
[svn] - make the evil 'reload plugins' button behave a bit better
giacomo
parents:
2662
diff
changeset
|
562 } |
c3cd6e47faf6
[svn] - make the evil 'reload plugins' button behave a bit better
giacomo
parents:
2662
diff
changeset
|
563 |
c3cd6e47faf6
[svn] - make the evil 'reload plugins' button behave a bit better
giacomo
parents:
2662
diff
changeset
|
564 void |
2313 | 565 bmp_config_load(void) |
566 { | |
567 ConfigDb *db; | |
568 gint i, length; | |
569 | |
570 memcpy(&cfg, &bmp_default_config, sizeof(BmpConfig)); | |
571 | |
572 db = bmp_cfg_db_open(); | |
573 for (i = 0; i < ncfgbent; ++i) { | |
574 bmp_cfg_db_get_bool(db, NULL, | |
575 bmp_boolents[i].be_vname, | |
576 bmp_boolents[i].be_vloc); | |
577 } | |
578 | |
579 for (i = 0; i < ncfgient; ++i) { | |
580 bmp_cfg_db_get_int(db, NULL, | |
581 bmp_numents[i].ie_vname, | |
582 bmp_numents[i].ie_vloc); | |
583 } | |
584 | |
585 for (i = 0; i < ncfgsent; ++i) { | |
586 bmp_cfg_db_get_string(db, NULL, | |
587 bmp_strents[i].se_vname, | |
588 bmp_strents[i].se_vloc); | |
589 } | |
590 | |
591 /* Preset */ | |
592 bmp_cfg_db_get_float(db, NULL, "equalizer_preamp", &cfg.equalizer_preamp); | |
593 for (i = 0; i < 10; i++) { | |
594 gchar eqtext[18]; | |
595 | |
596 g_snprintf(eqtext, sizeof(eqtext), "equalizer_band%d", i); | |
597 bmp_cfg_db_get_float(db, NULL, eqtext, &cfg.equalizer_bands[i]); | |
598 } | |
599 | |
600 /* History */ | |
601 if (bmp_cfg_db_get_int(db, NULL, "url_history_length", &length)) { | |
602 for (i = 1; i <= length; i++) { | |
603 gchar str[19], *tmp; | |
604 | |
605 g_snprintf(str, sizeof(str), "url_history%d", i); | |
606 if (bmp_cfg_db_get_string(db, NULL, str, &tmp)) | |
607 cfg.url_history = g_list_append(cfg.url_history, tmp); | |
608 } | |
609 } | |
610 | |
611 bmp_cfg_db_close(db); | |
612 | |
613 | |
614 if (cfg.playlist_font && strlen(cfg.playlist_font) == 0) { | |
615 g_free(cfg.playlist_font); | |
616 cfg.playlist_font = NULL; | |
617 } | |
618 | |
619 if (cfg.mainwin_font && strlen(cfg.mainwin_font) == 0) { | |
620 g_free(cfg.mainwin_font); | |
621 cfg.mainwin_font = NULL; | |
622 } | |
623 | |
624 if (!cfg.playlist_font) | |
625 cfg.playlist_font = g_strdup(PLAYLISTWIN_DEFAULT_FONT); | |
626 | |
627 if (!cfg.mainwin_font) | |
628 cfg.mainwin_font = g_strdup(MAINWIN_DEFAULT_FONT); | |
629 | |
630 if (!cfg.gentitle_format) | |
631 cfg.gentitle_format = g_strdup("%{p:%p - %}%{a:%a - %}%t"); | |
632 | |
633 if (!cfg.outputplugin) { | |
2364 | 634 gint iter; |
2313 | 635 gchar *pl_path = g_build_filename(PLUGIN_DIR, plugin_dir_list[0], NULL); |
636 | |
637 for (iter = 0; pl_candidates[iter] != NULL && cfg.outputplugin == NULL; iter++) | |
2364 | 638 { |
639 cfg.outputplugin = find_file_recursively(pl_path, pl_candidates[iter]); | |
640 } | |
2313 | 641 |
642 g_free(pl_path); | |
643 } | |
644 | |
645 if (!cfg.eqpreset_default_file) | |
646 cfg.eqpreset_default_file = g_strdup(EQUALIZER_DEFAULT_DIR_PRESET); | |
647 | |
648 if (!cfg.eqpreset_extension) | |
649 cfg.eqpreset_extension = g_strdup(EQUALIZER_DEFAULT_PRESET_EXT); | |
650 | |
651 if (!cfg.chardet_detector) | |
652 cfg.chardet_detector = g_strdup(""); | |
653 | |
654 if (!cfg.chardet_fallback) | |
655 cfg.chardet_fallback = g_strdup(""); | |
656 | |
657 if (!cfg.cover_name_include) | |
2364 | 658 cfg.cover_name_include = g_strdup(""); |
2313 | 659 |
660 if (!cfg.cover_name_exclude) | |
2364 | 661 cfg.cover_name_exclude = g_strdup("back"); |
2313 | 662 |
663 if (!cfg.session_uri_base) | |
664 cfg.session_uri_base = g_strdup(""); | |
665 | |
666 /* at least one of these should be true */ | |
667 if ((!cfg.get_info_on_demand) && (!cfg.get_info_on_load)) | |
668 cfg.get_info_on_demand = TRUE; | |
669 } | |
670 | |
671 | |
672 void | |
673 bmp_config_save(void) | |
674 { | |
675 GList *node; | |
676 gchar *str; | |
677 gint i, cur_pb_time; | |
678 ConfigDb *db; | |
679 Playlist *playlist = playlist_get_active(); | |
680 | |
681 cfg.disabled_iplugins = input_stringify_disabled_list(); | |
682 | |
683 | |
684 db = bmp_cfg_db_open(); | |
685 | |
686 for (i = 0; i < ncfgbent; ++i) | |
687 if (bmp_boolents[i].be_wrt) | |
688 bmp_cfg_db_set_bool(db, NULL, | |
689 bmp_boolents[i].be_vname, | |
690 *bmp_boolents[i].be_vloc); | |
691 | |
692 for (i = 0; i < ncfgient; ++i) | |
693 if (bmp_numents[i].ie_wrt) | |
694 bmp_cfg_db_set_int(db, NULL, | |
695 bmp_numents[i].ie_vname, | |
696 *bmp_numents[i].ie_vloc); | |
697 | |
698 /* This is a bit lame .. it'll end up being written twice, | |
699 * could do with being done a bit neater. -larne */ | |
700 bmp_cfg_db_set_int(db, NULL, "playlist_position", | |
701 playlist_get_position(playlist)); | |
702 | |
2530 | 703 /* FIXME: we're looking up SkinnedWindow::x &c ourselves here. |
704 * this isn't exactly right. -nenolod | |
705 */ | |
2651
4d5e6a8717dd
[svn] - allow the player to start with all of its windows hidden (but give a warning to the user, whose display can be disabled); also, try to remember player windows positions when they stay hidden between sessions
giacomo
parents:
2644
diff
changeset
|
706 if ( SKINNED_WINDOW(playlistwin)->x != -1 && |
4d5e6a8717dd
[svn] - allow the player to start with all of its windows hidden (but give a warning to the user, whose display can be disabled); also, try to remember player windows positions when they stay hidden between sessions
giacomo
parents:
2644
diff
changeset
|
707 SKINNED_WINDOW(playlistwin)->y != -1 ) |
4d5e6a8717dd
[svn] - allow the player to start with all of its windows hidden (but give a warning to the user, whose display can be disabled); also, try to remember player windows positions when they stay hidden between sessions
giacomo
parents:
2644
diff
changeset
|
708 { |
4d5e6a8717dd
[svn] - allow the player to start with all of its windows hidden (but give a warning to the user, whose display can be disabled); also, try to remember player windows positions when they stay hidden between sessions
giacomo
parents:
2644
diff
changeset
|
709 bmp_cfg_db_set_int(db, NULL, "playlist_x", |
4d5e6a8717dd
[svn] - allow the player to start with all of its windows hidden (but give a warning to the user, whose display can be disabled); also, try to remember player windows positions when they stay hidden between sessions
giacomo
parents:
2644
diff
changeset
|
710 SKINNED_WINDOW(playlistwin)->x); |
4d5e6a8717dd
[svn] - allow the player to start with all of its windows hidden (but give a warning to the user, whose display can be disabled); also, try to remember player windows positions when they stay hidden between sessions
giacomo
parents:
2644
diff
changeset
|
711 bmp_cfg_db_set_int(db, NULL, "playlist_y", |
4d5e6a8717dd
[svn] - allow the player to start with all of its windows hidden (but give a warning to the user, whose display can be disabled); also, try to remember player windows positions when they stay hidden between sessions
giacomo
parents:
2644
diff
changeset
|
712 SKINNED_WINDOW(playlistwin)->y); |
4d5e6a8717dd
[svn] - allow the player to start with all of its windows hidden (but give a warning to the user, whose display can be disabled); also, try to remember player windows positions when they stay hidden between sessions
giacomo
parents:
2644
diff
changeset
|
713 } |
4d5e6a8717dd
[svn] - allow the player to start with all of its windows hidden (but give a warning to the user, whose display can be disabled); also, try to remember player windows positions when they stay hidden between sessions
giacomo
parents:
2644
diff
changeset
|
714 |
4d5e6a8717dd
[svn] - allow the player to start with all of its windows hidden (but give a warning to the user, whose display can be disabled); also, try to remember player windows positions when they stay hidden between sessions
giacomo
parents:
2644
diff
changeset
|
715 if ( SKINNED_WINDOW(mainwin)->x != -1 && |
4d5e6a8717dd
[svn] - allow the player to start with all of its windows hidden (but give a warning to the user, whose display can be disabled); also, try to remember player windows positions when they stay hidden between sessions
giacomo
parents:
2644
diff
changeset
|
716 SKINNED_WINDOW(mainwin)->y != -1 ) |
4d5e6a8717dd
[svn] - allow the player to start with all of its windows hidden (but give a warning to the user, whose display can be disabled); also, try to remember player windows positions when they stay hidden between sessions
giacomo
parents:
2644
diff
changeset
|
717 { |
4d5e6a8717dd
[svn] - allow the player to start with all of its windows hidden (but give a warning to the user, whose display can be disabled); also, try to remember player windows positions when they stay hidden between sessions
giacomo
parents:
2644
diff
changeset
|
718 bmp_cfg_db_set_int(db, NULL, "player_x", |
4d5e6a8717dd
[svn] - allow the player to start with all of its windows hidden (but give a warning to the user, whose display can be disabled); also, try to remember player windows positions when they stay hidden between sessions
giacomo
parents:
2644
diff
changeset
|
719 SKINNED_WINDOW(mainwin)->x); |
4d5e6a8717dd
[svn] - allow the player to start with all of its windows hidden (but give a warning to the user, whose display can be disabled); also, try to remember player windows positions when they stay hidden between sessions
giacomo
parents:
2644
diff
changeset
|
720 bmp_cfg_db_set_int(db, NULL, "player_y", |
4d5e6a8717dd
[svn] - allow the player to start with all of its windows hidden (but give a warning to the user, whose display can be disabled); also, try to remember player windows positions when they stay hidden between sessions
giacomo
parents:
2644
diff
changeset
|
721 SKINNED_WINDOW(mainwin)->y); |
4d5e6a8717dd
[svn] - allow the player to start with all of its windows hidden (but give a warning to the user, whose display can be disabled); also, try to remember player windows positions when they stay hidden between sessions
giacomo
parents:
2644
diff
changeset
|
722 } |
2530 | 723 |
2651
4d5e6a8717dd
[svn] - allow the player to start with all of its windows hidden (but give a warning to the user, whose display can be disabled); also, try to remember player windows positions when they stay hidden between sessions
giacomo
parents:
2644
diff
changeset
|
724 if ( SKINNED_WINDOW(equalizerwin)->x != -1 && |
4d5e6a8717dd
[svn] - allow the player to start with all of its windows hidden (but give a warning to the user, whose display can be disabled); also, try to remember player windows positions when they stay hidden between sessions
giacomo
parents:
2644
diff
changeset
|
725 SKINNED_WINDOW(equalizerwin)->y != -1 ) |
4d5e6a8717dd
[svn] - allow the player to start with all of its windows hidden (but give a warning to the user, whose display can be disabled); also, try to remember player windows positions when they stay hidden between sessions
giacomo
parents:
2644
diff
changeset
|
726 { |
4d5e6a8717dd
[svn] - allow the player to start with all of its windows hidden (but give a warning to the user, whose display can be disabled); also, try to remember player windows positions when they stay hidden between sessions
giacomo
parents:
2644
diff
changeset
|
727 bmp_cfg_db_set_int(db, NULL, "equalizer_x", |
4d5e6a8717dd
[svn] - allow the player to start with all of its windows hidden (but give a warning to the user, whose display can be disabled); also, try to remember player windows positions when they stay hidden between sessions
giacomo
parents:
2644
diff
changeset
|
728 SKINNED_WINDOW(equalizerwin)->x); |
4d5e6a8717dd
[svn] - allow the player to start with all of its windows hidden (but give a warning to the user, whose display can be disabled); also, try to remember player windows positions when they stay hidden between sessions
giacomo
parents:
2644
diff
changeset
|
729 bmp_cfg_db_set_int(db, NULL, "equalizer_y", |
4d5e6a8717dd
[svn] - allow the player to start with all of its windows hidden (but give a warning to the user, whose display can be disabled); also, try to remember player windows positions when they stay hidden between sessions
giacomo
parents:
2644
diff
changeset
|
730 SKINNED_WINDOW(equalizerwin)->y); |
4d5e6a8717dd
[svn] - allow the player to start with all of its windows hidden (but give a warning to the user, whose display can be disabled); also, try to remember player windows positions when they stay hidden between sessions
giacomo
parents:
2644
diff
changeset
|
731 } |
2530 | 732 |
2313 | 733 bmp_cfg_db_set_bool(db, NULL, "mainwin_use_xfont", |
2364 | 734 cfg.mainwin_use_xfont); |
2313 | 735 |
736 for (i = 0; i < ncfgsent; ++i) { | |
737 if (bmp_strents[i].se_wrt) | |
738 bmp_cfg_db_set_string(db, NULL, | |
739 bmp_strents[i].se_vname, | |
740 *bmp_strents[i].se_vloc); | |
741 } | |
742 | |
743 bmp_cfg_db_set_float(db, NULL, "equalizer_preamp", cfg.equalizer_preamp); | |
744 | |
745 for (i = 0; i < 10; i++) { | |
746 str = g_strdup_printf("equalizer_band%d", i); | |
747 bmp_cfg_db_set_float(db, NULL, str, cfg.equalizer_bands[i]); | |
748 g_free(str); | |
749 } | |
750 | |
751 if (bmp_active_skin != NULL) | |
752 { | |
753 if (bmp_active_skin->path) | |
754 bmp_cfg_db_set_string(db, NULL, "skin", bmp_active_skin->path); | |
755 else | |
756 bmp_cfg_db_unset_key(db, NULL, "skin"); | |
757 } | |
758 | |
759 if (get_current_output_plugin()) | |
760 bmp_cfg_db_set_string(db, NULL, "output_plugin", | |
761 get_current_output_plugin()->filename); | |
762 else | |
763 bmp_cfg_db_unset_key(db, NULL, "output_plugin"); | |
764 | |
765 str = general_stringify_enabled_list(); | |
766 if (str) { | |
767 bmp_cfg_db_set_string(db, NULL, "enabled_gplugins", str); | |
768 g_free(str); | |
769 } | |
770 else | |
771 bmp_cfg_db_unset_key(db, NULL, "enabled_gplugins"); | |
772 | |
773 str = vis_stringify_enabled_list(); | |
774 if (str) { | |
775 bmp_cfg_db_set_string(db, NULL, "enabled_vplugins", str); | |
776 g_free(str); | |
777 } | |
778 else | |
779 bmp_cfg_db_unset_key(db, NULL, "enabled_vplugins"); | |
780 | |
781 str = effect_stringify_enabled_list(); | |
782 if (str) { | |
783 bmp_cfg_db_set_string(db, NULL, "enabled_eplugins", str); | |
784 g_free(str); | |
785 } | |
786 else | |
787 bmp_cfg_db_unset_key(db, NULL, "enabled_eplugins"); | |
788 | |
789 if (cfg.filesel_path) | |
790 bmp_cfg_db_set_string(db, NULL, "filesel_path", cfg.filesel_path); | |
791 | |
792 if (cfg.playlist_path) | |
793 bmp_cfg_db_set_string(db, NULL, "playlist_path", cfg.playlist_path); | |
794 | |
795 bmp_cfg_db_set_int(db, NULL, "url_history_length", | |
796 g_list_length(cfg.url_history)); | |
797 | |
798 for (node = cfg.url_history, i = 1; node; node = g_list_next(node), i++) { | |
799 str = g_strdup_printf("url_history%d", i); | |
800 bmp_cfg_db_set_string(db, NULL, str, node->data); | |
801 g_free(str); | |
802 } | |
803 | |
804 if (playback_get_playing()) { | |
2364 | 805 cur_pb_time = playback_get_time(); |
2313 | 806 } else |
2364 | 807 cur_pb_time = -1; |
2313 | 808 cfg.resume_playback_on_startup_time = cur_pb_time; |
809 bmp_cfg_db_set_int(db, NULL, "resume_playback_on_startup_time", | |
2364 | 810 cfg.resume_playback_on_startup_time); |
2313 | 811 |
812 bmp_cfg_db_close(db); | |
813 | |
814 playlist_save(playlist, bmp_paths[BMP_PATH_PLAYLIST_FILE]); | |
815 } | |
816 | |
817 static void | |
818 bmp_set_default_icon(void) | |
819 { | |
820 GdkPixbuf *icon; | |
821 | |
822 icon = gdk_pixbuf_new_from_xpm_data((const gchar **) audacious_player_xpm); | |
823 gtk_window_set_default_icon(icon); | |
824 g_object_unref(icon); | |
825 } | |
826 | |
827 static void | |
828 register_aud_stock_icons(void) | |
829 { | |
830 GtkIconFactory *iconfactory = gtk_icon_factory_new(); | |
831 GtkIconSet *iconset; | |
832 GdkPixbuf *pixbuf; | |
833 | |
834 /* pick images in icons-csource.h */ | |
835 pixbuf = gdk_pixbuf_new_from_inline( -1 , removedups_pixbuf , FALSE , NULL ); | |
836 iconset = gtk_icon_set_new_from_pixbuf( pixbuf ); g_object_unref( pixbuf ); | |
837 gtk_icon_factory_add( iconfactory , AUD_STOCK_REMOVEDUPS , iconset ); | |
838 pixbuf = gdk_pixbuf_new_from_inline( -1 , removeunavail_pixbuf , FALSE , NULL ); | |
839 iconset = gtk_icon_set_new_from_pixbuf( pixbuf ); g_object_unref( pixbuf ); | |
840 gtk_icon_factory_add( iconfactory , AUD_STOCK_REMOVEUNAVAIL , iconset ); | |
841 pixbuf = gdk_pixbuf_new_from_inline( -1 , randomizepl_pixbuf , FALSE , NULL ); | |
842 iconset = gtk_icon_set_new_from_pixbuf( pixbuf ); g_object_unref( pixbuf ); | |
843 gtk_icon_factory_add( iconfactory , AUD_STOCK_RANDOMIZEPL , iconset ); | |
844 pixbuf = gdk_pixbuf_new_from_inline( -1 , sortbytitle_pixbuf , FALSE , NULL ); | |
845 iconset = gtk_icon_set_new_from_pixbuf( pixbuf ); g_object_unref( pixbuf ); | |
846 gtk_icon_factory_add( iconfactory , AUD_STOCK_SORTBYTITLE , iconset ); | |
847 pixbuf = gdk_pixbuf_new_from_inline( -1 , sortbyfilename_pixbuf , FALSE , NULL ); | |
848 iconset = gtk_icon_set_new_from_pixbuf( pixbuf ); g_object_unref( pixbuf ); | |
849 gtk_icon_factory_add( iconfactory , AUD_STOCK_SORTBYFILENAME , iconset ); | |
850 pixbuf = gdk_pixbuf_new_from_inline( -1 , sortbyartist_pixbuf , FALSE , NULL ); | |
851 iconset = gtk_icon_set_new_from_pixbuf( pixbuf ); g_object_unref( pixbuf ); | |
852 gtk_icon_factory_add( iconfactory , AUD_STOCK_SORTBYARTIST , iconset ); | |
853 pixbuf = gdk_pixbuf_new_from_inline( -1 , sortbypathfile_pixbuf , FALSE , NULL ); | |
854 iconset = gtk_icon_set_new_from_pixbuf( pixbuf ); g_object_unref( pixbuf ); | |
855 gtk_icon_factory_add( iconfactory , AUD_STOCK_SORTBYPATHFILE , iconset ); | |
856 pixbuf = gdk_pixbuf_new_from_inline( -1 , selectnone_pixbuf , FALSE , NULL ); | |
857 iconset = gtk_icon_set_new_from_pixbuf( pixbuf ); g_object_unref( pixbuf ); | |
858 gtk_icon_factory_add( iconfactory , AUD_STOCK_SELECTNONE , iconset ); | |
859 pixbuf = gdk_pixbuf_new_from_inline( -1 , selectall_pixbuf , FALSE , NULL ); | |
860 iconset = gtk_icon_set_new_from_pixbuf( pixbuf ); g_object_unref( pixbuf ); | |
861 gtk_icon_factory_add( iconfactory , AUD_STOCK_SELECTALL , iconset ); | |
862 pixbuf = gdk_pixbuf_new_from_inline( -1 , selectinvert_pixbuf , FALSE , NULL ); | |
863 iconset = gtk_icon_set_new_from_pixbuf( pixbuf ); g_object_unref( pixbuf ); | |
864 gtk_icon_factory_add( iconfactory , AUD_STOCK_SELECTINVERT , iconset ); | |
865 pixbuf = gdk_pixbuf_new_from_inline( -1 , invertpl_pixbuf , FALSE , NULL ); | |
866 iconset = gtk_icon_set_new_from_pixbuf( pixbuf ); g_object_unref( pixbuf ); | |
867 gtk_icon_factory_add( iconfactory , AUD_STOCK_INVERTPL , iconset ); | |
868 pixbuf = gdk_pixbuf_new_from_inline( -1 , queuetoggle_pixbuf , FALSE , NULL ); | |
869 iconset = gtk_icon_set_new_from_pixbuf( pixbuf ); g_object_unref( pixbuf ); | |
870 gtk_icon_factory_add( iconfactory , AUD_STOCK_QUEUETOGGLE , iconset ); | |
871 pixbuf = gdk_pixbuf_new_from_inline( -1 , info_pixbuf , FALSE , NULL ); | |
872 iconset = gtk_icon_set_new_from_pixbuf( pixbuf ); g_object_unref( pixbuf ); | |
873 gtk_icon_factory_add( iconfactory , AUD_STOCK_INFO , iconset ); | |
874 pixbuf = gdk_pixbuf_new_from_inline( -1 , playlist_pixbuf , FALSE , NULL ); | |
875 iconset = gtk_icon_set_new_from_pixbuf( pixbuf ); g_object_unref( pixbuf ); | |
876 gtk_icon_factory_add( iconfactory , AUD_STOCK_PLAYLIST , iconset ); | |
877 | |
878 gtk_icon_factory_add_default( iconfactory ); | |
879 g_object_unref( iconfactory ); | |
880 } | |
881 | |
2411 | 882 static GOptionEntry cmd_entries[] = { |
2448
ff135e2ba10e
[svn] - mark some strings used by GOption as translatable
nenolod
parents:
2420
diff
changeset
|
883 {"session", 'n', 0, G_OPTION_ARG_INT, &options.session, N_("Select which Audacious session ID to use"), NULL}, |
ff135e2ba10e
[svn] - mark some strings used by GOption as translatable
nenolod
parents:
2420
diff
changeset
|
884 {"rew", 'r', 0, G_OPTION_ARG_NONE, &options.rew, N_("Skip backwards in playlist"), NULL}, |
ff135e2ba10e
[svn] - mark some strings used by GOption as translatable
nenolod
parents:
2420
diff
changeset
|
885 {"play", 'p', 0, G_OPTION_ARG_NONE, &options.play, N_("Start playing current playlist"), NULL}, |
ff135e2ba10e
[svn] - mark some strings used by GOption as translatable
nenolod
parents:
2420
diff
changeset
|
886 {"pause", 'u', 0, G_OPTION_ARG_NONE, &options.pause, N_("Pause current song"), NULL}, |
2475 | 887 {"stop", 's', 0, G_OPTION_ARG_NONE, &options.stop, N_("Stop current song"), NULL}, |
2551
cea3528b2996
[svn] Fix --play-pause commandline option, by Alex "Monkey" Maclean in #gentoo-x86
chainsaw
parents:
2530
diff
changeset
|
888 {"play-pause", 't', 0, G_OPTION_ARG_NONE, &options.play_pause, N_("Pause if playing, play otherwise"), NULL}, |
2448
ff135e2ba10e
[svn] - mark some strings used by GOption as translatable
nenolod
parents:
2420
diff
changeset
|
889 {"fwd", 'f', 0, G_OPTION_ARG_NONE, &options.fwd, N_("Skip forward in playlist"), NULL}, |
ff135e2ba10e
[svn] - mark some strings used by GOption as translatable
nenolod
parents:
2420
diff
changeset
|
890 {"show-jump-box", 'j', 0, G_OPTION_ARG_NONE, &options.show_jump_box, N_("Display Jump to File dialog"), NULL}, |
ff135e2ba10e
[svn] - mark some strings used by GOption as translatable
nenolod
parents:
2420
diff
changeset
|
891 {"enqueue", 'e', 0, G_OPTION_ARG_NONE, &options.enqueue, N_("Don't clear the playlist"), NULL}, |
ff135e2ba10e
[svn] - mark some strings used by GOption as translatable
nenolod
parents:
2420
diff
changeset
|
892 {"enqueue-to-temp", 'E', 0, G_OPTION_ARG_NONE, &options.enqueue_to_temp, N_("Add new files to a temporary playlist"), NULL}, |
ff135e2ba10e
[svn] - mark some strings used by GOption as translatable
nenolod
parents:
2420
diff
changeset
|
893 {"show-main-window", 'm', 0, G_OPTION_ARG_NONE, &options.mainwin, N_("Display the main window"), NULL}, |
ff135e2ba10e
[svn] - mark some strings used by GOption as translatable
nenolod
parents:
2420
diff
changeset
|
894 {"activate", 'a', 0, G_OPTION_ARG_NONE, &options.activate, N_("Display all open Audacious windows"), NULL}, |
ff135e2ba10e
[svn] - mark some strings used by GOption as translatable
nenolod
parents:
2420
diff
changeset
|
895 {"headless", 'H', 0, G_OPTION_ARG_NONE, &options.headless, N_("Enable headless operation"), NULL}, |
ff135e2ba10e
[svn] - mark some strings used by GOption as translatable
nenolod
parents:
2420
diff
changeset
|
896 {"no-log", 'N', 0, G_OPTION_ARG_NONE, &options.no_log, N_("Print all errors and warnings to stdout"), NULL}, |
ff135e2ba10e
[svn] - mark some strings used by GOption as translatable
nenolod
parents:
2420
diff
changeset
|
897 {"version", 'v', 0, G_OPTION_ARG_NONE, &options.version, N_("Show version and builtin features"), NULL}, |
2411 | 898 {G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &options.filenames, N_("FILE..."), NULL}, |
899 {NULL}, | |
900 }; | |
2313 | 901 |
902 static void | |
903 handle_cmd_line_options(BmpCmdLineOpt * options, | |
904 gboolean remote) | |
905 { | |
2411 | 906 gchar **filenames = options->filenames; |
2785 | 907 #ifdef USE_DBUS |
908 DBusGProxy *session = audacious_get_dbus_proxy(); | |
2727
14f9a629ba9c
[svn] - rename xmms_remote namespace to audacious_remote namespace
nenolod
parents:
2717
diff
changeset
|
909 #endif |
2313 | 910 |
2411 | 911 if (options->version) |
912 { | |
913 dump_version(); | |
914 exit(EXIT_SUCCESS); | |
915 } | |
916 | |
2788
b2b920b165ad
[svn] - exclude codes which use session if USE_DBUS is not defined.
yaz
parents:
2786
diff
changeset
|
917 #ifdef USE_DBUS |
2411 | 918 if (filenames != NULL) |
919 { | |
2313 | 920 gint pos = 0; |
2411 | 921 gint i = 0; |
2605
1ceaf00f9c6d
[svn] - fix handling of multiple files on the command line.
nenolod
parents:
2574
diff
changeset
|
922 GList *fns = NULL; |
2313 | 923 |
2411 | 924 for (i = 0; filenames[i] != NULL; i++) |
925 { | |
2570 | 926 gchar *filename; |
2512
3a1fc6f7c187
[svn] - unbreak relative path support. closes #791.
nenolod
parents:
2506
diff
changeset
|
927 gchar *current_dir = g_get_current_dir(); |
3a1fc6f7c187
[svn] - unbreak relative path support. closes #791.
nenolod
parents:
2506
diff
changeset
|
928 |
3a1fc6f7c187
[svn] - unbreak relative path support. closes #791.
nenolod
parents:
2506
diff
changeset
|
929 if (filenames[i][0] == '/' || strstr(filenames[i], "://")) |
3a1fc6f7c187
[svn] - unbreak relative path support. closes #791.
nenolod
parents:
2506
diff
changeset
|
930 filename = g_strdup(filenames[i]); |
3a1fc6f7c187
[svn] - unbreak relative path support. closes #791.
nenolod
parents:
2506
diff
changeset
|
931 else |
3a1fc6f7c187
[svn] - unbreak relative path support. closes #791.
nenolod
parents:
2506
diff
changeset
|
932 filename = g_build_filename(current_dir, filenames[i], NULL); |
3a1fc6f7c187
[svn] - unbreak relative path support. closes #791.
nenolod
parents:
2506
diff
changeset
|
933 |
2605
1ceaf00f9c6d
[svn] - fix handling of multiple files on the command line.
nenolod
parents:
2574
diff
changeset
|
934 fns = g_list_prepend(fns, filename); |
2313 | 935 |
2605
1ceaf00f9c6d
[svn] - fix handling of multiple files on the command line.
nenolod
parents:
2574
diff
changeset
|
936 g_free(current_dir); |
1ceaf00f9c6d
[svn] - fix handling of multiple files on the command line.
nenolod
parents:
2574
diff
changeset
|
937 } |
1ceaf00f9c6d
[svn] - fix handling of multiple files on the command line.
nenolod
parents:
2574
diff
changeset
|
938 |
1ceaf00f9c6d
[svn] - fix handling of multiple files on the command line.
nenolod
parents:
2574
diff
changeset
|
939 fns = g_list_reverse(fns); |
2411 | 940 |
2605
1ceaf00f9c6d
[svn] - fix handling of multiple files on the command line.
nenolod
parents:
2574
diff
changeset
|
941 if (options->load_skins) |
1ceaf00f9c6d
[svn] - fix handling of multiple files on the command line.
nenolod
parents:
2574
diff
changeset
|
942 { |
2727
14f9a629ba9c
[svn] - rename xmms_remote namespace to audacious_remote namespace
nenolod
parents:
2717
diff
changeset
|
943 audacious_remote_set_skin(session, filenames[0]); |
2605
1ceaf00f9c6d
[svn] - fix handling of multiple files on the command line.
nenolod
parents:
2574
diff
changeset
|
944 skin_install_skin(filenames[0]); |
1ceaf00f9c6d
[svn] - fix handling of multiple files on the command line.
nenolod
parents:
2574
diff
changeset
|
945 } |
1ceaf00f9c6d
[svn] - fix handling of multiple files on the command line.
nenolod
parents:
2574
diff
changeset
|
946 else |
1ceaf00f9c6d
[svn] - fix handling of multiple files on the command line.
nenolod
parents:
2574
diff
changeset
|
947 { |
1ceaf00f9c6d
[svn] - fix handling of multiple files on the command line.
nenolod
parents:
2574
diff
changeset
|
948 if (options->enqueue_to_temp) |
2727
14f9a629ba9c
[svn] - rename xmms_remote namespace to audacious_remote namespace
nenolod
parents:
2717
diff
changeset
|
949 audacious_remote_playlist_enqueue_to_temp(session, filenames[0]); |
2411 | 950 |
2605
1ceaf00f9c6d
[svn] - fix handling of multiple files on the command line.
nenolod
parents:
2574
diff
changeset
|
951 if (options->enqueue && options->play) |
2727
14f9a629ba9c
[svn] - rename xmms_remote namespace to audacious_remote namespace
nenolod
parents:
2717
diff
changeset
|
952 pos = audacious_remote_get_playlist_length(session); |
2313 | 953 |
2605
1ceaf00f9c6d
[svn] - fix handling of multiple files on the command line.
nenolod
parents:
2574
diff
changeset
|
954 if (!options->enqueue) |
1ceaf00f9c6d
[svn] - fix handling of multiple files on the command line.
nenolod
parents:
2574
diff
changeset
|
955 { |
2727
14f9a629ba9c
[svn] - rename xmms_remote namespace to audacious_remote namespace
nenolod
parents:
2717
diff
changeset
|
956 audacious_remote_playlist_clear(session); |
14f9a629ba9c
[svn] - rename xmms_remote namespace to audacious_remote namespace
nenolod
parents:
2717
diff
changeset
|
957 audacious_remote_stop(session); |
2411 | 958 } |
2512
3a1fc6f7c187
[svn] - unbreak relative path support. closes #791.
nenolod
parents:
2506
diff
changeset
|
959 |
2727
14f9a629ba9c
[svn] - rename xmms_remote namespace to audacious_remote namespace
nenolod
parents:
2717
diff
changeset
|
960 audacious_remote_playlist_add(session, fns); |
2605
1ceaf00f9c6d
[svn] - fix handling of multiple files on the command line.
nenolod
parents:
2574
diff
changeset
|
961 |
1ceaf00f9c6d
[svn] - fix handling of multiple files on the command line.
nenolod
parents:
2574
diff
changeset
|
962 if (options->enqueue && options->play && |
2727
14f9a629ba9c
[svn] - rename xmms_remote namespace to audacious_remote namespace
nenolod
parents:
2717
diff
changeset
|
963 audacious_remote_get_playlist_length(session) > pos) |
14f9a629ba9c
[svn] - rename xmms_remote namespace to audacious_remote namespace
nenolod
parents:
2717
diff
changeset
|
964 audacious_remote_set_playlist_pos(session, pos); |
2605
1ceaf00f9c6d
[svn] - fix handling of multiple files on the command line.
nenolod
parents:
2574
diff
changeset
|
965 |
1ceaf00f9c6d
[svn] - fix handling of multiple files on the command line.
nenolod
parents:
2574
diff
changeset
|
966 if (!options->enqueue) |
2727
14f9a629ba9c
[svn] - rename xmms_remote namespace to audacious_remote namespace
nenolod
parents:
2717
diff
changeset
|
967 audacious_remote_play(session); |
2313 | 968 } |
969 | |
2605
1ceaf00f9c6d
[svn] - fix handling of multiple files on the command line.
nenolod
parents:
2574
diff
changeset
|
970 g_list_foreach(fns, (GFunc) g_free, NULL); |
1ceaf00f9c6d
[svn] - fix handling of multiple files on the command line.
nenolod
parents:
2574
diff
changeset
|
971 g_list_free(fns); |
1ceaf00f9c6d
[svn] - fix handling of multiple files on the command line.
nenolod
parents:
2574
diff
changeset
|
972 |
2411 | 973 g_strfreev(filenames); |
2786 | 974 } /* filename */ |
2313 | 975 |
2832 | 976 if (remote) { |
977 if (options->rew) | |
978 audacious_remote_playlist_prev(session); | |
2313 | 979 |
2832 | 980 if (options->play) |
981 audacious_remote_play(session); | |
2313 | 982 |
2832 | 983 if (options->pause) |
984 audacious_remote_pause(session); | |
2313 | 985 |
2832 | 986 if (options->stop) |
987 audacious_remote_stop(session); | |
2313 | 988 |
2832 | 989 if (options->fwd) |
990 audacious_remote_playlist_next(session); | |
2313 | 991 |
2832 | 992 if (options->play_pause) |
993 audacious_remote_play_pause(session); | |
2313 | 994 |
2832 | 995 if (options->show_jump_box) |
996 audacious_remote_show_jtf_box(session); | |
2313 | 997 |
2832 | 998 if (options->mainwin) |
999 audacious_remote_main_win_toggle(session, TRUE); | |
2313 | 1000 |
2832 | 1001 if (options->activate) |
1002 audacious_remote_activate(session); | |
2313 | 1003 |
2832 | 1004 if (options->playcd) |
1005 play_medium(); | |
2845
a124656d4423
added handlers for cmd line args when remote == false
Ben Tucker <ben.tucker@gmail.com>
parents:
2838
diff
changeset
|
1006 } else { |
a124656d4423
added handlers for cmd line args when remote == false
Ben Tucker <ben.tucker@gmail.com>
parents:
2838
diff
changeset
|
1007 if (options->rew) |
a124656d4423
added handlers for cmd line args when remote == false
Ben Tucker <ben.tucker@gmail.com>
parents:
2838
diff
changeset
|
1008 audacious_drct_playlist_prev(); |
a124656d4423
added handlers for cmd line args when remote == false
Ben Tucker <ben.tucker@gmail.com>
parents:
2838
diff
changeset
|
1009 |
a124656d4423
added handlers for cmd line args when remote == false
Ben Tucker <ben.tucker@gmail.com>
parents:
2838
diff
changeset
|
1010 if (options->play) |
a124656d4423
added handlers for cmd line args when remote == false
Ben Tucker <ben.tucker@gmail.com>
parents:
2838
diff
changeset
|
1011 audacious_drct_play(); |
a124656d4423
added handlers for cmd line args when remote == false
Ben Tucker <ben.tucker@gmail.com>
parents:
2838
diff
changeset
|
1012 |
a124656d4423
added handlers for cmd line args when remote == false
Ben Tucker <ben.tucker@gmail.com>
parents:
2838
diff
changeset
|
1013 if (options->pause) |
a124656d4423
added handlers for cmd line args when remote == false
Ben Tucker <ben.tucker@gmail.com>
parents:
2838
diff
changeset
|
1014 audacious_drct_pause(); |
a124656d4423
added handlers for cmd line args when remote == false
Ben Tucker <ben.tucker@gmail.com>
parents:
2838
diff
changeset
|
1015 |
a124656d4423
added handlers for cmd line args when remote == false
Ben Tucker <ben.tucker@gmail.com>
parents:
2838
diff
changeset
|
1016 if (options->stop) |
a124656d4423
added handlers for cmd line args when remote == false
Ben Tucker <ben.tucker@gmail.com>
parents:
2838
diff
changeset
|
1017 audacious_drct_stop(); |
a124656d4423
added handlers for cmd line args when remote == false
Ben Tucker <ben.tucker@gmail.com>
parents:
2838
diff
changeset
|
1018 |
a124656d4423
added handlers for cmd line args when remote == false
Ben Tucker <ben.tucker@gmail.com>
parents:
2838
diff
changeset
|
1019 if (options->fwd) |
a124656d4423
added handlers for cmd line args when remote == false
Ben Tucker <ben.tucker@gmail.com>
parents:
2838
diff
changeset
|
1020 audacious_drct_playlist_next(); |
a124656d4423
added handlers for cmd line args when remote == false
Ben Tucker <ben.tucker@gmail.com>
parents:
2838
diff
changeset
|
1021 |
a124656d4423
added handlers for cmd line args when remote == false
Ben Tucker <ben.tucker@gmail.com>
parents:
2838
diff
changeset
|
1022 if (options->play_pause) { |
2846
89c3fef7ae1f
evaluate return value of audacious_drct_get_paused() instead of its address.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2845
diff
changeset
|
1023 if (audacious_drct_get_paused()) |
2845
a124656d4423
added handlers for cmd line args when remote == false
Ben Tucker <ben.tucker@gmail.com>
parents:
2838
diff
changeset
|
1024 audacious_drct_play(); |
a124656d4423
added handlers for cmd line args when remote == false
Ben Tucker <ben.tucker@gmail.com>
parents:
2838
diff
changeset
|
1025 else |
a124656d4423
added handlers for cmd line args when remote == false
Ben Tucker <ben.tucker@gmail.com>
parents:
2838
diff
changeset
|
1026 audacious_drct_pause(); |
a124656d4423
added handlers for cmd line args when remote == false
Ben Tucker <ben.tucker@gmail.com>
parents:
2838
diff
changeset
|
1027 } |
a124656d4423
added handlers for cmd line args when remote == false
Ben Tucker <ben.tucker@gmail.com>
parents:
2838
diff
changeset
|
1028 |
a124656d4423
added handlers for cmd line args when remote == false
Ben Tucker <ben.tucker@gmail.com>
parents:
2838
diff
changeset
|
1029 if (options->show_jump_box) |
a124656d4423
added handlers for cmd line args when remote == false
Ben Tucker <ben.tucker@gmail.com>
parents:
2838
diff
changeset
|
1030 audacious_drct_show_jtf_box(); |
a124656d4423
added handlers for cmd line args when remote == false
Ben Tucker <ben.tucker@gmail.com>
parents:
2838
diff
changeset
|
1031 |
a124656d4423
added handlers for cmd line args when remote == false
Ben Tucker <ben.tucker@gmail.com>
parents:
2838
diff
changeset
|
1032 if (options->mainwin) |
a124656d4423
added handlers for cmd line args when remote == false
Ben Tucker <ben.tucker@gmail.com>
parents:
2838
diff
changeset
|
1033 audacious_drct_main_win_toggle(TRUE); |
a124656d4423
added handlers for cmd line args when remote == false
Ben Tucker <ben.tucker@gmail.com>
parents:
2838
diff
changeset
|
1034 |
a124656d4423
added handlers for cmd line args when remote == false
Ben Tucker <ben.tucker@gmail.com>
parents:
2838
diff
changeset
|
1035 if (options->activate) |
a124656d4423
added handlers for cmd line args when remote == false
Ben Tucker <ben.tucker@gmail.com>
parents:
2838
diff
changeset
|
1036 audacious_drct_activate(); |
a124656d4423
added handlers for cmd line args when remote == false
Ben Tucker <ben.tucker@gmail.com>
parents:
2838
diff
changeset
|
1037 |
a124656d4423
added handlers for cmd line args when remote == false
Ben Tucker <ben.tucker@gmail.com>
parents:
2838
diff
changeset
|
1038 if (options->playcd) |
a124656d4423
added handlers for cmd line args when remote == false
Ben Tucker <ben.tucker@gmail.com>
parents:
2838
diff
changeset
|
1039 play_medium(); |
2832 | 1040 } |
2785 | 1041 |
2786 | 1042 if(remote) { |
2785 | 1043 gboolean is_running = audacious_remote_is_running(session); |
1044 if (is_running) | |
1045 exit(EXIT_SUCCESS); | |
1046 } | |
2788
b2b920b165ad
[svn] - exclude codes which use session if USE_DBUS is not defined.
yaz
parents:
2786
diff
changeset
|
1047 #endif |
2313 | 1048 } |
1049 | |
1050 static void | |
1051 bmp_setup_logger(void) | |
1052 { | |
1053 if (!bmp_logger_start(bmp_paths[BMP_PATH_LOG_FILE])) | |
1054 return; | |
1055 | |
1056 g_atexit(bmp_logger_stop); | |
1057 } | |
1058 | |
1059 static void | |
1060 run_load_skin_error_dialog(const gchar * skin_path) | |
1061 { | |
1062 const gchar *markup = | |
1063 N_("<b><big>Unable to load skin.</big></b>\n" | |
1064 "\n" | |
1065 "Check that skin at '%s' is usable and default skin is properly " | |
1066 "installed at '%s'\n"); | |
1067 | |
1068 GtkWidget *dialog = | |
1069 gtk_message_dialog_new_with_markup(NULL, | |
1070 GTK_DIALOG_MODAL, | |
1071 GTK_MESSAGE_ERROR, | |
1072 GTK_BUTTONS_CLOSE, | |
1073 _(markup), | |
1074 skin_path, | |
1075 BMP_DEFAULT_SKIN_PATH); | |
1076 gtk_dialog_run(GTK_DIALOG(dialog)); | |
1077 gtk_widget_destroy(dialog); | |
1078 } | |
1079 | |
2908
6a474a7954a0
Allow for printf-style format strings to be passed to report_error() via g_strdup_vprintf().
William Pitcock <nenolod@atheme.org>
parents:
2907
diff
changeset
|
1080 void report_error(const gchar *error_message, ...) |
2313 | 1081 { |
2908
6a474a7954a0
Allow for printf-style format strings to be passed to report_error() via g_strdup_vprintf().
William Pitcock <nenolod@atheme.org>
parents:
2907
diff
changeset
|
1082 gchar *buf; |
6a474a7954a0
Allow for printf-style format strings to be passed to report_error() via g_strdup_vprintf().
William Pitcock <nenolod@atheme.org>
parents:
2907
diff
changeset
|
1083 va_list va; |
6a474a7954a0
Allow for printf-style format strings to be passed to report_error() via g_strdup_vprintf().
William Pitcock <nenolod@atheme.org>
parents:
2907
diff
changeset
|
1084 |
6a474a7954a0
Allow for printf-style format strings to be passed to report_error() via g_strdup_vprintf().
William Pitcock <nenolod@atheme.org>
parents:
2907
diff
changeset
|
1085 va_start(va, error_message); |
6a474a7954a0
Allow for printf-style format strings to be passed to report_error() via g_strdup_vprintf().
William Pitcock <nenolod@atheme.org>
parents:
2907
diff
changeset
|
1086 buf = g_strdup_vprintf(error_message, va); |
6a474a7954a0
Allow for printf-style format strings to be passed to report_error() via g_strdup_vprintf().
William Pitcock <nenolod@atheme.org>
parents:
2907
diff
changeset
|
1087 va_end(va); |
6a474a7954a0
Allow for printf-style format strings to be passed to report_error() via g_strdup_vprintf().
William Pitcock <nenolod@atheme.org>
parents:
2907
diff
changeset
|
1088 |
6a474a7954a0
Allow for printf-style format strings to be passed to report_error() via g_strdup_vprintf().
William Pitcock <nenolod@atheme.org>
parents:
2907
diff
changeset
|
1089 fprintf(stderr, buf); |
2570 | 1090 |
1091 if (options.headless != 1) | |
1092 { | |
2313 | 1093 gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(err), |
2908
6a474a7954a0
Allow for printf-style format strings to be passed to report_error() via g_strdup_vprintf().
William Pitcock <nenolod@atheme.org>
parents:
2907
diff
changeset
|
1094 buf); |
2313 | 1095 gtk_dialog_run(GTK_DIALOG(err)); |
1096 gtk_widget_hide(err); | |
1097 } | |
2908
6a474a7954a0
Allow for printf-style format strings to be passed to report_error() via g_strdup_vprintf().
William Pitcock <nenolod@atheme.org>
parents:
2907
diff
changeset
|
1098 |
6a474a7954a0
Allow for printf-style format strings to be passed to report_error() via g_strdup_vprintf().
William Pitcock <nenolod@atheme.org>
parents:
2907
diff
changeset
|
1099 g_free(buf); |
2313 | 1100 } |
1101 | |
2369 | 1102 static gboolean |
1103 aud_headless_iteration(gpointer unused) | |
1104 { | |
2506
630910fd140f
[svn] - changed plugin directory to ~/.local/share/audacious/Plugins (seems more logical to me)
mf0102
parents:
2475
diff
changeset
|
1105 free_vis_data(); |
630910fd140f
[svn] - changed plugin directory to ~/.local/share/audacious/Plugins (seems more logical to me)
mf0102
parents:
2475
diff
changeset
|
1106 return TRUE; |
2369 | 1107 } |
1108 | |
2313 | 1109 gint |
1110 main(gint argc, gchar ** argv) | |
1111 { | |
1112 gboolean gtk_init_check_ok; | |
1113 Playlist *playlist; | |
2411 | 1114 GOptionContext *context; |
1115 GError *error = NULL; | |
2313 | 1116 |
2644
67082557b2c4
[svn] - glib-2.13.0 requires g_thread_init() to be called before all other GLib functions.
yaz
parents:
2605
diff
changeset
|
1117 /* glib-2.13.0 requires g_thread_init() to be called before all |
67082557b2c4
[svn] - glib-2.13.0 requires g_thread_init() to be called before all other GLib functions.
yaz
parents:
2605
diff
changeset
|
1118 other GLib functions */ |
67082557b2c4
[svn] - glib-2.13.0 requires g_thread_init() to be called before all other GLib functions.
yaz
parents:
2605
diff
changeset
|
1119 g_thread_init(NULL); |
67082557b2c4
[svn] - glib-2.13.0 requires g_thread_init() to be called before all other GLib functions.
yaz
parents:
2605
diff
changeset
|
1120 if (!g_thread_supported()) { |
67082557b2c4
[svn] - glib-2.13.0 requires g_thread_init() to be called before all other GLib functions.
yaz
parents:
2605
diff
changeset
|
1121 g_printerr(_("Sorry, threads isn't supported on your platform.\n\n" |
67082557b2c4
[svn] - glib-2.13.0 requires g_thread_init() to be called before all other GLib functions.
yaz
parents:
2605
diff
changeset
|
1122 "If you're on a libc5 based linux system and installed Glib & GTK+ before you\n" |
67082557b2c4
[svn] - glib-2.13.0 requires g_thread_init() to be called before all other GLib functions.
yaz
parents:
2605
diff
changeset
|
1123 "installed LinuxThreads you need to recompile Glib & GTK+.\n")); |
67082557b2c4
[svn] - glib-2.13.0 requires g_thread_init() to be called before all other GLib functions.
yaz
parents:
2605
diff
changeset
|
1124 exit(EXIT_FAILURE); |
67082557b2c4
[svn] - glib-2.13.0 requires g_thread_init() to be called before all other GLib functions.
yaz
parents:
2605
diff
changeset
|
1125 } |
67082557b2c4
[svn] - glib-2.13.0 requires g_thread_init() to be called before all other GLib functions.
yaz
parents:
2605
diff
changeset
|
1126 |
67082557b2c4
[svn] - glib-2.13.0 requires g_thread_init() to be called before all other GLib functions.
yaz
parents:
2605
diff
changeset
|
1127 gdk_threads_init(); |
67082557b2c4
[svn] - glib-2.13.0 requires g_thread_init() to be called before all other GLib functions.
yaz
parents:
2605
diff
changeset
|
1128 |
2313 | 1129 /* Setup l10n early so we can print localized error messages */ |
1130 gtk_set_locale(); | |
1131 bindtextdomain(PACKAGE_NAME, LOCALEDIR); | |
1132 bind_textdomain_codeset(PACKAGE_NAME, "UTF-8"); | |
2388
52bcc18eb8bb
[svn] - attempt to bind the audacious-plugins domain
nenolod
parents:
2369
diff
changeset
|
1133 bindtextdomain(PACKAGE_NAME "-plugins", LOCALEDIR); |
52bcc18eb8bb
[svn] - attempt to bind the audacious-plugins domain
nenolod
parents:
2369
diff
changeset
|
1134 bind_textdomain_codeset(PACKAGE_NAME "-plugins", "UTF-8"); |
2313 | 1135 textdomain(PACKAGE_NAME); |
1136 | |
1137 bmp_init_paths(); | |
1138 bmp_make_user_dir(); | |
1139 | |
1140 g_set_application_name(_(application_name)); | |
1141 | |
1142 cond_scan = g_cond_new(); | |
1143 mutex_scan = g_mutex_new(); | |
1144 | |
2463 | 1145 gtk_rc_add_default_file(bmp_paths[BMP_PATH_GTKRC_FILE]); |
1146 | |
2313 | 1147 gtk_init_check_ok = gtk_init_check(&argc, &argv); |
2411 | 1148 |
2413 | 1149 memset(&options, '\0', sizeof(BmpCmdLineOpt)); |
1150 options.session = -1; | |
1151 | |
2411 | 1152 context = g_option_context_new(_("- play multimedia files")); |
1153 g_option_context_add_main_entries(context, cmd_entries, PACKAGE_NAME); | |
1154 g_option_context_add_group(context, gtk_get_option_group(TRUE)); | |
1155 g_option_context_parse(context, &argc, &argv, &error); | |
1156 | |
2412 | 1157 if (error != NULL) |
1158 { | |
2938
1cdfc508d758
Fix adding files when Audacious is running.
Jonathan Schleifer <js@h3c.de>
parents:
2914
diff
changeset
|
1159 g_printerr(_("%s: %s\nTry `%s --help' for more information.\n"), |
1cdfc508d758
Fix adding files when Audacious is running.
Jonathan Schleifer <js@h3c.de>
parents:
2914
diff
changeset
|
1160 argv[0], error->message, argv[0]); |
2412 | 1161 exit(EXIT_FAILURE); |
1162 } | |
1163 | |
2313 | 1164 if (!gtk_init_check_ok) { |
1165 if (argc < 2) { | |
1166 /* GTK check failed, and no arguments passed to indicate | |
1167 that user is intending to only remote control a running | |
1168 session */ | |
2412 | 1169 g_printerr(_("%s: Unable to open display, exiting.\n"), argv[0]); |
2313 | 1170 exit(EXIT_FAILURE); |
1171 } | |
1172 | |
1173 handle_cmd_line_options(&options, TRUE); | |
1174 | |
1175 /* we could be running headless, so GTK probably wont matter */ | |
1176 if (options.headless != 1) | |
2938
1cdfc508d758
Fix adding files when Audacious is running.
Jonathan Schleifer <js@h3c.de>
parents:
2914
diff
changeset
|
1177 exit(EXIT_SUCCESS); |
2313 | 1178 } |
1179 | |
1180 if (options.no_log == FALSE) | |
1181 bmp_setup_logger(); | |
1182 | |
1183 signal_handlers_init(); | |
1184 | |
1185 g_random_set_seed(time(NULL)); | |
1186 | |
1187 bmp_config_load(); | |
1188 | |
2736 | 1189 handle_cmd_line_options(&options, TRUE); |
2313 | 1190 |
2733
cf080b11c3fa
[svn] Implemented more of the stubs in audctrl; Added more methods to objects.xml with implementations in dbus.c. I'm still trying to get plugins working with libaudclient.
magma
parents:
2727
diff
changeset
|
1191 #ifdef USE_DBUS |
cf080b11c3fa
[svn] Implemented more of the stubs in audctrl; Added more methods to objects.xml with implementations in dbus.c. I'm still trying to get plugins working with libaudclient.
magma
parents:
2727
diff
changeset
|
1192 init_dbus(); |
cf080b11c3fa
[svn] Implemented more of the stubs in audctrl; Added more methods to objects.xml with implementations in dbus.c. I'm still trying to get plugins working with libaudclient.
magma
parents:
2727
diff
changeset
|
1193 #endif |
2856
c4d07471f647
Added a mowgli_init() call
Cristi Magherusan <majeru@gentoo.ro>
parents:
2846
diff
changeset
|
1194 mowgli_init(); |
2313 | 1195 plugin_system_init(); |
1196 | |
1197 /* Initialize the playlist system. */ | |
1198 playlist_init(); | |
1199 | |
1200 if (options.headless != 1) | |
1201 { | |
1202 /* register icons in stock */ | |
1203 register_aud_stock_icons(); | |
1204 | |
1205 bmp_set_default_icon(); | |
1206 | |
1207 gtk_accel_map_load(bmp_paths[BMP_PATH_ACCEL_FILE]); | |
1208 | |
1209 /* uimanager */ | |
1210 ui_manager_init(); | |
1211 ui_manager_create_menus(); | |
1212 | |
1213 if (!init_skins(cfg.skin)) { | |
1214 run_load_skin_error_dialog(cfg.skin); | |
1215 exit(EXIT_FAILURE); | |
1216 } | |
1217 | |
1218 GDK_THREADS_ENTER(); | |
1219 } | |
1220 | |
1221 /* Load the default playlist in. */ | |
1222 playlist = playlist_get_active(); | |
1223 playlist_load(playlist, bmp_paths[BMP_PATH_PLAYLIST_FILE]); | |
1224 playlist_set_position(playlist, cfg.playlist_position); | |
1225 | |
1226 /* this needs to be called after all 3 windows are created and | |
1227 * input plugins are setup'ed | |
1228 * but not if we're running headless --nenolod | |
1229 */ | |
1230 mainwin_setup_menus(); | |
1231 | |
1232 if (options.headless != 1) | |
1233 { | |
1234 read_volume(VOLSET_STARTUP); | |
1235 | |
1236 /* FIXME: delayed, because it deals directly with the plugin | |
1237 * interface to set menu items */ | |
1238 create_prefs_window(); | |
1239 | |
2364 | 1240 create_fileinfo_window(); |
1241 | |
2313 | 1242 |
1243 if (cfg.player_visible) | |
1244 mainwin_show(TRUE); | |
1245 else if (!cfg.playlist_visible && !cfg.equalizer_visible) | |
2651
4d5e6a8717dd
[svn] - allow the player to start with all of its windows hidden (but give a warning to the user, whose display can be disabled); also, try to remember player windows positions when they stay hidden between sessions
giacomo
parents:
2644
diff
changeset
|
1246 { |
4d5e6a8717dd
[svn] - allow the player to start with all of its windows hidden (but give a warning to the user, whose display can be disabled); also, try to remember player windows positions when they stay hidden between sessions
giacomo
parents:
2644
diff
changeset
|
1247 /* all of the windows are hidden... warn user about this */ |
4d5e6a8717dd
[svn] - allow the player to start with all of its windows hidden (but give a warning to the user, whose display can be disabled); also, try to remember player windows positions when they stay hidden between sessions
giacomo
parents:
2644
diff
changeset
|
1248 mainwin_show_visibility_warning(); |
4d5e6a8717dd
[svn] - allow the player to start with all of its windows hidden (but give a warning to the user, whose display can be disabled); also, try to remember player windows positions when they stay hidden between sessions
giacomo
parents:
2644
diff
changeset
|
1249 } |
2313 | 1250 |
1251 if (cfg.equalizer_visible) | |
1252 equalizerwin_show(TRUE); | |
1253 | |
1254 if (cfg.playlist_visible) | |
1255 playlistwin_show(); | |
1256 | |
1257 hint_set_always(cfg.always_on_top); | |
1258 | |
1259 playlist_start_get_info_thread(); | |
1260 mainwin_attach_idle_func(); | |
1261 | |
2364 | 1262 has_x11_connection = TRUE; |
2313 | 1263 |
2364 | 1264 if (cfg.resume_playback_on_startup) |
1265 { | |
1266 if (cfg.resume_playback_on_startup_time != -1 && | |
1267 playlist_get_length(playlist) > 0) | |
1268 { | |
1269 int i; | |
1270 gint l = 0, r = 0; | |
1271 while (gtk_events_pending()) gtk_main_iteration(); | |
1272 output_get_volume(&l, &r); | |
1273 output_set_volume(0,0); | |
1274 playback_initiate(); | |
2313 | 1275 |
2364 | 1276 /* Busy wait; loop is fairly tight to minimize duration of |
1277 * "frozen" GUI. Feel free to tune. --chainsaw */ | |
1278 for (i = 0; i < 20; i++) | |
1279 { | |
1280 g_usleep(1000); | |
1281 if (!ip_data.playing) | |
1282 break; | |
1283 } | |
1284 playback_seek(cfg.resume_playback_on_startup_time / 1000); | |
1285 output_set_volume(l, r); | |
1286 } | |
1287 } | |
1288 | |
2313 | 1289 gtk_main(); |
1290 | |
1291 GDK_THREADS_LEAVE(); | |
1292 | |
1293 g_cond_free(cond_scan); | |
1294 g_mutex_free(mutex_scan); | |
1295 | |
1296 return EXIT_SUCCESS; | |
1297 } | |
2364 | 1298 // if we are running headless |
2313 | 1299 else |
1300 { | |
2506
630910fd140f
[svn] - changed plugin directory to ~/.local/share/audacious/Plugins (seems more logical to me)
mf0102
parents:
2475
diff
changeset
|
1301 GMainLoop *loop; |
2369 | 1302 |
2313 | 1303 playlist_start_get_info_thread(); |
1304 | |
2506
630910fd140f
[svn] - changed plugin directory to ~/.local/share/audacious/Plugins (seems more logical to me)
mf0102
parents:
2475
diff
changeset
|
1305 loop = g_main_loop_new(NULL, TRUE); |
630910fd140f
[svn] - changed plugin directory to ~/.local/share/audacious/Plugins (seems more logical to me)
mf0102
parents:
2475
diff
changeset
|
1306 g_timeout_add(10, aud_headless_iteration, NULL); |
630910fd140f
[svn] - changed plugin directory to ~/.local/share/audacious/Plugins (seems more logical to me)
mf0102
parents:
2475
diff
changeset
|
1307 g_main_loop_run(loop); |
2313 | 1308 |
1309 return EXIT_SUCCESS; | |
1310 } | |
1311 } |