void refresh_cdda_drive_node(char * device_path) { GtkTreeIter iter_cdda; GtkTreeIter iter_drive; GtkTreeIter iter_tmp; cdda_drive_t * drive; char str_title[MAXLEN]; int i, found; gtk_tree_model_get_iter_first(GTK_TREE_MODEL(music_store), &iter_cdda); i = found = 0; while (gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(music_store), &iter_drive, &iter_cdda, i++)) { gtk_tree_model_get(GTK_TREE_MODEL(music_store), &iter_drive, MS_COL_DATA, &drive, -1); if (strcmp(drive->device_path, device_path) == 0) { found = 1; break; } } if (!found) { return; } if (drive->disc.n_tracks > 0) { snprintf(str_title, MAXLEN-1, "%s [%s]", _("Unknown disc"), cdda_displayed_device_path(device_path)); } else { snprintf(str_title, MAXLEN-1, "%s [%s]", _("No disc"), cdda_displayed_device_path(device_path)); } gtk_tree_store_set(music_store, &iter_drive, MS_COL_NAME, str_title, -1); if (gtk_tree_model_iter_n_children(GTK_TREE_MODEL(music_store), &iter_drive) > 0) { if (options.cdda_remove_from_playlist) { cdda_remove_from_playlist(drive); } while (gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(music_store), &iter_tmp, &iter_drive, 0)) { store_cdda_remove_track(&iter_tmp); } } if (options.enable_ms_tree_icons) { if (drive->disc.n_tracks > 0) { gtk_tree_store_set(music_store, &iter_drive, MS_COL_ICON, icon_cdda_disc, -1); } else { gtk_tree_store_set(music_store, &iter_drive, MS_COL_ICON, icon_cdda_nodisc, -1); } } if (drive->disc.n_tracks > 0) { update_track_data(drive, iter_drive); } music_store_selection_changed(STORE_TYPE_CDDA); }
/** * The main loop of the jukebox. Waits for the end of the song (while updating * the timer) and then returns an indicator that we need the next song. * Also waits for keypresses; the user can press ESC, left arrow or right arrow * to trigger appropriate return codes. */ int jukebox_loop() { int key_p; while (TRUE) { while (keypressed()) { key_p = readkey() >> 8; if (key_p == KEY_ESC) { return JUKEBOX_EXIT; } if (key_p == KEY_LEFT) { return JUKEBOX_PREV_SONG; } if (key_p == KEY_RIGHT) { return JUKEBOX_NEXT_SONG; } } clear_bitmap(buffer); update_starfield(buffer); update_track_data(); update_song_data(); draw_help(); vsync(); blit(buffer, screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H); // When we're at the end of the file, midi_pos will be set to // the negative number of beats in the song. if (midi_pos < 0) { rest(TRACK_CHANGE_WAIT); return JUKEBOX_NEXT_SONG; } } }
void insert_cdda_drive_node(char * device_path) { GtkTreeIter iter_cdda; GtkTreeIter iter_drive; cdda_drive_t * drive = cdda_get_drive_by_device_path(device_path); char str_title[MAXLEN]; char str_sort[16]; if (drive == NULL) { return; } if (drive->disc.n_tracks > 0) { snprintf(str_title, MAXLEN-1, "%s [%s]", _("Unknown disc"), cdda_displayed_device_path(device_path)); } else { snprintf(str_title, MAXLEN-1, "%s [%s]", _("No disc"), cdda_displayed_device_path(device_path)); } snprintf(str_sort, 15, "%d", cdda_get_n(device_path)); gtk_tree_model_get_iter_first(GTK_TREE_MODEL(music_store), &iter_cdda); gtk_tree_store_append(music_store, &iter_drive, &iter_cdda); gtk_tree_store_set(music_store, &iter_drive, MS_COL_NAME, str_title, MS_COL_SORT, str_sort, MS_COL_DATA, drive, -1); if (options.enable_ms_tree_icons) { if (drive->disc.n_tracks > 0) { gtk_tree_store_set(music_store, &iter_drive, MS_COL_ICON, icon_cdda_disc, -1); } else { gtk_tree_store_set(music_store, &iter_drive, MS_COL_ICON, icon_cdda_nodisc, -1); } } if (drive->disc.n_tracks > 0) { update_track_data(drive, iter_drive); } music_store_selection_changed(STORE_TYPE_CDDA); }