plug-ins/common/file-cel.c plug-ins/common/file-html-table.c

2008-08-20  Sven Neumann  <sven@gimp.org>
 
	* plug-ins/common/file-cel.c
	* plug-ins/common/file-html-table.c
	* plug-ins/common/file-ps.c
	* plug-ins/common/file-sunras.c
	* plug-ins/common/file-tiff-load.c: pass error messages with the
	return values instead of calling g_message().


svn path=/trunk/; revision=26677
This commit is contained in:
Sven Neumann
2008-08-20 14:00:44 +00:00
committed by Sven Neumann
parent 584d078e5e
commit fd5550a4b2
6 changed files with 76 additions and 36 deletions

View File

@ -1,8 +1,17 @@
2008-08-20 Sven Neumann <sven@gimp.org>
* plug-ins/common/file-cel.c
* plug-ins/common/file-html-table.c
* plug-ins/common/file-ps.c
* plug-ins/common/file-sunras.c
* plug-ins/common/file-tiff-load.c: pass error messages with the
return values instead of calling g_message().
2008-08-20 Sven Neumann <sven@gimp.org>
* plug-ins/file-fits/fits.c
* plug-ins/file-fli/fli-gimp.c: pass error messages with the
return values instead of calling g_message()
return values instead of calling g_message().
2008-08-20 Sven Neumann <sven@gimp.org>

View File

@ -44,16 +44,18 @@ static void run (const gchar *name,
gint *nreturn_vals,
GimpParam **return_vals);
static gint load_palette (FILE *fp,
guchar palette[]);
static gint32 load_image (const gchar *file,
const gchar *brief);
static gboolean save_image (const gchar *file,
const gchar *brief,
gint32 image,
gint32 layer);
static void palette_dialog (const gchar *title);
static gboolean need_palette (const gchar *file);
static gint load_palette (FILE *fp,
guchar palette[]);
static gint32 load_image (const gchar *file,
const gchar *brief,
GError **error);
static gboolean save_image (const gchar *file,
const gchar *brief,
gint32 image,
gint32 layer,
GError **error);
static void palette_dialog (const gchar *title);
static gboolean need_palette (const gchar *file);
/* Globals... */
@ -147,6 +149,7 @@ run (const gchar *name,
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
gint32 image;
GimpExportReturn export = GIMP_EXPORT_CANCEL;
GError *error = NULL;
run_mode = param[0].data.d_int32;
@ -190,7 +193,8 @@ run (const gchar *name,
gimp_set_data (SAVE_PROC, palette_file, data_length);
}
image = load_image (param[1].data.d_string, param[2].data.d_string);
image = load_image (param[1].data.d_string, param[2].data.d_string,
&error);
if (image != -1)
{
@ -230,7 +234,7 @@ run (const gchar *name,
}
if (save_image (param[3].data.d_string, param[4].data.d_string,
image_ID, drawable_ID))
image_ID, drawable_ID, &error))
{
gimp_set_data (SAVE_PROC, palette_file, data_length);
}
@ -247,6 +251,13 @@ run (const gchar *name,
status = GIMP_PDB_CALLING_ERROR;
}
if (status != GIMP_PDB_SUCCESS && error)
{
*nreturn_vals = 2;
values[1].type = GIMP_PDB_STRING;
values[1].data.d_string = error->message;
}
values[0].data.d_status = status;
}
@ -270,8 +281,9 @@ need_palette (const gchar *file)
/* Load CEL image into GIMP */
static gint32
load_image (const gchar *file,
const gchar *brief)
load_image (const gchar *file,
const gchar *brief,
GError **error)
{
FILE *fp; /* Read file pointer */
guchar header[32]; /* File header */
@ -296,8 +308,9 @@ load_image (const gchar *file,
if (fp == NULL)
{
g_message (_("Could not open '%s' for reading: %s"),
gimp_filename_to_utf8 (file), g_strerror (errno));
g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errno),
_("Could not open '%s' for reading: %s"),
gimp_filename_to_utf8 (file), g_strerror (errno));
return -1;
}
@ -481,7 +494,7 @@ load_image (const gchar *file,
gimp_drawable_flush (drawable);
gimp_drawable_detach (drawable);
return (image);
return image;
}
static gint
@ -530,10 +543,11 @@ load_palette (FILE *fp,
}
static gboolean
save_image (const gchar *file,
const gchar *brief,
gint32 image,
gint32 layer)
save_image (const gchar *file,
const gchar *brief,
gint32 image,
gint32 layer,
GError **error)
{
FILE *fp; /* Write file pointer */
guchar header[32]; /* File header */
@ -565,8 +579,9 @@ save_image (const gchar *file,
if (fp == NULL)
{
g_message (_("Could not open '%s' for writing: %s"),
gimp_filename_to_utf8 (file), g_strerror (errno));
g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errno),
_("Could not open '%s' for writing: %s"),
gimp_filename_to_utf8 (file), g_strerror (errno));
return FALSE;
}

