gimp r28235 - in trunk: . app/pdb libgimp tools/pdbgen/pdb



Author: neo
Date: Tue Mar 31 19:07:12 2009
New Revision: 28235
URL: http://svn.gnome.org/viewvc/gimp?rev=28235&view=rev

Log:
2009-03-31  Sven Neumann  <sven gimp org>

	Bug 568479 â add PDB procedures to manipulate size of text box

	* tools/pdbgen/pdb/text_layer.pdb: add gimp-text-layer-resize,
	based on a patch from Barak Itkin.

	* app/pdb/internal-procs.c
	* app/pdb/text-layer-cmds.c
	* libgimp/gimptextlayer_pdb.[ch]: regenerated.



Modified:
   trunk/ChangeLog
   trunk/app/pdb/internal-procs.c
   trunk/app/pdb/text-layer-cmds.c
   trunk/libgimp/gimptextlayer_pdb.c
   trunk/libgimp/gimptextlayer_pdb.h
   trunk/tools/pdbgen/pdb/text_layer.pdb

Modified: trunk/app/pdb/internal-procs.c
==============================================================================
--- trunk/app/pdb/internal-procs.c	(original)
+++ trunk/app/pdb/internal-procs.c	Tue Mar 31 19:07:12 2009
@@ -28,7 +28,7 @@
 #include "internal-procs.h"
 
 
-/* 596 procedures registered total */
+/* 597 procedures registered total */
 
 void
 internal_procs_init (GimpPDB *pdb)

Modified: trunk/app/pdb/text-layer-cmds.c
==============================================================================
--- trunk/app/pdb/text-layer-cmds.c	(original)
+++ trunk/app/pdb/text-layer-cmds.c	Tue Mar 31 19:07:12 2009
@@ -1044,6 +1044,43 @@
 }
 
 static GValueArray *
