diff --git a/plug-ins/file-tiff/file-tiff-io.c b/plug-ins/file-tiff/file-tiff-io.c index 2139236dd8..c6e5520a9a 100644 --- a/plug-ins/file-tiff/file-tiff-io.c +++ b/plug-ins/file-tiff/file-tiff-io.c @@ -41,10 +41,12 @@ static void tiff_error (const gchar *module, TIFF * -tiff_open (const gchar *filename, +tiff_open (GFile *file, const gchar *mode, GError **error) { + gchar *filename = g_file_get_path (file); + TIFFSetWarningHandler (tiff_warning); TIFFSetErrorHandler (tiff_error); diff --git a/plug-ins/file-tiff/file-tiff-io.h b/plug-ins/file-tiff/file-tiff-io.h index b9c285bcb4..f4d4e31879 100644 --- a/plug-ins/file-tiff/file-tiff-io.h +++ b/plug-ins/file-tiff/file-tiff-io.h @@ -23,7 +23,7 @@ #define __FILE_TIFF_IO_H__ -TIFF * tiff_open (const gchar *filename, +TIFF * tiff_open (GFile *file, const gchar *mode, GError **error); diff --git a/plug-ins/file-tiff/file-tiff-load.c b/plug-ins/file-tiff/file-tiff-load.c index affaf10931..ffbd066f4a 100644 --- a/plug-ins/file-tiff/file-tiff-load.c +++ b/plug-ins/file-tiff/file-tiff-load.c @@ -218,7 +218,7 @@ load_dialog (TIFF *tif, } gint32 -load_image (const gchar *filename, +load_image (GFile *file, TIFF *tif, TiffSelectedPages *pages, gboolean *resolution_loaded, @@ -234,7 +234,7 @@ load_image (const gchar *filename, gint li; gimp_progress_init_printf (_("Opening '%s'"), - gimp_filename_to_utf8 (filename)); + gimp_file_get_utf8_name (file)); /* We will loop through the all pages in case of multipage TIFF * and load every page as a separate layer. @@ -370,14 +370,14 @@ load_image (const gchar *filename, if (! TIFFGetField (tif, TIFFTAG_IMAGEWIDTH, &cols)) { g_message ("Could not get image width from '%s'", - gimp_filename_to_utf8 (filename)); + gimp_file_get_utf8_name (file)); return -1; } if (! TIFFGetField (tif, TIFFTAG_IMAGELENGTH, &rows)) { g_message ("Could not get image length from '%s'", - gimp_filename_to_utf8 (filename)); + gimp_file_get_utf8_name (file)); return -1; } @@ -393,14 +393,14 @@ load_image (const gchar *filename, { g_message ("Could not get photometric from '%s'. " "Image is CCITT compressed, assuming min-is-white", - filename); + gimp_file_get_utf8_name (file)); photomet = PHOTOMETRIC_MINISWHITE; } else { g_message ("Could not get photometric from '%s'. " "Assuming min-is-black", - filename); + gimp_file_get_utf8_name (file)); /* old AppleScan software misses out the photometric tag * (and incidentally assumes min-is-white, but xv @@ -429,7 +429,7 @@ load_image (const gchar *filename, /* assuming unassociated alpha if unspecified */ g_message ("alpha channel type not defined for file %s. " "Assuming alpha is not premultiplied", - gimp_filename_to_utf8 (filename)); + gimp_file_get_utf8_name (file)); alpha = TRUE; tsvals.save_transp_pixels = TRUE; extra--; @@ -704,7 +704,8 @@ load_image (const gchar *filename, if (pages->target == GIMP_PAGE_SELECTOR_TARGET_IMAGES) { - gchar *fname = g_strdup_printf ("%s-%d", filename, ilayer); + gchar *fname = g_strdup_printf ("%s-%d", g_file_get_uri (file), + ilayer); gimp_image_set_filename (image, fname); g_free (fname); @@ -714,7 +715,8 @@ load_image (const gchar *filename, } else if (pages->o_pages != pages->n_pages) { - gchar *fname = g_strdup_printf (_("%s-%d-of-%d-pages"), filename, + gchar *fname = g_strdup_printf (_("%s-%d-of-%d-pages"), + g_file_get_uri (file), pages->n_pages, pages->o_pages); gimp_image_set_filename (image, fname); @@ -722,7 +724,7 @@ load_image (const gchar *filename, } else { - gimp_image_set_filename (image, filename); + gimp_image_set_filename (image, g_file_get_uri (file)); } } @@ -883,7 +885,7 @@ load_image (const gchar *filename, &redmap, &greenmap, &bluemap)) { g_message ("Could not get colormaps from '%s'", - gimp_filename_to_utf8 (filename)); + gimp_file_get_utf8_name (file)); return -1; } diff --git a/plug-ins/file-tiff/file-tiff-load.h b/plug-ins/file-tiff/file-tiff-load.h index fb4b2b6dbb..372af71f53 100644 --- a/plug-ins/file-tiff/file-tiff-load.h +++ b/plug-ins/file-tiff/file-tiff-load.h @@ -36,7 +36,7 @@ gboolean load_dialog (TIFF *tif, const gchar *help_id, TiffSelectedPages *pages); -gint32 load_image (const gchar *filename, +gint32 load_image (GFile *file, TIFF *tif, TiffSelectedPages *pages, gboolean *resolution_loaded, diff --git a/plug-ins/file-tiff/file-tiff-save.c b/plug-ins/file-tiff/file-tiff-save.c index 920ab10bb7..0f39d047e5 100644 --- a/plug-ins/file-tiff/file-tiff-save.c +++ b/plug-ins/file-tiff/file-tiff-save.c @@ -255,7 +255,7 @@ save_paths (TIFF *tif, */ gboolean -save_image (const gchar *filename, +save_image (GFile *file, TiffSaveVals *tsvals, gint32 image, gint32 layer, @@ -312,7 +312,7 @@ save_image (const gchar *filename, rowsperstrip = tile_height; gimp_progress_init_printf (_("Exporting '%s'"), - gimp_filename_to_utf8 (filename)); + gimp_file_get_utf8_name (file)); drawable_type = gimp_drawable_type (layer); buffer = gimp_drawable_get_buffer (layer); @@ -512,14 +512,14 @@ save_image (const gchar *filename, } } - tif = tiff_open (filename, "w", error); + tif = tiff_open (file, "w", error); if (! tif) { if (! error) 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)); + gimp_file_get_utf8_name (file), g_strerror (errno)); goto out; } @@ -551,7 +551,7 @@ save_image (const gchar *filename, } TIFFSetField (tif, TIFFTAG_PHOTOMETRIC, photometric); - TIFFSetField (tif, TIFFTAG_DOCUMENTNAME, filename); + TIFFSetField (tif, TIFFTAG_DOCUMENTNAME, g_file_get_path (file)); TIFFSetField (tif, TIFFTAG_SAMPLESPERPIXEL, samplesperpixel); TIFFSetField (tif, TIFFTAG_ROWSPERSTRIP, rowsperstrip); /* TIFFSetField( tif, TIFFTAG_STRIPBYTECOUNTS, rows / rowsperstrip ); */ @@ -776,7 +776,7 @@ save_image (const gchar *filename, *p++ = *thumb_pixels++; /* r */ *p++ = *thumb_pixels++; /* g */ *p++ = *thumb_pixels++; /* b */ - *thumb_pixels++; + thumb_pixels++; } TIFFWriteScanline (tif, buf, y, 0); diff --git a/plug-ins/file-tiff/file-tiff-save.h b/plug-ins/file-tiff/file-tiff-save.h index e82a33a90d..032b370671 100644 --- a/plug-ins/file-tiff/file-tiff-save.h +++ b/plug-ins/file-tiff/file-tiff-save.h @@ -35,7 +35,7 @@ typedef struct } TiffSaveVals; -gboolean save_image (const gchar *filename, +gboolean save_image (GFile *file, TiffSaveVals *tsvals, gint32 image, gint32 drawable, diff --git a/plug-ins/file-tiff/file-tiff.c b/plug-ins/file-tiff/file-tiff.c index 0a9a1db374..cd88955ad3 100644 --- a/plug-ins/file-tiff/file-tiff.c +++ b/plug-ins/file-tiff/file-tiff.c @@ -207,10 +207,10 @@ run (const gchar *name, if (strcmp (name, LOAD_PROC) == 0) { - const gchar *filename = param[1].data.d_string; - TIFF *tif; + GFile *file = g_file_new_for_path (param[1].data.d_string); + TIFF *tif; - tif = tiff_open (filename, "r", &error); + tif = tiff_open (file, "r", &error); if (tif) { @@ -226,7 +226,7 @@ run (const gchar *name, { g_set_error (&error, G_FILE_ERROR, G_FILE_ERROR_FAILED, _("TIFF '%s' does not contain any directories"), - gimp_filename_to_utf8 (filename)); + gimp_file_get_utf8_name (file)); status = GIMP_PDB_EXECUTION_ERROR; } @@ -262,13 +262,13 @@ run (const gchar *name, if (run_it) { - gint32 image; - gboolean resolution_loaded = FALSE; + gint32 image; + gboolean resolution_loaded = FALSE; gimp_set_data (LOAD_PROC, &pages.target, sizeof (pages.target)); - image = load_image (param[1].data.d_string, tif, &pages, + image = load_image (file, tif, &pages, &resolution_loaded, &error); @@ -276,11 +276,8 @@ run (const gchar *name, if (image > 0) { - GFile *file; GimpMetadata *metadata; - file = g_file_new_for_path (param[1].data.d_string); - metadata = gimp_image_metadata_load_prepare (image, "image/tiff", file, NULL); @@ -299,8 +296,6 @@ run (const gchar *name, g_object_unref (metadata); } - g_object_unref (file); - *nreturn_vals = 2; values[1].type = GIMP_PDB_IMAGE; values[1].data.d_image = image; @@ -309,6 +304,7 @@ run (const gchar *name, { status = GIMP_PDB_EXECUTION_ERROR; } + } else { @@ -322,6 +318,8 @@ run (const gchar *name, { status = GIMP_PDB_EXECUTION_ERROR; } + + g_object_unref (file); } else if ((strcmp (name, SAVE_PROC) == 0) || (strcmp (name, SAVE2_PROC) == 0)) @@ -455,15 +453,17 @@ run (const gchar *name, if (status == GIMP_PDB_SUCCESS) { - gint saved_bpp; + GFile *file; + gint saved_bpp; - if (save_image (param[3].data.d_string, &tsvals, + file = g_file_new_for_path (param[3].data.d_string); + + if (save_image (file, &tsvals, image, drawable, orig_image, image_comment, &saved_bpp, &error)) { if (metadata) { - GFile *file; /* See bug 758909: clear TIFFTAG_MIN/MAXSAMPLEVALUE because * exiv2 saves them with wrong type and the original values @@ -492,12 +492,10 @@ run (const gchar *name, /* never save metadata thumbnails for TIFF, see bug #729952 */ metadata_flags &= ~GIMP_METADATA_SAVE_THUMBNAIL; - file = g_file_new_for_path (param[3].data.d_string); gimp_image_metadata_save_finish (image, "image/tiff", metadata, metadata_flags, file, NULL); - g_object_unref (file); } /* Store mvals data */ @@ -507,6 +505,8 @@ run (const gchar *name, { status = GIMP_PDB_EXECUTION_ERROR; } + + g_object_unref (file); } if (export == GIMP_EXPORT_EXPORT)