Glisser-déposer

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.

X.VI.I. Réarrangement de lignes

Si vous faites appel à la fonction membre Gtk::TreeView::set_reorderable(), les éléments d'un objet TreeView peuvent être déplacés au sein même de la vue arborescente. Ceci est montré dans l'exemple 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.

Cette construction est montrée dans l'exemple du glisser-déposer.