in case of an error, pass the error message with the return values.

2008-08-17  Sven Neumann  <sven@gimp.org>

	* plug-ins/common/file-pdf.c: in case of an error, pass the 
error
	message with the return values.


svn path=/trunk/; revision=26637
This commit is contained in:
Sven Neumann
2008-08-17 21:39:44 +00:00
committed by Sven Neumann
parent ad828a0301
commit d5da6ce87b
3 changed files with 41 additions and 27 deletions

View File

@ -1,3 +1,8 @@
2008-08-17 Sven Neumann <sven@gimp.org>
* plug-ins/common/file-pdf.c: in case of an error, pass the error
message with the return values.
2008-08-17 Sven Neumann <sven@gimp.org> 2008-08-17 Sven Neumann <sven@gimp.org>
* plug-ins/common/file-gif-load.c * plug-ins/common/file-gif-load.c

View File

@ -289,14 +289,11 @@ run (const gchar *name,
if (export == GIMP_EXPORT_EXPORT) if (export == GIMP_EXPORT_EXPORT)
gimp_image_delete (image_ID); gimp_image_delete (image_ID);
if (status == GIMP_PDB_EXECUTION_ERROR) if (status == GIMP_PDB_EXECUTION_ERROR && error)
{ {
if (error) *nreturn_vals = 2;
{ values[1].type = GIMP_PDB_STRING;
*nreturn_vals = 2; values[1].data.d_string = error->message;
values[1].type = GIMP_PDB_STRING;
values[1].data.d_string = error->message;
}
} }
} }

View File

@ -77,7 +77,8 @@ static gint32 load_image (PopplerDocument *doc,
static gboolean load_dialog (PopplerDocument *doc, static gboolean load_dialog (PopplerDocument *doc,
PdfSelectedPages *pages); PdfSelectedPages *pages);
static PopplerDocument * open_document (const gchar *filename); static PopplerDocument * open_document (const gchar *filename,
GError **error);
static GdkPixbuf * get_thumbnail (PopplerDocument *doc, static GdkPixbuf * get_thumbnail (PopplerDocument *doc,
gint page, gint page,
@ -327,6 +328,7 @@ run (const gchar *name,
GimpPDBStatusType status = GIMP_PDB_SUCCESS; GimpPDBStatusType status = GIMP_PDB_SUCCESS;
gint32 image_ID = -1; gint32 image_ID = -1;
PopplerDocument *doc = NULL; PopplerDocument *doc = NULL;
GError *error = NULL;
run_mode = param[0].data.d_int32; run_mode = param[0].data.d_int32;
@ -351,7 +353,7 @@ run (const gchar *name,
/* Possibly retrieve last settings */ /* Possibly retrieve last settings */
gimp_get_data (LOAD_PROC, &loadvals); gimp_get_data (LOAD_PROC, &loadvals);
doc = open_document (param[1].data.d_string); doc = open_document (param[1].data.d_string, &error);
if (!doc) if (!doc)
{ {
@ -371,7 +373,7 @@ run (const gchar *name,
break; break;
case GIMP_RUN_NONINTERACTIVE: case GIMP_RUN_NONINTERACTIVE:
doc = open_document (param[1].data.d_string); doc = open_document (param[1].data.d_string, &error);
if (doc) if (doc)
{ {
@ -392,8 +394,9 @@ run (const gchar *name,
} }
} }
else else
status = GIMP_PDB_EXECUTION_ERROR; {
status = GIMP_PDB_EXECUTION_ERROR;
}
break; break;
} }
@ -439,7 +442,7 @@ run (const gchar *name,
/* Possibly retrieve last settings */ /* Possibly retrieve last settings */
gimp_get_data (LOAD_PROC, &loadvals); gimp_get_data (LOAD_PROC, &loadvals);
doc = open_document (param[0].data.d_string); doc = open_document (param[0].data.d_string, &error);
if (doc) if (doc)
{ {
@ -499,37 +502,46 @@ run (const gchar *name,
status = GIMP_PDB_CALLING_ERROR; status = GIMP_PDB_CALLING_ERROR;
} }
if (status == GIMP_PDB_EXECUTION_ERROR && error)
{
*nreturn_vals = 2;
values[1].type = GIMP_PDB_STRING;
values[1].data.d_string = error->message;
}
values[0].data.d_status = status; values[0].data.d_status = status;
} }
static PopplerDocument* static PopplerDocument*
open_document (const gchar *filename) open_document (const gchar *filename,
GError **load_error)
{ {
PopplerDocument *doc; PopplerDocument *doc;
GError *err = NULL;
gchar *uri; gchar *uri;
GError *error = NULL;
uri = g_filename_to_uri (filename, NULL, &err); uri = g_filename_to_uri (filename, NULL, &error);
if (err) if (! uri)
{ {
g_warning ("Could not convert '%s' to an URI: %s", g_set_error (load_error, 0, 0,
gimp_filename_to_utf8 (filename), "Could not convert '%s' to an URI: %s",
err->message); gimp_filename_to_utf8 (filename), error->message);
g_error_free (error);
return NULL; return NULL;
} }
doc = poppler_document_new_from_file (uri, NULL, &err); doc = poppler_document_new_from_file (uri, NULL, &error);
g_free (uri); g_free (uri);
if (err) if (! doc)
{ {
g_message (_("Could not open '%s' for reading: %s"), g_set_error (load_error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
gimp_filename_to_utf8 (filename), _("Could not open '%s' for reading: %s"),
err->message); gimp_filename_to_utf8 (filename),
error->message);
g_error_free (error);
return NULL; return NULL;
} }