gimp r26671 - in trunk: . plug-ins/file-psd
- From: neo svn gnome org
- To: svn-commits-list gnome org
- Subject: gimp r26671 - in trunk: . plug-ins/file-psd
- Date: Wed, 20 Aug 2008 07:36:25 +0000 (UTC)
Author: neo
Date: Wed Aug 20 07:36:25 2008
New Revision: 26671
URL: http://svn.gnome.org/viewvc/gimp?rev=26671&view=rev
Log:
2008-08-20 Sven Neumann <sven gimp org>
* plug-ins/file-psd/psd.c
* plug-ins/file-psd/psd-load.[ch]
* plug-ins/file-psd/psd-save.c
* plug-ins/file-psd/psd-thumb-load.[ch]: pass error messages
with
the return values instead of calling g_message().
Modified:
trunk/ChangeLog
trunk/plug-ins/file-psd/psd-load.c
trunk/plug-ins/file-psd/psd-load.h
trunk/plug-ins/file-psd/psd-save.c
trunk/plug-ins/file-psd/psd-thumb-load.c
trunk/plug-ins/file-psd/psd-thumb-load.h
trunk/plug-ins/file-psd/psd.c
Modified: trunk/plug-ins/file-psd/psd-load.c
==============================================================================
--- trunk/plug-ins/file-psd/psd-load.c (original)
+++ trunk/plug-ins/file-psd/psd-load.c Wed Aug 20 07:36:25 2008
@@ -105,7 +105,8 @@
/* Main file load function */
gint32
-load_image (const gchar *filename)
+load_image (const gchar *filename,
+ GError **load_error)
{
FILE *f;
struct stat st;
@@ -122,8 +123,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 (load_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;
}
@@ -205,7 +207,8 @@
load_error:
if (error)
{
- g_message (_("Error loading PSD file:\n\n%s"), error->message);
+ g_set_error (load_error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
+ _("Error loading PSD file: %s"), error->message);
g_error_free (error);
}
Modified: trunk/plug-ins/file-psd/psd-load.h
==============================================================================
--- trunk/plug-ins/file-psd/psd-load.h (original)
+++ trunk/plug-ins/file-psd/psd-load.h Wed Aug 20 07:36:25 2008
@@ -23,7 +23,8 @@
#define __PSD_LOAD_H__
-gint32 load_image (const gchar *filename);
+gint32 load_image (const gchar *filename,
+ GError **error);
#endif /* __PSD_LOAD_H__ */
Modified: trunk/plug-ins/file-psd/psd-save.c
==============================================================================
--- trunk/plug-ins/file-psd/psd-save.c (original)
+++ trunk/plug-ins/file-psd/psd-save.c Wed Aug 20 07:36:25 2008
@@ -156,7 +156,8 @@
static void save_data (FILE *fd,
gint32 image_id);
static gint save_image (const gchar *filename,
- gint32 image_id);
+ gint32 image_id,
+ GError **error);
static void xfwrite (FILE *fd,
gconstpointer buf,
glong len,
@@ -237,8 +238,9 @@
gint *nreturn_vals,
GimpParam **return_vals)
{
- static GimpParam values[2];
- GimpRunMode run_mode;
+ static GimpParam values[2];
+ GimpRunMode run_mode;
+ GError *error = NULL;
run_mode = param[0].data.d_int32;
@@ -284,10 +286,21 @@
break;
}
- if (save_image (param[3].data.d_string, image_id))
- values[0].data.d_status = GIMP_PDB_SUCCESS;
+ if (save_image (param[3].data.d_string, image_id, &error))
+ {
+ values[0].data.d_status = GIMP_PDB_SUCCESS;
+ }
else
- values[0].data.d_status = GIMP_PDB_EXECUTION_ERROR;
+ {
+ values[0].data.d_status = GIMP_PDB_EXECUTION_ERROR;
+
+ if (error)
+ {
+ *nreturn_vals = 2;
+ values[1].type = GIMP_PDB_STRING;
+ values[1].data.d_string = error->message;
+ }
+ }
if (export == GIMP_EXPORT_EXPORT)
gimp_image_delete (image_id);
@@ -395,7 +408,9 @@
xfwrite (fd, val, len, why);
}
else
- write_gint16 (fd, 0, why);
+ {
+ write_gint16 (fd, 0, why);
+ }
/* If total length (length byte + content) is not a multiple of PADDING,
add zeros to pad it. */
@@ -1518,8 +1533,9 @@
static gint
-save_image (const gchar *filename,
- gint32 image_id)
+save_image (const gchar *filename,
+ gint32 image_id,
+ GError **error)
{
FILE *fd;
gint32 *layers;
@@ -1531,9 +1547,12 @@
if (gimp_image_width (image_id) > 30000 ||
gimp_image_height (image_id) > 30000)
- {
- g_message (_("Unable to save '%s'. The PSD file format does not support images that are more than 30,000 pixels wide or tall."),
- gimp_filename_to_utf8 (filename));
+ {
+ g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
+ _("Unable to save '%s'. The PSD file format does not "
+ "support images that are more than 30,000 pixels wide "
+ "or tall."),
+ gimp_filename_to_utf8 (filename));
return FALSE;
}
@@ -1544,8 +1563,11 @@
drawable = gimp_drawable_get (layers[i]);
if (drawable->width > 30000 || drawable->height > 30000)
{
- g_message (_("Unable to save '%s'. The PSD file format does not support images with layers that are more than 30,000 pixels wide or tall."),
- gimp_filename_to_utf8 (filename));
+ g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
+ _("Unable to save '%s'. The PSD file format does not "
+ "support images with layers that are more than 30,000 "
+ "pixels wide or tall."),
+ gimp_filename_to_utf8 (filename));
g_free (layers);
return FALSE;
}
@@ -1556,8 +1578,9 @@
fd = g_fopen (filename, "wb");
if (fd == 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/file-psd/psd-thumb-load.c
==============================================================================
--- trunk/plug-ins/file-psd/psd-thumb-load.c (original)
+++ trunk/plug-ins/file-psd/psd-thumb-load.c Wed Aug 20 07:36:25 2008
@@ -35,37 +35,38 @@
#include "libgimp/stdplugins-intl.h"
/* Local function prototypes */
-static gint read_header_block (PSDimage *img_a,
- FILE *f,
- GError **error);
-
-static gint read_color_mode_block (PSDimage *img_a,
- FILE *f,
- GError **error);
-
-static gint read_image_resource_block (PSDimage *img_a,
- FILE *f,
- GError **error);
-
-static gint32 create_gimp_image (PSDimage *img_a,
- const gchar *filename);
-
-static gint add_image_resources (const gint32 image_id,
- PSDimage *img_a,
- FILE *f,
- GError **error);
+static gint read_header_block (PSDimage *img_a,
+ FILE *f,
+ GError **error);
+
+static gint read_color_mode_block (PSDimage *img_a,
+ FILE *f,
+ GError **error);
+
+static gint read_image_resource_block (PSDimage *img_a,
+ FILE *f,
+ GError **error);
+
+static gint32 create_gimp_image (PSDimage *img_a,
+ const gchar *filename);
+
+static gint add_image_resources (const gint32 image_id,
+ PSDimage *img_a,
+ FILE *f,
+ GError **error);
/* Main file load function */
gint32
-load_thumbnail_image (const gchar *filename,
- gint *width,
- gint *height)
+load_thumbnail_image (const gchar *filename,
+ gint *width,
+ gint *height,
+ GError **load_error)
{
- FILE *f;
- struct stat st;
- PSDimage img_a;
- gint32 image_id = -1;
- GError *error = NULL;
+ FILE *f;
+ struct stat st;
+ PSDimage img_a;
+ gint32 image_id = -1;
+ GError *error = NULL;
/* ----- Open PSD file ----- */
if (g_stat (filename, &st) == -1)
@@ -75,8 +76,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 (load_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;
}
@@ -123,6 +125,13 @@
/* ----- Process load errors ----- */
load_error:
+ if (error)
+ {
+ g_set_error (load_error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
+ _("Error loading PSD file: %s"), error->message);
+ g_error_free (error);
+ }
+
/* Delete partially loaded image */
if (image_id > 0)
gimp_image_delete (image_id);
Modified: trunk/plug-ins/file-psd/psd-thumb-load.h
==============================================================================
--- trunk/plug-ins/file-psd/psd-thumb-load.h (original)
+++ trunk/plug-ins/file-psd/psd-thumb-load.h Wed Aug 20 07:36:25 2008
@@ -23,9 +23,10 @@
#define __PSD_THUMB_LOAD_H__
-gint32 load_thumbnail_image (const gchar *filename,
- gint *width,
- gint *height);
+gint32 load_thumbnail_image (const gchar *filename,
+ gint *width,
+ gint *height,
+ GError **error);
#endif /* __PSD_THUMB_LOAD_H__ */
Modified: trunk/plug-ins/file-psd/psd.c
==============================================================================
--- trunk/plug-ins/file-psd/psd.c (original)
+++ trunk/plug-ins/file-psd/psd.c Wed Aug 20 07:36:25 2008
@@ -172,6 +172,7 @@
GimpRunMode run_mode;
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
gint32 image_ID;
+ GError *error = NULL;
#ifdef PSD_SAVE
gint32 drawable_ID;
GimpExportReturn export = GIMP_EXPORT_CANCEL;
@@ -190,7 +191,7 @@
/* File load */
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)
{
@@ -217,7 +218,7 @@
gint width = 0;
gint height = 0;
- image_ID = load_thumbnail_image (filename, &width, &height);
+ image_ID = load_thumbnail_image (filename, &width, &height, &error);
if (image_ID != -1)
{
@@ -267,7 +268,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))
{
}
else
@@ -287,5 +289,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]