moving nodes in trees



I'm writing a tree editor that uses gtk+ and I'm having problems moving
nodes around. I'm looking for some working example code.

I've got a working program that loads my data into a TreeStore and
displays it in a TreeView. The user can drag and drop nodes and that
works fine. But it's a bit fiddly to drop nodes in exactly the right
place and it's seriously impractical to drag past thousands of nodes.

So I'm trying an approach where the user selects the node to move
(confirmed with a Choose button), then navigates to some other point in
the tree, selects the destination node and presses a Move button. This
is easier to use for the user. Less context and less manual dexterity.

But I can't get it to work. I tried using gtk_tree_store_move_after. On
our production machines, which have gtk+ 2.6.4, the move fails. On a
test machine, which has gtk+ 2.10.6, the move works but it only moves
the selected node, not its descendents. So it works as I'd expect
gtk_list_store_move_after to work, not as I'd expect a *tree* move to work.

I also tried using gtk_tree_drag_source_row_draggable, which indicated
that my row was draggable, and gtk_tree_drag_source_drag_data_get, which
didn't return any data. This was on gtk+ 2.6.4. I haven't had time to
try on the newer release yet.

Updating the production machines is going to be a major pain, but I'll
do it if I have to. But I'd like to know it was going to be worthwhile
before I start :)

Does anybody have any working code that uses these functions to
manipulate trees? I haven't been able to find any examples. I don't mind
which language; I'm using the Perl bindings but I can make use of
anything. I'd just like to prove the mechanism works on my test machine
before I spend too much more time.

Thanks, Dave



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