gimp r26670 - in trunk: . plug-ins/file-jpeg
- From: neo svn gnome org
- To: svn-commits-list gnome org
- Subject: gimp r26670 - in trunk: . plug-ins/file-jpeg
- Date: Wed, 20 Aug 2008 07:07:56 +0000 (UTC)
Author: neo
Date: Wed Aug 20 07:07:56 2008
New Revision: 26670
URL: http://svn.gnome.org/viewvc/gimp?rev=26670&view=rev
Log:
2008-08-20 Sven Neumann <sven gimp org>
* plug-ins/file-jpeg/jpeg.[ch]
* plug-ins/file-jpeg/jpeg-load.[ch]
* plug-ins/file-jpeg/jpeg-save.[ch]: pass error messages with
the
return values instead of calling g_message().
Modified:
trunk/ChangeLog
trunk/plug-ins/file-jpeg/jpeg-load.c
trunk/plug-ins/file-jpeg/jpeg-load.h
trunk/plug-ins/file-jpeg/jpeg-save.c
trunk/plug-ins/file-jpeg/jpeg-save.h
trunk/plug-ins/file-jpeg/jpeg.c
trunk/plug-ins/file-jpeg/jpeg.h
Modified: trunk/plug-ins/file-jpeg/jpeg-load.c
==============================================================================
--- trunk/plug-ins/file-jpeg/jpeg-load.c (original)
+++ trunk/plug-ins/file-jpeg/jpeg-load.c Wed Aug 20 07:07:56 2008
@@ -66,9 +66,10 @@
gint32
-load_image (const gchar *filename,
- GimpRunMode runmode,
- gboolean preview)
+load_image (const gchar *filename,
+ GimpRunMode runmode,
+ gboolean preview,
+ GError **error)
{
GimpPixelRgn pixel_rgn;
GimpDrawable *drawable;
@@ -104,8 +105,9 @@
if ((infile = g_fopen (filename, "rb")) == 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;
}
@@ -590,9 +592,10 @@
}
gint32
-load_thumbnail_image (const gchar *filename,
- gint *width,
- gint *height)
+load_thumbnail_image (const gchar *filename,
+ gint *width,
+ gint *height,
+ GError **error)
{
gint32 volatile image_ID;
ExifData *exif_data;
@@ -821,8 +824,9 @@
if ((infile = g_fopen (filename, "rb")) == 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));
if (exif_data)
{
Modified: trunk/plug-ins/file-jpeg/jpeg-load.h
==============================================================================
--- trunk/plug-ins/file-jpeg/jpeg-load.h (original)
+++ trunk/plug-ins/file-jpeg/jpeg-load.h Wed Aug 20 07:07:56 2008
@@ -16,15 +16,17 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-gint32 load_image (const gchar *filename,
- GimpRunMode runmode,
- gboolean preview);
+gint32 load_image (const gchar *filename,
+ GimpRunMode runmode,
+ gboolean preview,
+ GError **error);
#ifdef HAVE_EXIF
-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 /* HAVE_EXIF */
Modified: trunk/plug-ins/file-jpeg/jpeg-save.c
==============================================================================
--- trunk/plug-ins/file-jpeg/jpeg-save.c (original)
+++ trunk/plug-ins/file-jpeg/jpeg-save.c Wed Aug 20 07:07:56 2008
@@ -44,9 +44,10 @@
#include "libgimp/stdplugins-intl.h"
#include "jpeg.h"
-#include "jpeg-settings.h"
#include "jpeg-icc.h"
+#include "jpeg-load.h"
#include "jpeg-save.h"
+#include "jpeg-settings.h"
#define SCALE_WIDTH 125
@@ -200,7 +201,7 @@
gtk_label_set_text (GTK_LABEL (preview_size), temp);
/* and load the preview */
- load_image (pp->file_name, GIMP_RUN_NONINTERACTIVE, TRUE);
+ load_image (pp->file_name, GIMP_RUN_NONINTERACTIVE, TRUE, NULL);
}
/* we cleanup here (load_image doesn't run in the background) */
@@ -249,11 +250,12 @@
}
gboolean
-save_image (const gchar *filename,
- gint32 image_ID,
- gint32 drawable_ID,
- gint32 orig_image_ID,
- gboolean preview)
+save_image (const gchar *filename,
+ gint32 image_ID,
+ gint32 drawable_ID,
+ gint32 orig_image_ID,
+ gboolean preview,
+ GError **error)
{
GimpPixelRgn pixel_rgn;
GimpDrawable *drawable;
@@ -317,8 +319,9 @@
*/
if ((outfile = 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;
}
@@ -752,7 +755,7 @@
preview_image_ID,
drawable_ID_global,
orig_image_ID_global,
- TRUE);
+ TRUE, NULL);
if (display_ID == -1)
display_ID = gimp_display_new (preview_image_ID);
Modified: trunk/plug-ins/file-jpeg/jpeg-save.h
==============================================================================
--- trunk/plug-ins/file-jpeg/jpeg-save.h (original)
+++ trunk/plug-ins/file-jpeg/jpeg-save.h Wed Aug 20 07:07:56 2008
@@ -39,10 +39,11 @@
extern gint32 drawable_ID_global;
-gboolean save_image (const gchar *filename,
- gint32 image_ID,
- gint32 drawable_ID,
- gint32 orig_image_ID,
- gboolean preview);
+gboolean save_image (const gchar *filename,
+ gint32 image_ID,
+ gint32 drawable_ID,
+ gint32 orig_image_ID,
+ gboolean preview,
+ GError **error);
gboolean save_dialog (void);
void load_save_defaults (void);
Modified: trunk/plug-ins/file-jpeg/jpeg.c
==============================================================================
--- trunk/plug-ins/file-jpeg/jpeg.c (original)
+++ trunk/plug-ins/file-jpeg/jpeg.c Wed Aug 20 07:07:56 2008
@@ -196,8 +196,8 @@
gint32 drawable_ID;
gint32 orig_image_ID;
GimpParasite *parasite;
- gboolean err;
GimpExportReturn export = GIMP_EXPORT_CANCEL;
+ GError *error = NULL;
run_mode = param[0].data.d_int32;
@@ -230,7 +230,7 @@
break;
}
- image_ID = load_image (param[1].data.d_string, run_mode, FALSE);
+ image_ID = load_image (param[1].data.d_string, run_mode, FALSE, &error);
if (image_ID != -1)
{
@@ -259,7 +259,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)
{
@@ -430,6 +430,7 @@
* over the JPEG encoding parameters.
*/
run_mode = GIMP_RUN_INTERACTIVE;
+
/* If this image was loaded from a JPEG file and has not been
* saved yet, try to use some of the settings from the
* original file if they are better than the default values.
@@ -439,6 +440,7 @@
jsvals.quality = orig_quality;
jsvals.use_orig_quality = TRUE;
}
+
if (orig_subsmp == 2 || (orig_subsmp > 0 && jsvals.subsmp == 0))
jsvals.subsmp = orig_subsmp;
}
@@ -462,7 +464,7 @@
drawable_ID_global = drawable_ID;
/* First acquire information with a dialog */
- err = save_dialog ();
+ status = (save_dialog () ? GIMP_PDB_SUCCESS : GIMP_PDB_CANCEL);
if (undo_touched)
{
@@ -471,18 +473,13 @@
gimp_image_undo_thaw (image_ID);
gimp_displays_flush ();
}
-
- if (!err)
- status = GIMP_PDB_CANCEL;
}
if (status == GIMP_PDB_SUCCESS)
{
if (! save_image (param[3].data.d_string,
- image_ID,
- drawable_ID,
- orig_image_ID,
- FALSE))
+ image_ID, drawable_ID, orig_image_ID, FALSE,
+ &error))
{
status = GIMP_PDB_EXECUTION_ERROR;
}
@@ -525,6 +522,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;
}
Modified: trunk/plug-ins/file-jpeg/jpeg.h
==============================================================================
--- trunk/plug-ins/file-jpeg/jpeg.h (original)
+++ trunk/plug-ins/file-jpeg/jpeg.h Wed Aug 20 07:07:56 2008
@@ -53,9 +53,6 @@
extern gint orig_subsmp;
extern gint num_quant_tables;
-gint32 load_image (const gchar *filename,
- GimpRunMode runmode,
- gboolean preview);
void destroy_preview (void);
@@ -68,10 +65,6 @@
extern ExifData *exif_data;
-gint32 load_thumbnail_image (const gchar *filename,
- gint *width,
- gint *height);
-
ExifData * jpeg_exif_data_new_from_file (const gchar *filename,
GError **error);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]