[gimp/soc-2010-cage] app: rename gimp_template_create_image() to gimp_image_new_from_template()



commit b8160a3487d17fedfb264a323ae7a85a9f4a4df1
Author: Michael Natterer <mitch gimp org>
Date:   Sat Jun 5 22:42:00 2010 +0200

    app: rename gimp_template_create_image() to gimp_image_new_from_template()
    
    and move it from gimptemplate.c to gimpimage-new.c

 app/actions/templates-commands.c |    2 +-
 app/core/gimpimage-new.c         |   72 +++++++++++++++++++++++++++++++++++
 app/core/gimpimage-new.h         |    3 +
 app/core/gimptemplate.c          |   77 --------------------------------------
 app/core/gimptemplate.h          |   12 ++----
 app/dialogs/image-new-dialog.c   |    2 +-
 6 files changed, 81 insertions(+), 87 deletions(-)
---
diff --git a/app/actions/templates-commands.c b/app/actions/templates-commands.c
index 57d413a..cfd3274 100644
--- a/app/actions/templates-commands.c
+++ b/app/actions/templates-commands.c
@@ -91,7 +91,7 @@ templates_create_image_cmd_callback (GtkAction *action,
 
   if (template && gimp_container_have (container, GIMP_OBJECT (template)))
     {
-      gimp_template_create_image (gimp, template, context);
+      gimp_image_new_from_template (gimp, template, context);
       gimp_image_new_set_last_template (gimp, template);
     }
 }
diff --git a/app/core/gimpimage-new.c b/app/core/gimpimage-new.c
index 9c46a8f..a1addfd 100644
--- a/app/core/gimpimage-new.c
+++ b/app/core/gimpimage-new.c
@@ -31,6 +31,7 @@
 #include "gimp.h"
 #include "gimpbuffer.h"
 #include "gimpchannel.h"
+#include "gimpcontext.h"
 #include "gimpimage.h"
 #include "gimpimage-colormap.h"
 #include "gimpimage-new.h"
@@ -79,6 +80,77 @@ gimp_image_new_set_last_template (Gimp         *gimp,
 }
 
 GimpImage *
