From: Benjamin Otte Date: Sat, 11 Jun 2022 02:51:41 +0000 (+0200) Subject: selectionfiltermodel: Add ::item-type and ::n-items X-Git-Tag: archive/raspbian/4.8.3+ds-2+rpi1~3^2~20^2~4^2~131^2~12 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=e1845f5e90bb73320e911adb030831d9dfe8170f;p=gtk4.git selectionfiltermodel: Add ::item-type and ::n-items --- diff --git a/gtk/gtkselectionfiltermodel.c b/gtk/gtkselectionfiltermodel.c index 3745721d82..e5ad87137b 100644 --- a/gtk/gtkselectionfiltermodel.c +++ b/gtk/gtkselectionfiltermodel.c @@ -34,7 +34,10 @@ enum { PROP_0, + PROP_ITEM_TYPE, PROP_MODEL, + PROP_N_ITEMS, + NUM_PROPERTIES }; @@ -127,6 +130,8 @@ selection_filter_model_items_changed (GtkSelectionFilterModel *self, if (sel_removed > 0 || sel_added > 0) g_list_model_items_changed (G_LIST_MODEL (self), sel_position, sel_removed, sel_added); + if (sel_removed != sel_added) + g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_N_ITEMS]); } static void @@ -178,10 +183,18 @@ gtk_selection_filter_model_get_property (GObject *object, switch (prop_id) { + case PROP_ITEM_TYPE: + g_value_set_gtype (value, gtk_selection_filter_model_get_item_type (G_LIST_MODEL (self))); + break; + case PROP_MODEL: g_value_set_object (value, self->model); break; + case PROP_N_ITEMS: + g_value_set_uint (value, gtk_selection_filter_model_get_n_items (G_LIST_MODEL (self))); + break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -220,6 +233,18 @@ gtk_selection_filter_model_class_init (GtkSelectionFilterModelClass *class) gobject_class->get_property = gtk_selection_filter_model_get_property; gobject_class->dispose = gtk_selection_filter_model_dispose; + /** + * GtkSelectionFilterModel:item-type: + * + * The type of items. See [method@Gio.ListModel.get_item_type]. + * + * Since: 4.8 + **/ + properties[PROP_ITEM_TYPE] = + g_param_spec_gtype ("item-type", NULL, NULL, + G_TYPE_OBJECT, + G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); + /** * GtkSelectionFilterModel:model: (attributes org.gtk.Property.get=gtk_selection_filter_model_get_model org.gtk.Property.set=gtk_selection_filter_model_set_model) * @@ -230,6 +255,18 @@ gtk_selection_filter_model_class_init (GtkSelectionFilterModelClass *class) GTK_TYPE_SELECTION_MODEL, GTK_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY); + /** + * GtkSelectionFilterModel:n-items: + * + * The number of items. See [method@Gio.ListModel.get_n_items]. + * + * Since: 4.8 + **/ + properties[PROP_N_ITEMS] = + g_param_spec_uint ("n-items", NULL, NULL, + 0, G_MAXUINT, 0, + G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); + g_object_class_install_properties (gobject_class, NUM_PROPERTIES, properties); } @@ -300,6 +337,8 @@ gtk_selection_filter_model_set_model (GtkSelectionFilterModel *self, if (removed > 0 || added > 0) g_list_model_items_changed (G_LIST_MODEL (self), 0, removed, added); + if (removed != added) + g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_N_ITEMS]); g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_MODEL]); }