[gimp] Add get_parent() API for items, layers, channels and vectors
- From: Michael Natterer <mitch src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gimp] Add get_parent() API for items, layers, channels and vectors
- Date: Sun, 7 Feb 2010 12:49:21 +0000 (UTC)
commit e0224cdbfbacec49c72c4ae22c6e661790c6b68b
Author: Michael Natterer <mitch gimp org>
Date: Sun Feb 7 12:03:07 2010 +0100
Add get_parent() API for items, layers, channels and vectors
this is pretty pointless from an abstraction point of view, but using
these functions will make the code a lot more readable by getting rid
of tons of ugly casts to and from GimpViewable whenever getting an
item's parent.
app/core/gimpchannel.c | 8 ++++++++
app/core/gimpchannel.h | 2 ++
app/core/gimpitem.c | 8 ++++++++
app/core/gimpitem.h | 2 ++
app/core/gimplayer.c | 8 ++++++++
app/core/gimplayer.h | 2 ++
app/vectors/gimpvectors.c | 8 ++++++++
app/vectors/gimpvectors.h | 3 ++-
8 files changed, 40 insertions(+), 1 deletions(-)
---
diff --git a/app/core/gimpchannel.c b/app/core/gimpchannel.c
index 7d68e73..7354976 100644
--- a/app/core/gimpchannel.c
+++ b/app/core/gimpchannel.c
@@ -1684,6 +1684,14 @@ gimp_channel_new_from_component (GimpImage *image,
return channel;
}
+GimpChannel *
+gimp_channel_get_parent (GimpChannel *channel)
+{
+ g_return_val_if_fail (GIMP_IS_CHANNEL (channel), NULL);
+
+ return GIMP_CHANNEL (gimp_viewable_get_parent (GIMP_VIEWABLE (channel)));
+}
+
void
gimp_channel_set_color (GimpChannel *channel,
const GimpRGB *color,
diff --git a/app/core/gimpchannel.h b/app/core/gimpchannel.h
index 8618d66..5b1dd77 100644
--- a/app/core/gimpchannel.h
+++ b/app/core/gimpchannel.h
@@ -138,6 +138,8 @@ GimpChannel * gimp_channel_new_from_component (GimpImage *image,
const gchar *name,
const GimpRGB *color);
+GimpChannel * gimp_channel_get_parent (GimpChannel *channel);
+
gdouble gimp_channel_get_opacity (const GimpChannel *channel);
void gimp_channel_set_opacity (GimpChannel *channel,
gdouble opacity,
diff --git a/app/core/gimpitem.c b/app/core/gimpitem.c
index 3839831..34b0219 100644
--- a/app/core/gimpitem.c
+++ b/app/core/gimpitem.c
@@ -689,6 +689,14 @@ gimp_item_is_attached (const GimpItem *item)
return GIMP_ITEM_GET_CLASS (item)->is_attached (item);
}
+GimpItem *
+gimp_item_get_parent (GimpItem *item)
+{
+ g_return_val_if_fail (GIMP_IS_ITEM (item), NULL);
+
+ return GIMP_ITEM (gimp_viewable_get_parent (GIMP_VIEWABLE (item)));
+}
+
GimpItemTree *
gimp_item_get_tree (GimpItem *item)
{
diff --git a/app/core/gimpitem.h b/app/core/gimpitem.h
index 9810d1c..c59cb31 100644
--- a/app/core/gimpitem.h
+++ b/app/core/gimpitem.h
@@ -143,6 +143,8 @@ gboolean gimp_item_is_removed (const GimpItem *item);
gboolean gimp_item_is_attached (const GimpItem *item);
+GimpItem * gimp_item_get_parent (GimpItem *item);
+
GimpItemTree * gimp_item_get_tree (GimpItem *item);
GimpContainer * gimp_item_get_container (GimpItem *item);
GList * gimp_item_get_container_iter (GimpItem *item);
diff --git a/app/core/gimplayer.c b/app/core/gimplayer.c
index 62d3bfd..fe5892d 100644
--- a/app/core/gimplayer.c
+++ b/app/core/gimplayer.c
@@ -1339,6 +1339,14 @@ gimp_layer_new_from_region (PixelRegion *region,
return new_layer;
}
+GimpLayer *
+gimp_layer_get_parent (GimpLayer *layer)
+{
+ g_return_val_if_fail (GIMP_IS_LAYER (layer), NULL);
+
+ return GIMP_LAYER (gimp_viewable_get_parent (GIMP_VIEWABLE (layer)));
+}
+
GimpLayerMask *
gimp_layer_get_mask (const GimpLayer *layer)
{
diff --git a/app/core/gimplayer.h b/app/core/gimplayer.h
index c45d245..1ac2197 100644
--- a/app/core/gimplayer.h
+++ b/app/core/gimplayer.h
@@ -96,6 +96,8 @@ GimpLayer * gimp_layer_new_from_region (PixelRegion *region,
gdouble opacity,
GimpLayerModeEffects mode);
+GimpLayer * gimp_layer_get_parent (GimpLayer *layer);
+
GimpLayerMask * gimp_layer_get_mask (const GimpLayer *layer);
GimpLayerMask * gimp_layer_create_mask (const GimpLayer *layer,
GimpAddMaskType mask_type,
diff --git a/app/vectors/gimpvectors.c b/app/vectors/gimpvectors.c
index e0d3aea..e570217 100644
--- a/app/vectors/gimpvectors.c
+++ b/app/vectors/gimpvectors.c
@@ -587,6 +587,14 @@ gimp_vectors_new (GimpImage *image,
return vectors;
}
+GimpVectors *
+gimp_vectors_get_parent (GimpVectors *vectors)
+{
+ g_return_val_if_fail (GIMP_IS_VECTORS (vectors), NULL);
+
+ return GIMP_VECTORS (gimp_viewable_get_parent (GIMP_VIEWABLE (vectors)));
+}
+
void
gimp_vectors_freeze (GimpVectors *vectors)
{
diff --git a/app/vectors/gimpvectors.h b/app/vectors/gimpvectors.h
index 235e925..9a91f15 100644
--- a/app/vectors/gimpvectors.h
+++ b/app/vectors/gimpvectors.h
@@ -88,6 +88,8 @@ GType gimp_vectors_get_type (void) G_GNUC_CONST;
GimpVectors * gimp_vectors_new (GimpImage *image,
const gchar *name);
+GimpVectors * gimp_vectors_get_parent (GimpVectors *vectors);
+
void gimp_vectors_freeze (GimpVectors *vectors);
void gimp_vectors_thaw (GimpVectors *vectors);
@@ -97,7 +99,6 @@ void gimp_vectors_add_strokes (const GimpVectors *src_vectors,
GimpVectors *dest_vectors);
-
/* accessing / modifying the anchors */
GimpAnchor * gimp_vectors_anchor_get (const GimpVectors *vectors,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]