[1.2] Drop on treeitem



I'm unable to make Drag'N'Drop work correctly on GtkTreeItem, my drop
routine works OK if called on a clist or on a tree, but I need to know
exactly on WHICH tree item the drop occurs, so I'm trying to setup my
tree calling gtk_drag_dest_set() for EACH treeitem of the tree. I've
read this should work in the 1.2 tutorial:

<<< CUT
Finally, drag-n-drop does work with TreeItems. You just have to make
sure that the TreeItem you want to make into a drag item or a drop site
has not only been added to a Tree, but that each successive parent
widget has a parent itself, all the way back to a toplevel or dialog
window, when you call gtk_widget_dnd_drag_set() or
gtk_widget_dnd_drop_set(). Otherwise, strange things will happen.


The problem is that "strange things" happen :(

The only item that is "highlighted" and is responsive to the drag is the
root node of the tree, the other items are not...

I've found a similar problem in a ML googling the net with the keys
"drag drop gtk treeitem" but no answer to it...

Here is the sequence I use to add an item to the tree (that is
configured as drag_source at its root):

1) create treeitem
2) add it to the tree
3) if it's not a node go to 7
4) make a subtree
5) attach subtree to the item
6) set drop capabilites to the item
7) show the item

This is my "SetDroppable" call, it works ok with clists or tree as
destinations and also for the root treeitem of a tree!

target_entry is the same as the dnd.c gtk example.

void windowdata::SetDroppable(GtkWidget *w, DropCbk cbk, void *user_data)
{
    gtk_drag_dest_set(
            w,
            (GtkDestDefaults)(GTK_DEST_DEFAULT_MOTION |
GTK_DEST_DEFAULT_HIGHLIGHT |
                               GTK_DEST_DEFAULT_DROP),
            target_entry,
            sizeof(target_entry) / sizeof(GtkTargetEntry),
            (GdkDragAction)(GDK_ACTION_MOVE | GDK_ACTION_COPY |
GDK_ACTION_LINK)
            );

    gtk_signal_connect(
            GTK_OBJECT(w), "drag_data_received",
            GTK_SIGNAL_FUNC(cbk), user_data
            );

}

Bye,
 Gabry








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