gimp r26640 - in trunk: . plug-ins/common
- From: neo svn gnome org
- To: svn-commits-list gnome org
- Subject: gimp r26640 - in trunk: . plug-ins/common
- Date: Mon, 18 Aug 2008 10:02:20 +0000 (UTC)
Author: neo
Date: Mon Aug 18 10:02:20 2008
New Revision: 26640
URL: http://svn.gnome.org/viewvc/gimp?rev=26640&view=rev
Log:
2008-08-18 Sven Neumann <sven gimp org>
* plug-ins/common/file-raw.c
* plug-ins/common/file-tga.c
* plug-ins/common/file-tiff-load.c
* plug-ins/common/file-tiff-save.c: pass error messages with the
return values instead of calling gimp_message().
Modified:
trunk/ChangeLog
trunk/plug-ins/common/file-raw.c
trunk/plug-ins/common/file-tga.c
trunk/plug-ins/common/file-tiff-load.c
trunk/plug-ins/common/file-tiff-save.c
Modified: trunk/plug-ins/common/file-raw.c
==============================================================================
--- trunk/plug-ins/common/file-raw.c (original)
+++ trunk/plug-ins/common/file-raw.c Mon Aug 18 10:02:20 2008
@@ -113,10 +113,13 @@
gint32 len,
gint32 pos,
gint rowstride);
-static gint32 load_image (const gchar *filename);
+
+static gint32 load_image (const gchar *filename,
+ GError **error);
static GimpPDBStatusType save_image (const gchar *filename,
gint32 image_id,
- gint32 drawable_id);
+ gint32 drawable_id,
+ GError **error);
/* gui functions */
static void preview_update (GimpPreviewArea *preview);
@@ -207,11 +210,12 @@
gint *nreturn_vals,
GimpParam **return_vals)
{
- static GimpParam values[2];
- GimpRunMode run_mode;
- GimpPDBStatusType status = GIMP_PDB_SUCCESS;
- gint32 image_id;
- gint32 drawable_id;
+ static GimpParam values[2];
+ GimpRunMode run_mode;
+ GimpPDBStatusType status = GIMP_PDB_SUCCESS;
+ GError *error = NULL;
+ gint32 image_id;
+ gint32 drawable_id;
run_mode = param[0].data.d_int32;
@@ -240,9 +244,12 @@
if (preview_fd < 0)
{
- g_message (_("Could not open '%s' for reading: %s"),
- gimp_filename_to_utf8 (param[1].data.d_string),
- 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 (param[1].data.d_string),
+ g_strerror (errno));
+
status = GIMP_PDB_EXECUTION_ERROR;
}
else
@@ -265,7 +272,7 @@
/* we are okay, and the user clicked OK in the load dialog */
if (status == GIMP_PDB_SUCCESS)
{
- image_id = load_image (param[1].data.d_string);
+ image_id = load_image (param[1].data.d_string, &error);
if (image_id != -1)
{
@@ -310,12 +317,21 @@
if (status == GIMP_PDB_SUCCESS)
{
- status = save_image (param[3].data.d_string, image_id, drawable_id);
+ status = save_image (param[3].data.d_string, image_id, drawable_id,
+ &error);
}
}
- values[0].data.d_status = status;
g_free (runtime);
+
+ 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;
}
@@ -487,7 +503,8 @@
static GimpPDBStatusType
save_image (const gchar *filename,
gint32 image_id,
- gint32 drawable_id)
+ gint32 drawable_id,
+ GError **error)
{
GimpDrawable *drawable;
GimpPixelRgn pixel_rgn;
@@ -525,8 +542,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 GIMP_PDB_EXECUTION_ERROR;
}
@@ -552,8 +570,9 @@
if (! fp)
{
- g_message (_("Could not open '%s' for writing: %s"),
- gimp_filename_to_utf8 (newfile), 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 (newfile), g_strerror (errno));
return GIMP_PDB_EXECUTION_ERROR;
}
@@ -628,7 +647,8 @@
}
static gint32
-load_image (const gchar *filename)
+load_image (const gchar *filename,
+ GError **error)
{
RawGimpData *data;
gint32 layer_id = -1;
@@ -642,8 +662,9 @@
data->fp = g_fopen (filename, "rb");
if (! data->fp)
{
- g_message (_("Could not open '%s' for reading: %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 reading: %s"),
+ gimp_filename_to_utf8 (filename), g_strerror (errno));
return -1;
}
Modified: trunk/plug-ins/common/file-tga.c
==============================================================================
--- trunk/plug-ins/common/file-tga.c (original)
+++ trunk/plug-ins/common/file-tga.c Mon Aug 18 10:02:20 2008
@@ -185,10 +185,12 @@
gint *nreturn_vals,
GimpParam **return_vals);
-static gint32 load_image (const gchar *filename);
+static gint32 load_image (const gchar *filename,
+ GError **error);
static gint save_image (const gchar *filename,
gint32 image_ID,
- gint32 drawable_ID);
+ gint32 drawable_ID,
+ GError **error);
static gboolean save_dialog (void);
@@ -276,12 +278,13 @@
gint *nreturn_vals,
GimpParam **return_vals)
{
- static GimpParam values[2];
- GimpRunMode run_mode;
- GimpPDBStatusType status = GIMP_PDB_SUCCESS;
- gint32 image_ID;
- gint32 drawable_ID;
- GimpExportReturn export = GIMP_EXPORT_CANCEL;
+ static GimpParam values[2];
+ GimpRunMode run_mode;
+ GimpPDBStatusType status = GIMP_PDB_SUCCESS;
+ gint32 image_ID;
+ gint32 drawable_ID;
+ GimpExportReturn export = GIMP_EXPORT_CANCEL;
+ GError *error = NULL;
#ifdef PROFILE
struct tms tbuf1, tbuf2;
@@ -303,7 +306,7 @@
times (&tbuf1);
#endif
- image_ID = load_image (param[1].data.d_string);
+ image_ID = load_image (param[1].data.d_string, &error);
if (image_ID != -1)
{
@@ -381,7 +384,8 @@
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 */
gimp_set_data (SAVE_PROC, &tsvals, sizeof (tsvals));
@@ -400,6 +404,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;
#ifdef PROFILE
@@ -411,7 +422,8 @@
}
static gint32
-load_image (const gchar *filename)
+load_image (const gchar *filename,
+ GError **error)
{
FILE *fp;
tga_info info;
@@ -423,10 +435,12 @@
gint32 image_ID = -1;
fp = g_fopen (filename, "rb");
- if (!fp)
+
+ if (! fp)
{
- g_message (_("Could not open '%s' for reading: %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 reading: %s"),
+ gimp_filename_to_utf8 (filename), g_strerror (errno));
return -1;
}
@@ -1120,9 +1134,10 @@
static gint
-save_image (const gchar *filename,
- gint32 image_ID,
- gint32 drawable_ID)
+save_image (const gchar *filename,
+ gint32 image_ID,
+ gint32 drawable_ID,
+ GError **error)
{
GimpPixelRgn pixel_rgn;
GimpDrawable *drawable;
@@ -1151,8 +1166,9 @@
if ((fp = g_fopen (filename, "wb")) == NULL)
{
- 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-tiff-load.c
==============================================================================
--- trunk/plug-ins/common/file-tiff-load.c (original)
+++ trunk/plug-ins/common/file-tiff-load.c Mon Aug 18 10:02:20 2008
@@ -107,12 +107,13 @@
gint *nreturn_vals,
GimpParam **return_vals);
-static gboolean load_dialog (TIFF *tif,
- TiffSelectedPages *pages);
+static gboolean load_dialog (TIFF *tif,
+ TiffSelectedPages *pages);
-static gint32 load_image (const gchar *filename,
- TIFF *tif,
- TiffSelectedPages *pages);
+static gint32 load_image (const gchar *filename,
+ TIFF *tif,
+ TiffSelectedPages *pages,
+ GError **error);
static void load_rgba (TIFF *tif,
channel_data *channel);
@@ -259,6 +260,7 @@
{
static GimpParam values[2];
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
+ GError *error = NULL;
gint32 image;
TiffSelectedPages pages;
@@ -285,8 +287,9 @@
if (fd == -1)
{
- g_message (_("Could not open '%s' for reading: %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 reading: %s"),
+ gimp_filename_to_utf8 (filename), g_strerror (errno));
status = GIMP_PDB_EXECUTION_ERROR;
}
else
@@ -337,7 +340,8 @@
{
gimp_set_data (LOAD_PROC, &target, sizeof (target));
- image = load_image (param[1].data.d_string, tif, &pages);
+ image = load_image (param[1].data.d_string, tif, &pages,
+ &error);
g_free (pages.pages);
@@ -372,6 +376,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;
}
@@ -535,9 +546,10 @@
}
static gint32
-load_image (const gchar *filename,
- TIFF *tif,
- TiffSelectedPages *pages)
+load_image (const gchar *filename,
+ TIFF *tif,
+ TiffSelectedPages *pages,
+ GError **error)
{
gushort bps, spp, photomet;
guint16 orientation;
@@ -744,7 +756,8 @@
{
if ((image = gimp_image_new (cols, rows, image_type)) == -1)
{
- g_message ("Could not create a new image");
+ g_message ("Could not create a new image: %s",
+ gimp_get_pdb_error ());
return -1;
}
Modified: trunk/plug-ins/common/file-tiff-save.c
==============================================================================
--- trunk/plug-ins/common/file-tiff-save.c (original)
+++ trunk/plug-ins/common/file-tiff-save.c Mon Aug 18 10:02:20 2008
@@ -108,7 +108,8 @@
static gboolean save_image (const gchar *filename,
gint32 image,
gint32 drawable,
- gint32 orig_image);
+ gint32 orig_image,
+ GError **error);
static gboolean save_dialog (gboolean has_alpha,
gboolean is_monochrome);
@@ -218,6 +219,7 @@
gint32 drawable;
gint32 orig_image;
GimpExportReturn export = GIMP_EXPORT_CANCEL;
+ GError *error = NULL;
run_mode = param[0].data.d_int32;
@@ -341,7 +343,8 @@
if (status == GIMP_PDB_SUCCESS)
{
- if (save_image (param[3].data.d_string, image, drawable, orig_image))
+ if (save_image (param[3].data.d_string, image, drawable, orig_image,
+ &error))
{
/* Store mvals data */
gimp_set_data (SAVE_PROC, &tsvals, sizeof (TiffSaveVals));
@@ -360,6 +363,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;
}
@@ -617,10 +627,11 @@
*/
static gboolean
-save_image (const gchar *filename,
- gint32 image,
- gint32 layer,
- gint32 orig_image) /* the export function might have created a duplicate */
+save_image (const gchar *filename,
+ gint32 image,
+ gint32 layer,
+ gint32 orig_image, /* the export function might have */
+ GError **error) /* created a duplicate */
{
TIFF *tif;
gushort red[256];
@@ -668,8 +679,9 @@
if (fd == -1)
{
- 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;
}
@@ -769,7 +781,9 @@
break;
case GIMP_INDEXEDA_IMAGE:
- g_message ("TIFF save cannot handle indexed images with alpha channel.");
+ g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
+ "%s",
+ "TIFF save cannot handle indexed images with alpha channel.");
default:
return FALSE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]