View File

@ -108,7 +108,8 @@ static void run (const gchar *name,
GimpParam **return_vals);
static gboolean save_image (const gchar *filename,
GimpDrawable *drawable);
GimpDrawable *drawable,
GError **error);
static gboolean save_dialog (gint32 image_ID);
static gboolean color_comp (guchar *buffer,
@ -172,6 +173,7 @@ run (const gchar *name,
static GimpParam values[2];
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
GimpDrawable *drawable;
GError *error = NULL;
INIT_I18N ();
@ -187,7 +189,7 @@ run (const gchar *name,
if (save_dialog (param[1].data.d_int32))
{
if (save_image (param[3].data.d_string, drawable))
if (save_image (param[3].data.d_string, drawable, &error))
{
gimp_set_data (SAVE_PROC, &gtmvals, sizeof (GTMValues));
}
@ -201,12 +203,20 @@ run (const gchar *name,
status = GIMP_PDB_CANCEL;
}
if (status != GIMP_PDB_SUCCESS && error)
{
*nreturn_vals = 2;
values[1].type = GIMP_PDB_STRING;
values[1].data.d_string = error->message;
}
values[0].data.d_status = status;
}
static gboolean
save_image (const gchar *filename,
GimpDrawable *drawable)
save_image (const gchar *filename,
GimpDrawable *drawable,
GError **error)
{
gint row,col, cols, rows, x, y;
gint colcount, colspan, rowspan;
@ -222,8 +232,9 @@ save_image (const gchar *filename,
if (! fp)
{
g_message (_("Could not open '%s' for writing: %s"),
gimp_filename_to_utf8 (filename), g_strerror (errno));
g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errno),
_("Could not open '%s' for writing: %s"),
gimp_filename_to_utf8 (filename), g_strerror (errno));
return FALSE;
}

View File

@ -1046,8 +1046,9 @@ load_image (const gchar *filename,
&ChildPid);
if (!ifp)
{
g_message (_("Could not interpret '%s'"),
gimp_filename_to_utf8 (filename));
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR,
_("Could not interpret Postscript file '%s'"),
gimp_filename_to_utf8 (filename));
return -1;
}
@ -1187,7 +1188,8 @@ save_image (const gchar *filename,
/* Make sure we're not saving an image with an alpha channel */
if (gimp_drawable_has_alpha (drawable_ID))
{
g_message (_("PostScript save cannot handle images with alpha channels"));
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
_("PostScript save cannot handle images with alpha channels"));
return FALSE;
}

View File

@ -538,7 +538,8 @@ save_image (const gchar *filename,
/* Make sure we're not saving an image with an alpha channel */
if (gimp_drawable_has_alpha (drawable_ID))
{
g_message (_("SUNRAS save cannot handle images with alpha channels"));
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
_("SUNRAS save cannot handle images with alpha channels"));
return FALSE;
}

View File

@ -290,6 +290,7 @@ run (const gchar *name,
g_set_error (&error, G_FILE_ERROR, g_file_error_from_errno (errno),
_("Could not open '%s' for reading: %s"),
gimp_filename_to_utf8 (filename), g_strerror (errno));
status = GIMP_PDB_EXECUTION_ERROR;
}
else
@ -305,8 +306,9 @@ run (const gchar *name,
if (pages.n_pages == 0)
{
g_message (_("TIFF '%s' does not contain any directories"),
gimp_filename_to_utf8 (filename));
g_set_error (&error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
_("TIFF '%s' does not contain any directories"),
gimp_filename_to_utf8 (filename));
status = GIMP_PDB_EXECUTION_ERROR;
}