having GtkListBox with text GtkLabels (which added and removed dynamically at listbox lifecycle), is it okay (taking in mind used memory) to not dispose them manually at removing? (note: the labels are referenced only in this listbox)
GtkWidget *label = gtk_widget_get_first_child(listbox);
if (label) {
if (GTK_IS_LABEL(label)) gtk_label_set_text(GTK_LABEL(label), NULL);
gtk_list_box_remove(GTK_LIST_BOX(listbox), label);
// g_object_run_dispose(G_OBJECT(label)); // is it necessary?
}
Yes: when you add a child to a parent widget, the parent acquires a reference of the child. Removing the child will release that reference. If you haven’t acquired your own reference, then the reference owned by the parent is the last one, and the widget gets collected.
There’s basically no reason whatsoever for people to call this function. At most, you want to call g_object_unref()—though not in this case.
If your GtkListBox is made of heterogenous rows, you probably want to look at using a model, and binding it to GtkListBox with gtk_list_box_bind_model(), so you’re not responsible for adding/removing widgets, and instead you’re only responsible of creating the row widget representing the contents of a model.