Drag and Drop
Gtk::TreeView already implements simple drag-and-drop when used with the Gtk::ListStore or Gtk::TreeStore models. If necessary, it also allows you to implement more complex behaviour when items are dragged and dropped, using the normal Drag and Drop API.
- 10.6.1. Reorderable rows
10.6.1. Reorderable rows
If you call Gtk::TreeView::set_reorderable() then your TreeView's items can be moved within the treeview itself. This is demonstrated in the TreeStore example.
However, this does not allow you any control of which items can be dragged, and where they can be dropped. If you need that extra control then you might create a derived Gtk::TreeModel from Gtk::TreeStore or Gtk::ListStore and override the Gtk::TreeDragSource::row_draggable_vfunc() and Gtk::TreeDragDest::row_drop_possible_vfunc() virtual methods. You can examine the Gtk::TreeModel::Paths provided and allow or disallow dragging or dropping by returning true or false.
This is demonstrated in the drag_and_drop example.