Dnd in gtk_tree ?



Hi
I've got a problem in doing drag'n drop into a gtk_tree.
I've an application which I split in two different part, the left one is
a gtk_tree, and the right one is a canvas.
I've succeed in doing a drag'n drop from the gtk_tree to canvas. But
when
I want to do Drag'n drop from gtk_tree to itself, I never succeed.
Could you explain my errors ?

Here is a part of my code :
Add_component1 (...) {
	tree_entry = gtk_tree_item_new ();
	label = gtk_label_new (get_name(key));
	hbox = gtk_hbox_new (FALSE, 1);
	image = gnome_pixmap_new_from_file_at_size ( GASPARD_IMAGE_COMPOUND,
		GASPARD_ICON_HEIGHT, GASPARD_ICON_WIDTH);
	gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0);
	gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
	gtk_container_add (GTK_CONTAINER (tree_entry), hbox);
	gtk_tree_append (GTK_TREE (arbre), tree_entry);
	drag_icon = gdk_pixmap_colormap_create_from_xpm_d (NULL,
		gtk_widget_get_colormap (mainApp_Window),
		&drag_mask, NULL, GASPARD_DRAG_ICON);
	gtk_drag_source_set (tree_entry, GDK_BUTTON2_MASK, target_table, 
		2, GDK_ACTION_COPY|GDK_ACTION_MOVE);
	gtk_drag_source_set_icon (tree_entry, gtk_widget_get_colormap
		(mainApp_Window), drag_icon, drag_mask);
	gdk_pixmap_unref (drag_icon);
	gdk_pixmap_unref (drag_mask);
	gtk_signal_connect (GTK_OBJECT (tree_entry), "drag_data_get",
		GTK_SIGNAL_FUNC (source_drag_data_get), key);
	gtk_signal_connect (GTK_OBJECT (tree_entry), "drag_data_delete",
		GTK_SIGNAL_FUNC (source_drag_data_delete), NULL);
}

Add_component2 (...) {
	tree_entry = gtk_tree_item_new ();
	key = create_iterative_slot ();
	hbox = gtk_hbox_new (FALSE, 1);
	label = gtk_label_new (get_name (key));
	image = gnome_pixmap_new_from_file_at_size (
		GASPARD_IMAGE_ITERATIVE_SLOT, 
		GASPARD_ICON_HEIGHT, GASPARD_ICON_WIDTH);
	gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0);
	gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
	gtk_container_add (GTK_CONTAINER (tree_entry), hbox);

	gtk_drag_dest_set (tree_entry, GTK_DEST_DEFAULT_ALL, target_table,
		 n_targets, GDK_ACTION_COPY | GDK_ACTION_MOVE);

	gtk_signal_connect (GTK_OBJECT (tree_entry), "drag_leave",
		GTK_SIGNAL_FUNC (list_drag_leave), NULL);
	gtk_signal_connect (GTK_OBJECT (tree_entry), "drag_motion",
		GTK_SIGNAL_FUNC (list_drag_motion), NULL);
	gtk_signal_connect (GTK_OBJECT (tree_entry), "drag_drop",
		GTK_SIGNAL_FUNC (list_drag_drop), NULL);
	gtk_signal_connect (GTK_OBJECT (tree_entry), "drag-data-received",
		GTK_SIGNAL_FUNC (list_drag_data_received), NULL);
}

Note that I haven't set anything for the gtk_tree_itself, but only for
gtk_tree_item. I didn't set any signal for the gtk_tree, because the
gtk_tree_item on which I drop is a significant for me.



-- 
Florent DEVIN




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