added new PDB function gimp_path_import_string() to allow to easily import

2005-03-03  Sven Neumann  <sven@gimp.org>

	* tools/pdbgen/pdb/paths.pdb: added new PDB function
	gimp_path_import_string() to allow to easily import dynamically
	created SVG.

	* app/pdb/internal_procs.c
	* app/pdb/paths_cmds.c
	* libgimp/gimppaths_pdb.[ch]: regenerated.

	* libgimp/gimp.def: updated.

	* plug-ins/script-fu/siod-wrapper.c (marshall_proc_db_call):
	removed unused variable.
This commit is contained in:
Sven Neumann 2005-03-03 11:02:12 +00:00 committed by Sven Neumann
parent 5dda6a8219
commit 8e0fe5f3aa
9 changed files with 211 additions and 37 deletions

View File

@ -1,3 +1,18 @@
2005-03-03 Sven Neumann <sven@gimp.org>
* tools/pdbgen/pdb/paths.pdb: added new PDB function
gimp_path_import_string() to allow to easily import dynamically
created SVG.
* app/pdb/internal_procs.c
* app/pdb/paths_cmds.c
* libgimp/gimppaths_pdb.[ch]: regenerated.
* libgimp/gimp.def: updated.
* plug-ins/script-fu/siod-wrapper.c (marshall_proc_db_call):
removed unused variable.
2005-03-03 Manish Singh <yosh@gimp.org> 2005-03-03 Manish Singh <yosh@gimp.org>
* configure.in: Add check for ppc64. * configure.in: Add check for ppc64.
@ -36,7 +51,7 @@
2005-03-03 Sven Neumann <sven@gimp.org> 2005-03-03 Sven Neumann <sven@gimp.org>
* libgimp/gimpdrawablecombobox.c * libgimp/gimpdrawablecombobox.c
* libgimp/gimpimagecombobox.c: set a width-request on the combo boxes. * libgimp/gimpimagecombobox.c: set a width request on the combo boxes.
* plug-ins/common/bumpmap.c (SCALE_WIDTH): set a minimum width on * plug-ins/common/bumpmap.c (SCALE_WIDTH): set a minimum width on
the scales. the scales.

View File

