dnd with treeviews



Hello,

I would like to implement D'n'D between two 
TreeViews. My callback function is invoked when
I drag a line from one TreeView to the other.
But now I don't know how to determine which line(s)
of the source TreeView has been dragged or even
from which TreeView the dragged data comes.
The definitions of the TargetEntries are from
some example from the net, I simply copied it because
I have no idea which TargetEntry could match the
data type of a dragged TreeView row.

Surprising to me: the userdata in the callback function
is not the same as given in the gtk_signal_connect(), I
would expect the "ok" to be printed in the callback function.
But it isn't.

Any help is appreciated, Thanks,
Leander



// for the destination
gtk_tree_view_enable_model_drag_dest(
	GTK_TREE_VIEW(dstview),
	targetentries, 3,
	GDK_ACTION_COPY|GDK_ACTION_MOVE|GDK_ACTION_LINK
);
gtk_signal_connect( 
	dstview,
	"drag_drop",
	G_CALLBACK(mmef_drag_rec_table),
	treestore_src
);



// for the source
gtk_tree_view_enable_model_drag_source(
	GTK_TREE_VIEW(srcview),
	GDK_BUTTON1_MASK,
	targetentries,3,
	GDK_ACTION_COPY|GDK_ACTION_MOVE|GDK_ACTION_LINK
);



//my callback function
void mmef_drag_rec_table(
	GtkWidget *wgt,
	GdkDragContext *context,
	int x , int y,
	GtkSelectionData *seldata,
	guint info, guint time,
	gpointer userdata) {

printf("catch %d %d\n",x,y);
if(userdata==treestore_src) printf("ok\n");
}



// targetentries
enum { TARGET_STRING, TARGET_URL};
static GtkTargetEntry targetentries[]= {
	{ "STRING",0,TARGET_STRING },
	{ "text/plain",0,TARGET_STRING },
	{ "text/uri-list",0,TARGET_URL },
};



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]