DND help needed.



Hi,

I'm stuck in trying to implement DND in a little app.

I want to implement DND in a GtkCtree.
I created GtkTargetEntry for drag types and drop types. Then i've connected
'drag_begin', 'drag_end', 'drag_motion', 'drag_leave' and 'drag_data_recevied'
signal to fake callback (just do g_message in them) to see what happen.
I've understood the purpose of the fisrt four, but i've never managed to
trigger the last one, 'drag_data_recevied', and it seems to be the more
important...

I've look in gmc code and balsa code but i've not enough knownledge to figure
out what stucks me.

Can you help me ?
Thanks in advance

Here is the code related to DND stuff in my code :
typedef enum {
	TARGET_TEXT_PLAIN
} TargetType;

static GtkTargetEntry drag_types [] = {
	{ TARGET_TEXT_PLAIN_TYPE, 0,  TARGET_TEXT_PLAIN}
};

static GtkTargetEntry drop_types [] = {
	{ TARGET_TEXT_PLAIN_TYPE, 0,  TARGET_TEXT_PLAIN}
};

(...)
	gtk_drag_source_set (GTK_WIDGET (ctree), GDK_BUTTON1_MASK | GDK_BUTTON2_MASK,
			     drag_types, 1,
			     (GDK_ACTION_LINK | GDK_ACTION_MOVE | GDK_ACTION_COPY
			      | GDK_ACTION_ASK | GDK_ACTION_DEFAULT));
			
	gtk_drag_dest_set (GTK_WIDGET (ctree),
			   GTK_DEST_DEFAULT_DROP,
			   drop_types, 1,
			   GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK | GDK_ACTION_ASK);

	gtk_signal_connect (GTK_OBJECT (ctree), "drag_data_received",
			    GTK_SIGNAL_FUNC (drag_data_received_cb), NULL);

	gtk_signal_connect (GTK_OBJECT (ctree), "drag_motion",
			    GTK_SIGNAL_FUNC (drag_motion_cb), NULL);
	gtk_signal_connect (GTK_OBJECT (ctree), "drag_leave",
			    GTK_SIGNAL_FUNC (drag_leave_cb), NULL);
	gtk_signal_connect (GTK_OBJECT (ctree), "drag_begin",
			    GTK_SIGNAL_FUNC (drag_begin_cb), NULL);
	gtk_signal_connect (GTK_OBJECT (ctree), "drag_end",
			    GTK_SIGNAL_FUNC (drag_end_cb), NULL);

And here is one exemple of callbaks :
void drag_data_received_cb(GtkWidget* widget, GdkDragContext *drag_context, gint x, gint y, GtkSelectionData *data, guint info, guint time, gpointer user_data)
{
  static int count = 0;

  g_message("Signal : drag_data_received (%d) : %d %d %d %d", count, x, y, info, time );
  print_drag_context(drag_context);
  count++;
}



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