Arrastrar y soltar

Gtk::TreeView ya implementa un simple «arrastrar y soltar» cuando se usa con los modelos Gtk::ListStore o Gtk::TreeStore. Si es necesario, también le permite implementar un comportamiento más complejo cuando se arrastran y sueltan los elementos, usando la API de Arrastrar y soltar normal.

10.6.1. Filas reordenables

Si llama a Gtk::TreeView::set:reorderable, entonces se podrán mover los elementos de su «TreeView» dentro del «TreeView» en sí. Esto se demuestra en el ejemplo TreeStore.

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.

Esto se demuestra en el ejemplo «drag_and_drop».