app: virtualize the add/remove/freeze/thaw logic of GimpFilteredContainer

and derive GimpTaggedContainer from it, removing a lot od code
dupliucation.
This commit is contained in:
Michael Natterer 2011-03-23 22:12:49 +01:00
parent 014a333d27
commit f2d5831ee2
4 changed files with 227 additions and 292 deletions

View File

@ -37,28 +37,35 @@ enum
}; };
static void gimp_filtered_container_constructed (GObject *object); static void gimp_filtered_container_constructed (GObject *object);
static void gimp_filtered_container_dispose (GObject *object); static void gimp_filtered_container_dispose (GObject *object);
static void gimp_filtered_container_set_property (GObject *object, static void gimp_filtered_container_set_property (GObject *object,
guint property_id, guint property_id,
const GValue *value, const GValue *value,
GParamSpec *pspec); GParamSpec *pspec);
static void gimp_filtered_container_get_property (GObject *object, static void gimp_filtered_container_get_property (GObject *object,
guint property_id, guint property_id,
GValue *value, GValue *value,
GParamSpec *pspec); GParamSpec *pspec);
static void gimp_filtered_container_filter (GimpFilteredContainer *filtered_container); static void gimp_filtered_container_real_src_add (GimpFilteredContainer *filtered_container,
static void gimp_filtered_container_src_add (GimpContainer *src_container, GimpObject *object);
GimpObject *obj, static void gimp_filtered_container_real_src_remove (GimpFilteredContainer *filtered_container,
GimpFilteredContainer *filtered_container); GimpObject *object);
static void gimp_filtered_container_src_remove (GimpContainer *src_container, static void gimp_filtered_container_real_src_freeze (GimpFilteredContainer *filtered_container);
GimpObject *obj, static void gimp_filtered_container_real_src_thaw (GimpFilteredContainer *filtered_container);
GimpFilteredContainer *filtered_container);
static void gimp_filtered_container_src_freeze (GimpContainer *src_container, static void gimp_filtered_container_filter (GimpFilteredContainer *filtered_container);
GimpFilteredContainer *filtered_container); static void gimp_filtered_container_src_add (GimpContainer *src_container,
static void gimp_filtered_container_src_thaw (GimpContainer *src_container, GimpObject *obj,
GimpFilteredContainer *filtered_container); GimpFilteredContainer *filtered_container);
static void gimp_filtered_container_src_remove (GimpContainer *src_container,
GimpObject *obj,
GimpFilteredContainer *filtered_container);
static void gimp_filtered_container_src_freeze (GimpContainer *src_container,
GimpFilteredContainer *filtered_container);
static void gimp_filtered_container_src_thaw (GimpContainer *src_container,
GimpFilteredContainer *filtered_container);
G_DEFINE_TYPE (GimpFilteredContainer, gimp_filtered_container, GIMP_TYPE_LIST) G_DEFINE_TYPE (GimpFilteredContainer, gimp_filtered_container, GIMP_TYPE_LIST)
@ -69,13 +76,19 @@ G_DEFINE_TYPE (GimpFilteredContainer, gimp_filtered_container, GIMP_TYPE_LIST)
static void static void
gimp_filtered_container_class_init (GimpFilteredContainerClass *klass) gimp_filtered_container_class_init (GimpFilteredContainerClass *klass)
{ {
GObjectClass *g_object_class = G_OBJECT_CLASS (klass); GObjectClass *g_object_class = G_OBJECT_CLASS (klass);
GimpFilteredContainerClass *filtered_class = GIMP_FILTERED_CONTAINER_CLASS (klass);
g_object_class->constructed = gimp_filtered_container_constructed; g_object_class->constructed = gimp_filtered_container_constructed;
g_object_class->dispose = gimp_filtered_container_dispose; g_object_class->dispose = gimp_filtered_container_dispose;
g_object_class->set_property = gimp_filtered_container_set_property; g_object_class->set_property = gimp_filtered_container_set_property;
g_object_class->get_property = gimp_filtered_container_get_property; g_object_class->get_property = gimp_filtered_container_get_property;
filtered_class->src_add = gimp_filtered_container_real_src_add;
filtered_class->src_remove = gimp_filtered_container_real_src_remove;
filtered_class->src_freeze = gimp_filtered_container_real_src_freeze;
filtered_class->src_thaw = gimp_filtered_container_real_src_thaw;
g_object_class_install_property (g_object_class, PROP_SRC_CONTAINER, g_object_class_install_property (g_object_class, PROP_SRC_CONTAINER,
g_param_spec_object ("src-container", g_param_spec_object ("src-container",
NULL, NULL, NULL, NULL,
@ -110,10 +123,18 @@ gimp_filtered_container_constructed (GObject *object)
G_OBJECT_CLASS (parent_class)->constructed (object); G_OBJECT_CLASS (parent_class)->constructed (object);
g_assert (GIMP_IS_CONTAINER (filtered_container->src_container)); g_assert (GIMP_IS_CONTAINER (filtered_container->src_container));
g_assert (filtered_container->filter_func != NULL);
if (! gimp_container_frozen (filtered_container->src_container)) if (! gimp_container_frozen (filtered_container->src_container))
gimp_filtered_container_filter (filtered_container); {
/* a freeze/thaw can't hurt on a newly created container because
* we can't have any views yet. This way we get away without
* having a virtual function for initializing the container.
*/
gimp_filtered_container_src_freeze (filtered_container->src_container,
filtered_container);
gimp_filtered_container_src_thaw (filtered_container->src_container,
filtered_container);
}
} }
static void static void
@ -212,6 +233,40 @@ gimp_filtered_container_get_property (GObject *object,
} }
} }
static void
gimp_filtered_container_real_src_add (GimpFilteredContainer *filtered_container,
GimpObject *object)
{
if (! filtered_container->filter_func ||
filtered_container->filter_func (object, filtered_container->filter_data))
{
gimp_container_add (GIMP_CONTAINER (filtered_container), object);
}
}
static void
gimp_filtered_container_real_src_remove (GimpFilteredContainer *filtered_container,
GimpObject *object)
{
if (! filtered_container->filter_func ||
filtered_container->filter_func (object, filtered_container->filter_data))
{
gimp_container_remove (GIMP_CONTAINER (filtered_container), object);
}
}
static void
gimp_filtered_container_real_src_freeze (GimpFilteredContainer *filtered_container)
{
gimp_container_clear (GIMP_CONTAINER (filtered_container));
}
static void
gimp_filtered_container_real_src_thaw (GimpFilteredContainer *filtered_container)
{
gimp_filtered_container_filter (filtered_container);
}
/** /**
* gimp_filtered_container_new: * gimp_filtered_container_new:
* @src_container: container to be filtered. * @src_container: container to be filtered.
@ -232,7 +287,6 @@ gimp_filtered_container_new (GimpContainer *src_container,
GCompareFunc sort_func; GCompareFunc sort_func;
g_return_val_if_fail (GIMP_IS_LIST (src_container), NULL); g_return_val_if_fail (GIMP_IS_LIST (src_container), NULL);
g_return_val_if_fail (filter_func != NULL, NULL);
children_type = gimp_container_get_children_type (src_container); children_type = gimp_container_get_children_type (src_container);
sort_func = GIMP_LIST (src_container)->sort_func; sort_func = GIMP_LIST (src_container)->sort_func;
@ -259,7 +313,8 @@ gimp_filtered_container_filter (GimpFilteredContainer *filtered_container)
{ {
GimpObject *child = list->data; GimpObject *child = list->data;
if (filtered_container->filter_func (child, if (! filtered_container->filter_func ||
filtered_container->filter_func (child,
filtered_container->filter_data)) filtered_container->filter_data))
{ {
gimp_container_add (GIMP_CONTAINER (filtered_container), child); gimp_container_add (GIMP_CONTAINER (filtered_container), child);
@ -269,25 +324,25 @@ gimp_filtered_container_filter (GimpFilteredContainer *filtered_container)
static void static void
gimp_filtered_container_src_add (GimpContainer *src_container, gimp_filtered_container_src_add (GimpContainer *src_container,
GimpObject *obj, GimpObject *object,
GimpFilteredContainer *filtered_container) GimpFilteredContainer *filtered_container)
{ {
if (! gimp_container_frozen (src_container) && if (! gimp_container_frozen (filtered_container->src_container))
filtered_container->filter_func (obj, filtered_container->filter_data))
{ {
gimp_container_add (GIMP_CONTAINER (filtered_container), obj); GIMP_FILTERED_CONTAINER_GET_CLASS (filtered_container)->src_add (filtered_container,
object);
} }
} }
static void static void
gimp_filtered_container_src_remove (GimpContainer *src_container, gimp_filtered_container_src_remove (GimpContainer *src_container,
GimpObject *obj, GimpObject *object,
GimpFilteredContainer *filtered_container) GimpFilteredContainer *filtered_container)
{ {
if (! gimp_container_frozen (src_container) && if (! gimp_container_frozen (filtered_container->src_container))
filtered_container->filter_func (obj, filtered_container->filter_data))
{ {
gimp_container_remove (GIMP_CONTAINER (filtered_container), obj); GIMP_FILTERED_CONTAINER_GET_CLASS (filtered_container)->src_remove (filtered_container,
object);
} }
} }
@ -296,13 +351,15 @@ gimp_filtered_container_src_freeze (GimpContainer *src_container,
GimpFilteredContainer *filtered_container) GimpFilteredContainer *filtered_container)
{ {
gimp_container_freeze (GIMP_CONTAINER (filtered_container)); gimp_container_freeze (GIMP_CONTAINER (filtered_container));
gimp_container_clear (GIMP_CONTAINER (filtered_container));
GIMP_FILTERED_CONTAINER_GET_CLASS (filtered_container)->src_freeze (filtered_container);
} }
static void static void
gimp_filtered_container_src_thaw (GimpContainer *src_container, gimp_filtered_container_src_thaw (GimpContainer *src_container,
GimpFilteredContainer *filtered_container) GimpFilteredContainer *filtered_container)
{ {
gimp_filtered_container_filter (filtered_container); GIMP_FILTERED_CONTAINER_GET_CLASS (filtered_container)->src_thaw (filtered_container);
gimp_container_thaw (GIMP_CONTAINER (filtered_container)); gimp_container_thaw (GIMP_CONTAINER (filtered_container));
} }

View File

@ -48,6 +48,13 @@ struct _GimpFilteredContainer
struct _GimpFilteredContainerClass struct _GimpFilteredContainerClass
{ {
GimpContainerClass parent_class; GimpContainerClass parent_class;
void (* src_add) (GimpFilteredContainer *filtered_container,
GimpObject *object);
void (* src_remove) (GimpFilteredContainer *filtered_container,
GimpObject *object);
void (* src_freeze) (GimpFilteredContainer *filtered_container);
void (* src_thaw) (GimpFilteredContainer *filtered_container);
}; };

View File

@ -37,55 +37,37 @@ enum
LAST_SIGNAL LAST_SIGNAL
}; };
enum
{ static void gimp_tagged_container_dispose (GObject *object);
PROP_0, static gint64 gimp_tagged_container_get_memsize (GimpObject *object,
PROP_SRC_CONTAINER gint64 *gui_size);
};
static void gimp_tagged_container_src_add (GimpFilteredContainer *filtered_container,
GimpObject *object);
static void gimp_tagged_container_src_remove (GimpFilteredContainer *filtered_container,
GimpObject *object);
static void gimp_tagged_container_src_freeze (GimpFilteredContainer *filtered_container);
static void gimp_tagged_container_src_thaw (GimpFilteredContainer *filtered_container);
static gboolean gimp_tagged_container_object_matches (GimpTaggedContainer *tagged_container,
GimpObject *object);
static void gimp_tagged_container_tag_added (GimpTagged *tagged,
GimpTag *tag,
GimpTaggedContainer *tagged_container);
static void gimp_tagged_container_tag_removed (GimpTagged *tagged,
GimpTag *tag,
GimpTaggedContainer *tagged_container);
static void gimp_tagged_container_ref_tag (GimpTaggedContainer *tagged_container,
GimpTag *tag);
static void gimp_tagged_container_unref_tag (GimpTaggedContainer *tagged_container,
GimpTag *tag);
static void gimp_tagged_container_tag_count_changed (GimpTaggedContainer *tagged_container,
gint tag_count);
static void gimp_tagged_container_constructed (GObject *object); G_DEFINE_TYPE (GimpTaggedContainer, gimp_tagged_container,
static void gimp_tagged_container_dispose (GObject *object); GIMP_TYPE_FILTERED_CONTAINER)
static void gimp_tagged_container_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static void gimp_tagged_container_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec);
static gint64 gimp_tagged_container_get_memsize (GimpObject *object,
gint64 *gui_size);
static gboolean gimp_tagged_container_object_matches (GimpTaggedContainer *tagged_container,
GimpObject *object);
static void gimp_tagged_container_src_add (GimpContainer *src_container,
GimpObject *object,
GimpTaggedContainer *tagged_container);
static void gimp_tagged_container_src_remove (GimpContainer *src_container,
GimpObject *object,
GimpTaggedContainer *tagged_container);
static void gimp_tagged_container_src_freeze (GimpContainer *src_container,
GimpTaggedContainer *tagged_container);
static void gimp_tagged_container_src_thaw (GimpContainer *src_container,
GimpTaggedContainer *tagged_container);
static void gimp_tagged_container_tag_added (GimpTagged *tagged,
GimpTag *tag,
GimpTaggedContainer *tagged_container);
static void gimp_tagged_container_tag_removed (GimpTagged *tagged,
GimpTag *tag,
GimpTaggedContainer *tagged_container);
static void gimp_tagged_container_ref_tag (GimpTaggedContainer *tagged_container,
GimpTag *tag);
static void gimp_tagged_container_unref_tag (GimpTaggedContainer *tagged_container,
GimpTag *tag);
static void gimp_tagged_container_tag_count_changed (GimpTaggedContainer *tagged_container,
gint tag_count);
G_DEFINE_TYPE (GimpTaggedContainer, gimp_tagged_container, GIMP_TYPE_LIST)
#define parent_class gimp_tagged_container_parent_class #define parent_class gimp_tagged_container_parent_class
@ -95,16 +77,19 @@ static guint gimp_tagged_container_signals[LAST_SIGNAL] = { 0, };
static void static void
gimp_tagged_container_class_init (GimpTaggedContainerClass *klass) gimp_tagged_container_class_init (GimpTaggedContainerClass *klass)
{ {
GObjectClass *g_object_class = G_OBJECT_CLASS (klass); GObjectClass *g_object_class = G_OBJECT_CLASS (klass);
GimpObjectClass *gimp_object_class = GIMP_OBJECT_CLASS (klass); GimpObjectClass *gimp_object_class = GIMP_OBJECT_CLASS (klass);
GimpFilteredContainerClass *filtered_class = GIMP_FILTERED_CONTAINER_CLASS (klass);
g_object_class->constructed = gimp_tagged_container_constructed;
g_object_class->dispose = gimp_tagged_container_dispose; g_object_class->dispose = gimp_tagged_container_dispose;
g_object_class->set_property = gimp_tagged_container_set_property;
g_object_class->get_property = gimp_tagged_container_get_property;
gimp_object_class->get_memsize = gimp_tagged_container_get_memsize; gimp_object_class->get_memsize = gimp_tagged_container_get_memsize;
filtered_class->src_add = gimp_tagged_container_src_add;
filtered_class->src_remove = gimp_tagged_container_src_remove;
filtered_class->src_freeze = gimp_tagged_container_src_freeze;
filtered_class->src_thaw = gimp_tagged_container_src_thaw;
klass->tag_count_changed = gimp_tagged_container_tag_count_changed; klass->tag_count_changed = gimp_tagged_container_tag_count_changed;
gimp_tagged_container_signals[TAG_COUNT_CHANGED] = gimp_tagged_container_signals[TAG_COUNT_CHANGED] =
@ -116,45 +101,14 @@ gimp_tagged_container_class_init (GimpTaggedContainerClass *klass)
gimp_marshal_VOID__INT, gimp_marshal_VOID__INT,
G_TYPE_NONE, 1, G_TYPE_NONE, 1,
G_TYPE_INT); G_TYPE_INT);
g_object_class_install_property (g_object_class, PROP_SRC_CONTAINER,
g_param_spec_object ("src-container",
NULL, NULL,
GIMP_TYPE_CONTAINER,
GIMP_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY));
} }
static void static void
gimp_tagged_container_init (GimpTaggedContainer *tagged_container) gimp_tagged_container_init (GimpTaggedContainer *tagged_container)
{ {
}
static void
gimp_tagged_container_constructed (GObject *object)
{
GimpTaggedContainer *tagged_container = GIMP_TAGGED_CONTAINER (object);
if (G_OBJECT_CLASS (parent_class)->constructed)
G_OBJECT_CLASS (parent_class)->constructed (object);
tagged_container->tag_ref_counts = tagged_container->tag_ref_counts =
g_hash_table_new ((GHashFunc) gimp_tag_get_hash, g_hash_table_new ((GHashFunc) gimp_tag_get_hash,
(GEqualFunc) gimp_tag_equals); (GEqualFunc) gimp_tag_equals);
if (! gimp_container_frozen (tagged_container->src_container))
{
GList *list;
for (list = GIMP_LIST (tagged_container->src_container)->list;
list;
list = g_list_next (list))
{
gimp_tagged_container_src_add (tagged_container->src_container,
list->data,
tagged_container);
}
}
} }
static void static void
@ -168,81 +122,9 @@ gimp_tagged_container_dispose (GObject *object)
tagged_container->tag_ref_counts = NULL; tagged_container->tag_ref_counts = NULL;
} }
if (tagged_container->src_container)
{
g_signal_handlers_disconnect_by_func (tagged_container->src_container,
gimp_tagged_container_src_add,
tagged_container);
g_signal_handlers_disconnect_by_func (tagged_container->src_container,
gimp_tagged_container_src_remove,
tagged_container);
g_signal_handlers_disconnect_by_func (tagged_container->src_container,
gimp_tagged_container_src_freeze,
tagged_container);
g_signal_handlers_disconnect_by_func (tagged_container->src_container,
gimp_tagged_container_src_thaw,
tagged_container);
g_object_unref (tagged_container->src_container);
tagged_container->src_container = NULL;
}
G_OBJECT_CLASS (parent_class)->dispose (object); G_OBJECT_CLASS (parent_class)->dispose (object);
} }
static void
gimp_tagged_container_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
GimpTaggedContainer *tagged_container = GIMP_TAGGED_CONTAINER (object);
switch (property_id)
{
case PROP_SRC_CONTAINER:
tagged_container->src_container = g_value_dup_object (value);
g_signal_connect (tagged_container->src_container, "add",
G_CALLBACK (gimp_tagged_container_src_add),
tagged_container);
g_signal_connect (tagged_container->src_container, "remove",
G_CALLBACK (gimp_tagged_container_src_remove),
tagged_container);
g_signal_connect (tagged_container->src_container, "freeze",
G_CALLBACK (gimp_tagged_container_src_freeze),
tagged_container);
g_signal_connect (tagged_container->src_container, "thaw",
G_CALLBACK (gimp_tagged_container_src_thaw),
tagged_container);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
gimp_tagged_container_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
GimpTaggedContainer *tagged_container = GIMP_TAGGED_CONTAINER (object);
switch (property_id)
{
case PROP_SRC_CONTAINER:
g_value_set_object (value, tagged_container->src_container);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static gint64 static gint64
gimp_tagged_container_get_memsize (GimpObject *object, gimp_tagged_container_get_memsize (GimpObject *object,
gint64 *gui_size) gint64 *gui_size)
@ -255,6 +137,83 @@ gimp_tagged_container_get_memsize (GimpObject *object,
gui_size); gui_size);
} }
static void
gimp_tagged_container_src_add (GimpFilteredContainer *filtered_container,
GimpObject *object)
{
GimpTaggedContainer *tagged_container = GIMP_TAGGED_CONTAINER (filtered_container);
GList *list;
for (list = gimp_tagged_get_tags (GIMP_TAGGED (object));
list;
list = g_list_next (list))
{
gimp_tagged_container_ref_tag (tagged_container, list->data);
}
g_signal_connect (object, "tag-added",
G_CALLBACK (gimp_tagged_container_tag_added),
tagged_container);
g_signal_connect (object, "tag-removed",
G_CALLBACK (gimp_tagged_container_tag_removed),
tagged_container);
if (gimp_tagged_container_object_matches (tagged_container, object))
{
gimp_container_add (GIMP_CONTAINER (tagged_container), object);
}
}
static void
gimp_tagged_container_src_remove (GimpFilteredContainer *filtered_container,
GimpObject *object)
{
GimpTaggedContainer *tagged_container = GIMP_TAGGED_CONTAINER (filtered_container);
GList *list;
g_signal_handlers_disconnect_by_func (object,
gimp_tagged_container_tag_added,
tagged_container);
g_signal_handlers_disconnect_by_func (object,
gimp_tagged_container_tag_removed,
tagged_container);
for (list = gimp_tagged_get_tags (GIMP_TAGGED (object));
list;
list = g_list_next (list))
{
gimp_tagged_container_unref_tag (tagged_container, list->data);
}
if (gimp_tagged_container_object_matches (tagged_container, object))
{
gimp_container_remove (GIMP_CONTAINER (tagged_container), object);
}
}
static void
gimp_tagged_container_src_freeze (GimpFilteredContainer *filtered_container)
{
GimpTaggedContainer *tagged_container = GIMP_TAGGED_CONTAINER (filtered_container);
gimp_container_clear (GIMP_CONTAINER (tagged_container));
g_hash_table_remove_all (tagged_container->tag_ref_counts);
tagged_container->tag_count = 0;
}
static void
gimp_tagged_container_src_thaw (GimpFilteredContainer *filtered_container)
{
GList *list;
for (list = GIMP_LIST (filtered_container->src_container)->list;
list;
list = g_list_next (list))
{
gimp_tagged_container_src_add (filtered_container, list->data);
}
}
/** /**
* gimp_tagged_container_new: * gimp_tagged_container_new:
* @src_container: container to be filtered. * @src_container: container to be filtered.
@ -303,13 +262,14 @@ gimp_tagged_container_set_filter (GimpTaggedContainer *tagged_container,
{ {
g_return_if_fail (GIMP_IS_TAGGED_CONTAINER (tagged_container)); g_return_if_fail (GIMP_IS_TAGGED_CONTAINER (tagged_container));
gimp_tagged_container_src_freeze (tagged_container->src_container, if (! gimp_container_frozen (GIMP_FILTERED_CONTAINER (tagged_container)->src_container))
tagged_container); {
gimp_tagged_container_src_freeze (GIMP_FILTERED_CONTAINER (tagged_container));
tagged_container->filter = tags; tagged_container->filter = tags;
gimp_tagged_container_src_thaw (tagged_container->src_container, gimp_tagged_container_src_thaw (GIMP_FILTERED_CONTAINER (tagged_container));
tagged_container); }
} }
/** /**
@ -372,95 +332,6 @@ gimp_tagged_container_object_matches (GimpTaggedContainer *tagged_container,
return TRUE; return TRUE;
} }
static void
gimp_tagged_container_src_add (GimpContainer *src_container,
GimpObject *object,
GimpTaggedContainer *tagged_container)
{
if (! gimp_container_frozen (src_container))
{
GList *list;
for (list = gimp_tagged_get_tags (GIMP_TAGGED (object));
list;
list = g_list_next (list))
{
gimp_tagged_container_ref_tag (tagged_container, list->data);
}
g_signal_connect (object, "tag-added",
G_CALLBACK (gimp_tagged_container_tag_added),
tagged_container);
g_signal_connect (object, "tag-removed",
G_CALLBACK (gimp_tagged_container_tag_removed),
tagged_container);
if (gimp_tagged_container_object_matches (tagged_container, object))
{
gimp_container_add (GIMP_CONTAINER (tagged_container), object);
}
}
}
static void
gimp_tagged_container_src_remove (GimpContainer *src_container,
GimpObject *object,
GimpTaggedContainer *tagged_container)
{
if (! gimp_container_frozen (src_container))
{
GList *list;
g_signal_handlers_disconnect_by_func (object,
gimp_tagged_container_tag_added,
tagged_container);
g_signal_handlers_disconnect_by_func (object,
gimp_tagged_container_tag_removed,
tagged_container);
for (list = gimp_tagged_get_tags (GIMP_TAGGED (object));
list;
list = g_list_next (list))
{
gimp_tagged_container_unref_tag (tagged_container, list->data);
}
if (gimp_tagged_container_object_matches (tagged_container, object))
{
gimp_container_remove (GIMP_CONTAINER (tagged_container), object);
}
}
}
static void
gimp_tagged_container_src_freeze (GimpContainer *src_container,
GimpTaggedContainer *tagged_container)
{
gimp_container_freeze (GIMP_CONTAINER (tagged_container));
gimp_container_clear (GIMP_CONTAINER (tagged_container));
g_hash_table_remove_all (tagged_container->tag_ref_counts);
tagged_container->tag_count = 0;
}
static void
gimp_tagged_container_src_thaw (GimpContainer *src_container,
GimpTaggedContainer *tagged_container)
{
GList *list;
for (list = GIMP_LIST (tagged_container->src_container)->list;
list;
list = g_list_next (list))
{
gimp_tagged_container_src_add (tagged_container->src_container,
list->data,
tagged_container);
}
gimp_container_thaw (GIMP_CONTAINER (tagged_container));
}
static void static void
gimp_tagged_container_tag_added (GimpTagged *tagged, gimp_tagged_container_tag_added (GimpTagged *tagged,
GimpTag *tag, GimpTag *tag,

View File

@ -22,7 +22,7 @@
#define __GIMP_TAGGED_CONTAINER_H__ #define __GIMP_TAGGED_CONTAINER_H__
#include "gimplist.h" #include "gimpfilteredcontainer.h"
#define GIMP_TYPE_TAGGED_CONTAINER (gimp_tagged_container_get_type ()) #define GIMP_TYPE_TAGGED_CONTAINER (gimp_tagged_container_get_type ())
@ -37,17 +37,17 @@ typedef struct _GimpTaggedContainerClass GimpTaggedContainerClass;
struct _GimpTaggedContainer struct _GimpTaggedContainer
{ {
GimpList parent_instance; GimpFilteredContainer parent_instance;
GimpContainer *src_container; GimpContainer *src_container;
GList *filter; GList *filter;
GHashTable *tag_ref_counts; GHashTable *tag_ref_counts;
gint tag_count; gint tag_count;
}; };
struct _GimpTaggedContainerClass struct _GimpTaggedContainerClass
{ {
GimpListClass parent_class; GimpFilteredContainerClass parent_class;
void (* tag_count_changed) (GimpTaggedContainer *container, void (* tag_count_changed) (GimpTaggedContainer *container,
gint count); gint count);