#include "gtkmaplistmodel.h"
#include "gtkrbtreeprivate.h"
+#include "gtksectionmodel.h"
#include "gtkprivate.h"
/**
*
* `GtkMapListModel` will attempt to discard the mapped objects as soon as
* they are no longer needed and recreate them if necessary.
+ *
+ * `GtkMapListModel` passes through sections from the underlying model.
*/
enum {
*out_end = self->model ? g_list_model_get_n_items (self->model) : 0;
}
+static void
+gtk_map_list_model_sections_changed_cb (GtkSectionModel *model,
+ unsigned int position,
+ unsigned int n_items,
+ gpointer user_data)
+{
+ gtk_section_model_sections_changed (GTK_SECTION_MODEL (user_data), position, n_items);
+}
+
+
static void
gtk_map_list_model_section_model_init (GtkSectionModelInterface *iface)
{
if (self->model == NULL)
return;
+ g_signal_handlers_disconnect_by_func (self->model, gtk_map_list_model_sections_changed_cb, self);
g_signal_handlers_disconnect_by_func (self->model, gtk_map_list_model_items_changed_cb, self);
g_clear_object (&self->model);
}
self->model = g_object_ref (model);
g_signal_connect (model, "items-changed", G_CALLBACK (gtk_map_list_model_items_changed_cb), self);
added = g_list_model_get_n_items (model);
+
+ if (GTK_IS_SECTION_MODEL (model))
+ g_signal_connect (model, "sections-changed", G_CALLBACK (gtk_map_list_model_sections_changed_cb), self);
}
else
{