gimp r26639 - in trunk: . plug-ins/common
- From: neo svn gnome org
- To: svn-commits-list gnome org
- Subject: gimp r26639 - in trunk: . plug-ins/common
- Date: Mon, 18 Aug 2008 06:53:22 +0000 (UTC)
Author: neo
Date: Mon Aug 18 06:53:21 2008
New Revision: 26639
URL: http://svn.gnome.org/viewvc/gimp?rev=26639&view=rev
Log:
2008-08-18 Sven Neumann <sven gimp org>
* plug-ins/common/file-pnm.c
* plug-ins/common/file-ps.c
* plug-ins/common/file-psp.c: for the most common errors, pass
the
error message with the return values instead of calling
gimp_message().
Modified:
trunk/ChangeLog
trunk/plug-ins/common/file-png.c
trunk/plug-ins/common/file-pnm.c
trunk/plug-ins/common/file-ps.c
trunk/plug-ins/common/file-psp.c
Modified: trunk/plug-ins/common/file-png.c
==============================================================================
--- trunk/plug-ins/common/file-png.c (original)
+++ trunk/plug-ins/common/file-png.c Mon Aug 18 06:53:21 2008
@@ -699,7 +699,7 @@
if (setjmp (pp->jmpbuf))
{
- g_set_error (error, 0, 0,
+ g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
_("Error while reading '%s'. File corrupted?"),
gimp_filename_to_utf8 (filename));
return image;
Modified: trunk/plug-ins/common/file-pnm.c
==============================================================================
--- trunk/plug-ins/common/file-pnm.c (original)
+++ trunk/plug-ins/common/file-pnm.c Mon Aug 18 06:53:21 2008
@@ -125,11 +125,13 @@
const GimpParam *param,
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,
- gboolean pbm);
+ gboolean pbm,
+ GError **error);
static gint save_dialog (void);
@@ -321,13 +323,14 @@
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;
- gboolean pbm = FALSE; /* flag for PBM output */
+ 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;
+ gboolean pbm = FALSE; /* flag for PBM output */
run_mode = param[0].data.d_int32;
@@ -340,7 +343,7 @@
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)
{
@@ -437,7 +440,8 @@
if (status == GIMP_PDB_SUCCESS)
{
- if (save_image (param[3].data.d_string, image_ID, drawable_ID, pbm))
+ if (save_image (param[3].data.d_string, image_ID, drawable_ID, pbm,
+ &error))
{
/* Store psvals data */
gimp_set_data (name, &psvals, sizeof (PNMSaveVals));
@@ -456,11 +460,19 @@
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;
}
static gint32
-load_image (const gchar *filename)
+load_image (const gchar *filename,
+ GError **error)
{
GimpPixelRgn pixel_rgn;
gint32 volatile image_ID = -1;
@@ -477,8 +489,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));
return -1;
}
@@ -916,10 +929,11 @@
}
static gboolean
-save_image (const gchar *filename,
- gint32 image_ID,
- gint32 drawable_ID,
- gboolean pbm)
+save_image (const gchar *filename,
+ gint32 image_ID,
+ gint32 drawable_ID,
+ gboolean pbm,
+ GError **error)
{
GimpPixelRgn pixel_rgn;
GimpDrawable *drawable;
@@ -955,8 +969,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;
}
Modified: trunk/plug-ins/common/file-ps.c
==============================================================================
--- trunk/plug-ins/common/file-ps.c (original)
+++ trunk/plug-ins/common/file-ps.c Mon Aug 18 06:53:21 2008
@@ -194,10 +194,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 gint save_gray (FILE *ofp,
gint32 image_ID,
@@ -759,13 +761,14 @@
gint *nreturn_vals,
GimpParam **return_vals)
{
- static GimpParam values[2];
- GimpRunMode run_mode;
- GimpPDBStatusType status = GIMP_PDB_SUCCESS;
- gint32 image_ID = -1;
- gint32 drawable_ID = -1;
- gint32 orig_image_ID = -1;
- GimpExportReturn export = GIMP_EXPORT_CANCEL;
+ static GimpParam values[2];
+ GimpRunMode run_mode;
+ GimpPDBStatusType status = GIMP_PDB_SUCCESS;
+ gint32 image_ID = -1;
+ gint32 drawable_ID = -1;
+ gint32 orig_image_ID = -1;
+ GimpExportReturn export = GIMP_EXPORT_CANCEL;
+ GError *error = NULL;
l_run_mode = run_mode = param[0].data.d_int32;
@@ -812,7 +815,7 @@
if (status == GIMP_PDB_SUCCESS)
{
check_load_vals ();
- image_ID = load_image (param[1].data.d_string);
+ image_ID = load_image (param[1].data.d_string, &error);
if (image_ID != -1)
{
@@ -851,7 +854,7 @@
strcpy (plvals.pages, "1");
check_load_vals ();
- image_ID = load_image (param[0].data.d_string);
+ image_ID = load_image (param[0].data.d_string, &error);
if (image_ID != -1)
{
@@ -944,7 +947,8 @@
ps_set_save_size (&psvals, orig_image_ID);
check_save_vals ();
- 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 (name, &psvals, sizeof (PSSaveVals));
@@ -990,12 +994,20 @@
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;
}
static gint32
-load_image (const gchar *filename)
+load_image (const gchar *filename,
+ GError **error)
{
gint32 image_ID = 0;
gint32 *image_list, *nl;
@@ -1020,8 +1032,9 @@
ifp = g_fopen (filename, "r");
if (ifp == NULL)
{
- 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;
}
fclose (ifp);
@@ -1156,9 +1169,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)
{
FILE* ofp;
GimpImageType drawable_type;
@@ -1193,8 +1207,9 @@
ofp = g_fopen (filename, "wb");
if (!ofp)
{
- 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-psp.c
==============================================================================
--- trunk/plug-ins/common/file-psp.c (original)
+++ trunk/plug-ins/common/file-psp.c Mon Aug 18 06:53:21 2008
@@ -528,10 +528,12 @@
const GimpParam *param,
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);
/* Various local variables...
*/
@@ -607,7 +609,7 @@
"",
"0,string,Paint\\040Shop\\040Pro\\040Image\\040File\n\032");
- /* Removed until Saving is implemented -- njl195 zepler org */
+ /* commented out until saving is implemented */
#if 0
gimp_install_procedure (SAVE_PROC,
"saves images in the Paint Shop Pro PSP file format",
@@ -1725,7 +1727,8 @@
/* The main function for loading PSP-images
*/
static gint32
-load_image (const gchar *filename)
+load_image (const gchar *filename,
+ GError **error)
{
FILE *f;
struct stat st;
@@ -1744,8 +1747,9 @@
f = g_fopen (filename, "rb");
if (f == NULL)
{
- 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;
}
@@ -1917,9 +1921,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)
{
g_message ("Saving not implemented yet");
@@ -1933,12 +1938,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;
INIT_I18N ();
@@ -1952,7 +1958,7 @@
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)
{
@@ -2028,7 +2034,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))
{
gimp_set_data (SAVE_PROC, &psvals, sizeof (PSPSaveVals));
}
@@ -2046,5 +2053,12 @@
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;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]