[gimp] app: change image parameter in gimp_text_layout_new() to xres, yres



commit f13abfa3f077d14d9026197af02fb7f35943e00d
Author: Michael Natterer <mitch gimp org>
Date:   Fri Mar 18 02:31:20 2011 +0100

    app: change image parameter in gimp_text_layout_new() to xres,yres
    
    Because GimpTextLayout doesn't depend on any image, it only needs a
    resolution.

 app/text/gimptext-vectors.c |    6 +++++-
 app/text/gimptextlayer.c    |    6 +++++-
 app/text/gimptextlayout.c   |    9 ++-------
 app/text/gimptextlayout.h   |    3 ++-
 app/tools/gimptexttool.c    |    7 ++++++-
 5 files changed, 20 insertions(+), 11 deletions(-)
---
diff --git a/app/text/gimptext-vectors.c b/app/text/gimptext-vectors.c
index 52b79d9..7a79055 100644
--- a/app/text/gimptext-vectors.c
+++ b/app/text/gimptext-vectors.c
@@ -67,6 +67,8 @@ gimp_text_vectors_new (GimpImage *image,
       GimpTextLayout  *layout;
       cairo_surface_t *surface;
       cairo_t         *cr;
+      gdouble          xres;
+      gdouble          yres;
 
       if (text->text)
         gimp_object_set_name_safe (GIMP_OBJECT (vectors), text->text);
@@ -82,7 +84,9 @@ gimp_text_vectors_new (GimpImage *image,
       surface = cairo_image_surface_create (CAIRO_FORMAT_A8, 2, 2);
       cr = cairo_create (surface);
 
-      layout = gimp_text_layout_new (text, image);
+      gimp_image_get_resolution (image, &xres, &yres);
+
+      layout = gimp_text_layout_new (text, xres, yres);
       gimp_text_layout_render (layout, cr, text->base_dir, TRUE);
       g_object_unref (layout);
 
diff --git a/app/text/gimptextlayer.c b/app/text/gimptextlayer.c
index e0f4636..ad38a96 100644
--- a/app/text/gimptextlayer.c
+++ b/app/text/gimptextlayer.c
@@ -562,6 +562,8 @@ gimp_text_layer_render (GimpTextLayer *layer)
   GimpItem       *item;
   GimpImage      *image;
   GimpTextLayout *layout;
+  gdouble         xres;
+  gdouble         yres;
   gint            width;
   gint            height;
 
@@ -580,7 +582,9 @@ gimp_text_layer_render (GimpTextLayer *layer)
       return FALSE;
     }
 
-  layout = gimp_text_layout_new (layer->text, image);
+  gimp_image_get_resolution (image, &xres, &yres);
+
+  layout = gimp_text_layout_new (layer->text, xres, yres);
 
   g_object_freeze_notify (G_OBJECT (drawable));
 
diff --git a/app/text/gimptextlayout.c b/app/text/gimptextlayout.c
index d35ada4..95103a4 100644
--- a/app/text/gimptextlayout.c
+++ b/app/text/gimptextlayout.c
@@ -31,8 +31,6 @@
 
 #include "text-types.h"
 
-#include "core/gimpimage.h"
-
 #include "gimptext.h"
 #include "gimptextlayout.h"
 
@@ -108,23 +106,20 @@ gimp_text_layout_finalize (GObject *object)
 
 GimpTextLayout *
 gimp_text_layout_new (GimpText  *text,
-                      GimpImage *image)
+                      gdouble    xres,
+                      gdouble    yres)
 {
   GimpTextLayout       *layout;
   PangoContext         *context;
   PangoFontDescription *font_desc;
   PangoAlignment        alignment = PANGO_ALIGN_LEFT;
-  gdouble               xres, yres;
   gint                  size;
 
   g_return_val_if_fail (GIMP_IS_TEXT (text), NULL);
-  g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
 
   font_desc = pango_font_description_from_string (text->font);
   g_return_val_if_fail (font_desc != NULL, NULL);
 
-  gimp_image_get_resolution (image, &xres, &yres);
-
   size = gimp_text_layout_point_size (text->font_size,
                                       text->unit,
                                       yres);
diff --git a/app/text/gimptextlayout.h b/app/text/gimptextlayout.h
index c562ca8..fdb8a3d 100644
--- a/app/text/gimptextlayout.h
+++ b/app/text/gimptextlayout.h
@@ -38,7 +38,8 @@ struct _GimpTextLayoutClass
 GType            gimp_text_layout_get_type             (void) G_GNUC_CONST;
 
 GimpTextLayout * gimp_text_layout_new                  (GimpText       *text,
-                                                        GimpImage      *image);
+                                                        gdouble         xres,
+                                                        gdouble         yres);
 gboolean         gimp_text_layout_get_size             (GimpTextLayout *layout,
                                                         gint           *width,
                                                         gint           *heigth);
diff --git a/app/tools/gimptexttool.c b/app/tools/gimptexttool.c
index dddc91b..1d9f134 100644
--- a/app/tools/gimptexttool.c
+++ b/app/tools/gimptexttool.c
@@ -1746,8 +1746,13 @@ gimp_text_tool_ensure_layout (GimpTextTool *text_tool)
   if (! text_tool->layout && text_tool->text)
     {
       GimpImage *image = gimp_item_get_image (GIMP_ITEM (text_tool->layer));
+      gdouble    xres;
+      gdouble    yres;
 
-      text_tool->layout = gimp_text_layout_new (text_tool->layer->text, image);
+      gimp_image_get_resolution (image, &xres, &yres);
+
+      text_tool->layout = gimp_text_layout_new (text_tool->layer->text,
+                                                xres, yres);
     }
 
   return text_tool->layout != NULL;



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