gimp r26636 - in trunk: . plug-ins/common
- From: neo svn gnome org
- To: svn-commits-list gnome org
- Subject: gimp r26636 - in trunk: . plug-ins/common
- Date: Sun, 17 Aug 2008 21:30:35 +0000 (UTC)
Author: neo
Date: Sun Aug 17 21:30:34 2008
New Revision: 26636
URL: http://svn.gnome.org/viewvc/gimp?rev=26636&view=rev
Log:
2008-08-17 Sven Neumann <sven gimp org>
* plug-ins/common/file-gif-load.c
* plug-ins/common/file-gif-save.c: for the most common errors,
pass the error message with the return values instead of calling
gimp_message().
* plug-ins/common/file-png.c: unmarked a string for translation.
This error condition can't possibly happen.
* plug-ins/common/file-svg.c: also return an error message when
the thumbnail can't be loaded.
Modified:
trunk/ChangeLog
trunk/plug-ins/common/file-gif-load.c
trunk/plug-ins/common/file-gif-save.c
trunk/plug-ins/common/file-png.c
trunk/plug-ins/common/file-svg.c
Modified: trunk/plug-ins/common/file-gif-load.c
==============================================================================
--- trunk/plug-ins/common/file-gif-load.c (original)
+++ trunk/plug-ins/common/file-gif-load.c Sun Aug 17 21:30:34 2008
@@ -92,7 +92,8 @@
gint *nreturn_vals,
GimpParam **return_vals);
static gint32 load_image (const gchar *filename,
- gboolean thumbnail);
+ gboolean thumbnail,
+ GError **error);
static guchar used_cmap[3][256];
@@ -177,6 +178,7 @@
{
static GimpParam values[2];
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
+ GError *error = NULL;
gint32 image_ID;
INIT_I18N ();
@@ -189,11 +191,11 @@
if (strcmp (name, LOAD_PROC) == 0)
{
- image_ID = load_image (param[1].data.d_string, FALSE);
+ image_ID = load_image (param[1].data.d_string, FALSE, &error);
}
else if (strcmp (name, LOAD_THUMB_PROC) == 0)
{
- image_ID = load_image (param[0].data.d_string, TRUE);
+ image_ID = load_image (param[0].data.d_string, TRUE, &error);
}
else
{
@@ -228,6 +230,13 @@
else
{
status = GIMP_PDB_EXECUTION_ERROR;
+
+ if (error)
+ {
+ *nreturn_vals = 2;
+ values[1].type = GIMP_PDB_STRING;
+ values[1].data.d_string = error->message;
+ }
}
}
@@ -289,8 +298,9 @@
static gint32
-load_image (const gchar *filename,
- gboolean thumbnail)
+load_image (const gchar *filename,
+ gboolean thumbnail,
+ GError **error)
{
FILE *fd;
guchar buf[16];
@@ -304,10 +314,12 @@
gint32 image_ID = -1;
fd = g_fopen (filename, "rb");
- if (!fd)
+
+ if (! fd)
{
- 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;
}
@@ -322,7 +334,8 @@
if (strncmp ((gchar *) buf, "GIF", 3) != 0)
{
- g_message (_("This is not a GIF file"));
+ g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
+ "%s", _("This is not a GIF file"));
return -1;
}
Modified: trunk/plug-ins/common/file-gif-save.c
==============================================================================
--- trunk/plug-ins/common/file-gif-save.c (original)
+++ trunk/plug-ins/common/file-gif-save.c Sun Aug 17 21:30:34 2008
@@ -82,19 +82,22 @@
/* Declare some local functions.
*/
-static void query (void);
-static void run (const gchar *name,
+static void query (void);
+static void run (const gchar *name,
gint nparams,
const GimpParam *param,
gint *nreturn_vals,
GimpParam **return_vals);
-static gint save_image (const gchar *filename,
+
+static gboolean save_image (const gchar *filename,
gint32 image_ID,
gint32 drawable_ID,
- gint32 orig_image_ID);
+ gint32 orig_image_ID,
+ GError **error);
-static gboolean sanity_check (const gchar *filename,
- gint32 image_ID);
+static GimpPDBStatusType sanity_check (const gchar *filename,
+ gint32 image_ID,
+ GError **error);
static gboolean bad_bounds_dialog (void);
static gboolean save_dialog (gint32 image_ID);
@@ -182,6 +185,7 @@
static GimpParam values[2];
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
GimpExportReturn export = GIMP_EXPORT_CANCEL;
+ GError *error = NULL;
run_mode = param[0].data.d_int32;
@@ -210,6 +214,7 @@
case GIMP_RUN_INTERACTIVE:
case GIMP_RUN_WITH_LAST_VALS:
gimp_ui_init (PLUG_IN_BINARY, FALSE);
+
export = gimp_export_image (&image_ID, &drawable_ID, "GIF",
(GIMP_EXPORT_CAN_HANDLE_INDEXED |
GIMP_EXPORT_CAN_HANDLE_GRAY |
@@ -225,7 +230,9 @@
break;
}
- if (sanity_check (filename, image_ID))
+ status = sanity_check (filename, image_ID, &error);
+
+ if (status == GIMP_PDB_SUCCESS)
{
switch (run_mode)
{
@@ -266,9 +273,8 @@
if (status == GIMP_PDB_SUCCESS)
{
if (save_image (param[3].data.d_string,
- image_ID,
- drawable_ID,
- orig_image_ID))
+ image_ID, drawable_ID, orig_image_ID,
+ &error))
{
/* Store psvals data */
gimp_set_data (SAVE_PROC, &gsvals, sizeof (GIFSaveVals));
@@ -279,15 +285,19 @@
}
}
}
- else
- /* Some layers were out of bounds and the user wishes
- to abort. */
- {
- status = GIMP_PDB_CANCEL;
- }
if (export == GIMP_EXPORT_EXPORT)
gimp_image_delete (image_ID);
+
+ if (status == GIMP_PDB_EXECUTION_ERROR)
+ {
+ if (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 +545,10 @@
}
-static gboolean
-sanity_check (const gchar *filename,
- gint32 image_ID)
+static GimpPDBStatusType
+sanity_check (const gchar *filename,
+ gint32 image_ID,
+ GError **error)
{
gint32 *layers;
gint nlayers;
@@ -550,9 +561,13 @@
if (image_width > G_MAXUSHORT || image_height > G_MAXUSHORT)
{
- g_message (_("Unable to save '%s'. The GIF file format does not support images that are more than %d pixels wide or tall."),
- gimp_filename_to_utf8 (filename), G_MAXUSHORT);
- return FALSE;
+ g_set_error (error, 0, 0,
+ _("Unable to save '%s'. "
+ "The GIF file format does not support images that are "
+ "more than %d pixels wide or tall."),
+ gimp_filename_to_utf8 (filename), G_MAXUSHORT);
+
+ return GIMP_PDB_EXECUTION_ERROR;
}
/*** Iterate through the layers to make sure they're all ***/
@@ -577,30 +592,32 @@
/* Image has illegal bounds - ask the user what it wants to do */
/* Do the crop if we can't talk to the user, or if we asked
- * the user and they said yes. */
+ * the user and they said yes.
+ */
if ((run_mode == GIMP_RUN_NONINTERACTIVE) || bad_bounds_dialog ())
{
gimp_image_crop (image_ID, image_width, image_height, 0, 0);
- return TRUE;
+ return GIMP_PDB_SUCCESS;
}
else
{
- return FALSE;
+ return GIMP_PDB_CANCEL;
}
}
}
g_free (layers);
- return TRUE;
+ return GIMP_PDB_SUCCESS;
}
-static gint
+static gboolean
save_image (const gchar *filename,
gint32 image_ID,
gint32 drawable_ID,
- gint32 orig_image_ID)
+ gint32 orig_image_ID,
+ GError **error)
{
GimpPixelRgn pixel_rgn;
GimpDrawable *drawable;
@@ -743,8 +760,9 @@
outfile = g_fopen (filename, "wb");
if (!outfile)
{
- 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-png.c
==============================================================================
--- trunk/plug-ins/common/file-png.c (original)
+++ trunk/plug-ins/common/file-png.c Sun Aug 17 21:30:34 2008
@@ -1349,8 +1349,7 @@
break;
default:
- g_set_error (error, 0, 0,
- "%s", _("Image type can't be saved as PNG"));
+ g_set_error (error, 0, 0, "Image type can't be saved as PNG");
return FALSE;
}
Modified: trunk/plug-ins/common/file-svg.c
==============================================================================
--- trunk/plug-ins/common/file-svg.c (original)
+++ trunk/plug-ins/common/file-svg.c Sun Aug 17 21:30:34 2008
@@ -279,7 +279,7 @@
load_vals.width = - param[1].data.d_int32;
load_vals.height = - param[1].data.d_int32;
- image_ID = load_image (filename, NULL);
+ image_ID = load_image (filename, &error);
if (image_ID != -1)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]