gimp r27206 - in trunk: . app/core app/display app/xcf



Author: mitch
Date: Fri Oct 10 11:45:00 2008
New Revision: 27206
URL: http://svn.gnome.org/viewvc/gimp?rev=27206&view=rev

Log:
2008-10-10  Michael Natterer  <mitch gimp org>

	* app/core/gimpimage.[ch]: add new functions
	gimp_image_get_layer_by_index(), _channel_by_index() and
	_vectors_by_index().

	* app/core/gimpprojection-construct.c
	* app/display/gimpdisplayshell-layer-select.c
	* app/xcf/xcf-load.c: use them instead of looking the items up
	in image->container and casting the return value.



Modified:
   trunk/ChangeLog
   trunk/app/core/gimpimage.c
   trunk/app/core/gimpimage.h
   trunk/app/core/gimpprojection-construct.c
   trunk/app/display/gimpdisplayshell-layer-select.c
   trunk/app/xcf/xcf-load.c

Modified: trunk/app/core/gimpimage.c
==============================================================================
--- trunk/app/core/gimpimage.c	(original)
+++ trunk/app/core/gimpimage.c	Fri Oct 10 11:45:00 2008
@@ -1599,7 +1599,7 @@
 
   g_return_val_if_fail (GIMP_IS_IMAGE (image), TRUE);
 
-  layer = (GimpLayer *) gimp_container_get_child_by_index (image->layers, 0);
+  layer = gimp_image_get_layer_by_index (image, 0);
 
   return ((gimp_container_num_children (image->layers) > 1) ||
           (layer && gimp_drawable_has_alpha (GIMP_DRAWABLE (layer))));
@@ -2780,6 +2780,36 @@
                                          GIMP_OBJECT (vectors));
 }
 
+GimpLayer *
+gimp_image_get_layer_by_index (const GimpImage *image,
+                               gint             index)
+{
+  g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
+
+  return (GimpLayer *) gimp_container_get_child_by_index (image->layers,
+                                                          index);
+}
+
+GimpChannel *
+gimp_image_get_channel_by_index (const GimpImage *image,
+                                 gint             index)
+{
+  g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
+
+  return (GimpChannel *) gimp_container_get_child_by_index (image->channels,
+                                                            index);
+}
+
+GimpVectors *
+gimp_image_get_vectors_by_index (const GimpImage *image,
+                                 gint             index)
+{
+  g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
+
+  return (GimpVectors *) gimp_container_get_child_by_index (image->vectors,
+                                                            index);
+}
+
 static GimpItem *
 gimp_image_get_item_by_tattoo (GimpContainer *items,
                                GimpTattoo     tattoo)
@@ -3005,8 +3035,7 @@
             {
               index = CLAMP (index, 0, n_children - 1);
 
-              active_layer = (GimpLayer *)
-                gimp_container_get_child_by_index (image->layers, index);
+              active_layer = gimp_image_get_layer_by_index (image, index);
             }
           else
             {
@@ -3318,8 +3347,7 @@
             {
               index = CLAMP (index, 0, n_children - 1);
 
-              active_channel = (GimpChannel *)
-                gimp_container_get_child_by_index (image->channels, index);
+              active_channel = gimp_image_get_channel_by_index (image, index);
             }
           else
             {
@@ -3546,8 +3574,7 @@
             {
               index = CLAMP (index, 0, n_children - 1);
 
-              active_vectors = (GimpVectors *)
-                gimp_container_get_child_by_index (image->vectors, index);
+              active_vectors = gimp_image_get_vectors_by_index (image, index);
             }
           else
             {

Modified: trunk/app/core/gimpimage.h
==============================================================================
--- trunk/app/core/gimpimage.h	(original)
+++ trunk/app/core/gimpimage.h	Fri Oct 10 11:45:00 2008
@@ -443,6 +443,13 @@
 gint            gimp_image_get_vectors_index     (const GimpImage    *image,
                                                   const GimpVectors  *vectors);
 
+GimpLayer     * gimp_image_get_layer_by_index    (const GimpImage    *image,
+                                                  gint                index);
+GimpChannel   * gimp_image_get_channel_by_index  (const GimpImage    *image,
+                                                  gint                index);
+GimpVectors   * gimp_image_get_vectors_by_index  (const GimpImage    *image,
+                                                  gint                index);
+
 GimpLayer     * gimp_image_get_layer_by_tattoo   (const GimpImage    *image,
                                                   GimpTattoo          tattoo);
 GimpChannel   * gimp_image_get_channel_by_tattoo (const GimpImage    *image,

Modified: trunk/app/core/gimpprojection-construct.c
==============================================================================
--- trunk/app/core/gimpprojection-construct.c	(original)
+++ trunk/app/core/gimpprojection-construct.c	Fri Oct 10 11:45:00 2008
@@ -101,8 +101,7 @@
     {
       GimpDrawable *layer;
 
-      layer = GIMP_DRAWABLE (gimp_container_get_child_by_index (image->layers,
-                                                                0));
+      layer = GIMP_DRAWABLE (gimp_image_get_layer_by_index (image, 0));
 
       if (gimp_drawable_has_alpha (layer)                         &&
           (gimp_item_get_visible (GIMP_ITEM (layer)))             &&

Modified: trunk/app/display/gimpdisplayshell-layer-select.c
==============================================================================
--- trunk/app/display/gimpdisplayshell-layer-select.c	(original)
+++ trunk/app/display/gimpdisplayshell-layer-select.c	Fri Oct 10 11:45:00 2008
@@ -212,8 +212,7 @@
   else if (index >= gimp_container_num_children (layer_select->image->layers))
     index = 0;
 
-  next_layer = (GimpLayer *)
-    gimp_container_get_child_by_index (layer_select->image->layers, index);
+  next_layer = gimp_image_get_layer_by_index (layer_select->image, index);
 
   if (next_layer && next_layer != current_layer)
     {

Modified: trunk/app/xcf/xcf-load.c
==============================================================================
--- trunk/app/xcf/xcf-load.c	(original)
+++ trunk/app/xcf/xcf-load.c	Fri Oct 10 11:45:00 2008
@@ -1529,8 +1529,7 @@
   while (num_paths-- > 0)
     xcf_load_old_path (info, image);
 
-  active_vectors = (GimpVectors *)
-    gimp_container_get_child_by_index (image->vectors, last_selected_row);
+  active_vectors = gimp_image_get_vectors_by_index (image, last_selected_row);
 
   if (active_vectors)
     gimp_image_set_active_vectors (image, active_vectors);
@@ -1670,8 +1669,7 @@
     if (! xcf_load_vector (info, image))
       return FALSE;
 
-  active_vectors = (GimpVectors *)
-    gimp_container_get_child_by_index (image->vectors, active_index);
+  active_vectors = gimp_image_get_vectors_by_index (image, active_index);
 
   if (active_vectors)
     gimp_image_set_active_vectors (image, active_vectors);



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