Sign up

How to make a custom TreeModel reorderable?

I've been slowly wrapping my head around working with TreeViews, and TreeModels, and I've derived a class from TreeModel, so it can interface with a class that already handles storage.

But now, I'd like to make it so I can to tree.setReorderable(true), and drag-drop to reorder the various items in the TreeModel, and I'm not at all sure how to go about telling GTK that my derived TreeModel is reorderable, and how to do that reordering.

Re: How to make a custom TreeModel reorderable?

On 12/26/2013 01:30 AM, E.S. Quinn wrote:

I've been slowly wrapping my head around working with TreeViews, and TreeModels, and I've derived a class from TreeModel, so it can interface with a class that already handles storage.

But now, I'd like to make it so I can to tree.setReorderable(true), and drag-drop to reorder the various items in the TreeModel, and I'm not at all sure how to go about telling GTK that my derived TreeModel is reorderable, and how to do that reordering.

I think your custom TreeModel also needs to implement the TreeDragSource
and TreeDragDest interfaces to support reordering.

It's currently not easy to get these implemented properly with GtkD, but
ill look into it.

Re: How to make a custom TreeModel reorderable?

On Thu, 26 Dec 2013 12:36:39 +0100, Mike Wey wrote:

On 12/26/2013 01:30 AM, E.S. Quinn wrote:

I've been slowly wrapping my head around working with TreeViews, and TreeModels, and I've derived a class from TreeModel, so it can interface with a class that already handles storage.

But now, I'd like to make it so I can to tree.setReorderable(true), and drag-drop to reorder the various items in the TreeModel, and I'm not at all sure how to go about telling GTK that my derived TreeModel is reorderable, and how to do that reordering.

I think your custom TreeModel also needs to implement the TreeDragSource
and TreeDragDest interfaces to support reordering.

It's currently not easy to get these implemented properly with GtkD, but
ill look into it.

Gotcha! It also occurs to me, re-reading through various GTK and GtkD docs, that it might be better to subclass ListStore, and just override everything so it doesn't touch ListStore's internal storage. Would this sort of thing work?

Re: How to make a custom TreeModel reorderable?

On 12/26/2013 12:54 PM, E.S. Quinn wrote:

On Thu, 26 Dec 2013 12:36:39 +0100, Mike Wey wrote:

On 12/26/2013 01:30 AM, E.S. Quinn wrote:

I've been slowly wrapping my head around working with TreeViews, and TreeModels, and I've derived a class from TreeModel, so it can interface with a class that already handles storage.

But now, I'd like to make it so I can to tree.setReorderable(true), and drag-drop to reorder the various items in the TreeModel, and I'm not at all sure how to go about telling GTK that my derived TreeModel is reorderable, and how to do that reordering.

I think your custom TreeModel also needs to implement the TreeDragSource
and TreeDragDest interfaces to support reordering.

It's currently not easy to get these implemented properly with GtkD, but
ill look into it.

Gotcha! It also occurs to me, re-reading through various GTK and GtkD docs, that it might be better to subclass ListStore, and just override everything so it doesn't touch ListStore's internal storage. Would this sort of thing work?

Currently overriding anything in the Liststore doesn't have any affect
in the C / Gtk+ side of things.

Re: How to make a custom TreeModel reorderable?

Gotcha! It also occurs to me, re-reading through various GTK and GtkD docs, that it might be better to subclass ListStore, and just override everything so it doesn't touch ListStore's internal storage. Would this sort of thing work?

Currently overriding anything in the Liststore doesn't have any affect
in the C / Gtk+ side of things.

Rats! That does make perfect sense, thinking about it now. Fortunately, drag reordering is nice, but not critical for my app, so that can wait :)

Re: How to make a custom TreeModel reorderable?

On Wed, 01 Jan 2014 02:02:36 GMT, E.S. Quinn wrote:

Gotcha! It also occurs to me, re-reading through various GTK and GtkD docs, that it might be better to subclass ListStore, and just override everything so it doesn't touch ListStore's internal storage. Would this sort of thing work?

Currently overriding anything in the Liststore doesn't have any affect
in the C / Gtk+ side of things.

Rats! That does make perfect sense, thinking about it now. Fortunately, drag reordering is nice, but not critical for my app, so that can wait :)

I've a copy of the DemoCustomlist demo that supports reordering by dragging and dropping.
You can find it in the Gist here: https://gist.github.com/MikeWey/8223114

The original can be found in the demos/gtkD/DemoCustomList directory:
https://github.com/gtkd-developers/GtkD/tree/master/demos/gtkD/DemoCustomList

Re: How to make a custom TreeModel reorderable?

On Thu, 02 Jan 2014 17:55:00 GMT, Mike Wey wrote:

On Wed, 01 Jan 2014 02:02:36 GMT, E.S. Quinn wrote:

Gotcha! It also occurs to me, re-reading through various GTK and GtkD docs, that it might be better to subclass ListStore, and just override everything so it doesn't touch ListStore's internal storage. Would this sort of thing work?

Currently overriding anything in the Liststore doesn't have any affect
in the C / Gtk+ side of things.

Rats! That does make perfect sense, thinking about it now. Fortunately, drag reordering is nice, but not critical for my app, so that can wait :)

I've a copy of the DemoCustomlist demo that supports reordering by dragging and dropping.
You can find it in the Gist here: https://gist.github.com/MikeWey/8223114

The original can be found in the demos/gtkD/DemoCustomList directory:
https://github.com/gtkd-developers/GtkD/tree/master/demos/gtkD/DemoCustomList

Thank you so much!

Re: How to make a custom TreeModel reorderable?

On Fri, 03 Jan 2014 22:51:15 GMT, E.S. Quinn wrote:

On Thu, 02 Jan 2014 17:55:00 GMT, Mike Wey wrote:

On Wed, 01 Jan 2014 02:02:36 GMT, E.S. Quinn wrote:

Gotcha! It also occurs to me, re-reading through various GTK and GtkD docs, that it might be better to subclass ListStore, and just override everything so it doesn't touch ListStore's internal storage. Would this sort of thing work?

Currently overriding anything in the Liststore doesn't have any affect
in the C / Gtk+ side of things.

Rats! That does make perfect sense, thinking about it now. Fortunately, drag reordering is nice, but not critical for my app, so that can wait :)

I've a copy of the DemoCustomlist demo that supports reordering by dragging and dropping.
You can find it in the Gist here: https://gist.github.com/MikeWey/8223114

The original can be found in the demos/gtkD/DemoCustomList directory:
https://github.com/gtkd-developers/GtkD/tree/master/demos/gtkD/DemoCustomList

Thank you so much!

I just got that stuff implemented in one of my own custom List models, and it works great. Thanks for going through the effort to put this together!