+text_layer_resize_invoker (GimpProcedure      *procedure,
+                           Gimp               *gimp,
+                           GimpContext        *context,
+                           GimpProgress       *progress,
+                           const GValueArray  *args,
+                           GError            **error)
+{
+  gboolean success = TRUE;
+  GimpLayer *layer;
+  gdouble width;
+  gdouble height;
+
+  layer = gimp_value_get_layer (&args->values[0], gimp);
+  width = g_value_get_double (&args->values[1]);
+  height = g_value_get_double (&args->values[2]);
+
+  if (success)
+    {
+      if (gimp_pdb_layer_is_text_layer (layer, error))
+        {
+          gimp_text_layer_set (GIMP_TEXT_LAYER (layer),
+                               _("Set text layer attribute"),
+                               "box-width",  width,
+                               "box-height", height,
+                               NULL);
+        }
+      else
+        {
+          success = FALSE;
+        }
+    }
+
+  return gimp_procedure_get_return_values (procedure, success,
+                                           error ? *error : NULL);
+}
+
+static GValueArray *
 text_layer_get_hinting_invoker (GimpProcedure      *procedure,
                                 Gimp               *gimp,
                                 GimpContext        *context,
@@ -1968,6 +2005,41 @@
   g_object_unref (procedure);
 
   /*
+   * gimp-text-layer-resize
+   */
+  procedure = gimp_procedure_new (text_layer_resize_invoker);
+  gimp_object_set_static_name (GIMP_OBJECT (procedure),
+                               "gimp-text-layer-resize");
+  gimp_procedure_set_static_strings (procedure,
+                                     "gimp-text-layer-resize",
+                                     "Resize the box of a text layer.",
+                                     "This procedure changes the width and height of a text layer while keeping it as a text layer and not converting it to a bitmap like 'gimp-layer-resize' would do.",
+                                     "Barak Itkin <lightningismyname gmail com>",
+                                     "Barak Itkin",
+                                     "2009",
+                                     NULL);
+  gimp_procedure_add_argument (procedure,
+                               gimp_param_spec_layer_id ("layer",
+                                                         "layer",
+                                                         "The text layer",
+                                                         pdb->gimp, FALSE,
+                                                         GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               g_param_spec_double ("width",
+                                                    "width",
+                                                    "The new box width in pixels",
+                                                    0.0, GIMP_MAX_IMAGE_SIZE, 0.0,
+                                                    GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               g_param_spec_double ("height",
+                                                    "height",
+                                                    "The new box height in pixels",
+                                                    0.0, GIMP_MAX_IMAGE_SIZE, 0.0,
+                                                    GIMP_PARAM_READWRITE));
+  gimp_pdb_register_procedure (pdb, procedure);
+  g_object_unref (procedure);
+
+  /*
    * gimp-text-layer-get-hinting
    */
   procedure = gimp_procedure_new (text_layer_get_hinting_invoker);

Modified: trunk/libgimp/gimptextlayer_pdb.c
==============================================================================
--- trunk/libgimp/gimptextlayer_pdb.c	(original)
+++ trunk/libgimp/gimptextlayer_pdb.c	Tue Mar 31 19:07:12 2009
@@ -969,6 +969,45 @@
 }
 
 /**
+ * gimp_text_layer_resize:
+ * @layer_ID: The text layer.
+ * @width: The new box width in pixels.
+ * @height: The new box height in pixels.
+ *
+ * Resize the box of a text layer.
+ *
+ * This procedure changes the width and height of a text layer while
+ * keeping it as a text layer and not converting it to a bitmap like
+ * gimp_layer_resize() would do.
+ *
+ * Returns: TRUE on success.
+ *
+ * Since: GIMP 2.8
+ */
+gboolean
+gimp_text_layer_resize (gint32  layer_ID,
+                        gdouble width,
+                        gdouble height)
+{
+  GimpParam *return_vals;
+  gint nreturn_vals;
+  gboolean success = TRUE;
+
+  return_vals = gimp_run_procedure ("gimp-text-layer-resize",
+                                    &nreturn_vals,
+                                    GIMP_PDB_LAYER, layer_ID,
+                                    GIMP_PDB_FLOAT, width,
+                                    GIMP_PDB_FLOAT, height,
+                                    GIMP_PDB_END);
+
+  success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
+
+  gimp_destroy_params (return_vals, nreturn_vals);
+
+  return success;
+}
+
+/**
  * gimp_text_layer_get_hinting:
  * @layer_ID: The text layer.
  * @autohint: A flag which is true if the text layer is forced to use the autohinter from FreeType.

Modified: trunk/libgimp/gimptextlayer_pdb.h
==============================================================================
--- trunk/libgimp/gimptextlayer_pdb.h	(original)
+++ trunk/libgimp/gimptextlayer_pdb.h	Tue Mar 31 19:07:12 2009
@@ -75,6 +75,9 @@
 gdouble               gimp_text_layer_get_letter_spacing (gint32                 layer_ID);
 gboolean              gimp_text_layer_set_letter_spacing (gint32                 layer_ID,
                                                           gdouble                letter_spacing);
+gboolean              gimp_text_layer_resize             (gint32                 layer_ID,
+                                                          gdouble                width,
+                                                          gdouble                height);
 #ifndef GIMP_DISABLE_DEPRECATED
 gboolean              gimp_text_layer_get_hinting        (gint32                 layer_ID,
                                                           gboolean              *autohint);

Modified: trunk/tools/pdbgen/pdb/text_layer.pdb
==============================================================================
--- trunk/tools/pdbgen/pdb/text_layer.pdb	(original)
+++ trunk/tools/pdbgen/pdb/text_layer.pdb	Tue Mar 31 19:07:12 2009
@@ -1109,6 +1109,49 @@
     );
 }
 
+sub text_layer_resize {
+    $blurb = 'Resize the box of a text layer.';
+
+    $help = <<'HELP';
+This procedure changes the width and height of a text layer while
+keeping it as a text layer and not converting it to a bitmap like
+gimp_layer_resize() would do.
+HELP
+
+    	$author = 'Barak Itkin <lightningismyname gmail com>';
+	$copyright = 'Barak Itkin';
+	$date = '2009';
+	$since = '2.8';
+
+    @inargs = (
+        { name => 'layer', type => 'layer',
+          desc => 'The text layer' },
+        { name => 'width', type => '0.0 <= float <= GIMP_MAX_IMAGE_SIZE',
+          desc => 'The new box width in pixels' },
+        { name => 'height', type => '0.0 <= float <= GIMP_MAX_IMAGE_SIZE',
+          desc => 'The new box height in pixels' },
+    );
+
+    %invoke = (
+        code => <<'CODE'
+{
+  if (gimp_pdb_layer_is_text_layer (layer, error))
+    {
+      gimp_text_layer_set (GIMP_TEXT_LAYER (layer),
+                           _("Set text layer attribute"),
+                           "box-width",  width,
+                           "box-height", height,
+                           NULL);
+    }
+  else
+    {
+      success = FALSE;
+    }
+}
+CODE
+    );
+}
+
 
 @headers = qw("libgimpbase/gimpbase.h"
               "core/gimpcontext.h"
@@ -1145,6 +1188,7 @@
             text_layer_set_line_spacing
             text_layer_get_letter_spacing
             text_layer_set_letter_spacing
+	    text_layer_resize
             text_layer_get_hinting
             text_layer_set_hinting
 );



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