views:

19

answers:

2

As the title suggests, I have a pygtk.TreeView whose model is sorted and filtered. According to the documentation: "Drag and drop reordering of rows only works with unsorted stores.". The only other information given relates to using external sources, which in this case I don't need.

I tried implementing it anyway, providing handlers to the drag-dest received and drag-drop signals, but still get the following error:

GtkWarning: You must override the default 'drag_data_received' handler on GtkTreeView when using models that don't support the GtkTreeDragDest interface and enabling drag-and-drop. The simplest way to do this is to connect to 'drag_data_received' and call g_signal_stop_emission_by_name() in your signal handler to prevent the default handler from running. Look at the source code for the default handler in gtktreeview.c to get an idea what your handler should do. (gtktreeview.c is in the GTK source code.) If you're using GTK from a language other than C, there may be a more natural way to override default handlers, e.g. via derivation.

Despite this, although I haven't implemented it yet, it looks like I could make it work, since it doesn't crash. Nevertheless, this is a warning I'd rather not have.

So, Is there a python equivalent of g_signal_stop_emission_by_name, or am I going about this the wrong way?

A: 

It is gobject.GObject.emit_stop_by_name(). I don't know if what you are doing will succeed, but there is no "standard" way I can think of.

Instead of implementing yourself, you could try using Py-gtktree: see example called drag_between_tree_and_list.py. You can sort the tree on the right and still be able to drag into it with items dragged in automatically placed in the "correct" position. It doesn't allow draggin anywhere into the tree, but for a different reason: example explicitly requests this.

doublep
A: 

I got rid of the warning by using treeview.stop_emission('drag-drop-received') in my own drag-drop-received signal handler. Perhaps the method by doublep will also work, although I haven't tried it.

rioch