Beispiel #1
0
int check_filelist_with_cd_length(int cd_length_in_minutes,
                                  char **filelist,
                                  int num_files,
                                  int verbose)
{
    int i = 0;
    int ret = 1;
    int current_length = 0;
    int total_length = 0;

    if (filelist && num_files)
    {
        for(i = 0; i < num_files; i++)
        {
            current_length = get_song_length(filelist[i]);
            if (current_length != -1)
            {
                total_length += current_length;
            }
        }

        if (verbose)
        {
            printf("Total Computed Target CD Length is %.2d:%.2d\n",
                   (int)(total_length / 60),
                   (int)(total_length % 60));
        }

        if (total_length < (cd_length_in_minutes * 60))
        {
            ret = 0;
        }
    }
    return ret;
}
Beispiel #2
0
void ui_update_entry(struct playlist *playlist, struct playlist_entry *entry)
{
	struct playlist_ui_ctx *playlist_ctx = get_playlist_ui_ctx(playlist);
	struct entry_ui_ctx *ctx = get_entry_ui_ctx(entry);
	if (ctx->rowref == NULL)
		return;

	lock_ui();
	GtkTreePath *path = gtk_tree_row_reference_get_path(ctx->rowref);
	GtkTreeIter iter;
	gtk_tree_model_get_iter(GTK_TREE_MODEL(playlist_ctx->store), &iter, path);
	gtk_tree_path_free(path);

	char *name = get_display_name(get_entry_song(entry));
	char buf[32];
	unsigned int length = get_song_length(get_entry_song(entry));
	if (length == -1)
		strcpy(buf, "-");
	else
		sprintf(buf, "%d:%02d", length / (1000 * 60), (length / 1000) % 60);
	gtk_list_store_set(playlist_ctx->store, &iter,
		COL_NAME, name, COL_LENGTH, buf, -1);
	free(name);
	unlock_ui();
}
Beispiel #3
0
void ui_set_cursor(struct playlist_entry *entry)
{
	GtkAdjustment *adj = gtk_range_get_adjustment(GTK_RANGE(seekbar));
	lock_ui();
	if (entry) {
		struct song *song = get_entry_song(entry);
		char *name = get_display_name(song);
		char *buf = concat_strings(name, " - " APP_NAME);
		if (buf) {
			gtk_window_set_title(GTK_WINDOW(main_window), buf);
			free(buf);
		}
		free(name);
		gtk_adjustment_set_upper(adj, get_song_length(song) / 1000.0);
	} else {
		gtk_window_set_title(GTK_WINDOW(main_window), APP_NAME);
		gtk_adjustment_set_upper(adj, 1);
	}
	unlock_ui();
}
Beispiel #4
0
void ui_add_entry(struct playlist *playlist, struct playlist_entry *after,
		  struct playlist_entry *entry)
{
	struct playlist_ui_ctx *playlist_ctx = get_playlist_ui_ctx(playlist);
	struct song *song = get_entry_song(entry);
	struct entry_ui_ctx *ctx = get_entry_ui_ctx(entry);

	lock_ui();
	GtkTreeIter sibling;
	if (after) {
		struct entry_ui_ctx *after_ctx = get_entry_ui_ctx(after);
		GtkTreePath *path = gtk_tree_row_reference_get_path(after_ctx->rowref);
		gtk_tree_model_get_iter(GTK_TREE_MODEL(playlist_ctx->store), &sibling, path);
		gtk_tree_path_free(path);
	}

	GtkTreeIter iter;
	if (after)
		gtk_list_store_insert_after(playlist_ctx->store, &iter, &sibling);
	else
		gtk_list_store_insert_after(playlist_ctx->store, &iter, NULL);
	char *name = get_display_name(song);
	char buf[32];
	unsigned int length = get_song_length(song);
	if (length == -1)
		strcpy(buf, "-");
	else
		sprintf(buf, "%d:%02d", length / (1000 * 60), (length / 1000) % 60);
	gtk_list_store_set(playlist_ctx->store, &iter, COL_ENTRY, entry,
		COL_NAME, name, COL_LENGTH, buf, COL_COLOR, NULL, -1);
	free(name);

	/* store row reference */
	GtkTreePath *path = gtk_tree_model_get_path(GTK_TREE_MODEL(playlist_ctx->store), &iter);
	ctx->rowref = gtk_tree_row_reference_new(GTK_TREE_MODEL(playlist_ctx->store), path);
	gtk_tree_path_free(path);
	unlock_ui();
}