mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-12 15:36:17 +01:00
liststore: Add "n-items" property
This commit is contained in:
parent
9b55841d78
commit
6b62d63d36
@ -64,6 +64,7 @@ enum
|
|||||||
{
|
{
|
||||||
PROP_0,
|
PROP_0,
|
||||||
PROP_ITEM_TYPE,
|
PROP_ITEM_TYPE,
|
||||||
|
PROP_N_ITEMS,
|
||||||
N_PROPERTIES
|
N_PROPERTIES
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -89,6 +90,8 @@ g_list_store_items_changed (GListStore *store,
|
|||||||
}
|
}
|
||||||
|
|
||||||
g_list_model_items_changed (G_LIST_MODEL (store), position, removed, added);
|
g_list_model_items_changed (G_LIST_MODEL (store), position, removed, added);
|
||||||
|
if (removed != added)
|
||||||
|
g_object_notify_by_pspec (G_OBJECT (store), properties[PROP_N_ITEMS]);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -115,6 +118,10 @@ g_list_store_get_property (GObject *object,
|
|||||||
g_value_set_gtype (value, store->item_type);
|
g_value_set_gtype (value, store->item_type);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case PROP_N_ITEMS:
|
||||||
|
g_value_set_uint (value, g_sequence_get_length (store->items));
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||||
}
|
}
|
||||||
@ -161,6 +168,17 @@ g_list_store_class_init (GListStoreClass *klass)
|
|||||||
g_param_spec_gtype ("item-type", "", "", G_TYPE_OBJECT,
|
g_param_spec_gtype ("item-type", "", "", G_TYPE_OBJECT,
|
||||||
G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
|
G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GListStore:n-items:
|
||||||
|
*
|
||||||
|
* The number of items contained in this list store.
|
||||||
|
*
|
||||||
|
* Since: 2.74
|
||||||
|
**/
|
||||||
|
properties[PROP_N_ITEMS] =
|
||||||
|
g_param_spec_uint ("n-items", "", "", 0, G_MAXUINT, 0,
|
||||||
|
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
|
||||||
|
|
||||||
g_object_class_install_properties (object_class, N_PROPERTIES, properties);
|
g_object_class_install_properties (object_class, N_PROPERTIES, properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user