Drag and drop items in Gtk.ListBox with GTK 4


I am working on a new app in Vala with GTK 4 and libadwaita-1. I need to enable reordering items in Gtk.ListBox with drag and drop and I am struggling with it. I didn’t find any tutorial for GTK 4 on the internet, only drag and drop demo in GTK 4 demos app. But there isn’t any example how to do that in Gtk.ListBox.

So what is the best way how to implement it?

Thank you in advance.

Edit: I looked to the source code of GNOME Control Center and I figured out how to handle dragging. But I am still struggling with handling the drop. It is still not working.

1 Like

As far as I know reordering is currently not easily available and needs lots of manual work. An alternative design is up/down arrows at the end of the row, as you can see for example in fragments.

Thanks for your reply! I already figured out how to implement drag and drop. And surprisingly, it wasn’t difficult. I only forgot to close this topic. Maybe I also could write some guide how to do that.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.