gimp r26677 - in trunk: . plug-ins/common
- From: neo svn gnome org
- To: svn-commits-list gnome org
- Subject: gimp r26677 - in trunk: . plug-ins/common
- Date: Wed, 20 Aug 2008 14:00:44 +0000 (UTC)
Author: neo
Date: Wed Aug 20 14:00:44 2008
New Revision: 26677
URL: http://svn.gnome.org/viewvc/gimp?rev=26677&view=rev
Log:
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().
Modified:
trunk/ChangeLog
trunk/plug-ins/common/file-cel.c
trunk/plug-ins/common/file-html-table.c
trunk/plug-ins/common/file-ps.c
trunk/plug-ins/common/file-sunras.c
trunk/plug-ins/common/file-tiff-load.c
Modified: trunk/plug-ins/common/file-cel.c
==============================================================================
--- trunk/plug-ins/common/file-cel.c (original)
+++ trunk/plug-ins/common/file-cel.c Wed Aug 20 14:00:44 2008
@@ -44,16 +44,18 @@
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 @@
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 @@
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 @@
}
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 @@
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 @@
/* 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 @@
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 @@
gimp_drawable_flush (drawable);
gimp_drawable_detach (drawable);
- return (image);
+ return image;
}
static gint
@@ -530,10 +543,11 @@
}
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 @@
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;
}
Modified: trunk/plug-ins/common/file-html-table.c
==============================================================================
--- trunk/plug-ins/common/file-html-table.c (original)
+++ trunk/plug-ins/common/file-html-table.c Wed Aug 20 14:00:44 2008
@@ -108,7 +108,8 @@
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 @@
static GimpParam values[2];
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
GimpDrawable *drawable;
+ GError *error = NULL;
INIT_I18N ();
@@ -187,7 +189,7 @@
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, >mvals, sizeof (GTMValues));
}
@@ -201,12 +203,20 @@
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 @@
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;
}
Modified: trunk/plug-ins/common/file-ps.c
==============================================================================
--- trunk/plug-ins/common/file-ps.c (original)
+++ trunk/plug-ins/common/file-ps.c Wed Aug 20 14:00:44 2008
@@ -1046,8 +1046,9 @@
&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 @@
/* 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;
}
Modified: trunk/plug-ins/common/file-sunras.c
==============================================================================
--- trunk/plug-ins/common/file-sunras.c (original)
+++ trunk/plug-ins/common/file-sunras.c Wed Aug 20 14:00:44 2008
@@ -538,7 +538,8 @@
/* 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;
}
Modified: trunk/plug-ins/common/file-tiff-load.c
==============================================================================
--- trunk/plug-ins/common/file-tiff-load.c (original)
+++ trunk/plug-ins/common/file-tiff-load.c Wed Aug 20 14:00:44 2008
@@ -290,6 +290,7 @@
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 @@
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;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]