@ -74,7 +74,7 @@ void register_transform_tools_procs (Gimp *gimp);
void register_undo_procs (Gimp *gimp); void register_undo_procs (Gimp *gimp);
void register_unit_procs (Gimp *gimp); void register_unit_procs (Gimp *gimp);
/* 452 procedures registered total */ /* 453 procedures registered total */
void void
internal_procs_init (Gimp *gimp, internal_procs_init (Gimp *gimp,
@ -92,7 +92,7 @@ internal_procs_init (Gimp *gimp,
(* status_callback) (NULL, _("Brushes"), 0.055); (* status_callback) (NULL, _("Brushes"), 0.055);
register_brushes_procs (gimp); register_brushes_procs (gimp);
(* status_callback) (NULL, _("Channel"), 0.069); (* status_callback) (NULL, _("Channel"), 0.068);
register_channel_procs (gimp); register_channel_procs (gimp);
(* status_callback) (NULL, _("Color"), 0.091); (* status_callback) (NULL, _("Color"), 0.091);
@ -101,7 +101,7 @@ internal_procs_init (Gimp *gimp,
(* status_callback) (NULL, _("Context"), 0.124); (* status_callback) (NULL, _("Context"), 0.124);
register_context_procs (gimp); register_context_procs (gimp);
(* status_callback) (NULL, _("Convert"), 0.173); (* status_callback) (NULL, _("Convert"), 0.172);
register_convert_procs (gimp); register_convert_procs (gimp);
(* status_callback) (NULL, _("Display procedures"), 0.179); (* status_callback) (NULL, _("Display procedures"), 0.179);
@ -113,73 +113,73 @@ internal_procs_init (Gimp *gimp,
(* status_callback) (NULL, _("Transformation procedures"), 0.263); (* status_callback) (NULL, _("Transformation procedures"), 0.263);
register_drawable_transform_procs (gimp); register_drawable_transform_procs (gimp);
(* status_callback) (NULL, _("Edit procedures"), 0.299); (* status_callback) (NULL, _("Edit procedures"), 0.298);
register_edit_procs (gimp); register_edit_procs (gimp);
(* status_callback) (NULL, _("File Operations"), 0.319); (* status_callback) (NULL, _("File Operations"), 0.318);
register_fileops_procs (gimp); register_fileops_procs (gimp);
(* status_callback) (NULL, _("Floating selections"), 0.341); (* status_callback) (NULL, _("Floating selections"), 0.34);
register_floating_sel_procs (gimp); register_floating_sel_procs (gimp);
(* status_callback) (NULL, _("Font UI"), 0.354); (* status_callback) (NULL, _("Font UI"), 0.353);
register_font_select_procs (gimp); register_font_select_procs (gimp);
(* status_callback) (NULL, _("Fonts"), 0.361); (* status_callback) (NULL, _("Fonts"), 0.36);
register_fonts_procs (gimp); register_fonts_procs (gimp);
(* status_callback) (NULL, _("Gimprc procedures"), 0.365); (* status_callback) (NULL, _("Gimprc procedures"), 0.364);
register_gimprc_procs (gimp); register_gimprc_procs (gimp);
(* status_callback) (NULL, _("Gradient"), 0.378); (* status_callback) (NULL, _("Gradient"), 0.377);
register_gradient_procs (gimp); register_gradient_procs (gimp);
(* status_callback) (NULL, _("Gradient UI"), 0.445); (* status_callback) (NULL, _("Gradient UI"), 0.444);
register_gradient_select_procs (gimp); register_gradient_select_procs (gimp);
(* status_callback) (NULL, _("Gradients"), 0.451); (* status_callback) (NULL, _("Gradients"), 0.45);
register_gradients_procs (gimp); register_gradients_procs (gimp);
(* status_callback) (NULL, _("Guide procedures"), 0.462); (* status_callback) (NULL, _("Guide procedures"), 0.461);
register_guides_procs (gimp); register_guides_procs (gimp);
(* status_callback) (NULL, _("Help procedures"), 0.476); (* status_callback) (NULL, _("Help procedures"), 0.475);
register_help_procs (gimp); register_help_procs (gimp);
(* status_callback) (NULL, _("Image"), 0.478); (* status_callback) (NULL, _("Image"), 0.477);
register_image_procs (gimp); register_image_procs (gimp);
(* status_callback) (NULL, _("Layer"), 0.615); (* status_callback) (NULL, _("Layer"), 0.614);
register_layer_procs (gimp); register_layer_procs (gimp);
(* status_callback) (NULL, _("Message procedures"), 0.675); (* status_callback) (NULL, _("Message procedures"), 0.673);
register_message_procs (gimp); register_message_procs (gimp);
(* status_callback) (NULL, _("Miscellaneous"), 0.681); (* status_callback) (NULL, _("Miscellaneous"), 0.68);
register_misc_procs (gimp); register_misc_procs (gimp);
(* status_callback) (NULL, _("Paint Tool procedures"), 0.686); (* status_callback) (NULL, _("Paint Tool procedures"), 0.684);
register_paint_tools_procs (gimp); register_paint_tools_procs (gimp);
(* status_callback) (NULL, _("Palette"), 0.719); (* status_callback) (NULL, _("Palette"), 0.717);
register_palette_procs (gimp); register_palette_procs (gimp);
(* status_callback) (NULL, _("Palette UI"), 0.746); (* status_callback) (NULL, _("Palette UI"), 0.744);
register_palette_select_procs (gimp); register_palette_select_procs (gimp);
(* status_callback) (NULL, _("Palettes"), 0.752); (* status_callback) (NULL, _("Palettes"), 0.751);
register_palettes_procs (gimp); register_palettes_procs (gimp);
(* status_callback) (NULL, _("Parasite procedures"), 0.761); (* status_callback) (NULL, _("Parasite procedures"), 0.759);
register_parasite_procs (gimp); register_parasite_procs (gimp);
(* status_callback) (NULL, _("Paths"), 0.788); (* status_callback) (NULL, _("Paths"), 0.786);
register_paths_procs (gimp); register_paths_procs (gimp);
(* status_callback) (NULL, _("Pattern"), 0.821); (* status_callback) (NULL, _("Pattern"), 0.821);
register_pattern_procs (gimp); register_pattern_procs (gimp);
(* status_callback) (NULL, _("Pattern UI"), 0.825); (* status_callback) (NULL, _("Pattern UI"), 0.826);
register_pattern_select_procs (gimp); register_pattern_select_procs (gimp);
(* status_callback) (NULL, _("Patterns"), 0.832); (* status_callback) (NULL, _("Patterns"), 0.832);
@ -209,7 +209,7 @@ internal_procs_init (Gimp *gimp,
(* status_callback) (NULL, _("Undo"), 0.958); (* status_callback) (NULL, _("Undo"), 0.958);
register_undo_procs (gimp); register_undo_procs (gimp);
(* status_callback) (NULL, _("Units"), 0.973); (* status_callback) (NULL, _("Units"), 0.974);
register_unit_procs (gimp); register_unit_procs (gimp);
} }

View File

@ -54,6 +54,7 @@ static ProcRecord path_get_locked_proc;
static ProcRecord path_set_locked_proc; static ProcRecord path_set_locked_proc;
static ProcRecord path_to_selection_proc; static ProcRecord path_to_selection_proc;
static ProcRecord path_import_proc; static ProcRecord path_import_proc;
static ProcRecord path_import_string_proc;
void void
register_paths_procs (Gimp *gimp) register_paths_procs (Gimp *gimp)
@ -73,6 +74,7 @@ register_paths_procs (Gimp *gimp)
procedural_db_register (gimp, &path_set_locked_proc); procedural_db_register (gimp, &path_set_locked_proc);
procedural_db_register (gimp, &path_to_selection_proc); procedural_db_register (gimp, &path_to_selection_proc);
procedural_db_register (gimp, &path_import_proc); procedural_db_register (gimp, &path_import_proc);
procedural_db_register (gimp, &path_import_string_proc);
} }
static Argument * static Argument *
@ -1335,7 +1337,7 @@ static ProcRecord path_import_proc =
{ {
"gimp_path_import", "gimp_path_import",
"Import paths from an SVG file.", "Import paths from an SVG file.",
"This procedure imports paths from an SVG file. This is a temporary solution until the new vectors PDB API is in place. Don't rely on this function being available in future GIMP releases.", "This procedure imports paths from an SVG file. SVG elements other than paths and basic shapes are ignored.",
"Sven Neumann", "Sven Neumann",
"Sven Neumann", "Sven Neumann",
"2003", "2003",
@ -1347,3 +1349,82 @@ static ProcRecord path_import_proc =
NULL, NULL,
{ { path_import_invoker } } { { path_import_invoker } }
}; };
static Argument *
path_import_string_invoker (Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
Argument *args)
{
gboolean success = TRUE;
GimpImage *gimage;
gchar *string;
gint32 length;
gboolean merge;
gboolean scale;
gimage = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
if (! GIMP_IS_IMAGE (gimage))
success = FALSE;
string = (gchar *) args[1].value.pdb_pointer;
if (string == NULL)
success = FALSE;
length = args[2].value.pdb_int;
merge = args[3].value.pdb_int ? TRUE : FALSE;
scale = args[4].value.pdb_int ? TRUE : FALSE;
if (success)
success = gimp_vectors_import_buffer (gimage, string, length, merge, scale, -1, NULL);
return procedural_db_return_args (&path_import_string_proc, success);
}
static ProcArg path_import_string_inargs[] =
{
{
GIMP_PDB_IMAGE,
"image",
"The image"
},
{
GIMP_PDB_STRING,
"string",
"A string that must be a complete and valid SVG document."
},
{
GIMP_PDB_INT32,
"length",
"Number of bytes in string or -1 if the string is NULL terminated."
},
{
GIMP_PDB_INT32,
"merge",
"Merge paths into a single vectors object."
},
{
GIMP_PDB_INT32,
"scale",
"Scale the SVG to image dimensions."
}
};
static ProcRecord path_import_string_proc =
{
"gimp_path_import_string",
"Import paths from an SVG string.",
"This procedure works like gimp_path_import() but takes a string rather than a filename. This allows you to write scripts that generate SVG and feed it to GIMP.",
"Sven Neumann",
"Sven Neumann",
"2005",
NULL,
GIMP_INTERNAL,
5,
path_import_string_inargs,
0,
NULL,
{ { path_import_string_invoker } }
};

View File

@ -424,6 +424,7 @@ EXPORTS
gimp_path_get_points gimp_path_get_points
gimp_path_get_tattoo gimp_path_get_tattoo
gimp_path_import gimp_path_import
gimp_path_import_string
gimp_path_list gimp_path_list
gimp_path_set_current gimp_path_set_current
gimp_path_set_locked gimp_path_set_locked

View File

@ -565,9 +565,8 @@ gimp_path_to_selection (gint32 image_ID,
* *
* Import paths from an SVG file. * Import paths from an SVG file.
* *
* This procedure imports paths from an SVG file. This is a temporary * This procedure imports paths from an SVG file. SVG elements other
* solution until the new vectors PDB API is in place. Don't rely on * than paths and basic shapes are ignored.
* this function being available in future GIMP releases.
* *
* Returns: TRUE on success. * Returns: TRUE on success.
*/ */
@ -595,3 +594,48 @@ gimp_path_import (gint32 image_ID,
return success; return success;
} }
/**
* gimp_path_import_string:
* @image_ID: The image.
* @string: A string that must be a complete and valid SVG document.
* @length: Number of bytes in string or -1 if the string is NULL terminated.
* @merge: Merge paths into a single vectors object.
* @scale: Scale the SVG to image dimensions.
*
* Import paths from an SVG string.
*
* This procedure works like gimp_path_import() but takes a string
* rather than a filename. This allows you to write scripts that
* generate SVG and feed it to GIMP.
*
* Returns: TRUE on success.
*
* Since: GIMP 2.4
*/
gboolean
gimp_path_import_string (gint32 image_ID,
const gchar *string,
gint length,
gboolean merge,
gboolean scale)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp_path_import_string",
&nreturn_vals,
GIMP_PDB_IMAGE, image_ID,
GIMP_PDB_STRING, string,
GIMP_PDB_INT32, length,
GIMP_PDB_INT32, merge,
GIMP_PDB_INT32, scale,
GIMP_PDB_END);
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
gimp_destroy_params (return_vals, nreturn_vals);
return success;
}

View File

@ -74,6 +74,11 @@ gboolean gimp_path_import (gint32 image_ID,
const gchar *filename, const gchar *filename,
gboolean merge, gboolean merge,
gboolean scale); gboolean scale);
gboolean gimp_path_import_string (gint32 image_ID,
const gchar *string,
gint length,
gboolean merge,
gboolean scale);
G_END_DECLS G_END_DECLS

View File

@ -747,7 +747,6 @@ marshall_proc_db_call (LISP a)
{ {
gint n_elements = args[i - 1].data.d_int32; gint n_elements = args[i - 1].data.d_int32;
LISP list = car (a); LISP list = car (a);
gint j;
if ((n_elements < 0) || (n_elements > nlength (list))) if ((n_elements < 0) || (n_elements > nlength (list)))
{ {

View File

@ -747,7 +747,6 @@ marshall_proc_db_call (LISP a)
{ {
gint n_elements = args[i - 1].data.d_int32; gint n_elements = args[i - 1].data.d_int32;
LISP list = car (a); LISP list = car (a);
gint j;
if ((n_elements < 0) || (n_elements > nlength (list))) if ((n_elements < 0) || (n_elements > nlength (list)))
{ {

View File

@ -682,9 +682,8 @@ sub path_import {
$blurb = 'Import paths from an SVG file.'; $blurb = 'Import paths from an SVG file.';
$help = <<'HELP'; $help = <<'HELP';
This procedure imports paths from an SVG file. This is a temporary solution This procedure imports paths from an SVG file. SVG elements other than
until the new vectors PDB API is in place. Don't rely on this function paths and basic shapes are ignored.
being available in future GIMP releases.
HELP HELP
$author = $copyright = 'Sven Neumann'; $author = $copyright = 'Sven Neumann';
@ -706,6 +705,37 @@ HELP
); );
} }
sub path_import_string {
$blurb = 'Import paths from an SVG string.';
$help = <<'HELP';
This procedure works like gimp_path_import() but takes a string rather
than reading the SVG from a file. This allows you to write scripts that
generate SVG and feed it to GIMP.
HELP
$author = $copyright = 'Sven Neumann';
$date = '2005';
$since = '2.4';
@inargs = (
&std_image_arg,
{ name => 'string', type => 'string', no_validate => 1,
desc => 'A string that must be a complete and valid SVG document.' },
{ name => 'length', type => 'int32',
desc => 'Number of bytes in string or -1 if the string is NULL terminated.' },
{ name => 'merge', type => 'boolean',
desc => 'Merge paths into a single vectors object.' },
{ name => 'scale', type => 'boolean',
desc => 'Scale the SVG to image dimensions.' }
);
%invoke = (
headers => [ qw("vectors/gimpvectors-import.h") ],
code => 'success = gimp_vectors_import_buffer (gimage, string, length, merge, scale, -1, NULL);'
);
}
@headers = qw(<string.h> "core/gimp.h" "core/gimplist.h" @headers = qw(<string.h> "core/gimp.h" "core/gimplist.h"
"core/gimpchannel-select.h" "core/gimpchannel-select.h"
"vectors/gimpanchor.h" "vectors/gimpbezierstroke.h" "vectors/gimpanchor.h" "vectors/gimpbezierstroke.h"
@ -717,7 +747,7 @@ HELP
path_stroke_current path_get_point_at_dist path_stroke_current path_get_point_at_dist
path_get_tattoo path_set_tattoo get_path_by_tattoo path_get_tattoo path_set_tattoo get_path_by_tattoo
path_get_locked path_set_locked path_to_selection path_get_locked path_set_locked path_to_selection
path_import); path_import path_import_string);
%exports = (app => [@procs], lib => [@procs]); %exports = (app => [@procs], lib => [@procs]);
$desc = 'Paths'; $desc = 'Paths';