[gimp] app: use gimp_tagged_has_tag() instead of imlementing the same



commit d64eae8c4ed5a663c98d19ed7c61e7e6b9f12680
Author: Michael Natterer <mitch gimp org>
Date:   Thu Mar 24 09:13:02 2011 +0100

    app: use gimp_tagged_has_tag() instead of imlementing the same
    
    and some general cleanup.

 app/core/gimptaggedcontainer.c |   32 +++++++++++---------------------
 app/core/gimptaggedcontainer.h |    2 +-
 2 files changed, 12 insertions(+), 22 deletions(-)
---
diff --git a/app/core/gimptaggedcontainer.c b/app/core/gimptaggedcontainer.c
index 368e48e..d1ab9bd 100644
--- a/app/core/gimptaggedcontainer.c
+++ b/app/core/gimptaggedcontainer.c
@@ -219,9 +219,9 @@ gimp_tagged_container_src_thaw (GimpFilteredContainer *filtered_container)
  * @src_container: container to be filtered.
  *
  * Creates a new #GimpTaggedContainer object which creates filtered
- * data view of #GimpTagged objects. It filters @src_container for objects
- * containing all of the filtering tags. Syncronization with @src_container
- * data is performed automatically.
+ * data view of #GimpTagged objects. It filters @src_container for
+ * objects containing all of the filtering tags. Syncronization with
+ * @src_container data is performed automatically.
  *
  * Return value: a new #GimpTaggedContainer object.
  **/
@@ -253,8 +253,8 @@ gimp_tagged_container_new (GimpContainer *src_container)
  * @tagged_container: a #GimpTaggedContainer object.
  * @tags:               list of #GimpTag objects.
  *
- * Sets list of tags to be used for filtering. Only objects which have all of
- * the tags assigned match filtering criteria.
+ * Sets list of tags to be used for filtering. Only objects which have
+ * all of the tags assigned match filtering criteria.
  **/
 void
 gimp_tagged_container_set_filter (GimpTaggedContainer *tagged_container,
@@ -265,9 +265,12 @@ gimp_tagged_container_set_filter (GimpTaggedContainer *tagged_container,
   if (! gimp_container_frozen (GIMP_FILTERED_CONTAINER (tagged_container)->src_container))
     {
       gimp_tagged_container_src_freeze (GIMP_FILTERED_CONTAINER (tagged_container));
+    }
 
-      tagged_container->filter = tags;
+  tagged_container->filter = tags;
 
+  if (! gimp_container_frozen (GIMP_FILTERED_CONTAINER (tagged_container)->src_container))
+    {
       gimp_tagged_container_src_thaw (GIMP_FILTERED_CONTAINER (tagged_container));
     }
 }
@@ -300,27 +303,14 @@ gimp_tagged_container_object_matches (GimpTaggedContainer *tagged_container,
        filter_tags;
        filter_tags = g_list_next (filter_tags))
     {
-      GList *object_tags;
-
       if (! filter_tags->data)
         {
           /* invalid tag - does not match */
           return FALSE;
         }
 
-      for (object_tags = gimp_tagged_get_tags (GIMP_TAGGED (object));
-           object_tags;
-           object_tags = g_list_next (object_tags))
-        {
-          if (gimp_tag_equals (object_tags->data,
-                               filter_tags->data))
-            {
-              /* found match for the tag */
-              break;
-            }
-        }
-
-      if (! object_tags)
+      if (! gimp_tagged_has_tag (GIMP_TAGGED (object),
+                                 filter_tags->data))
         {
           /* match for the tag was not found.
            * since query is of type AND, it whole fails.
diff --git a/app/core/gimptaggedcontainer.h b/app/core/gimptaggedcontainer.h
index 2c18f92..d8cf12c 100644
--- a/app/core/gimptaggedcontainer.h
+++ b/app/core/gimptaggedcontainer.h
@@ -50,7 +50,7 @@ struct _GimpTaggedContainerClass
   GimpFilteredContainerClass  parent_class;
 
   void (* tag_count_changed) (GimpTaggedContainer *container,
-                              gint                   count);
+                              gint                 count);
 };
 
 



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