TreeView: disable drop before or after a row



Hi,

I'm writing an application with gtkmm. I write my own derived TreeModel
(derived from GtkTreeStore), and in the process I've been reading GTK
source code a lot, gtktreeview.c and gtktreestore.c, because that's
where things are actually implemented.

I've been looking for a way to disable drag-n-drop between rows. As you
probably know, a drop can happen between rows (then the GUI shows a thin
line where the drop would happen) or on a row (then the GUI highlights
the drop destination row).

The automatic DnD doesn't work with sorting, so it's currently off, but
even if I eventually use my own sorting code, the model will be sorted.
Just like when I open Nautilus and watch a folder's contents in the
list-view mode - it doesn't make sense to drop between rows because the
order is determined by the sorting code, not by the user.

I found several locations in the code, which I believe are responsible
to start the graphical highlight when the cursor moves while dragging a
row. But I'm not sure I covered all cases and found everything I need,
so I'd like to know:

Basically, which signal handlers do I need to override, and/or which
stages of DnD process require my intervension, in order to avoid any
highlighting of drop-between-rows (i.e. never draw that thin line
between the rows) ?

I figured out overriding drag_dest_row_drop_possible (), i.e. in the
gtkmm case overriding Gtk::TreeDragDest::row_drop_possible_vfunc(), can
help avoid the drop itself, but does it also mean the lines aren't drawn
in the first place? Do I also need to override TreeView signal handlers,
e.g. gtk_tree_view_drag_motion() ?

I found an internal function set_destination_row() which seems to be
responsible for highlighting the rows by calling public method
gtk_tree_view_set_drag_dest_row() but I can't override either, so I
guess the workaround, if it's really the solution, is to find all the
places where these methods are called and make sure the
drop-between-rows case is ignored.

Thanks in advance,
Tom



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