plug-ins/common/file-gbr.c plug-ins/common/file-gih.c

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

	* plug-ins/common/file-gbr.c
	* plug-ins/common/file-gih.c
	* plug-ins/common/file-pat.c
	* plug-ins/common/file-pix.c
	* plug-ins/common/file-sunras.c: for the most common errors, 
pass
	the error message with the return values instead of calling
	g_message().


svn path=/trunk/; revision=26650
This commit is contained in:
Sven Neumann
2008-08-18 19:35:55 +00:00
committed by Sven Neumann
parent 9dde6e448d
commit a1cbd58195
6 changed files with 208 additions and 116 deletions

View File

@ -1,3 +1,13 @@
2008-08-18 Sven Neumann <sven@gimp.org>
* plug-ins/common/file-gbr.c
* plug-ins/common/file-gih.c
* plug-ins/common/file-pat.c
* plug-ins/common/file-pix.c
* plug-ins/common/file-sunras.c: for the most common errors, pass
the error message with the return values instead of calling
g_message().
2008-08-18 Michael Natterer <mitch@gimp.org> 2008-08-18 Michael Natterer <mitch@gimp.org>
* plug-ins/common/compressor.c: renamed... * plug-ins/common/compressor.c: renamed...

View File

@ -88,10 +88,12 @@ static void run (const gchar *name,
gint *nreturn_vals, gint *nreturn_vals,
GimpParam **return_vals); GimpParam **return_vals);
static gint32 load_image (const gchar *filename); static gint32 load_image (const gchar *filename,
GError **error);
static gboolean save_image (const gchar *filename, static gboolean save_image (const gchar *filename,
gint32 image_ID, gint32 image_ID,
gint32 drawable_ID); gint32 drawable_ID,
GError **error);
static gboolean save_dialog (void); static gboolean save_dialog (void);
static void entry_callback (GtkWidget *widget, static void entry_callback (GtkWidget *widget,
@ -189,12 +191,13 @@ run (const gchar *name,
gint *nreturn_vals, gint *nreturn_vals,
GimpParam **return_vals) GimpParam **return_vals)
{ {
static GimpParam values[2]; static GimpParam values[2];
GimpRunMode run_mode; GimpRunMode run_mode;
GimpPDBStatusType status = GIMP_PDB_SUCCESS; GimpPDBStatusType status = GIMP_PDB_SUCCESS;
gint32 image_ID; gint32 image_ID;
gint32 drawable_ID; gint32 drawable_ID;
GimpExportReturn export = GIMP_EXPORT_CANCEL; GimpExportReturn export = GIMP_EXPORT_CANCEL;
GError *error = NULL;
run_mode = param[0].data.d_int32; run_mode = param[0].data.d_int32;
@ -208,7 +211,7 @@ run (const gchar *name,
if (strcmp (name, LOAD_PROC) == 0) if (strcmp (name, LOAD_PROC) == 0)
{ {
image_ID = load_image (param[1].data.d_string); image_ID = load_image (param[1].data.d_string, &error);
if (image_ID != -1) if (image_ID != -1)
{ {
@ -292,7 +295,8 @@ run (const gchar *name,
if (status == GIMP_PDB_SUCCESS) if (status == GIMP_PDB_SUCCESS)
{ {
if (save_image (param[3].data.d_string, image_ID, drawable_ID)) if (save_image (param[3].data.d_string, image_ID, drawable_ID,
&error))
{ {
gimp_set_data (SAVE_PROC, &info, sizeof (info)); gimp_set_data (SAVE_PROC, &info, sizeof (info));
} }
@ -322,11 +326,19 @@ run (const gchar *name,
status = GIMP_PDB_CALLING_ERROR; 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; values[0].data.d_status = status;
} }
static gint32 static gint32
load_image (const gchar *filename) load_image (const gchar *filename,
GError **error)
{ {
gchar *name; gchar *name;
gint fd; gint fd;
@ -345,8 +357,9 @@ load_image (const gchar *filename)
if (fd == -1) if (fd == -1)
{ {
g_message (_("Could not open '%s' for reading: %s"), g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errno),
gimp_filename_to_utf8 (filename), g_strerror (errno)); _("Could not open '%s' for reading: %s"),
gimp_filename_to_utf8 (filename), g_strerror (errno));
return -1; return -1;
} }
@ -408,8 +421,9 @@ load_image (const gchar *filename)
if ((read (fd, temp, bn_size)) < bn_size) if ((read (fd, temp, bn_size)) < bn_size)
{ {
g_message (_("Error in GIMP brush file '%s'"), g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
gimp_filename_to_utf8 (filename)); _("Error in GIMP brush file '%s'"),
gimp_filename_to_utf8 (filename));
close (fd); close (fd);
g_free (temp); g_free (temp);
return -1; return -1;
@ -578,9 +592,10 @@ load_image (const gchar *filename)
} }
static gboolean static gboolean
save_image (const gchar *filename, save_image (const gchar *filename,
gint32 image_ID, gint32 image_ID,
gint32 drawable_ID) gint32 drawable_ID,
GError **error)
{ {
gint fd; gint fd;
BrushHeader bh; BrushHeader bh;
@ -613,8 +628,9 @@ save_image (const gchar *filename,
if (fd == -1) if (fd == -1)
{ {
g_message (_("Could not open '%s' for writing: %s"), g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errno),
gimp_filename_to_utf8 (filename), g_strerror (errno)); _("Could not open '%s' for writing: %s"),
gimp_filename_to_utf8 (filename), g_strerror (errno));
return FALSE; return FALSE;
} }

View File

@ -99,13 +99,13 @@ static struct
static gint num_useable_layers; static gint num_useable_layers;
static gchar *selection_modes[] = {"incremental", static const gchar *selection_modes[] = { "incremental",
"angular", "angular",
"random", "random",
"velocity", "velocity",
"pressure", "pressure",
"xtilt", "xtilt",
"ytilt"}; "ytilt" };
static GimpPixPipeParams gihparams; static GimpPixPipeParams gihparams;
@ -139,18 +139,20 @@ static void run (const gchar *name,
gint *nreturn_vals, gint *nreturn_vals,
GimpParam **return_vals); GimpParam **return_vals);
static gint32 gih_load_image (const gchar *filename); static gint32 gih_load_image (const gchar *filename,
static gboolean gih_load_one_brush (gint fd, GError **error);
gint32 image_ID); static gboolean gih_load_one_brush (gint fd,
gint32 image_ID);
static gboolean gih_save_dialog (gint32 image_ID); static gboolean gih_save_dialog (gint32 image_ID);
static gboolean gih_save_one_brush (gint fd, static gboolean gih_save_one_brush (gint fd,
GimpPixelRgn *pixel_rgn, GimpPixelRgn *pixel_rgn,
gchar *name); gchar *name);
static gboolean gih_save_image (const gchar *filename, static gboolean gih_save_image (const gchar *filename,
gint32 image_ID, gint32 image_ID,
gint32 orig_image_ID, gint32 orig_image_ID,
gint32 drawable_ID); gint32 drawable_ID,
GError **error);
const GimpPlugInInfo PLUG_IN_INFO = const GimpPlugInInfo PLUG_IN_INFO =
@ -258,6 +260,7 @@ run (const gchar *name,
gchar *layer_name; gchar *layer_name;
gint i; gint i;
GimpExportReturn export = GIMP_EXPORT_CANCEL; GimpExportReturn export = GIMP_EXPORT_CANCEL;
GError *error = NULL;
run_mode = param[0].data.d_int32; run_mode = param[0].data.d_int32;
@ -271,7 +274,7 @@ run (const gchar *name,
if (strcmp (name, LOAD_PROC) == 0) if (strcmp (name, LOAD_PROC) == 0)
{ {
image_ID = gih_load_image (param[1].data.d_string); image_ID = gih_load_image (param[1].data.d_string, &error);
if (image_ID != -1) if (image_ID != -1)
{ {
@ -337,7 +340,8 @@ run (const gchar *name,
if (gihparams.rows < 1) gihparams.rows = 1; if (gihparams.rows < 1) gihparams.rows = 1;
if (gihparams.cols < 1) gihparams.cols = 1; if (gihparams.cols < 1) gihparams.cols = 1;
gihparams.ncells = num_useable_layers * gihparams.rows * gihparams.cols; gihparams.ncells = (num_useable_layers *
gihparams.rows * gihparams.cols);
if (gihparams.cellwidth == 1 && gihparams.cellheight == 1) if (gihparams.cellwidth == 1 && gihparams.cellheight == 1)
{ {
@ -409,7 +413,7 @@ run (const gchar *name,
if (status == GIMP_PDB_SUCCESS) if (status == GIMP_PDB_SUCCESS)
{ {
if (gih_save_image (param[3].data.d_string, if (gih_save_image (param[3].data.d_string,
image_ID, orig_image_ID, drawable_ID)) image_ID, orig_image_ID, drawable_ID, &error))
{ {
gimp_set_data (SAVE_PROC, &info, sizeof (info)); gimp_set_data (SAVE_PROC, &info, sizeof (info));
} }
@ -427,6 +431,13 @@ run (const gchar *name,
status = GIMP_PDB_CALLING_ERROR; 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; values[0].data.d_status = status;
} }
@ -489,7 +500,7 @@ gih_load_one_brush (gint fd,
name = g_new (gchar, bn_size); name = g_new (gchar, bn_size);
if ((read (fd, name, bn_size)) < bn_size) if ((read (fd, name, bn_size)) < bn_size)
{ {
g_message (_("Error in GIMP brush pipe file.")); g_message (_("Error in GIMP brush pipe file."));
g_free (name); g_free (name);
return FALSE; return FALSE;
} }
@ -630,7 +641,8 @@ gih_load_one_brush (gint fd,
} }
static gint32 static gint32
gih_load_image (const gchar *filename) gih_load_image (const gchar *filename,
GError **error)
{ {
gint fd; gint fd;
gint i; gint i;
@ -646,8 +658,9 @@ gih_load_image (const gchar *filename)
if (fd == -1) if (fd == -1)
{ {
g_message (_("Could not open '%s' for reading: %s"), g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errno),
gimp_filename_to_utf8 (filename), g_strerror (errno)); _("Could not open '%s' for reading: %s"),
gimp_filename_to_utf8 (filename), g_strerror (errno));
return -1; return -1;
} }
@ -700,7 +713,9 @@ gih_load_image (const gchar *filename)
{ {
if (! gih_load_one_brush (fd, image_ID)) if (! gih_load_one_brush (fd, image_ID))
{ {
g_message (_("Couldn't load one brush in the pipe, giving up.")); g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
"%s",
_("Couldn't load one brush in the pipe, giving up."));
close (fd); close (fd);
g_free (name); g_free (name);
g_string_free (buffer, TRUE); g_string_free (buffer, TRUE);
@ -1228,21 +1243,22 @@ gih_save_one_brush (gint fd,
} }
static gboolean static gboolean
gih_save_image (const gchar *filename, gih_save_image (const gchar *filename,
gint32 image_ID, gint32 image_ID,
gint32 orig_image_ID, gint32 orig_image_ID,
gint32 drawable_ID) gint32 drawable_ID,
GError **error)
{ {
GimpDrawable *drawable; GimpDrawable *drawable;
GimpPixelRgn pixel_rgn; GimpPixelRgn pixel_rgn;
GimpParasite *pipe_parasite; GimpParasite *pipe_parasite;
gchar *header; gchar *header;
gchar *parstring; gchar *parstring;
gint32 *layer_ID; gint32 *layer_ID;
gint fd; gint fd;
gint nlayers, layer, row, col; gint nlayers, layer, row, col;
gint imagew, imageh, offsetx, offsety; gint imagew, imageh, offsetx, offsety;
gint k, x, y, thisx, thisy, xnext, ynext, thisw, thish; gint k, x, y, thisx, thisy, xnext, ynext, thisw, thish;
if (gihparams.ncells < 1) if (gihparams.ncells < 1)
return FALSE; return FALSE;
@ -1255,8 +1271,9 @@ gih_save_image (const gchar *filename,
if (fd == -1) if (fd == -1)
{ {
g_message (_("Could not open '%s' for writing: %s"), g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errno),
gimp_filename_to_utf8 (filename), g_strerror (errno)); _("Could not open '%s' for writing: %s"),
gimp_filename_to_utf8 (filename), g_strerror (errno));
return FALSE; return FALSE;
} }

View File

@ -63,10 +63,12 @@ static void run (const gchar *name,
const GimpParam *param, const GimpParam *param,
gint *nreturn_vals, gint *nreturn_vals,
GimpParam **return_vals); GimpParam **return_vals);
static gint32 load_image (const gchar *filename); static gint32 load_image (const gchar *filename,
GError **error);
static gboolean save_image (const gchar *filename, static gboolean save_image (const gchar *filename,
gint32 image_ID, gint32 image_ID,
gint32 drawable_ID); gint32 drawable_ID,
GError **error);
static gboolean save_dialog (void); static gboolean save_dialog (void);
@ -159,12 +161,13 @@ run (const gchar *name,
gint *nreturn_vals, gint *nreturn_vals,
GimpParam **return_vals) GimpParam **return_vals)
{ {
static GimpParam values[2]; static GimpParam values[2];
GimpRunMode run_mode; GimpRunMode run_mode;
GimpPDBStatusType status = GIMP_PDB_SUCCESS; GimpPDBStatusType status = GIMP_PDB_SUCCESS;
gint32 image_ID; gint32 image_ID;
gint32 drawable_ID; gint32 drawable_ID;
GimpExportReturn export = GIMP_EXPORT_CANCEL; GimpExportReturn export = GIMP_EXPORT_CANCEL;
GError *error = NULL;
run_mode = param[0].data.d_int32; run_mode = param[0].data.d_int32;
@ -178,7 +181,7 @@ run (const gchar *name,
if (strcmp (name, LOAD_PROC) == 0) if (strcmp (name, LOAD_PROC) == 0)
{ {
image_ID = load_image (param[1].data.d_string); image_ID = load_image (param[1].data.d_string, &error);
if (image_ID != -1) if (image_ID != -1)
{ {
@ -261,7 +264,8 @@ run (const gchar *name,
if (status == GIMP_PDB_SUCCESS) if (status == GIMP_PDB_SUCCESS)
{ {
if (save_image (param[3].data.d_string, image_ID, drawable_ID)) if (save_image (param[3].data.d_string, image_ID, drawable_ID,
&error))
{ {
gimp_set_data (SAVE_PROC, description, sizeof (description)); gimp_set_data (SAVE_PROC, description, sizeof (description));
} }
@ -291,11 +295,19 @@ run (const gchar *name,
status = GIMP_PDB_CALLING_ERROR; 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; values[0].data.d_status = status;
} }
static gint32 static gint32
load_image (const gchar *filename) load_image (const gchar *filename,
GError **error)
{ {
gint fd; gint fd;
PatternHeader ph; PatternHeader ph;
@ -314,8 +326,9 @@ load_image (const gchar *filename)
if (fd == -1) if (fd == -1)
{ {
g_message (_("Could not open '%s' for reading: %s"), g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errno),
gimp_filename_to_utf8 (filename), g_strerror (errno)); _("Could not open '%s' for reading: %s"),
gimp_filename_to_utf8 (filename), g_strerror (errno));
return -1; return -1;
} }
@ -429,9 +442,10 @@ load_image (const gchar *filename)
} }
static gboolean static gboolean
save_image (const gchar *filename, save_image (const gchar *filename,
gint32 image_ID, gint32 image_ID,
gint32 drawable_ID) gint32 drawable_ID,
GError **error)
{ {
gint fd; gint fd;
PatternHeader ph; PatternHeader ph;
@ -444,8 +458,9 @@ save_image (const gchar *filename,
if (fd == -1) if (fd == -1)
{ {
g_message (_("Could not open '%s' for writing: %s"), g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errno),
gimp_filename_to_utf8 (filename), g_strerror (errno)); _("Could not open '%s' for writing: %s"),
gimp_filename_to_utf8 (filename), g_strerror (errno));
return FALSE; return FALSE;
} }

View File

@ -81,10 +81,12 @@ static void run (const gchar *name,
/* Local Helper Functions */ /* Local Helper Functions */
static gint32 load_image (const gchar *filename); static gint32 load_image (const gchar *filename,
GError **error);
static gboolean save_image (const gchar *filename, static gboolean save_image (const gchar *filename,
gint32 image_ID, gint32 image_ID,
gint32 drawable_ID); gint32 drawable_ID,
GError **error);
static guint16 get_short (FILE *file); static guint16 get_short (FILE *file);
static void put_short (guint16 value, static void put_short (guint16 value,
@ -188,6 +190,7 @@ run (const gchar *name,
gint32 image_ID; gint32 image_ID;
gint32 drawable_ID; gint32 drawable_ID;
GimpExportReturn export = GIMP_EXPORT_CANCEL; GimpExportReturn export = GIMP_EXPORT_CANCEL;
GError *error = NULL;
run_mode = param[0].data.d_int32; run_mode = param[0].data.d_int32;
@ -201,7 +204,7 @@ run (const gchar *name,
if (strcmp (name, LOAD_PROC) == 0) if (strcmp (name, LOAD_PROC) == 0)
{ {
/* Perform the image load */ /* Perform the image load */
image_ID = load_image (param[1].data.d_string); image_ID = load_image (param[1].data.d_string, &error);
if (image_ID != -1) if (image_ID != -1)
{ {
@ -242,7 +245,8 @@ run (const gchar *name,
if (status == GIMP_PDB_SUCCESS) if (status == GIMP_PDB_SUCCESS)
{ {
if (! save_image (param[3].data.d_string, image_ID, drawable_ID)) if (! save_image (param[3].data.d_string, image_ID, drawable_ID,
&error))
{ {
status = GIMP_PDB_EXECUTION_ERROR; status = GIMP_PDB_EXECUTION_ERROR;
} }
@ -256,6 +260,13 @@ run (const gchar *name,
status = GIMP_PDB_CALLING_ERROR; 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; values[0].data.d_status = status;
} }
@ -306,7 +317,8 @@ put_short (guint16 value,
*/ */
static gint32 static gint32
load_image (const gchar *filename) load_image (const gchar *filename,
GError **error)
{ {
gint i, j, tile_height, row; gint i, j, tile_height, row;
FILE *file = NULL; FILE *file = NULL;
@ -324,10 +336,12 @@ load_image (const gchar *filename)
PIX_DEBUG_PRINT ("Opening file: %s\n", filename); PIX_DEBUG_PRINT ("Opening file: %s\n", filename);
file = g_fopen (filename, "rb"); file = g_fopen (filename, "rb");
if (NULL == file)
if (! file)
{ {
g_message (_("Could not open '%s' for reading: %s"), g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errno),
gimp_filename_to_utf8 (filename), g_strerror (errno)); _("Could not open '%s' for reading: %s"),
gimp_filename_to_utf8 (filename), g_strerror (errno));
return -1; return -1;
} }
@ -480,9 +494,10 @@ load_image (const gchar *filename)
*/ */
static gboolean static gboolean
save_image (const gchar *filename, save_image (const gchar *filename,
gint32 image_ID, gint32 image_ID,
gint32 drawable_ID) gint32 drawable_ID,
GError **error)
{ {
gint depth, i, j, row, tile_height, writelen, rectHeight; gint depth, i, j, row, tile_height, writelen, rectHeight;
gboolean savingColor = TRUE; gboolean savingColor = TRUE;
@ -503,10 +518,11 @@ save_image (const gchar *filename,
/* Open the output file. */ /* Open the output file. */
file = g_fopen (filename, "wb"); file = g_fopen (filename, "wb");
if (!file) if (! file)
{ {
g_message (_("Could not open '%s' for writing: %s"), g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errno),
gimp_filename_to_utf8 (filename), g_strerror (errno)); _("Could not open '%s' for writing: %s"),
gimp_filename_to_utf8 (filename), g_strerror (errno));
return FALSE; return FALSE;
} }

View File

@ -96,10 +96,12 @@ static void run (const gchar *name,
gint *nreturn_vals, gint *nreturn_vals,
GimpParam **return_vals); GimpParam **return_vals);
static gint32 load_image (const gchar *filename); static gint32 load_image (const gchar *filename,
static gint save_image (const gchar *filename, GError **error);
gint32 image_ID, static gboolean save_image (const gchar *filename,
gint32 drawable_ID); gint32 image_ID,
gint32 drawable_ID,
GError **error);
static void set_color_table (gint32, L_SUNFILEHEADER *, const guchar *); static void set_color_table (gint32, L_SUNFILEHEADER *, const guchar *);
static gint32 create_new_image (const gchar *filename, static gint32 create_new_image (const gchar *filename,
@ -251,12 +253,13 @@ run (const gchar *name,
gint *nreturn_vals, gint *nreturn_vals,
GimpParam **return_vals) GimpParam **return_vals)
{ {
static GimpParam values[2]; static GimpParam values[2];
GimpRunMode run_mode; GimpRunMode run_mode;
GimpPDBStatusType status = GIMP_PDB_SUCCESS; GimpPDBStatusType status = GIMP_PDB_SUCCESS;
gint32 image_ID; gint32 image_ID;
gint32 drawable_ID; gint32 drawable_ID;
GimpExportReturn export = GIMP_EXPORT_CANCEL; GimpExportReturn export = GIMP_EXPORT_CANCEL;
GError *error = NULL;
l_run_mode = run_mode = param[0].data.d_int32; l_run_mode = run_mode = param[0].data.d_int32;
@ -269,7 +272,7 @@ run (const gchar *name,
if (strcmp (name, LOAD_PROC) == 0) if (strcmp (name, LOAD_PROC) == 0)
{ {
image_ID = load_image (param[1].data.d_string); image_ID = load_image (param[1].data.d_string, &error);
if (image_ID != -1) if (image_ID != -1)
{ {
@ -341,7 +344,8 @@ run (const gchar *name,
if (status == GIMP_PDB_SUCCESS) if (status == GIMP_PDB_SUCCESS)
{ {
if (save_image (param[3].data.d_string, image_ID, drawable_ID)) if (save_image (param[3].data.d_string, image_ID, drawable_ID,
&error))
{ {
/* Store psvals data */ /* Store psvals data */
gimp_set_data (SAVE_PROC, &psvals, sizeof (SUNRASSaveVals)); gimp_set_data (SAVE_PROC, &psvals, sizeof (SUNRASSaveVals));
@ -360,12 +364,20 @@ run (const gchar *name,
status = GIMP_PDB_CALLING_ERROR; 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; values[0].data.d_status = status;
} }
static gint32 static gint32
load_image (const gchar *filename) load_image (const gchar *filename,
GError **error)
{ {
gint32 image_ID; gint32 image_ID;
FILE *ifp; FILE *ifp;
@ -375,8 +387,9 @@ load_image (const gchar *filename)
ifp = g_fopen (filename, "rb"); ifp = g_fopen (filename, "rb");
if (!ifp) if (!ifp)
{ {
g_message (_("Could not open '%s' for reading: %s"), g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errno),
gimp_filename_to_utf8 (filename), g_strerror (errno)); _("Could not open '%s' for reading: %s"),
gimp_filename_to_utf8 (filename), g_strerror (errno));
return -1; return -1;
} }
@ -385,15 +398,18 @@ load_image (const gchar *filename)
read_sun_header (ifp, &sunhdr); read_sun_header (ifp, &sunhdr);
if (sunhdr.l_ras_magic != RAS_MAGIC) if (sunhdr.l_ras_magic != RAS_MAGIC)
{ {
g_message (_("Could not open '%s' as SUN-raster-file"), g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
gimp_filename_to_utf8 (filename)); _("Could not open '%s' as SUN-raster-file"),
gimp_filename_to_utf8 (filename));
fclose (ifp); fclose (ifp);
return (-1); return (-1);
} }
if ((sunhdr.l_ras_type < 0) || (sunhdr.l_ras_type > 5)) if ((sunhdr.l_ras_type < 0) || (sunhdr.l_ras_type > 5))
{ {
g_message (_("The type of this SUN-rasterfile is not supported")); g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
"%s",
_("The type of this SUN-rasterfile is not supported"));
fclose (ifp); fclose (ifp);
return (-1); return (-1);
} }
@ -507,14 +523,15 @@ load_image (const gchar *filename)
} }
static gint static gboolean
save_image (const gchar *filename, save_image (const gchar *filename,
gint32 image_ID, gint32 image_ID,
gint32 drawable_ID) gint32 drawable_ID,
GError **error)
{ {
FILE* ofp; FILE* ofp;
GimpImageType drawable_type; GimpImageType drawable_type;
gint retval; gboolean retval;
drawable_type = gimp_drawable_type (drawable_ID); drawable_type = gimp_drawable_type (drawable_ID);
@ -541,8 +558,9 @@ save_image (const gchar *filename,
ofp = g_fopen (filename, "wb"); ofp = g_fopen (filename, "wb");
if (!ofp) if (!ofp)
{ {
g_message (_("Could not open '%s' for writing: %s"), g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errno),
gimp_filename_to_utf8 (filename), g_strerror (errno)); _("Could not open '%s' for writing: %s"),
gimp_filename_to_utf8 (filename), g_strerror (errno));
return FALSE; return FALSE;
} }