Commit 94e626e1 authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann

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

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.


svn path=/trunk/; revision=28235
parent 9ba967f0
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.
2009-03-31 Sven Neumann <sven@gimp.org>
* plug-ins/file-uri/uri-backend-gvfs.c (copy_uri): simplified the
......
......@@ -28,7 +28,7 @@
#include "internal-procs.h"
/* 596 procedures registered total */
/* 597 procedures registered total */
void
internal_procs_init (GimpPDB *pdb)
......
......@@ -1043,6 +1043,43 @@ text_layer_set_letter_spacing_invoker (GimpProcedure *procedure,
error ? *error : NULL);
}
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,
......@@ -1967,6 +2004,41 @@ register_text_layer_procs (GimpPDB *pdb)
gimp_pdb_register_procedure (pdb, procedure);
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
*/
......
......@@ -968,6 +968,45 @@ gimp_text_layer_set_letter_spacing (gint32 layer_ID,
return success;
}
/**
* 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.
......
......@@ -75,6 +75,9 @@ gboolean gimp_text_layer_set_line_spacing (gint32
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);
......
......@@ -1109,6 +1109,49 @@ CODE
);
}
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 @@ CODE
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
);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment