Commit 181c089a authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann
Browse files

check the number of return values. Only retrieve width and height if the

2004-11-18  Sven Neumann  <sven@gimp.org>

	* app/file/file-open.c (file_open_thumbnail): check the number of
	return values. Only retrieve width and height if the thumbnail
	load procedure does actually provide such this information.

	* plug-ins/common/postscript.c: added a procedure to loads
	thumbnails.  For now it only renders the first page of the
	document at low resolution. It should be extended to load an
	embedded thumbnail if available.

	* plug-ins/common/jpeg.c
	* plug-ins/common/svg.c: no need to register a menu label for the
	thumbnail loaders. Allocate the return_vals array large enough to
	hold all return values.
parent 649f7ef4
2004-11-18 Sven Neumann <sven@gimp.org>
* app/file/file-open.c (file_open_thumbnail): check the number of
return values. Only retrieve width and height if the thumbnail
load procedure does actually provide such this information.
* plug-ins/common/postscript.c: added a procedure to loads
thumbnails. For now it only renders the first page of the
document at low resolution. It should be extended to load an
embedded thumbnail if available.
* plug-ins/common/jpeg.c
* plug-ins/common/svg.c: no need to register a menu label for the
thumbnail loaders. Allocate the return_vals array large enough to
hold all return values.
2004-11-18 Michael Natterer <mitch@gimp.org>
 
* app/widgets/gimpenumaction.[ch]: added boolean property
......
......@@ -215,7 +215,7 @@ file_open_thumbnail (Gimp *gimp,
proc = procedural_db_lookup (gimp, file_proc->thumb_loader);
if (proc && proc->num_args >= 2)
if (proc && proc->num_args >= 2 && proc->num_values >= 2)
{
GimpPDBStatusType status;
Argument *args;
......@@ -242,8 +242,12 @@ file_open_thumbnail (Gimp *gimp,
status = return_vals[0].value.pdb_int;
image_id = return_vals[1].value.pdb_int;
*image_width = MAX (0, return_vals[2].value.pdb_int);
*image_height = MAX (0, return_vals[3].value.pdb_int);
if (proc->num_values >= 4)
{
*image_width = MAX (0, return_vals[2].value.pdb_int);
*image_height = MAX (0, return_vals[3].value.pdb_int);
}
procedural_db_destroy_args (return_vals, proc->num_values);
g_free (args);
......
......@@ -387,7 +387,7 @@ query (void)
"S. Mukund <muks@mukund.org>, Sven Neumann <sven@gimp.org>",
"S. Mukund <muks@mukund.org>, Sven Neumann <sven@gimp.org>",
"November 15, 2004",
N_("JPEG image"),
NULL,
NULL,
GIMP_PLUGIN,
G_N_ELEMENTS (thumb_args),
......@@ -421,7 +421,7 @@ run (const gchar *name,
gint *nreturn_vals,
GimpParam **return_vals)
{
static GimpParam values[2];
static GimpParam values[4];
GimpRunMode run_mode;
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
gint32 image_ID;
......
......@@ -522,7 +522,7 @@ query (void)
};
static GimpParamDef load_return_vals[] =
{
{ GIMP_PDB_IMAGE, "image", "Output image" },
{ GIMP_PDB_IMAGE, "image", "Output image" }
};
static GimpParamDef set_load_args[] =
......@@ -537,6 +537,16 @@ query (void)
{ GIMP_PDB_INT32, "GraphicsAlphaBits", "1, 2, or 4" }
};
static GimpParamDef thumb_args[] =
{
{ GIMP_PDB_STRING, "filename", "The name of the file to load" },
{ GIMP_PDB_INT32, "thumb_size", "Preferred thumbnail size" }
};
static GimpParamDef thumb_return_vals[] =
{
{ GIMP_PDB_IMAGE, "image", "Output image" }
};
static GimpParamDef save_args[] =
{
{ GIMP_PDB_INT32, "run_mode", "Interactive, non-interactive" },
......@@ -626,6 +636,23 @@ query (void)
G_N_ELEMENTS (set_load_args), 0,
set_load_args, NULL);
gimp_install_procedure ("file_ps_load_thumb",
"Loads a small preview from a Postscript or PDF document",
"",
"Peter Kirchgessner <peter@kirchgessner.net>",
"Peter Kirchgessner",
dversio,
NULL,
NULL,
GIMP_PLUGIN,
G_N_ELEMENTS (thumb_args),
G_N_ELEMENTS (thumb_return_vals),
thumb_args, thumb_return_vals);
gimp_register_thumbnail_loader ("file_ps_load", "file_ps_load_thumb");
gimp_register_thumbnail_loader ("file_eps_load", "file_ps_load_thumb");
gimp_register_thumbnail_loader ("file_pdf_load", "file_ps_load_thumb");
gimp_install_procedure ("file_ps_save",
"save image as PostScript docuement",
"PostScript saving handles all image types except those with alpha channels.",
......@@ -716,6 +743,7 @@ run (const gchar *name,
*nreturn_vals = 1;
*return_vals = values;
values[0].type = GIMP_PDB_STATUS;
values[0].data.d_status = GIMP_PDB_EXECUTION_ERROR;
......@@ -771,6 +799,41 @@ run (const gchar *name,
if (status == GIMP_PDB_SUCCESS)
gimp_set_data ("file_ps_load", &plvals, sizeof (PSLoadVals));
}
else if (strcmp (name, "file_ps_load_thumb") == 0)
{
if (nparams < 2)
{
status = GIMP_PDB_CALLING_ERROR;
}
else
{
gint size = MAX (32, param[1].data.d_int32);
/* We should look for an embedded preview but for now we
* just load the document at a small resolution and the
* first page only.
*/
plvals.resolution = size / 8;
plvals.width = size;
plvals.height = size;
strcpy (plvals.pages, "1");
check_load_vals ();
image_ID = load_image (param[0].data.d_string);
if (image_ID != -1)
{
*nreturn_vals = 2;
values[1].type = GIMP_PDB_IMAGE;
values[1].data.d_image = image_ID;
}
else
{
status = GIMP_PDB_EXECUTION_ERROR;
}
}
}
else if (strcmp (name, "file_ps_save") == 0 ||
strcmp (name, "file_eps_save") == 0)
{
......
......@@ -151,7 +151,7 @@ query (void)
"Dom Lachowicz, Sven Neumann",
"Dom Lachowicz <cinamod@hotmail.com>",
SVG_VERSION,
N_("Scalable SVG image"),
NULL,
NULL,
GIMP_PLUGIN,
G_N_ELEMENTS (thumb_args),
......@@ -168,7 +168,7 @@ run (const gchar *name,
gint *nreturn_vals,
GimpParam **return_vals)
{
static GimpParam values[2];
static GimpParam values[4];
GimpRunMode run_mode;
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
......
......@@ -387,7 +387,7 @@ query (void)
"S. Mukund <muks@mukund.org>, Sven Neumann <sven@gimp.org>",
"S. Mukund <muks@mukund.org>, Sven Neumann <sven@gimp.org>",
"November 15, 2004",
N_("JPEG image"),
NULL,
NULL,
GIMP_PLUGIN,
G_N_ELEMENTS (thumb_args),
......@@ -421,7 +421,7 @@ run (const gchar *name,
gint *nreturn_vals,
GimpParam **return_vals)
{
static GimpParam values[2];
static GimpParam values[4];
GimpRunMode run_mode;
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
gint32 image_ID;
......
......@@ -387,7 +387,7 @@ query (void)
"S. Mukund <muks@mukund.org>, Sven Neumann <sven@gimp.org>",
"S. Mukund <muks@mukund.org>, Sven Neumann <sven@gimp.org>",
"November 15, 2004",
N_("JPEG image"),
NULL,
NULL,
GIMP_PLUGIN,
G_N_ELEMENTS (thumb_args),
......@@ -421,7 +421,7 @@ run (const gchar *name,
gint *nreturn_vals,
GimpParam **return_vals)
{
static GimpParam values[2];
static GimpParam values[4];
GimpRunMode run_mode;
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
gint32 image_ID;
......
......@@ -387,7 +387,7 @@ query (void)
"S. Mukund <muks@mukund.org>, Sven Neumann <sven@gimp.org>",
"S. Mukund <muks@mukund.org>, Sven Neumann <sven@gimp.org>",
"November 15, 2004",
N_("JPEG image"),
NULL,
NULL,
GIMP_PLUGIN,
G_N_ELEMENTS (thumb_args),
......@@ -421,7 +421,7 @@ run (const gchar *name,
gint *nreturn_vals,
GimpParam **return_vals)
{
static GimpParam values[2];
static GimpParam values[4];
GimpRunMode run_mode;
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
gint32 image_ID;
......
......@@ -387,7 +387,7 @@ query (void)
"S. Mukund <muks@mukund.org>, Sven Neumann <sven@gimp.org>",
"S. Mukund <muks@mukund.org>, Sven Neumann <sven@gimp.org>",
"November 15, 2004",
N_("JPEG image"),
NULL,
NULL,
GIMP_PLUGIN,
G_N_ELEMENTS (thumb_args),
......@@ -421,7 +421,7 @@ run (const gchar *name,
gint *nreturn_vals,
GimpParam **return_vals)
{
static GimpParam values[2];
static GimpParam values[4];
GimpRunMode run_mode;
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
gint32 image_ID;
......
......@@ -387,7 +387,7 @@ query (void)
"S. Mukund <muks@mukund.org>, Sven Neumann <sven@gimp.org>",
"S. Mukund <muks@mukund.org>, Sven Neumann <sven@gimp.org>",
"November 15, 2004",
N_("JPEG image"),
NULL,
NULL,
GIMP_PLUGIN,
G_N_ELEMENTS (thumb_args),
......@@ -421,7 +421,7 @@ run (const gchar *name,
gint *nreturn_vals,
GimpParam **return_vals)
{
static GimpParam values[2];
static GimpParam values[4];
GimpRunMode run_mode;
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
gint32 image_ID;
......
......@@ -387,7 +387,7 @@ query (void)
"S. Mukund <muks@mukund.org>, Sven Neumann <sven@gimp.org>",
"S. Mukund <muks@mukund.org>, Sven Neumann <sven@gimp.org>",
"November 15, 2004",
N_("JPEG image"),
NULL,
NULL,
GIMP_PLUGIN,
G_N_ELEMENTS (thumb_args),
......@@ -421,7 +421,7 @@ run (const gchar *name,
gint *nreturn_vals,
GimpParam **return_vals)
{
static GimpParam values[2];
static GimpParam values[4];
GimpRunMode run_mode;
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
gint32 image_ID;
......
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