[gimp] app: add gimp_tagged_has_tag(), and some cleanup in GimpTagged
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: add gimp_tagged_has_tag(), and some cleanup in GimpTagged
- Date: Thu, 24 Mar 2011 08:38:31 +0000 (UTC)
commit 39d206705861bff990ddd8fe60990efab1d9fde9
Author: Michael Natterer <mitch gimp org>
Date: Thu Mar 24 09:10:59 2011 +0100
app: add gimp_tagged_has_tag(), and some cleanup in GimpTagged
app/core/gimptagged.c | 43 ++++++++++++++++++++++++++++++++++++++-----
app/core/gimptagged.h | 3 +++
2 files changed, 41 insertions(+), 5 deletions(-)
---
diff --git a/app/core/gimptagged.c b/app/core/gimptagged.c
index 375f748..9c44940 100644
--- a/app/core/gimptagged.c
+++ b/app/core/gimptagged.c
@@ -110,6 +110,7 @@ gimp_tagged_add_tag (GimpTagged *tagged,
GimpTag *tag)
{
g_return_if_fail (GIMP_IS_TAGGED (tagged));
+ g_return_if_fail (GIMP_IS_TAG (tag));
if (GIMP_TAGGED_GET_INTERFACE (tagged)->add_tag (tagged, tag))
{
@@ -130,22 +131,27 @@ void
gimp_tagged_remove_tag (GimpTagged *tagged,
GimpTag *tag)
{
- GList *tag_iter;
+ GList *tag_iter;
g_return_if_fail (GIMP_IS_TAGGED (tagged));
+ g_return_if_fail (GIMP_IS_TAG (tag));
- for (tag_iter = gimp_tagged_get_tags (tagged); tag_iter;
+ for (tag_iter = gimp_tagged_get_tags (tagged);
+ tag_iter;
tag_iter = g_list_next (tag_iter))
{
- GimpTag *tag_ref = GIMP_TAG (tag_iter->data);
+ GimpTag *tag_ref = tag_iter->data;
if (gimp_tag_equals (tag_ref, tag))
{
g_object_ref (tag_ref);
+
if (GIMP_TAGGED_GET_INTERFACE (tagged)->remove_tag (tagged, tag_ref))
{
- g_signal_emit (tagged, gimp_tagged_signals[TAG_REMOVED], 0, tag_ref);
+ g_signal_emit (tagged, gimp_tagged_signals[TAG_REMOVED], 0,
+ tag_ref);
}
+
g_object_unref (tag_ref);
}
}
@@ -154,7 +160,7 @@ gimp_tagged_remove_tag (GimpTagged *tagged,
/**
* gimp_tagged_set_tags:
* @tagged: an object that implements the %GimpTagged interface
- * @tags: a list of tags
+ * @tags: a list of tags
*
* Sets the list of tags assigned to this object. The passed list of
* tags is copied and should be freed by the caller.
@@ -245,3 +251,30 @@ gimp_tagged_get_checksum (GimpTagged *tagged)
return GIMP_TAGGED_GET_INTERFACE (tagged)->get_checksum (tagged);
}
+
+/**
+ * gimp_tagged_has_tag:
+ * @tagged: an object that implements the %GimpTagged interface
+ * @tag: a %GimpTag
+ *
+ * Return value: #TRUE if the object has @tag, #FALSE otherwise.
+ **/
+gboolean
+gimp_tagged_has_tag (GimpTagged *tagged,
+ GimpTag *tag)
+{
+ GList *tag_iter;
+
+ g_return_val_if_fail (GIMP_IS_TAGGED (tagged), FALSE);
+ g_return_val_if_fail (GIMP_IS_TAG (tag), FALSE);
+
+ for (tag_iter = gimp_tagged_get_tags (tagged);
+ tag_iter;
+ tag_iter = g_list_next (tag_iter))
+ {
+ if (gimp_tag_equals (tag_iter->data, tag))
+ return TRUE;
+ }
+
+ return FALSE;
+}
diff --git a/app/core/gimptagged.h b/app/core/gimptagged.h
index b133cc3..a6d1117 100644
--- a/app/core/gimptagged.h
+++ b/app/core/gimptagged.h
@@ -65,5 +65,8 @@ GList * gimp_tagged_get_tags (GimpTagged *tagged);
gchar * gimp_tagged_get_identifier (GimpTagged *tagged);
gchar * gimp_tagged_get_checksum (GimpTagged *tagged);
+gboolean gimp_tagged_has_tag (GimpTagged *tagged,
+ GimpTag *tag);
+
#endif /* __GIMP_TAGGED_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]