Mercurial > audlegacy-plugins
comparison src/cdaudio-ng/cdaudio-ng.c @ 3120:b3402e6f9aaa
Some minor changes; shuffle works again for CDs.
author | John Lindgren <john.lindgren@tds.net> |
---|---|
date | Tue, 05 May 2009 10:00:57 -0400 |
parents | e0b95157aa33 |
children | 2fa63d8ef645 |
comparison
equal
deleted
inserted
replaced
3119:e0b95157aa33 | 3120:b3402e6f9aaa |
---|---|
58 static InputPlayback *pglobalinputplayback = NULL; | 58 static InputPlayback *pglobalinputplayback = NULL; |
59 | 59 |
60 #define N_MENUS 3 | 60 #define N_MENUS 3 |
61 static const int menus [N_MENUS] = {AUDACIOUS_MENU_MAIN, | 61 static const int menus [N_MENUS] = {AUDACIOUS_MENU_MAIN, |
62 AUDACIOUS_MENU_PLAYLIST_ADD, AUDACIOUS_MENU_PLAYLIST_RCLICK}; | 62 AUDACIOUS_MENU_PLAYLIST_ADD, AUDACIOUS_MENU_PLAYLIST_RCLICK}; |
63 static GtkWidget * menu_items [N_MENUS]; | 63 static GtkWidget * menu_items [2 * N_MENUS]; |
64 | 64 |
65 static void cdaudio_init(void); | 65 static void cdaudio_init(void); |
66 static void cdaudio_about(void); | 66 static void cdaudio_about(void); |
67 static void cdaudio_configure(void); | 67 static void cdaudio_configure(void); |
68 static gint cdaudio_is_our_file(gchar *filename); | 68 static gint cdaudio_is_our_file(gchar *filename); |
269 { | 269 { |
270 set_monitor (1); | 270 set_monitor (1); |
271 trim_playlist (playlist); | 271 trim_playlist (playlist); |
272 } | 272 } |
273 else | 273 else |
274 { | |
275 set_monitor (0); | |
276 purge_all_playlists (); | 274 purge_all_playlists (); |
277 } | |
278 } | 275 } |
279 } | 276 } |
280 | 277 |
281 static char check_disk (void) | 278 static char check_disk (void) |
282 { | 279 { |
289 { | 286 { |
290 set_monitor (1); | 287 set_monitor (1); |
291 return 1; | 288 return 1; |
292 } | 289 } |
293 | 290 |
294 set_monitor (0); | |
295 show_noaudiocd_info (); | 291 show_noaudiocd_info (); |
296 return 0; | 292 return 0; |
297 } | 293 } |
298 | 294 |
299 static void play_our_playlist (Playlist * playlist) | |
300 { | |
301 char found; | |
302 int count, length; | |
303 char * filename; | |
304 | |
305 found = 0; | |
306 length = aud_playlist_get_length (playlist); | |
307 | |
308 for (count = 0; ! found && count < length; count ++) | |
309 { | |
310 filename = aud_playlist_get_filename (playlist, count); | |
311 | |
312 if (cdaudio_is_our_file (filename)) | |
313 { | |
314 aud_playlist_set_position (playlist, count); | |
315 audacious_drct_play (); | |
316 found = 1; | |
317 } | |
318 | |
319 g_free (filename); | |
320 } | |
321 } | |
322 | |
323 static void play_cd (void) | 295 static void play_cd (void) |
324 { | 296 { |
325 Playlist * playlist; | 297 Playlist * playlist; |
326 | 298 |
327 audacious_drct_stop (); | 299 audacious_drct_stop (); |
328 playlist = aud_playlist_get_active (); | 300 playlist = aud_playlist_get_active (); |
329 purge_playlist (playlist); | 301 aud_playlist_clear (playlist); |
330 | 302 |
331 if (! check_disk ()) | 303 if (! check_disk ()) |
332 return; | 304 return; |
333 | 305 |
334 add_cd_to_playlist (playlist); | 306 add_cd_to_playlist (playlist); |
335 play_our_playlist (playlist); | 307 audacious_drct_play (); |
308 } | |
309 | |
310 static void add_cd (void) | |
311 { | |
312 Playlist * playlist; | |
313 | |
314 playlist = aud_playlist_get_active (); | |
315 purge_playlist (playlist); | |
316 | |
317 if (! check_disk ()) | |
318 return; | |
319 | |
320 add_cd_to_playlist (playlist); | |
336 } | 321 } |
337 | 322 |
338 static void cdaudio_init() | 323 static void cdaudio_init() |
339 { | 324 { |
340 mcs_handle_t *db; | 325 mcs_handle_t *db; |
399 { | 384 { |
400 item = gtk_image_menu_item_new_with_label (_ ("Play CD")); | 385 item = gtk_image_menu_item_new_with_label (_ ("Play CD")); |
401 gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), | 386 gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), |
402 gtk_image_new_from_stock (GTK_STOCK_CDROM, GTK_ICON_SIZE_MENU)); | 387 gtk_image_new_from_stock (GTK_STOCK_CDROM, GTK_ICON_SIZE_MENU)); |
403 gtk_widget_show (item); | 388 gtk_widget_show (item); |
404 menu_items [count] = item; | 389 menu_items [2 * count] = item; |
405 audacious_menu_plugin_item_add (menus [count], item); | 390 audacious_menu_plugin_item_add (menus [count], item); |
406 g_signal_connect (G_OBJECT (item), "activate", | 391 g_signal_connect (G_OBJECT (item), "activate", |
407 G_CALLBACK (play_cd), NULL); | 392 G_CALLBACK (play_cd), NULL); |
393 | |
394 item = gtk_image_menu_item_new_with_label (_ ("Add CD")); | |
395 gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), | |
396 gtk_image_new_from_stock (GTK_STOCK_CDROM, GTK_ICON_SIZE_MENU)); | |
397 gtk_widget_show (item); | |
398 menu_items [2 * count + 1] = item; | |
399 audacious_menu_plugin_item_add (menus [count], item); | |
400 g_signal_connect (G_OBJECT (item), "activate", | |
401 G_CALLBACK (add_cd), NULL); | |
408 } | 402 } |
409 | 403 |
410 aud_uri_set_plugin("cdda://", &inputplugin); | 404 aud_uri_set_plugin("cdda://", &inputplugin); |
411 | |
412 aud_hook_associate ("playlist select", check_playlist, 0); | |
413 aud_hook_associate ("playlist load", check_playlist, 0); | 405 aud_hook_associate ("playlist load", check_playlist, 0); |
414 } | 406 } |
415 | 407 |
416 static void cdaudio_about() | 408 static void cdaudio_about() |
417 { | 409 { |
696 int count; | 688 int count; |
697 | 689 |
698 debug("cdaudio_cleanup()\n"); | 690 debug("cdaudio_cleanup()\n"); |
699 | 691 |
700 for (count = 0; count < N_MENUS; count ++) | 692 for (count = 0; count < N_MENUS; count ++) |
701 audacious_menu_plugin_item_remove (menus [count], menu_items [count]); | 693 { |
702 | 694 audacious_menu_plugin_item_remove (menus [count], |
703 aud_hook_dissociate ("playlist select", check_playlist); | 695 menu_items [2 * count]); |
696 audacious_menu_plugin_item_remove (menus [count], | |
697 menu_items [2 * count + 1]); | |
698 } | |
699 | |
704 aud_hook_dissociate ("playlist load", check_playlist); | 700 aud_hook_dissociate ("playlist load", check_playlist); |
705 set_monitor (0); | 701 set_monitor (0); |
706 | 702 |
707 if (pcdio != NULL) { | 703 if (pcdio != NULL) { |
708 if (playing_track != -1 && !cdng_cfg.use_dae) | 704 if (playing_track != -1 && !cdng_cfg.use_dae) |