Mercurial > audlegacy
annotate src/audacious/main.c @ 3530:08dae20c75f0 trunk
Don't store default playlist in the playlists/ directory.
author | Kieran Clancy <clancy.kieran+audacious@gmail.com> |
---|---|
date | Sat, 15 Sep 2007 18:10:55 +0930 |
parents | 56e2a8704164 |
children | 6b8c8e051c1b |
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 |
3251 | 58 #include "skin.h" |
2845
a124656d4423
added handlers for cmd line args when remote == false
Ben Tucker <ben.tucker@gmail.com>
parents:
2838
diff
changeset
|
59 #include "auddrct.h" |
2313 | 60 #include "dnd.h" |
61 #include "effect.h" | |
62 #include "ui_equalizer.h" | |
63 #include "general.h" | |
64 #include "hints.h" | |
65 #include "input.h" | |
66 #include "logger.h" | |
67 #include "ui_main.h" | |
68 #include "ui_manager.h" | |
69 #include "output.h" | |
70 #include "playback.h" | |
71 #include "playlist.h" | |
72 #include "ui_playlist.h" | |
73 #include "ui_preferences.h" | |
74 #include "pluginenum.h" | |
75 #include "ui_skinselector.h" | |
76 #include "util.h" | |
77 #include "visualization.h" | |
78 #include "build_stamp.h" | |
79 #include "ui_fileinfo.h" | |
80 #include "signals.h" | |
2530 | 81 #include "ui_skinned_window.h" |
2313 | 82 |
83 #include "icons-csource.h" | |
84 #include "icons-stock.h" | |
85 #include "images/audacious_player.xpm" | |
86 | |
2364 | 87 gboolean has_x11_connection = FALSE; /* do we have an X11 connection? */ |
2313 | 88 |
89 /* Translatable string for beep.desktop's comment field */ | |
90 const gchar *desktop_comment = N_("Audacious"); | |
91 | |
92 const gchar *application_name = N_("Audacious"); | |
93 | |
94 | |
95 struct _BmpCmdLineOpt { | |
2411 | 96 gchar **filenames; |
2313 | 97 gint session; |
3351
7a4fcf84a34f
Removed the hardcoded Add/Play CD menu entry
Calin Crisan ccrisan@gmail.com
parents:
3346
diff
changeset
|
98 gboolean play, stop, pause, fwd, rew, play_pause, show_jump_box; |
2313 | 99 gboolean enqueue, mainwin, remote, activate; |
100 gboolean load_skins; | |
101 gboolean headless; | |
102 gboolean no_log; | |
103 gboolean enqueue_to_temp; | |
2411 | 104 gboolean version; |
2313 | 105 gchar *previous_session_id; |
106 }; | |
107 | |
108 typedef struct _BmpCmdLineOpt BmpCmdLineOpt; | |
109 | |
110 BmpCmdLineOpt options; | |
111 | |
112 BmpConfig cfg; | |
113 | |
114 BmpConfig bmp_default_config = { | |
115 MAINWIN_DEFAULT_POS_X, /* mainwin x position */ | |
116 MAINWIN_DEFAULT_POS_Y, /* mainwin y position */ | |
117 EQUALIZER_DEFAULT_POS_X, /* equalizer x position */ | |
118 EQUALIZER_DEFAULT_POS_Y, /* equalizer y position */ | |
119 PLAYLISTWIN_DEFAULT_POS_X, /* playlistwin x position */ | |
120 PLAYLISTWIN_DEFAULT_POS_Y, /* playlistwin y position */ | |
121 PLAYLISTWIN_DEFAULT_WIDTH, /* playlistwin width */ | |
122 PLAYLISTWIN_DEFAULT_HEIGHT, /* playlistwin height */ | |
123 10, /* snap distance */ | |
124 FALSE, /* real-time priority */ | |
125 FALSE, FALSE, /* shuffle, repeat */ | |
126 FALSE, /* UNUSED (double size) */ | |
127 TRUE, /* autoscroll */ | |
128 TRUE, /* analyzer peaks */ | |
129 FALSE, /* equalizer autoload */ | |
130 FALSE, /* easy move */ | |
131 FALSE, /* equalizer active */ | |
132 FALSE, /* playlistwin visible */ | |
133 FALSE, /* equalizer visible */ | |
134 TRUE, /* player visible */ | |
135 FALSE, /* player shaded */ | |
136 FALSE, /* playlistwin shaded */ | |
137 FALSE, /* equalizer shaded */ | |
138 FALSE, /* allow multiple instances */ | |
139 TRUE, /* always show cb */ | |
140 TRUE, TRUE, TRUE, /* convert '_', %20 and '\' */ | |
141 TRUE, /* show numbers in playlist */ | |
142 TRUE, /* snap windows */ | |
143 TRUE, /* save window positions */ | |
144 TRUE, /* dim titlebar */ | |
145 FALSE, /* get playlist info on load */ | |
146 TRUE, /* get playlist info on demand */ | |
147 TRUE, /* UNUSED (equalizer doublesize linked) */ | |
148 FALSE, /* sort jump to file */ | |
149 FALSE, /* use effect plugins */ | |
150 FALSE, /* always on top */ | |
151 FALSE, /* sticky */ | |
152 FALSE, /* no playlist advance */ | |
153 FALSE, /* stop after current song */ | |
154 TRUE, /* refresh file list */ | |
155 TRUE, /* UNUSED (smooth title scrolling) */ | |
156 TRUE, /* use playlist metadata */ | |
2662
09b404d61ebd
[svn] - remove the unplayable files dialog. it is more annoying than useful.
nenolod
parents:
2651
diff
changeset
|
157 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
|
158 TRUE, /* warn about windows visibility */ |
2313 | 159 FALSE, /* use \ as directory delimiter */ |
160 FALSE, /* random skin on play */ | |
161 FALSE, /* use fontsets */ | |
162 FALSE, /* use X font for mainwin */ | |
2364 | 163 TRUE, /* use custom cursors */ |
164 TRUE, /* close dialog on open */ | |
165 TRUE, /* close dialog on add */ | |
2313 | 166 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
|
167 {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
|
168 0.0, 0.0, 0.0, 0.0, 0.0}, |
2313 | 169 NULL, /* skin */ |
170 NULL, /* output plugin */ | |
171 NULL, /* file selector path */ | |
172 NULL, /* playlist path */ | |
173 NULL, /* playlist font */ | |
174 NULL, /* mainwin font */ | |
175 NULL, /* disabled input plugins */ | |
176 NULL, /* enabled general plugins */ | |
177 NULL, /* enabled visualization plugins */ | |
178 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
|
179 NULL, /* enabled discovery plugins */ |
2313 | 180 NULL, /* equalizer preset default file */ |
181 NULL, /* equalizer preset extension */ | |
182 NULL, /* URL history */ | |
183 0, /* timer mode */ | |
184 VIS_ANALYZER, /* visualizer type */ | |
185 ANALYZER_NORMAL, /* analyzer mode */ | |
186 ANALYZER_BARS, /* analyzer type */ | |
187 SCOPE_DOT, /* scope mode */ | |
188 VOICEPRINT_NORMAL, /* voiceprint mode */ | |
189 VU_SMOOTH, /* VU mode */ | |
190 REFRESH_FULL, /* visualizer refresh rate */ | |
191 FALLOFF_FAST, /* analyzer fall off rate */ | |
192 FALLOFF_SLOW, /* peaks fall off rate */ | |
193 0, /* playlist position */ | |
194 2, /* pause between songs time */ | |
195 FALSE, /* pause between songs */ | |
196 FALSE, /* show window decorations */ | |
197 8, /* mouse wheel scroll step */ | |
198 FALSE, /* playlist transparent */ | |
199 2, /* 3rd preset (ARTIST - ALBUM - TITLE) */ | |
200 NULL, /* title format */ | |
201 FALSE, /* software volume control enabled */ | |
202 TRUE, /* UNUSED (XMMS compatibility mode) */ | |
203 TRUE, /* extra eq filtering */ | |
204 3, /* scroll pl by */ | |
205 FALSE, /* resume playback on startup */ | |
206 -1, /* resume playback on startup time */ | |
2364 | 207 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
|
208 NULL, /* chardet_detector */ |
5e12e740c66c
default value for "enabled discovery plugins" was missing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3216
diff
changeset
|
209 NULL, /* chardet_fallback */ |
3443
709cd9c2fa8f
Allocate a 500ms buffer instead of a 3000ms buffer by default.
William Pitcock <nenolod@atheme.org>
parents:
3400
diff
changeset
|
210 500, /* audio buffer size */ |
2364 | 211 FALSE, /* whether or not to postpone format detection on initial add */ |
212 TRUE, /* show filepopup for tuple */ | |
213 NULL, /* words identifying covers */ | |
214 NULL, /* words that might not show up in cover names */ | |
2313 | 215 FALSE, |
216 0, | |
2364 | 217 NULL, /* default session uri base (non-NULL = custom session uri base) */ |
218 150, /* short side length of the picture in the filepopup */ | |
219 20, /* delay until the filepopup comes up */ | |
220 FALSE, /* use filename.jpg for coverart */ | |
221 FALSE, /* use XMMS-style file selection */ | |
222 TRUE, /* use extension probing */ | |
223 255, 255, 255, /* colorize r, g, b */ | |
224 FALSE, /* internal: whether or not to terminate */ | |
2405 | 225 TRUE, /* whether show progress bar in filepopup or not */ |
2806 | 226 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
|
227 TRUE, /* use back and forth scroll */ |
2313 | 228 }; |
229 | |
230 typedef struct bmp_cfg_boolent_t { | |
231 char const *be_vname; | |
232 gboolean *be_vloc; | |
233 gboolean be_wrt; | |
234 } bmp_cfg_boolent; | |
235 | |
236 typedef struct bmp_cfg_nument_t { | |
237 char const *ie_vname; | |
238 gint *ie_vloc; | |
239 gboolean ie_wrt; | |
240 } bmp_cfg_nument; | |
241 | |
242 typedef struct bmp_cfg_strent_t { | |
243 char const *se_vname; | |
244 char **se_vloc; | |
245 gboolean se_wrt; | |
246 } bmp_cfg_strent; | |
247 | |
248 const gchar *bmp_titlestring_presets[] = { | |
3296
c1f506c2b1d0
new format strings
William Pitcock <nenolod@atheme-project.org>
parents:
3251
diff
changeset
|
249 "${title}", |
c1f506c2b1d0
new format strings
William Pitcock <nenolod@atheme-project.org>
parents:
3251
diff
changeset
|
250 "${?artist:${artist} - }${title}", |
c1f506c2b1d0
new format strings
William Pitcock <nenolod@atheme-project.org>
parents:
3251
diff
changeset
|
251 "${?artist:${artist} - }${?album:${album} - }${title}", |
c1f506c2b1d0
new format strings
William Pitcock <nenolod@atheme-project.org>
parents:
3251
diff
changeset
|
252 "${?artist:${artist} - }${?album:${album} - }${?track-number:${track-number}. }${title}", |
c1f506c2b1d0
new format strings
William Pitcock <nenolod@atheme-project.org>
parents:
3251
diff
changeset
|
253 "${?artist:${artist} }${?album:[ ${album} ] }${?artist:- }${?track-number:${track-number}. }${title}", |
c1f506c2b1d0
new format strings
William Pitcock <nenolod@atheme-project.org>
parents:
3251
diff
changeset
|
254 "${?album:${album} - }${title}" |
2313 | 255 }; |
256 | |
257 const guint n_titlestring_presets = G_N_ELEMENTS(bmp_titlestring_presets); | |
258 | |
259 const gchar *chardet_detector_presets[] = { | |
2364 | 260 "None", |
261 "Japanese", | |
262 "Taiwanese", | |
263 "Chinese", | |
264 "Korean", | |
265 "Russian", | |
3216
e91acf24afbc
Expose new libguess-ng character detectors in preferences.
William Pitcock <nenolod@atheme-project.org>
parents:
3165
diff
changeset
|
266 "Greek", |
e91acf24afbc
Expose new libguess-ng character detectors in preferences.
William Pitcock <nenolod@atheme-project.org>
parents:
3165
diff
changeset
|
267 "Hebrew", |
e91acf24afbc
Expose new libguess-ng character detectors in preferences.
William Pitcock <nenolod@atheme-project.org>
parents:
3165
diff
changeset
|
268 "Turkish", |
e91acf24afbc
Expose new libguess-ng character detectors in preferences.
William Pitcock <nenolod@atheme-project.org>
parents:
3165
diff
changeset
|
269 "Arabic", |
2313 | 270 #ifdef HAVE_UDET |
2364 | 271 "Universal" |
2313 | 272 #endif |
273 }; | |
274 | |
2364 | 275 const guint n_chardet_detector_presets = G_N_ELEMENTS(chardet_detector_presets); |
2313 | 276 |
277 static bmp_cfg_boolent bmp_boolents[] = { | |
278 {"allow_multiple_instances", &cfg.allow_multiple_instances, TRUE}, | |
279 {"use_realtime", &cfg.use_realtime, TRUE}, | |
280 {"always_show_cb", &cfg.always_show_cb, TRUE}, | |
281 {"convert_underscore", &cfg.convert_underscore, TRUE}, | |
282 {"convert_twenty", &cfg.convert_twenty, TRUE}, | |
283 {"convert_slash", &cfg.convert_slash, TRUE }, | |
284 {"show_numbers_in_pl", &cfg.show_numbers_in_pl, TRUE}, | |
285 {"show_separator_in_pl", &cfg.show_separator_in_pl, TRUE}, | |
286 {"snap_windows", &cfg.snap_windows, TRUE}, | |
287 {"save_window_positions", &cfg.save_window_position, TRUE}, | |
288 {"dim_titlebar", &cfg.dim_titlebar, TRUE}, | |
289 {"get_info_on_load", &cfg.get_info_on_load, TRUE}, | |
290 {"get_info_on_demand", &cfg.get_info_on_demand, TRUE}, | |
291 {"eq_doublesize_linked", &cfg.eq_doublesize_linked, TRUE}, | |
292 {"no_playlist_advance", &cfg.no_playlist_advance, TRUE}, | |
293 {"refresh_file_list", &cfg.refresh_file_list, TRUE}, | |
294 {"sort_jump_to_file", &cfg.sort_jump_to_file, TRUE}, | |
295 {"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
|
296 {"warn_about_win_visibility", &cfg.warn_about_win_visibility, TRUE}, |
2313 | 297 {"use_backslash_as_dir_delimiter", &cfg.use_backslash_as_dir_delimiter, TRUE}, |
298 {"player_shaded", &cfg.player_shaded, TRUE}, | |
299 {"player_visible", &cfg.player_visible, TRUE}, | |
300 {"shuffle", &cfg.shuffle, TRUE}, | |
301 {"repeat", &cfg.repeat, TRUE}, | |
302 {"doublesize", &cfg.doublesize, TRUE}, | |
303 {"autoscroll_songname", &cfg.autoscroll, TRUE}, | |
304 {"stop_after_current_song", &cfg.stopaftersong, TRUE}, | |
305 {"playlist_shaded", &cfg.playlist_shaded, TRUE}, | |
306 {"playlist_visible", &cfg.playlist_visible, TRUE}, | |
307 {"use_fontsets", &cfg.use_fontsets, TRUE}, | |
308 {"mainwin_use_xfont", &cfg.mainwin_use_xfont, FALSE}, | |
309 {"equalizer_visible", &cfg.equalizer_visible, TRUE}, | |
310 {"equalizer_active", &cfg.equalizer_active, TRUE}, | |
311 {"equalizer_shaded", &cfg.equalizer_shaded, TRUE}, | |
312 {"equalizer_autoload", &cfg.equalizer_autoload, TRUE}, | |
313 {"easy_move", &cfg.easy_move, TRUE}, | |
314 {"use_eplugins", &cfg.use_eplugins, TRUE}, | |
315 {"always_on_top", &cfg.always_on_top, TRUE}, | |
316 {"sticky", &cfg.sticky, TRUE}, | |
317 {"random_skin_on_play", &cfg.random_skin_on_play, TRUE}, | |
318 {"pause_between_songs", &cfg.pause_between_songs, TRUE}, | |
319 {"show_wm_decorations", &cfg.show_wm_decorations, TRUE}, | |
320 {"eq_extra_filtering", &cfg.eq_extra_filtering, TRUE}, | |
321 {"analyzer_peaks", &cfg.analyzer_peaks, TRUE}, | |
322 {"custom_cursors", &cfg.custom_cursors, TRUE}, | |
323 {"close_dialog_open", &cfg.close_dialog_open, TRUE}, | |
324 {"close_dialog_add", &cfg.close_dialog_add, TRUE}, | |
325 {"resume_playback_on_startup", &cfg.resume_playback_on_startup, TRUE}, | |
326 {"playlist_detect", &cfg.playlist_detect, TRUE}, | |
327 {"show_filepopup_for_tuple", &cfg.show_filepopup_for_tuple, TRUE}, | |
328 {"recurse_for_cover", &cfg.recurse_for_cover, TRUE}, | |
329 {"use_file_cover", &cfg.use_file_cover, TRUE}, | |
330 {"use_xmms_style_fileselector", &cfg.use_xmms_style_fileselector, TRUE}, | |
331 {"use_extension_probing", &cfg.use_extension_probing, TRUE}, | |
2405 | 332 {"filepopup_showprogressbar", &cfg.filepopup_showprogressbar, TRUE}, |
2805
6295535fbf49
[svn] - add toggle button to keep jtf dialog opened on jump.
yaz
parents:
2788
diff
changeset
|
333 {"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
|
334 {"twoway_scroll", &cfg.twoway_scroll, TRUE}, |
2313 | 335 }; |
336 | |
337 static gint ncfgbent = G_N_ELEMENTS(bmp_boolents); | |
338 | |
339 static bmp_cfg_nument bmp_numents[] = { | |
340 {"player_x", &cfg.player_x, TRUE}, | |
341 {"player_y", &cfg.player_y, TRUE}, | |
342 {"timer_mode", &cfg.timer_mode, TRUE}, | |
343 {"vis_type", &cfg.vis_type, TRUE}, | |
344 {"analyzer_mode", &cfg.analyzer_mode, TRUE}, | |
345 {"analyzer_type", &cfg.analyzer_type, TRUE}, | |
346 {"scope_mode", &cfg.scope_mode, TRUE}, | |
347 {"vu_mode", &cfg.vu_mode, TRUE}, | |
348 {"voiceprint_mode", &cfg.voiceprint_mode, TRUE}, | |
349 {"vis_refresh_rate", &cfg.vis_refresh, TRUE}, | |
350 {"analyzer_falloff", &cfg.analyzer_falloff, TRUE}, | |
351 {"peaks_falloff", &cfg.peaks_falloff, TRUE}, | |
352 {"playlist_x", &cfg.playlist_x, TRUE}, | |
353 {"playlist_y", &cfg.playlist_y, TRUE}, | |
354 {"playlist_width", &cfg.playlist_width, TRUE}, | |
355 {"playlist_height", &cfg.playlist_height, TRUE}, | |
356 {"playlist_position", &cfg.playlist_position, TRUE}, | |
357 {"equalizer_x", &cfg.equalizer_x, TRUE}, | |
358 {"equalizer_y", &cfg.equalizer_y, TRUE}, | |
359 {"snap_distance", &cfg.snap_distance, TRUE}, | |
360 {"pause_between_songs_time", &cfg.pause_between_songs_time, TRUE}, | |
361 {"mouse_wheel_change", &cfg.mouse_change, TRUE}, | |
362 {"scroll_pl_by", &cfg.scroll_pl_by, TRUE}, | |
363 {"titlestring_preset", &cfg.titlestring_preset, TRUE}, | |
364 {"resume_playback_on_startup_time", &cfg.resume_playback_on_startup_time, TRUE}, | |
365 {"output_buffer_size", &cfg.output_buffer_size, TRUE}, | |
366 {"recurse_for_cover_depth", &cfg.recurse_for_cover_depth, TRUE}, | |
367 {"filepopup_pixelsize", &cfg.filepopup_pixelsize, TRUE}, | |
368 {"filepopup_delay", &cfg.filepopup_delay, TRUE}, | |
369 {"colorize_r", &cfg.colorize_r, TRUE}, | |
370 {"colorize_g", &cfg.colorize_g, TRUE}, | |
371 {"colorize_b", &cfg.colorize_b, TRUE}, | |
372 }; | |
373 | |
374 static gint ncfgient = G_N_ELEMENTS(bmp_numents); | |
375 | |
376 static bmp_cfg_strent bmp_strents[] = { | |
377 {"playlist_font", &cfg.playlist_font, TRUE}, | |
378 {"mainwin_font", &cfg.mainwin_font, TRUE}, | |
379 {"eqpreset_default_file", &cfg.eqpreset_default_file, TRUE}, | |
380 {"eqpreset_extension", &cfg.eqpreset_extension, TRUE}, | |
381 {"skin", &cfg.skin, FALSE}, | |
382 {"output_plugin", &cfg.outputplugin, FALSE}, | |
383 {"disabled_iplugins", &cfg.disabled_iplugins, TRUE}, | |
384 {"enabled_gplugins", &cfg.enabled_gplugins, FALSE}, | |
385 {"enabled_vplugins", &cfg.enabled_vplugins, FALSE}, | |
386 {"enabled_eplugins", &cfg.enabled_eplugins, FALSE}, | |
387 {"filesel_path", &cfg.filesel_path, FALSE}, | |
388 {"playlist_path", &cfg.playlist_path, FALSE}, | |
389 {"generic_title_format", &cfg.gentitle_format, TRUE}, | |
390 {"chardet_detector", &cfg.chardet_detector, TRUE}, | |
391 {"chardet_fallback", &cfg.chardet_fallback, TRUE}, | |
392 {"cover_name_include", &cfg.cover_name_include, TRUE}, | |
393 {"cover_name_exclude", &cfg.cover_name_exclude, TRUE}, | |
394 {"session_uri_base", &cfg.session_uri_base, TRUE} | |
395 }; | |
396 | |
397 static gint ncfgsent = G_N_ELEMENTS(bmp_strents); | |
398 | |
399 gchar *bmp_paths[BMP_PATH_COUNT] = {}; | |
400 | |
401 GList *dock_window_list = NULL; | |
402 | |
403 /* XXX: case-sensitivity is bad for lazy nenolods. :( -nenolod */ | |
404 static gchar *pl_candidates[] = { | |
2364 | 405 PLUGIN_FILENAME("ALSA"), |
406 PLUGIN_FILENAME("coreaudio"), | |
407 PLUGIN_FILENAME("OSS"), | |
408 PLUGIN_FILENAME("sun"), | |
409 PLUGIN_FILENAME("ESD"), | |
410 PLUGIN_FILENAME("pulse_audio"), | |
411 PLUGIN_FILENAME("disk_writer"), | |
412 NULL | |
2313 | 413 }; |
414 | |
415 GCond *cond_scan; | |
416 GMutex *mutex_scan; | |
3346
71d8d93f1bad
Implemented TrackChange, StatusChange signals, with a stub for CapsChange.
Ben Tucker <ben.tucker@gmail.com>
parents:
3334
diff
changeset
|
417 #ifdef USE_DBUS |
71d8d93f1bad
Implemented TrackChange, StatusChange signals, with a stub for CapsChange.
Ben Tucker <ben.tucker@gmail.com>
parents:
3334
diff
changeset
|
418 MprisPlayer *mpris; |
71d8d93f1bad
Implemented TrackChange, StatusChange signals, with a stub for CapsChange.
Ben Tucker <ben.tucker@gmail.com>
parents:
3334
diff
changeset
|
419 #endif |
2313 | 420 |
421 static GSList * | |
422 get_feature_list(void) | |
423 { | |
424 GSList *features = NULL; | |
425 | |
426 #ifdef HAVE_GCONF | |
427 features = g_slist_append(features, "GConf"); | |
428 #endif | |
429 | |
430 return features; | |
431 } | |
432 | |
433 static void | |
434 dump_version(void) | |
435 { | |
436 GSList *features; | |
437 | |
438 g_printf("%s %s [%s]", _(application_name), VERSION, svn_stamp); | |
439 | |
440 features = get_feature_list(); | |
441 | |
442 if (features) { | |
443 GSList *item; | |
444 | |
445 g_printf(" ("); | |
446 | |
447 for (item = features; g_slist_next(item); item = g_slist_next(item)) | |
448 g_printf("%s, ", (const gchar *) item->data); | |
449 | |
450 g_printf("%s)", (const gchar *) item->data); | |
451 | |
452 g_slist_free(features); | |
453 } | |
454 | |
455 g_printf("\n"); | |
456 } | |
457 | |
458 const gchar * | |
3334
ea806daf3ef0
rename xmms_get_gentitle_format() to get_gentitle_format().
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3317
diff
changeset
|
459 get_gentitle_format(void) |
2313 | 460 { |
461 guint titlestring_preset = cfg.titlestring_preset; | |
462 | |
463 if (titlestring_preset < n_titlestring_presets) | |
2364 | 464 return bmp_titlestring_presets[titlestring_preset]; |
2313 | 465 |
466 return cfg.gentitle_format; | |
467 } | |
468 | |
469 void | |
470 make_directory(const gchar * path, mode_t mode) | |
471 { | |
2317
49d285f6008b
[svn] Full support for XDG basedir added. The old config doesn't get automatically converted yet.
js
parents:
2313
diff
changeset
|
472 if (g_mkdir_with_parents(path, mode) == 0) |
2313 | 473 return; |
474 | |
2317
49d285f6008b
[svn] Full support for XDG basedir added. The old config doesn't get automatically converted yet.
js
parents:
2313
diff
changeset
|
475 g_printerr(_("Could not create directory (%s): %s\n"), path, |
2313 | 476 g_strerror(errno)); |
477 } | |
478 | |
479 static void | |
480 bmp_make_user_dir(void) | |
481 { | |
482 const mode_t mode755 = S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH; | |
483 | |
484 make_directory(bmp_paths[BMP_PATH_USER_DIR], mode755); | |
485 make_directory(bmp_paths[BMP_PATH_USER_PLUGIN_DIR], mode755); | |
486 make_directory(bmp_paths[BMP_PATH_USER_SKIN_DIR], mode755); | |
487 make_directory(bmp_paths[BMP_PATH_SKIN_THUMB_DIR], mode755); | |
3400
8764498b75ed
Add new playlists directory to paths
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3351
diff
changeset
|
488 make_directory(bmp_paths[BMP_PATH_PLAYLISTS_DIR], mode755); |
2313 | 489 } |
490 | |
491 static void | |
492 bmp_free_paths(void) | |
493 { | |
494 int i; | |
495 | |
496 for (i = 0; i < BMP_PATH_COUNT; i++) | |
497 { | |
498 g_free(bmp_paths[i]); | |
499 bmp_paths[i] = 0; | |
500 } | |
501 } | |
502 | |
2317
49d285f6008b
[svn] Full support for XDG basedir added. The old config doesn't get automatically converted yet.
js
parents:
2313
diff
changeset
|
503 static void |
49d285f6008b
[svn] Full support for XDG basedir added. The old config doesn't get automatically converted yet.
js
parents:
2313
diff
changeset
|
504 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
|
505 { |
2364 | 506 char *xdg_config_home; |
507 char *xdg_data_home; | |
508 char *xdg_cache_home; | |
2313 | 509 |
2364 | 510 xdg_config_home = (getenv("XDG_CONFIG_HOME") == NULL |
511 ? g_build_filename(g_get_home_dir(), ".config", NULL) | |
512 : g_strdup(getenv("XDG_CONFIG_HOME"))); | |
513 xdg_data_home = (getenv("XDG_DATA_HOME") == NULL | |
514 ? g_build_filename(g_get_home_dir(), ".local", "share", NULL) | |
515 : g_strdup(getenv("XDG_DATA_HOME"))); | |
516 xdg_cache_home = (getenv("XDG_CACHE_HOME") == NULL | |
517 ? g_build_filename(g_get_home_dir(), ".cache", NULL) | |
518 : g_strdup(getenv("XDG_CACHE_HOME"))); | |
2313 | 519 |
2364 | 520 bmp_paths[BMP_PATH_USER_DIR] = |
521 g_build_filename(xdg_config_home, "audacious", NULL); | |
522 bmp_paths[BMP_PATH_USER_SKIN_DIR] = | |
523 g_build_filename(xdg_data_home, "audacious", "Skins", NULL); | |
524 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
|
525 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
|
526 |
2364 | 527 bmp_paths[BMP_PATH_SKIN_THUMB_DIR] = |
528 g_build_filename(xdg_cache_home, "audacious", "thumbs", NULL); | |
2313 | 529 |
3400
8764498b75ed
Add new playlists directory to paths
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3351
diff
changeset
|
530 bmp_paths[BMP_PATH_PLAYLISTS_DIR] = |
8764498b75ed
Add new playlists directory to paths
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3351
diff
changeset
|
531 g_build_filename(bmp_paths[BMP_PATH_USER_DIR], "playlists", NULL); |
8764498b75ed
Add new playlists directory to paths
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3351
diff
changeset
|
532 |
2364 | 533 bmp_paths[BMP_PATH_CONFIG_FILE] = |
534 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
|
535 #ifdef HAVE_XSPF_PLAYLIST |
2364 | 536 bmp_paths[BMP_PATH_PLAYLIST_FILE] = |
537 g_build_filename(bmp_paths[BMP_PATH_USER_DIR], | |
538 "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
|
539 #else |
2364 | 540 bmp_paths[BMP_PATH_PLAYLIST_FILE] = |
541 g_build_filename(bmp_paths[BMP_PATH_USER_DIR], | |
542 "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
|
543 #endif |
2364 | 544 bmp_paths[BMP_PATH_ACCEL_FILE] = |
545 g_build_filename(bmp_paths[BMP_PATH_USER_DIR], "accels", NULL); | |
546 bmp_paths[BMP_PATH_LOG_FILE] = | |
547 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
|
548 |
2463 | 549 bmp_paths[BMP_PATH_GTKRC_FILE] = |
2570 | 550 g_build_filename(bmp_paths[BMP_PATH_USER_DIR], "gtkrc", NULL); |
2463 | 551 |
2364 | 552 g_free(xdg_config_home); |
553 g_free(xdg_data_home); | |
554 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
|
555 |
2364 | 556 g_atexit(bmp_free_paths); |
2313 | 557 } |
558 | |
559 void | |
2682
c3cd6e47faf6
[svn] - make the evil 'reload plugins' button behave a bit better
giacomo
parents:
2662
diff
changeset
|
560 bmp_config_free(void) |
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 gint i; |
c3cd6e47faf6
[svn] - make the evil 'reload plugins' button behave a bit better
giacomo
parents:
2662
diff
changeset
|
563 for (i = 0; i < ncfgsent; ++i) { |
c3cd6e47faf6
[svn] - make the evil 'reload plugins' button behave a bit better
giacomo
parents:
2662
diff
changeset
|
564 if ( *(bmp_strents[i].se_vloc) != NULL ) |
c3cd6e47faf6
[svn] - make the evil 'reload plugins' button behave a bit better
giacomo
parents:
2662
diff
changeset
|
565 { |
c3cd6e47faf6
[svn] - make the evil 'reload plugins' button behave a bit better
giacomo
parents:
2662
diff
changeset
|
566 g_free( *(bmp_strents[i].se_vloc) ); |
c3cd6e47faf6
[svn] - make the evil 'reload plugins' button behave a bit better
giacomo
parents:
2662
diff
changeset
|
567 *(bmp_strents[i].se_vloc) = NULL; |
c3cd6e47faf6
[svn] - make the evil 'reload plugins' button behave a bit better
giacomo
parents:
2662
diff
changeset
|
568 } |
c3cd6e47faf6
[svn] - make the evil 'reload plugins' button behave a bit better
giacomo
parents:
2662
diff
changeset
|
569 } |
c3cd6e47faf6
[svn] - make the evil 'reload plugins' button behave a bit better
giacomo
parents:
2662
diff
changeset
|
570 } |
c3cd6e47faf6
[svn] - make the evil 'reload plugins' button behave a bit better
giacomo
parents:
2662
diff
changeset
|
571 |
c3cd6e47faf6
[svn] - make the evil 'reload plugins' button behave a bit better
giacomo
parents:
2662
diff
changeset
|
572 void |
2313 | 573 bmp_config_load(void) |
574 { | |
575 ConfigDb *db; | |
576 gint i, length; | |
577 | |
578 memcpy(&cfg, &bmp_default_config, sizeof(BmpConfig)); | |
579 | |
580 db = bmp_cfg_db_open(); | |
581 for (i = 0; i < ncfgbent; ++i) { | |
582 bmp_cfg_db_get_bool(db, NULL, | |
583 bmp_boolents[i].be_vname, | |
584 bmp_boolents[i].be_vloc); | |
585 } | |
586 | |
587 for (i = 0; i < ncfgient; ++i) { | |
588 bmp_cfg_db_get_int(db, NULL, | |
589 bmp_numents[i].ie_vname, | |
590 bmp_numents[i].ie_vloc); | |
591 } | |
592 | |
593 for (i = 0; i < ncfgsent; ++i) { | |
594 bmp_cfg_db_get_string(db, NULL, | |
595 bmp_strents[i].se_vname, | |
596 bmp_strents[i].se_vloc); | |
597 } | |
598 | |
599 /* Preset */ | |
600 bmp_cfg_db_get_float(db, NULL, "equalizer_preamp", &cfg.equalizer_preamp); | |
601 for (i = 0; i < 10; i++) { | |
602 gchar eqtext[18]; | |
603 | |
604 g_snprintf(eqtext, sizeof(eqtext), "equalizer_band%d", i); | |
605 bmp_cfg_db_get_float(db, NULL, eqtext, &cfg.equalizer_bands[i]); | |
606 } | |
607 | |
608 /* History */ | |
609 if (bmp_cfg_db_get_int(db, NULL, "url_history_length", &length)) { | |
610 for (i = 1; i <= length; i++) { | |
611 gchar str[19], *tmp; | |
612 | |
613 g_snprintf(str, sizeof(str), "url_history%d", i); | |
614 if (bmp_cfg_db_get_string(db, NULL, str, &tmp)) | |
615 cfg.url_history = g_list_append(cfg.url_history, tmp); | |
616 } | |
617 } | |
618 | |
619 bmp_cfg_db_close(db); | |
620 | |
621 | |
622 if (cfg.playlist_font && strlen(cfg.playlist_font) == 0) { | |
623 g_free(cfg.playlist_font); | |
624 cfg.playlist_font = NULL; | |
625 } | |
626 | |
627 if (cfg.mainwin_font && strlen(cfg.mainwin_font) == 0) { | |
628 g_free(cfg.mainwin_font); | |
629 cfg.mainwin_font = NULL; | |
630 } | |
631 | |
632 if (!cfg.playlist_font) | |
633 cfg.playlist_font = g_strdup(PLAYLISTWIN_DEFAULT_FONT); | |
634 | |
635 if (!cfg.mainwin_font) | |
636 cfg.mainwin_font = g_strdup(MAINWIN_DEFAULT_FONT); | |
637 | |
638 if (!cfg.gentitle_format) | |
3317 | 639 cfg.gentitle_format = g_strdup("${?artist:${artist} - }${?album:${album} - }${title}"); |
2313 | 640 |
641 if (!cfg.outputplugin) { | |
2364 | 642 gint iter; |
2313 | 643 gchar *pl_path = g_build_filename(PLUGIN_DIR, plugin_dir_list[0], NULL); |
644 | |
645 for (iter = 0; pl_candidates[iter] != NULL && cfg.outputplugin == NULL; iter++) | |
2364 | 646 { |
647 cfg.outputplugin = find_file_recursively(pl_path, pl_candidates[iter]); | |
648 } | |
2313 | 649 |
650 g_free(pl_path); | |
651 } | |
652 | |
653 if (!cfg.eqpreset_default_file) | |
654 cfg.eqpreset_default_file = g_strdup(EQUALIZER_DEFAULT_DIR_PRESET); | |
655 | |
656 if (!cfg.eqpreset_extension) | |
657 cfg.eqpreset_extension = g_strdup(EQUALIZER_DEFAULT_PRESET_EXT); | |
658 | |
659 if (!cfg.chardet_detector) | |
660 cfg.chardet_detector = g_strdup(""); | |
661 | |
662 if (!cfg.chardet_fallback) | |
663 cfg.chardet_fallback = g_strdup(""); | |
664 | |
665 if (!cfg.cover_name_include) | |
2364 | 666 cfg.cover_name_include = g_strdup(""); |
2313 | 667 |
668 if (!cfg.cover_name_exclude) | |
2364 | 669 cfg.cover_name_exclude = g_strdup("back"); |
2313 | 670 |
671 if (!cfg.session_uri_base) | |
672 cfg.session_uri_base = g_strdup(""); | |
673 | |
674 /* at least one of these should be true */ | |
675 if ((!cfg.get_info_on_demand) && (!cfg.get_info_on_load)) | |
676 cfg.get_info_on_demand = TRUE; | |
677 } | |
678 | |
3481
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
679 static gboolean |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
680 save_extra_playlist(const gchar * path, const gchar * basename, |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
681 gpointer savedlist) |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
682 { |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
683 GList *playlists, *iter; |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
684 GList **saved; |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
685 Playlist *playlist; |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
686 int found; |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
687 gchar *filename; |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
688 |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
689 playlists = playlist_get_playlists(); |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
690 saved = (GList **) savedlist; |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
691 |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
692 found = 0; |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
693 for (iter = playlists; iter; iter = iter->next) { |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
694 playlist = (Playlist *) iter->data; |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
695 if (g_list_find(*saved, playlist)) continue; |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
696 filename = playlist_filename_get(playlist); |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
697 if (!filename) continue; |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
698 if (strcmp(filename, path) == 0) { |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
699 /* Save playlist */ |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
700 playlist_save(playlist, path); |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
701 *saved = g_list_prepend(*saved, playlist); |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
702 found = 1; |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
703 g_free(filename); |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
704 break; |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
705 } |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
706 g_free(filename); |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
707 } |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
708 |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
709 if(!found) { |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
710 /* Remove playlist */ |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
711 unlink(path); |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
712 } |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
713 |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
714 return FALSE; /* process other playlists */ |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
715 } |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
716 |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
717 static void |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
718 save_other_playlists(GList *saved) |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
719 { |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
720 GList *playlists, *iter; |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
721 Playlist *playlist; |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
722 gchar *pos, *ext, *basename, *filename, *newbasename; |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
723 int i, num, isdigits; |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
724 |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
725 playlists = playlist_get_playlists(); |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
726 for(iter = playlists; iter; iter = iter->next) { |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
727 playlist = (Playlist *) iter->data; |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
728 if (g_list_find(saved, playlist)) continue; |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
729 filename = playlist_filename_get(playlist); |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
730 if (!filename || !filename[0] |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
731 || g_file_test(filename, G_FILE_TEST_IS_DIR)) { |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
732 /* default basename */ |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
733 #ifdef HAVE_XSPF_PLAYLIST |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
734 basename = g_strdup("playlist_01.xspf"); |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
735 #else |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
736 basename = g_strdup("playlist_01.m3u"); |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
737 #endif |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
738 } else { |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
739 basename = g_path_get_basename(filename); |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
740 } |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
741 g_free(filename); |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
742 if ((pos = strrchr(basename, '.'))) { |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
743 *pos = '\0'; |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
744 } |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
745 #ifdef HAVE_XSPF_PLAYLIST |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
746 ext = ".xspf"; |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
747 #else |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
748 ext = ".m3u"; |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
749 #endif |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
750 num = -1; |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
751 if ((pos = strrchr(basename, '_'))) { |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
752 isdigits = 0; |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
753 for (i=1; pos[i]; i++) { |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
754 if (!g_ascii_isdigit(pos[i])) { |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
755 isdigits = 0; |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
756 break; |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
757 } |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
758 isdigits = 1; |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
759 } |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
760 if (isdigits) { |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
761 num = atoi(pos+1) + 1; |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
762 *pos = '\0'; |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
763 } |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
764 } |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
765 /* attempt to generate unique filename */ |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
766 filename = NULL; |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
767 do { |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
768 g_free(filename); |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
769 if (num < 0) { |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
770 /* try saving without number first */ |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
771 newbasename = g_strdup_printf("%s%s", basename, ext); |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
772 num = 1; |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
773 } else { |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
774 newbasename = g_strdup_printf("%s_%02d%s", basename, num, ext); |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
775 num++; |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
776 if (num < 0) { |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
777 g_warning("Playlist number in filename overflowed." |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
778 " Not saving playlist.\n"); |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
779 goto cleanup; |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
780 } |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
781 } |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
782 filename = g_build_filename(bmp_paths[BMP_PATH_PLAYLISTS_DIR], |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
783 newbasename, NULL); |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
784 g_free(newbasename); |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
785 } while (g_file_test(filename, G_FILE_TEST_EXISTS)); |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
786 |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
787 playlist_save(playlist, filename); |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
788 cleanup: |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
789 g_free(filename); |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
790 g_free(basename); |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
791 } |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
792 } |
2313 | 793 |
794 void | |
795 bmp_config_save(void) | |
796 { | |
797 GList *node; | |
798 gchar *str; | |
799 gint i, cur_pb_time; | |
800 ConfigDb *db; | |
3481
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
801 GList *saved; |
2313 | 802 Playlist *playlist = playlist_get_active(); |
803 | |
804 cfg.disabled_iplugins = input_stringify_disabled_list(); | |
805 | |
806 | |
807 db = bmp_cfg_db_open(); | |
808 | |
809 for (i = 0; i < ncfgbent; ++i) | |
810 if (bmp_boolents[i].be_wrt) | |
811 bmp_cfg_db_set_bool(db, NULL, | |
812 bmp_boolents[i].be_vname, | |
813 *bmp_boolents[i].be_vloc); | |
814 | |
815 for (i = 0; i < ncfgient; ++i) | |
816 if (bmp_numents[i].ie_wrt) | |
817 bmp_cfg_db_set_int(db, NULL, | |
818 bmp_numents[i].ie_vname, | |
819 *bmp_numents[i].ie_vloc); | |
820 | |
821 /* This is a bit lame .. it'll end up being written twice, | |
822 * could do with being done a bit neater. -larne */ | |
823 bmp_cfg_db_set_int(db, NULL, "playlist_position", | |
824 playlist_get_position(playlist)); | |
825 | |
2530 | 826 /* FIXME: we're looking up SkinnedWindow::x &c ourselves here. |
827 * this isn't exactly right. -nenolod | |
828 */ | |
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
|
829 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
|
830 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
|
831 { |
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
|
832 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
|
833 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
|
834 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
|
835 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
|
836 } |
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
|
837 |
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
|
838 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
|
839 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
|
840 { |
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
|
841 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
|
842 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
|
843 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
|
844 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
|
845 } |
2530 | 846 |
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
|
847 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
|
848 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
|
849 { |
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
|
850 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
|
851 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
|
852 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
|
853 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
|
854 } |
2530 | 855 |
2313 | 856 bmp_cfg_db_set_bool(db, NULL, "mainwin_use_xfont", |
2364 | 857 cfg.mainwin_use_xfont); |
2313 | 858 |
859 for (i = 0; i < ncfgsent; ++i) { | |
860 if (bmp_strents[i].se_wrt) | |
861 bmp_cfg_db_set_string(db, NULL, | |
862 bmp_strents[i].se_vname, | |
863 *bmp_strents[i].se_vloc); | |
864 } | |
865 | |
866 bmp_cfg_db_set_float(db, NULL, "equalizer_preamp", cfg.equalizer_preamp); | |
867 | |
868 for (i = 0; i < 10; i++) { | |
869 str = g_strdup_printf("equalizer_band%d", i); | |
870 bmp_cfg_db_set_float(db, NULL, str, cfg.equalizer_bands[i]); | |
871 g_free(str); | |
872 } | |
873 | |
874 if (bmp_active_skin != NULL) | |
875 { | |
876 if (bmp_active_skin->path) | |
877 bmp_cfg_db_set_string(db, NULL, "skin", bmp_active_skin->path); | |
878 else | |
879 bmp_cfg_db_unset_key(db, NULL, "skin"); | |
880 } | |
881 | |
882 if (get_current_output_plugin()) | |
883 bmp_cfg_db_set_string(db, NULL, "output_plugin", | |
884 get_current_output_plugin()->filename); | |
885 else | |
886 bmp_cfg_db_unset_key(db, NULL, "output_plugin"); | |
887 | |
888 str = general_stringify_enabled_list(); | |
889 if (str) { | |
890 bmp_cfg_db_set_string(db, NULL, "enabled_gplugins", str); | |
891 g_free(str); | |
892 } | |
893 else | |
894 bmp_cfg_db_unset_key(db, NULL, "enabled_gplugins"); | |
895 | |
896 str = vis_stringify_enabled_list(); | |
897 if (str) { | |
898 bmp_cfg_db_set_string(db, NULL, "enabled_vplugins", str); | |
899 g_free(str); | |
900 } | |
901 else | |
902 bmp_cfg_db_unset_key(db, NULL, "enabled_vplugins"); | |
903 | |
904 str = effect_stringify_enabled_list(); | |
905 if (str) { | |
906 bmp_cfg_db_set_string(db, NULL, "enabled_eplugins", str); | |
907 g_free(str); | |
908 } | |
909 else | |
910 bmp_cfg_db_unset_key(db, NULL, "enabled_eplugins"); | |
911 | |
912 if (cfg.filesel_path) | |
913 bmp_cfg_db_set_string(db, NULL, "filesel_path", cfg.filesel_path); | |
914 | |
915 if (cfg.playlist_path) | |
916 bmp_cfg_db_set_string(db, NULL, "playlist_path", cfg.playlist_path); | |
917 | |
918 bmp_cfg_db_set_int(db, NULL, "url_history_length", | |
919 g_list_length(cfg.url_history)); | |
920 | |
921 for (node = cfg.url_history, i = 1; node; node = g_list_next(node), i++) { | |
922 str = g_strdup_printf("url_history%d", i); | |
923 bmp_cfg_db_set_string(db, NULL, str, node->data); | |
924 g_free(str); | |
925 } | |
926 | |
927 if (playback_get_playing()) { | |
2364 | 928 cur_pb_time = playback_get_time(); |
2313 | 929 } else |
2364 | 930 cur_pb_time = -1; |
2313 | 931 cfg.resume_playback_on_startup_time = cur_pb_time; |
932 bmp_cfg_db_set_int(db, NULL, "resume_playback_on_startup_time", | |
2364 | 933 cfg.resume_playback_on_startup_time); |
2313 | 934 |
935 bmp_cfg_db_close(db); | |
936 | |
937 playlist_save(playlist, bmp_paths[BMP_PATH_PLAYLIST_FILE]); | |
3481
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
938 |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
939 /* Save extra playlists that were loaded from PLAYLISTS_DIR */ |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
940 saved = NULL; |
3530
08dae20c75f0
Don't store default playlist in the playlists/ directory.
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3526
diff
changeset
|
941 saved = g_list_prepend(saved, playlist); /* don't save default again */ |
3481
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
942 if(!dir_foreach(bmp_paths[BMP_PATH_PLAYLISTS_DIR], save_extra_playlist, |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
943 &saved, NULL)) { |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
944 g_warning("Could not save extra playlists\n"); |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
945 } |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
946 |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
947 /* Save other playlists to PLAYLISTS_DIR */ |
308e5fb348db
Save extra playlists on exit
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3480
diff
changeset
|
948 save_other_playlists(saved); |
2313 | 949 } |
950 | |
951 static void | |
952 bmp_set_default_icon(void) | |
953 { | |
954 GdkPixbuf *icon; | |
955 | |
956 icon = gdk_pixbuf_new_from_xpm_data((const gchar **) audacious_player_xpm); | |
957 gtk_window_set_default_icon(icon); | |
958 g_object_unref(icon); | |
959 } | |
960 | |
3525
540e49d1d87c
macos: Set an application icon in the dock.
William Pitcock <nenolod@atheme.org>
parents:
3400
diff
changeset
|
961 #ifdef GDK_WINDOWING_QUARTZ |
540e49d1d87c
macos: Set an application icon in the dock.
William Pitcock <nenolod@atheme.org>
parents:
3400
diff
changeset
|
962 static void |
540e49d1d87c
macos: Set an application icon in the dock.
William Pitcock <nenolod@atheme.org>
parents:
3400
diff
changeset
|
963 set_dock_icon(void) |
540e49d1d87c
macos: Set an application icon in the dock.
William Pitcock <nenolod@atheme.org>
parents:
3400
diff
changeset
|
964 { |
540e49d1d87c
macos: Set an application icon in the dock.
William Pitcock <nenolod@atheme.org>
parents:
3400
diff
changeset
|
965 GdkPixbuf *icon, *pixbuf; |
540e49d1d87c
macos: Set an application icon in the dock.
William Pitcock <nenolod@atheme.org>
parents:
3400
diff
changeset
|
966 CGColorSpaceRef colorspace; |
540e49d1d87c
macos: Set an application icon in the dock.
William Pitcock <nenolod@atheme.org>
parents:
3400
diff
changeset
|
967 CGDataProviderRef data_provider; |
540e49d1d87c
macos: Set an application icon in the dock.
William Pitcock <nenolod@atheme.org>
parents:
3400
diff
changeset
|
968 CGImageRef image; |
540e49d1d87c
macos: Set an application icon in the dock.
William Pitcock <nenolod@atheme.org>
parents:
3400
diff
changeset
|
969 gpointer data; |
540e49d1d87c
macos: Set an application icon in the dock.
William Pitcock <nenolod@atheme.org>
parents:
3400
diff
changeset
|
970 gint rowstride, pixbuf_width, pixbuf_height; |
540e49d1d87c
macos: Set an application icon in the dock.
William Pitcock <nenolod@atheme.org>
parents:
3400
diff
changeset
|
971 gboolean has_alpha; |
540e49d1d87c
macos: Set an application icon in the dock.
William Pitcock <nenolod@atheme.org>
parents:
3400
diff
changeset
|
972 |
540e49d1d87c
macos: Set an application icon in the dock.
William Pitcock <nenolod@atheme.org>
parents:
3400
diff
changeset
|
973 icon = gdk_pixbuf_new_from_xpm_data((const gchar **) audacious_player_xpm); |
540e49d1d87c
macos: Set an application icon in the dock.
William Pitcock <nenolod@atheme.org>
parents:
3400
diff
changeset
|
974 pixbuf = gdk_pixbuf_scale_simple(icon, 128, 128, GDK_INTERP_BILINEAR); |
540e49d1d87c
macos: Set an application icon in the dock.
William Pitcock <nenolod@atheme.org>
parents:
3400
diff
changeset
|
975 |
540e49d1d87c
macos: Set an application icon in the dock.
William Pitcock <nenolod@atheme.org>
parents:
3400
diff
changeset
|
976 data = gdk_pixbuf_get_pixels(pixbuf); |
540e49d1d87c
macos: Set an application icon in the dock.
William Pitcock <nenolod@atheme.org>
parents:
3400
diff
changeset
|
977 pixbuf_width = gdk_pixbuf_get_width(pixbuf); |
540e49d1d87c
macos: Set an application icon in the dock.
William Pitcock <nenolod@atheme.org>
parents:
3400
diff
changeset
|
978 pixbuf_height = gdk_pixbuf_get_height(pixbuf); |
540e49d1d87c
macos: Set an application icon in the dock.
William Pitcock <nenolod@atheme.org>
parents:
3400
diff
changeset
|
979 rowstride = gdk_pixbuf_get_rowstride(pixbuf); |
540e49d1d87c
macos: Set an application icon in the dock.
William Pitcock <nenolod@atheme.org>
parents:
3400
diff
changeset
|
980 has_alpha = gdk_pixbuf_get_has_alpha(pixbuf); |
540e49d1d87c
macos: Set an application icon in the dock.
William Pitcock <nenolod@atheme.org>
parents:
3400
diff
changeset
|
981 |
540e49d1d87c
macos: Set an application icon in the dock.
William Pitcock <nenolod@atheme.org>
parents:
3400
diff
changeset
|
982 /* create the colourspace for the CGImage. */ |
540e49d1d87c
macos: Set an application icon in the dock.
William Pitcock <nenolod@atheme.org>
parents:
3400
diff
changeset
|
983 colorspace = CGColorSpaceCreateDeviceRGB(); |
540e49d1d87c
macos: Set an application icon in the dock.
William Pitcock <nenolod@atheme.org>
parents:
3400
diff
changeset
|
984 data_provider = CGDataProviderCreateWithData(NULL, data, pixbuf_height * rowstride, NULL); |
540e49d1d87c
macos: Set an application icon in the dock.
William Pitcock <nenolod@atheme.org>
parents:
3400
diff
changeset
|
985 image = CGImageCreate(pixbuf_width, pixbuf_height, 8, |
540e49d1d87c
macos: Set an application icon in the dock.
William Pitcock <nenolod@atheme.org>
parents:
3400
diff
changeset
|
986 has_alpha ? 32 : 24, rowstride, colorspace, |
540e49d1d87c
macos: Set an application icon in the dock.
William Pitcock <nenolod@atheme.org>
parents:
3400
diff
changeset
|
987 has_alpha ? kCGImageAlphaLast : 0, |
540e49d1d87c
macos: Set an application icon in the dock.
William Pitcock <nenolod@atheme.org>
parents:
3400
diff
changeset
|
988 data_provider, NULL, FALSE, |
540e49d1d87c
macos: Set an application icon in the dock.
William Pitcock <nenolod@atheme.org>
parents:
3400
diff
changeset
|
989 kCGRenderingIntentDefault); |
540e49d1d87c
macos: Set an application icon in the dock.
William Pitcock <nenolod@atheme.org>
parents:
3400
diff
changeset
|
990 |
540e49d1d87c
macos: Set an application icon in the dock.
William Pitcock <nenolod@atheme.org>
parents:
3400
diff
changeset
|
991 /* release the colourspace and data provider, we have what we want. */ |
540e49d1d87c
macos: Set an application icon in the dock.
William Pitcock <nenolod@atheme.org>
parents:
3400
diff
changeset
|
992 CGDataProviderRelease(data_provider); |
540e49d1d87c
macos: Set an application icon in the dock.
William Pitcock <nenolod@atheme.org>
parents:
3400
diff
changeset
|
993 CGColorSpaceRelease(colorspace); |
540e49d1d87c
macos: Set an application icon in the dock.
William Pitcock <nenolod@atheme.org>
parents:
3400
diff
changeset
|
994 |
540e49d1d87c
macos: Set an application icon in the dock.
William Pitcock <nenolod@atheme.org>
parents:
3400
diff
changeset
|
995 /* set the dock tile images */ |
540e49d1d87c
macos: Set an application icon in the dock.
William Pitcock <nenolod@atheme.org>
parents:
3400
diff
changeset
|
996 SetApplicationDockTileImage(image); |
540e49d1d87c
macos: Set an application icon in the dock.
William Pitcock <nenolod@atheme.org>
parents:
3400
diff
changeset
|
997 |
540e49d1d87c
macos: Set an application icon in the dock.
William Pitcock <nenolod@atheme.org>
parents:
3400
diff
changeset
|
998 #if 0 |
540e49d1d87c
macos: Set an application icon in the dock.
William Pitcock <nenolod@atheme.org>
parents:
3400
diff
changeset
|
999 /* and release */ |
540e49d1d87c
macos: Set an application icon in the dock.
William Pitcock <nenolod@atheme.org>
parents:
3400
diff
changeset
|
1000 CGImageRelease(image); |
540e49d1d87c
macos: Set an application icon in the dock.
William Pitcock <nenolod@atheme.org>
parents:
3400
diff
changeset
|
1001 g_object_unref(icon); |
540e49d1d87c
macos: Set an application icon in the dock.
William Pitcock <nenolod@atheme.org>
parents:
3400
diff
changeset
|
1002 g_object_unref(pixbuf); |
540e49d1d87c
macos: Set an application icon in the dock.
William Pitcock <nenolod@atheme.org>
parents:
3400
diff
changeset
|
1003 #endif |
540e49d1d87c
macos: Set an application icon in the dock.
William Pitcock <nenolod@atheme.org>
parents:
3400
diff
changeset
|
1004 } |
540e49d1d87c
macos: Set an application icon in the dock.
William Pitcock <nenolod@atheme.org>
parents:
3400
diff
changeset
|
1005 #endif |
540e49d1d87c
macos: Set an application icon in the dock.
William Pitcock <nenolod@atheme.org>
parents:
3400
diff
changeset
|
1006 |
2313 | 1007 static void |
1008 register_aud_stock_icons(void) | |
1009 { | |
1010 GtkIconFactory *iconfactory = gtk_icon_factory_new(); | |
1011 GtkIconSet *iconset; | |
1012 GdkPixbuf *pixbuf; | |
1013 | |
1014 /* pick images in icons-csource.h */ | |
1015 pixbuf = gdk_pixbuf_new_from_inline( -1 , removedups_pixbuf , FALSE , NULL ); | |
1016 iconset = gtk_icon_set_new_from_pixbuf( pixbuf ); g_object_unref( pixbuf ); | |
1017 gtk_icon_factory_add( iconfactory , AUD_STOCK_REMOVEDUPS , iconset ); | |
1018 pixbuf = gdk_pixbuf_new_from_inline( -1 , removeunavail_pixbuf , FALSE , NULL ); | |
1019 iconset = gtk_icon_set_new_from_pixbuf( pixbuf ); g_object_unref( pixbuf ); | |
1020 gtk_icon_factory_add( iconfactory , AUD_STOCK_REMOVEUNAVAIL , iconset ); | |
1021 pixbuf = gdk_pixbuf_new_from_inline( -1 , randomizepl_pixbuf , FALSE , NULL ); | |
1022 iconset = gtk_icon_set_new_from_pixbuf( pixbuf ); g_object_unref( pixbuf ); | |
1023 gtk_icon_factory_add( iconfactory , AUD_STOCK_RANDOMIZEPL , iconset ); | |
1024 pixbuf = gdk_pixbuf_new_from_inline( -1 , sortbytitle_pixbuf , FALSE , NULL ); | |
1025 iconset = gtk_icon_set_new_from_pixbuf( pixbuf ); g_object_unref( pixbuf ); | |
1026 gtk_icon_factory_add( iconfactory , AUD_STOCK_SORTBYTITLE , iconset ); | |
1027 pixbuf = gdk_pixbuf_new_from_inline( -1 , sortbyfilename_pixbuf , FALSE , NULL ); | |
1028 iconset = gtk_icon_set_new_from_pixbuf( pixbuf ); g_object_unref( pixbuf ); | |
1029 gtk_icon_factory_add( iconfactory , AUD_STOCK_SORTBYFILENAME , iconset ); | |
1030 pixbuf = gdk_pixbuf_new_from_inline( -1 , sortbyartist_pixbuf , FALSE , NULL ); | |
1031 iconset = gtk_icon_set_new_from_pixbuf( pixbuf ); g_object_unref( pixbuf ); | |
1032 gtk_icon_factory_add( iconfactory , AUD_STOCK_SORTBYARTIST , iconset ); | |
1033 pixbuf = gdk_pixbuf_new_from_inline( -1 , sortbypathfile_pixbuf , FALSE , NULL ); | |
1034 iconset = gtk_icon_set_new_from_pixbuf( pixbuf ); g_object_unref( pixbuf ); | |
1035 gtk_icon_factory_add( iconfactory , AUD_STOCK_SORTBYPATHFILE , iconset ); | |
1036 pixbuf = gdk_pixbuf_new_from_inline( -1 , selectnone_pixbuf , FALSE , NULL ); | |
1037 iconset = gtk_icon_set_new_from_pixbuf( pixbuf ); g_object_unref( pixbuf ); | |
1038 gtk_icon_factory_add( iconfactory , AUD_STOCK_SELECTNONE , iconset ); | |
1039 pixbuf = gdk_pixbuf_new_from_inline( -1 , selectall_pixbuf , FALSE , NULL ); | |
1040 iconset = gtk_icon_set_new_from_pixbuf( pixbuf ); g_object_unref( pixbuf ); | |
1041 gtk_icon_factory_add( iconfactory , AUD_STOCK_SELECTALL , iconset ); | |
1042 pixbuf = gdk_pixbuf_new_from_inline( -1 , selectinvert_pixbuf , FALSE , NULL ); | |
1043 iconset = gtk_icon_set_new_from_pixbuf( pixbuf ); g_object_unref( pixbuf ); | |
1044 gtk_icon_factory_add( iconfactory , AUD_STOCK_SELECTINVERT , iconset ); | |
1045 pixbuf = gdk_pixbuf_new_from_inline( -1 , invertpl_pixbuf , FALSE , NULL ); | |
1046 iconset = gtk_icon_set_new_from_pixbuf( pixbuf ); g_object_unref( pixbuf ); | |
1047 gtk_icon_factory_add( iconfactory , AUD_STOCK_INVERTPL , iconset ); | |
1048 pixbuf = gdk_pixbuf_new_from_inline( -1 , queuetoggle_pixbuf , FALSE , NULL ); | |
1049 iconset = gtk_icon_set_new_from_pixbuf( pixbuf ); g_object_unref( pixbuf ); | |
1050 gtk_icon_factory_add( iconfactory , AUD_STOCK_QUEUETOGGLE , iconset ); | |
1051 pixbuf = gdk_pixbuf_new_from_inline( -1 , info_pixbuf , FALSE , NULL ); | |
1052 iconset = gtk_icon_set_new_from_pixbuf( pixbuf ); g_object_unref( pixbuf ); | |
1053 gtk_icon_factory_add( iconfactory , AUD_STOCK_INFO , iconset ); | |
1054 pixbuf = gdk_pixbuf_new_from_inline( -1 , playlist_pixbuf , FALSE , NULL ); | |
1055 iconset = gtk_icon_set_new_from_pixbuf( pixbuf ); g_object_unref( pixbuf ); | |
1056 gtk_icon_factory_add( iconfactory , AUD_STOCK_PLAYLIST , iconset ); | |
1057 | |
1058 gtk_icon_factory_add_default( iconfactory ); | |
1059 g_object_unref( iconfactory ); | |
1060 } | |
1061 | |
2411 | 1062 static GOptionEntry cmd_entries[] = { |
2448
ff135e2ba10e
[svn] - mark some strings used by GOption as translatable
nenolod
parents:
2420
diff
changeset
|
1063 {"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
|
1064 {"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
|
1065 {"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
|
1066 {"pause", 'u', 0, G_OPTION_ARG_NONE, &options.pause, N_("Pause current song"), NULL}, |
2475 | 1067 {"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
|
1068 {"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
|
1069 {"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
|
1070 {"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
|
1071 {"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
|
1072 {"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
|
1073 {"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
|
1074 {"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
|
1075 {"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
|
1076 {"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
|
1077 {"version", 'v', 0, G_OPTION_ARG_NONE, &options.version, N_("Show version and builtin features"), NULL}, |
2411 | 1078 {G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &options.filenames, N_("FILE..."), NULL}, |
1079 {NULL}, | |
1080 }; | |
2313 | 1081 |
1082 static void | |
1083 handle_cmd_line_options(BmpCmdLineOpt * options, | |
1084 gboolean remote) | |
1085 { | |
2411 | 1086 gchar **filenames = options->filenames; |
2785 | 1087 #ifdef USE_DBUS |
1088 DBusGProxy *session = audacious_get_dbus_proxy(); | |
2727
14f9a629ba9c
[svn] - rename xmms_remote namespace to audacious_remote namespace
nenolod
parents:
2717
diff
changeset
|
1089 #endif |
2313 | 1090 |
2411 | 1091 if (options->version) |
1092 { | |
1093 dump_version(); | |
1094 exit(EXIT_SUCCESS); | |
1095 } | |
1096 | |
2788
b2b920b165ad
[svn] - exclude codes which use session if USE_DBUS is not defined.
yaz
parents:
2786
diff
changeset
|
1097 #ifdef USE_DBUS |
2411 | 1098 if (filenames != NULL) |
1099 { | |
2313 | 1100 gint pos = 0; |
2411 | 1101 gint i = 0; |
2605
1ceaf00f9c6d
[svn] - fix handling of multiple files on the command line.
nenolod
parents:
2574
diff
changeset
|
1102 GList *fns = NULL; |
2313 | 1103 |
2411 | 1104 for (i = 0; filenames[i] != NULL; i++) |
1105 { | |
2570 | 1106 gchar *filename; |
2512
3a1fc6f7c187
[svn] - unbreak relative path support. closes #791.
nenolod
parents:
2506
diff
changeset
|
1107 gchar *current_dir = g_get_current_dir(); |
3a1fc6f7c187
[svn] - unbreak relative path support. closes #791.
nenolod
parents:
2506
diff
changeset
|
1108 |
3a1fc6f7c187
[svn] - unbreak relative path support. closes #791.
nenolod
parents:
2506
diff
changeset
|
1109 if (filenames[i][0] == '/' || strstr(filenames[i], "://")) |
3a1fc6f7c187
[svn] - unbreak relative path support. closes #791.
nenolod
parents:
2506
diff
changeset
|
1110 filename = g_strdup(filenames[i]); |
3a1fc6f7c187
[svn] - unbreak relative path support. closes #791.
nenolod
parents:
2506
diff
changeset
|
1111 else |
3a1fc6f7c187
[svn] - unbreak relative path support. closes #791.
nenolod
parents:
2506
diff
changeset
|
1112 filename = g_build_filename(current_dir, filenames[i], NULL); |
3a1fc6f7c187
[svn] - unbreak relative path support. closes #791.
nenolod
parents:
2506
diff
changeset
|
1113 |
2605
1ceaf00f9c6d
[svn] - fix handling of multiple files on the command line.
nenolod
parents:
2574
diff
changeset
|
1114 fns = g_list_prepend(fns, filename); |
2313 | 1115 |
2605
1ceaf00f9c6d
[svn] - fix handling of multiple files on the command line.
nenolod
parents:
2574
diff
changeset
|
1116 g_free(current_dir); |
1ceaf00f9c6d
[svn] - fix handling of multiple files on the command line.
nenolod
parents:
2574
diff
changeset
|
1117 } |
1ceaf00f9c6d
[svn] - fix handling of multiple files on the command line.
nenolod
parents:
2574
diff
changeset
|
1118 |
1ceaf00f9c6d
[svn] - fix handling of multiple files on the command line.
nenolod
parents:
2574
diff
changeset
|
1119 fns = g_list_reverse(fns); |
2411 | 1120 |
2605
1ceaf00f9c6d
[svn] - fix handling of multiple files on the command line.
nenolod
parents:
2574
diff
changeset
|
1121 if (options->load_skins) |
1ceaf00f9c6d
[svn] - fix handling of multiple files on the command line.
nenolod
parents:
2574
diff
changeset
|
1122 { |
2727
14f9a629ba9c
[svn] - rename xmms_remote namespace to audacious_remote namespace
nenolod
parents:
2717
diff
changeset
|
1123 audacious_remote_set_skin(session, filenames[0]); |
2605
1ceaf00f9c6d
[svn] - fix handling of multiple files on the command line.
nenolod
parents:
2574
diff
changeset
|
1124 skin_install_skin(filenames[0]); |
1ceaf00f9c6d
[svn] - fix handling of multiple files on the command line.
nenolod
parents:
2574
diff
changeset
|
1125 } |
1ceaf00f9c6d
[svn] - fix handling of multiple files on the command line.
nenolod
parents:
2574
diff
changeset
|
1126 else |
1ceaf00f9c6d
[svn] - fix handling of multiple files on the command line.
nenolod
parents:
2574
diff
changeset
|
1127 { |
1ceaf00f9c6d
[svn] - fix handling of multiple files on the command line.
nenolod
parents:
2574
diff
changeset
|
1128 if (options->enqueue_to_temp) |
2727
14f9a629ba9c
[svn] - rename xmms_remote namespace to audacious_remote namespace
nenolod
parents:
2717
diff
changeset
|
1129 audacious_remote_playlist_enqueue_to_temp(session, filenames[0]); |
2411 | 1130 |
2605
1ceaf00f9c6d
[svn] - fix handling of multiple files on the command line.
nenolod
parents:
2574
diff
changeset
|
1131 if (options->enqueue && options->play) |
2727
14f9a629ba9c
[svn] - rename xmms_remote namespace to audacious_remote namespace
nenolod
parents:
2717
diff
changeset
|
1132 pos = audacious_remote_get_playlist_length(session); |
2313 | 1133 |
2605
1ceaf00f9c6d
[svn] - fix handling of multiple files on the command line.
nenolod
parents:
2574
diff
changeset
|
1134 if (!options->enqueue) |
1ceaf00f9c6d
[svn] - fix handling of multiple files on the command line.
nenolod
parents:
2574
diff
changeset
|
1135 { |
2727
14f9a629ba9c
[svn] - rename xmms_remote namespace to audacious_remote namespace
nenolod
parents:
2717
diff
changeset
|
1136 audacious_remote_playlist_clear(session); |
14f9a629ba9c
[svn] - rename xmms_remote namespace to audacious_remote namespace
nenolod
parents:
2717
diff
changeset
|
1137 audacious_remote_stop(session); |
2411 | 1138 } |
2512
3a1fc6f7c187
[svn] - unbreak relative path support. closes #791.
nenolod
parents:
2506
diff
changeset
|
1139 |
2727
14f9a629ba9c
[svn] - rename xmms_remote namespace to audacious_remote namespace
nenolod
parents:
2717
diff
changeset
|
1140 audacious_remote_playlist_add(session, fns); |
2605
1ceaf00f9c6d
[svn] - fix handling of multiple files on the command line.
nenolod
parents:
2574
diff
changeset
|
1141 |
1ceaf00f9c6d
[svn] - fix handling of multiple files on the command line.
nenolod
parents:
2574
diff
changeset
|
1142 if (options->enqueue && options->play && |
2727
14f9a629ba9c
[svn] - rename xmms_remote namespace to audacious_remote namespace
nenolod
parents:
2717
diff
changeset
|
1143 audacious_remote_get_playlist_length(session) > pos) |
14f9a629ba9c
[svn] - rename xmms_remote namespace to audacious_remote namespace
nenolod
parents:
2717
diff
changeset
|
1144 audacious_remote_set_playlist_pos(session, pos); |
2605
1ceaf00f9c6d
[svn] - fix handling of multiple files on the command line.
nenolod
parents:
2574
diff
changeset
|
1145 |
1ceaf00f9c6d
[svn] - fix handling of multiple files on the command line.
nenolod
parents:
2574
diff
changeset
|
1146 if (!options->enqueue) |
2727
14f9a629ba9c
[svn] - rename xmms_remote namespace to audacious_remote namespace
nenolod
parents:
2717
diff
changeset
|
1147 audacious_remote_play(session); |
2313 | 1148 } |
1149 | |
2605
1ceaf00f9c6d
[svn] - fix handling of multiple files on the command line.
nenolod
parents:
2574
diff
changeset
|
1150 g_list_foreach(fns, (GFunc) g_free, NULL); |
1ceaf00f9c6d
[svn] - fix handling of multiple files on the command line.
nenolod
parents:
2574
diff
changeset
|
1151 g_list_free(fns); |
1ceaf00f9c6d
[svn] - fix handling of multiple files on the command line.
nenolod
parents:
2574
diff
changeset
|
1152 |
2411 | 1153 g_strfreev(filenames); |
2786 | 1154 } /* filename */ |
2313 | 1155 |
2832 | 1156 if (remote) { |
1157 if (options->rew) | |
1158 audacious_remote_playlist_prev(session); | |
2313 | 1159 |
2832 | 1160 if (options->play) |
1161 audacious_remote_play(session); | |
2313 | 1162 |
2832 | 1163 if (options->pause) |
1164 audacious_remote_pause(session); | |
2313 | 1165 |
2832 | 1166 if (options->stop) |
1167 audacious_remote_stop(session); | |
2313 | 1168 |
2832 | 1169 if (options->fwd) |
1170 audacious_remote_playlist_next(session); | |
2313 | 1171 |
2832 | 1172 if (options->play_pause) |
1173 audacious_remote_play_pause(session); | |
2313 | 1174 |
2832 | 1175 if (options->show_jump_box) |
1176 audacious_remote_show_jtf_box(session); | |
2313 | 1177 |
2832 | 1178 if (options->mainwin) |
1179 audacious_remote_main_win_toggle(session, TRUE); | |
2313 | 1180 |
2832 | 1181 if (options->activate) |
1182 audacious_remote_activate(session); | |
2845
a124656d4423
added handlers for cmd line args when remote == false
Ben Tucker <ben.tucker@gmail.com>
parents:
2838
diff
changeset
|
1183 } else { |
a124656d4423
added handlers for cmd line args when remote == false
Ben Tucker <ben.tucker@gmail.com>
parents:
2838
diff
changeset
|
1184 if (options->rew) |
a124656d4423
added handlers for cmd line args when remote == false
Ben Tucker <ben.tucker@gmail.com>
parents:
2838
diff
changeset
|
1185 audacious_drct_playlist_prev(); |
a124656d4423
added handlers for cmd line args when remote == false
Ben Tucker <ben.tucker@gmail.com>
parents:
2838
diff
changeset
|
1186 |
a124656d4423
added handlers for cmd line args when remote == false
Ben Tucker <ben.tucker@gmail.com>
parents:
2838
diff
changeset
|
1187 if (options->play) |
a124656d4423
added handlers for cmd line args when remote == false
Ben Tucker <ben.tucker@gmail.com>
parents:
2838
diff
changeset
|
1188 audacious_drct_play(); |
a124656d4423
added handlers for cmd line args when remote == false
Ben Tucker <ben.tucker@gmail.com>
parents:
2838
diff
changeset
|
1189 |
a124656d4423
added handlers for cmd line args when remote == false
Ben Tucker <ben.tucker@gmail.com>
parents:
2838
diff
changeset
|
1190 if (options->pause) |
a124656d4423
added handlers for cmd line args when remote == false
Ben Tucker <ben.tucker@gmail.com>
parents:
2838
diff
changeset
|
1191 audacious_drct_pause(); |
a124656d4423
added handlers for cmd line args when remote == false
Ben Tucker <ben.tucker@gmail.com>
parents:
2838
diff
changeset
|
1192 |
a124656d4423
added handlers for cmd line args when remote == false
Ben Tucker <ben.tucker@gmail.com>
parents:
2838
diff
changeset
|
1193 if (options->stop) |
a124656d4423
added handlers for cmd line args when remote == false
Ben Tucker <ben.tucker@gmail.com>
parents:
2838
diff
changeset
|
1194 audacious_drct_stop(); |
a124656d4423
added handlers for cmd line args when remote == false
Ben Tucker <ben.tucker@gmail.com>
parents:
2838
diff
changeset
|
1195 |
a124656d4423
added handlers for cmd line args when remote == false
Ben Tucker <ben.tucker@gmail.com>
parents:
2838
diff
changeset
|
1196 if (options->fwd) |
a124656d4423
added handlers for cmd line args when remote == false
Ben Tucker <ben.tucker@gmail.com>
parents:
2838
diff
changeset
|
1197 audacious_drct_playlist_next(); |
a124656d4423
added handlers for cmd line args when remote == false
Ben Tucker <ben.tucker@gmail.com>
parents:
2838
diff
changeset
|
1198 |
a124656d4423
added handlers for cmd line args when remote == false
Ben Tucker <ben.tucker@gmail.com>
parents:
2838
diff
changeset
|
1199 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
|
1200 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
|
1201 audacious_drct_play(); |
a124656d4423
added handlers for cmd line args when remote == false
Ben Tucker <ben.tucker@gmail.com>
parents:
2838
diff
changeset
|
1202 else |
a124656d4423
added handlers for cmd line args when remote == false
Ben Tucker <ben.tucker@gmail.com>
parents:
2838
diff
changeset
|
1203 audacious_drct_pause(); |
a124656d4423
added handlers for cmd line args when remote == false
Ben Tucker <ben.tucker@gmail.com>
parents:
2838
diff
changeset
|
1204 } |
a124656d4423
added handlers for cmd line args when remote == false
Ben Tucker <ben.tucker@gmail.com>
parents:
2838
diff
changeset
|
1205 |
a124656d4423
added handlers for cmd line args when remote == false
Ben Tucker <ben.tucker@gmail.com>
parents:
2838
diff
changeset
|
1206 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
|
1207 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
|
1208 |
a124656d4423
added handlers for cmd line args when remote == false
Ben Tucker <ben.tucker@gmail.com>
parents:
2838
diff
changeset
|
1209 if (options->mainwin) |
a124656d4423
added handlers for cmd line args when remote == false
Ben Tucker <ben.tucker@gmail.com>
parents:
2838
diff
changeset
|
1210 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
|
1211 |
a124656d4423
added handlers for cmd line args when remote == false
Ben Tucker <ben.tucker@gmail.com>
parents:
2838
diff
changeset
|
1212 if (options->activate) |
a124656d4423
added handlers for cmd line args when remote == false
Ben Tucker <ben.tucker@gmail.com>
parents:
2838
diff
changeset
|
1213 audacious_drct_activate(); |
2832 | 1214 } |
2785 | 1215 |
2786 | 1216 if(remote) { |
2785 | 1217 gboolean is_running = audacious_remote_is_running(session); |
1218 if (is_running) | |
1219 exit(EXIT_SUCCESS); | |
1220 } | |
2788
b2b920b165ad
[svn] - exclude codes which use session if USE_DBUS is not defined.
yaz
parents:
2786
diff
changeset
|
1221 #endif |
2313 | 1222 } |
1223 | |
1224 static void | |
1225 bmp_setup_logger(void) | |
1226 { | |
1227 if (!bmp_logger_start(bmp_paths[BMP_PATH_LOG_FILE])) | |
1228 return; | |
1229 | |
1230 g_atexit(bmp_logger_stop); | |
1231 } | |
1232 | |
1233 static void | |
1234 run_load_skin_error_dialog(const gchar * skin_path) | |
1235 { | |
1236 const gchar *markup = | |
1237 N_("<b><big>Unable to load skin.</big></b>\n" | |
1238 "\n" | |
1239 "Check that skin at '%s' is usable and default skin is properly " | |
1240 "installed at '%s'\n"); | |
1241 | |
1242 GtkWidget *dialog = | |
1243 gtk_message_dialog_new_with_markup(NULL, | |
1244 GTK_DIALOG_MODAL, | |
1245 GTK_MESSAGE_ERROR, | |
1246 GTK_BUTTONS_CLOSE, | |
1247 _(markup), | |
1248 skin_path, | |
1249 BMP_DEFAULT_SKIN_PATH); | |
1250 gtk_dialog_run(GTK_DIALOG(dialog)); | |
1251 gtk_widget_destroy(dialog); | |
1252 } | |
1253 | |
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
|
1254 void report_error(const gchar *error_message, ...) |
2313 | 1255 { |
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
|
1256 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
|
1257 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
|
1258 |
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
|
1259 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
|
1260 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
|
1261 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
|
1262 |
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
|
1263 fprintf(stderr, buf); |
2570 | 1264 |
1265 if (options.headless != 1) | |
1266 { | |
2313 | 1267 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
|
1268 buf); |
2313 | 1269 gtk_dialog_run(GTK_DIALOG(err)); |
1270 gtk_widget_hide(err); | |
1271 } | |
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
|
1272 |
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
|
1273 g_free(buf); |
2313 | 1274 } |
1275 | |
2369 | 1276 static gboolean |
1277 aud_headless_iteration(gpointer unused) | |
1278 { | |
2506
630910fd140f
[svn] - changed plugin directory to ~/.local/share/audacious/Plugins (seems more logical to me)
mf0102
parents:
2475
diff
changeset
|
1279 free_vis_data(); |
630910fd140f
[svn] - changed plugin directory to ~/.local/share/audacious/Plugins (seems more logical to me)
mf0102
parents:
2475
diff
changeset
|
1280 return TRUE; |
2369 | 1281 } |
1282 | |
3480
3f4ad59a5c02
Load extra playlists on startup
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3443
diff
changeset
|
1283 static gboolean |
3f4ad59a5c02
Load extra playlists on startup
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3443
diff
changeset
|
1284 load_extra_playlist(const gchar * path, const gchar * basename, |
3f4ad59a5c02
Load extra playlists on startup
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3443
diff
changeset
|
1285 gpointer def) |
3f4ad59a5c02
Load extra playlists on startup
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3443
diff
changeset
|
1286 { |
3f4ad59a5c02
Load extra playlists on startup
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3443
diff
changeset
|
1287 const gchar *title; |
3f4ad59a5c02
Load extra playlists on startup
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3443
diff
changeset
|
1288 Playlist *playlist; |
3f4ad59a5c02
Load extra playlists on startup
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3443
diff
changeset
|
1289 Playlist *deflist; |
3f4ad59a5c02
Load extra playlists on startup
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3443
diff
changeset
|
1290 |
3f4ad59a5c02
Load extra playlists on startup
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3443
diff
changeset
|
1291 deflist = (Playlist *)def; |
3f4ad59a5c02
Load extra playlists on startup
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3443
diff
changeset
|
1292 playlist = playlist_new(); |
3f4ad59a5c02
Load extra playlists on startup
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3443
diff
changeset
|
1293 if (!playlist) { |
3f4ad59a5c02
Load extra playlists on startup
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3443
diff
changeset
|
1294 g_warning("Couldn't create new playlist\n"); |
3f4ad59a5c02
Load extra playlists on startup
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3443
diff
changeset
|
1295 return FALSE; |
3f4ad59a5c02
Load extra playlists on startup
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3443
diff
changeset
|
1296 } |
3f4ad59a5c02
Load extra playlists on startup
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3443
diff
changeset
|
1297 |
3f4ad59a5c02
Load extra playlists on startup
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3443
diff
changeset
|
1298 playlist_add_playlist(playlist); |
3f4ad59a5c02
Load extra playlists on startup
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3443
diff
changeset
|
1299 playlist_load(playlist, path); |
3f4ad59a5c02
Load extra playlists on startup
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3443
diff
changeset
|
1300 |
3f4ad59a5c02
Load extra playlists on startup
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3443
diff
changeset
|
1301 title = playlist_get_current_name(playlist); |
3f4ad59a5c02
Load extra playlists on startup
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3443
diff
changeset
|
1302 |
3f4ad59a5c02
Load extra playlists on startup
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3443
diff
changeset
|
1303 return FALSE; /* keep loading other playlists */ |
3f4ad59a5c02
Load extra playlists on startup
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3443
diff
changeset
|
1304 } |
3f4ad59a5c02
Load extra playlists on startup
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3443
diff
changeset
|
1305 |
2313 | 1306 gint |
1307 main(gint argc, gchar ** argv) | |
1308 { | |
1309 gboolean gtk_init_check_ok; | |
1310 Playlist *playlist; | |
2411 | 1311 GOptionContext *context; |
1312 GError *error = NULL; | |
2313 | 1313 |
2644
67082557b2c4
[svn] - glib-2.13.0 requires g_thread_init() to be called before all other GLib functions.
yaz
parents:
2605
diff
changeset
|
1314 /* 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
|
1315 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
|
1316 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
|
1317 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
|
1318 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
|
1319 "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
|
1320 "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
|
1321 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
|
1322 } |
67082557b2c4
[svn] - glib-2.13.0 requires g_thread_init() to be called before all other GLib functions.
yaz
parents:
2605
diff
changeset
|
1323 |
67082557b2c4
[svn] - glib-2.13.0 requires g_thread_init() to be called before all other GLib functions.
yaz
parents:
2605
diff
changeset
|
1324 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
|
1325 |
2313 | 1326 /* Setup l10n early so we can print localized error messages */ |
1327 gtk_set_locale(); | |
1328 bindtextdomain(PACKAGE_NAME, LOCALEDIR); | |
1329 bind_textdomain_codeset(PACKAGE_NAME, "UTF-8"); | |
2388
52bcc18eb8bb
[svn] - attempt to bind the audacious-plugins domain
nenolod
parents:
2369
diff
changeset
|
1330 bindtextdomain(PACKAGE_NAME "-plugins", LOCALEDIR); |
52bcc18eb8bb
[svn] - attempt to bind the audacious-plugins domain
nenolod
parents:
2369
diff
changeset
|
1331 bind_textdomain_codeset(PACKAGE_NAME "-plugins", "UTF-8"); |
2313 | 1332 textdomain(PACKAGE_NAME); |
1333 | |
1334 bmp_init_paths(); | |
1335 bmp_make_user_dir(); | |
1336 | |
1337 g_set_application_name(_(application_name)); | |
1338 | |
1339 cond_scan = g_cond_new(); | |
1340 mutex_scan = g_mutex_new(); | |
1341 | |
2463 | 1342 gtk_rc_add_default_file(bmp_paths[BMP_PATH_GTKRC_FILE]); |
1343 | |
2313 | 1344 gtk_init_check_ok = gtk_init_check(&argc, &argv); |
2411 | 1345 |
2413 | 1346 memset(&options, '\0', sizeof(BmpCmdLineOpt)); |
1347 options.session = -1; | |
1348 | |
2411 | 1349 context = g_option_context_new(_("- play multimedia files")); |
1350 g_option_context_add_main_entries(context, cmd_entries, PACKAGE_NAME); | |
1351 g_option_context_add_group(context, gtk_get_option_group(TRUE)); | |
1352 g_option_context_parse(context, &argc, &argv, &error); | |
1353 | |
2412 | 1354 if (error != NULL) |
1355 { | |
2938
1cdfc508d758
Fix adding files when Audacious is running.
Jonathan Schleifer <js@h3c.de>
parents:
2914
diff
changeset
|
1356 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
|
1357 argv[0], error->message, argv[0]); |
2412 | 1358 exit(EXIT_FAILURE); |
1359 } | |
1360 | |
2313 | 1361 if (!gtk_init_check_ok) { |
1362 if (argc < 2) { | |
1363 /* GTK check failed, and no arguments passed to indicate | |
1364 that user is intending to only remote control a running | |
1365 session */ | |
2412 | 1366 g_printerr(_("%s: Unable to open display, exiting.\n"), argv[0]); |
2313 | 1367 exit(EXIT_FAILURE); |
1368 } | |
1369 | |
1370 handle_cmd_line_options(&options, TRUE); | |
1371 | |
1372 /* we could be running headless, so GTK probably wont matter */ | |
1373 if (options.headless != 1) | |
2938
1cdfc508d758
Fix adding files when Audacious is running.
Jonathan Schleifer <js@h3c.de>
parents:
2914
diff
changeset
|
1374 exit(EXIT_SUCCESS); |
2313 | 1375 } |
1376 | |
1377 if (options.no_log == FALSE) | |
1378 bmp_setup_logger(); | |
1379 | |
1380 signal_handlers_init(); | |
1381 | |
1382 g_random_set_seed(time(NULL)); | |
1383 | |
1384 bmp_config_load(); | |
1385 | |
2736 | 1386 handle_cmd_line_options(&options, TRUE); |
2313 | 1387 |
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
|
1388 #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
|
1389 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
|
1390 #endif |
2856
c4d07471f647
Added a mowgli_init() call
Cristi Magherusan <majeru@gentoo.ro>
parents:
2846
diff
changeset
|
1391 mowgli_init(); |
3306
404ffedef3e1
added support for plugin-customizable menus; plugins can add their own entries (and even submenus) in main and playlist popup menus
Giacomo Lozito <james@develia.org>
parents:
3296
diff
changeset
|
1392 |
404ffedef3e1
added support for plugin-customizable menus; plugins can add their own entries (and even submenus) in main and playlist popup menus
Giacomo Lozito <james@develia.org>
parents:
3296
diff
changeset
|
1393 if (options.headless != 1) |
404ffedef3e1
added support for plugin-customizable menus; plugins can add their own entries (and even submenus) in main and playlist popup menus
Giacomo Lozito <james@develia.org>
parents:
3296
diff
changeset
|
1394 { |
404ffedef3e1
added support for plugin-customizable menus; plugins can add their own entries (and even submenus) in main and playlist popup menus
Giacomo Lozito <james@develia.org>
parents:
3296
diff
changeset
|
1395 /* UIManager |
404ffedef3e1
added support for plugin-customizable menus; plugins can add their own entries (and even submenus) in main and playlist popup menus
Giacomo Lozito <james@develia.org>
parents:
3296
diff
changeset
|
1396 NOTE: this needs to be called before plugin init, cause |
404ffedef3e1
added support for plugin-customizable menus; plugins can add their own entries (and even submenus) in main and playlist popup menus
Giacomo Lozito <james@develia.org>
parents:
3296
diff
changeset
|
1397 plugin init functions may want to add custom menu entries */ |
404ffedef3e1
added support for plugin-customizable menus; plugins can add their own entries (and even submenus) in main and playlist popup menus
Giacomo Lozito <james@develia.org>
parents:
3296
diff
changeset
|
1398 ui_manager_init(); |
404ffedef3e1
added support for plugin-customizable menus; plugins can add their own entries (and even submenus) in main and playlist popup menus
Giacomo Lozito <james@develia.org>
parents:
3296
diff
changeset
|
1399 ui_manager_create_menus(); |
404ffedef3e1
added support for plugin-customizable menus; plugins can add their own entries (and even submenus) in main and playlist popup menus
Giacomo Lozito <james@develia.org>
parents:
3296
diff
changeset
|
1400 } |
404ffedef3e1
added support for plugin-customizable menus; plugins can add their own entries (and even submenus) in main and playlist popup menus
Giacomo Lozito <james@develia.org>
parents:
3296
diff
changeset
|
1401 |
2313 | 1402 plugin_system_init(); |
1403 | |
1404 /* Initialize the playlist system. */ | |
1405 playlist_init(); | |
1406 | |
1407 if (options.headless != 1) | |
1408 { | |
1409 /* register icons in stock */ | |
1410 register_aud_stock_icons(); | |
1411 | |
1412 bmp_set_default_icon(); | |
3525
540e49d1d87c
macos: Set an application icon in the dock.
William Pitcock <nenolod@atheme.org>
parents:
3400
diff
changeset
|
1413 #ifdef GDK_WINDOWING_QUARTZ |
540e49d1d87c
macos: Set an application icon in the dock.
William Pitcock <nenolod@atheme.org>
parents:
3400
diff
changeset
|
1414 set_dock_icon(); |
540e49d1d87c
macos: Set an application icon in the dock.
William Pitcock <nenolod@atheme.org>
parents:
3400
diff
changeset
|
1415 #endif |
2313 | 1416 |
1417 gtk_accel_map_load(bmp_paths[BMP_PATH_ACCEL_FILE]); | |
1418 | |
1419 if (!init_skins(cfg.skin)) { | |
1420 run_load_skin_error_dialog(cfg.skin); | |
1421 exit(EXIT_FAILURE); | |
1422 } | |
1423 | |
1424 GDK_THREADS_ENTER(); | |
1425 } | |
1426 | |
1427 /* Load the default playlist in. */ | |
1428 playlist = playlist_get_active(); | |
1429 playlist_load(playlist, bmp_paths[BMP_PATH_PLAYLIST_FILE]); | |
1430 playlist_set_position(playlist, cfg.playlist_position); | |
1431 | |
3480
3f4ad59a5c02
Load extra playlists on startup
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3443
diff
changeset
|
1432 /* Load extra playlists */ |
3f4ad59a5c02
Load extra playlists on startup
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3443
diff
changeset
|
1433 if(!dir_foreach(bmp_paths[BMP_PATH_PLAYLISTS_DIR], load_extra_playlist, |
3f4ad59a5c02
Load extra playlists on startup
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3443
diff
changeset
|
1434 playlist, NULL)) { |
3f4ad59a5c02
Load extra playlists on startup
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3443
diff
changeset
|
1435 g_warning("Could not load extra playlists\n"); |
3f4ad59a5c02
Load extra playlists on startup
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3443
diff
changeset
|
1436 } |
3f4ad59a5c02
Load extra playlists on startup
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3443
diff
changeset
|
1437 |
2313 | 1438 /* this needs to be called after all 3 windows are created and |
1439 * input plugins are setup'ed | |
1440 * but not if we're running headless --nenolod | |
1441 */ | |
1442 mainwin_setup_menus(); | |
1443 | |
1444 if (options.headless != 1) | |
1445 { | |
1446 read_volume(VOLSET_STARTUP); | |
1447 | |
1448 /* FIXME: delayed, because it deals directly with the plugin | |
1449 * interface to set menu items */ | |
1450 create_prefs_window(); | |
1451 | |
2364 | 1452 create_fileinfo_window(); |
1453 | |
2313 | 1454 |
1455 if (cfg.player_visible) | |
1456 mainwin_show(TRUE); | |
1457 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
|
1458 { |
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
|
1459 /* 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
|
1460 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
|
1461 } |
2313 | 1462 |
1463 if (cfg.equalizer_visible) | |
1464 equalizerwin_show(TRUE); | |
1465 | |
1466 if (cfg.playlist_visible) | |
1467 playlistwin_show(); | |
1468 | |
1469 hint_set_always(cfg.always_on_top); | |
1470 | |
1471 playlist_start_get_info_thread(); | |
1472 mainwin_attach_idle_func(); | |
1473 | |
2364 | 1474 has_x11_connection = TRUE; |
2313 | 1475 |
2364 | 1476 if (cfg.resume_playback_on_startup) |
1477 { | |
1478 if (cfg.resume_playback_on_startup_time != -1 && | |
1479 playlist_get_length(playlist) > 0) | |
1480 { | |
1481 int i; | |
1482 gint l = 0, r = 0; | |
1483 while (gtk_events_pending()) gtk_main_iteration(); | |
1484 output_get_volume(&l, &r); | |
1485 output_set_volume(0,0); | |
1486 playback_initiate(); | |
2313 | 1487 |
2364 | 1488 /* Busy wait; loop is fairly tight to minimize duration of |
1489 * "frozen" GUI. Feel free to tune. --chainsaw */ | |
1490 for (i = 0; i < 20; i++) | |
1491 { | |
1492 g_usleep(1000); | |
1493 if (!ip_data.playing) | |
1494 break; | |
1495 } | |
1496 playback_seek(cfg.resume_playback_on_startup_time / 1000); | |
1497 output_set_volume(l, r); | |
1498 } | |
1499 } | |
1500 | |
2313 | 1501 gtk_main(); |
1502 | |
1503 GDK_THREADS_LEAVE(); | |
1504 | |
1505 g_cond_free(cond_scan); | |
1506 g_mutex_free(mutex_scan); | |
1507 | |
1508 return EXIT_SUCCESS; | |
1509 } | |
2364 | 1510 // if we are running headless |
2313 | 1511 else |
1512 { | |
2506
630910fd140f
[svn] - changed plugin directory to ~/.local/share/audacious/Plugins (seems more logical to me)
mf0102
parents:
2475
diff
changeset
|
1513 GMainLoop *loop; |
2369 | 1514 |
2313 | 1515 playlist_start_get_info_thread(); |
1516 | |
2506
630910fd140f
[svn] - changed plugin directory to ~/.local/share/audacious/Plugins (seems more logical to me)
mf0102
parents:
2475
diff
changeset
|
1517 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
|
1518 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
|
1519 g_main_loop_run(loop); |
2313 | 1520 |
1521 return EXIT_SUCCESS; | |
1522 } | |
1523 } |