Example #1
0
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);
}
Example #2
0
gboolean
store_cdda_remove_record(GtkTreeIter * iter) {

	GtkTreeIter track_iter;
	int i = 0;

	while (gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(music_store), &track_iter, iter, i++)) {
		store_cdda_remove_track(&track_iter);
	}

	return gtk_tree_store_remove(music_store, iter);
}