gimp r26674 - in trunk: . plug-ins/file-sgi



Author: neo
Date: Wed Aug 20 12:49:41 2008
New Revision: 26674
URL: http://svn.gnome.org/viewvc/gimp?rev=26674&view=rev

Log:
2008-08-20  Sven Neumann  <sven gimp org>

	* plug-ins/file-sgi/sgi.c
	* plug-ins/file-sgi/sgi-lib.[ch]: pass error messages with the
	return values instead of calling g_message().



Modified:
   trunk/ChangeLog
   trunk/plug-ins/file-sgi/sgi-lib.c
   trunk/plug-ins/file-sgi/sgi-lib.h
   trunk/plug-ins/file-sgi/sgi.c

Modified: trunk/plug-ins/file-sgi/sgi-lib.c
==============================================================================
--- trunk/plug-ins/file-sgi/sgi-lib.c	(original)
+++ trunk/plug-ins/file-sgi/sgi-lib.c	Wed Aug 20 12:49:41 2008
@@ -246,13 +246,13 @@
  */
 
 sgi_t *
-sgiOpen(char *filename,	/* I - File to open */
-        int  mode,	/* I - Open mode (SGI_READ or SGI_WRITE) */
-        int  comp,	/* I - Type of compression */
-        int  bpp,	/* I - Bytes per pixel */
-        int  xsize,	/* I - Width of image in pixels */
-        int  ysize,	/* I - Height of image in pixels */
-        int  zsize)	/* I - Number of channels */
+sgiOpen(const char *filename,	/* I - File to open */
+        int         mode,	/* I - Open mode (SGI_READ or SGI_WRITE) */
+        int         comp,	/* I - Type of compression */
+        int         bpp,	/* I - Bytes per pixel */
+        int         xsize,	/* I - Width of image in pixels */
+        int         ysize,	/* I - Height of image in pixels */
+        int         zsize)	/* I - Number of channels */
 {
   sgi_t	*sgip;		/* New SGI image file */
   FILE	*file;		/* Image file pointer */

Modified: trunk/plug-ins/file-sgi/sgi-lib.h
==============================================================================
--- trunk/plug-ins/file-sgi/sgi-lib.h	(original)
+++ trunk/plug-ins/file-sgi/sgi-lib.h	Wed Aug 20 12:49:41 2008
@@ -70,7 +70,7 @@
                               unsigned short *row,
                               int y,
                               int z);
-extern sgi_t	*sgiOpen     (char *filename,
+extern sgi_t	*sgiOpen     (const char *filename,
                               int mode,
                               int comp,
                               int bpp,

Modified: trunk/plug-ins/file-sgi/sgi.c
==============================================================================
--- trunk/plug-ins/file-sgi/sgi.c	(original)
+++ trunk/plug-ins/file-sgi/sgi.c	Wed Aug 20 12:49:41 2008
@@ -62,10 +62,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);
 
@@ -155,12 +157,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;
 
   run_mode = param[0].data.d_int32;
 
@@ -173,7 +176,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)
         {
@@ -256,7 +259,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, &compression, sizeof (compression));
             }
@@ -274,6 +278,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;
 }
 
@@ -283,9 +294,10 @@
  */
 
 static gint32
-load_image (const gchar *filename)  /* I - File to load */
+load_image (const gchar  *filename,
+            GError      **error)
 {
-  int            i,           /* Looping var */
+  gint           i,           /* Looping var */
                  x,           /* Current X coordinate */
                  y,           /* Current Y coordinate */
                  image_type,  /* Type of image */
@@ -307,11 +319,12 @@
   * Open the file for reading...
   */
 
-  sgip = sgiOpen ((char *) filename, SGI_READ, 0, 0, 0, 0, 0);
+  sgip = sgiOpen (filename, SGI_READ, 0, 0, 0, 0, 0);
   if (sgip == NULL)
     {
-      g_message (_("Could not open '%s' for reading."),
-                 gimp_filename_to_utf8 (filename));
+      g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
+                   _("Could not open '%s' for reading."),
+                   gimp_filename_to_utf8 (filename));
       return -1;
     };
 
@@ -356,7 +369,9 @@
   image = gimp_image_new (sgip->xsize, sgip->ysize, image_type);
   if (image == -1)
     {
-      g_message ("Could not allocate new image");
+      g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
+                   "Could not allocate new image: %s",
+                   gimp_get_pdb_error());
       return -1;
     }
 
@@ -474,9 +489,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)
 {
   gint        i, j,        /* Looping var */
               x,           /* Current X coordinate */
@@ -525,12 +541,13 @@
    * Open the file for writing...
    */
 
-  sgip = sgiOpen ((char *) filename, SGI_WRITE, compression, 1,
+  sgip = sgiOpen (filename, SGI_WRITE, compression, 1,
                   drawable->width, drawable->height, zsize);
   if (sgip == NULL)
     {
-      g_message (_("Could not open '%s' for writing."),
-                  gimp_filename_to_utf8 (filename));
+      g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
+                   _("Could not open '%s' for writing."),
+                   gimp_filename_to_utf8 (filename));
       return FALSE;
     };
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]