Exemplo n.º 1
0
static void gmpc_meta_data_widgets_similar_songs_add_clicked (GmpcMetaDataWidgetsSimilarSongs* self, GtkWidget* item) {
	GtkTreeView* _tmp0_;
	GtkTreeView* tree;
	GtkTreeSelection* _tmp1_ = NULL;
	GtkTreeSelection* _tmp2_;
	GtkTreeSelection* sel;
	GtkTreeModel* model;
	GtkTreeIter iter = {0};
	GtkTreeModel* _tmp3_ = NULL;
	GList* _tmp4_ = NULL;
	GtkTreeModel* _tmp5_;
	GList* list;
	g_return_if_fail (self != NULL);
	g_return_if_fail (item != NULL);
	_tmp0_ = _g_object_ref0 (GTK_TREE_VIEW (self->priv->pchild));
	tree = _tmp0_;
	_tmp1_ = gtk_tree_view_get_selection (tree);
	_tmp2_ = _g_object_ref0 (_tmp1_);
	sel = _tmp2_;
	model = NULL;
	_tmp4_ = gtk_tree_selection_get_selected_rows (sel, &_tmp3_);
	_g_object_unref0 (model);
	_tmp5_ = _g_object_ref0 (_tmp3_);
	model = _tmp5_;
	list = _tmp4_;
	{
		GList* path_collection;
		GList* path_it;
		path_collection = list;
		for (path_it = path_collection; path_it != NULL; path_it = path_it->next) {
			GtkTreePath* _tmp6_;
			GtkTreePath* path;
			_tmp6_ = _gtk_tree_path_copy0 ((GtkTreePath*) path_it->data);
			path = _tmp6_;
			{
				GtkTreeIter _tmp7_ = {0};
				gboolean _tmp8_;
				_tmp8_ = gtk_tree_model_get_iter (model, &_tmp7_, path);
				iter = _tmp7_;
				if (_tmp8_) {
					const mpd_Song* song;
					song = NULL;
					gtk_tree_model_get (model, &iter, 0, &song, -1, -1);
					if (song != NULL) {
						mpd_playlist_queue_add (connection, song->file);
					}
				}
				_gtk_tree_path_free0 (path);
			}
		}
	}
	mpd_playlist_queue_commit (connection);
	__g_list_free__gtk_tree_path_free0_0 (list);
	_g_object_unref0 (model);
	_g_object_unref0 (sel);
	_g_object_unref0 (tree);
}
Exemplo n.º 2
0
static void add_command(gpointer user_data, const char *param)
{
	gulong songs = 0;
	MpdData *data = advanced_search(param, FALSE);
	for (; data; data = mpd_data_get_next(data))
	{

		if ((songs & 16383) == 16383)
		{
			mpd_playlist_queue_commit(connection);
		}
		if (data->type == MPD_DATA_TYPE_SONG)
		{
			mpd_playlist_queue_add(connection, data->song->file);
			songs++;
		}
	}
	mpd_playlist_queue_commit(connection);
}
Exemplo n.º 3
0
int mpd_playlist_add(MpdObj *mi,const char *path)
{
	int retv = mpd_playlist_queue_add(mi, path);
	if(retv != MPD_OK) return retv;
	return mpd_playlist_queue_commit(mi);
}
/* adds found songs to the playlist */
void mpd_add_song_list(GtkWidget *widget, gpointer data) {

    GList *argument_list = (GList *)data;
    GList *song_list = NULL;
    GtkTreeIter iter;
    int list_length = 0, i;
    GtkTreeSelection *selection;
    GtkTreeModel *model;
    GList *selected_rows;
    gchar *file_name;

    if(debug) {
	fprintf(log_file, "[%s:%3i] %s() called\n", __FILE__, __LINE__, __FUNCTION__);
	fflush(log_file);
    }

    selection = g_list_nth_data(argument_list, 1);
    selected_rows = gtk_tree_selection_get_selected_rows(selection, &model);

    /* anything selected ? */
    if(g_list_length(selected_rows) > 0) {

	if(debug) {
	    fprintf(log_file, "[%s:%3i] %s(): %i songs selected\n", __FILE__, __LINE__, __FUNCTION__, g_list_length(selected_rows));
	    fflush(log_file);
	}
	selected_rows = g_list_first(selected_rows);
	while(selected_rows != NULL) {
	    gtk_tree_model_get_iter(model, &iter, selected_rows->data);

	    gtk_tree_model_get(model, &iter, COLUMN_FILE, &file_name, -1);
	    if(debug) {
		fprintf(log_file, "[%s:%3i] %s(): file_name = %s\n", __FILE__, __LINE__, __FUNCTION__, file_name);
		fflush(log_file);
	    }
	    song_list = g_list_append(song_list, file_name);
	    /* g_free(file_name); */
	    selected_rows = g_list_next(selected_rows);
	}
	list_length = g_list_length(song_list);
	/* free selected rows list */
	g_list_foreach (selected_rows, (GFunc)gtk_tree_path_free, NULL);
	g_list_free(selected_rows);
    }
    /* nothing selected, add all found songs; maybe not the best way, but never mind */
    else {
	song_list = g_list_nth_data(argument_list, 0);
	list_length = g_list_length(song_list);
	if(debug) {
	    fprintf(log_file, "[%s:%3i] %s(): list_length = %i\n", __FILE__, __LINE__, __FUNCTION__, list_length);
	    fflush(log_file);
	}
    }

    /* add songs */

    for(i = 0; i < list_length; i++) {
	if(debug) {
	    fprintf(log_file, "[%s:%3i] %s(): song to add = %s\n", __FILE__, __LINE__, __FUNCTION__, (char *)song_list->data);
	    fflush(log_file);
	}
	mpd_playlist_queue_add(mpd_info.obj, song_list->data);
	song_list = g_list_next(song_list);
    }

    mpd_playlist_queue_commit(mpd_info.obj);


    /* free song list *
    g_list_foreach(song_list, (GFunc)g_free, NULL);
    g_list_free(song_list); */

    return;
}