Sign up

how can I delete all the rows in a Gtk ListBox?

How can I delete all the rows in a Gtk ListBox?
Is there a simple listbox (like ComboBoxText) that maintains its own internal model, or do I have to create a ListStore myself?

Re: how can I delete all the rows in a Gtk ListBox?

On 03-04-2020 13:19, mark wrote:

How can I delete all the rows in a Gtk ListBox?
Is there a simple listbox (like ComboBoxText) that maintains its own internal model, or do I have to create a ListStore myself?

Looping over all the children and removing them, i think is the only
option to remove all the rows:

foreach( widget; listbox.getChildren().toArray!Widget)
	box.remove(widget);

I don't think gtk.ListBox allows you to set the model, so there is only
the simple version?

Re: how can I delete all the rows in a Gtk ListBox?

On Fri, 3 Apr 2020 23:15:51 +0200, Mike Wey wrote:

On 03-04-2020 13:19, mark wrote:

How can I delete all the rows in a Gtk ListBox?
Is there a simple listbox (like ComboBoxText) that maintains its own internal model, or do I have to create a ListStore myself?

Looping over all the children and removing them, i think is the only
option to remove all the rows:

foreach( widget; listbox.getChildren().toArray!Widget)
	box.remove(widget);

I don't think gtk.ListBox allows you to set the model, so there is only
the simple version?

Thanks for that information. But how did you know about getChildren? I read the docs on https://api.gtkd.org/gtk.ListBox.ListBox.html and there's no mention of this method. Nor does there seem to be a superclass that I could look into for this method.

So I wonder what other methods exist for ListBox and how I can find them?

Re: how can I delete all the rows in a Gtk ListBox?

On 04-04-2020 00:40, mark wrote:

Thanks for that information. But how did you know about getChildren? I read the docs on https://api.gtkd.org/gtk.ListBox.ListBox.html and there's no mention of this method. Nor does there seem to be a superclass that I could look into for this method.

So I wonder what other methods exist for ListBox and how I can find them?

The link in the documantation seems to be broken, but Listbox is a child
of gtk.Container.

https://api.gtkd.org/gtk.Container.Container.html