コード例 #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);
}
コード例 #2
0
ファイル: mpd-easy-commands.c プロジェクト: emillon/gmpc
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);
}
コード例 #3
0
ファイル: mpd.c プロジェクト: BackupTheBerlios/lcd-stuff
/* -------------------------------------------------------------------------- */
static void mpd_menu_handler(const char *event, const char *id, const char *arg, void *cookie)
{
    char **ids;
    struct lcd_stuff_mpd *mpd = (struct lcd_stuff_mpd *)cookie;

    if (strlen(id) == 0)
        return;

    ids = g_strsplit(id, "_", 2);

    if ((g_ascii_strcasecmp(ids[0], "pl") == 0) && (ids[1] != NULL)) {
        int no = atoi(ids[1]) - 1;

        if (no == -1) {
            mpd_playlist_clear(mpd->mpd);
            mpd_playlist_queue_commit(mpd->mpd);
        } else if (mpd->current_list && (no < (int)mpd->current_list->len)) {
            char *list;
            list = g_strconcat(mpd->current_list->pdata[no], NULL);
            mpd_playlist_queue_load(mpd->mpd, list);
            mpd_playlist_queue_commit(mpd->mpd);

            if (mpd->current_state != MPD_PLAYER_PLAY)
                mpd_player_play(mpd->mpd);

            g_free(list);
        }
    } else if ((g_ascii_strcasecmp(ids[0], "standby") == 0)) {
        int min = atoi(arg) * 15;
        if (min == 0) {
            mpd->stop_time = INT_MAX;
        } else {
            mpd->stop_time = time(NULL) + 60 * min;
        }
    }

    g_strfreev(ids);
}
コード例 #4
0
/* delete songs from playlist */
void pl_del_songs(GtkWidget *widget, gpointer data) {
    GtkTreeIter iter;
    int i, selection_length;
    gint *pl_id;
    GList *selection;
    GtkTreeModel *tree_model;

    pl_id = (gint *)-32;

    selection = gtk_tree_selection_get_selected_rows(GTK_TREE_SELECTION(data), &tree_model);
    selection_length = g_list_length(selection);
    if(debug) {
	fprintf(log_file, "[%s:%3i] %s(): selection length = %i\n", __FILE__, __LINE__, __FUNCTION__, selection_length);
	fflush(log_file);
    }

    if(mpd_info.msi.connected) {
	if(!mpd_check_connected(mpd_info.obj))
	    if(mpd_connect(mpd_info.obj) != MPD_OK) {
		msi_clear(&mpd_info);
		mpd_info.msi.connected = FALSE;
		return;
	    }
	msi_fill(&mpd_info);
	mpd_info.msi.connected = TRUE;
    }
    for(i=0; i<selection_length; i++) {
	gtk_tree_model_get_iter(tree_model, &iter, selection->data);
	gtk_tree_model_get(tree_model, &iter, COLUMN_PL_ID, &pl_id, -1);
	if(debug) {
	    fprintf(log_file, "[%s:%3i] %s(): song id = %i\n", __FILE__, __LINE__, __FUNCTION__, (int)pl_id);
	    fflush(log_file);
	}
	mpd_playlist_queue_delete_id(mpd_info.obj, (int)pl_id);
	selection = g_list_next(selection);
    }
    mpd_playlist_queue_commit(mpd_info.obj);
    fprintf(log_file, "[%s:%3i] %s(): finished deleting songs\n", __FILE__, __LINE__, __FUNCTION__);
    g_list_foreach (selection, (GFunc)gtk_tree_path_free, NULL);
    g_list_free (selection);
    return;
}
コード例 #5
0
ファイル: libmpd-playlist.c プロジェクト: AndTH/Theremin
int mpd_playlist_delete_pos(MpdObj *mi, int songpos)
{
	int retv = mpd_playlist_queue_delete_pos(mi, songpos);
	if(retv != MPD_OK) return retv;
	return mpd_playlist_queue_commit(mi);
}
コード例 #6
0
ファイル: libmpd-playlist.c プロジェクト: AndTH/Theremin
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);
}
コード例 #7
0
/* 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;
}