[gnome-keyring: 9/12] gcr: Add gcr_union_collection_have() and gcr_union_collection_size()



commit a33d38d1efc6c74b878680c00d94316cc57e3712
Author: Stef Walter <stefw collabora co uk>
Date:   Fri Sep 9 12:22:06 2011 +0200

    gcr: Add gcr_union_collection_have() and gcr_union_collection_size()
    
     * Used to check wether a collection is part of the union.

 docs/reference/gcr/gcr-sections.txt |    2 ++
 gcr/gcr-union-collection.c          |   34 ++++++++++++++++++++++++++++++++++
 gcr/gcr-union-collection.h          |    5 +++++
 3 files changed, 41 insertions(+), 0 deletions(-)
---
diff --git a/docs/reference/gcr/gcr-sections.txt b/docs/reference/gcr/gcr-sections.txt
index 7019ad3..0f22399 100644
--- a/docs/reference/gcr/gcr-sections.txt
+++ b/docs/reference/gcr/gcr-sections.txt
@@ -269,6 +269,8 @@ gcr_union_collection_new
 gcr_union_collection_add
 gcr_union_collection_take
 gcr_union_collection_remove
+gcr_union_collection_have
+gcr_union_collection_size
 <SUBSECTION Standard>
 GCR_IS_UNION_COLLECTION
 GCR_IS_UNION_COLLECTION_CLASS
diff --git a/gcr/gcr-union-collection.c b/gcr/gcr-union-collection.c
index 558590f..55e1785 100644
--- a/gcr/gcr-union-collection.c
+++ b/gcr/gcr-union-collection.c
@@ -305,3 +305,37 @@ gcr_union_collection_remove (GcrUnionCollection *self,
 
 	g_object_unref (collection);
 }
+
+/**
+ * gcr_union_collection_have:
+ * @self: the union collection
+ * @collection: the collection to check
+ *
+ * Check whether the collection is present in the union.
+ *
+ * Returns: whether present or not
+ */
+gboolean
+gcr_union_collection_have (GcrUnionCollection *self,
+                           GcrCollection *collection)
+{
+	g_return_val_if_fail (GCR_IS_UNION_COLLECTION (self), FALSE);
+	g_return_val_if_fail (GCR_IS_COLLECTION (collection), FALSE);
+	return g_hash_table_lookup (self->pv->collections, collection) != NULL;
+}
+
+/**
+ * gcr_union_collection_size:
+ * @self: the union collection
+ *
+ * Return the number of collections in this union. This does not reflect
+ * the number of objects in the combined collection.
+ *
+ * Returns: number of collections inlcuded
+ */
+guint
+gcr_union_collection_size (GcrUnionCollection *self)
+{
+	g_return_val_if_fail (GCR_IS_UNION_COLLECTION (self), FALSE);
+	return g_hash_table_size (self->pv->collections);
+}
diff --git a/gcr/gcr-union-collection.h b/gcr/gcr-union-collection.h
index ac9a59d..46d8a04 100644
--- a/gcr/gcr-union-collection.h
+++ b/gcr/gcr-union-collection.h
@@ -66,6 +66,11 @@ void                gcr_union_collection_take                    (GcrUnionCollec
 void                gcr_union_collection_remove                  (GcrUnionCollection *self,
                                                                   GcrCollection *collection);
 
+gboolean            gcr_union_collection_have                    (GcrUnionCollection *self,
+                                                                  GcrCollection *collection);
+
+guint               gcr_union_collection_size                    (GcrUnionCollection *self);
+
 G_END_DECLS
 
 #endif /* __GCR_UNION_COLLECTION_H__ */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]