GtkTree + Drag and Drop



hello,

i have a little understanding problem with the gtktree and it's drag and
drop capabilities. with the following lines i like to describe the
situation i am in and would like to ask if someone could give me some
more background informations.

first of all i would like to let you know that i spent the past couple
of days experimenting with this stuff and i am quite successful with my
experiments but this still leaves some gaps of understanding open. i
read the few lines of drag and drop from the gtktutorial, read the
gtkdnd.c example from the gtk+ sourcetree and spent some more time
reading other tree examples dealing with drag and drop from the same
sourcetree. so basically a good foundation of knowledge exist already.

now the problem situation:
--------------------------

say i have build up a gtktree and populated it with different values,
nodes, leaves (basically a complete btree is stored inside it). now to
get drag and drop support inside it i have called:

gtk_tree_view_enable_model_drag_dest ();
gtk_tree_view_enable_model_drag_source ();

the matching target_table is set up as well and after compiling the app
it allows me to pic up the elements inside my tree and drag and drop
them around there. so far so good. this also saved me to use the
gtk_drag_source_set and *_dest_set calls.

so far: i have the gtktree, it's populated with values, i can drag and
drop stuff from that tree around inside it.

now let's continue, i have an entry field somewhere in my application
and as you know it does drag and drop on it's own, there is no need to
connect a source or destination to it (at least i think). you simply
select the text and by pressing the left mousebutton you can drag the
text around.

now i want to drag my selected text from the entryfield to my tree. this
also works, i see that the selected stuff is pointing to my tree and
that it uncollapse the nodes (if required) and i also see the
underlaying position marker where i could drop my selection.

i have now connected the 'drag_data_received' signal to my tree which
only calls a g_print ("'%d'\n", selectiondata->data) and i can see the
selected text in the terminal whenever i drop the selected text from my
entryfield to the tree.

so far i am happy with the results, i have a populated, tree, i am able
to drag and drop stuff around inside the tree, and i can see my selected
text in the g_print whenever i drop it in the tree.

the point and my problem here is:

how do i get the path of the tree where i have dropped the element ? i
have extended the callback of my 'drag_data_received' signal with the
function:

gtk_tree_view_get_drag_dest_row ();

when i now drag and drop stuff elements inside my tree then it gives me
back the path. but when i drag stuff from my entry field to the tree
then it does not return the path.

i now added a 'drag_motion' signal to the tree where i permanently call
the above gtk function and now i am able to return the correct path and
store it somewhere in my private structure. but somehow this doesn't
really satisfy me and i am not sure if this is the right approach to do
this kind of stuff.

i saw in the few examples that people changed the entire interface of
the tree but i am also not sure if this is the right approach to do this
kind of stuff.

i would be happy to get some advise from someone who knows more about
these things and probably came up with a suitable solution. maybe some
general informations why people change the interface and what advantages
it may give me when using it. if i should use it for my problem, i don't
know. and more important how i could solve my current problem as
described above in a good way.

greetings,

ali akcaagac




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