+gimp_image_new_from_template (Gimp         *gimp,
+                              GimpTemplate *template,
+                              GimpContext  *context)
+{
+  GimpImage     *image;
+  GimpLayer     *layer;
+  GimpImageType  type;
+  gint           width, height;
+
+  g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
+  g_return_val_if_fail (GIMP_IS_TEMPLATE (template), NULL);
+  g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
+
+  image = gimp_create_image (gimp,
+                             template->width, template->height,
+                             template->image_type,
+                             FALSE);
+
+  gimp_image_undo_disable (image);
+
+  if (template->comment)
+    {
+      GimpParasite *parasite;
+
+      parasite = gimp_parasite_new ("gimp-comment",
+                                    GIMP_PARASITE_PERSISTENT,
+                                    strlen (template->comment) + 1,
+                                    template->comment);
+      gimp_image_parasite_attach (image, parasite);
+      gimp_parasite_free (parasite);
+    }
+
+  gimp_image_set_resolution (image,
+                             template->xresolution, template->yresolution);
+  gimp_image_set_unit (image, template->resolution_unit);
+
+  width  = gimp_image_get_width (image);
+  height = gimp_image_get_height (image);
+
+  switch (template->fill_type)
+    {
+    case GIMP_TRANSPARENT_FILL:
+      type = ((template->image_type == GIMP_RGB) ?
+              GIMP_RGBA_IMAGE : GIMP_GRAYA_IMAGE);
+      break;
+    default:
+      type = ((template->image_type == GIMP_RGB) ?
+              GIMP_RGB_IMAGE : GIMP_GRAY_IMAGE);
+      break;
+    }
+
+  layer = gimp_layer_new (image, width, height, type,
+                          _("Background"),
+                          GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE);
+
+  gimp_drawable_fill_by_type (GIMP_DRAWABLE (layer),
+                              context, template->fill_type);
+
+  gimp_image_add_layer (image, layer, NULL, 0, FALSE);
+
+  gimp_image_undo_enable (image);
+  gimp_image_clean_all (image);
+
+  gimp_create_display (gimp, image, template->unit, 1.0);
+
+  g_object_unref (image);
+
+  return image;
+}
+
+GimpImage *
 gimp_image_new_from_drawable (Gimp         *gimp,
                               GimpDrawable *drawable)
 {
diff --git a/app/core/gimpimage-new.h b/app/core/gimpimage-new.h
index 1786157..d07e780 100644
--- a/app/core/gimpimage-new.h
+++ b/app/core/gimpimage-new.h
@@ -24,6 +24,9 @@ GimpTemplate * gimp_image_new_get_last_template (Gimp            *gimp,
 void           gimp_image_new_set_last_template (Gimp            *gimp,
                                                  GimpTemplate    *template);
 
+GimpImage    * gimp_image_new_from_template     (Gimp            *gimp,
+                                                 GimpTemplate    *template,
+                                                 GimpContext     *context);
 GimpImage    * gimp_image_new_from_drawable     (Gimp            *gimp,
                                                  GimpDrawable    *drawable);
 GimpImage    * gimp_image_new_from_component    (Gimp            *gimp,
diff --git a/app/core/gimptemplate.c b/app/core/gimptemplate.c
index fe45ede..250a1a6 100644
--- a/app/core/gimptemplate.c
+++ b/app/core/gimptemplate.c
@@ -20,8 +20,6 @@
 
 #include "config.h"
 
-#include <string.h>
-
 #include <gegl.h>
 
 #include "libgimpbase/gimpbase.h"
@@ -29,11 +27,7 @@
 
 #include "core-types.h"
 
-#include "gimp.h"
-#include "gimpcontext.h"
 #include "gimpimage.h"
-#include "gimpimage-undo.h"
-#include "gimplayer.h"
 #include "gimpprojection.h"
 #include "gimptemplate.h"
 
@@ -348,74 +342,3 @@ gimp_template_set_from_image (GimpTemplate *template,
   if (comment)
     g_free (comment);
 }
-
-GimpImage *
-gimp_template_create_image (Gimp         *gimp,
-                            GimpTemplate *template,
-                            GimpContext  *context)
-{
-  GimpImage     *image;
-  GimpLayer     *layer;
-  GimpImageType  type;
-  gint           width, height;
-
-  g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
-  g_return_val_if_fail (GIMP_IS_TEMPLATE (template), NULL);
-  g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
-
-  image = gimp_create_image (gimp,
-                             template->width, template->height,
-                             template->image_type,
-                             FALSE);
-
-  gimp_image_undo_disable (image);
-
-  if (template->comment)
-    {
-      GimpParasite *parasite;
-
-      parasite = gimp_parasite_new ("gimp-comment",
-                                    GIMP_PARASITE_PERSISTENT,
-                                    strlen (template->comment) + 1,
-                                    template->comment);
-      gimp_image_parasite_attach (image, parasite);
-      gimp_parasite_free (parasite);
-    }
-
-  gimp_image_set_resolution (image,
-                             template->xresolution, template->yresolution);
-  gimp_image_set_unit (image, template->resolution_unit);
-
-  width  = gimp_image_get_width (image);
-  height = gimp_image_get_height (image);
-
-  switch (template->fill_type)
-    {
-    case GIMP_TRANSPARENT_FILL:
-      type = ((template->image_type == GIMP_RGB) ?
-              GIMP_RGBA_IMAGE : GIMP_GRAYA_IMAGE);
-      break;
-    default:
-      type = ((template->image_type == GIMP_RGB) ?
-              GIMP_RGB_IMAGE : GIMP_GRAY_IMAGE);
-      break;
-    }
-
-  layer = gimp_layer_new (image, width, height, type,
-                          _("Background"),
-                          GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE);
-
-  gimp_drawable_fill_by_type (GIMP_DRAWABLE (layer),
-                              context, template->fill_type);
-
-  gimp_image_add_layer (image, layer, NULL, 0, FALSE);
-
-  gimp_image_undo_enable (image);
-  gimp_image_clean_all (image);
-
-  gimp_create_display (gimp, image, template->unit, 1.0);
-
-  g_object_unref (image);
-
-  return image;
-}
diff --git a/app/core/gimptemplate.h b/app/core/gimptemplate.h
index ffc1598..1a68c38 100644
--- a/app/core/gimptemplate.h
+++ b/app/core/gimptemplate.h
@@ -78,16 +78,12 @@ struct _GimpTemplateClass
 };
 
 
-GType          gimp_template_get_type        (void) G_GNUC_CONST;
+GType          gimp_template_get_type       (void) G_GNUC_CONST;
 
-GimpTemplate * gimp_template_new             (const gchar    *name);
+GimpTemplate * gimp_template_new            (const gchar  *name);
 
-void           gimp_template_set_from_image  (GimpTemplate   *template,
-                                              GimpImage      *image);
-
-GimpImage    * gimp_template_create_image    (Gimp           *gimp,
-                                              GimpTemplate   *template,
-                                              GimpContext    *context);
+void           gimp_template_set_from_image (GimpTemplate *template,
+                                             GimpImage    *image);
 
 
 #endif /* __GIMP_TEMPLATE__ */
diff --git a/app/dialogs/image-new-dialog.c b/app/dialogs/image-new-dialog.c
index 28ad571..0fc0375 100644
--- a/app/dialogs/image-new-dialog.c
+++ b/app/dialogs/image-new-dialog.c
@@ -344,7 +344,7 @@ image_new_create_image (ImageNewDialog *dialog)
 
   gtk_widget_destroy (dialog->dialog);
 
-  gimp_template_create_image (gimp, template, gimp_get_user_context (gimp));
+  gimp_image_new_from_template (gimp, template, gimp_get_user_context (gimp));
   gimp_image_new_set_last_template (gimp, template);
 
   g_object_unref (template);



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