mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-09 18:30:08 +00:00
maplistmodel: Handle the ::sections-changed signal
Wrapper section models need to listen to and pass on the ::sections-changed signal from the underlying model.
This commit is contained in:
parent
32a3690a3c
commit
9590a5f45e
@ -22,6 +22,7 @@
|
||||
#include "gtkmaplistmodel.h"
|
||||
|
||||
#include "gtkrbtreeprivate.h"
|
||||
#include "gtksectionmodel.h"
|
||||
#include "gtkprivate.h"
|
||||
|
||||
/**
|
||||
@ -54,6 +55,8 @@
|
||||
*
|
||||
* `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 {
|
||||
@ -225,6 +228,16 @@ gtk_map_list_model_get_section (GtkSectionModel *model,
|
||||
*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)
|
||||
{
|
||||
@ -362,6 +375,7 @@ gtk_map_list_model_clear_model (GtkMapListModel *self)
|
||||
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);
|
||||
}
|
||||
@ -633,6 +647,9 @@ gtk_map_list_model_set_model (GtkMapListModel *self,
|
||||
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
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user