[gimp] Add an "image" property to GimpItemTree
- From: Michael Natterer <mitch src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gimp] Add an "image" property to GimpItemTree
- Date: Sat, 6 Feb 2010 15:01:24 +0000 (UTC)
commit f551333cbe6de83dfe3b0833a627f03f97076a26
Author: Michael Natterer <mitch gimp org>
Date: Sat Feb 6 13:49:09 2010 +0100
Add an "image" property to GimpItemTree
app/core/gimpimage.c | 9 ++++++---
app/core/gimpitemtree.c | 28 ++++++++++++++++++++++++----
app/core/gimpitemtree.h | 5 +++--
3 files changed, 33 insertions(+), 9 deletions(-)
---
diff --git a/app/core/gimpimage.c b/app/core/gimpimage.c
index 4b7f19f..c561f99 100644
--- a/app/core/gimpimage.c
+++ b/app/core/gimpimage.c
@@ -619,11 +619,14 @@ gimp_image_init (GimpImage *image)
private->grid = NULL;
private->sample_points = NULL;
- private->layers = gimp_item_tree_new (GIMP_TYPE_DRAWABLE_STACK,
+ private->layers = gimp_item_tree_new (image,
+ GIMP_TYPE_DRAWABLE_STACK,
GIMP_TYPE_LAYER);
- private->channels = gimp_item_tree_new (GIMP_TYPE_DRAWABLE_STACK,
+ private->channels = gimp_item_tree_new (image,
+ GIMP_TYPE_DRAWABLE_STACK,
GIMP_TYPE_CHANNEL);
- private->vectors = gimp_item_tree_new (GIMP_TYPE_ITEM_STACK,
+ private->vectors = gimp_item_tree_new (image,
+ GIMP_TYPE_ITEM_STACK,
GIMP_TYPE_VECTORS);
private->layer_stack = NULL;
diff --git a/app/core/gimpitemtree.c b/app/core/gimpitemtree.c
index ca09335..1083597 100644
--- a/app/core/gimpitemtree.c
+++ b/app/core/gimpitemtree.c
@@ -26,6 +26,7 @@
#include "core-types.h"
+#include "gimpimage.h"
#include "gimpitem.h"
#include "gimpitemstack.h"
#include "gimpitemtree.h"
@@ -34,6 +35,7 @@
enum
{
PROP_0,
+ PROP_IMAGE,
PROP_CONTAINER_TYPE,
PROP_ITEM_TYPE
};
@@ -43,8 +45,9 @@ typedef struct _GimpItemTreePrivate GimpItemTreePrivate;
struct _GimpItemTreePrivate
{
- GType container_type;
- GType item_type;
+ GimpImage *image;
+ GType container_type;
+ GType item_type;
};
#define GIMP_ITEM_TREE_GET_PRIVATE(object) \
@@ -90,6 +93,13 @@ gimp_item_tree_class_init (GimpItemTreeClass *klass)
gimp_object_class->get_memsize = gimp_item_tree_get_memsize;
+ g_object_class_install_property (object_class, PROP_IMAGE,
+ g_param_spec_object ("image",
+ NULL, NULL,
+ GIMP_TYPE_IMAGE,
+ GIMP_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY));
+
g_object_class_install_property (object_class, PROP_CONTAINER_TYPE,
g_param_spec_gtype ("container-type",
NULL, NULL,
@@ -126,6 +136,7 @@ gimp_item_tree_constructor (GType type,
tree = GIMP_ITEM_TREE (object);
private = GIMP_ITEM_TREE_GET_PRIVATE (tree);
+ g_assert (GIMP_IS_IMAGE (private->image));
g_assert (g_type_is_a (private->container_type, GIMP_TYPE_ITEM_STACK));
g_assert (g_type_is_a (private->item_type, GIMP_TYPE_ITEM));
g_assert (private->item_type != GIMP_TYPE_ITEM);
@@ -164,6 +175,9 @@ gimp_item_tree_set_property (GObject *object,
switch (property_id)
{
+ case PROP_IMAGE:
+ private->image = g_value_get_object (value); /* don't ref */
+ break;
case PROP_CONTAINER_TYPE:
private->container_type = g_value_get_gtype (value);
break;
@@ -187,6 +201,9 @@ gimp_item_tree_get_property (GObject *object,
switch (property_id)
{
+ case PROP_IMAGE:
+ g_value_set_object (value, private->image);
+ break;
case PROP_CONTAINER_TYPE:
g_value_set_gtype (value, private->container_type);
break;
@@ -217,13 +234,16 @@ gimp_item_tree_get_memsize (GimpObject *object,
/* public functions */
GimpItemTree *
-gimp_item_tree_new (GType container_type,
- GType item_type)
+gimp_item_tree_new (GimpImage *image,
+ GType container_type,
+ GType item_type)
{
+ g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
g_return_val_if_fail (g_type_is_a (container_type, GIMP_TYPE_ITEM_STACK), NULL);
g_return_val_if_fail (g_type_is_a (item_type, GIMP_TYPE_ITEM), NULL);
return g_object_new (GIMP_TYPE_ITEM_TREE,
+ "image", image,
"container-type", container_type,
"item-type", item_type,
NULL);
diff --git a/app/core/gimpitemtree.h b/app/core/gimpitemtree.h
index a4cdd02..ae5f849 100644
--- a/app/core/gimpitemtree.h
+++ b/app/core/gimpitemtree.h
@@ -48,8 +48,9 @@ struct _GimpItemTreeClass
GType gimp_item_tree_get_type (void) G_GNUC_CONST;
-GimpItemTree * gimp_item_tree_new (GType container_type,
- GType item_type);
+GimpItemTree * gimp_item_tree_new (GimpImage *image,
+ GType container_type,
+ GType item_type);
#endif /* __GIMP_ITEM_TREE_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]