[gimp] pdb, app, libgimp, plug-ins: replace most PDB filenames/URIs by GFile
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] pdb, app, libgimp, plug-ins: replace most PDB filenames/URIs by GFile
- Date: Wed, 11 Sep 2019 19:53:40 +0000 (UTC)
commit 6bca8c4f8970d976c731463f938ae39df3c3fd4c
Author: Michael Natterer <mitch gimp org>
Date: Wed Sep 11 21:48:34 2019 +0200
pdb, app, libgimp, plug-ins: replace most PDB filenames/URIs by GFile
and in an attack of madness, changes almost all file plug-in
code to use GFile instead of filenames, which means passing
the GFile down to the bottom and get its filename at the very
end where it's actually needed.
app/file-data/file-data-gbr.c | 16 +-
app/file-data/file-data-gex.c | 6 +-
app/file-data/file-data-gih.c | 18 +-
app/file-data/file-data-pat.c | 14 +-
app/file-data/file-data.c | 85 ++++----
app/file/file-open.c | 17 +-
app/file/file-save.c | 29 ++-
app/file/file-utils.c | 37 ++--
app/file/file-utils.h | 4 +-
app/pdb/file-cmds.c | 199 +++++++-----------
app/pdb/image-cmds.c | 298 +++++++++------------------
app/pdb/internal-procs.c | 2 +-
app/pdb/vectors-cmds.c | 37 ++--
app/plug-in/gimpplugin-proc.c | 15 +-
app/plug-in/gimppluginprocedure.c | 13 +-
app/xcf/xcf.c | 41 ++--
libgimp/gimpfile_pdb.c | 36 ++--
libgimp/gimpfile_pdb.h | 10 +-
libgimp/gimpimage_pdb.c | 158 +++++---------
libgimp/gimpimage_pdb.h | 13 +-
libgimp/gimploadprocedure.c | 21 +-
libgimp/gimpprocedure-params.h | 27 +++
libgimp/gimpsaveprocedure.c | 23 +--
libgimp/gimpthumbnailprocedure.c | 17 +-
libgimp/gimpvectors_pdb.c | 12 +-
libgimp/gimpvectors_pdb.h | 4 +-
pdb/app.pl | 9 +
pdb/groups/file.pdb | 141 +++++--------
pdb/groups/image.pdb | 156 ++++----------
pdb/groups/vectors.pdb | 17 +-
pdb/pdb.pl | 11 +
plug-ins/common/Makefile.am | 1 +
plug-ins/common/compose.c | 8 +-
plug-ins/common/decompose.c | 14 +-
plug-ins/common/file-cel.c | 60 +++---
plug-ins/common/file-compressor.c | 56 ++---
plug-ins/common/file-desktop-link.c | 2 +-
plug-ins/common/file-dicom.c | 73 ++++---
plug-ins/common/file-gegl.c | 27 ++-
plug-ins/common/file-gif-load.c | 38 ++--
plug-ins/common/file-heif.c | 2 +-
plug-ins/common/file-jp2-load.c | 46 +++--
plug-ins/common/file-pcx.c | 40 ++--
plug-ins/common/file-pdf-load.c | 47 +++--
plug-ins/common/file-pix.c | 4 +-
plug-ins/common/file-png.c | 47 +++--
plug-ins/common/file-pnm.c | 2 +-
plug-ins/common/file-ps.c | 165 +++++++++------
plug-ins/common/file-psp.c | 35 ++--
plug-ins/common/file-raw-data.c | 81 +++++---
plug-ins/common/file-sunras.c | 84 ++++----
plug-ins/common/file-svg.c | 95 ++++-----
plug-ins/common/file-tga.c | 65 +++---
plug-ins/common/file-wmf.c | 118 +++++------
plug-ins/common/file-xbm.c | 41 ++--
plug-ins/common/file-xmc.c | 87 ++++----
plug-ins/common/file-xpm.c | 42 ++--
plug-ins/common/file-xwd.c | 105 +++++-----
plug-ins/common/film.c | 10 +-
plug-ins/common/guillotine.c | 28 +--
plug-ins/common/mail.c | 5 +-
plug-ins/common/plugin-defs.pl | 2 +-
plug-ins/file-bmp/bmp-load.c | 57 ++---
plug-ins/file-bmp/bmp-load.h | 4 +-
plug-ins/file-bmp/bmp-save.c | 12 +-
plug-ins/file-bmp/bmp-save.h | 2 +-
plug-ins/file-bmp/bmp.c | 11 +-
plug-ins/file-dds/dds.c | 5 +-
plug-ins/file-dds/ddsplugin.h | 4 +-
plug-ins/file-dds/ddsread.c | 18 +-
plug-ins/file-dds/ddswrite.c | 16 +-
plug-ins/file-exr/file-exr.c | 26 +--
plug-ins/file-faxg3/faxg3.c | 23 ++-
plug-ins/file-fits/fits.c | 80 ++++---
plug-ins/file-fli/fli-gimp.c | 125 ++++++-----
plug-ins/file-ico/ico-load.c | 30 ++-
plug-ins/file-ico/ico-load.h | 4 +-
plug-ins/file-ico/ico-save.c | 30 +--
plug-ins/file-ico/ico-save.h | 2 +-
plug-ins/file-ico/ico.c | 22 +-
plug-ins/file-jpeg/jpeg-load.c | 15 +-
plug-ins/file-jpeg/jpeg-load.h | 2 +-
plug-ins/file-jpeg/jpeg-save.c | 38 ++--
plug-ins/file-jpeg/jpeg-save.h | 2 +-
plug-ins/file-jpeg/jpeg.c | 19 +-
plug-ins/file-psd/psd-load.c | 31 ++-
plug-ins/file-psd/psd-load.h | 2 +-
plug-ins/file-psd/psd-save.c | 24 ++-
plug-ins/file-psd/psd-save.h | 6 +-
plug-ins/file-psd/psd-thumb-load.c | 36 ++--
plug-ins/file-psd/psd-thumb-load.h | 8 +-
plug-ins/file-psd/psd.c | 9 +-
plug-ins/file-raw/file-darktable.c | 41 ++--
plug-ins/file-raw/file-rawtherapee.c | 37 ++--
plug-ins/file-sgi/sgi.c | 45 ++--
plug-ins/file-tiff/file-tiff-load.c | 6 +-
plug-ins/file-webp/file-webp-load.c | 22 +-
plug-ins/file-webp/file-webp-load.h | 2 +-
plug-ins/file-webp/file-webp-save.c | 42 ++--
plug-ins/file-webp/file-webp-save.h | 2 +-
plug-ins/file-webp/file-webp.c | 6 +-
plug-ins/screenshot/screenshot-freedesktop.c | 6 +-
plug-ins/screenshot/screenshot-gnome-shell.c | 5 +-
plug-ins/screenshot/screenshot-kwin.c | 5 +-
104 files changed, 1816 insertions(+), 1982 deletions(-)
---
diff --git a/app/file-data/file-data-gbr.c b/app/file-data/file-data-gbr.c
index 2a5d73df33..229fbac45b 100644
--- a/app/file-data/file-data-gbr.c
+++ b/app/file-data/file-data-gbr.c
@@ -66,15 +66,13 @@ file_gbr_load_invoker (GimpProcedure *procedure,
{
GimpValueArray *return_vals;
GimpImage *image = NULL;
- const gchar *uri;
GFile *file;
GInputStream *input;
GError *my_error = NULL;
gimp_set_busy (gimp);
- uri = g_value_get_string (gimp_value_array_index (args, 1));
- file = g_file_new_for_uri (uri);
+ file = g_value_get_object (gimp_value_array_index (args, 1));
input = G_INPUT_STREAM (g_file_read (file, NULL, &my_error));
@@ -97,8 +95,6 @@ file_gbr_load_invoker (GimpProcedure *procedure,
gimp_file_get_utf8_name (file));
}
- g_object_unref (file);
-
return_vals = gimp_procedure_get_return_values (procedure, image != NULL,
error ? *error : NULL);
@@ -122,7 +118,6 @@ file_gbr_save_invoker (GimpProcedure *procedure,
GimpImage *image;
GimpDrawable *drawable;
GimpBrush *brush;
- const gchar *uri;
const gchar *name;
GFile *file;
gint spacing;
@@ -132,11 +127,9 @@ file_gbr_save_invoker (GimpProcedure *procedure,
image = g_value_get_object (gimp_value_array_index (args, 1));
drawable = g_value_get_object (gimp_value_array_index (args, 2));
- uri = g_value_get_string (gimp_value_array_index (args, 3));
- spacing = g_value_get_int (gimp_value_array_index (args, 5));
- name = g_value_get_string (gimp_value_array_index (args, 6));
-
- file = g_file_new_for_uri (uri);
+ file = g_value_get_object (gimp_value_array_index (args, 3));
+ spacing = g_value_get_int (gimp_value_array_index (args, 4));
+ name = g_value_get_string (gimp_value_array_index (args, 5));
brush = file_gbr_image_to_brush (image, drawable, name, spacing);
@@ -145,7 +138,6 @@ file_gbr_save_invoker (GimpProcedure *procedure,
success = gimp_data_save (GIMP_DATA (brush), error);
g_object_unref (brush);
- g_object_unref (file);
return_vals = gimp_procedure_get_return_values (procedure, success,
error ? *error : NULL);
diff --git a/app/file-data/file-data-gex.c b/app/file-data/file-data-gex.c
index 9ac22fd9ad..6aafe3e7a9 100644
--- a/app/file-data/file-data-gex.c
+++ b/app/file-data/file-data-gex.c
@@ -499,7 +499,6 @@ file_gex_load_invoker (GimpProcedure *procedure,
GError **error)
{
GimpValueArray *return_vals;
- const gchar *uri;
GFile *file;
gchar *ext_dir = NULL;
AsApp *appdata = NULL;
@@ -507,8 +506,7 @@ file_gex_load_invoker (GimpProcedure *procedure,
gimp_set_busy (gimp);
- uri = g_value_get_string (gimp_value_array_index (args, 1));
- file = g_file_new_for_uri (uri);
+ file = g_value_get_object (gimp_value_array_index (args, 1));
success = file_gex_validate (file, &appdata, error);
if (success)
@@ -548,8 +546,6 @@ file_gex_load_invoker (GimpProcedure *procedure,
success = FALSE;
}
- g_object_unref (file);
-
return_vals = gimp_procedure_get_return_values (procedure, success,
error ? *error : NULL);
gimp_unset_busy (gimp);
diff --git a/app/file-data/file-data-gih.c b/app/file-data/file-data-gih.c
index 7a2c13a80c..94d44e539b 100644
--- a/app/file-data/file-data-gih.c
+++ b/app/file-data/file-data-gih.c
@@ -67,15 +67,13 @@ file_gih_load_invoker (GimpProcedure *procedure,
{
GimpValueArray *return_vals;
GimpImage *image = NULL;
- const gchar *uri;
GFile *file;
GInputStream *input;
GError *my_error = NULL;
gimp_set_busy (gimp);
- uri = g_value_get_string (gimp_value_array_index (args, 1));
- file = g_file_new_for_uri (uri);
+ file = g_value_get_object (gimp_value_array_index (args, 1));
input = G_INPUT_STREAM (g_file_read (file, NULL, &my_error));
@@ -102,8 +100,6 @@ file_gih_load_invoker (GimpProcedure *procedure,
gimp_file_get_utf8_name (file));
}
- g_object_unref (file);
-
return_vals = gimp_procedure_get_return_values (procedure, image != NULL,
error ? *error : NULL);
@@ -126,7 +122,6 @@ file_gih_save_invoker (GimpProcedure *procedure,
GimpValueArray *return_vals;
GimpImage *image;
GimpBrushPipe *pipe;
- const gchar *uri;
const gchar *name;
const gchar *params;
GFile *file;
@@ -136,12 +131,10 @@ file_gih_save_invoker (GimpProcedure *procedure,
gimp_set_busy (gimp);
image = g_value_get_object (gimp_value_array_index (args, 1));
- uri = g_value_get_string (gimp_value_array_index (args, 3));
- spacing = g_value_get_int (gimp_value_array_index (args, 5));
- name = g_value_get_string (gimp_value_array_index (args, 6));
- params = g_value_get_string (gimp_value_array_index (args, 7));
-
- file = g_file_new_for_uri (uri);
+ file = g_value_get_object (gimp_value_array_index (args, 3));
+ spacing = g_value_get_int (gimp_value_array_index (args, 4));
+ name = g_value_get_string (gimp_value_array_index (args, 5));
+ params = g_value_get_string (gimp_value_array_index (args, 6));
pipe = file_gih_image_to_pipe (image, name, spacing, params);
@@ -150,7 +143,6 @@ file_gih_save_invoker (GimpProcedure *procedure,
success = gimp_data_save (GIMP_DATA (pipe), error);
g_object_unref (pipe);
- g_object_unref (file);
return_vals = gimp_procedure_get_return_values (procedure, success,
error ? *error : NULL);
diff --git a/app/file-data/file-data-pat.c b/app/file-data/file-data-pat.c
index 4045602f89..baa314ffd4 100644
--- a/app/file-data/file-data-pat.c
+++ b/app/file-data/file-data-pat.c
@@ -63,15 +63,13 @@ file_pat_load_invoker (GimpProcedure *procedure,
{
GimpValueArray *return_vals;
GimpImage *image = NULL;
- const gchar *uri;
GFile *file;
GInputStream *input;
GError *my_error = NULL;
gimp_set_busy (gimp);
- uri = g_value_get_string (gimp_value_array_index (args, 1));
- file = g_file_new_for_uri (uri);
+ file = g_value_get_object (gimp_value_array_index (args, 1));
input = G_INPUT_STREAM (g_file_read (file, NULL, &my_error));
@@ -98,8 +96,6 @@ file_pat_load_invoker (GimpProcedure *procedure,
gimp_file_get_utf8_name (file));
}
- g_object_unref (file);
-
return_vals = gimp_procedure_get_return_values (procedure, image != NULL,
error ? *error : NULL);
@@ -123,7 +119,6 @@ file_pat_save_invoker (GimpProcedure *procedure,
GimpImage *image;
GimpDrawable *drawable;
GimpPattern *pattern;
- const gchar *uri;
const gchar *name;
GFile *file;
gboolean success;
@@ -132,10 +127,8 @@ file_pat_save_invoker (GimpProcedure *procedure,
image = g_value_get_object (gimp_value_array_index (args, 1));
drawable = g_value_get_object (gimp_value_array_index (args, 2));
- uri = g_value_get_string (gimp_value_array_index (args, 3));
- name = g_value_get_string (gimp_value_array_index (args, 5));
-
- file = g_file_new_for_uri (uri);
+ file = g_value_get_object (gimp_value_array_index (args, 3));
+ name = g_value_get_string (gimp_value_array_index (args, 4));
pattern = file_pat_image_to_pattern (image, drawable, name);
@@ -144,7 +137,6 @@ file_pat_save_invoker (GimpProcedure *procedure,
success = gimp_data_save (GIMP_DATA (pattern), error);
g_object_unref (pattern);
- g_object_unref (file);
return_vals = gimp_procedure_get_return_values (procedure, success,
error ? *error : NULL);
diff --git a/app/file-data/file-data.c b/app/file-data/file-data.c
index bfad944b89..16db30c732 100644
--- a/app/file-data/file-data.c
+++ b/app/file-data/file-data.c
@@ -89,13 +89,11 @@ file_data_init (Gimp *gimp)
GIMP_RUN_INTERACTIVE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
- gimp_param_spec_string ("uri",
- "URI",
- "The URI of the file "
- "to load",
- TRUE, FALSE, TRUE,
- NULL,
- GIMP_PARAM_READWRITE));
+ g_param_spec_object ("file",
+ "File",
+ "The file to load",
+ G_TYPE_FILE,
+ GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
gimp_param_spec_image ("image",
@@ -162,13 +160,11 @@ file_data_init (Gimp *gimp)
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
- gimp_param_spec_string ("uri",
- "URI",
- "The URI of the file "
- "to export",
- FALSE, FALSE, TRUE,
- NULL,
- GIMP_PARAM_READWRITE));
+ g_param_spec_object ("file",
+ "File",
+ "The file to export",
+ G_TYPE_FILE,
+ GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
g_param_spec_int ("spacing",
"spacing",
@@ -225,13 +221,11 @@ file_data_init (Gimp *gimp)
GIMP_RUN_INTERACTIVE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
- gimp_param_spec_string ("uri",
- "URI",
- "The URI of the file "
- "to load",
- TRUE, FALSE, TRUE,
- NULL,
- GIMP_PARAM_READWRITE));
+ g_param_spec_object ("file",
+ "File",
+ "The file to load",
+ G_TYPE_FILE,
+ GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
gimp_param_spec_image ("image",
@@ -298,13 +292,11 @@ file_data_init (Gimp *gimp)
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
- gimp_param_spec_string ("uri",
- "URI",
- "The URI of the file "
- "to export",
- FALSE, FALSE, TRUE,
- NULL,
- GIMP_PARAM_READWRITE));
+ g_param_spec_object ("file",
+ "File",
+ "The file to export",
+ G_TYPE_FILE,
+ GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
g_param_spec_int ("spacing",
"spacing",
@@ -368,13 +360,11 @@ file_data_init (Gimp *gimp)
GIMP_RUN_INTERACTIVE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
- gimp_param_spec_string ("uri",
- "URI",
- "The URI of the file "
- "to load",
- TRUE, FALSE, TRUE,
- NULL,
- GIMP_PARAM_READWRITE));
+ g_param_spec_object ("file",
+ "File",
+ "The file to load",
+ G_TYPE_FILE,
+ GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
gimp_param_spec_image ("image",
"Image",
@@ -440,14 +430,11 @@ file_data_init (Gimp *gimp)
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
- gimp_param_spec_string ("uri",
- "URI",
- "The URI of the file "
- "to export",
- FALSE, FALSE, TRUE,
- NULL,
- GIMP_PARAM_READWRITE));
-
+ g_param_spec_object ("file",
+ "File",
+ "The file to export",
+ G_TYPE_FILE,
+ GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_string ("name",
"name",
@@ -496,13 +483,11 @@ file_data_init (Gimp *gimp)
GIMP_RUN_INTERACTIVE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
- gimp_param_spec_string ("uri",
- "URI",
- "The URI of the file "
- "to load",
- TRUE, FALSE, TRUE,
- NULL,
- GIMP_PARAM_READWRITE));
+ g_param_spec_object ("file",
+ "File",
+ "The file to load",
+ G_TYPE_FILE,
+ GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
gimp_param_spec_string ("extension-id",
diff --git a/app/file/file-open.c b/app/file/file-open.c
index b41b090f57..86811673b0 100644
--- a/app/file/file-open.c
+++ b/app/file/file-open.c
@@ -79,9 +79,9 @@ file_open_image (Gimp *gimp,
GError **error)
{
GimpValueArray *return_vals;
+ GFile *orig_file;
GimpImage *image = NULL;
GFile *local_file = NULL;
- gchar *uri = NULL;
gboolean mounted = TRUE;
GError *my_error = NULL;
@@ -94,6 +94,8 @@ file_open_image (Gimp *gimp,
*status = GIMP_PDB_EXECUTION_ERROR;
+ orig_file = file;
+
/* FIXME enable these tests for remote files again, needs testing */
if (g_file_is_native (file) &&
g_file_query_exists (file, NULL))
@@ -199,15 +201,12 @@ file_open_image (Gimp *gimp,
return NULL;
}
- uri = g_file_get_uri (local_file);
+ file = local_file;
}
g_free (my_path);
}
- if (! uri)
- uri = g_file_get_uri (file);
-
if (progress)
g_object_add_weak_pointer (G_OBJECT (progress), (gpointer) &progress);
@@ -216,14 +215,12 @@ file_open_image (Gimp *gimp,
context, progress, error,
gimp_object_get_name (file_proc),
GIMP_TYPE_RUN_MODE, run_mode,
- G_TYPE_STRING, uri,
+ G_TYPE_FILE, file,
G_TYPE_NONE);
if (progress)
g_object_remove_weak_pointer (G_OBJECT (progress), (gpointer) &progress);
- g_free (uri);
-
*status = g_value_get_enum (gimp_value_array_index (return_vals, 0));
if (*status == GIMP_PDB_SUCCESS && ! file_proc->generic_file_proc)
@@ -232,7 +229,7 @@ file_open_image (Gimp *gimp,
if (local_file)
{
if (image)
- gimp_image_set_file (image, file);
+ gimp_image_set_file (image, orig_file);
g_file_delete (local_file, NULL, NULL);
g_object_unref (local_file);
@@ -278,7 +275,7 @@ file_open_image (Gimp *gimp,
if (file_open_file_proc_is_import (file_proc))
{
- file_import_image (image, context, file,
+ file_import_image (image, context, orig_file,
run_mode == GIMP_RUN_INTERACTIVE,
progress);
}
diff --git a/app/file/file-save.c b/app/file/file-save.c
index e6eb6b5a04..f02330ec0a 100644
--- a/app/file/file-save.c
+++ b/app/file/file-save.c
@@ -65,9 +65,9 @@ file_save (Gimp *gimp,
{
GimpDrawable *drawable;
GimpValueArray *return_vals;
+ GFile *orig_file;
GimpPDBStatusType status = GIMP_PDB_EXECUTION_ERROR;
GFile *local_file = NULL;
- gchar *uri = NULL;
gboolean mounted = TRUE;
GError *my_error = NULL;
@@ -83,9 +83,11 @@ file_save (Gimp *gimp,
g_return_val_if_fail (error == NULL || *error == NULL,
GIMP_PDB_CALLING_ERROR);
+ orig_file = file;
+
/* ref image and file, so they can't get deleted during save */
g_object_ref (image);
- g_object_ref (file);
+ g_object_ref (orig_file);
gimp_image_saving (image);
@@ -177,15 +179,12 @@ file_save (Gimp *gimp,
goto out;
}
- uri = g_file_get_uri (local_file);
+ file = local_file;
}
g_free (my_path);
}
- if (! uri)
- uri = g_file_get_uri (file);
-
return_vals =
gimp_pdb_execute_procedure_by_name (image->gimp->pdb,
gimp_get_user_context (gimp),
@@ -194,7 +193,7 @@ file_save (Gimp *gimp,
GIMP_TYPE_RUN_MODE, run_mode,
GIMP_TYPE_IMAGE, image,
GIMP_TYPE_DRAWABLE, drawable,
- G_TYPE_STRING, uri,
+ G_TYPE_FILE, file,
G_TYPE_NONE);
status = g_value_get_enum (gimp_value_array_index (return_vals, 0));
@@ -207,7 +206,7 @@ file_save (Gimp *gimp,
{
GError *my_error = NULL;
- if (! file_remote_upload_image_finish (gimp, file, local_file,
+ if (! file_remote_upload_image_finish (gimp, orig_file, local_file,
progress, &my_error))
{
status = GIMP_PDB_EXECUTION_ERROR;
@@ -230,7 +229,7 @@ file_save (Gimp *gimp,
if (change_saved_state)
{
- gimp_image_set_file (image, file);
+ gimp_image_set_file (image, orig_file);
gimp_image_set_save_proc (image, file_proc);
/* Forget the import source when we save. We interpret a
@@ -256,7 +255,7 @@ file_save (Gimp *gimp,
* happens implicitly when saving since the GimpObject name
* of a GimpImage is the last-save URI
*/
- gimp_image_set_exported_file (image, file);
+ gimp_image_set_exported_file (image, orig_file);
gimp_image_set_export_proc (image, file_proc);
/* An image can not be considered both exported and imported
@@ -269,13 +268,13 @@ file_save (Gimp *gimp,
}
if (export_backward || export_forward)
- gimp_image_exported (image, file);
+ gimp_image_exported (image, orig_file);
else
- gimp_image_saved (image, file);
+ gimp_image_saved (image, orig_file);
documents = GIMP_DOCUMENT_LIST (image->gimp->documents);
- imagefile = gimp_document_list_add_file (documents, file,
+ imagefile = gimp_document_list_add_file (documents, orig_file,
g_slist_nth_data (file_proc->mime_types_list, 0));
/* only save a thumbnail if we are saving as XCF, see bug #25272 */
@@ -298,10 +297,8 @@ file_save (Gimp *gimp,
gimp_image_flush (image);
out:
- g_object_unref (file);
+ g_object_unref (orig_file);
g_object_unref (image);
- g_free (uri);
-
return status;
}
diff --git a/app/file/file-utils.c b/app/file/file-utils.c
index 230c1efde7..d9d862eed4 100644
--- a/app/file/file-utils.c
+++ b/app/file/file-utils.c
@@ -168,27 +168,22 @@ file_utils_filename_to_file (Gimp *gimp,
}
GdkPixbuf *
-file_utils_load_thumbnail (const gchar *filename)
+file_utils_load_thumbnail (GFile *file)
{
GimpThumbnail *thumbnail = NULL;
GdkPixbuf *pixbuf = NULL;
gchar *uri;
- g_return_val_if_fail (filename != NULL, NULL);
+ g_return_val_if_fail (G_IS_FILE (file), NULL);
- uri = g_filename_to_uri (filename, NULL, NULL);
+ uri = g_file_get_uri (file);
- if (uri)
- {
- thumbnail = gimp_thumbnail_new ();
- gimp_thumbnail_set_uri (thumbnail, uri);
+ thumbnail = gimp_thumbnail_new ();
+ gimp_thumbnail_set_uri (thumbnail, uri);
- pixbuf = gimp_thumbnail_load_thumb (thumbnail,
- (GimpThumbSize) GIMP_THUMBNAIL_SIZE_NORMAL,
- NULL);
- }
-
- g_free (uri);
+ pixbuf = gimp_thumbnail_load_thumb (thumbnail,
+ (GimpThumbSize) GIMP_THUMBNAIL_SIZE_NORMAL,
+ NULL);
if (pixbuf)
{
@@ -215,21 +210,21 @@ file_utils_load_thumbnail (const gchar *filename)
}
gboolean
-file_utils_save_thumbnail (GimpImage *image,
- const gchar *filename)
+file_utils_save_thumbnail (GimpImage *image,
+ GFile *file)
{
- GFile *file;
+ GFile *image_file;
gboolean success = FALSE;
g_return_val_if_fail (GIMP_IS_IMAGE (image), FALSE);
- g_return_val_if_fail (filename != NULL, FALSE);
+ g_return_val_if_fail (G_IS_FILE (file), FALSE);
- file = gimp_image_get_file (image);
+ image_file = gimp_image_get_file (image);
- if (file)
+ if (image_file)
{
- gchar *image_uri = g_file_get_uri (file);
- gchar *uri = g_filename_to_uri (filename, NULL, NULL);
+ gchar *image_uri = g_file_get_uri (image_file);
+ gchar *uri = g_file_get_uri (file);
if (uri && image_uri && ! strcmp (uri, image_uri))
{
diff --git a/app/file/file-utils.h b/app/file/file-utils.h
index 02a30cc2b5..b491e4737c 100644
--- a/app/file/file-utils.h
+++ b/app/file/file-utils.h
@@ -25,9 +25,9 @@ GFile * file_utils_filename_to_file (Gimp *gimp,
const gchar *filename,
GError **error);
-GdkPixbuf * file_utils_load_thumbnail (const gchar *filename);
+GdkPixbuf * file_utils_load_thumbnail (GFile *file);
gboolean file_utils_save_thumbnail (GimpImage *image,
- const gchar *filename);
+ GFile *file);
#endif /* __FILE_UTILS_H__ */
diff --git a/app/pdb/file-cmds.c b/app/pdb/file-cmds.c
index 442d9d9a0d..1a508b1af9 100644
--- a/app/pdb/file-cmds.c
+++ b/app/pdb/file-cmds.c
@@ -58,9 +58,7 @@ file_load_invoker (GimpProcedure *procedure,
GFile *file;
gint i;
- file = file_utils_filename_to_file (gimp,
- g_value_get_string (gimp_value_array_index (args, 1)),
- error);
+ file = g_value_get_object (gimp_value_array_index (args, 1));
if (! file)
return gimp_procedure_get_return_values (procedure, FALSE,
@@ -71,12 +69,8 @@ file_load_invoker (GimpProcedure *procedure,
file, error);
if (! file_proc)
- {
- g_object_unref (file);
-
- return gimp_procedure_get_return_values (procedure, FALSE,
- error ? *error : NULL);
- }
+ return gimp_procedure_get_return_values (procedure, FALSE,
+ error ? *error : NULL);
proc = GIMP_PROCEDURE (file_proc);
@@ -112,8 +106,6 @@ file_load_invoker (GimpProcedure *procedure,
}
}
- g_object_unref (file);
-
return return_vals;
}
@@ -129,35 +121,26 @@ file_load_layer_invoker (GimpProcedure *procedure,
GimpValueArray *return_vals;
gint run_mode;
GimpImage *image;
- const gchar *filename;
+ GFile *file;
GimpLayer *layer = NULL;
run_mode = g_value_get_enum (gimp_value_array_index (args, 0));
image = g_value_get_object (gimp_value_array_index (args, 1));
- filename = g_value_get_string (gimp_value_array_index (args, 2));
+ file = g_value_get_object (gimp_value_array_index (args, 2));
if (success)
{
- GFile *file = file_utils_filename_to_file (gimp, filename, error);
-
- if (file)
- {
- GList *layers;
- GimpPDBStatusType status;
-
- layers = file_open_layers (gimp, context, progress,
- image, FALSE,
- file, run_mode, NULL, &status, error);
+ GList *layers;
+ GimpPDBStatusType status;
- g_object_unref (file);
+ layers = file_open_layers (gimp, context, progress,
+ image, FALSE,
+ file, run_mode, NULL, &status, error);
- if (layers)
- {
- layer = layers->data;
- g_list_free (layers);
- }
- else
- success = FALSE;
+ if (layers)
+ {
+ layer = layers->data;
+ g_list_free (layers);
}
else
success = FALSE;
@@ -184,49 +167,40 @@ file_load_layers_invoker (GimpProcedure *procedure,
GimpValueArray *return_vals;
gint run_mode;
GimpImage *image;
- const gchar *filename;
+ GFile *file;
gint num_layers = 0;
GimpLayer **layers = NULL;
run_mode = g_value_get_enum (gimp_value_array_index (args, 0));
image = g_value_get_object (gimp_value_array_index (args, 1));
- filename = g_value_get_string (gimp_value_array_index (args, 2));
+ file = g_value_get_object (gimp_value_array_index (args, 2));
if (success)
{
- GFile *file = file_utils_filename_to_file (gimp, filename, error);
+ GList *layer_list;
+ GimpPDBStatusType status;
- if (file)
+ layer_list = file_open_layers (gimp, context, progress,
+ image, FALSE,
+ file, run_mode, NULL, &status, error);
+
+ if (layers)
{
- GList *layer_list;
- GimpPDBStatusType status;
+ GList *list;
+ gint i;
- layer_list = file_open_layers (gimp, context, progress,
- image, FALSE,
- file, run_mode, NULL, &status, error);
+ num_layers = g_list_length (layer_list);
- g_object_unref (file);
+ layers = g_new (GimpLayer *, num_layers);
- if (layers)
+ for (i = 0, list = layer_list;
+ i < num_layers;
+ i++, list = g_list_next (list))
{
- GList *list;
- gint i;
-
- num_layers = g_list_length (layer_list);
-
- layers = g_new (GimpLayer *, num_layers);
-
- for (i = 0, list = layer_list;
- i < num_layers;
- i++, list = g_list_next (list))
- {
- layers[i] = g_object_ref (list->data);
- }
-
- g_list_free (layer_list);
+ layers[i] = g_object_ref (list->data);
}
- else
- success = FALSE;
+
+ g_list_free (layer_list);
}
else
success = FALSE;
@@ -255,17 +229,11 @@ file_save_invoker (GimpProcedure *procedure,
GimpValueArray *new_args;
GimpValueArray *return_vals;
GimpPlugInProcedure *file_proc;
- GimpProcedure *proc;
GFile *file;
+ GimpProcedure *proc;
gint i;
- file = file_utils_filename_to_file (gimp,
- g_value_get_string (gimp_value_array_index (args, 3)),
- error);
-
- if (! file)
- return gimp_procedure_get_return_values (procedure, FALSE,
- error ? *error : NULL);
+ file = g_value_get_object (gimp_value_array_index (args, 3));
file_proc = gimp_plug_in_manager_file_procedure_find (gimp->plug_in_manager,
GIMP_FILE_PROCEDURE_GROUP_SAVE,
@@ -277,12 +245,8 @@ file_save_invoker (GimpProcedure *procedure,
file, error);
if (! file_proc)
- {
- g_object_unref (file);
-
- return gimp_procedure_get_return_values (procedure, FALSE,
- error ? *error : NULL);
- }
+ return gimp_procedure_get_return_values (procedure, FALSE,
+ error ? *error : NULL);
proc = GIMP_PROCEDURE (file_proc);
@@ -294,9 +258,8 @@ file_save_invoker (GimpProcedure *procedure,
gimp_value_array_index (new_args, 1));
g_value_transform (gimp_value_array_index (args, 2),
gimp_value_array_index (new_args, 2));
-
- g_value_take_string (gimp_value_array_index (new_args, 3),
- g_file_get_uri (file));
+ g_value_transform (gimp_value_array_index (args, 3),
+ gimp_value_array_index (new_args, 3));
for (i = 4; i < proc->num_args; i++)
if (G_IS_PARAM_SPEC_STRING (proc->args[i]))
@@ -310,8 +273,6 @@ file_save_invoker (GimpProcedure *procedure,
gimp_value_array_unref (new_args);
- g_object_unref (file);
-
return return_vals;
}
@@ -325,17 +286,17 @@ file_load_thumbnail_invoker (GimpProcedure *procedure,
{
gboolean success = TRUE;
GimpValueArray *return_vals;
- const gchar *filename;
+ GFile *file;
gint width = 0;
gint height = 0;
gint thumb_data_count = 0;
guint8 *thumb_data = NULL;
- filename = g_value_get_string (gimp_value_array_index (args, 0));
+ file = g_value_get_object (gimp_value_array_index (args, 0));
if (success)
{
- GdkPixbuf *pixbuf = file_utils_load_thumbnail (filename);
+ GdkPixbuf *pixbuf = file_utils_load_thumbnail (file);
if (pixbuf)
{
@@ -375,14 +336,14 @@ file_save_thumbnail_invoker (GimpProcedure *procedure,
{
gboolean success = TRUE;
GimpImage *image;
- const gchar *filename;
+ GFile *file;
image = g_value_get_object (gimp_value_array_index (args, 0));
- filename = g_value_get_string (gimp_value_array_index (args, 1));
+ file = g_value_get_object (gimp_value_array_index (args, 1));
if (success)
{
- success = file_utils_save_thumbnail (image, filename);
+ success = file_utils_save_thumbnail (image, file);
}
return gimp_procedure_get_return_values (procedure, success,
@@ -418,12 +379,11 @@ register_file_procs (GimpPDB *pdb)
gimp_param_spec_enum_exclude_value (GIMP_PARAM_SPEC_ENUM (procedure->args[0]),
GIMP_RUN_WITH_LAST_VALS);
gimp_procedure_add_argument (procedure,
- gimp_param_spec_string ("filename",
- "filename",
- "The name of the file to load",
- TRUE, FALSE, FALSE,
- NULL,
- GIMP_PARAM_READWRITE));
+ g_param_spec_object ("file",
+ "file",
+ "The file to load",
+ G_TYPE_FILE,
+ GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
gimp_param_spec_image ("image",
"image",
@@ -463,12 +423,11 @@ register_file_procs (GimpPDB *pdb)
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
- gimp_param_spec_string ("filename",
- "filename",
- "The name of the file to load",
- TRUE, FALSE, FALSE,
- NULL,
- GIMP_PARAM_READWRITE));
+ g_param_spec_object ("file",
+ "file",
+ "The file to load",
+ G_TYPE_FILE,
+ GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
gimp_param_spec_layer ("layer",
"layer",
@@ -508,12 +467,11 @@ register_file_procs (GimpPDB *pdb)
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
- gimp_param_spec_string ("filename",
- "filename",
- "The name of the file to load",
- TRUE, FALSE, FALSE,
- NULL,
- GIMP_PARAM_READWRITE));
+ g_param_spec_object ("file",
+ "file",
+ "The file to load",
+ G_TYPE_FILE,
+ GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
g_param_spec_int ("num-layers",
"num layers",
@@ -563,12 +521,11 @@ register_file_procs (GimpPDB *pdb)
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
- gimp_param_spec_string ("filename",
- "filename",
- "The name of the file to save the image in",
- TRUE, FALSE, FALSE,
- NULL,
- GIMP_PARAM_READWRITE));
+ g_param_spec_object ("file",
+ "file",
+ "The file to save the image in",
+ G_TYPE_FILE,
+ GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
@@ -580,19 +537,18 @@ register_file_procs (GimpPDB *pdb)
"gimp-file-load-thumbnail");
gimp_procedure_set_static_help (procedure,
"Loads the thumbnail for a file.",
- "This procedure tries to load a thumbnail that belongs to the file with
the given filename. This name is a full pathname. The returned data is an array of colordepth 3 (RGB),
regardless of the image type. Width and height of the thumbnail are also returned. Don't use this function if
you need a thumbnail of an already opened image, use 'gimp-image-thumbnail' instead.",
+ "This procedure tries to load a thumbnail that belongs to the file with
the given file. This name is a full pathname. The returned data is an array of colordepth 3 (RGB), regardless
of the image type. Width and height of the thumbnail are also returned. Don't use this function if you need a
thumbnail of an already opened image, use 'gimp-image-thumbnail' instead.",
NULL);
gimp_procedure_set_static_attribution (procedure,
"Adam D. Moss, Sven Neumann",
"Adam D. Moss, Sven Neumann",
"1999-2003");
gimp_procedure_add_argument (procedure,
- gimp_param_spec_string ("filename",
- "filename",
- "The name of the file that owns the thumbnail to
load",
- TRUE, FALSE, FALSE,
- NULL,
- GIMP_PARAM_READWRITE));
+ g_param_spec_object ("file",
+ "file",
+ "The file that owns the thumbnail to load",
+ G_TYPE_FILE,
+ GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
g_param_spec_int ("width",
"width",
@@ -627,7 +583,7 @@ register_file_procs (GimpPDB *pdb)
"gimp-file-save-thumbnail");
gimp_procedure_set_static_help (procedure,
"Saves a thumbnail for the given image",
- "This procedure saves a thumbnail for the given image according to the
Free Desktop Thumbnail Managing Standard. The thumbnail is saved so that it belongs to the file with the
given filename. This means you have to save the image under this name first, otherwise this procedure will
fail. This procedure may become useful if you want to explicitly save a thumbnail with a file.",
+ "This procedure saves a thumbnail for the given image according to the
Free Desktop Thumbnail Managing Standard. The thumbnail is saved so that it belongs to the file with the
given filen. This means you have to save the image under this name first, otherwise this procedure will fail.
This procedure may become useful if you want to explicitly save a thumbnail with a file.",
NULL);
gimp_procedure_set_static_attribution (procedure,
"Josh MacDonald",
@@ -640,12 +596,11 @@ register_file_procs (GimpPDB *pdb)
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
- gimp_param_spec_string ("filename",
- "filename",
- "The name of the file the thumbnail belongs to",
- TRUE, FALSE, FALSE,
- NULL,
- GIMP_PARAM_READWRITE));
+ g_param_spec_object ("file",
+ "file",
+ "The file the thumbnail belongs to",
+ G_TYPE_FILE,
+ GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
}
diff --git a/app/pdb/image-cmds.c b/app/pdb/image-cmds.c
index 7b2da4eae6..2ff32add9e 100644
--- a/app/pdb/image-cmds.c
+++ b/app/pdb/image-cmds.c
@@ -2090,82 +2090,52 @@ image_set_component_visible_invoker (GimpProcedure *procedure,
}
static GimpValueArray *
-image_get_filename_invoker (GimpProcedure *procedure,
- Gimp *gimp,
- GimpContext *context,
- GimpProgress *progress,
- const GimpValueArray *args,
- GError **error)
+image_get_file_invoker (GimpProcedure *procedure,
+ Gimp *gimp,
+ GimpContext *context,
+ GimpProgress *progress,
+ const GimpValueArray *args,
+ GError **error)
{
gboolean success = TRUE;
GimpValueArray *return_vals;
GimpImage *image;
- gchar *filename = NULL;
+ GFile *file = NULL;
image = g_value_get_object (gimp_value_array_index (args, 0));
if (success)
{
- GFile *file = gimp_image_get_any_file (image);
- if (file)
- filename = g_file_get_path (file);
+ file = gimp_image_get_any_file (image);
}
return_vals = gimp_procedure_get_return_values (procedure, success,
error ? *error : NULL);
if (success)
- g_value_take_string (gimp_value_array_index (return_vals, 1), filename);
+ g_value_set_object (gimp_value_array_index (return_vals, 1), file);
return return_vals;
}
static GimpValueArray *
-image_set_filename_invoker (GimpProcedure *procedure,
- Gimp *gimp,
- GimpContext *context,
- GimpProgress *progress,
- const GimpValueArray *args,
- GError **error)
+image_set_file_invoker (GimpProcedure *procedure,
+ Gimp *gimp,
+ GimpContext *context,
+ GimpProgress *progress,
+ const GimpValueArray *args,
+ GError **error)
{
gboolean success = TRUE;
GimpImage *image;
- const gchar *filename;
+ GFile *file;
image = g_value_get_object (gimp_value_array_index (args, 0));
- filename = g_value_get_string (gimp_value_array_index (args, 1));
+ file = g_value_get_object (gimp_value_array_index (args, 1));
if (success)
{
- /* verify that the filename can be converted to UTF-8 and back */
- gchar *utf8 = g_filename_to_utf8 (filename, -1, NULL, NULL, error);
-
- if (utf8)
- {
- gchar *tmp = g_filename_from_utf8 (utf8, -1, NULL, NULL, error);
-
- if (tmp)
- g_free (tmp);
- else
- success = FALSE;
-
- g_free (utf8);
- }
- else
- success = FALSE;
-
- if (success)
- {
- GFile *file = NULL;
-
- if (filename && strlen (filename))
- file = file_utils_filename_to_file (image->gimp, filename, NULL);
-
- gimp_image_set_file (image, file);
-
- if (file)
- g_object_unref (file);
- }
+ gimp_image_set_file (image, file);
}
return gimp_procedure_get_return_values (procedure, success,
@@ -2173,125 +2143,88 @@ image_set_filename_invoker (GimpProcedure *procedure,
}
static GimpValueArray *
-image_get_uri_invoker (GimpProcedure *procedure,
- Gimp *gimp,
- GimpContext *context,
- GimpProgress *progress,
- const GimpValueArray *args,
- GError **error)
-{
- gboolean success = TRUE;
- GimpValueArray *return_vals;
- GimpImage *image;
- gchar *uri = NULL;
-
- image = g_value_get_object (gimp_value_array_index (args, 0));
-
- if (success)
- {
- GFile *file = gimp_image_get_any_file (image);
- if (file)
- uri = g_file_get_uri (file);
- }
-
- return_vals = gimp_procedure_get_return_values (procedure, success,
- error ? *error : NULL);
-
- if (success)
- g_value_take_string (gimp_value_array_index (return_vals, 1), uri);
-
- return return_vals;
-}
-
-static GimpValueArray *
-image_get_xcf_uri_invoker (GimpProcedure *procedure,
- Gimp *gimp,
- GimpContext *context,
- GimpProgress *progress,
- const GimpValueArray *args,
- GError **error)
+image_get_xcf_file_invoker (GimpProcedure *procedure,
+ Gimp *gimp,
+ GimpContext *context,
+ GimpProgress *progress,
+ const GimpValueArray *args,
+ GError **error)
{
gboolean success = TRUE;
GimpValueArray *return_vals;
GimpImage *image;
- gchar *uri = NULL;
+ GFile *file = NULL;
image = g_value_get_object (gimp_value_array_index (args, 0));
if (success)
{
- GFile *file = gimp_image_get_file (image);
- if (file)
- uri = g_file_get_uri (file);
+ file = gimp_image_get_file (image);
}
return_vals = gimp_procedure_get_return_values (procedure, success,
error ? *error : NULL);
if (success)
- g_value_take_string (gimp_value_array_index (return_vals, 1), uri);
+ g_value_set_object (gimp_value_array_index (return_vals, 1), file);
return return_vals;
}
static GimpValueArray *
-image_get_imported_uri_invoker (GimpProcedure *procedure,
- Gimp *gimp,
- GimpContext *context,
- GimpProgress *progress,
- const GimpValueArray *args,
- GError **error)
+image_get_imported_file_invoker (GimpProcedure *procedure,
+ Gimp *gimp,
+ GimpContext *context,
+ GimpProgress *progress,
+ const GimpValueArray *args,
+ GError **error)
{
gboolean success = TRUE;
GimpValueArray *return_vals;
GimpImage *image;
- gchar *uri = NULL;
+ GFile *file = NULL;
image = g_value_get_object (gimp_value_array_index (args, 0));
if (success)
{
- GFile *file = gimp_image_get_imported_file (image);
- if (file)
- uri = g_file_get_uri (file);
+ file = gimp_image_get_imported_file (image);
}
return_vals = gimp_procedure_get_return_values (procedure, success,
error ? *error : NULL);
if (success)
- g_value_take_string (gimp_value_array_index (return_vals, 1), uri);
+ g_value_set_object (gimp_value_array_index (return_vals, 1), file);
return return_vals;
}
static GimpValueArray *
-image_get_exported_uri_invoker (GimpProcedure *procedure,
- Gimp *gimp,
- GimpContext *context,
- GimpProgress *progress,
- const GimpValueArray *args,
- GError **error)
+image_get_exported_file_invoker (GimpProcedure *procedure,
+ Gimp *gimp,
+ GimpContext *context,
+ GimpProgress *progress,
+ const GimpValueArray *args,
+ GError **error)
{
gboolean success = TRUE;
GimpValueArray *return_vals;
GimpImage *image;
- gchar *uri = NULL;
+ GFile *file = NULL;
image = g_value_get_object (gimp_value_array_index (args, 0));
if (success)
{
- GFile *file = gimp_image_get_exported_file (image);
- if (file)
- uri = g_file_get_uri (file);
+ file = gimp_image_get_exported_file (image);
}
return_vals = gimp_procedure_get_return_values (procedure, success,
error ? *error : NULL);
if (success)
- g_value_take_string (gimp_value_array_index (return_vals, 1), uri);
+ g_value_set_object (gimp_value_array_index (return_vals, 1), file);
return return_vals;
}
@@ -4776,19 +4709,19 @@ register_image_procs (GimpPDB *pdb)
g_object_unref (procedure);
/*
- * gimp-image-get-filename
+ * gimp-image-get-file
*/
- procedure = gimp_procedure_new (image_get_filename_invoker);
+ procedure = gimp_procedure_new (image_get_file_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
- "gimp-image-get-filename");
+ "gimp-image-get-file");
gimp_procedure_set_static_help (procedure,
- "Returns the specified image's filename.",
- "This procedure returns the specified image's filename in the filesystem
encoding. The image has a filename only if it was loaded or imported from a file or has since been saved or
exported. Otherwise, this function returns %NULL. See also 'gimp-image-get-uri'.",
+ "Returns the file for the specified image.",
+ "This procedure returns the file associated with the specified image. The
image has a file only if it was loaded or imported from a file or has since been saved or exported.
Otherwise, this function returns %NULL. See also gimp-image-get-imported-file to get the current file if it
was imported from a non-GIMP file format and not yet saved, or gimp-image-get-exported-file if the image has
been exported to a non-GIMP file format.",
NULL);
gimp_procedure_set_static_attribution (procedure,
- "Spencer Kimball & Peter Mattis",
- "Spencer Kimball & Peter Mattis",
- "1995-1996");
+ "Sven Neumann <sven gimp org>",
+ "Sven Neumann",
+ "2009");
gimp_procedure_add_argument (procedure,
gimp_param_spec_image ("image",
"image",
@@ -4796,24 +4729,23 @@ register_image_procs (GimpPDB *pdb)
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
- gimp_param_spec_string ("filename",
- "filename",
- "The filename.",
- FALSE, FALSE, FALSE,
- NULL,
- GIMP_PARAM_READWRITE));
+ g_param_spec_object ("file",
+ "file",
+ "The file.",
+ G_TYPE_FILE,
+ GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
- * gimp-image-set-filename
+ * gimp-image-set-file
*/
- procedure = gimp_procedure_new (image_set_filename_invoker);
+ procedure = gimp_procedure_new (image_set_file_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
- "gimp-image-set-filename");
+ "gimp-image-set-file");
gimp_procedure_set_static_help (procedure,
- "Sets the specified image's filename.",
- "This procedure sets the specified image's filename. The filename should
be in the filesystem encoding.",
+ "Sets the specified image's file.",
+ "This procedure sets the specified image's file.",
NULL);
gimp_procedure_set_static_attribution (procedure,
"Spencer Kimball & Peter Mattis",
@@ -4826,54 +4758,23 @@ register_image_procs (GimpPDB *pdb)
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
- gimp_param_spec_string ("filename",
- "filename",
- "The new image filename",
- TRUE, FALSE, FALSE,
- NULL,
- GIMP_PARAM_READWRITE));
- gimp_pdb_register_procedure (pdb, procedure);
- g_object_unref (procedure);
-
- /*
- * gimp-image-get-uri
- */
- procedure = gimp_procedure_new (image_get_uri_invoker);
- gimp_object_set_static_name (GIMP_OBJECT (procedure),
- "gimp-image-get-uri");
- gimp_procedure_set_static_help (procedure,
- "Returns the URI for the specified image.",
- "This procedure returns the URI associated with the specified image. The
image has an URI only if it was loaded or imported from a file or has since been saved or exported.
Otherwise, this function returns %NULL. See also gimp-image-get-imported-uri to get the URI of the current
file if it was imported from a non-GIMP file format and not yet saved, or gimp-image-get-exported-uri if the
image has been exported to a non-GIMP file format.",
- NULL);
- gimp_procedure_set_static_attribution (procedure,
- "Sven Neumann <sven gimp org>",
- "Sven Neumann",
- "2009");
- gimp_procedure_add_argument (procedure,
- gimp_param_spec_image ("image",
- "image",
- "The image",
- FALSE,
- GIMP_PARAM_READWRITE));
- gimp_procedure_add_return_value (procedure,
- gimp_param_spec_string ("uri",
- "uri",
- "The URI.",
- FALSE, FALSE, FALSE,
- NULL,
- GIMP_PARAM_READWRITE));
+ g_param_spec_object ("file",
+ "file",
+ "The new image file",
+ G_TYPE_FILE,
+ GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
- * gimp-image-get-xcf-uri
+ * gimp-image-get-xcf-file
*/
- procedure = gimp_procedure_new (image_get_xcf_uri_invoker);
+ procedure = gimp_procedure_new (image_get_xcf_file_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
- "gimp-image-get-xcf-uri");
+ "gimp-image-get-xcf-file");
gimp_procedure_set_static_help (procedure,
- "Returns the XCF URI for the specified image.",
- "This procedure returns the XCF URI associated with the image. If there is
no such URI, this procedure returns %NULL.",
+ "Returns the XCF file for the specified image.",
+ "This procedure returns the XCF file associated with the image. If there
is no such file, this procedure returns %NULL.",
NULL);
gimp_procedure_set_static_attribution (procedure,
"Eric Grivel <gimp lumenssolutions com>",
@@ -4886,24 +4787,23 @@ register_image_procs (GimpPDB *pdb)
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
- gimp_param_spec_string ("uri",
- "uri",
- "The imported URI.",
- FALSE, FALSE, FALSE,
- NULL,
- GIMP_PARAM_READWRITE));
+ g_param_spec_object ("file",
+ "file",
+ "The imported XCF file.",
+ G_TYPE_FILE,
+ GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
- * gimp-image-get-imported-uri
+ * gimp-image-get-imported-file
*/
- procedure = gimp_procedure_new (image_get_imported_uri_invoker);
+ procedure = gimp_procedure_new (image_get_imported_file_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
- "gimp-image-get-imported-uri");
+ "gimp-image-get-imported-file");
gimp_procedure_set_static_help (procedure,
- "Returns the imported URI for the specified image.",
- "This procedure returns the URI associated with the specified image if the
image was imported from a non-native Gimp format. If the image was not imported, or has since been saved in
the native Gimp format, this procedure returns %NULL.",
+ "Returns the imported file for the specified image.",
+ "This procedure returns the file associated with the specified image if
the image was imported from a non-native Gimp format. If the image was not imported, or has since been saved
in the native Gimp format, this procedure returns %NULL.",
NULL);
gimp_procedure_set_static_attribution (procedure,
"Eric Grivel <gimp lumenssolutions com>",
@@ -4916,24 +4816,23 @@ register_image_procs (GimpPDB *pdb)
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
- gimp_param_spec_string ("uri",
- "uri",
- "The imported URI.",
- FALSE, FALSE, FALSE,
- NULL,
- GIMP_PARAM_READWRITE));
+ g_param_spec_object ("file",
+ "file",
+ "The imported file.",
+ G_TYPE_FILE,
+ GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
- * gimp-image-get-exported-uri
+ * gimp-image-get-exported-file
*/
- procedure = gimp_procedure_new (image_get_exported_uri_invoker);
+ procedure = gimp_procedure_new (image_get_exported_file_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
- "gimp-image-get-exported-uri");
+ "gimp-image-get-exported-file");
gimp_procedure_set_static_help (procedure,
- "Returns the exported URI for the specified image.",
- "This procedure returns the URI associated with the specified image if the
image was exported a non-native GIMP format. If the image was not exported, this procedure returns %NULL.",
+ "Returns the exported file for the specified image.",
+ "This procedure returns the file associated with the specified image if
the image was exported a non-native GIMP format. If the image was not exported, this procedure returns
%NULL.",
NULL);
gimp_procedure_set_static_attribution (procedure,
"Eric Grivel <gimp lumenssolutions com>",
@@ -4946,12 +4845,11 @@ register_image_procs (GimpPDB *pdb)
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
- gimp_param_spec_string ("uri",
- "uri",
- "The exported URI.",
- FALSE, FALSE, FALSE,
- NULL,
- GIMP_PARAM_READWRITE));
+ g_param_spec_object ("file",
+ "file",
+ "The exported file.",
+ G_TYPE_FILE,
+ GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
diff --git a/app/pdb/internal-procs.c b/app/pdb/internal-procs.c
index 62670ef47d..5290afec05 100644
--- a/app/pdb/internal-procs.c
+++ b/app/pdb/internal-procs.c
@@ -28,7 +28,7 @@
#include "internal-procs.h"
-/* 752 procedures registered total */
+/* 751 procedures registered total */
void
internal_procs_init (GimpPDB *pdb)
diff --git a/app/pdb/vectors-cmds.c b/app/pdb/vectors-cmds.c
index 7a8a8b66a8..87351b6012 100644
--- a/app/pdb/vectors-cmds.c
+++ b/app/pdb/vectors-cmds.c
@@ -1110,20 +1110,19 @@ vectors_import_from_file_invoker (GimpProcedure *procedure,
gboolean success = TRUE;
GimpValueArray *return_vals;
GimpImage *image;
- const gchar *filename;
+ GFile *file;
gboolean merge;
gboolean scale;
gint num_vectors = 0;
GimpVectors **vectors = NULL;
image = g_value_get_object (gimp_value_array_index (args, 0));
- filename = g_value_get_string (gimp_value_array_index (args, 1));
+ file = g_value_get_object (gimp_value_array_index (args, 1));
merge = g_value_get_boolean (gimp_value_array_index (args, 2));
scale = g_value_get_boolean (gimp_value_array_index (args, 3));
if (success)
{
- GFile *file = g_file_new_for_path (filename);
GList *vectors_list = NULL;
/* FIXME tree */
@@ -1131,8 +1130,6 @@ vectors_import_from_file_invoker (GimpProcedure *procedure,
merge, scale, NULL, -1,
&vectors_list, error);
- g_object_unref (file);
-
if (success)
{
num_vectors = g_list_length (vectors_list);
@@ -1246,20 +1243,16 @@ vectors_export_to_file_invoker (GimpProcedure *procedure,
{
gboolean success = TRUE;
GimpImage *image;
- const gchar *filename;
+ GFile *file;
GimpVectors *vectors;
image = g_value_get_object (gimp_value_array_index (args, 0));
- filename = g_value_get_string (gimp_value_array_index (args, 1));
+ file = g_value_get_object (gimp_value_array_index (args, 1));
vectors = g_value_get_object (gimp_value_array_index (args, 2));
if (success)
{
- GFile *file = g_file_new_for_path (filename);
-
success = gimp_vectors_export_file (image, vectors, file, error);
-
- g_object_unref (file);
}
return gimp_procedure_get_return_values (procedure, success,
@@ -2266,12 +2259,11 @@ register_vectors_procs (GimpPDB *pdb)
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
- gimp_param_spec_string ("filename",
- "filename",
- "The name of the SVG file to import.",
- TRUE, FALSE, TRUE,
- NULL,
- GIMP_PARAM_READWRITE));
+ g_param_spec_object ("file",
+ "file",
+ "The SVG file to import.",
+ G_TYPE_FILE,
+ GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
g_param_spec_boolean ("merge",
"merge",
@@ -2380,12 +2372,11 @@ register_vectors_procs (GimpPDB *pdb)
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
- gimp_param_spec_string ("filename",
- "filename",
- "The name of the SVG file to create.",
- TRUE, FALSE, TRUE,
- NULL,
- GIMP_PARAM_READWRITE));
+ g_param_spec_object ("file",
+ "file",
+ "The SVG file to create.",
+ G_TYPE_FILE,
+ GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_vectors ("vectors",
"vectors",
diff --git a/app/plug-in/gimpplugin-proc.c b/app/plug-in/gimpplugin-proc.c
index 49bd680ac6..e09250ec1c 100644
--- a/app/plug-in/gimpplugin-proc.c
+++ b/app/plug-in/gimpplugin-proc.c
@@ -258,6 +258,13 @@ GIMP_IS_PARAM_SPEC_RUN_MODE (GParamSpec *pspec)
pspec->value_type == GIMP_TYPE_RUN_MODE);
}
+static inline gboolean
+GIMP_IS_PARAM_SPEC_FILE (GParamSpec *pspec)
+{
+ return (G_IS_PARAM_SPEC_OBJECT (pspec) &&
+ pspec->value_type == G_TYPE_FILE);
+}
+
gboolean
gimp_plug_in_set_file_proc_load_handler (GimpPlugIn *plug_in,
const gchar *proc_name,
@@ -294,7 +301,7 @@ gimp_plug_in_set_file_proc_load_handler (GimpPlugIn *plug_in,
if (((procedure->num_args < 2) ||
(procedure->num_values < 1) ||
! GIMP_IS_PARAM_SPEC_RUN_MODE (procedure->args[0]) ||
- ! G_IS_PARAM_SPEC_STRING (procedure->args[1]) ||
+ ! GIMP_IS_PARAM_SPEC_FILE (procedure->args[1]) ||
(! proc->generic_file_proc &&
! GIMP_IS_PARAM_SPEC_IMAGE (procedure->values[0]))))
{
@@ -303,7 +310,7 @@ gimp_plug_in_set_file_proc_load_handler (GimpPlugIn *plug_in,
"attempted to register procedure \"%s\" "
"as load handler which does not take the standard "
"load procedure arguments: "
- "(GimpRunMode, String) -> (GimpImage)",
+ "(GimpRunMode, GFile) -> (GimpImage)",
gimp_object_get_name (plug_in),
gimp_file_get_utf8_name (plug_in->file),
proc_name);
@@ -354,14 +361,14 @@ gimp_plug_in_set_file_proc_save_handler (GimpPlugIn *plug_in,
! GIMP_IS_PARAM_SPEC_RUN_MODE (procedure->args[0]) ||
! GIMP_IS_PARAM_SPEC_IMAGE (procedure->args[1]) ||
! GIMP_IS_PARAM_SPEC_DRAWABLE (procedure->args[2]) ||
- ! G_IS_PARAM_SPEC_STRING (procedure->args[3]))
+ ! GIMP_IS_PARAM_SPEC_FILE (procedure->args[3]))
{
g_set_error (error, GIMP_PDB_ERROR, GIMP_PDB_ERROR_FAILED,
"Plug-in \"%s\"\n(%s)\n"
"attempted to register procedure \"%s\" "
"as save handler which does not take the standard "
"save procedure arguments: "
- "(GimpRunMode, GimpImage, GimpDrawable, String)",
+ "(GimpRunMode, GimpImage, GimpDrawable, GFile)",
gimp_object_get_name (plug_in),
gimp_file_get_utf8_name (plug_in->file),
proc_name);
diff --git a/app/plug-in/gimppluginprocedure.c b/app/plug-in/gimppluginprocedure.c
index 39ff34d6ea..85975335ae 100644
--- a/app/plug-in/gimppluginprocedure.c
+++ b/app/plug-in/gimppluginprocedure.c
@@ -433,6 +433,13 @@ GIMP_IS_PARAM_SPEC_RUN_MODE (GParamSpec *pspec)
pspec->value_type == GIMP_TYPE_RUN_MODE);
}
+static inline gboolean
+GIMP_IS_PARAM_SPEC_FILE (GParamSpec *pspec)
+{
+ return (G_IS_PARAM_SPEC_OBJECT (pspec) &&
+ pspec->value_type == G_TYPE_FILE);
+}
+
static gboolean
gimp_plug_in_procedure_validate_args (GimpPlugInProcedure *proc,
Gimp *gimp,
@@ -445,6 +452,7 @@ gimp_plug_in_procedure_validate_args (GimpPlugInProcedure *proc,
if (! proc->file_proc)
return TRUE;
+#if 0
/* make sure that the passed strings are actually URIs, not just a
* file path (bug 758685)
*/
@@ -452,7 +460,7 @@ gimp_plug_in_procedure_validate_args (GimpPlugInProcedure *proc,
if ((procedure->num_args >= 3) &&
(procedure->num_values >= 1) &&
GIMP_IS_PARAM_SPEC_RUN_MODE (procedure->args[0]) &&
- G_IS_PARAM_SPEC_STRING (procedure->args[1]) &&
+ GIMP_IS_PARAM_SPEC_FILE (procedure->args[1]) &&
GIMP_IS_PARAM_SPEC_IMAGE (procedure->values[0]))
{
uri_value = gimp_value_array_index (args, 1);
@@ -461,7 +469,7 @@ gimp_plug_in_procedure_validate_args (GimpPlugInProcedure *proc,
GIMP_IS_PARAM_SPEC_RUN_MODE (procedure->args[0]) &&
GIMP_IS_PARAM_SPEC_IMAGE (procedure->args[1]) &&
GIMP_IS_PARAM_SPEC_DRAWABLE (procedure->args[2]) &&
- G_IS_PARAM_SPEC_STRING (procedure->args[3]))
+ GIMP_IS_PARAM_SPEC_FILE (procedure->args[3]))
{
uri_value = gimp_value_array_index (args, 3);
}
@@ -480,6 +488,7 @@ gimp_plug_in_procedure_validate_args (GimpPlugInProcedure *proc,
g_value_take_string (uri_value, g_file_get_uri (file));
g_object_unref (file);
}
+#endif
return TRUE;
}
diff --git a/app/xcf/xcf.c b/app/xcf/xcf.c
index b858162232..8ee98c4888 100644
--- a/app/xcf/xcf.c
+++ b/app/xcf/xcf.c
@@ -155,15 +155,12 @@ xcf_init (Gimp *gimp)
TRUE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
- gimp_param_spec_string ("filename",
- "Filename",
- "The name of the file "
- "to save the image in, "
- "in URI format and "
- "UTF-8 encoding",
- TRUE, FALSE, TRUE,
- NULL,
- GIMP_PARAM_READWRITE));
+ g_param_spec_object ("file",
+ "File",
+ "The file "
+ "to save the image in",
+ G_TYPE_FILE,
+ GIMP_PARAM_READWRITE));
gimp_plug_in_manager_add_procedure (gimp->plug_in_manager, proc);
g_object_unref (procedure);
@@ -209,15 +206,11 @@ xcf_init (Gimp *gimp)
GIMP_RUN_INTERACTIVE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
- gimp_param_spec_string ("filename",
- "Filename",
- "The name of the file "
- "to load, in the "
- "on-disk character "
- "set and encoding",
- TRUE, FALSE, TRUE,
- NULL,
- GIMP_PARAM_READWRITE));
+ g_param_spec_object ("file",
+ "File",
+ "The file to load",
+ G_TYPE_FILE,
+ GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
gimp_param_spec_image ("image",
@@ -416,15 +409,13 @@ xcf_load_invoker (GimpProcedure *procedure,
{
GimpValueArray *return_vals;
GimpImage *image = NULL;
- const gchar *uri;
GFile *file;
GInputStream *input;
GError *my_error = NULL;
gimp_set_busy (gimp);
- uri = g_value_get_string (gimp_value_array_index (args, 1));
- file = g_file_new_for_uri (uri);
+ file = g_value_get_object (gimp_value_array_index (args, 1));
input = G_INPUT_STREAM (g_file_read (file, NULL, &my_error));
@@ -441,8 +432,6 @@ xcf_load_invoker (GimpProcedure *procedure,
gimp_file_get_utf8_name (file));
}
- g_object_unref (file);
-
return_vals = gimp_procedure_get_return_values (procedure, image != NULL,
error ? *error : NULL);
@@ -464,7 +453,6 @@ xcf_save_invoker (GimpProcedure *procedure,
{
GimpValueArray *return_vals;
GimpImage *image;
- const gchar *uri;
GFile *file;
GOutputStream *output;
gboolean success = FALSE;
@@ -473,8 +461,7 @@ xcf_save_invoker (GimpProcedure *procedure,
gimp_set_busy (gimp);
image = g_value_get_object (gimp_value_array_index (args, 1));
- uri = g_value_get_string (gimp_value_array_index (args, 3));
- file = g_file_new_for_uri (uri);
+ file = g_value_get_object (gimp_value_array_index (args, 3));
output = G_OUTPUT_STREAM (g_file_replace (file,
NULL, FALSE, G_FILE_CREATE_NONE,
@@ -493,8 +480,6 @@ xcf_save_invoker (GimpProcedure *procedure,
gimp_file_get_utf8_name (file));
}
- g_object_unref (file);
-
return_vals = gimp_procedure_get_return_values (procedure, success,
error ? *error : NULL);
diff --git a/libgimp/gimpfile_pdb.c b/libgimp/gimpfile_pdb.c
index 5278cd7a0d..91d3b3c76d 100644
--- a/libgimp/gimpfile_pdb.c
+++ b/libgimp/gimpfile_pdb.c
@@ -37,7 +37,7 @@
/**
* gimp_file_load:
* @run_mode: The run mode.
- * @filename: The name of the file to load.
+ * @file: The file to load.
*
* Loads an image file by invoking the right load handler.
*
@@ -53,7 +53,7 @@
**/
GimpImage *
gimp_file_load (GimpRunMode run_mode,
- const gchar *filename)
+ GFile *file)
{
GimpValueArray *args;
GimpValueArray *return_vals;
@@ -61,7 +61,7 @@ gimp_file_load (GimpRunMode run_mode,
args = gimp_value_array_new_from_types (NULL,
GIMP_TYPE_RUN_MODE, run_mode,
- G_TYPE_STRING, filename,
+ G_TYPE_FILE, file,
G_TYPE_NONE);
return_vals = gimp_pdb_run_procedure_array (gimp_get_pdb (),
@@ -81,7 +81,7 @@ gimp_file_load (GimpRunMode run_mode,
* gimp_file_load_layer:
* @run_mode: The run mode.
* @image: Destination image.
- * @filename: The name of the file to load.
+ * @file: The file to load.
*
* Loads an image file as a layer for an existing image.
*
@@ -97,7 +97,7 @@ gimp_file_load (GimpRunMode run_mode,
GimpLayer *
gimp_file_load_layer (GimpRunMode run_mode,
GimpImage *image,
- const gchar *filename)
+ GFile *file)
{
GimpValueArray *args;
GimpValueArray *return_vals;
@@ -106,7 +106,7 @@ gimp_file_load_layer (GimpRunMode run_mode,
args = gimp_value_array_new_from_types (NULL,
GIMP_TYPE_RUN_MODE, run_mode,
GIMP_TYPE_IMAGE, image,
- G_TYPE_STRING, filename,
+ G_TYPE_FILE, file,
G_TYPE_NONE);
return_vals = gimp_pdb_run_procedure_array (gimp_get_pdb (),
@@ -126,7 +126,7 @@ gimp_file_load_layer (GimpRunMode run_mode,
* gimp_file_load_layers:
* @run_mode: The run mode.
* @image: Destination image.
- * @filename: The name of the file to load.
+ * @file: The file to load.
* @num_layers: (out): The number of loaded layers.
*
* Loads an image file as layers for an existing image.
@@ -145,7 +145,7 @@ gimp_file_load_layer (GimpRunMode run_mode,
GimpLayer **
gimp_file_load_layers (GimpRunMode run_mode,
GimpImage *image,
- const gchar *filename,
+ GFile *file,
gint *num_layers)
{
GimpValueArray *args;
@@ -155,7 +155,7 @@ gimp_file_load_layers (GimpRunMode run_mode,
args = gimp_value_array_new_from_types (NULL,
GIMP_TYPE_RUN_MODE, run_mode,
GIMP_TYPE_IMAGE, image,
- G_TYPE_STRING, filename,
+ G_TYPE_FILE, file,
G_TYPE_NONE);
return_vals = gimp_pdb_run_procedure_array (gimp_get_pdb (),
@@ -181,7 +181,7 @@ gimp_file_load_layers (GimpRunMode run_mode,
* @run_mode: The run mode.
* @image: Input image.
* @drawable: Drawable to save.
- * @filename: The name of the file to save the image in.
+ * @file: The file to save the image in.
*
* Saves a file by extension.
*
@@ -199,7 +199,7 @@ gboolean
gimp_file_save (GimpRunMode run_mode,
GimpImage *image,
GimpDrawable *drawable,
- const gchar *filename)
+ GFile *file)
{
GimpValueArray *args;
GimpValueArray *return_vals;
@@ -209,7 +209,7 @@ gimp_file_save (GimpRunMode run_mode,
GIMP_TYPE_RUN_MODE, run_mode,
GIMP_TYPE_IMAGE, image,
GIMP_TYPE_DRAWABLE, drawable,
- G_TYPE_STRING, filename,
+ G_TYPE_FILE, file,
G_TYPE_NONE);
return_vals = gimp_pdb_run_procedure_array (gimp_get_pdb (),
@@ -227,22 +227,22 @@ gimp_file_save (GimpRunMode run_mode,
/**
* gimp_file_save_thumbnail:
* @image: The image.
- * @filename: The name of the file the thumbnail belongs to.
+ * @file: The file the thumbnail belongs to.
*
* Saves a thumbnail for the given image
*
* This procedure saves a thumbnail for the given image according to
* the Free Desktop Thumbnail Managing Standard. The thumbnail is saved
- * so that it belongs to the file with the given filename. This means
- * you have to save the image under this name first, otherwise this
+ * so that it belongs to the file with the given filen. This means you
+ * have to save the image under this name first, otherwise this
* procedure will fail. This procedure may become useful if you want to
* explicitly save a thumbnail with a file.
*
* Returns: TRUE on success.
**/
gboolean
-gimp_file_save_thumbnail (GimpImage *image,
- const gchar *filename)
+gimp_file_save_thumbnail (GimpImage *image,
+ GFile *file)
{
GimpValueArray *args;
GimpValueArray *return_vals;
@@ -250,7 +250,7 @@ gimp_file_save_thumbnail (GimpImage *image,
args = gimp_value_array_new_from_types (NULL,
GIMP_TYPE_IMAGE, image,
- G_TYPE_STRING, filename,
+ G_TYPE_FILE, file,
G_TYPE_NONE);
return_vals = gimp_pdb_run_procedure_array (gimp_get_pdb (),
diff --git a/libgimp/gimpfile_pdb.h b/libgimp/gimpfile_pdb.h
index 2139ecacee..2257e48638 100644
--- a/libgimp/gimpfile_pdb.h
+++ b/libgimp/gimpfile_pdb.h
@@ -33,20 +33,20 @@ G_BEGIN_DECLS
GimpImage* gimp_file_load (GimpRunMode run_mode,
- const gchar *filename);
+ GFile *file);
GimpLayer* gimp_file_load_layer (GimpRunMode run_mode,
GimpImage *image,
- const gchar *filename);
+ GFile *file);
GimpLayer** gimp_file_load_layers (GimpRunMode run_mode,
GimpImage *image,
- const gchar *filename,
+ GFile *file,
gint *num_layers);
gboolean gimp_file_save (GimpRunMode run_mode,
GimpImage *image,
GimpDrawable *drawable,
- const gchar *filename);
+ GFile *file);
gboolean gimp_file_save_thumbnail (GimpImage *image,
- const gchar *filename);
+ GFile *file);
G_END_DECLS
diff --git a/libgimp/gimpimage_pdb.c b/libgimp/gimpimage_pdb.c
index 436870ffc8..5c5d32d796 100644
--- a/libgimp/gimpimage_pdb.c
+++ b/libgimp/gimpimage_pdb.c
@@ -2490,59 +2490,61 @@ gimp_image_set_component_visible (GimpImage *image,
}
/**
- * gimp_image_get_filename:
+ * gimp_image_get_file:
* @image: The image.
*
- * Returns the specified image's filename.
+ * Returns the file for the specified image.
*
- * This procedure returns the specified image's filename in the
- * filesystem encoding. The image has a filename only if it was loaded
- * or imported from a file or has since been saved or exported.
- * Otherwise, this function returns %NULL. See also
- * gimp_image_get_uri().
+ * This procedure returns the file associated with the specified image.
+ * The image has a file only if it was loaded or imported from a file
+ * or has since been saved or exported. Otherwise, this function
+ * returns %NULL. See also gimp-image-get-imported-file to get the
+ * current file if it was imported from a non-GIMP file format and not
+ * yet saved, or gimp-image-get-exported-file if the image has been
+ * exported to a non-GIMP file format.
*
- * Returns: (transfer full): The filename.
- * The returned value must be freed with g_free().
+ * Returns: (transfer full): The file.
+ *
+ * Since: 2.8
**/
-gchar *
-gimp_image_get_filename (GimpImage *image)
+GFile *
+gimp_image_get_file (GimpImage *image)
{
GimpValueArray *args;
GimpValueArray *return_vals;
- gchar *filename = NULL;
+ GFile *file = NULL;
args = gimp_value_array_new_from_types (NULL,
GIMP_TYPE_IMAGE, image,
G_TYPE_NONE);
return_vals = gimp_pdb_run_procedure_array (gimp_get_pdb (),
- "gimp-image-get-filename",
+ "gimp-image-get-file",
args);
gimp_value_array_unref (args);
if (GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS)
- filename = GIMP_VALUES_DUP_STRING (return_vals, 1);
+ file = GIMP_VALUES_DUP_FILE (return_vals, 1);
gimp_value_array_unref (return_vals);
- return filename;
+ return file;
}
/**
- * gimp_image_set_filename:
+ * gimp_image_set_file:
* @image: The image.
- * @filename: The new image filename.
+ * @file: The new image file.
*
- * Sets the specified image's filename.
+ * Sets the specified image's file.
*
- * This procedure sets the specified image's filename. The filename
- * should be in the filesystem encoding.
+ * This procedure sets the specified image's file.
*
* Returns: TRUE on success.
**/
gboolean
-gimp_image_set_filename (GimpImage *image,
- const gchar *filename)
+gimp_image_set_file (GimpImage *image,
+ GFile *file)
{
GimpValueArray *args;
GimpValueArray *return_vals;
@@ -2550,11 +2552,11 @@ gimp_image_set_filename (GimpImage *image,
args = gimp_value_array_new_from_types (NULL,
GIMP_TYPE_IMAGE, image,
- G_TYPE_STRING, filename,
+ G_TYPE_FILE, file,
G_TYPE_NONE);
return_vals = gimp_pdb_run_procedure_array (gimp_get_pdb (),
- "gimp-image-set-filename",
+ "gimp-image-set-file",
args);
gimp_value_array_unref (args);
@@ -2566,163 +2568,117 @@ gimp_image_set_filename (GimpImage *image,
}
/**
- * gimp_image_get_uri:
- * @image: The image.
- *
- * Returns the URI for the specified image.
- *
- * This procedure returns the URI associated with the specified image.
- * The image has an URI only if it was loaded or imported from a file
- * or has since been saved or exported. Otherwise, this function
- * returns %NULL. See also gimp-image-get-imported-uri to get the URI
- * of the current file if it was imported from a non-GIMP file format
- * and not yet saved, or gimp-image-get-exported-uri if the image has
- * been exported to a non-GIMP file format.
- *
- * Returns: (transfer full): The URI.
- * The returned value must be freed with g_free().
- *
- * Since: 2.8
- **/
-gchar *
-gimp_image_get_uri (GimpImage *image)
-{
- GimpValueArray *args;
- GimpValueArray *return_vals;
- gchar *uri = NULL;
-
- args = gimp_value_array_new_from_types (NULL,
- GIMP_TYPE_IMAGE, image,
- G_TYPE_NONE);
-
- return_vals = gimp_pdb_run_procedure_array (gimp_get_pdb (),
- "gimp-image-get-uri",
- args);
- gimp_value_array_unref (args);
-
- if (GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS)
- uri = GIMP_VALUES_DUP_STRING (return_vals, 1);
-
- gimp_value_array_unref (return_vals);
-
- return uri;
-}
-
-/**
- * gimp_image_get_xcf_uri:
+ * gimp_image_get_xcf_file:
* @image: The image.
*
- * Returns the XCF URI for the specified image.
+ * Returns the XCF file for the specified image.
*
- * This procedure returns the XCF URI associated with the image. If
- * there is no such URI, this procedure returns %NULL.
+ * This procedure returns the XCF file associated with the image. If
+ * there is no such file, this procedure returns %NULL.
*
- * Returns: (transfer full): The imported URI.
- * The returned value must be freed with g_free().
+ * Returns: (transfer full): The imported XCF file.
*
* Since: 2.8
**/
-gchar *
-gimp_image_get_xcf_uri (GimpImage *image)
+GFile *
+gimp_image_get_xcf_file (GimpImage *image)
{
GimpValueArray *args;
GimpValueArray *return_vals;
- gchar *uri = NULL;
+ GFile *file = NULL;
args = gimp_value_array_new_from_types (NULL,
GIMP_TYPE_IMAGE, image,
G_TYPE_NONE);
return_vals = gimp_pdb_run_procedure_array (gimp_get_pdb (),
- "gimp-image-get-xcf-uri",
+ "gimp-image-get-xcf-file",
args);
gimp_value_array_unref (args);
if (GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS)
- uri = GIMP_VALUES_DUP_STRING (return_vals, 1);
+ file = GIMP_VALUES_DUP_FILE (return_vals, 1);
gimp_value_array_unref (return_vals);
- return uri;
+ return file;
}
/**
- * gimp_image_get_imported_uri:
+ * gimp_image_get_imported_file:
* @image: The image.
*
- * Returns the imported URI for the specified image.
+ * Returns the imported file for the specified image.
*
- * This procedure returns the URI associated with the specified image
+ * This procedure returns the file associated with the specified image
* if the image was imported from a non-native Gimp format. If the
* image was not imported, or has since been saved in the native Gimp
* format, this procedure returns %NULL.
*
- * Returns: (transfer full): The imported URI.
- * The returned value must be freed with g_free().
+ * Returns: (transfer full): The imported file.
*
* Since: 2.8
**/
-gchar *
-gimp_image_get_imported_uri (GimpImage *image)
+GFile *
+gimp_image_get_imported_file (GimpImage *image)
{
GimpValueArray *args;
GimpValueArray *return_vals;
- gchar *uri = NULL;
+ GFile *file = NULL;
args = gimp_value_array_new_from_types (NULL,
GIMP_TYPE_IMAGE, image,
G_TYPE_NONE);
return_vals = gimp_pdb_run_procedure_array (gimp_get_pdb (),
- "gimp-image-get-imported-uri",
+ "gimp-image-get-imported-file",
args);
gimp_value_array_unref (args);
if (GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS)
- uri = GIMP_VALUES_DUP_STRING (return_vals, 1);
+ file = GIMP_VALUES_DUP_FILE (return_vals, 1);
gimp_value_array_unref (return_vals);
- return uri;
+ return file;
}
/**
- * gimp_image_get_exported_uri:
+ * gimp_image_get_exported_file:
* @image: The image.
*
- * Returns the exported URI for the specified image.
+ * Returns the exported file for the specified image.
*
- * This procedure returns the URI associated with the specified image
+ * This procedure returns the file associated with the specified image
* if the image was exported a non-native GIMP format. If the image was
* not exported, this procedure returns %NULL.
*
- * Returns: (transfer full): The exported URI.
- * The returned value must be freed with g_free().
+ * Returns: (transfer full): The exported file.
*
* Since: 2.8
**/
-gchar *
-gimp_image_get_exported_uri (GimpImage *image)
+GFile *
+gimp_image_get_exported_file (GimpImage *image)
{
GimpValueArray *args;
GimpValueArray *return_vals;
- gchar *uri = NULL;
+ GFile *file = NULL;
args = gimp_value_array_new_from_types (NULL,
GIMP_TYPE_IMAGE, image,
G_TYPE_NONE);
return_vals = gimp_pdb_run_procedure_array (gimp_get_pdb (),
- "gimp-image-get-exported-uri",
+ "gimp-image-get-exported-file",
args);
gimp_value_array_unref (args);
if (GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS)
- uri = GIMP_VALUES_DUP_STRING (return_vals, 1);
+ file = GIMP_VALUES_DUP_FILE (return_vals, 1);
gimp_value_array_unref (return_vals);
- return uri;
+ return file;
}
/**
diff --git a/libgimp/gimpimage_pdb.h b/libgimp/gimpimage_pdb.h
index 3cb3a0ede2..6e3c066d65 100644
--- a/libgimp/gimpimage_pdb.h
+++ b/libgimp/gimpimage_pdb.h
@@ -153,13 +153,12 @@ gboolean gimp_image_get_component_visible (GimpImage
gboolean gimp_image_set_component_visible (GimpImage *image,
GimpChannelType component,
gboolean visible);
-gchar* gimp_image_get_filename (GimpImage *image);
-gboolean gimp_image_set_filename (GimpImage *image,
- const gchar *filename);
-gchar* gimp_image_get_uri (GimpImage *image);
-gchar* gimp_image_get_xcf_uri (GimpImage *image);
-gchar* gimp_image_get_imported_uri (GimpImage *image);
-gchar* gimp_image_get_exported_uri (GimpImage *image);
+GFile* gimp_image_get_file (GimpImage *image);
+gboolean gimp_image_set_file (GimpImage *image,
+ GFile *file);
+GFile* gimp_image_get_xcf_file (GimpImage *image);
+GFile* gimp_image_get_imported_file (GimpImage *image);
+GFile* gimp_image_get_exported_file (GimpImage *image);
gchar* gimp_image_get_name (GimpImage *image);
gboolean gimp_image_get_resolution (GimpImage *image,
gdouble *xresolution,
diff --git a/libgimp/gimploadprocedure.c b/libgimp/gimploadprocedure.c
index 6f139e74ec..08d8ea02a6 100644
--- a/libgimp/gimploadprocedure.c
+++ b/libgimp/gimploadprocedure.c
@@ -78,11 +78,10 @@ gimp_load_procedure_constructed (GObject *object)
G_OBJECT_CLASS (parent_class)->constructed (object);
- GIMP_PROC_ARG_STRING (procedure, "uri",
- "URI",
- "The URI of the file to load",
- NULL,
- GIMP_PARAM_READWRITE);
+ GIMP_PROC_ARG_FILE (procedure, "file",
+ "File",
+ "The file to load",
+ GIMP_PARAM_READWRITE);
GIMP_PROC_VAL_IMAGE (procedure, "image",
"Image",
@@ -148,14 +147,11 @@ gimp_load_procedure_run (GimpProcedure *procedure,
GimpValueArray *remaining;
GimpValueArray *return_values;
GimpRunMode run_mode;
- const gchar *uri;
GFile *file;
gint i;
- run_mode = GIMP_VALUES_GET_ENUM (args, 0);
- uri = GIMP_VALUES_GET_STRING (args, 1);
-
- file = g_file_new_for_uri (uri);
+ run_mode = GIMP_VALUES_GET_ENUM (args, 0);
+ file = GIMP_VALUES_GET_FILE (args, 1);
remaining = gimp_value_array_new (gimp_value_array_length (args) - 2);
@@ -173,7 +169,6 @@ gimp_load_procedure_run (GimpProcedure *procedure,
load_proc->priv->run_data);
gimp_value_array_unref (remaining);
- g_object_unref (file);
return return_values;
}
@@ -200,11 +195,11 @@ gimp_load_procedure_run (GimpProcedure *procedure,
*
* It automatically adds the standard
*
- * (run-mode, uri)
+ * (GimpRunMode, GFile)
*
* arguments and the standard
*
- * (image-id)
+ * (GimpImage)
*
* return value of a load procedure. It is possible to add additional
* arguments.
diff --git a/libgimp/gimpprocedure-params.h b/libgimp/gimpprocedure-params.h
index 0b36990980..6fee7f770f 100644
--- a/libgimp/gimpprocedure-params.h
+++ b/libgimp/gimpprocedure-params.h
@@ -673,6 +673,33 @@ G_BEGIN_DECLS
g_value_set_object (gimp_value_array_index (args, n), value)
+/* file */
+
+#define GIMP_PROC_ARG_FILE(class, name, nick, blurb, flags) \
+ gimp_procedure_add_argument (procedure,\
+ g_param_spec_object (name, nick, blurb,\
+ G_TYPE_FILE,\
+ flags))
+
+#define GIMP_PROC_VAL_FILE(class, name, nick, blurb, none_ok, flags) \
+ gimp_procedure_add_return_value (procedure,\
+ g_param_spec_object (name, nick, blurb,\
+ G_TYPE_FILE,\
+ flags))
+
+#define GIMP_VALUES_GET_FILE(args, n) \
+ g_value_get_object (gimp_value_array_index (args, n))
+
+#define GIMP_VALUES_DUP_FILE(args, n) \
+ g_value_dup_object (gimp_value_array_index (args, n))
+
+#define GIMP_VALUES_SET_FILE(args, n, value) \
+ g_value_set_object (gimp_value_array_index (args, n), value)
+
+#define GIMP_VALUES_TAKE_FILE(args, n, value) \
+ g_value_take_object (gimp_value_array_index (args, n), value)
+
+
G_END_DECLS
#endif /* __GIMP_PROCEDURE_PARAMS_H__ */
diff --git a/libgimp/gimpsaveprocedure.c b/libgimp/gimpsaveprocedure.c
index 60fbf514f9..c5a6bedf35 100644
--- a/libgimp/gimpsaveprocedure.c
+++ b/libgimp/gimpsaveprocedure.c
@@ -87,11 +87,10 @@ gimp_save_procedure_constructed (GObject *object)
FALSE,
G_PARAM_READWRITE);
- GIMP_PROC_ARG_STRING (procedure, "uri",
- "URI",
- "The URI of the file to save to",
- NULL,
- GIMP_PARAM_READWRITE);
+ GIMP_PROC_ARG_FILE (procedure, "file",
+ "File",
+ "The file to save to",
+ GIMP_PARAM_READWRITE);
}
static void
@@ -142,16 +141,13 @@ gimp_save_procedure_run (GimpProcedure *procedure,
GimpRunMode run_mode;
GimpImage *image;
GimpDrawable *drawable;
- const gchar *uri;
GFile *file;
gint i;
- run_mode = GIMP_VALUES_GET_ENUM (args, 0);
- image = GIMP_VALUES_GET_IMAGE (args, 1);
- drawable = GIMP_VALUES_GET_DRAWABLE (args, 2);
- uri = GIMP_VALUES_GET_STRING (args, 3);
-
- file = g_file_new_for_uri (uri);
+ run_mode = GIMP_VALUES_GET_ENUM (args, 0);
+ image = GIMP_VALUES_GET_IMAGE (args, 1);
+ drawable = GIMP_VALUES_GET_DRAWABLE (args, 2);
+ file = GIMP_VALUES_GET_FILE (args, 3);
remaining = gimp_value_array_new (gimp_value_array_length (args) - 4);
@@ -170,7 +166,6 @@ gimp_save_procedure_run (GimpProcedure *procedure,
save_proc->priv->run_data);
gimp_value_array_unref (remaining);
- g_object_unref (file);
return return_values;
}
@@ -197,7 +192,7 @@ gimp_save_procedure_run (GimpProcedure *procedure,
*
* It automatically adds the standard
*
- * (run-mode, image-id, drawable-id, uri)
+ * (GimpRunMode, GimpImage, GimpImage, GFile)
*
* arguments of a save procedure. It is possible to add additional
* arguments.
diff --git a/libgimp/gimpthumbnailprocedure.c b/libgimp/gimpthumbnailprocedure.c
index 6ec0ca3f6b..a823de61bc 100644
--- a/libgimp/gimpthumbnailprocedure.c
+++ b/libgimp/gimpthumbnailprocedure.c
@@ -72,11 +72,10 @@ gimp_thumbnail_procedure_constructed (GObject *object)
G_OBJECT_CLASS (parent_class)->constructed (object);
- GIMP_PROC_ARG_STRING (procedure, "uri",
- "URI",
- "URI of the file to load the thumbnail from",
- NULL,
- GIMP_PARAM_READWRITE);
+ GIMP_PROC_ARG_FILE (procedure, "file",
+ "File",
+ "The file to load the thumbnail from",
+ GIMP_PARAM_READWRITE);
GIMP_PROC_ARG_INT (procedure, "thumb-size",
"Thumb Size",
@@ -134,15 +133,12 @@ gimp_thumbnail_procedure_run (GimpProcedure *procedure,
GimpThumbnailProcedure *thumbnail_proc = GIMP_THUMBNAIL_PROCEDURE (procedure);
GimpValueArray *remaining;
GimpValueArray *return_values;
- const gchar *uri;
GFile *file;
gint size;
gint i;
- uri = GIMP_VALUES_GET_STRING (args, 0);
- size = GIMP_VALUES_GET_INT (args, 1);
-
- file = g_file_new_for_uri (uri);
+ file = GIMP_VALUES_GET_FILE (args, 0);
+ size = GIMP_VALUES_GET_INT (args, 1);
remaining = gimp_value_array_new (gimp_value_array_length (args) - 2);
@@ -160,7 +156,6 @@ gimp_thumbnail_procedure_run (GimpProcedure *procedure,
thumbnail_proc->priv->run_data);
gimp_value_array_unref (remaining);
- g_object_unref (file);
return return_values;
}
diff --git a/libgimp/gimpvectors_pdb.c b/libgimp/gimpvectors_pdb.c
index fd2cef1368..64e2124244 100644
--- a/libgimp/gimpvectors_pdb.c
+++ b/libgimp/gimpvectors_pdb.c
@@ -1030,7 +1030,7 @@ gimp_vectors_bezier_stroke_new_ellipse (GimpVectors *vectors,
/**
* gimp_vectors_import_from_file:
* @image: The image.
- * @filename: The name of the SVG file to import.
+ * @file: The SVG file to import.
* @merge: Merge paths into a single vectors object.
* @scale: Scale the SVG to image dimensions.
* @num_vectors: (out): The number of newly created vectors.
@@ -1047,7 +1047,7 @@ gimp_vectors_bezier_stroke_new_ellipse (GimpVectors *vectors,
**/
gboolean
gimp_vectors_import_from_file (GimpImage *image,
- const gchar *filename,
+ GFile *file,
gboolean merge,
gboolean scale,
gint *num_vectors,
@@ -1059,7 +1059,7 @@ gimp_vectors_import_from_file (GimpImage *image,
args = gimp_value_array_new_from_types (NULL,
GIMP_TYPE_IMAGE, image,
- G_TYPE_STRING, filename,
+ G_TYPE_FILE, file,
G_TYPE_BOOLEAN, merge,
G_TYPE_BOOLEAN, scale,
G_TYPE_NONE);
@@ -1150,7 +1150,7 @@ gimp_vectors_import_from_string (GimpImage *image,
/**
* gimp_vectors_export_to_file:
* @image: The image.
- * @filename: The name of the SVG file to create.
+ * @file: The SVG file to create.
* @vectors: The vectors object to be saved, or 0 for all in the image.
*
* save a path as an SVG file.
@@ -1166,7 +1166,7 @@ gimp_vectors_import_from_string (GimpImage *image,
**/
gboolean
gimp_vectors_export_to_file (GimpImage *image,
- const gchar *filename,
+ GFile *file,
GimpVectors *vectors)
{
GimpValueArray *args;
@@ -1175,7 +1175,7 @@ gimp_vectors_export_to_file (GimpImage *image,
args = gimp_value_array_new_from_types (NULL,
GIMP_TYPE_IMAGE, image,
- G_TYPE_STRING, filename,
+ G_TYPE_FILE, file,
GIMP_TYPE_VECTORS, vectors,
G_TYPE_NONE);
diff --git a/libgimp/gimpvectors_pdb.h b/libgimp/gimpvectors_pdb.h
index f4a4639f5f..8665f8a8f4 100644
--- a/libgimp/gimpvectors_pdb.h
+++ b/libgimp/gimpvectors_pdb.h
@@ -120,7 +120,7 @@ gint gimp_vectors_bezier_stroke_new_ellipse (GimpVectors
gdouble radius_y,
gdouble angle);
gboolean gimp_vectors_import_from_file (GimpImage *image,
- const gchar *filename,
+ GFile *file,
gboolean merge,
gboolean scale,
gint *num_vectors,
@@ -133,7 +133,7 @@ gboolean gimp_vectors_import_from_string (GimpImage
gint *num_vectors,
GimpVectors ***vectors);
gboolean gimp_vectors_export_to_file (GimpImage *image,
- const gchar *filename,
+ GFile *file,
GimpVectors *vectors);
gchar* gimp_vectors_export_to_string (GimpImage *image,
GimpVectors *vectors);
diff --git a/pdb/app.pl b/pdb/app.pl
index 02757cd4d3..6d48b3c29c 100644
--- a/pdb/app.pl
+++ b/pdb/app.pl
@@ -317,6 +317,15 @@ gimp_param_spec_display ("$name",
"$blurb",
$none_ok,
$flags)
+CODE
+ }
+ elsif ($pdbtype eq 'file') {
+ $pspec = <<CODE;
+g_param_spec_object ("$name",
+ "$nick",
+ "$blurb",
+ G_TYPE_FILE,
+ $flags)
CODE
}
elsif ($pdbtype eq 'tattoo') {
diff --git a/pdb/groups/file.pdb b/pdb/groups/file.pdb
index 8692f1c263..23c905f635 100644
--- a/pdb/groups/file.pdb
+++ b/pdb/groups/file.pdb
@@ -36,8 +36,8 @@ HELP
{ name => 'run_mode',
type => 'enum GimpRunMode (no GIMP_RUN_WITH_LAST_VALS)',
desc => 'The run mode' },
- { name => 'filename', type => 'string', allow_non_utf8 => 1,
- desc => 'The name of the file to load' }
+ { name => 'file', type => 'file',
+ desc => 'The file to load' }
);
@outargs = (
@@ -56,9 +56,7 @@ HELP
GFile *file;
gint i;
- file = file_utils_filename_to_file (gimp,
- g_value_get_string (gimp_value_array_index (args, 1)),
- error);
+ file = g_value_get_object (gimp_value_array_index (args, 1));
if (! file)
return gimp_procedure_get_return_values (procedure, FALSE,
@@ -69,12 +67,8 @@ HELP
file, error);
if (! file_proc)
- {
- g_object_unref (file);
-
- return gimp_procedure_get_return_values (procedure, FALSE,
- error ? *error : NULL);
- }
+ return gimp_procedure_get_return_values (procedure, FALSE,
+ error ? *error : NULL);
proc = GIMP_PROCEDURE (file_proc);
@@ -110,8 +104,6 @@ HELP
}
}
- g_object_unref (file);
-
return return_vals;
}
CODE
@@ -135,8 +127,8 @@ HELP
desc => 'The run mode' },
{ name => 'image', type => 'image',
desc => 'Destination image' },
- { name => 'filename', type => 'string', allow_non_utf8 => 1,
- desc => 'The name of the file to load' }
+ { name => 'file', type => 'file',
+ desc => 'The file to load' }
);
@outargs = (
@@ -147,26 +139,17 @@ HELP
%invoke = (
code => <<'CODE'
{
- GFile *file = file_utils_filename_to_file (gimp, filename, error);
-
- if (file)
- {
- GList *layers;
- GimpPDBStatusType status;
-
- layers = file_open_layers (gimp, context, progress,
- image, FALSE,
- file, run_mode, NULL, &status, error);
+ GList *layers;
+ GimpPDBStatusType status;
- g_object_unref (file);
+ layers = file_open_layers (gimp, context, progress,
+ image, FALSE,
+ file, run_mode, NULL, &status, error);
- if (layers)
- {
- layer = layers->data;
- g_list_free (layers);
- }
- else
- success = FALSE;
+ if (layers)
+ {
+ layer = layers->data;
+ g_list_free (layers);
}
else
success = FALSE;
@@ -192,8 +175,8 @@ HELP
desc => 'The run mode' },
{ name => 'image', type => 'image',
desc => 'Destination image' },
- { name => 'filename', type => 'string', allow_non_utf8 => 1,
- desc => 'The name of the file to load' }
+ { name => 'file', type => 'file',
+ desc => 'The file to load' }
);
@outargs = (
@@ -206,39 +189,30 @@ HELP
%invoke = (
code => <<'CODE'
{
- GFile *file = file_utils_filename_to_file (gimp, filename, error);
+ GList *layer_list;
+ GimpPDBStatusType status;
- if (file)
+ layer_list = file_open_layers (gimp, context, progress,
+ image, FALSE,
+ file, run_mode, NULL, &status, error);
+
+ if (layers)
{
- GList *layer_list;
- GimpPDBStatusType status;
+ GList *list;
+ gint i;
- layer_list = file_open_layers (gimp, context, progress,
- image, FALSE,
- file, run_mode, NULL, &status, error);
+ num_layers = g_list_length (layer_list);
- g_object_unref (file);
+ layers = g_new (GimpLayer *, num_layers);
- if (layers)
+ for (i = 0, list = layer_list;
+ i < num_layers;
+ i++, list = g_list_next (list))
{
- GList *list;
- gint i;
-
- num_layers = g_list_length (layer_list);
-
- layers = g_new (GimpLayer *, num_layers);
-
- for (i = 0, list = layer_list;
- i < num_layers;
- i++, list = g_list_next (list))
- {
- layers[i] = g_object_ref (list->data);
- }
-
- g_list_free (layer_list);
+ layers[i] = g_object_ref (list->data);
}
- else
- success = FALSE;
+
+ g_list_free (layer_list);
}
else
success = FALSE;
@@ -268,8 +242,8 @@ HELP
desc => 'Input image' },
{ name => 'drawable', type => 'drawable',
desc => 'Drawable to save' },
- { name => 'filename', type => 'string', allow_non_utf8 => 1,
- desc => 'The name of the file to save the image in' }
+ { name => 'file', type => 'file',
+ desc => 'The file to save the image in' }
);
%invoke = (
@@ -280,17 +254,11 @@ HELP
GimpValueArray *new_args;
GimpValueArray *return_vals;
GimpPlugInProcedure *file_proc;
- GimpProcedure *proc;
GFile *file;
+ GimpProcedure *proc;
gint i;
- file = file_utils_filename_to_file (gimp,
- g_value_get_string (gimp_value_array_index (args, 3)),
- error);
-
- if (! file)
- return gimp_procedure_get_return_values (procedure, FALSE,
- error ? *error : NULL);
+ file = g_value_get_object (gimp_value_array_index (args, 3));
file_proc = gimp_plug_in_manager_file_procedure_find (gimp->plug_in_manager,
GIMP_FILE_PROCEDURE_GROUP_SAVE,
@@ -302,12 +270,8 @@ HELP
file, error);
if (! file_proc)
- {
- g_object_unref (file);
-
- return gimp_procedure_get_return_values (procedure, FALSE,
- error ? *error : NULL);
- }
+ return gimp_procedure_get_return_values (procedure, FALSE,
+ error ? *error : NULL);
proc = GIMP_PROCEDURE (file_proc);
@@ -319,9 +283,8 @@ HELP
gimp_value_array_index (new_args, 1));
g_value_transform (gimp_value_array_index (args, 2),
gimp_value_array_index (new_args, 2));
-
- g_value_take_string (gimp_value_array_index (new_args, 3),
- g_file_get_uri (file));
+ g_value_transform (gimp_value_array_index (args, 3),
+ gimp_value_array_index (new_args, 3));
for (i = 4; i < proc->num_args; i++)
if (G_IS_PARAM_SPEC_STRING (proc->args[i]))
@@ -335,8 +298,6 @@ HELP
gimp_value_array_unref (new_args);
- g_object_unref (file);
-
return return_vals;
}
CODE
@@ -348,7 +309,7 @@ sub file_load_thumbnail {
$help = <<'HELP';
This procedure tries to load a thumbnail that belongs to the file with
-the given filename. This name is a full pathname. The returned data is
+the given file. This name is a full pathname. The returned data is
an array of colordepth 3 (RGB), regardless of the image type. Width and
height of the thumbnail are also returned. Don't use this function if
you need a thumbnail of an already opened image, use gimp_image_thumbnail()
@@ -359,8 +320,8 @@ HELP
$date = '1999-2003';
@inargs = (
- { name => 'filename', type => 'string', allow_non_utf8 => 1,
- desc => 'The name of the file that owns the thumbnail to load' }
+ { name => 'file', type => 'file',
+ desc => 'The file that owns the thumbnail to load' }
);
@outargs = (
@@ -377,7 +338,7 @@ HELP
%invoke = (
code => <<'CODE'
{
- GdkPixbuf *pixbuf = file_utils_load_thumbnail (filename);
+ GdkPixbuf *pixbuf = file_utils_load_thumbnail (file);
if (pixbuf)
{
@@ -402,7 +363,7 @@ sub file_save_thumbnail {
$help = <<'HELP';
This procedure saves a thumbnail for the given image according to the
Free Desktop Thumbnail Managing Standard. The thumbnail is saved so
-that it belongs to the file with the given filename. This means you
+that it belongs to the file with the given filen. This means you
have to save the image under this name first, otherwise this procedure
will fail. This procedure may become useful if you want to
explicitly save a thumbnail with a file.
@@ -413,14 +374,14 @@ HELP
@inargs = (
{ name => 'image', type => 'image',
desc => 'The image' },
- { name => 'filename', type => 'string', allow_non_utf8 => 1,
- desc => 'The name of the file the thumbnail belongs to' },
+ { name => 'file', type => 'file',
+ desc => 'The file the thumbnail belongs to' },
);
%invoke = (
code => <<'CODE'
{
- success = file_utils_save_thumbnail (image, filename);
+ success = file_utils_save_thumbnail (image, file);
}
CODE
);
diff --git a/pdb/groups/image.pdb b/pdb/groups/image.pdb
index de399c3b9c..c3e347c6cf 100644
--- a/pdb/groups/image.pdb
+++ b/pdb/groups/image.pdb
@@ -2127,17 +2127,20 @@ CODE
);
}
-sub image_get_filename {
- $blurb = "Returns the specified image's filename.";
+sub image_get_file {
+ $blurb = "Returns the file for the specified image.";
$help = <<'HELP';
-This procedure returns the specified image's filename in the
-filesystem encoding. The image has a filename only if it was loaded or
-imported from a file or has since been saved or exported. Otherwise,
-this function returns %NULL. See also gimp_image_get_uri().
+This procedure returns the file associated with the specified image.
+The image has a file only if it was loaded or imported from a file or
+has since been saved or exported. Otherwise, this function returns
+%NULL. See also gimp-image-get-imported-file to get the
+current file if it was imported from a non-GIMP file format and not
+yet saved, or gimp-image-get-exported-file if the image has been
+exported to a non-GIMP file format.
HELP
- &std_pdb_misc;
+ &neo_pdb_misc('2009', '2.8');
@inargs = (
{ name => 'image', type => 'image',
@@ -2145,27 +2148,24 @@ HELP
);
@outargs = (
- { name => 'filename', type => 'string',
- desc => 'The filename.' }
+ { name => 'file', type => 'file',
+ desc => 'The file.' }
);
%invoke = (
code => <<'CODE'
{
- GFile *file = gimp_image_get_any_file (image);
- if (file)
- filename = g_file_get_path (file);
+ file = gimp_image_get_any_file (image);
}
CODE
);
}
-sub image_set_filename {
- $blurb = "Sets the specified image's filename.";
+sub image_set_file {
+ $blurb = "Sets the specified image's file.";
$help = <<'HELP';
-This procedure sets the specified image's filename. The filename
-should be in the filesystem encoding.
+This procedure sets the specified image's file.
HELP
&std_pdb_misc;
@@ -2173,89 +2173,25 @@ HELP
@inargs = (
{ name => 'image', type => 'image',
desc => 'The image' },
- { name => 'filename', type => 'string',
- desc => 'The new image filename', allow_non_utf8 => 1 }
- );
-
- %invoke = (
- code => <<'CODE'
-{
- /* verify that the filename can be converted to UTF-8 and back */
- gchar *utf8 = g_filename_to_utf8 (filename, -1, NULL, NULL, error);
-
- if (utf8)
- {
- gchar *tmp = g_filename_from_utf8 (utf8, -1, NULL, NULL, error);
-
- if (tmp)
- g_free (tmp);
- else
- success = FALSE;
-
- g_free (utf8);
- }
- else
- success = FALSE;
-
- if (success)
- {
- GFile *file = NULL;
-
- if (filename && strlen (filename))
- file = file_utils_filename_to_file (image->gimp, filename, NULL);
-
- gimp_image_set_file (image, file);
-
- if (file)
- g_object_unref (file);
- }
-}
-CODE
- );
-}
-
-sub image_get_uri {
- $blurb = "Returns the URI for the specified image.";
-
- $help = <<'HELP';
-This procedure returns the URI associated with the specified image.
-The image has an URI only if it was loaded or imported from a file or
-has since been saved or exported. Otherwise, this function returns
-%NULL. See also gimp-image-get-imported-uri to get the URI of the
-current file if it was imported from a non-GIMP file format and not
-yet saved, or gimp-image-get-exported-uri if the image has been
-exported to a non-GIMP file format.
-HELP
-
- &neo_pdb_misc('2009', '2.8');
-
- @inargs = (
- { name => 'image', type => 'image',
- desc => 'The image' }
- );
-
- @outargs = (
- { name => 'uri', type => 'string',
- desc => 'The URI.' }
+ { name => 'file', type => 'file',
+ desc => 'The new image file' }
);
%invoke = (
code => <<'CODE'
{
- GFile *file = gimp_image_get_any_file (image);
- if (file)
- uri = g_file_get_uri (file);
+ gimp_image_set_file (image, file);
}
CODE
);
}
-sub image_get_xcf_uri {
- $blurb = "Returns the XCF URI for the specified image.";
+sub image_get_xcf_file {
+ $blurb = "Returns the XCF file for the specified image.";
$help = <<'HELP';
-This procedure returns the XCF URI associated with the image. If
-there is no such URI, this procedure returns %NULL.
+This procedure returns the XCF file associated with the image. If
+there is no such file, this procedure returns %NULL.
HELP
$author = 'Eric Grivel <gimp lumenssolutions com>';
@@ -2269,26 +2205,24 @@ HELP
);
@outargs = (
- { name => 'uri', type => 'string',
- desc => 'The imported URI.' }
+ { name => 'file', type => 'file',
+ desc => 'The imported XCF file.' }
);
%invoke = (
code => <<'CODE'
{
- GFile *file = gimp_image_get_file (image);
- if (file)
- uri = g_file_get_uri (file);
+ file = gimp_image_get_file (image);
}
CODE
);
}
-sub image_get_imported_uri {
- $blurb = "Returns the imported URI for the specified image.";
+sub image_get_imported_file {
+ $blurb = "Returns the imported file for the specified image.";
$help = <<'HELP';
-This procedure returns the URI associated with the specified image
+This procedure returns the file associated with the specified image
if the image was imported from a non-native Gimp format. If the
image was not imported, or has since been saved in the native Gimp
format, this procedure returns %NULL.
@@ -2305,26 +2239,24 @@ HELP
);
@outargs = (
- { name => 'uri', type => 'string',
- desc => 'The imported URI.' }
+ { name => 'file', type => 'file',
+ desc => 'The imported file.' }
);
%invoke = (
code => <<'CODE'
{
- GFile *file = gimp_image_get_imported_file (image);
- if (file)
- uri = g_file_get_uri (file);
+ file = gimp_image_get_imported_file (image);
}
CODE
);
}
-sub image_get_exported_uri {
- $blurb = "Returns the exported URI for the specified image.";
+sub image_get_exported_file {
+ $blurb = "Returns the exported file for the specified image.";
$help = <<'HELP';
-This procedure returns the URI associated with the specified image
+This procedure returns the file associated with the specified image
if the image was exported a non-native GIMP format. If the
image was not exported, this procedure returns %NULL.
HELP
@@ -2340,16 +2272,14 @@ HELP
);
@outargs = (
- { name => 'uri', type => 'string',
- desc => 'The exported URI.' }
+ { name => 'file', type => 'file',
+ desc => 'The exported file.' }
);
%invoke = (
code => <<'CODE'
{
- GFile *file = gimp_image_get_exported_file (image);
- if (file)
- uri = g_file_get_uri (file);
+ file = gimp_image_get_exported_file (image);
}
CODE
);
@@ -3025,11 +2955,11 @@ CODE
image_get_selection
image_get_component_active image_set_component_active
image_get_component_visible image_set_component_visible
- image_get_filename image_set_filename
- image_get_uri
- image_get_xcf_uri
- image_get_imported_uri
- image_get_exported_uri
+ image_get_file
+ image_set_file
+ image_get_xcf_file
+ image_get_imported_file
+ image_get_exported_file
image_get_name
image_get_resolution image_set_resolution
image_get_unit image_set_unit
diff --git a/pdb/groups/vectors.pdb b/pdb/groups/vectors.pdb
index edb09c5783..057bccfdf5 100644
--- a/pdb/groups/vectors.pdb
+++ b/pdb/groups/vectors.pdb
@@ -1087,9 +1087,8 @@ HELP
@inargs = (
{ name => 'image', type => 'image',
desc => 'The image' },
- { name => 'filename', type => 'string', allow_non_utf8 => 1,
- non_empty => 1,
- desc => 'The name of the SVG file to import.' },
+ { name => 'file', type => 'file',
+ desc => 'The SVG file to import.' },
{ name => 'merge', type => 'boolean',
desc => 'Merge paths into a single vectors object.' },
{ name => 'scale', type => 'boolean',
@@ -1107,7 +1106,6 @@ HELP
headers => [ qw("vectors/gimpvectors-import.h") ],
code => <<'CODE'
{
- GFile *file = g_file_new_for_path (filename);
GList *vectors_list = NULL;
/* FIXME tree */
@@ -1115,8 +1113,6 @@ HELP
merge, scale, NULL, -1,
&vectors_list, error);
- g_object_unref (file);
-
if (success)
{
num_vectors = g_list_length (vectors_list);
@@ -1227,9 +1223,8 @@ HELP
@inargs = (
{ name => 'image', type => 'image',
desc => 'The image' },
- { name => 'filename', type => 'string', allow_non_utf8 => 1,
- non_empty => 1,
- desc => 'The name of the SVG file to create.' },
+ { name => 'file', type => 'file',
+ desc => 'The SVG file to create.' },
{ name => 'vectors', type => 'vectors', no_validate => 1,
desc => 'The vectors object to be saved, or 0 for all in the image' }
);
@@ -1238,11 +1233,7 @@ HELP
headers => [ qw("vectors/gimpvectors-export.h") ],
code => <<'CODE'
{
- GFile *file = g_file_new_for_path (filename);
-
success = gimp_vectors_export_file (image, vectors, file, error);
-
- g_object_unref (file);
}
CODE
);
diff --git a/pdb/pdb.pl b/pdb/pdb.pl
index 5925809ba4..f6eb4e9a8d 100644
--- a/pdb/pdb.pl
+++ b/pdb/pdb.pl
@@ -322,6 +322,17 @@ package Gimp::CodeGen::pdb;
take_value_func => 'g_value_set_object ($value, $var)',
headers => [ qw("vectors/gimpvectors.h") ] },
+ file => { name => 'FILE',
+ gtype => 'G_TYPE_FILE',
+ type => 'GFile *',
+ const_type => 'GFile *',
+ init_value => 'NULL',
+ out_annotate => '(transfer full)',
+ get_value_func => '$var = g_value_get_object ($value)',
+ dup_value_func => '$var = GIMP_VALUES_DUP_FILE ($value)',
+ set_value_func => 'g_value_set_object ($value, $var)',
+ take_value_func => 'g_value_set_object ($value, $var)' },
+
parasite => { name => 'PARASITE',
gtype => 'GIMP_TYPE_PARASITE',
type => 'GimpParasite *',
diff --git a/plug-ins/common/Makefile.am b/plug-ins/common/Makefile.am
index 299be07e19..aa7dc474a3 100644
--- a/plug-ins/common/Makefile.am
+++ b/plug-ins/common/Makefile.am
@@ -1246,6 +1246,7 @@ guillotine_LDADD = \
$(libgimpbase) \
$(CAIRO_LIBS) \
$(GDK_PIXBUF_LIBS) \
+ $(GIO_LIBS) \
$(RT_LIBS) \
$(INTLLIBS) \
$(guillotine_RC)
diff --git a/plug-ins/common/compose.c b/plug-ins/common/compose.c
index fe6ca9c6cf..e37cc34159 100644
--- a/plug-ins/common/compose.c
+++ b/plug-ins/common/compose.c
@@ -162,7 +162,7 @@ static GimpImage * compose (const gchar *compose_type,
ComposeInput *inputs,
gboolean compose_by_drawable);
-static GimpImage * create_new_image (const gchar *filename,
+static GimpImage * create_new_image (GFile *file,
guint width,
guint height,
GimpImageType gdtype,
@@ -1035,7 +1035,7 @@ compose (const gchar *compose_type,
gdtype_dst = ((babl_model (compose_dsc[compose_idx].babl_model) == babl_model ("RGBA")) ?
GIMP_RGBA_IMAGE : GIMP_RGB_IMAGE);
- image_dst = create_new_image (compose_dsc[compose_idx].filename,
+ image_dst = create_new_image (g_file_new_for_path (compose_dsc[compose_idx].filename),
width, height, gdtype_dst, precision,
&layer_dst, &buffer_dst);
}
@@ -1077,7 +1077,7 @@ compose (const gchar *compose_type,
/* Create an image. Sets layer_ID, drawable and rgn. Returns image */
static GimpImage *
-create_new_image (const gchar *filename,
+create_new_image (GFile *file,
guint width,
guint height,
GimpImageType gdtype,
@@ -1098,7 +1098,7 @@ create_new_image (const gchar *filename,
image = gimp_image_new_with_precision (width, height, gitype, precision);
gimp_image_undo_disable (image);
- gimp_image_set_filename (image, filename);
+ gimp_image_set_file (image, file);
*layer = gimp_layer_new (image, _("Background"), width, height,
gdtype,
diff --git a/plug-ins/common/decompose.c b/plug-ins/common/decompose.c
index 1931a53e06..e49510f1dd 100644
--- a/plug-ins/common/decompose.c
+++ b/plug-ins/common/decompose.c
@@ -115,7 +115,7 @@ static gint decompose (GimpImage *image,
GimpImage **image_dst,
gint32 *num_layers,
GimpLayer **layer_dst);
-static GimpImage * create_new_image (const gchar *filename,
+static GimpImage * create_new_image (GFile *file,
const gchar *layername,
guint width,
guint height,
@@ -543,7 +543,8 @@ decompose (GimpImage *image,
layername = gettext (extract[extract_idx].component[j].channel_name);
if (j == 0)
- image_dst[j] = create_new_image (filename, layername,
+ image_dst[j] = create_new_image (g_file_new_for_path (filename),
+ layername,
width, height, GIMP_GRAY, precision,
xres, yres,
layer_dst + j);
@@ -553,7 +554,8 @@ decompose (GimpImage *image,
}
else
{
- image_dst[j] = create_new_image (filename, NULL,
+ image_dst[j] = create_new_image (g_file_new_for_path (filename),
+ NULL,
width, height, GIMP_GRAY, precision,
xres, yres,
layer_dst + j);
@@ -587,7 +589,7 @@ decompose (GimpImage *image,
/* Create an image. Returns layer and image */
static GimpImage *
-create_new_image (const gchar *filename,
+create_new_image (GFile *file,
const gchar *layername,
guint width,
guint height,
@@ -602,7 +604,7 @@ create_new_image (const gchar *filename,
image = gimp_image_new_with_precision (width, height, type, precision);
gimp_image_undo_disable (image);
- gimp_image_set_filename (image, filename);
+ gimp_image_set_file (image, file);
gimp_image_set_resolution (image, xres, yres);
*layer = create_new_layer (image, 0,
@@ -968,7 +970,7 @@ generate_filename (GimpImage *image,
gchar *filename;
gchar *extension;
- fname = gimp_image_get_filename (image);
+ fname = g_file_get_path (gimp_image_get_file (image));
if (fname)
{
diff --git a/plug-ins/common/file-cel.c b/plug-ins/common/file-cel.c
index 80755d2b5e..5881e464b3 100644
--- a/plug-ins/common/file-cel.c
+++ b/plug-ins/common/file-cel.c
@@ -73,18 +73,18 @@ static GimpValueArray * cel_save (GimpProcedure *procedure,
const GimpValueArray *args,
gpointer run_data);
-static gint load_palette (const gchar *file,
+static gint load_palette (GFile *file,
FILE *fp,
guchar palette[],
GError **error);
-static GimpImage * load_image (const gchar *file,
+static GimpImage * load_image (GFile *file,
GError **error);
static gboolean save_image (GFile *file,
GimpImage *image,
GimpDrawable *drawable,
GError **error);
static void palette_dialog (const gchar *title);
-static gboolean need_palette (const gchar *file,
+static gboolean need_palette (GFile *file,
GError **error);
@@ -235,7 +235,7 @@ cel_load (GimpProcedure *procedure,
else if (run_mode == GIMP_RUN_INTERACTIVE)
{
/* Let user choose KCF palette (cancel ignores) */
- needs_palette = need_palette (g_file_get_path (file), &error);
+ needs_palette = need_palette (file, &error);
if (! error)
{
@@ -248,8 +248,7 @@ cel_load (GimpProcedure *procedure,
if (! error)
{
- image = load_image (g_file_get_path (file),
- &error);
+ image = load_image (file, &error);
}
if (! image)
@@ -324,19 +323,23 @@ cel_save (GimpProcedure *procedure,
/* Peek into the file to determine whether we need a palette */
static gboolean
-need_palette (const gchar *file,
- GError **error)
+need_palette (GFile *file,
+ GError **error)
{
+ gchar *filename;
FILE *fp;
guchar header[32];
size_t n_read;
- fp = g_fopen (file, "rb");
- if (fp == NULL)
+ filename = g_file_get_path (file);
+ fp = g_fopen (filename, "rb");
+ g_free (filename);
+
+ if (! fp)
{
g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errno),
_("Could not open '%s' for reading: %s"),
- gimp_filename_to_utf8 (file), g_strerror (errno));
+ gimp_file_get_utf8_name (file), g_strerror (errno));
return FALSE;
}
@@ -357,9 +360,10 @@ need_palette (const gchar *file,
/* Load CEL image into GIMP */
static GimpImage *
-load_image (const gchar *file,
- GError **error)
+load_image (GFile *file,
+ GError **error)
{
+ gchar *filename;
FILE *fp; /* Read file pointer */
guchar header[32], /* File header */
file_mark, /* KiSS file type */
@@ -378,16 +382,18 @@ load_image (const gchar *file,
size_t n_read; /* Number of items read from file */
gimp_progress_init_printf (_("Opening '%s'"),
- gimp_filename_to_utf8 (file));
+ gimp_file_get_utf8_name (file));
/* Open the file for reading */
- fp = g_fopen (file, "r");
+ filename = g_file_get_path (file);
+ fp = g_fopen (filename, "r");
+ g_free (filename);
if (fp == NULL)
{
g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errno),
_("Could not open '%s' for reading: %s"),
- gimp_filename_to_utf8 (file), g_strerror (errno));
+ gimp_file_get_utf8_name (file), g_strerror (errno));
return NULL;
}
@@ -477,7 +483,7 @@ load_image (const gchar *file,
return NULL;
}
- gimp_image_set_filename (image, file);
+ gimp_image_set_file (image, file);
/* Create an indexed-alpha layer to hold the image... */
if (bpp == 32)
@@ -635,7 +641,7 @@ load_image (const gchar *file,
if (fp != NULL)
{
- colors = load_palette (palette_file, fp, palette, error);
+ colors = load_palette (g_file_new_for_path (palette_file), fp, palette, error);
fclose (fp);
if (colors < 0 || *error)
return NULL;
@@ -661,7 +667,7 @@ load_image (const gchar *file,
}
static gint
-load_palette (const gchar *file,
+load_palette (GFile *file,
FILE *fp,
guchar palette[],
GError **error)
@@ -678,7 +684,7 @@ load_palette (const gchar *file,
{
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
_("'%s': EOF or error while reading palette header"),
- gimp_filename_to_utf8 (file));
+ gimp_file_get_utf8_name (file));
return -1;
}
@@ -690,7 +696,7 @@ load_palette (const gchar *file,
{
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
_("'%s': EOF or error while reading palette header"),
- gimp_filename_to_utf8 (file));
+ gimp_file_get_utf8_name (file));
return -1;
}
@@ -699,7 +705,7 @@ load_palette (const gchar *file,
{
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
_("'%s': is not a KCF palette file"),
- gimp_filename_to_utf8 (file));
+ gimp_file_get_utf8_name (file));
return -1;
}
@@ -708,7 +714,7 @@ load_palette (const gchar *file,
{
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
_("'%s': illegal bpp value in palette: %hhu"),
- gimp_filename_to_utf8 (file), bpp);
+ gimp_file_get_utf8_name (file), bpp);
return -1;
}
@@ -717,7 +723,7 @@ load_palette (const gchar *file,
{
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
_("'%s': illegal number of colors: %u"),
- gimp_filename_to_utf8 (file), colors);
+ gimp_file_get_utf8_name (file), colors);
return -1;
}
@@ -733,7 +739,7 @@ load_palette (const gchar *file,
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
_("'%s': EOF or error while reading "
"palette data"),
- gimp_filename_to_utf8 (file));
+ gimp_file_get_utf8_name (file));
return -1;
}
@@ -749,7 +755,7 @@ load_palette (const gchar *file,
{
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
_("'%s': EOF or error while reading palette data"),
- gimp_filename_to_utf8 (file));
+ gimp_file_get_utf8_name (file));
return -1;
}
break;
@@ -769,7 +775,7 @@ load_palette (const gchar *file,
{
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
_("'%s': EOF or error while reading palette data"),
- gimp_filename_to_utf8 (file));
+ gimp_file_get_utf8_name (file));
return -1;
}
diff --git a/plug-ins/common/file-compressor.c b/plug-ins/common/file-compressor.c
index bc7899714d..4a2eda66e6 100644
--- a/plug-ins/common/file-compressor.c
+++ b/plug-ins/common/file-compressor.c
@@ -166,13 +166,13 @@ static GimpValueArray * compressor_load (GimpProcedure *proce
const GimpValueArray *args,
gpointer run_data);
-static GimpImage * load_image (const CompressorEntry *compressor,
- const gchar *filename,
- gint32 run_mode,
- GimpPDBStatusType *status,
- GError **error);
+static GimpImage * load_image (const CompressorEntry *compressor,
+ GFile *file,
+ gint32 run_mode,
+ GimpPDBStatusType *status,
+ GError **error);
static GimpPDBStatusType save_image (const CompressorEntry *compressor,
- const gchar *filename,
+ GFile *file,
GimpImage *image,
GimpDrawable *drawable,
gint32 run_mode,
@@ -369,7 +369,6 @@ compressor_load (GimpProcedure *procedure,
const CompressorEntry *compressor = run_data;
GimpValueArray *return_vals;
GimpPDBStatusType status;
- gchar *filename;
GimpImage *image;
GError *error = NULL;
@@ -379,13 +378,9 @@ compressor_load (GimpProcedure *procedure,
gimp_plug_in_set_pdb_error_handler (gimp_procedure_get_plug_in (procedure),
GIMP_PDB_ERROR_HANDLER_PLUGIN);
- filename = g_file_get_path (file);
-
- image = load_image (compressor, filename, run_mode,
+ image = load_image (compressor, file, run_mode,
&status, &error);
- g_free (filename);
-
return_vals = gimp_procedure_new_return_values (procedure, status, error);
if (image && status == GIMP_PDB_SUCCESS)
@@ -405,7 +400,6 @@ compressor_save (GimpProcedure *procedure,
{
const CompressorEntry *compressor = run_data;
GimpPDBStatusType status;
- gchar *filename;
GError *error = NULL;
/* We handle PDB errors by forwarding them to the caller in
@@ -414,24 +408,21 @@ compressor_save (GimpProcedure *procedure,
gimp_plug_in_set_pdb_error_handler (gimp_procedure_get_plug_in (procedure),
GIMP_PDB_ERROR_HANDLER_PLUGIN);
- filename = g_file_get_path (file);
-
- status = save_image (compressor, filename, image, drawable, run_mode,
+ status = save_image (compressor, file, image, drawable, run_mode,
&error);
- g_free (filename);
-
return gimp_procedure_new_return_values (procedure, status, error);
}
static GimpPDBStatusType
save_image (const CompressorEntry *compressor,
- const gchar *filename,
+ GFile *file,
GimpImage *image,
GimpDrawable *drawable,
gint32 run_mode,
GError **error)
{
+ gchar *filename = g_file_get_path (file);
const gchar *ext;
gchar *tmpname;
@@ -450,10 +441,12 @@ save_image (const CompressorEntry *compressor,
if (! (gimp_file_save (run_mode,
image,
drawable,
- tmpname) && valid_file (tmpname)))
+ g_file_new_for_path (tmpname)) &&
+ valid_file (tmpname)))
{
g_unlink (tmpname);
g_free (tmpname);
+ g_free (filename);
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
"%s", gimp_pdb_get_last_error (gimp_get_pdb ()));
@@ -462,12 +455,13 @@ save_image (const CompressorEntry *compressor,
}
gimp_progress_init_printf (_("Compressing '%s'"),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
- if (!compressor->save_fn (tmpname, filename))
+ if (! compressor->save_fn (tmpname, filename))
{
g_unlink (tmpname);
g_free (tmpname);
+ g_free (filename);
return GIMP_PDB_EXECUTION_ERROR;
}
@@ -478,22 +472,27 @@ save_image (const CompressorEntry *compressor,
/* ask the core to save a thumbnail for compressed XCF files */
if (strcmp (ext, ".xcf") == 0)
- gimp_file_save_thumbnail (image, filename);
+ gimp_file_save_thumbnail (image, file);
+
+ g_free (filename);
return GIMP_PDB_SUCCESS;
}
static GimpImage *
load_image (const CompressorEntry *compressor,
- const gchar *filename,
+ GFile *file,
gint32 run_mode,
GimpPDBStatusType *status,
GError **error)
{
GimpImage *image;
+ gchar *filename;
const gchar *ext;
gchar *tmpname;
+ filename = g_file_get_path (file);
+
ext = find_extension (compressor, filename);
if (! ext)
@@ -506,16 +505,19 @@ load_image (const CompressorEntry *compressor,
/* find a temp name */
tmpname = gimp_temp_name (ext + 1);
- if (!compressor->load_fn (filename, tmpname))
+ if (! compressor->load_fn (filename, tmpname))
{
g_free (tmpname);
+ g_free (filename);
*status = GIMP_PDB_EXECUTION_ERROR;
return NULL;
}
+ g_free (filename);
+
/* now that we uncompressed it, load the temp file */
- image = gimp_file_load (run_mode, tmpname);
+ image = gimp_file_load (run_mode, g_file_new_for_path (tmpname));
g_unlink (tmpname);
g_free (tmpname);
@@ -524,7 +526,7 @@ load_image (const CompressorEntry *compressor,
{
*status = GIMP_PDB_SUCCESS;
- gimp_image_set_filename (image, filename);
+ gimp_image_set_file (image, file);
}
else
{
diff --git a/plug-ins/common/file-desktop-link.c b/plug-ins/common/file-desktop-link.c
index 7c41dffac0..73f041c2f1 100644
--- a/plug-ins/common/file-desktop-link.c
+++ b/plug-ins/common/file-desktop-link.c
@@ -187,7 +187,7 @@ load_image (GFile *file,
value = g_key_file_get_value (key_file,
group, G_KEY_FILE_DESKTOP_KEY_URL, &error);
if (value)
- image = gimp_file_load (run_mode, value);
+ image = gimp_file_load (run_mode, g_file_new_for_uri (value));
out:
if (error)
diff --git a/plug-ins/common/file-dicom.c b/plug-ins/common/file-dicom.c
index 0fa85bce55..a491227cff 100644
--- a/plug-ins/common/file-dicom.c
+++ b/plug-ins/common/file-dicom.c
@@ -96,9 +96,9 @@ static GimpValueArray * dicom_save (GimpProcedure *procedure,
const GimpValueArray *args,
gpointer run_data);
-static GimpImage * load_image (const gchar *filename,
+static GimpImage * load_image (GFile *file,
GError **error);
-static gboolean save_image (const gchar *filename,
+static gboolean save_image (GFile *file,
GimpImage *image,
GimpDrawable *drawable,
GError **error);
@@ -240,7 +240,7 @@ dicom_load (GimpProcedure *procedure,
INIT_I18N ();
gegl_init (NULL, NULL);
- image = load_image (g_file_get_path (file), &error);
+ image = load_image (file, &error);
if (! image)
return gimp_procedure_new_return_values (procedure,
@@ -293,8 +293,7 @@ dicom_save (GimpProcedure *procedure,
if (status == GIMP_PDB_SUCCESS)
{
- if (! save_image (g_file_get_path (file),
- image, drawable,
+ if (! save_image (file, image, drawable,
&error))
{
status = GIMP_PDB_EXECUTION_ERROR;
@@ -328,36 +327,39 @@ add_parasites_to_image (gpointer data,
}
static GimpImage *
-load_image (const gchar *filename,
- GError **error)
+load_image (GFile *file,
+ GError **error)
{
- GimpImage *image = NULL;
- GimpLayer *layer;
- GeglBuffer*buffer;
- GSList *elements = NULL;
- FILE *dicom;
- gchar buf[500]; /* buffer for random things like scanning */
- DicomInfo *dicominfo;
- guint width = 0;
- guint height = 0;
- gint samples_per_pixel = 0;
- gint bpp = 0;
- gint bits_stored = 0;
- gint high_bit = 0;
- guint8 *pix_buf = NULL;
- gboolean is_signed = FALSE;
- guint8 in_sequence = 0;
+ GimpImage *image = NULL;
+ GimpLayer *layer;
+ GeglBuffer *buffer;
+ gchar *filename;
+ GSList *elements = NULL;
+ FILE *dicom;
+ gchar buf[500]; /* buffer for random things like scanning */
+ DicomInfo *dicominfo;
+ guint width = 0;
+ guint height = 0;
+ gint samples_per_pixel = 0;
+ gint bpp = 0;
+ gint bits_stored = 0;
+ gint high_bit = 0;
+ guint8 *pix_buf = NULL;
+ gboolean is_signed = FALSE;
+ guint8 in_sequence = 0;
gimp_progress_init_printf (_("Opening '%s'"),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
+ filename = g_file_get_path (file);
dicom = g_fopen (filename, "rb");
+ g_free (filename);
if (! dicom)
{
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));
+ gimp_file_get_utf8_name (file), g_strerror (errno));
return NULL;
}
@@ -372,7 +374,7 @@ load_image (const gchar *filename,
{
g_message ("'%s' is a PAPYRUS DICOM file.\n"
"This plug-in does not support this type yet.",
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
g_free (dicominfo);
fclose (dicom);
return NULL;
@@ -383,7 +385,7 @@ load_image (const gchar *filename,
{
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
_("'%s' is not a DICOM file."),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
g_free (dicominfo);
fclose (dicom);
return NULL;
@@ -489,7 +491,7 @@ load_image (const gchar *filename,
if (element_length >= (G_MAXUINT - 6))
{
g_message ("'%s' seems to have an incorrect value field length.",
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
gimp_quit ();
}
@@ -590,21 +592,21 @@ load_image (const gchar *filename,
if ((bpp != 8) && (bpp != 16))
{
g_message ("'%s' has a bpp of %d which GIMP cannot handle.",
- gimp_filename_to_utf8 (filename), bpp);
+ gimp_file_get_utf8_name (file), bpp);
gimp_quit ();
}
if ((width > GIMP_MAX_IMAGE_SIZE) || (height > GIMP_MAX_IMAGE_SIZE))
{
g_message ("'%s' has a larger image size (%d x %d) than GIMP can handle.",
- gimp_filename_to_utf8 (filename), width, height);
+ gimp_file_get_utf8_name (file), width, height);
gimp_quit ();
}
if (samples_per_pixel > 3)
{
g_message ("'%s' has samples per pixel of %d which GIMP cannot handle.",
- gimp_filename_to_utf8 (filename), samples_per_pixel);
+ gimp_file_get_utf8_name (file), samples_per_pixel);
gimp_quit ();
}
@@ -623,7 +625,7 @@ load_image (const gchar *filename,
image = gimp_image_new (dicominfo->width, dicominfo->height,
(dicominfo->samples_per_pixel >= 3 ?
GIMP_RGB : GIMP_GRAY));
- gimp_image_set_filename (image, filename);
+ gimp_image_set_file (image, file);
layer = gimp_layer_new (image, _("Background"),
dicominfo->width, dicominfo->height,
@@ -1321,11 +1323,12 @@ dicom_ensure_required_elements_present (GSList *elements,
* must just be filled with dummy values.
*/
static gboolean
-save_image (const gchar *filename,
+save_image (GFile *file,
GimpImage *image,
GimpDrawable *drawable,
GError **error)
{
+ gchar *filename;
FILE *dicom;
GimpImageType drawable_type;
GeglBuffer *buffer;
@@ -1380,13 +1383,15 @@ save_image (const gchar *filename,
g_date_free (date);
/* Open the output file. */
+ filename = g_file_get_path (file);
dicom = g_fopen (filename, "wb");
+ g_free (filename);
if (! dicom)
{
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));
return FALSE;
}
diff --git a/plug-ins/common/file-gegl.c b/plug-ins/common/file-gegl.c
index 1c81259caa..574e2b3336 100644
--- a/plug-ins/common/file-gegl.c
+++ b/plug-ins/common/file-gegl.c
@@ -89,9 +89,9 @@ static GimpValueArray * goat_save (GimpProcedure *procedure,
const GimpValueArray *args,
gpointer run_data);
-static GimpImage * load_image (const gchar *filename,
+static GimpImage * load_image (GFile *file,
GError **error);
-static gboolean save_image (const gchar *filename,
+static gboolean save_image (GFile *file,
GimpImage *image,
GimpDrawable *drawable,
GError **error);
@@ -240,7 +240,7 @@ goat_load (GimpProcedure *procedure,
INIT_I18N ();
gegl_init (NULL, NULL);
- image = load_image (g_file_get_path (file), &error);
+ image = load_image (file, &error);
if (! image)
return gimp_procedure_new_return_values (procedure,
@@ -294,8 +294,7 @@ goat_save (GimpProcedure *procedure,
break;
}
- if (! save_image (g_file_get_path (file),
- image, drawable,
+ if (! save_image (file, image, drawable,
&error))
{
status = GIMP_PDB_EXECUTION_ERROR;
@@ -308,11 +307,12 @@ goat_save (GimpProcedure *procedure,
}
static GimpImage *
-load_image (const gchar *filename,
- GError **error)
+load_image (GFile *file,
+ GError **error)
{
GimpImage *image;
GimpLayer *layer;
+ gchar *filename;
GimpImageType image_type;
GimpImageBaseType base_type;
GimpPrecision precision;
@@ -325,8 +325,10 @@ load_image (const gchar *filename,
GeglBuffer *dest_buf = NULL;
const Babl *format;
+ filename = g_file_get_path (file);
+
gimp_progress_init_printf (_("Opening '%s'"),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
graph = gegl_node_new ();
@@ -350,7 +352,7 @@ load_image (const gchar *filename,
{
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
_("Could not open '%s'"),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
return NULL;
}
@@ -438,7 +440,7 @@ load_image (const gchar *filename,
image = gimp_image_new_with_precision (width, height,
base_type, precision);
- gimp_image_set_filename (image, filename);
+ gimp_image_set_file (image, file);
layer = gimp_layer_new (image,
_("Background"),
@@ -463,16 +465,19 @@ load_image (const gchar *filename,
}
static gboolean
-save_image (const gchar *filename,
+save_image (GFile *file,
GimpImage *image,
GimpDrawable *drawable,
GError **error)
{
+ gchar *filename;
GeglNode *graph;
GeglNode *source;
GeglNode *sink;
GeglBuffer *src_buf;
+ filename = g_file_get_path (file);
+
src_buf = gimp_drawable_get_buffer (drawable);
graph = gegl_node_new ();
diff --git a/plug-ins/common/file-gif-load.c b/plug-ins/common/file-gif-load.c
index 01686f126e..d88713185a 100644
--- a/plug-ins/common/file-gif-load.c
+++ b/plug-ins/common/file-gif-load.c
@@ -117,7 +117,7 @@ static GimpValueArray * gif_load_thumb (GimpProcedure *procedure,
const GimpValueArray *args,
gpointer run_data);
-static GimpImage * load_image (const gchar *filename,
+static GimpImage * load_image (GFile *file,
gboolean thumbnail,
GError **error);
@@ -225,18 +225,13 @@ gif_load (GimpProcedure *procedure,
gpointer run_data)
{
GimpValueArray *return_vals;
- gchar *filename;
GimpImage *image;
GError *error = NULL;
INIT_I18N ();
gegl_init (NULL, NULL);
- filename = g_file_get_path (file);
-
- image = load_image (filename, FALSE, &error);
-
- g_free (filename);
+ image = load_image (file, FALSE, &error);
if (! image)
return gimp_procedure_new_return_values (procedure,
@@ -284,7 +279,7 @@ gif_load_thumb (GimpProcedure *procedure,
INIT_I18N ();
gegl_init (NULL, NULL);
- image = load_image (g_file_get_path (file), TRUE, &error);
+ image = load_image (file, TRUE, &error);
if (! image)
return gimp_procedure_new_return_values (procedure,
@@ -366,7 +361,7 @@ static gint LZWReadByte (FILE *fd,
gint just_reset_LZW,
gint input_code_size);
static gboolean ReadImage (FILE *fd,
- const gchar *filename,
+ GFile *file,
gint len,
gint height,
CMap cmap,
@@ -382,11 +377,12 @@ static gboolean ReadImage (FILE *fd,
static GimpImage *
-load_image (const gchar *filename,
- gboolean thumbnail,
- GError **error)
+load_image (GFile *file,
+ gboolean thumbnail,
+ GError **error)
{
FILE *fd;
+ gchar *filename;
guchar buf[16];
guchar c;
CMap localColorMap;
@@ -399,15 +395,17 @@ load_image (const gchar *filename,
gboolean status;
gimp_progress_init_printf (_("Opening '%s'"),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
+ filename = g_file_get_path (file);
fd = g_fopen (filename, "rb");
+ g_free (filename);
if (! fd)
{
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));
+ gimp_file_get_utf8_name (file), g_strerror (errno));
return NULL;
}
@@ -528,7 +526,7 @@ load_image (const gchar *filename,
return image; /* will be NULL if failed on first image! */
}
- status = ReadImage (fd, filename, LM_to_uint (buf[4], buf[5]),
+ status = ReadImage (fd, file, LM_to_uint (buf[4], buf[5]),
LM_to_uint (buf[6], buf[7]),
localColorMap, bitPixel,
grayScale,
@@ -541,7 +539,7 @@ load_image (const gchar *filename,
}
else
{
- status = ReadImage (fd, filename, LM_to_uint (buf[4], buf[5]),
+ status = ReadImage (fd, file, LM_to_uint (buf[4], buf[5]),
LM_to_uint (buf[6], buf[7]),
GifScreen.ColorMap, GifScreen.BitPixel,
GifScreen.GrayScale,
@@ -960,7 +958,7 @@ LZWReadByte (FILE *fd,
static gboolean
ReadImage (FILE *fd,
- const gchar *filename,
+ GFile *file,
gint len,
gint height,
CMap cmap,
@@ -1024,7 +1022,7 @@ ReadImage (FILE *fd,
screenheight = height;
*image = gimp_image_new (screenwidth, screenheight, GIMP_INDEXED);
- gimp_image_set_filename (*image, filename);
+ gimp_image_set_file (*image, file);
for (i = 0, j = 0; i < ncols; i++)
{
@@ -1066,7 +1064,7 @@ ReadImage (FILE *fd,
else /* NOT FIRST FRAME */
{
gimp_progress_set_text_printf (_("Opening '%s' (frame %d)"),
- gimp_filename_to_utf8 (filename),
+ gimp_file_get_utf8_name (file),
frame_number);
gimp_progress_pulse ();
@@ -1159,7 +1157,7 @@ ReadImage (FILE *fd,
if (len > (G_MAXSIZE / height / (alpha_frame ? (promote_to_rgb ? 4 : 2) : 1)))
{
g_message ("'%s' has a larger image size than GIMP can handle.",
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
gimp_image_delete (*image);
*image = NULL;
return FALSE;
diff --git a/plug-ins/common/file-heif.c b/plug-ins/common/file-heif.c
index 8c1433694a..84e6399531 100644
--- a/plug-ins/common/file-heif.c
+++ b/plug-ins/common/file-heif.c
@@ -559,7 +559,7 @@ load_image (GFile *file,
*/
image = gimp_image_new (width, height, GIMP_RGB);
- gimp_image_set_filename (image, g_file_get_uri (file));
+ gimp_image_set_file (image, file);
if (profile)
gimp_image_set_color_profile (image, profile);
diff --git a/plug-ins/common/file-jp2-load.c b/plug-ins/common/file-jp2-load.c
index 7ba3eea8b2..178a398e76 100644
--- a/plug-ins/common/file-jp2-load.c
+++ b/plug-ins/common/file-jp2-load.c
@@ -123,14 +123,14 @@ static GimpValueArray * jp2_load (GimpProcedure *procedure,
const GimpValueArray *args,
gpointer run_data);
-static GimpImage * load_image (const gchar *filename,
+static GimpImage * load_image (GFile *file,
OPJ_CODEC_FORMAT format,
OPJ_COLOR_SPACE color_space,
gboolean interactive,
gboolean *profile_loaded,
GError **error);
-static OPJ_COLOR_SPACE open_dialog (const gchar *filename,
+static OPJ_COLOR_SPACE open_dialog (GFile *file,
OPJ_CODEC_FORMAT format,
gint num_components,
GError **error);
@@ -304,13 +304,13 @@ jp2_load (GimpProcedure *procedure,
if (! strcmp (gimp_procedure_get_name (procedure), LOAD_JP2_PROC))
{
- image = load_image (g_file_get_path (file), OPJ_CODEC_JP2,
+ image = load_image (file, OPJ_CODEC_JP2,
color_space, interactive, &profile_loaded,
&error);
}
else
{
- image = load_image (g_file_get_path (file), OPJ_CODEC_J2K,
+ image = load_image (file, OPJ_CODEC_J2K,
color_space, interactive, &profile_loaded,
&error);
}
@@ -948,7 +948,7 @@ get_image_precision (gint precision,
}
static OPJ_COLOR_SPACE
-open_dialog (const gchar *filename,
+open_dialog (GFile *file,
OPJ_CODEC_FORMAT format,
gint num_components,
GError **error)
@@ -1017,7 +1017,7 @@ open_dialog (const gchar *filename,
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
_("Unsupported JPEG 2000%s '%s' with %d components."),
(format == OPJ_CODEC_J2K) ? " codestream" : "",
- gimp_filename_to_utf8 (filename), num_components);
+ gimp_file_get_utf8_name (file), num_components);
color_space = OPJ_CLRSPC_UNKNOWN;
}
@@ -1051,13 +1051,14 @@ open_dialog (const gchar *filename,
}
static GimpImage *
-load_image (const gchar *filename,
+load_image (GFile *file,
OPJ_CODEC_FORMAT format,
OPJ_COLOR_SPACE color_space,
gboolean interactive,
gboolean *profile_loaded,
GError **error)
{
+ gchar *filename;
opj_stream_t *stream = NULL;
opj_codec_t *codec = NULL;
opj_dparameters_t parameters;
@@ -1082,14 +1083,17 @@ load_image (const gchar *filename,
unsigned char *c = NULL;
gimp_progress_init_printf (_("Opening '%s'"),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
+ filename = g_file_get_path (file);
stream = opj_stream_create_default_file_stream (filename, OPJ_TRUE);
+ g_free (filename);
+
if (! stream)
{
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
_("Could not open '%s' for reading"),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
goto out;
}
@@ -1100,7 +1104,7 @@ load_image (const gchar *filename,
{
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
_("Couldn't set parameters on decoder for '%s'."),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
goto out;
}
@@ -1108,7 +1112,7 @@ load_image (const gchar *filename,
{
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
_("Couldn't read JP2 header from '%s'."),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
goto out;
}
@@ -1116,7 +1120,7 @@ load_image (const gchar *filename,
{
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
_("Couldn't decode JP2 image in '%s'."),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
goto out;
}
@@ -1124,7 +1128,7 @@ load_image (const gchar *filename,
{
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
_("Couldn't decompress JP2 image in '%s'."),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
goto out;
}
@@ -1155,7 +1159,7 @@ load_image (const gchar *filename,
{
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
_("Couldn't decode CIELAB JP2 image in '%s'."),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
goto out;
}
@@ -1197,7 +1201,7 @@ load_image (const gchar *filename,
}
else if (interactive)
{
- image->color_space = open_dialog (filename, format,
+ image->color_space = open_dialog (file, format,
num_components, error);
if (image->color_space == OPJ_CLRSPC_UNKNOWN)
@@ -1212,7 +1216,7 @@ load_image (const gchar *filename,
*/
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
_("Unknown color space in JP2 codestream '%s'."),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
goto out;
}
}
@@ -1223,7 +1227,7 @@ load_image (const gchar *filename,
{
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
_("Couldn't convert YCbCr JP2 image '%s' to RGB."),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
goto out;
}
}
@@ -1233,7 +1237,7 @@ load_image (const gchar *filename,
{
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
_("Couldn't convert CMYK JP2 image in '%s' to RGB."),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
goto out;
}
}
@@ -1243,7 +1247,7 @@ load_image (const gchar *filename,
{
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
_("Couldn't convert xvYCC JP2 image in '%s' to RGB."),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
goto out;
}
}
@@ -1270,7 +1274,7 @@ load_image (const gchar *filename,
/* If not gray or RGB, this is an image we cannot handle. */
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
_("Unsupported color space in JP2 image '%s'."),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
goto out;
}
@@ -1288,7 +1292,7 @@ load_image (const gchar *filename,
gimp_image = gimp_image_new_with_precision (width, height,
base_type, image_precision);
- gimp_image_set_filename (gimp_image, filename);
+ gimp_image_set_file (gimp_image, file);
if (profile)
gimp_image_set_color_profile (gimp_image, profile);
diff --git a/plug-ins/common/file-pcx.c b/plug-ins/common/file-pcx.c
index b888e19ecc..c8a00c8712 100644
--- a/plug-ins/common/file-pcx.c
+++ b/plug-ins/common/file-pcx.c
@@ -74,7 +74,7 @@ static GimpValueArray * pcx_save (GimpProcedure *procedure,
const GimpValueArray *args,
gpointer run_data);
-static GimpImage * load_image (const gchar *filename,
+static GimpImage * load_image (GFile *file,
GError **error);
static void load_1 (FILE *fp,
@@ -108,7 +108,7 @@ static void readline (FILE *fp,
guchar *buf,
gint bytes);
-static gboolean save_image (const gchar *filename,
+static gboolean save_image (GFile *file,
GimpImage *image,
GimpDrawable *drawable,
GError **error);
@@ -235,7 +235,7 @@ pcx_load (GimpProcedure *procedure,
INIT_I18N ();
gegl_init (NULL, NULL);
- image = load_image (g_file_get_path (file), &error);
+ image = load_image (file, &error);
if (! image)
return gimp_procedure_new_return_values (procedure,
@@ -288,7 +288,7 @@ pcx_save (GimpProcedure *procedure,
break;
}
- if (! save_image (g_file_get_path (file),
+ if (! save_image (file,
image, drawable,
&error))
{
@@ -371,11 +371,12 @@ pcx_header_to_buffer (guint8 *buf)
}
static GimpImage *
-load_image (const gchar *filename,
- GError **error)
+load_image (GFile *file,
+ GError **error)
{
FILE *fd;
GeglBuffer *buffer;
+ gchar *filename;
guint16 offset_x, offset_y, bytesperline;
gint32 width, height;
guint16 resolution_x, resolution_y;
@@ -385,15 +386,17 @@ load_image (const gchar *filename,
guint8 header_buf[128];
gimp_progress_init_printf (_("Opening '%s'"),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
+ filename = g_file_get_path (file);
fd = g_fopen (filename, "rb");
+ g_free (filename);
if (! fd)
{
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));
+ gimp_file_get_utf8_name (file), g_strerror (errno));
return NULL;
}
@@ -401,7 +404,7 @@ load_image (const gchar *filename,
{
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
_("Could not read header from '%s'"),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
fclose (fd);
return NULL;
}
@@ -412,7 +415,7 @@ load_image (const gchar *filename,
{
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
_("'%s' is not a PCX file"),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
fclose (fd);
return NULL;
}
@@ -476,7 +479,7 @@ load_image (const gchar *filename,
gimp_image_get_default_new_layer_mode (image));
}
- gimp_image_set_filename (image, filename);
+ gimp_image_set_file (image, file);
gimp_image_set_resolution (image, resolution_x, resolution_y);
gimp_image_insert_layer (image, layer, NULL, 0);
@@ -749,13 +752,14 @@ readline (FILE *fp,
}
static gboolean
-save_image (const gchar *filename,
+save_image (GFile *file,
GimpImage *image,
GimpDrawable *drawable,
GError **error)
{
FILE *fp;
GeglBuffer *buffer;
+ gchar *filename;
const Babl *format;
GimpImageType drawable_type;
guchar *cmap= NULL;
@@ -776,7 +780,7 @@ save_image (const gchar *filename,
height = gegl_buffer_get_height (buffer);
gimp_progress_init_printf (_("Exporting '%s'"),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
pcx_header.manufacturer = 0x0a;
pcx_header.version = 5;
@@ -885,11 +889,15 @@ save_image (const gchar *filename,
return FALSE;
}
- if ((fp = g_fopen (filename, "wb")) == NULL)
+ filename = g_file_get_path (file);
+ fp = g_fopen (filename, "wb");
+ g_free (filename);
+
+ if (! fp)
{
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));
return FALSE;
}
@@ -955,7 +963,7 @@ save_image (const gchar *filename,
{
g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errno),
_("Writing to file '%s' failed: %s"),
- gimp_filename_to_utf8 (filename), g_strerror (errno));
+ gimp_file_get_utf8_name (file), g_strerror (errno));
return FALSE;
}
diff --git a/plug-ins/common/file-pdf-load.c b/plug-ins/common/file-pdf-load.c
index d74a7259d3..9051d41a41 100644
--- a/plug-ins/common/file-pdf-load.c
+++ b/plug-ins/common/file-pdf-load.c
@@ -250,7 +250,7 @@ static GimpValueArray * pdf_load_thumb (GimpProcedure *procedure,
gpointer run_data);
static GimpImage * load_image (PopplerDocument *doc,
- const gchar *filename,
+ GFile *file,
GimpRunMode run_mode,
GimpPageSelectorTarget target,
guint32 resolution,
@@ -260,7 +260,7 @@ static GimpImage * load_image (PopplerDocument *doc,
static GimpPDBStatusType load_dialog (PopplerDocument *doc,
PdfSelectedPages *pages);
-static PopplerDocument * open_document (const gchar *filename,
+static PopplerDocument * open_document (GFile *file,
const gchar *PDF_password,
GimpRunMode run_mode,
GError **error);
@@ -408,7 +408,7 @@ pdf_load (GimpProcedure *procedure,
case GIMP_RUN_INTERACTIVE:
gimp_get_data (LOAD_PROC, &loadvals);
gimp_ui_init (PLUG_IN_BINARY, FALSE);
- doc = open_document (g_file_get_path (file),
+ doc = open_document (file,
loadvals.PDF_password,
run_mode, &error);
@@ -431,7 +431,7 @@ pdf_load (GimpProcedure *procedure,
break;
case GIMP_RUN_NONINTERACTIVE:
- doc = open_document (g_file_get_path (file),
+ doc = open_document (file,
GIMP_VALUES_GET_STRING (args, 0),
run_mode, &error);
@@ -506,7 +506,7 @@ pdf_load (GimpProcedure *procedure,
if (status == GIMP_PDB_SUCCESS)
{
image = load_image (doc,
- g_file_get_path (file),
+ file,
run_mode,
loadvals.target,
loadvals.resolution,
@@ -553,7 +553,7 @@ pdf_load_thumb (GimpProcedure *procedure,
INIT_I18N ();
gegl_init (NULL, NULL);
- doc = open_document (g_file_get_path (file),
+ doc = open_document (file,
NULL,
GIMP_RUN_NONINTERACTIVE,
&error);
@@ -614,17 +614,15 @@ pdf_load_thumb (GimpProcedure *procedure,
return return_vals;
}
-static PopplerDocument*
-open_document (const gchar *filename,
+static PopplerDocument *
+open_document (GFile *file,
const gchar *PDF_password,
GimpRunMode run_mode,
GError **load_error)
{
PopplerDocument *doc;
- GFile *file;
GError *error = NULL;
- file = g_file_new_for_path (filename);
doc = poppler_document_new_from_gfile (file, PDF_password, NULL, &error);
if (run_mode == GIMP_RUN_INTERACTIVE)
@@ -675,9 +673,9 @@ open_document (const gchar *filename,
break;
}
}
+
gtk_widget_destroy (label);
}
- g_object_unref (file);
/* We can't g_mapped_file_unref(mapped_file) as apparently doc has
* references to data in there. No big deal, this is just a
@@ -687,7 +685,7 @@ open_document (const gchar *filename,
{
g_set_error (load_error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
_("Could not load '%s': %s"),
- gimp_filename_to_utf8 (filename),
+ gimp_file_get_utf8_name (file),
error->message);
g_error_free (error);
return NULL;
@@ -784,7 +782,7 @@ render_page_to_pixbuf (PopplerPage *page,
static GimpImage *
load_image (PopplerDocument *doc,
- const gchar *filename,
+ GFile *file,
GimpRunMode run_mode,
GimpPageSelectorTarget target,
guint32 resolution,
@@ -801,7 +799,7 @@ load_image (PopplerDocument *doc,
images = g_new0 (GimpImage *, pages->n_pages);
gimp_progress_init_printf (_("Opening '%s'"),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
scale = resolution / gimp_unit_get_factor (GIMP_UNIT_POINT);
@@ -828,18 +826,29 @@ load_image (PopplerDocument *doc,
if (! image)
{
- gchar *name;
+ GFile *new_file;
+ gchar *uri;
+ gchar *new_uri;
image = gimp_image_new (width, height, GIMP_RGB);
gimp_image_undo_disable (image);
+ uri = g_file_get_uri (file);
+
if (target == GIMP_PAGE_SELECTOR_TARGET_IMAGES)
- name = g_strdup_printf (_("%s-%s"), filename, page_label);
+ new_uri = g_strdup_printf (_("%s-%s"), uri, page_label);
else
- name = g_strdup_printf (_("%s-pages"), filename);
+ new_uri = g_strdup_printf (_("%s-pages"), uri);
+
+ g_free (uri);
+
+ new_file = g_file_new_for_uri (new_uri);
+
+ g_free (new_uri);
+
+ gimp_image_set_file (image, new_file);
- gimp_image_set_filename (image, name);
- g_free (name);
+ g_object_unref (new_file);
gimp_image_set_resolution (image, resolution, resolution);
}
diff --git a/plug-ins/common/file-pix.c b/plug-ins/common/file-pix.c
index 197791e561..79f00020f7 100644
--- a/plug-ins/common/file-pix.c
+++ b/plug-ins/common/file-pix.c
@@ -361,7 +361,7 @@ load_image (GFile *file,
gushort width, height, depth;
gint i, j, tile_height, row;
- PIX_DEBUG_PRINT ("Opening file: %s\n", filename);
+ PIX_DEBUG_PRINT ("Opening file: %s\n", gimp_file_get_utf8_name (file));
gimp_progress_init_printf (_("Opening '%s'"),
g_file_get_parse_name (file));
@@ -404,7 +404,7 @@ load_image (GFile *file,
}
image = gimp_image_new (width, height, imgtype);
- gimp_image_set_filename (image, g_file_get_uri (file));
+ gimp_image_set_file (image, file);
layer = gimp_layer_new (image, _("Background"),
width, height,
diff --git a/plug-ins/common/file-png.c b/plug-ins/common/file-png.c
index c2beeb201c..c760d2d9d4 100644
--- a/plug-ins/common/file-png.c
+++ b/plug-ins/common/file-png.c
@@ -176,12 +176,12 @@ static GimpValueArray * png_save (GimpProcedure *procedure,
const GimpValueArray *args,
gpointer run_data);
-static GimpImage * load_image (const gchar *filename,
+static GimpImage * load_image (GFile *file,
gboolean interactive,
gboolean *resolution_loaded,
gboolean *profile_loaded,
GError **error);
-static gboolean save_image (const gchar *filename,
+static gboolean save_image (GFile *file,
GimpImage *image,
GimpDrawable *drawable,
GimpImage *orig_image,
@@ -416,7 +416,7 @@ png_load (GimpProcedure *procedure,
break;
}
- image = load_image (g_file_get_path (file),
+ image = load_image (file,
interactive,
&resolution_loaded,
&profile_loaded,
@@ -564,7 +564,7 @@ png_save (GimpProcedure *procedure,
{
gboolean profile_saved = FALSE;
- if (save_image (g_file_get_path (file),
+ if (save_image (file,
image, drawable, orig_image,
&profile_saved, &error))
{
@@ -719,7 +719,7 @@ load_color_profile (png_structp pp,
* 'load_image()' - Load a PNG image into a new image window.
*/
static GimpImage *
-load_image (const gchar *filename,
+load_image (GFile *file,
gboolean interactive,
gboolean *resolution_loaded,
gboolean *profile_loaded,
@@ -740,6 +740,7 @@ load_image (const gchar *filename,
GimpPrecision image_precision; /* Precision of image */
GimpImageType layer_type; /* Type of drawable/layer */
GimpColorProfile *profile = NULL; /* Color profile */
+ gchar *filename;
gchar *profile_name = NULL; /* Profile's name */
gboolean linear = FALSE; /* Linear RGB */
FILE *fp; /* File pointer */
@@ -764,7 +765,7 @@ load_image (const gchar *filename,
g_set_error (error, 0, 0,
_("Error creating PNG read struct while loading '%s'."),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
return NULL;
}
@@ -773,7 +774,7 @@ load_image (const gchar *filename,
{
g_set_error (error, 0, 0,
_("Error while reading '%s'. Could not create PNG header info structure."),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
return NULL;
}
@@ -781,7 +782,7 @@ load_image (const gchar *filename,
{
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
_("Error while reading '%s'. File corrupted?"),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
return (GimpImage *) image;
}
@@ -798,15 +799,17 @@ load_image (const gchar *filename,
*/
gimp_progress_init_printf (_("Opening '%s'"),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
+ filename = g_file_get_path (file);
fp = g_fopen (filename, "rb");
+ g_free (filename);
if (fp == NULL)
{
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));
+ gimp_file_get_utf8_name (file), g_strerror (errno));
return NULL;
}
@@ -940,7 +943,7 @@ load_image (const gchar *filename,
default:
g_set_error (error, 0, 0,
_("Unknown color model in PNG file '%s'."),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
return NULL;
}
@@ -953,7 +956,7 @@ load_image (const gchar *filename,
{
g_set_error (error, 0, 0,
_("Could not create new image for '%s': %s"),
- gimp_filename_to_utf8 (filename),
+ gimp_file_get_utf8_name (file),
gimp_pdb_get_last_error (gimp_get_pdb ()));
return NULL;
}
@@ -1084,7 +1087,7 @@ load_image (const gchar *filename,
}
- gimp_image_set_filename ((GimpImage *) image, filename);
+ gimp_image_set_file ((GimpImage *) image, file);
/*
* Load the colormap as necessary...
@@ -1323,7 +1326,7 @@ offsets_dialog (gint offset_x,
*/
static gboolean
-save_image (const gchar *filename,
+save_image (GFile *file,
GimpImage *image,
GimpDrawable *drawable,
GimpImage *orig_image,
@@ -1345,6 +1348,7 @@ save_image (const gchar *filename,
GimpColorProfile *profile = NULL; /* Color profile */
gboolean out_linear; /* Save linear RGB */
GeglBuffer *buffer; /* GEGL buffer for layer */
+ gchar *filename;
const Babl *file_format = NULL; /* BABL format of file */
const gchar *encoding;
const Babl *space;
@@ -1462,7 +1466,7 @@ save_image (const gchar *filename,
*/
g_set_error (error, 0, 0,
_("Error creating PNG write struct while exporting '%s'."),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
return FALSE;
}
@@ -1471,7 +1475,7 @@ save_image (const gchar *filename,
{
g_set_error (error, 0, 0,
_("Error while exporting '%s'. Could not create PNG header info structure."),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
return FALSE;
}
@@ -1479,7 +1483,7 @@ save_image (const gchar *filename,
{
g_set_error (error, 0, 0,
_("Error while exporting '%s'. Could not export image."),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
return FALSE;
}
@@ -1496,14 +1500,17 @@ save_image (const gchar *filename,
*/
gimp_progress_init_printf (_("Exporting '%s'"),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
+ filename = g_file_get_path (file);
fp = g_fopen (filename, "wb");
- if (fp == NULL)
+ g_free (filename);
+
+ if (! fp)
{
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));
return FALSE;
}
diff --git a/plug-ins/common/file-pnm.c b/plug-ins/common/file-pnm.c
index d4a5949446..fe3875b8f6 100644
--- a/plug-ins/common/file-pnm.c
+++ b/plug-ins/common/file-pnm.c
@@ -748,7 +748,7 @@ load_image (GFile *file,
(pnminfo->np >= 3) ? GIMP_RGB : GIMP_GRAY,
precision);
- gimp_image_set_filename (image, g_file_get_uri (file));
+ gimp_image_set_file (image, file);
layer = gimp_layer_new (image, _("Background"),
pnminfo->xres, pnminfo->yres,
diff --git a/plug-ins/common/file-ps.c b/plug-ins/common/file-ps.c
index ded68265fd..f381d97cfe 100644
--- a/plug-ins/common/file-ps.c
+++ b/plug-ins/common/file-ps.c
@@ -174,7 +174,7 @@ static GimpValueArray * ps_save (GimpProcedure *procedure,
const GimpValueArray *args,
gpointer run_data);
-static GimpImage * load_image (const gchar *filename,
+static GimpImage * load_image (GFile *file,
GError **error);
static gboolean save_image (GFile *file,
GimpImage *image,
@@ -222,7 +222,7 @@ static gboolean print (GOutputStream *output,
const gchar *format,
...) G_GNUC_PRINTF (3, 4);
-static GimpImage * create_new_image (const gchar *filename,
+static GimpImage * create_new_image (GFile *file,
guint pagenum,
guint width,
guint height,
@@ -235,13 +235,13 @@ static void check_save_vals (void);
static gint page_in_list (gchar *list,
guint pagenum);
-static gint get_bbox (const gchar *filename,
+static gint get_bbox (GFile *file,
gint *x0,
gint *y0,
gint *x1,
gint *y1);
-static FILE * ps_open (const gchar *filename,
+static FILE * ps_open (GFile *file,
const PSLoadVals *loadopt,
gint *llx,
gint *lly,
@@ -253,7 +253,7 @@ static void ps_close (FILE *ifp);
static gboolean skip_ps (FILE *ifp);
-static GimpImage * load_ps (const gchar *filename,
+static GimpImage * load_ps (GFile *file,
guint pagenum,
FILE *ifp,
gint llx,
@@ -269,13 +269,13 @@ static void dither_grey (const guchar *grey,
/* Dialog-handling */
-static gint32 count_ps_pages (const gchar *filename);
-static gboolean load_dialog (const gchar *filename);
+static gint32 count_ps_pages (GFile *file);
+static gboolean load_dialog (GFile *file);
static void load_pages_entry_callback (GtkWidget *widget,
gpointer data);
static gboolean resolution_change_callback (GtkAdjustment *adjustment,
- gpointer data);
+ gpointer data);
typedef struct
{
@@ -604,7 +604,6 @@ ps_load (GimpProcedure *procedure,
gpointer run_data)
{
GimpValueArray *return_vals;
- gchar *filename;
GimpImage *image;
GError *error = NULL;
@@ -613,14 +612,12 @@ ps_load (GimpProcedure *procedure,
l_run_mode = run_mode;
- filename = g_file_get_path (file);
-
switch (run_mode)
{
case GIMP_RUN_INTERACTIVE:
gimp_get_data (LOAD_PS_PROC, &plvals);
- if (! load_dialog (filename))
+ if (! load_dialog (file))
return gimp_procedure_new_return_values (procedure,
GIMP_PDB_CANCEL,
NULL);
@@ -652,9 +649,7 @@ ps_load (GimpProcedure *procedure,
check_load_vals ();
- image = load_image (filename, &error);
-
- g_free (filename);
+ image = load_image (file, &error);
if (! image)
return gimp_procedure_new_return_values (procedure,
@@ -697,7 +692,7 @@ ps_load_thumb (GimpProcedure *procedure,
check_load_vals ();
- image = load_image (g_file_get_path (file), &error);
+ image = load_image (file, &error);
if (! image)
return gimp_procedure_new_return_values (procedure,
@@ -1102,11 +1097,12 @@ ps_end_data (GOutputStream *output,
}
static GimpImage *
-load_image (const gchar *filename,
- GError **error)
+load_image (GFile *file,
+ GError **error)
{
GimpImage *image = NULL;
GimpImage **image_list, **nl;
+ gchar *filename;
guint page_count;
FILE *ifp;
gchar *temp;
@@ -1124,25 +1120,28 @@ load_image (const gchar *filename,
#endif
gimp_progress_init_printf (_("Opening '%s'"),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
/* Try to see if PostScript file is available */
+ filename = g_file_get_path (file);
ifp = g_fopen (filename, "r");
- if (ifp == NULL)
+ g_free (filename);
+
+ if (! ifp)
{
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));
+ gimp_file_get_utf8_name (file), g_strerror (errno));
return NULL;
}
fclose (ifp);
- ifp = ps_open (filename, &plvals, &llx, &lly, &urx, &ury, &is_epsf);
+ ifp = ps_open (file, &plvals, &llx, &lly, &urx, &ury, &is_epsf);
if (!ifp)
{
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR,
_("Could not interpret PostScript file '%s'"),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
return NULL;
}
@@ -1178,7 +1177,7 @@ load_image (const gchar *filename,
{
if (page_in_list (plvals.pages, page_count))
{
- image = load_ps (filename, page_count, ifp, llx, lly, urx, ury);
+ image = load_ps (file, page_count, ifp, llx, lly, urx, ury);
if (! image)
break;
@@ -1210,20 +1209,30 @@ load_image (const gchar *filename,
{
for (k = 0; k < n_images; k++)
{
- gchar *name;
-
if (k == 0)
{
+ GFile *new_file;
+ gchar *uri;
+ gchar *new_uri;
+
image = image_list[0];
- name = g_strdup_printf (_("%s-pages"), filename);
- gimp_image_set_filename (image, name);
- g_free (name);
+ uri = g_file_get_uri (file);
+
+ new_uri = g_strdup_printf (_("%s-pages"), uri);
+ g_free (uri);
+
+ new_file = g_file_new_for_uri (new_uri);
+ g_free (new_uri);
+
+ gimp_image_set_file (image, new_file);
+ g_object_unref (new_file);
}
else
{
GimpLayer *current_layer;
GimpDrawable *tmp_drawable;
+ gchar *name;
tmp_drawable = gimp_image_get_active_drawable (image_list[k]);
@@ -1626,18 +1635,22 @@ static char *psfgets (char *s, int size, FILE *stream)
/* Get the BoundingBox of a PostScript file. On success, 0 is returned. */
/* On failure, -1 is returned. */
static gint
-get_bbox (const gchar *filename,
- gint *x0,
- gint *y0,
- gint *x1,
- gint *y1)
+get_bbox (GFile *file,
+ gint *x0,
+ gint *y0,
+ gint *x1,
+ gint *y1)
{
- char line[1024], *src;
- FILE *ifp;
- int retval = -1;
+ gchar *filename;
+ char line[1024], *src;
+ FILE *ifp;
+ int retval = -1;
+ filename = g_file_get_path (file);
ifp = g_fopen (filename, "rb");
- if (ifp == NULL)
+ g_free (filename);
+
+ if (! ifp)
return -1;
for (;;)
@@ -1665,7 +1678,7 @@ static gchar *pnmfile;
/* The filepointer returned will give a PNM-file generated */
/* by the PostScript-interpreter. */
static FILE *
-ps_open (const gchar *filename,
+ps_open (GFile *file,
const PSLoadVals *loadopt,
gint *llx,
gint *lly,
@@ -1673,6 +1686,7 @@ ps_open (const gchar *filename,
gint *ury,
gboolean *is_epsf)
{
+ gchar *filename;
const gchar *driver;
GPtrArray *cmdA;
gchar **pcmdA;
@@ -1701,9 +1715,11 @@ ps_open (const gchar *filename,
/* Check if it is a EPS-file */
*is_epsf = FALSE;
+ filename = g_file_get_path (file);
+
eps_file = g_fopen (filename, "rb");
- if (eps_file != NULL)
+ if (eps_file)
{
gchar hdr[512];
@@ -1740,7 +1756,7 @@ ps_open (const gchar *filename,
if ((!is_pdf) && (loadopt->use_bbox)) /* Try the BoundingBox ? */
{
- if (get_bbox (filename, &x0, &y0, &x1, &y1) == 0)
+ if (get_bbox (file, &x0, &y0, &x1, &y1) == 0)
{
if (maybe_epsf && ((x0 < 0) || (y0 < 0)))
*is_epsf = 1;
@@ -1839,6 +1855,8 @@ ps_open (const gchar *filename,
g_ptr_array_add (cmdA, g_strdup ("-f"));
g_ptr_array_add (cmdA, g_strdup (filename));
+ g_free (filename);
+
if (*is_epsf)
{
g_ptr_array_add (cmdA, g_strdup ("-c"));
@@ -1958,7 +1976,7 @@ read_pnmraw_type (FILE *ifp,
/* Create an image. Sets layer, drawable and rgn. Returns image */
static GimpImage *
-create_new_image (const gchar *filename,
+create_new_image (GFile *file,
guint pagenum,
guint width,
guint height,
@@ -1967,6 +1985,9 @@ create_new_image (const gchar *filename,
{
GimpImage *image;
GimpImageType gdtype;
+ GFile *new_file;
+ gchar *uri;
+ gchar *new_uri;
gchar *tmp;
switch (type)
@@ -1986,9 +2007,16 @@ create_new_image (const gchar *filename,
GIMP_PRECISION_U8_NON_LINEAR);
gimp_image_undo_disable (image);
- tmp = g_strdup_printf ("%s-%d", filename, pagenum);
- gimp_image_set_filename (image, tmp);
- g_free (tmp);
+ uri = g_file_get_uri (file);
+
+ new_uri = g_strdup_printf ("%s-%d", uri, pagenum);
+ g_free (uri);
+
+ new_file = g_file_new_for_uri (new_uri);
+ g_free (new_uri);
+
+ gimp_image_set_file (image, new_file);
+ g_object_unref (new_file);
tmp = g_strdup_printf (_("Page %d"), pagenum);
*layer = gimp_layer_new (image, tmp, width, height,
@@ -2040,26 +2068,27 @@ skip_ps (FILE *ifp)
/* Load PNM image generated from PostScript file */
static GimpImage *
-load_ps (const gchar *filename,
- guint pagenum,
- FILE *ifp,
- gint llx,
- gint lly,
- gint urx,
- gint ury)
+load_ps (GFile *file,
+ guint pagenum,
+ FILE *ifp,
+ gint llx,
+ gint lly,
+ gint urx,
+ gint ury)
{
guchar *dest;
guchar *data, *bitline = NULL, *byteline = NULL, *byteptr, *temp;
- guchar bit2byte[256*8];
- int width, height, tile_height, scan_lines, total_scan_lines;
- int image_width, image_height;
- int skip_left, skip_bottom;
- int i, j, pnmtype, maxval, bpp, nread;
+ guchar bit2byte[256*8];
+ int width, height, tile_height, scan_lines, total_scan_lines;
+ int image_width, image_height;
+ int skip_left, skip_bottom;
+ int i, j, pnmtype, maxval, bpp, nread;
GimpImageBaseType imagetype;
- GimpImage *image;
- GimpLayer *layer;
+ GimpImage *image;
+ GimpLayer *layer;
GeglBuffer *buffer = NULL;
- int err = 0, e;
+ int err = 0;
+ int e;
pnmtype = read_pnmraw_type (ifp, &width, &height, &maxval);
@@ -2106,7 +2135,7 @@ load_ps (const gchar *filename,
else
return NULL;
- image = create_new_image (filename, pagenum,
+ image = create_new_image (file, pagenum,
image_width, image_height, imagetype,
&layer);
buffer = gimp_drawable_get_buffer (GIMP_DRAWABLE (layer));
@@ -3421,14 +3450,17 @@ print (GOutputStream *output,
/* Load interface functions */
static gint32
-count_ps_pages (const gchar *filename)
+count_ps_pages (GFile *file)
{
+ gchar *filename;
FILE *psfile;
gchar *extension;
gchar buf[1024];
gint32 num_pages = 0;
gint32 showpage_count = 0;
+ filename = g_file_get_path (file);
+
extension = strrchr (filename, '.');
if (extension)
{
@@ -3437,6 +3469,7 @@ count_ps_pages (const gchar *filename)
if (strcmp (extension, "eps") == 0)
{
g_free (extension);
+ g_free (filename);
return 1;
}
@@ -3445,10 +3478,12 @@ count_ps_pages (const gchar *filename)
psfile = g_fopen (filename, "r");
+ g_free (filename);
+
if (psfile == NULL)
{
g_message (_("Could not open '%s' for reading: %s"),
- gimp_filename_to_utf8 (filename), g_strerror (errno));
+ gimp_file_get_utf8_name (file), g_strerror (errno));
return 0;
}
@@ -3471,7 +3506,7 @@ count_ps_pages (const gchar *filename)
}
static gboolean
-load_dialog (const gchar *filename)
+load_dialog (GFile *file)
{
GtkWidget *dialog;
GtkWidget *main_vbox;
@@ -3489,7 +3524,7 @@ load_dialog (const gchar *filename)
gchar *range = NULL;
gboolean run;
- page_count = count_ps_pages (filename);
+ page_count = count_ps_pages (file);
gimp_ui_init (PLUG_IN_BINARY, FALSE);
diff --git a/plug-ins/common/file-psp.c b/plug-ins/common/file-psp.c
index 0dda7a97f8..cec7624321 100644
--- a/plug-ins/common/file-psp.c
+++ b/plug-ins/common/file-psp.c
@@ -563,9 +563,9 @@ static GimpValueArray * psp_save (GimpProcedure *procedure,
const GimpValueArray *args,
gpointer run_data);
-static GimpImage * load_image (const gchar *filename,
+static GimpImage * load_image (GFile *file,
GError **error);
-static gboolean save_image (const gchar *filename,
+static gboolean save_image (GFile *file,
GimpImage *image,
GimpDrawable *drawable,
GError **error);
@@ -699,7 +699,7 @@ psp_load (GimpProcedure *procedure,
INIT_I18N ();
gegl_init (NULL, NULL);
- image = load_image (g_file_get_path (file), &error);
+ image = load_image (file, &error);
if (! image)
return gimp_procedure_new_return_values (procedure,
@@ -777,7 +777,7 @@ psp_save (GimpProcedure *procedure,
if (status == GIMP_PDB_SUCCESS)
{
- if (save_image (g_file_get_path (file), image, drawable,
+ if (save_image (file, image, drawable,
&error))
{
gimp_set_data (SAVE_PROC, &psvals, sizeof (PSPSaveVals));
@@ -1910,10 +1910,11 @@ compression_name (gint compression)
/* The main function for loading PSP-images
*/
static GimpImage *
-load_image (const gchar *filename,
- GError **error)
+load_image (GFile *file,
+ GError **error)
{
- FILE *f;
+ gchar *filename;
+ FILE *f;
struct stat st;
char buf[32];
PSPimage ia;
@@ -1924,15 +1925,23 @@ load_image (const gchar *filename,
GimpImage *image = NULL;
+ filename = g_file_get_path (file);
+
if (g_stat (filename, &st) == -1)
- return NULL;
+ {
+ g_free (filename);
+ return NULL;
+ }
f = g_fopen (filename, "rb");
- if (f == NULL)
+
+ g_free (filename);
+
+ if (! f)
{
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));
+ gimp_file_get_utf8_name (file), g_strerror (errno));
return NULL;
}
@@ -1986,7 +1995,7 @@ load_image (const gchar *filename,
{
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
_("Could not open '%s' for reading: %s"),
- gimp_filename_to_utf8 (filename),
+ gimp_file_get_utf8_name (file),
_("invalid block size"));
goto error;
}
@@ -2017,7 +2026,7 @@ load_image (const gchar *filename,
goto error;
}
- gimp_image_set_filename (image, filename);
+ gimp_image_set_file (image, file);
gimp_image_set_resolution (image, ia.resolution, ia.resolution);
}
@@ -2109,7 +2118,7 @@ load_image (const gchar *filename,
}
static gint
-save_image (const gchar *filename,
+save_image (GFile *file,
GimpImage *image,
GimpDrawable *drawable,
GError **error)
diff --git a/plug-ins/common/file-raw-data.c b/plug-ins/common/file-raw-data.c
index e06060816f..506cf20986 100644
--- a/plug-ins/common/file-raw-data.c
+++ b/plug-ins/common/file-raw-data.c
@@ -178,10 +178,10 @@ static gboolean raw_load_rgb565 (RawGimpData *data,
RawType type);
static gboolean raw_load_planar (RawGimpData *data);
static gboolean raw_load_palette (RawGimpData *data,
- const gchar *palette_filename);
+ GFile *palette_file);
/* support functions */
-static goffset get_file_info (const gchar *filename);
+static goffset get_file_info (GFile *file);
static void raw_read_row (FILE *fp,
guchar *buf,
gint32 offset,
@@ -196,9 +196,9 @@ static void rgb_565_to_888 (guint16 *in,
gint32 num_pixels,
RawType type);
-static GimpImage * load_image (const gchar *filename,
+static GimpImage * load_image (GFile *file,
GError **error);
-static gboolean save_image (const gchar *filename,
+static gboolean save_image (GFile *file,
GimpImage *image,
GimpDrawable *drawable,
GError **error);
@@ -207,7 +207,7 @@ static gboolean save_image (const gchar *filename,
static void preview_update_size (GimpPreviewArea *preview);
static void preview_update (GimpPreviewArea *preview);
static void palette_update (GimpPreviewArea *preview);
-static gboolean load_dialog (const gchar *filename,
+static gboolean load_dialog (GFile *file,
gboolean is_hgt);
static gboolean save_dialog (GimpImage *image);
static void save_dialog_response (GtkWidget *widget,
@@ -227,7 +227,7 @@ GIMP_MAIN (RAW_TYPE)
static RawConfig *runtime = NULL;
-static gchar *palfile = NULL;
+static GFile *palfile = NULL;
static gint preview_fd = -1;
static guchar preview_cmap[1024];
static gboolean preview_cmap_update = TRUE;
@@ -471,7 +471,7 @@ raw_load (GimpProcedure *procedure,
}
else
{
- if (! load_dialog (g_file_get_path (file), is_hgt))
+ if (! load_dialog (file, is_hgt))
status = GIMP_PDB_CANCEL;
close (preview_fd);
@@ -542,7 +542,7 @@ raw_load (GimpProcedure *procedure,
/* we are okay, and the user clicked OK in the load dialog */
if (status == GIMP_PDB_SUCCESS)
{
- image = load_image (g_file_get_path (file), &error);
+ image = load_image (file, &error);
if (image)
{
@@ -631,8 +631,8 @@ raw_save (GimpProcedure *procedure,
if (status == GIMP_PDB_SUCCESS)
{
- if (save_image (g_file_get_path (file),
- image, drawable, &error))
+ if (save_image (file, image, drawable,
+ &error))
{
gimp_set_data (SAVE_PROC, &rawvals, sizeof (rawvals));
}
@@ -648,11 +648,10 @@ raw_save (GimpProcedure *procedure,
return gimp_procedure_new_return_values (procedure, status, error);
}
-/* get file size from a filename */
+/* get file size from a filen */
static goffset
-get_file_info (const gchar *filename)
+get_file_info (GFile *file)
{
- GFile *file = g_file_new_for_path (filename);
GFileInfo *info;
goffset size = 0;
@@ -668,8 +667,6 @@ get_file_info (const gchar *filename)
g_object_unref (info);
}
- g_object_unref (file);
-
return size;
}
@@ -1008,14 +1005,18 @@ raw_load_planar (RawGimpData *data)
static gboolean
raw_load_palette (RawGimpData *data,
- const gchar *palette_file)
+ GFile *palette_file)
{
guchar temp[1024];
gint fd, i, j;
if (palette_file)
{
- fd = g_open (palette_file, O_RDONLY, 0);
+ gchar *filename;
+
+ filename = g_file_get_path (palette_file);
+ fd = g_open (filename, O_RDONLY, 0);
+ g_free (filename);
if (! fd)
return FALSE;
@@ -1060,12 +1061,13 @@ raw_load_palette (RawGimpData *data,
/* end new image handle functions */
static gboolean
-save_image (const gchar *filename,
+save_image (GFile *file,
GimpImage *image,
GimpDrawable *drawable,
GError **error)
{
GeglBuffer *buffer;
+ gchar *filename;
const Babl *format = NULL;
guchar *cmap = NULL; /* colormap for indexed images */
guchar *buf;
@@ -1121,13 +1123,15 @@ save_image (const gchar *filename,
g_object_unref (buffer);
+ filename = g_file_get_path (file);
fp = g_fopen (filename, "wb");
if (! fp)
{
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));
+ g_free (filename);
return FALSE;
}
@@ -1156,6 +1160,7 @@ save_image (const gchar *filename,
g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errno),
_("Could not open '%s' for writing: %s"),
gimp_filename_to_utf8 (newfile), g_strerror (errno));
+ g_free (filename);
return FALSE;
}
@@ -1211,15 +1216,18 @@ save_image (const gchar *filename,
break;
}
+ g_free (filename);
+
return ret;
}
static GimpImage *
-load_image (const gchar *filename,
- GError **error)
+load_image (GFile *file,
+ GError **error)
{
RawGimpData *data;
GimpLayer *layer = NULL;
+ gchar *filename;
GimpImageType ltype = GIMP_RGB_IMAGE;
GimpImageBaseType itype = GIMP_RGB;
goffset size;
@@ -1229,18 +1237,21 @@ load_image (const gchar *filename,
data = g_new0 (RawGimpData, 1);
gimp_progress_init_printf (_("Opening '%s'"),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
+ filename = g_file_get_path (file);
data->fp = g_fopen (filename, "rb");
+ g_free (filename);
+
if (! data->fp)
{
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));
+ gimp_file_get_utf8_name (file), g_strerror (errno));
return NULL;
}
- size = get_file_info (filename);
+ size = get_file_info (file);
switch (runtime->image_type)
{
@@ -1325,7 +1336,7 @@ load_image (const gchar *filename,
data->image = gimp_image_new (runtime->image_width,
runtime->image_height,
itype);
- gimp_image_set_filename (data->image, filename);
+ gimp_image_set_file (data->image, file);
layer = gimp_layer_new (data->image, _("Background"),
runtime->image_width, runtime->image_height,
ltype,
@@ -1602,9 +1613,13 @@ preview_update (GimpPreviewArea *preview)
{
if (palfile)
{
- gint fd;
+ gchar *filename;
+ gint fd;
+
+ filename = g_file_get_path (palfile);
+ fd = g_open (filename, O_RDONLY, 0);
+ g_free (filename);
- fd = g_open (palfile, O_RDONLY, 0);
lseek (fd, runtime->palette_offset, SEEK_SET);
read (fd, preview_cmap,
(runtime->palette_type == RAW_PALETTE_RGB) ? 768 : 1024);
@@ -1747,8 +1762,8 @@ palette_update (GimpPreviewArea *preview)
}
static gboolean
-load_dialog (const gchar *filename,
- gboolean is_hgt)
+load_dialog (GFile *file,
+ gboolean is_hgt)
{
GtkWidget *dialog;
GtkWidget *main_vbox;
@@ -1763,7 +1778,7 @@ load_dialog (const gchar *filename,
goffset file_size;
gboolean run;
- file_size = get_file_info (filename);
+ file_size = get_file_info (file);
gimp_ui_init (PLUG_IN_BINARY, TRUE);
@@ -1999,7 +2014,7 @@ load_dialog (const gchar *filename,
button = gtk_file_chooser_button_new (_("Select Palette File"),
GTK_FILE_CHOOSER_ACTION_OPEN);
if (palfile)
- gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (button), palfile);
+ gtk_file_chooser_set_file (GTK_FILE_CHOOSER (button), palfile, NULL);
gimp_grid_attach_aligned (GTK_GRID (grid), 0, 2,
_("Pal_ette File:"), 0.0, 0.5,
@@ -2142,9 +2157,9 @@ palette_callback (GtkFileChooser *button,
GimpPreviewArea *preview)
{
if (palfile)
- g_free (palfile);
+ g_object_unref (palfile);
- palfile = gtk_file_chooser_get_filename (button);
+ palfile = gtk_file_chooser_get_file (button);
palette_update (preview);
}
diff --git a/plug-ins/common/file-sunras.c b/plug-ins/common/file-sunras.c
index d08a89a13c..8be4b7397b 100644
--- a/plug-ins/common/file-sunras.c
+++ b/plug-ins/common/file-sunras.c
@@ -129,9 +129,9 @@ static GimpValueArray * sunras_save (GimpProcedure *procedure
const GimpValueArray *args,
gpointer run_data);
-static GimpImage * load_image (const gchar *filename,
+static GimpImage * load_image (GFile *file,
GError **error);
-static gboolean save_image (const gchar *filename,
+static gboolean save_image (GFile *file,
GimpImage *image,
GimpDrawable *drawable,
GError **error);
@@ -139,26 +139,26 @@ static gboolean save_image (const gchar *filename,
static void set_color_table (GimpImage *image,
L_SUNFILEHEADER *sunhdr,
const guchar *suncolmap);
-static GimpImage * create_new_image (const gchar *filename,
+static GimpImage * create_new_image (GFile *file,
guint width,
guint height,
GimpImageBaseType type,
GimpLayer **layer,
GeglBuffer **buffer);
-static GimpImage * load_sun_d1 (const gchar *filename,
+static GimpImage * load_sun_d1 (GFile *file,
FILE *ifp,
L_SUNFILEHEADER *sunhdr,
guchar *suncolmap);
-static GimpImage * load_sun_d8 (const gchar *filename,
+static GimpImage * load_sun_d8 (GFile *file,
FILE *ifp,
L_SUNFILEHEADER *sunhdr,
guchar *suncolmap);
-static GimpImage * load_sun_d24 (const gchar *filename,
+static GimpImage * load_sun_d24 (GFile *file,
FILE *ifp,
L_SUNFILEHEADER *sunhdr,
guchar *suncolmap);
-static GimpImage * load_sun_d32 (const gchar *filename,
+static GimpImage * load_sun_d32 (GFile *file,
FILE *ifp,
L_SUNFILEHEADER *sunhdr,
guchar *suncolmap);
@@ -345,7 +345,7 @@ sunras_load (GimpProcedure *procedure,
INIT_I18N ();
gegl_init (NULL, NULL);
- image = load_image (g_file_get_path (file), &error);
+ image = load_image (file, &error);
if (! image)
return gimp_procedure_new_return_values (procedure,
@@ -421,7 +421,7 @@ sunras_save (GimpProcedure *procedure,
if (status == GIMP_PDB_SUCCESS)
{
- if (save_image (g_file_get_path (file), image, drawable,
+ if (save_image (file, image, drawable,
&error))
{
gimp_set_data (SAVE_PROC, &psvals, sizeof (SUNRASSaveVals));
@@ -439,23 +439,27 @@ sunras_save (GimpProcedure *procedure,
}
static GimpImage *
-load_image (const gchar *filename,
- GError **error)
+load_image (GFile *file,
+ GError **error)
{
GimpImage *image;
+ gchar *filename;
FILE *ifp;
L_SUNFILEHEADER sunhdr;
guchar *suncolmap = NULL;
gimp_progress_init_printf (_("Opening '%s'"),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
+ filename = g_file_get_path (file);
ifp = g_fopen (filename, "rb");
- if (!ifp)
+ g_free (filename);
+
+ if (! ifp)
{
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));
+ gimp_file_get_utf8_name (file), g_strerror (errno));
return NULL;
}
@@ -466,7 +470,7 @@ load_image (const gchar *filename,
{
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
_("Could not open '%s' as SUN-raster-file"),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
fclose (ifp);
return NULL;
}
@@ -495,7 +499,7 @@ load_image (const gchar *filename,
#ifdef DEBUG
{
int j, ncols;
- printf ("File %s\n",filename);
+ printf ("File %s\n", g_file_get_path (file));
ncols = sunhdr.l_ras_maplength/3;
for (j=0; j < ncols; j++)
printf ("Entry 0x%08x: 0x%04x, 0x%04x, 0x%04x\n",
@@ -505,7 +509,7 @@ load_image (const gchar *filename,
if (sunhdr.l_ras_magic != RAS_MAGIC)
{
g_message (_("Could not read color entries from '%s'"),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
fclose (ifp);
g_free (suncolmap);
return NULL;
@@ -521,7 +525,7 @@ load_image (const gchar *filename,
if (sunhdr.l_ras_width <= 0)
{
g_message (_("'%s':\nNo image width specified"),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
fclose (ifp);
return NULL;
}
@@ -529,7 +533,7 @@ load_image (const gchar *filename,
if (sunhdr.l_ras_width > GIMP_MAX_IMAGE_SIZE)
{
g_message (_("'%s':\nImage width is larger than GIMP can handle"),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
fclose (ifp);
return NULL;
}
@@ -537,7 +541,7 @@ load_image (const gchar *filename,
if (sunhdr.l_ras_height <= 0)
{
g_message (_("'%s':\nNo image height specified"),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
fclose (ifp);
return NULL;
}
@@ -545,7 +549,7 @@ load_image (const gchar *filename,
if (sunhdr.l_ras_height > GIMP_MAX_IMAGE_SIZE)
{
g_message (_("'%s':\nImage height is larger than GIMP can handle"),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
fclose (ifp);
return NULL;
}
@@ -553,19 +557,19 @@ load_image (const gchar *filename,
switch (sunhdr.l_ras_depth)
{
case 1: /* bitmap */
- image = load_sun_d1 (filename, ifp, &sunhdr, suncolmap);
+ image = load_sun_d1 (file, ifp, &sunhdr, suncolmap);
break;
case 8: /* 256 colors */
- image = load_sun_d8 (filename, ifp, &sunhdr, suncolmap);
+ image = load_sun_d8 (file, ifp, &sunhdr, suncolmap);
break;
case 24: /* True color */
- image = load_sun_d24 (filename, ifp, &sunhdr, suncolmap);
+ image = load_sun_d24 (file, ifp, &sunhdr, suncolmap);
break;
case 32: /* True color with extra byte */
- image = load_sun_d32 (filename, ifp, &sunhdr, suncolmap);
+ image = load_sun_d32 (file, ifp, &sunhdr, suncolmap);
break;
default:
@@ -588,11 +592,12 @@ load_image (const gchar *filename,
}
static gboolean
-save_image (const gchar *filename,
+save_image (GFile *file,
GimpImage *image,
GimpDrawable *drawable,
GError **error)
{
+ gchar *filename;
FILE *ofp;
GimpImageType drawable_type;
gboolean retval;
@@ -620,15 +625,18 @@ save_image (const gchar *filename,
}
gimp_progress_init_printf (_("Exporting '%s'"),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
/* Open the output file. */
+ filename = g_file_get_path (file);
ofp = g_fopen (filename, "wb");
+ g_free (filename);
+
if (! ofp)
{
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));
return FALSE;
}
@@ -1044,7 +1052,7 @@ set_color_table (GimpImage *image,
/* Create an image. Sets layer, drawable and rgn. Returns image */
static GimpImage *
-create_new_image (const gchar *filename,
+create_new_image (GFile *file,
guint width,
guint height,
GimpImageBaseType type,
@@ -1071,7 +1079,7 @@ create_new_image (const gchar *filename,
}
image = gimp_image_new (width, height, type);
- gimp_image_set_filename (image, filename);
+ gimp_image_set_file (image, file);
*layer = gimp_layer_new (image, _("Background"), width, height,
gdtype,
@@ -1087,7 +1095,7 @@ create_new_image (const gchar *filename,
/* Load SUN-raster-file with depth 1 */
static GimpImage *
-load_sun_d1 (const gchar *filename,
+load_sun_d1 (GFile *file,
FILE *ifp,
L_SUNFILEHEADER *sunhdr,
guchar *suncolmap)
@@ -1108,7 +1116,7 @@ load_sun_d1 (const gchar *filename,
width = sunhdr->l_ras_width;
height = sunhdr->l_ras_height;
- image = create_new_image (filename, width, height, GIMP_INDEXED,
+ image = create_new_image (file, width, height, GIMP_INDEXED,
&layer, &buffer);
tile_height = gimp_tile_height ();
@@ -1194,7 +1202,7 @@ load_sun_d1 (const gchar *filename,
/* Load SUN-raster-file with depth 8 */
static GimpImage *
-load_sun_d8 (const gchar *filename,
+load_sun_d8 (GFile *file,
FILE *ifp,
L_SUNFILEHEADER *sunhdr,
guchar *suncolmap)
@@ -1232,7 +1240,7 @@ load_sun_d8 (const gchar *filename,
}
}
- image = create_new_image (filename, width, height,
+ image = create_new_image (file, width, height,
grayscale ? GIMP_GRAY : GIMP_INDEXED,
&layer, &buffer);
@@ -1288,7 +1296,7 @@ load_sun_d8 (const gchar *filename,
/* Load SUN-raster-file with depth 24 */
static GimpImage *
-load_sun_d24 (const gchar *filename,
+load_sun_d24 (GFile *file,
FILE *ifp,
L_SUNFILEHEADER *sunhdr,
guchar *suncolmap)
@@ -1306,7 +1314,7 @@ load_sun_d24 (const gchar *filename,
width = sunhdr->l_ras_width;
height = sunhdr->l_ras_height;
- image = create_new_image (filename, width, height, GIMP_RGB,
+ image = create_new_image (file, width, height, GIMP_RGB,
&layer, &buffer);
tile_height = gimp_tile_height ();
@@ -1373,7 +1381,7 @@ load_sun_d24 (const gchar *filename,
/* Load SUN-raster-file with depth 32 */
static GimpImage *
-load_sun_d32 (const gchar *filename,
+load_sun_d32 (GFile *file,
FILE *ifp,
L_SUNFILEHEADER *sunhdr,
guchar *suncolmap)
@@ -1396,7 +1404,7 @@ load_sun_d32 (const gchar *filename,
cerr = 0;
- image = create_new_image (filename, width, height, GIMP_RGB,
+ image = create_new_image (file, width, height, GIMP_RGB,
&layer, &buffer);
tile_height = gimp_tile_height ();
diff --git a/plug-ins/common/file-svg.c b/plug-ins/common/file-svg.c
index 0740e43c28..ffd6c64a9a 100644
--- a/plug-ins/common/file-svg.c
+++ b/plug-ins/common/file-svg.c
@@ -88,16 +88,16 @@ static GimpValueArray * svg_load_thumb (GimpProcedure *procedure,
const GimpValueArray *args,
gpointer run_data);
-static GimpImage * load_image (const gchar *filename,
- GError **error);
-static GdkPixbuf * load_rsvg_pixbuf (const gchar *filename,
- SvgLoadVals *vals,
- GError **error);
-static gboolean load_rsvg_size (const gchar *filename,
- SvgLoadVals *vals,
- GError **error);
-static gboolean load_dialog (const gchar *filename,
- GError **error);
+static GimpImage * load_image (GFile *file,
+ GError **error);
+static GdkPixbuf * load_rsvg_pixbuf (GFile *file,
+ SvgLoadVals *vals,
+ GError **error);
+static gboolean load_rsvg_size (GFile *file,
+ SvgLoadVals *vals,
+ GError **error);
+static gboolean load_dialog (GFile *file,
+ GError **error);
@@ -232,15 +232,12 @@ svg_load (GimpProcedure *procedure,
gpointer run_data)
{
GimpValueArray *return_vals;
- gchar *filename;
GimpImage *image;
GError *error = NULL;
INIT_I18N ();
gegl_init (NULL, NULL);
- filename = g_file_get_path (file);
-
switch (run_mode)
{
case GIMP_RUN_NONINTERACTIVE:
@@ -253,7 +250,7 @@ svg_load (GimpProcedure *procedure,
case GIMP_RUN_INTERACTIVE:
gimp_get_data (LOAD_PROC, &load_vals);
- if (! load_dialog (filename, &error))
+ if (! load_dialog (file, &error))
return gimp_procedure_new_return_values (procedure,
GIMP_PDB_CANCEL,
NULL);
@@ -264,7 +261,7 @@ svg_load (GimpProcedure *procedure,
break;
}
- image = load_image (filename, &error);
+ image = load_image (file, &error);
if (! image)
return gimp_procedure_new_return_values (procedure,
@@ -275,7 +272,7 @@ svg_load (GimpProcedure *procedure,
GimpVectors **vectors;
gint num_vectors;
- gimp_vectors_import_from_file (image, filename,
+ gimp_vectors_import_from_file (image, file,
load_vals.merge, TRUE,
&num_vectors, &vectors);
if (num_vectors > 0)
@@ -285,8 +282,6 @@ svg_load (GimpProcedure *procedure,
if (run_mode != GIMP_RUN_NONINTERACTIVE)
gimp_set_data (LOAD_PROC, &load_vals, sizeof (load_vals));
- g_free (filename);
-
return_vals = gimp_procedure_new_return_values (procedure,
GIMP_PDB_SUCCESS,
NULL);
@@ -312,8 +307,7 @@ svg_load_thumb (GimpProcedure *procedure,
INIT_I18N ();
gegl_init (NULL, NULL);
- if (load_rsvg_size (g_file_get_path (file),
- &load_vals, NULL))
+ if (load_rsvg_size (file, &load_vals, NULL))
{
width = load_vals.width;
height = load_vals.height;
@@ -323,8 +317,7 @@ svg_load_thumb (GimpProcedure *procedure,
load_vals.width = - size;
load_vals.height = - size;
- image = load_image (g_file_get_path (file),
- &error);
+ image = load_image (file, &error);
if (! image)
return gimp_procedure_new_return_values (procedure,
@@ -345,8 +338,8 @@ svg_load_thumb (GimpProcedure *procedure,
}
static GimpImage *
-load_image (const gchar *filename,
- GError **load_error)
+load_image (GFile *file,
+ GError **load_error)
{
GimpImage *image;
GimpLayer *layer;
@@ -355,7 +348,7 @@ load_image (const gchar *filename,
gint height;
GError *error = NULL;
- pixbuf = load_rsvg_pixbuf (filename, &load_vals, &error);
+ pixbuf = load_rsvg_pixbuf (file, &load_vals, &error);
if (! pixbuf)
{
@@ -363,7 +356,7 @@ load_image (const gchar *filename,
g_set_error (load_error,
error ? error->domain : 0, error ? error->code : 0,
_("Could not open '%s' for reading: %s"),
- gimp_filename_to_utf8 (filename),
+ gimp_file_get_utf8_name (file),
error ? error->message : _("Unknown reason"));
g_clear_error (&error);
@@ -378,7 +371,7 @@ load_image (const gchar *filename,
image = gimp_image_new (width, height, GIMP_RGB);
gimp_image_undo_disable (image);
- gimp_image_set_filename (image, filename);
+ gimp_image_set_file (image, file);
gimp_image_set_resolution (image,
load_vals.resolution, load_vals.resolution);
@@ -443,24 +436,18 @@ load_set_size_callback (gint *width,
/* This function renders a pixbuf from an SVG file according to vals. */
static GdkPixbuf *
-load_rsvg_pixbuf (const gchar *filename,
+load_rsvg_pixbuf (GFile *file,
SvgLoadVals *vals,
GError **error)
{
GdkPixbuf *pixbuf = NULL;
RsvgHandle *handle;
- GFile *file;
-
- file = g_file_new_for_path (filename);
- handle = rsvg_handle_new_from_gfile_sync (file, RSVG_HANDLE_FLAGS_NONE, NULL, error);
+ handle = rsvg_handle_new_from_gfile_sync (file, RSVG_HANDLE_FLAGS_NONE, NULL,
+ error);
- g_object_unref (file);
-
- if (!handle)
- {
- return NULL;
- }
+ if (! handle)
+ return NULL;
rsvg_handle_set_dpi (handle, vals->resolution);
rsvg_handle_set_size_callback (handle, load_set_size_callback, vals, NULL);
@@ -476,25 +463,19 @@ static GtkWidget *size_label = NULL;
/* This function retrieves the pixel size from an SVG file. */
static gboolean
-load_rsvg_size (const gchar *filename,
+load_rsvg_size (GFile *file,
SvgLoadVals *vals,
GError **error)
{
RsvgHandle *handle;
- GFile *file;
RsvgDimensionData dim;
gboolean has_size;
- file = g_file_new_for_path (filename);
-
- handle = rsvg_handle_new_from_gfile_sync (file, RSVG_HANDLE_FLAGS_NONE, NULL, error);
-
- g_object_unref (file);
+ handle = rsvg_handle_new_from_gfile_sync (file, RSVG_HANDLE_FLAGS_NONE, NULL,
+ error);
- if (!handle)
- {
- return FALSE;
- }
+ if (! handle)
+ return FALSE;
rsvg_handle_set_dpi (handle, vals->resolution);
@@ -593,13 +574,13 @@ load_dialog_ratio_callback (GtkAdjustment *adj,
static void
load_dialog_resolution_callback (GimpSizeEntry *res,
- const gchar *filename)
+ GFile *file)
{
SvgLoadVals vals = { 0.0, 0, 0 };
load_vals.resolution = vals.resolution = gimp_size_entry_get_refval (res, 0);
- if (!load_rsvg_size (filename, &vals, NULL))
+ if (! load_rsvg_size (file, &vals, NULL))
return;
g_signal_handlers_block_by_func (size, load_dialog_size_callback, NULL);
@@ -646,8 +627,8 @@ load_dialog_set_ratio (gdouble x,
}
static gboolean
-load_dialog (const gchar *filename,
- GError **load_error)
+load_dialog (GFile *file,
+ GError **load_error)
{
GtkWidget *dialog;
GtkWidget *frame;
@@ -672,7 +653,7 @@ load_dialog (const gchar *filename,
- SVG_PREVIEW_SIZE
};
- preview = load_rsvg_pixbuf (filename, &vals, &error);
+ preview = load_rsvg_pixbuf (file, &vals, &error);
if (! preview)
{
@@ -680,7 +661,7 @@ load_dialog (const gchar *filename,
g_set_error (load_error,
error ? error->domain : 0, error ? error->code : 0,
_("Could not open '%s' for reading: %s"),
- gimp_filename_to_utf8 (filename),
+ gimp_file_get_utf8_name (file),
error ? error->message : _("Unknown reason"));
g_clear_error (&error);
@@ -737,7 +718,7 @@ load_dialog (const gchar *filename,
/* query the initial size after the size label is created */
vals.resolution = load_vals.resolution;
- load_rsvg_size (filename, &vals, NULL);
+ load_rsvg_size (file, &vals, NULL);
svg_width = vals.width;
svg_height = vals.height;
@@ -889,7 +870,7 @@ load_dialog (const gchar *filename,
g_signal_connect (res, "value-changed",
G_CALLBACK (load_dialog_resolution_callback),
- (gpointer) filename);
+ file);
/* Path Import */
toggle = gtk_check_button_new_with_mnemonic (_("Import _paths"));
diff --git a/plug-ins/common/file-tga.c b/plug-ins/common/file-tga.c
index 203f743b99..2ecc7b72f0 100644
--- a/plug-ins/common/file-tga.c
+++ b/plug-ins/common/file-tga.c
@@ -191,9 +191,9 @@ static GimpValueArray * tga_save (GimpProcedure *procedure,
const GimpValueArray *args,
gpointer run_data);
-static GimpImage * load_image (const gchar *filename,
+static GimpImage * load_image (GFile *file,
GError **error);
-static gboolean save_image (const gchar *filename,
+static gboolean save_image (GFile *file,
GimpImage *image,
GimpDrawable *drawable,
GError **error);
@@ -202,7 +202,7 @@ static gboolean save_dialog (void);
static GimpImage * ReadImage (FILE *fp,
tga_info *info,
- const gchar *filename);
+ GFile *file);
G_DEFINE_TYPE (Tga, tga, GIMP_TYPE_PLUG_IN)
@@ -333,7 +333,7 @@ tga_load (GimpProcedure *procedure,
INIT_I18N ();
gegl_init (NULL, NULL);
- image = load_image (g_file_get_path (file), &error);
+ image = load_image (file, &error);
if (! image)
return gimp_procedure_new_return_values (procedure,
@@ -410,8 +410,7 @@ tga_save (GimpProcedure *procedure,
if (status == GIMP_PDB_SUCCESS)
{
- if (save_image (g_file_get_path (file),
- image, drawable,
+ if (save_image (file, image, drawable,
&error))
{
gimp_set_data (SAVE_PROC, &tsvals, sizeof (tsvals));
@@ -429,9 +428,10 @@ tga_save (GimpProcedure *procedure,
}
static GimpImage *
-load_image (const gchar *filename,
- GError **error)
+load_image (GFile *file,
+ GError **error)
{
+ gchar *filename;
FILE *fp;
tga_info info;
guchar header[18];
@@ -441,15 +441,17 @@ load_image (const gchar *filename,
GimpImage *image = NULL;
gimp_progress_init_printf (_("Opening '%s'"),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
+ filename = g_file_get_path (file);
fp = g_fopen (filename, "rb");
+ g_free (filename);
if (! fp)
{
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));
+ gimp_file_get_utf8_name (file), g_strerror (errno));
return NULL;
}
@@ -459,7 +461,7 @@ load_image (const gchar *filename,
if (fread (footer, sizeof (footer), 1, fp) != 1)
{
g_message (_("Cannot read footer from '%s'"),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
return NULL;
}
else if (memcmp (footer + 8, magic, sizeof (magic)) == 0)
@@ -477,7 +479,7 @@ load_image (const gchar *filename,
fread (extension, sizeof (extension), 1, fp) != 1)
{
g_message (_("Cannot read extension from '%s'"),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
return NULL;
}
/* Eventually actually handle version 2 TGA here */
@@ -489,7 +491,7 @@ load_image (const gchar *filename,
fread (header, sizeof (header), 1, fp) != 1)
{
g_message (_("Cannot read header from '%s'"),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
return NULL;
}
@@ -563,7 +565,7 @@ load_image (const gchar *filename,
if (info.bpp != 8)
{
g_message ("Unhandled sub-format in '%s' (type = %u, bpp = %u)",
- gimp_filename_to_utf8 (filename),
+ gimp_file_get_utf8_name (file),
info.imageType, info.bpp);
return NULL;
}
@@ -578,7 +580,7 @@ load_image (const gchar *filename,
(info.bpp == 32 && info.alphaBits != 8))
{
g_message ("Unhandled sub-format in '%s' (type = %u, bpp = %u, alpha = %u)",
- gimp_filename_to_utf8 (filename),
+ gimp_file_get_utf8_name (file),
info.imageType, info.bpp, info.alphaBits);
return NULL;
}
@@ -588,7 +590,7 @@ load_image (const gchar *filename,
(info.alphaBits != 8 || (info.bpp != 16 && info.bpp != 15)))
{
g_message ("Unhandled sub-format in '%s' (type = %u, bpp = %u)",
- gimp_filename_to_utf8 (filename),
+ gimp_file_get_utf8_name (file),
info.imageType, info.bpp);
return NULL;
}
@@ -596,7 +598,7 @@ load_image (const gchar *filename,
default:
g_message ("Unknown image type %u for '%s'",
- info.imageType, gimp_filename_to_utf8 (filename));
+ info.imageType, gimp_file_get_utf8_name (file));
return NULL;
}
@@ -604,7 +606,7 @@ load_image (const gchar *filename,
if (info.bytes * 8 != info.bpp && info.bpp != 15)
{
g_message ("Unhandled sub-format in '%s' (type = %u, bpp = %u)",
- gimp_filename_to_utf8 (filename),
+ gimp_file_get_utf8_name (file),
info.imageType, info.bpp);
return NULL;
}
@@ -627,11 +629,11 @@ load_image (const gchar *filename,
if (info.idLength && fseek (fp, info.idLength, SEEK_CUR))
{
g_message ("File '%s' is truncated or corrupted",
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
return NULL;
}
- image = ReadImage (fp, &info, filename);
+ image = ReadImage (fp, &info, file);
fclose (fp);
@@ -971,9 +973,9 @@ read_line (FILE *fp,
}
static GimpImage *
-ReadImage (FILE *fp,
- tga_info *info,
- const gchar *filename)
+ReadImage (FILE *fp,
+ tga_info *info,
+ GFile *file)
{
GimpImage *image;
GimpLayer *layer;
@@ -1087,13 +1089,13 @@ ReadImage (FILE *fp,
else
{
g_message ("File '%s' is truncated or corrupted",
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
return NULL;
}
}
image = gimp_image_new (info->width, info->height, itype);
- gimp_image_set_filename (image, filename);
+ gimp_image_set_file (image, file);
if (gimp_cmap)
gimp_image_set_colormap (image, gimp_cmap, info->colorMapLength);
@@ -1176,7 +1178,7 @@ ReadImage (FILE *fp,
static gboolean
-save_image (const gchar *filename,
+save_image (GFile *file,
GimpImage *image,
GimpDrawable *drawable,
GError **error)
@@ -1186,6 +1188,7 @@ save_image (const gchar *filename,
GimpImageType dtype;
gint width;
gint height;
+ gchar *filename;
FILE *fp;
gint out_bpp = 0;
gboolean status = TRUE;
@@ -1205,13 +1208,17 @@ save_image (const gchar *filename,
height = gegl_buffer_get_height (buffer);
gimp_progress_init_printf (_("Exporting '%s'"),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
- if ((fp = g_fopen (filename, "wb")) == NULL)
+ filename = g_file_get_path (file);
+ fp = g_fopen (filename, "wb");
+ g_free (filename);
+
+ if (! fp)
{
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));
return FALSE;
}
diff --git a/plug-ins/common/file-wmf.c b/plug-ins/common/file-wmf.c
index fad452520d..770c84edb6 100644
--- a/plug-ins/common/file-wmf.c
+++ b/plug-ins/common/file-wmf.c
@@ -84,15 +84,15 @@ static GimpValueArray * wmf_load_thumb (GimpProcedure *procedure,
const GimpValueArray *args,
gpointer run_data);
-static GimpImage * load_image (const gchar *filename,
+static GimpImage * load_image (GFile *file,
GError **error);
-static gboolean load_wmf_size (const gchar *filename,
+static gboolean load_wmf_size (GFile *file,
WmfLoadVals *vals);
-static gboolean load_dialog (const gchar *filename);
-static guchar * wmf_get_pixbuf (const gchar *filename,
+static gboolean load_dialog (GFile *file);
+static guchar * wmf_get_pixbuf (GFile *file,
gint *width,
gint *height);
-static guchar * wmf_load_file (const gchar *filename,
+static guchar * wmf_load_file (GFile *file,
guint *width,
guint *height,
GError **error);
@@ -217,15 +217,12 @@ wmf_load (GimpProcedure *procedure,
gpointer run_data)
{
GimpValueArray *return_vals;
- gchar *filename;
GimpImage *image;
GError *error = NULL;
INIT_I18N ();
gegl_init (NULL, NULL);
- filename = g_file_get_path (file);
-
switch (run_mode)
{
case GIMP_RUN_NONINTERACTIVE:
@@ -236,7 +233,7 @@ wmf_load (GimpProcedure *procedure,
case GIMP_RUN_INTERACTIVE:
gimp_get_data (LOAD_PROC, &load_vals);
- if (! load_dialog (filename))
+ if (! load_dialog (file))
return gimp_procedure_new_return_values (procedure,
GIMP_PDB_CANCEL,
NULL);
@@ -247,9 +244,7 @@ wmf_load (GimpProcedure *procedure,
break;
}
- image = load_image (filename, &error);
-
- g_free (filename);
+ image = load_image (file, &error);
if (! image)
return gimp_procedure_new_return_values (procedure,
@@ -273,7 +268,6 @@ wmf_load_thumb (GimpProcedure *procedure,
gpointer run_data)
{
GimpValueArray *return_vals;
- gchar *filename;
GimpImage *image;
gint width;
gint height;
@@ -282,10 +276,8 @@ wmf_load_thumb (GimpProcedure *procedure,
INIT_I18N ();
gegl_init (NULL, NULL);
- filename = g_file_get_path (file);
-
- if (load_wmf_size (filename, &load_vals) &&
- load_vals.width > 0 &&
+ if (load_wmf_size (file, &load_vals) &&
+ load_vals.width > 0 &&
load_vals.height > 0)
{
width = load_vals.width;
@@ -309,9 +301,7 @@ wmf_load_thumb (GimpProcedure *procedure,
NULL);
}
- image = load_image (filename, &error);
-
- g_free (filename);
+ image = load_image (file, &error);
if (! image)
return gimp_procedure_new_return_values (procedure,
@@ -337,10 +327,11 @@ static GtkWidget *size_label = NULL;
/* This function retrieves the pixel size from a WMF file. */
static gboolean
-load_wmf_size (const gchar *filename,
+load_wmf_size (GFile *file,
WmfLoadVals *vals)
{
- GMappedFile *file;
+ gchar *filename;
+ GMappedFile *mapped;
/* the bits we need to decode the WMF via libwmf2's GD layer */
wmf_error_t err;
gulong flags;
@@ -353,8 +344,11 @@ load_wmf_size (const gchar *filename,
gboolean success = TRUE;
char* wmffontdirs[2] = { NULL, NULL };
- file = g_mapped_file_new (filename, FALSE, NULL);
- if (! file)
+ filename = g_file_get_path (file);
+ mapped = g_mapped_file_new (filename, FALSE, NULL);
+ g_free (filename);
+
+ if (! mapped)
return FALSE;
flags = WMF_OPT_IGNORE_NONFATAL | WMF_OPT_FUNCTION;
@@ -377,8 +371,8 @@ load_wmf_size (const gchar *filename,
ddata->type = wmf_gd_image;
err = wmf_mem_open (API,
- (guchar *) g_mapped_file_get_contents (file),
- g_mapped_file_get_length (file));
+ (guchar *) g_mapped_file_get_contents (mapped),
+ g_mapped_file_get_length (mapped));
if (err != wmf_E_None)
success = FALSE;
@@ -392,7 +386,7 @@ load_wmf_size (const gchar *filename,
success = FALSE;
wmf_mem_close (API);
- g_mapped_file_unref (file);
+ g_mapped_file_unref (mapped);
if (width < 1 || height < 1)
{
@@ -476,13 +470,13 @@ load_dialog_ratio_callback (GtkAdjustment *adj,
static void
load_dialog_resolution_callback (GimpSizeEntry *res,
- const gchar *filename)
+ GFile *file)
{
WmfLoadVals vals = { 0.0, 0, 0 };
load_vals.resolution = vals.resolution = gimp_size_entry_get_refval (res, 0);
- if (!load_wmf_size (filename, &vals))
+ if (! load_wmf_size (file, &vals))
return;
wmf_width = vals.width;
@@ -527,7 +521,7 @@ load_dialog_set_ratio (gdouble x,
}
static gboolean
-load_dialog (const gchar *filename)
+load_dialog (GFile *file)
{
GtkWidget *dialog;
GtkWidget *frame;
@@ -582,7 +576,7 @@ load_dialog (const gchar *filename)
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
gtk_widget_show (frame);
- pixels = wmf_get_pixbuf (filename, &vals.width, &vals.height);
+ pixels = wmf_get_pixbuf (file, &vals.width, &vals.height);
image = gimp_preview_area_new ();
gtk_widget_set_size_request (image, vals.width, vals.height);
gtk_container_add (GTK_CONTAINER (frame), image);
@@ -600,7 +594,7 @@ load_dialog (const gchar *filename)
/* query the initial size after the size label is created */
vals.resolution = load_vals.resolution;
- load_wmf_size (filename, &vals);
+ load_wmf_size (file, &vals);
wmf_width = vals.width;
wmf_height = vals.height;
@@ -743,7 +737,7 @@ load_dialog (const gchar *filename)
g_signal_connect (res, "value-changed",
G_CALLBACK (load_dialog_resolution_callback),
- (gpointer) filename);
+ file);
gtk_widget_show (dialog);
@@ -800,11 +794,12 @@ pixbuf_gd_convert (const gint *gd_pixels,
}
static guchar *
-wmf_get_pixbuf (const gchar *filename,
- gint *width,
- gint *height)
+wmf_get_pixbuf (GFile *file,
+ gint *width,
+ gint *height)
{
- GMappedFile *file;
+ gchar *filename;
+ GMappedFile *mapped;
guchar *pixels = NULL;
/* the bits we need to decode the WMF via libwmf2's GD layer */
@@ -819,8 +814,11 @@ wmf_get_pixbuf (const gchar *filename,
gint *gd_pixels = NULL;
char* wmffontdirs[2] = { NULL, NULL };
- file = g_mapped_file_new (filename, FALSE, NULL);
- if (! file)
+ filename = g_file_get_path (file);
+ mapped = g_mapped_file_new (filename, FALSE, NULL);
+ g_free (filename);
+
+ if (! mapped)
return NULL;
flags = WMF_OPT_IGNORE_NONFATAL | WMF_OPT_FUNCTION;
@@ -843,8 +841,8 @@ wmf_get_pixbuf (const gchar *filename,
ddata->type = wmf_gd_image;
err = wmf_mem_open (API,
- (guchar *) g_mapped_file_get_contents (file),
- g_mapped_file_get_length (file));
+ (guchar *) g_mapped_file_get_contents (mapped),
+ g_mapped_file_get_length (mapped));
if (err != wmf_E_None)
goto _wmf_error;
@@ -912,18 +910,19 @@ wmf_get_pixbuf (const gchar *filename,
wmf_api_destroy (API);
}
- g_mapped_file_unref (file);
+ g_mapped_file_unref (mapped);
return pixels;
}
static guchar *
-wmf_load_file (const gchar *filename,
- guint *width,
- guint *height,
- GError **error)
+wmf_load_file (GFile *file,
+ guint *width,
+ guint *height,
+ GError **error)
{
- GMappedFile *file;
+ gchar *filename;
+ GMappedFile *mapped;
guchar *pixels = NULL;
/* the bits we need to decode the WMF via libwmf2's GD layer */
@@ -938,8 +937,11 @@ wmf_load_file (const gchar *filename,
*width = *height = -1;
- file = g_mapped_file_new (filename, FALSE, error);
- if (! file)
+ filename = g_file_get_path (file);
+ mapped = g_mapped_file_new (filename, FALSE, NULL);
+ g_free (filename);
+
+ if (! mapped)
return NULL;
flags = WMF_OPT_IGNORE_NONFATAL | WMF_OPT_FUNCTION;
@@ -962,8 +964,8 @@ wmf_load_file (const gchar *filename,
ddata->type = wmf_gd_image;
err = wmf_mem_open (API,
- (guchar *) g_mapped_file_get_contents (file),
- g_mapped_file_get_length (file));
+ (guchar *) g_mapped_file_get_contents (mapped),
+ g_mapped_file_get_length (mapped));
if (err != wmf_E_None)
goto _wmf_error;
@@ -1007,12 +1009,12 @@ wmf_load_file (const gchar *filename,
wmf_api_destroy (API);
}
- g_mapped_file_unref (file);
+ g_mapped_file_unref (mapped);
/* FIXME: improve error message */
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
_("Could not open '%s' for reading"),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
return pixels;
}
@@ -1021,8 +1023,8 @@ wmf_load_file (const gchar *filename,
* 'load_image()' - Load a WMF image into a new image window.
*/
static GimpImage *
-load_image (const gchar *filename,
- GError **error)
+load_image (GFile *file,
+ GError **error)
{
GimpImage *image;
GimpLayer *layer;
@@ -1031,15 +1033,15 @@ load_image (const gchar *filename,
guint width, height;
gimp_progress_init_printf (_("Opening '%s'"),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
- pixels = wmf_load_file (filename, &width, &height, error);
+ pixels = wmf_load_file (file, &width, &height, error);
if (! pixels)
return NULL;
image = gimp_image_new (width, height, GIMP_RGB);
- gimp_image_set_filename (image, filename);
+ gimp_image_set_file (image, file);
gimp_image_set_resolution (image,
load_vals.resolution, load_vals.resolution);
diff --git a/plug-ins/common/file-xbm.c b/plug-ins/common/file-xbm.c
index fa4bc20395..67c8182366 100644
--- a/plug-ins/common/file-xbm.c
+++ b/plug-ins/common/file-xbm.c
@@ -116,7 +116,7 @@ static GimpValueArray * xbm_save (GimpProcedure *procedure,
const GimpValueArray *args,
gpointer run_data);
-static GimpImage * load_image (const gchar *filename,
+static GimpImage * load_image (GFile *file,
GError **error);
static gboolean save_image (GFile *file,
const gchar *prefix,
@@ -313,7 +313,7 @@ xbm_load (GimpProcedure *procedure,
INIT_I18N ();
gegl_init (NULL, NULL);
- image = load_image (g_file_get_path (file), &error);
+ image = load_image (file, &error);
if (! image)
return gimp_procedure_new_return_values (procedure, status, error);
@@ -328,12 +328,15 @@ xbm_load (GimpProcedure *procedure,
}
static gchar *
-init_prefix (const gchar *filename)
+init_prefix (GFile *file)
{
+ gchar *filename;
gchar *p, *prefix;
- gint len;
+ gint len;
+ filename = g_file_get_path (file);
prefix = g_path_get_basename (filename);
+ g_free (filename);
memset (xsvals.prefix, 0, sizeof (xsvals.prefix));
@@ -397,7 +400,7 @@ xbm_save (GimpProcedure *procedure,
gimp_get_data (SAVE_PROC, &xsvals);
/* Always override the prefix with the filename. */
- mask_basename = g_strdup (init_prefix (g_file_get_path (file)));
+ mask_basename = g_strdup (init_prefix (file));
break;
case GIMP_RUN_NONINTERACTIVE:
@@ -409,7 +412,7 @@ xbm_save (GimpProcedure *procedure,
xsvals.y_hot = GIMP_VALUES_GET_INT (args, 3);
xsvals.use_hot = xsvals.x_hot != 0 || xsvals.y_hot != 0;
- mask_basename = g_strdup (init_prefix (g_file_get_path (file)));
+ mask_basename = g_strdup (init_prefix (file));
g_strlcpy (xsvals.prefix, GIMP_VALUES_GET_STRING (args, 4),
MAX_PREFIX);
@@ -743,9 +746,10 @@ get_int (FILE *fp)
}
static GimpImage *
-load_image (const gchar *filename,
- GError **error)
+load_image (GFile *file,
+ GError **error)
{
+ gchar *filename;
FILE *fp;
GeglBuffer *buffer;
GimpImage *image;
@@ -767,14 +771,17 @@ load_image (const gchar *filename,
};
gimp_progress_init_printf (_("Opening '%s'"),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
+ filename = g_file_get_path (file);
fp = g_fopen (filename, "rb");
+ g_free (filename);
+
if (! fp)
{
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));
+ gimp_file_get_utf8_name (file), g_strerror (errno));
return NULL;
}
@@ -854,7 +861,7 @@ load_image (const gchar *filename,
if (c == EOF)
{
g_message (_("'%s':\nCould not read header (ftell == %ld)"),
- gimp_filename_to_utf8 (filename), ftell (fp));
+ gimp_file_get_utf8_name (file), ftell (fp));
fclose (fp);
return NULL;
}
@@ -862,7 +869,7 @@ load_image (const gchar *filename,
if (width <= 0)
{
g_message (_("'%s':\nNo image width specified"),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
fclose (fp);
return NULL;
}
@@ -870,7 +877,7 @@ load_image (const gchar *filename,
if (width > GIMP_MAX_IMAGE_SIZE)
{
g_message (_("'%s':\nImage width is larger than GIMP can handle"),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
fclose (fp);
return NULL;
}
@@ -878,7 +885,7 @@ load_image (const gchar *filename,
if (height <= 0)
{
g_message (_("'%s':\nNo image height specified"),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
fclose (fp);
return NULL;
}
@@ -886,7 +893,7 @@ load_image (const gchar *filename,
if (height > GIMP_MAX_IMAGE_SIZE)
{
g_message (_("'%s':\nImage height is larger than GIMP can handle"),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
fclose (fp);
return NULL;
}
@@ -894,13 +901,13 @@ load_image (const gchar *filename,
if (intbits == 0)
{
g_message (_("'%s':\nNo image data type specified"),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
fclose (fp);
return NULL;
}
image = gimp_image_new (width, height, GIMP_INDEXED);
- gimp_image_set_filename (image, filename);
+ gimp_image_set_file (image, file);
if (comment)
{
diff --git a/plug-ins/common/file-xmc.c b/plug-ins/common/file-xmc.c
index 9f7780ed29..1d42e2f656 100644
--- a/plug-ins/common/file-xmc.c
+++ b/plug-ins/common/file-xmc.c
@@ -185,10 +185,10 @@ static GimpValueArray * xmc_save (GimpProcedure *procedure,
const GimpValueArray *args,
gpointer run_data);
-static GimpImage * load_image (const gchar *filename,
+static GimpImage * load_image (GFile *file,
GError **error);
-static GimpImage * load_thumbnail (const gchar *filename,
+static GimpImage * load_thumbnail (GFile *file,
gint32 thumb_size,
gint32 *width,
gint32 *height,
@@ -198,7 +198,7 @@ static GimpImage * load_thumbnail (const gchar *filename,
static guint32 read32 (FILE *f,
GError **error);
-static gboolean save_image (const gchar *filename,
+static gboolean save_image (GFile *file,
GimpImage *image,
GimpDrawable *drawable,
GimpImage *orig_image,
@@ -472,18 +472,13 @@ xmc_load (GimpProcedure *procedure,
gpointer run_data)
{
GimpValueArray *return_vals;
- gchar *filename;
GimpImage *image;
GError *error = NULL;
INIT_I18N ();
gegl_init (NULL, NULL);
- filename = g_file_get_path (file);
-
- image = load_image (filename, &error);
-
- g_free (filename);
+ image = load_image (file, &error);
if (! image)
return gimp_procedure_new_return_values (procedure,
@@ -507,7 +502,6 @@ xmc_load_thumb (GimpProcedure *procedure,
gpointer run_data)
{
GimpValueArray *return_vals;
- gchar *filename;
gint width;
gint height;
gint num_layers;
@@ -517,16 +511,12 @@ xmc_load_thumb (GimpProcedure *procedure,
INIT_I18N ();
gegl_init (NULL, NULL);
- filename = g_file_get_path (file);
-
- image = load_thumbnail (filename, size,
+ image = load_thumbnail (file, size,
&width,
&height,
&num_layers,
&error);
- g_free (filename);
-
if (! image)
return gimp_procedure_new_return_values (procedure,
GIMP_PDB_EXECUTION_ERROR,
@@ -555,7 +545,6 @@ xmc_save (GimpProcedure *procedure,
gpointer run_data)
{
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
- gchar *filename;
GimpImage *orig_image;
GimpExportReturn export = GIMP_EXPORT_CANCEL;
GeglRectangle *hotspotRange = NULL;
@@ -567,8 +556,6 @@ xmc_save (GimpProcedure *procedure,
orig_image = image;
- filename = g_file_get_path (file);
-
hotspotRange = get_intersection_of_frames (image);
if (! hotspotRange)
@@ -670,8 +657,7 @@ xmc_save (GimpProcedure *procedure,
break;
}
- if (save_image (g_file_get_path (file),
- image, drawable, orig_image,
+ if (save_image (file, image, drawable, orig_image,
&error))
{
gimp_set_data (SAVE_PROC, &xmcvals, sizeof (XmcSaveVals));
@@ -692,8 +678,6 @@ xmc_save (GimpProcedure *procedure,
xmcparas.comments[i] = NULL;
}
- g_free (filename);
-
return gimp_procedure_new_return_values (procedure, status, error);
}
@@ -702,9 +686,10 @@ xmc_save (GimpProcedure *procedure,
*/
static GimpImage *
-load_image (const gchar *filename,
- GError **error)
+load_image (GFile *file,
+ GError **error)
{
+ gchar *filename;
FILE *fp;
GimpImage *image;
GimpLayer *layer;
@@ -719,24 +704,26 @@ load_image (const gchar *filename,
gint i, j;
gimp_progress_init_printf (_("Opening '%s'"),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
/* Open the file and check it is a valid X cursor */
+ filename = g_file_get_path (file);
fp = g_fopen (filename, "rb");
+ g_free (filename);
if (fp == NULL)
{
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));
+ gimp_file_get_utf8_name (file), g_strerror (errno));
return NULL;
}
if (! XcursorFileLoad (fp, &commentsp, &imagesp))
{
g_set_error (error, 0, 0, _("'%s' is not a valid X cursor."),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
fclose (fp);
return NULL;
}
@@ -749,7 +736,7 @@ load_image (const gchar *filename,
{
g_set_error (error, 0, 0,
_("Frame %d of '%s' is too wide for an X cursor."),
- i + 1, gimp_filename_to_utf8 (filename));
+ i + 1, gimp_file_get_utf8_name (file));
fclose (fp);
return NULL;
}
@@ -757,7 +744,7 @@ load_image (const gchar *filename,
{
g_set_error (error, 0, 0,
_("Frame %d of '%s' is too high for an X cursor."),
- i + 1, gimp_filename_to_utf8 (filename));
+ i + 1, gimp_file_get_utf8_name (file));
fclose (fp);
return NULL;
}
@@ -772,7 +759,7 @@ load_image (const gchar *filename,
image = gimp_image_new (img_width, img_height, GIMP_RGB);
- gimp_image_set_filename (image, filename);
+ gimp_image_set_file (image, file);
if (! set_hotspot_to_parasite (image))
{
@@ -878,12 +865,12 @@ load_image (const gchar *filename,
*/
static GimpImage *
-load_thumbnail (const gchar *filename,
- gint32 thumb_size,
- gint32 *thumb_width,
- gint32 *thumb_height,
- gint32 *thumb_num_layers,
- GError **error)
+load_thumbnail (GFile *file,
+ gint32 thumb_size,
+ gint32 *thumb_width,
+ gint32 *thumb_height,
+ gint32 *thumb_num_layers,
+ GError **error)
{
/* Return only one frame for thumbnail.
* We select first frame of an animation sequence which nominal size is the
@@ -897,6 +884,7 @@ load_thumbnail (const gchar *filename,
guint32 diff; /* difference between thumb_size and current size */
guint32 min_diff = XCURSOR_IMAGE_MAX_SIZE; /* minimum value of diff */
guint32 type; /* chunk type */
+ gchar *filename;
FILE *fp = NULL;
GimpImage *image = NULL;
GimpLayer *layer;
@@ -916,13 +904,15 @@ load_thumbnail (const gchar *filename,
*thumb_height = 0;
*thumb_num_layers = 0;
+ filename = g_file_get_path (file);
fp = g_fopen (filename, "rb");
+ g_free (file);
- if (fp == NULL)
+ if (! fp)
{
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));
+ gimp_file_get_utf8_name (file), g_strerror (errno));
return NULL;
}
@@ -943,7 +933,7 @@ load_thumbnail (const gchar *filename,
{
g_set_error (error, 0, 0,
"'%s' seems to have an incorrect toc size.",
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
fclose (fp);
return NULL;
}
@@ -982,7 +972,7 @@ load_thumbnail (const gchar *filename,
{
g_set_error (error, 0, 0,
_("there is no image chunk in \"%s\"."),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
fclose (fp);
return NULL;
}
@@ -1023,7 +1013,7 @@ load_thumbnail (const gchar *filename,
{
g_set_error (error, 0, 0,
_("'%s' is too wide for an X cursor."),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
fclose (fp);
return NULL;
}
@@ -1032,7 +1022,7 @@ load_thumbnail (const gchar *filename,
{
g_set_error (error, 0, 0,
_("'%s' is too high for an X cursor."),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
fclose (fp);
return NULL;
}
@@ -1511,12 +1501,13 @@ load_default_hotspot (GimpImage *image,
*/
static gboolean
-save_image (const gchar *filename,
+save_image (GFile *file,
GimpImage *image,
GimpDrawable *drawable,
GimpImage *orig_image,
GError **error)
{
+ gchar *filename;
FILE *fp; /* File pointer */
gboolean dimension_warn = FALSE; /* become TRUE if even one
* of the dimensions of the
@@ -1553,18 +1544,22 @@ save_image (const gchar *filename,
NULL);
gimp_progress_init_printf (_("Saving '%s'"),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
/*
* Open the file pointer.
*/
DM_XMC ("Open the file pointer.\n");
+
+ filename = g_file_get_path (file);
fp = g_fopen (filename, "wb");
- if (fp == NULL)
+ g_free (filename);
+
+ if (! fp)
{
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));
return FALSE;
}
diff --git a/plug-ins/common/file-xpm.c b/plug-ins/common/file-xpm.c
index 2e6faa6103..34bf5697e4 100644
--- a/plug-ins/common/file-xpm.c
+++ b/plug-ins/common/file-xpm.c
@@ -121,13 +121,13 @@ static GimpValueArray * xpm_save (GimpProcedure *procedure,
const GimpValueArray *args,
gpointer run_data);
-static GimpImage * load_image (const gchar *filename,
+static GimpImage * load_image (GFile *file,
GError **error);
static guchar * parse_colors (XpmImage *xpm_image);
static void parse_image (GimpImage *image,
XpmImage *xpm_image,
guchar *cmap);
-static gboolean save_image (const gchar *filename,
+static gboolean save_image (GFile *file,
GimpImage *image,
GimpDrawable *drawable,
GError **error);
@@ -280,7 +280,7 @@ xpm_load (GimpProcedure *procedure,
INIT_I18N ();
gegl_init (NULL, NULL);
- image = load_image (g_file_get_path (file), &error);
+ image = load_image (file, &error);
if (! image)
return gimp_procedure_new_return_values (procedure,
@@ -358,8 +358,7 @@ xpm_save (GimpProcedure *procedure,
if (status == GIMP_PDB_SUCCESS)
{
- if (save_image (g_file_get_path (file),
- image, drawable,
+ if (save_image (file, image, drawable,
&error))
{
gimp_set_data (SAVE_PROC, &xpmvals, sizeof (XpmSaveVals));
@@ -377,18 +376,21 @@ xpm_save (GimpProcedure *procedure,
}
static GimpImage *
-load_image (const gchar *filename,
- GError **error)
+load_image (GFile *file,
+ GError **error)
{
+ gchar *filename;
XpmImage xpm_image;
guchar *cmap;
GimpImage *image;
gimp_progress_init_printf (_("Opening '%s'"),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
+
+ filename = g_file_get_path (file);
/* read the raw file */
- switch (XpmReadFileToXpmImage ((char *) filename, &xpm_image, NULL))
+ switch (XpmReadFileToXpmImage (filename, &xpm_image, NULL))
{
case XpmSuccess:
break;
@@ -396,25 +398,30 @@ load_image (const gchar *filename,
case XpmOpenFailed:
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
_("Error opening file '%s'"),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
+ g_free (filename);
return NULL;
case XpmFileInvalid:
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
"%s", _("XPM file invalid"));
+ g_free (filename);
return NULL;
default:
+ g_free (filename);
return NULL;
}
+ g_free (filename);
+
cmap = parse_colors (&xpm_image);
image = gimp_image_new (xpm_image.width,
xpm_image.height,
GIMP_RGB);
- gimp_image_set_filename (image, filename);
+ gimp_image_set_file (image, file);
/* fill it */
parse_image (image, &xpm_image, cmap);
@@ -622,7 +629,7 @@ create_colormap_from_hash (gpointer gkey,
}
static gboolean
-save_image (const gchar *filename,
+save_image (GFile *file,
GimpImage *image,
GimpDrawable *drawable,
GError **error)
@@ -636,6 +643,7 @@ save_image (const gchar *filename,
gboolean indexed;
gboolean alpha;
XpmColor *colormap;
+ gchar *filename;
XpmImage *xpm_image;
guint *ibuff = NULL;
guchar *buf;
@@ -690,7 +698,7 @@ save_image (const gchar *filename,
hash = g_hash_table_new ((GHashFunc) rgbhash, (GCompareFunc) compare);
gimp_progress_init_printf (_("Exporting '%s'"),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
ncolors = alpha ? 1 : 0;
@@ -817,8 +825,10 @@ save_image (const gchar *filename,
xpm_image->colorTable = colormap;
xpm_image->data = ibuff;
+ filename = g_file_get_path (file);
+
/* do the save */
- switch (XpmWriteFileFromXpmImage ((char *) filename, xpm_image, NULL))
+ switch (XpmWriteFileFromXpmImage (filename, xpm_image, NULL))
{
case XpmSuccess:
success = TRUE;
@@ -827,7 +837,7 @@ save_image (const gchar *filename,
case XpmOpenFailed:
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
_("Error opening file '%s'"),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
break;
case XpmFileInvalid:
@@ -839,6 +849,8 @@ save_image (const gchar *filename,
break;
}
+ g_free (filename);
+
g_object_unref (buffer);
g_free (ibuff);
diff --git a/plug-ins/common/file-xwd.c b/plug-ins/common/file-xwd.c
index 6518d60a1a..caa77cbca2 100644
--- a/plug-ins/common/file-xwd.c
+++ b/plug-ins/common/file-xwd.c
@@ -172,13 +172,13 @@ static GimpValueArray * xwd_save (GimpProcedure *procedure,
const GimpValueArray *args,
gpointer run_data);
-static GimpImage * load_image (const gchar *filename,
+static GimpImage * load_image (GFile *file,
GError **error);
static gboolean save_image (GFile *file,
GimpImage *image,
GimpDrawable *drawable,
GError **error);
-static GimpImage * create_new_image (const gchar *filename,
+static GimpImage * create_new_image (GFile *file,
guint width,
guint height,
GimpImageBaseType type,
@@ -200,28 +200,28 @@ static void set_color_table (GimpImage *image,
L_XWDFILEHEADER *xwdhdr,
L_XWDCOLOR *xwdcolmap);
-static GimpImage * load_xwd_f2_d1_b1 (const gchar *filename,
+static GimpImage * load_xwd_f2_d1_b1 (GFile *file,
FILE *ifp,
L_XWDFILEHEADER *xwdhdr,
L_XWDCOLOR *xwdcolmap);
-static GimpImage * load_xwd_f2_d8_b8 (const gchar *filename,
+static GimpImage * load_xwd_f2_d8_b8 (GFile *file,
FILE *ifp,
L_XWDFILEHEADER *xwdhdr,
L_XWDCOLOR *xwdcolmap);
-static GimpImage * load_xwd_f2_d16_b16 (const gchar *filename,
+static GimpImage * load_xwd_f2_d16_b16 (GFile *file,
FILE *ifp,
L_XWDFILEHEADER *xwdhdr,
L_XWDCOLOR *xwdcolmap);
-static GimpImage * load_xwd_f2_d24_b32 (const gchar *filename,
+static GimpImage * load_xwd_f2_d24_b32 (GFile *file,
FILE *ifp,
L_XWDFILEHEADER *xwdhdr,
L_XWDCOLOR *xwdcolmap,
GError **error);
-static GimpImage * load_xwd_f2_d32_b32 (const gchar *filename,
+static GimpImage * load_xwd_f2_d32_b32 (GFile *file,
FILE *ifp,
L_XWDFILEHEADER *xwdhdr,
L_XWDCOLOR *xwdcolmap);
-static GimpImage * load_xwd_f1_d24_b1 (const gchar *filename,
+static GimpImage * load_xwd_f1_d24_b1 (GFile *file,
FILE *ifp,
L_XWDFILEHEADER *xwdhdr,
L_XWDCOLOR *xwdcolmap,
@@ -376,17 +376,12 @@ xwd_load (GimpProcedure *procedure,
{
GimpValueArray *return_vals;
GimpImage *image;
- gchar *filename;
GError *error = NULL;
INIT_I18N ();
gegl_init (NULL, NULL);
- filename = g_file_get_path (file);
-
- image = load_image (filename, &error);
-
- g_free (filename);
+ image = load_image (file, &error);
if (! image)
return gimp_procedure_new_return_values (procedure,
@@ -451,24 +446,28 @@ xwd_save (GimpProcedure *procedure,
}
static GimpImage *
-load_image (const gchar *filename,
- GError **error)
+load_image (GFile *file,
+ GError **error)
{
- FILE *ifp = NULL;
+ gchar *filename;
+ FILE *ifp;
gint depth, bpp;
GimpImage *image = NULL;
L_XWDFILEHEADER xwdhdr;
L_XWDCOLOR *xwdcolmap = NULL;
gimp_progress_init_printf (_("Opening '%s'"),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
+ filename = g_file_get_path (file);
ifp = g_fopen (filename, "rb");
- if (!ifp)
+ g_free (filename);
+
+ if (! ifp)
{
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));
+ gimp_file_get_utf8_name (file), g_strerror (errno));
goto out;
}
@@ -477,7 +476,7 @@ load_image (const gchar *filename,
{
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
_("Could not read XWD header from '%s'"),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
goto out;
}
@@ -498,7 +497,7 @@ load_image (const gchar *filename,
if (xwdhdr.l_colormap_entries > 256)
{
g_message (_("'%s':\nIllegal number of colormap entries: %ld"),
- gimp_filename_to_utf8 (filename),
+ gimp_file_get_utf8_name (file),
(long)xwdhdr.l_colormap_entries);
goto out;
}
@@ -508,7 +507,7 @@ load_image (const gchar *filename,
if (xwdhdr.l_colormap_entries < xwdhdr.l_ncolors)
{
g_message (_("'%s':\nNumber of colormap entries < number of colors"),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
goto out;
}
@@ -519,7 +518,7 @@ load_image (const gchar *filename,
#ifdef XWD_COL_DEBUG
{
int j;
- g_printf ("File %s\n",filename);
+ g_printf ("File %s\n", g_file_get_path (file));
for (j = 0; j < xwdhdr.l_colormap_entries; j++)
g_printf ("Entry 0x%08lx: 0x%04lx, 0x%04lx, 0x%04lx, %d\n",
(long)xwdcolmap[j].l_pixel,(long)xwdcolmap[j].l_red,
@@ -538,7 +537,7 @@ load_image (const gchar *filename,
if (xwdhdr.l_pixmap_width <= 0)
{
g_message (_("'%s':\nNo image width specified"),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
goto out;
}
@@ -546,21 +545,21 @@ load_image (const gchar *filename,
|| xwdhdr.l_bytes_per_line > GIMP_MAX_IMAGE_SIZE * 3)
{
g_message (_("'%s':\nImage width is larger than GIMP can handle"),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
goto out;
}
if (xwdhdr.l_pixmap_height <= 0)
{
g_message (_("'%s':\nNo image height specified"),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
goto out;
}
if (xwdhdr.l_pixmap_height > GIMP_MAX_IMAGE_SIZE)
{
g_message (_("'%s':\nImage height is larger than GIMP can handle"),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
goto out;
}
@@ -574,14 +573,14 @@ load_image (const gchar *filename,
case 0: /* Single plane bitmap */
if ((depth == 1) && (bpp == 1))
{ /* Can be performed by format 2 loader */
- image = load_xwd_f2_d1_b1 (filename, ifp, &xwdhdr, xwdcolmap);
+ image = load_xwd_f2_d1_b1 (file, ifp, &xwdhdr, xwdcolmap);
}
break;
case 1: /* Single plane pixmap */
if ((depth <= 24) && (bpp == 1))
{
- image = load_xwd_f1_d24_b1 (filename, ifp, &xwdhdr, xwdcolmap,
+ image = load_xwd_f1_d24_b1 (file, ifp, &xwdhdr, xwdcolmap,
error);
}
break;
@@ -589,24 +588,24 @@ load_image (const gchar *filename,
case 2: /* Multiplane pixmaps */
if ((depth == 1) && (bpp == 1))
{
- image = load_xwd_f2_d1_b1 (filename, ifp, &xwdhdr, xwdcolmap);
+ image = load_xwd_f2_d1_b1 (file, ifp, &xwdhdr, xwdcolmap);
}
else if ((depth <= 8) && (bpp == 8))
{
- image = load_xwd_f2_d8_b8 (filename, ifp, &xwdhdr, xwdcolmap);
+ image = load_xwd_f2_d8_b8 (file, ifp, &xwdhdr, xwdcolmap);
}
else if ((depth <= 16) && (bpp == 16))
{
- image = load_xwd_f2_d16_b16 (filename, ifp, &xwdhdr, xwdcolmap);
+ image = load_xwd_f2_d16_b16 (file, ifp, &xwdhdr, xwdcolmap);
}
else if ((depth <= 24) && ((bpp == 24) || (bpp == 32)))
{
- image = load_xwd_f2_d24_b32 (filename, ifp, &xwdhdr, xwdcolmap,
- error);
+ image = load_xwd_f2_d24_b32 (file, ifp, &xwdhdr, xwdcolmap,
+ error);
}
else if ((depth <= 32) && (bpp == 32))
{
- image = load_xwd_f2_d32_b32 (filename, ifp, &xwdhdr, xwdcolmap);
+ image = load_xwd_f2_d32_b32 (file, ifp, &xwdhdr, xwdcolmap);
}
break;
}
@@ -616,7 +615,7 @@ load_image (const gchar *filename,
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
_("XWD-file %s has format %d, depth %d and bits per pixel %d. "
"Currently this is not supported."),
- gimp_filename_to_utf8 (filename),
+ gimp_file_get_utf8_name (file),
(gint) xwdhdr.l_pixmap_format, depth, bpp);
out:
@@ -1278,7 +1277,7 @@ set_color_table (GimpImage *image,
/* Create an image. Sets layer, drawable and rgn. Returns image */
static GimpImage *
-create_new_image (const gchar *filename,
+create_new_image (GFile *file,
guint width,
guint height,
GimpImageBaseType type,
@@ -1289,7 +1288,7 @@ create_new_image (const gchar *filename,
GimpImage *image;
image = gimp_image_new (width, height, type);
- gimp_image_set_filename (image, filename);
+ gimp_image_set_file (image, file);
*layer = gimp_layer_new (image, "Background", width, height,
gdtype,
@@ -1306,7 +1305,7 @@ create_new_image (const gchar *filename,
/* Load XWD with pixmap_format 2, pixmap_depth 1, bits_per_pixel 1 */
static GimpImage *
-load_xwd_f2_d1_b1 (const gchar *filename,
+load_xwd_f2_d1_b1 (GFile *file,
FILE *ifp,
L_XWDFILEHEADER *xwdhdr,
L_XWDCOLOR *xwdcolmap)
@@ -1331,7 +1330,7 @@ load_xwd_f2_d1_b1 (const gchar *filename,
width = xwdhdr->l_pixmap_width;
height = xwdhdr->l_pixmap_height;
- image = create_new_image (filename, width, height, GIMP_INDEXED,
+ image = create_new_image (file, width, height, GIMP_INDEXED,
GIMP_INDEXED_IMAGE, &layer, &buffer);
tile_height = gimp_tile_height ();
@@ -1450,7 +1449,7 @@ load_xwd_f2_d1_b1 (const gchar *filename,
/* Load XWD with pixmap_format 2, pixmap_depth 8, bits_per_pixel 8 */
static GimpImage *
-load_xwd_f2_d8_b8 (const gchar *filename,
+load_xwd_f2_d8_b8 (GFile *file,
FILE *ifp,
L_XWDFILEHEADER *xwdhdr,
L_XWDCOLOR *xwdcolmap)
@@ -1487,7 +1486,7 @@ load_xwd_f2_d8_b8 (const gchar *filename,
grayscale = (j == 256);
}
- image = create_new_image (filename, width, height,
+ image = create_new_image (file, width, height,
grayscale ? GIMP_GRAY : GIMP_INDEXED,
grayscale ? GIMP_GRAY_IMAGE : GIMP_INDEXED_IMAGE,
&layer, &buffer);
@@ -1554,7 +1553,7 @@ load_xwd_f2_d8_b8 (const gchar *filename,
/* Load XWD with pixmap_format 2, pixmap_depth up to 16, bits_per_pixel 16 */
static GimpImage *
-load_xwd_f2_d16_b16 (const gchar *filename,
+load_xwd_f2_d16_b16 (GFile *file,
FILE *ifp,
L_XWDFILEHEADER *xwdhdr,
L_XWDCOLOR *xwdcolmap)
@@ -1580,7 +1579,7 @@ load_xwd_f2_d16_b16 (const gchar *filename,
width = xwdhdr->l_pixmap_width;
height = xwdhdr->l_pixmap_height;
- image = create_new_image (filename, width, height, GIMP_RGB,
+ image = create_new_image (file, width, height, GIMP_RGB,
GIMP_RGB_IMAGE, &layer, &buffer);
tile_height = gimp_tile_height ();
@@ -1714,7 +1713,7 @@ load_xwd_f2_d16_b16 (const gchar *filename,
/* Load XWD with pixmap_format 2, pixmap_depth up to 24, bits_per_pixel 24/32 */
static GimpImage *
-load_xwd_f2_d24_b32 (const gchar *filename,
+load_xwd_f2_d24_b32 (GFile *file,
FILE *ifp,
L_XWDFILEHEADER *xwdhdr,
L_XWDCOLOR *xwdcolmap,
@@ -1776,11 +1775,11 @@ load_xwd_f2_d24_b32 (const gchar *filename,
{
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
_("XWD-file %s is corrupt."),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
return NULL;
}
- image = create_new_image (filename, width, height, GIMP_RGB,
+ image = create_new_image (file, width, height, GIMP_RGB,
GIMP_RGB_IMAGE, &layer, &buffer);
tile_height = gimp_tile_height ();
@@ -1929,7 +1928,7 @@ load_xwd_f2_d24_b32 (const gchar *filename,
/* Load XWD with pixmap_format 2, pixmap_depth up to 32, bits_per_pixel 32 */
static GimpImage *
-load_xwd_f2_d32_b32 (const gchar *filename,
+load_xwd_f2_d32_b32 (GFile *file,
FILE *ifp,
L_XWDFILEHEADER *xwdhdr,
L_XWDCOLOR *xwdcolmap)
@@ -1957,7 +1956,7 @@ load_xwd_f2_d32_b32 (const gchar *filename,
width = xwdhdr->l_pixmap_width;
height = xwdhdr->l_pixmap_height;
- image = create_new_image (filename, width, height, GIMP_RGB,
+ image = create_new_image (file, width, height, GIMP_RGB,
GIMP_RGBA_IMAGE, &layer, &buffer);
tile_height = gimp_tile_height ();
@@ -2088,7 +2087,7 @@ load_xwd_f2_d32_b32 (const gchar *filename,
/* Load XWD with pixmap_format 1, pixmap_depth up to 24, bits_per_pixel 1 */
static GimpImage *
-load_xwd_f1_d24_b1 (const gchar *filename,
+load_xwd_f1_d24_b1 (GFile *file,
FILE *ifp,
L_XWDFILEHEADER *xwdhdr,
L_XWDCOLOR *xwdcolmap,
@@ -2176,7 +2175,7 @@ load_xwd_f1_d24_b1 (const gchar *filename,
{
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
_("XWD-file %s is corrupt."),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
return NULL;
}
@@ -2189,7 +2188,7 @@ load_xwd_f1_d24_b1 (const gchar *filename,
bluemap[blue] = (blue * 255) / maxblue;
}
- image = create_new_image (filename, width, height,
+ image = create_new_image (file, width, height,
indexed ? GIMP_INDEXED : GIMP_RGB,
indexed ? GIMP_INDEXED_IMAGE : GIMP_RGB_IMAGE,
&layer, &buffer);
diff --git a/plug-ins/common/film.c b/plug-ins/common/film.c
index 8bfdf2cfab..843d90bae7 100644
--- a/plug-ins/common/film.c
+++ b/plug-ins/common/film.c
@@ -103,8 +103,7 @@ static GimpValueArray * film_run (GimpProcedure *procedure,
const GimpValueArray *args,
gpointer run_data);
-static GimpImage * create_new_image (const gchar *filename,
- guint width,
+static GimpImage * create_new_image (guint width,
guint height,
GimpImageType gdtype,
GimpLayer **layer);
@@ -502,8 +501,7 @@ film (void)
g_printerr ("Number of pictures = %d\n", num_pictures);
#endif
- image_dst = create_new_image (_("Untitled"),
- (guint) film_width, (guint) film_height,
+ image_dst = create_new_image ((guint) film_width, (guint) film_height,
GIMP_RGB_IMAGE, &layer_dst);
/* Fill film background */
@@ -762,8 +760,7 @@ draw_number (GimpLayer *layer,
/* Create an image. Sets layer, drawable and rgn. Returns image */
static GimpImage *
-create_new_image (const gchar *filename,
- guint width,
+create_new_image (guint width,
guint height,
GimpImageType gdtype,
GimpLayer **layer)
@@ -779,7 +776,6 @@ create_new_image (const gchar *filename,
gitype = GIMP_RGB;
image = gimp_image_new (width, height, gitype);
- gimp_image_set_filename (image, filename);
gimp_image_undo_disable (image);
*layer = gimp_layer_new (image, _("Background"), width, height,
diff --git a/plug-ins/common/guillotine.c b/plug-ins/common/guillotine.c
index a58b1807b5..c3adab81b5 100644
--- a/plug-ins/common/guillotine.c
+++ b/plug-ins/common/guillotine.c
@@ -248,16 +248,16 @@ guillotine (GimpImage *image,
if (guides_found)
{
- gchar *filename;
+ GFile *file;
gint h, v, hpad, vpad;
gint x, y;
gchar *hformat;
gchar *format;
- filename = gimp_image_get_filename (image);
+ file = gimp_image_get_file (image);
- if (! filename)
- filename = g_strdup (_("Untitled"));
+ if (! file)
+ file = g_file_new_for_uri (_("Untitled"));
/* get the number horizontal and vertical slices */
h = g_list_length (hguides);
@@ -279,7 +279,8 @@ guillotine (GimpImage *image,
for (x = 0, vg = vguides; vg && vg->next; x++, vg = vg->next)
{
GimpImage *new_image = gimp_image_duplicate (image);
- GString *new_filename;
+ GString *new_uri;
+ GFile *new_file;
gchar *fileextension;
gchar *fileindex;
gint pos;
@@ -303,21 +304,24 @@ guillotine (GimpImage *image,
GPOINTER_TO_INT (hg->data));
- new_filename = g_string_new (filename);
+ new_uri = g_string_new (g_file_get_uri (file));
/* show the rough coordinates of the image in the title */
fileindex = g_strdup_printf (format, x, y);
/* get the position of the file extension - last . in filename */
- fileextension = strrchr (new_filename->str, '.');
- pos = fileextension - new_filename->str;
+ fileextension = strrchr (new_uri->str, '.');
+ pos = fileextension - new_uri->str;
/* insert the coordinates before the extension */
- g_string_insert (new_filename, pos, fileindex);
+ g_string_insert (new_uri, pos, fileindex);
g_free (fileindex);
- gimp_image_set_filename (new_image, new_filename->str);
- g_string_free (new_filename, TRUE);
+ new_file = g_file_new_for_uri (new_uri->str);
+ g_string_free (new_uri, TRUE);
+
+ gimp_image_set_file (new_image, new_file);
+ g_object_unref (new_file);
while ((guide = gimp_image_find_next_guide (new_image, 0)))
gimp_image_delete_guide (new_image, guide);
@@ -331,7 +335,7 @@ guillotine (GimpImage *image,
}
}
- g_free (filename);
+ g_object_unref (file);
g_free (hformat);
g_free (format);
}
diff --git a/plug-ins/common/mail.c b/plug-ins/common/mail.c
index 56e6062b47..c4ff430401 100644
--- a/plug-ins/common/mail.c
+++ b/plug-ins/common/mail.c
@@ -266,7 +266,7 @@ mail_run (GimpProcedure *procedure,
case GIMP_RUN_INTERACTIVE:
gimp_get_data (PLUG_IN_PROC, &mail_info);
{
- gchar *filename = gimp_image_get_filename (image);
+ gchar *filename = g_file_get_path (gimp_image_get_file (image));
if (filename)
{
@@ -353,7 +353,8 @@ send_image (const gchar *filename,
if (! (gimp_file_save (run_mode,
image,
drawable,
- tmpname) && valid_file (tmpname)))
+ g_file_new_for_path (tmpname)) &&
+ valid_file (tmpname)))
{
goto error;
}
diff --git a/plug-ins/common/plugin-defs.pl b/plug-ins/common/plugin-defs.pl
index c816b6aa71..e6f94316b9 100644
--- a/plug-ins/common/plugin-defs.pl
+++ b/plug-ins/common/plugin-defs.pl
@@ -54,7 +54,7 @@
'film' => { ui => 1, gegl => 1 },
'gradient-map' => { gegl => 1 },
'grid' => { ui => 1, gegl => 1 },
- 'guillotine' => { },
+ 'guillotine' => { gio => 1 },
'hot' => { ui => 1, gegl => 1 },
'jigsaw' => { ui => 1, gegl => 1 },
'mail' => { ui => 1, optional => 1 },
diff --git a/plug-ins/file-bmp/bmp-load.c b/plug-ins/file-bmp/bmp-load.c
index cf6fbba18c..a4653340c6 100644
--- a/plug-ins/file-bmp/bmp-load.c
+++ b/plug-ins/file-bmp/bmp-load.c
@@ -45,7 +45,7 @@
static GimpImage * ReadImage (FILE *fd,
- const gchar *filename,
+ GFile *file,
gint width,
gint height,
guchar cmap[256][3],
@@ -201,9 +201,10 @@ ReadChannelMasks (guint32 *tmp,
}
GimpImage *
-load_image (const gchar *filename,
- GError **error)
+load_image (GFile *file,
+ GError **error)
{
+ gchar *filename;
FILE *fd;
BitmapFileHead bitmap_file_head;
BitmapHead bitmap_head;
@@ -216,15 +217,17 @@ load_image (const gchar *filename,
BitmapChannel masks[4];
gimp_progress_init_printf (_("Opening '%s'"),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
+ filename = g_file_get_path (file);
fd = g_fopen (filename, "rb");
+ g_free (filename);
- if (!fd)
+ if (! fd)
{
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));
+ gimp_file_get_utf8_name (file), g_strerror (errno));
goto out;
}
@@ -240,7 +243,7 @@ load_image (const gchar *filename,
{
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
_("'%s' is not a valid BMP file"),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
goto out;
}
@@ -250,7 +253,7 @@ load_image (const gchar *filename,
{
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
_("'%s' is not a valid BMP file"),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
goto out;
}
@@ -258,7 +261,7 @@ load_image (const gchar *filename,
{
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
_("'%s' is not a valid BMP file"),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
goto out;
}
}
@@ -267,7 +270,7 @@ load_image (const gchar *filename,
{
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
_("'%s' is not a valid BMP file"),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
goto out;
}
@@ -282,7 +285,7 @@ load_image (const gchar *filename,
{
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
_("'%s' is not a valid BMP file"),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
goto out;
}
@@ -296,7 +299,7 @@ load_image (const gchar *filename,
{
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
_("Error reading BMP file header from '%s'"),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
goto out;
}
@@ -323,7 +326,7 @@ load_image (const gchar *filename,
{
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
_("Error reading BMP file header from '%s'"),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
goto out;
}
@@ -355,7 +358,7 @@ load_image (const gchar *filename,
{
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
_("Error reading BMP file header from '%s'"),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
goto out;
}
@@ -380,7 +383,7 @@ load_image (const gchar *filename,
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
_("Unsupported compression (%u) in BMP file from '%s'"),
bitmap_head.biCompr,
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
}
#ifdef DEBUG
@@ -396,7 +399,7 @@ load_image (const gchar *filename,
{
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
_("Error reading BMP file header from '%s'"),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
goto out;
}
@@ -427,7 +430,7 @@ load_image (const gchar *filename,
{
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
_("Error reading BMP file header from '%s'"),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
goto out;
}
@@ -469,7 +472,7 @@ load_image (const gchar *filename,
{
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
_("Error reading BMP file header from '%s'"),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
goto out;
}
@@ -489,7 +492,7 @@ load_image (const gchar *filename,
default:
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
_("'%s' is not a valid BMP file"),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
goto out;
}
@@ -514,7 +517,7 @@ load_image (const gchar *filename,
{
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
_("'%s' is not a valid BMP file"),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
goto out;
}
@@ -525,7 +528,7 @@ load_image (const gchar *filename,
{
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
_("'%s' is not a valid BMP file"),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
goto out;
}
@@ -533,7 +536,7 @@ load_image (const gchar *filename,
{
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
_("'%s' is not a valid BMP file"),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
goto out;
}
@@ -542,7 +545,7 @@ load_image (const gchar *filename,
{
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
_("'%s' is not a valid BMP file"),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
goto out;
}
@@ -554,7 +557,7 @@ load_image (const gchar *filename,
{
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
_("'%s' is not a valid BMP file"),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
goto out;
}
@@ -590,7 +593,7 @@ load_image (const gchar *filename,
/* Get the Image and return the image or NULL on error*/
image = ReadImage (fd,
- filename,
+ file,
bitmap_head.biWidth,
ABS (bitmap_head.biHeight),
ColorMap,
@@ -636,7 +639,7 @@ out:
static GimpImage *
ReadImage (FILE *fd,
- const gchar *filename,
+ GFile *file,
gint width,
gint height,
guchar cmap[256][3],
@@ -736,7 +739,7 @@ ReadImage (FILE *fd,
image_type, 100,
gimp_image_get_default_new_layer_mode (image));
- gimp_image_set_filename (image, filename);
+ gimp_image_set_file (image, file);
gimp_image_insert_layer (image, layer, NULL, 0);
diff --git a/plug-ins/file-bmp/bmp-load.h b/plug-ins/file-bmp/bmp-load.h
index 4ee93c78c6..0a44cc766d 100644
--- a/plug-ins/file-bmp/bmp-load.h
+++ b/plug-ins/file-bmp/bmp-load.h
@@ -20,8 +20,8 @@
#define __BMP_LOAD_H__
-GimpImage * load_image (const gchar *filename,
- GError **error);
+GimpImage * load_image (GFile *file,
+ GError **error);
#endif /* __BMP_LOAD_H__ */
diff --git a/plug-ins/file-bmp/bmp-save.c b/plug-ins/file-bmp/bmp-save.c
index fcdb83c8b0..392f6597de 100644
--- a/plug-ins/file-bmp/bmp-save.c
+++ b/plug-ins/file-bmp/bmp-save.c
@@ -124,12 +124,13 @@ warning_dialog (const gchar *primary,
}
GimpPDBStatusType
-save_image (const gchar *filename,
+save_image (GFile *file,
GimpImage *image,
GimpDrawable *drawable,
GimpRunMode run_mode,
GError **error)
{
+ gchar *filename;
FILE *outfile;
BitmapFileHead bitmap_file_head;
BitmapHead bitmap_head;
@@ -308,15 +309,18 @@ save_image (const gchar *filename,
/* Let's begin the progress */
gimp_progress_init_printf (_("Exporting '%s'"),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
/* Let's take some file */
+ filename = g_file_get_path (file);
outfile = g_fopen (filename, "wb");
- if (!outfile)
+ g_free (filename);
+
+ if (! outfile)
{
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));
return GIMP_PDB_EXECUTION_ERROR;
}
diff --git a/plug-ins/file-bmp/bmp-save.h b/plug-ins/file-bmp/bmp-save.h
index 189d63161e..be2ea9057b 100644
--- a/plug-ins/file-bmp/bmp-save.h
+++ b/plug-ins/file-bmp/bmp-save.h
@@ -20,7 +20,7 @@
#define __BMP_SAVE_H__
-GimpPDBStatusType save_image (const gchar *filename,
+GimpPDBStatusType save_image (GFile *file,
GimpImage *image,
GimpDrawable *drawable,
GimpRunMode run_mode,
diff --git a/plug-ins/file-bmp/bmp.c b/plug-ins/file-bmp/bmp.c
index 7be63e2c3b..5c11ef60bb 100644
--- a/plug-ins/file-bmp/bmp.c
+++ b/plug-ins/file-bmp/bmp.c
@@ -201,17 +201,12 @@ bmp_load (GimpProcedure *procedure,
{
GimpValueArray *return_vals;
GimpImage *image;
- gchar *filename;
GError *error = NULL;
INIT_I18N ();
gegl_init (NULL, NULL);
- filename = g_file_get_path (file);
-
- image = load_image (filename, &error);
-
- g_free (filename);
+ image = load_image (file, &error);
if (! image)
return gimp_procedure_new_return_values (procedure,
@@ -265,9 +260,7 @@ bmp_save (GimpProcedure *procedure,
break;
}
- status = save_image (g_file_get_path (file),
- image, drawable,
- run_mode,
+ status = save_image (file, image, drawable, run_mode,
&error);
if (export == GIMP_EXPORT_EXPORT)
diff --git a/plug-ins/file-dds/dds.c b/plug-ins/file-dds/dds.c
index f7d7949349..dd9dab9a18 100644
--- a/plug-ins/file-dds/dds.c
+++ b/plug-ins/file-dds/dds.c
@@ -398,7 +398,7 @@ dds_load (GimpProcedure *procedure,
break;
}
- status = read_dds (g_file_get_path (file), &image,
+ status = read_dds (file, &image,
run_mode == GIMP_RUN_INTERACTIVE);
if (status == GIMP_PDB_SUCCESS &&
@@ -495,8 +495,7 @@ dds_save (GimpProcedure *procedure,
*/
dds_write_vals.gamma = 2.2;
- status = write_dds (g_file_get_path (file),
- image, drawable,
+ status = write_dds (file, image, drawable,
run_mode == GIMP_RUN_INTERACTIVE);
if (status == GIMP_PDB_SUCCESS)
diff --git a/plug-ins/file-dds/ddsplugin.h b/plug-ins/file-dds/ddsplugin.h
index 7f66ddf78d..06cb0348e7 100644
--- a/plug-ins/file-dds/ddsplugin.h
+++ b/plug-ins/file-dds/ddsplugin.h
@@ -57,10 +57,10 @@ typedef struct
extern DDSWriteVals dds_write_vals;
extern DDSReadVals dds_read_vals;
-extern GimpPDBStatusType read_dds (gchar *filename,
+extern GimpPDBStatusType read_dds (GFile *file,
GimpImage **image,
gboolean interactive_dds);
-extern GimpPDBStatusType write_dds (gchar *filename,
+extern GimpPDBStatusType write_dds (GFile *file,
GimpImage *image,
GimpDrawable *drawable,
gboolean interactive_dds);
diff --git a/plug-ins/file-dds/ddsread.c b/plug-ins/file-dds/ddsread.c
index b834c6a801..6ec16b98b3 100644
--- a/plug-ins/file-dds/ddsread.c
+++ b/plug-ins/file-dds/ddsread.c
@@ -98,7 +98,7 @@ static int load_dialog (void);
static gboolean runme = FALSE;
GimpPDBStatusType
-read_dds (gchar *filename,
+read_dds (GFile *file,
GimpImage **ret_image,
gboolean interactive_dds)
{
@@ -106,7 +106,7 @@ read_dds (gchar *filename,
unsigned char *buf;
unsigned int l = 0;
guchar *pixels;
- gchar *tmp;
+ gchar *filename;
FILE *fp;
dds_header_t hdr;
dds_header_dx10_t dx10hdr;
@@ -121,19 +121,17 @@ read_dds (gchar *filename,
return GIMP_PDB_CANCEL;
}
+ filename = g_file_get_path (file);
fp = g_fopen (filename, "rb");
- if (fp == 0)
+ g_free (filename);
+
+ if (! fp)
{
g_message ("Error opening file.\n");
return GIMP_PDB_EXECUTION_ERROR;
}
- if (strrchr (filename, '/'))
- tmp = g_strdup_printf ("Loading %s:", strrchr (filename, '/') + 1);
- else
- tmp = g_strdup_printf ("Loading %s:", filename);
- gimp_progress_init (tmp);
- g_free (tmp);
+ gimp_progress_init_printf ("Loading %s:", gimp_file_get_utf8_name (file));
/* read header */
read_header (&hdr, fp);
@@ -282,7 +280,7 @@ read_dds (gchar *filename,
return GIMP_PDB_EXECUTION_ERROR;
}
- gimp_image_set_filename (image, filename);
+ gimp_image_set_file (image, file);
if (hdr.pixelfmt.flags & DDPF_PALETTEINDEXED8)
{
diff --git a/plug-ins/file-dds/ddswrite.c b/plug-ins/file-dds/ddswrite.c
index a01e7ed63b..ff7ea0cc43 100644
--- a/plug-ins/file-dds/ddswrite.c
+++ b/plug-ins/file-dds/ddswrite.c
@@ -590,13 +590,13 @@ get_array_size (GimpImage *image)
}
GimpPDBStatusType
-write_dds (gchar *filename,
+write_dds (GFile *file,
GimpImage *image,
GimpDrawable *drawable,
gboolean interactive_dds)
{
+ gchar *filename;
FILE *fp;
- gchar *tmp;
int rc = 0;
is_mipmap_chain_valid = check_mipmaps (image, dds_write_vals.savetype);
@@ -643,19 +643,17 @@ write_dds (gchar *filename,
}
}
+ filename = g_file_get_path (file);
fp = g_fopen (filename, "wb");
- if (fp == 0)
+ g_free (filename);
+
+ if (! fp)
{
g_message ("Error opening %s", filename);
return GIMP_PDB_EXECUTION_ERROR;
}
- if (strrchr (filename, '/'))
- tmp = g_strdup_printf ("Saving %s:", strrchr (filename, '/') + 1);
- else
- tmp = g_strdup_printf ("Saving %s:", filename);
- gimp_progress_init (tmp);
- g_free (tmp);
+ gimp_progress_init_printf ("Saving %s:", gimp_file_get_utf8_name (file));
rc = write_image (fp, image, drawable);
diff --git a/plug-ins/file-exr/file-exr.c b/plug-ins/file-exr/file-exr.c
index d3cab72a76..faf5cc8c95 100644
--- a/plug-ins/file-exr/file-exr.c
+++ b/plug-ins/file-exr/file-exr.c
@@ -58,7 +58,7 @@ static GimpValueArray * exr_load (GimpProcedure *procedure,
const GimpValueArray *args,
gpointer run_data);
-static GimpImage * load_image (const gchar *filename,
+static GimpImage * load_image (GFile *file,
gboolean interactive,
GError **error);
static void sanitize_comment (gchar *comment);
@@ -139,8 +139,7 @@ exr_load (GimpProcedure *procedure,
INIT_I18N ();
gegl_init (NULL, NULL);
- image = load_image (g_file_get_path (file),
- run_mode == GIMP_RUN_INTERACTIVE,
+ image = load_image (file, run_mode == GIMP_RUN_INTERACTIVE,
&error);
if (! image)
@@ -158,10 +157,11 @@ exr_load (GimpProcedure *procedure,
}
static GimpImage *
-load_image (const gchar *filename,
+load_image (GFile *file,
gboolean interactive,
GError **error)
{
+ gchar *filename;
EXRLoader *loader;
gint width;
gint height;
@@ -186,15 +186,17 @@ load_image (const gchar *filename,
guint xmp_size;
gimp_progress_init_printf (_("Opening '%s'"),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
+ filename = g_file_get_path (file);
loader = exr_loader_new (filename);
+ g_free (filename);
if (! loader)
{
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
_("Error opening file '%s' for reading"),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
goto out;
}
@@ -205,7 +207,7 @@ load_image (const gchar *filename,
{
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
_("Error querying image dimensions from '%s'"),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
goto out;
}
@@ -225,7 +227,7 @@ load_image (const gchar *filename,
default:
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
_("Error querying image precision from '%s'"),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
goto out;
}
@@ -242,7 +244,7 @@ load_image (const gchar *filename,
default:
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
_("Error querying image type from '%s'"),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
goto out;
}
@@ -252,12 +254,12 @@ load_image (const gchar *filename,
{
g_set_error (error, 0, 0,
_("Could not create new image for '%s': %s"),
- gimp_filename_to_utf8 (filename),
+ gimp_file_get_utf8_name (file),
gimp_pdb_get_last_error (gimp_get_pdb ()));
goto out;
}
- gimp_image_set_filename (image, filename);
+ gimp_image_set_file (image, file);
/* try to load an icc profile, it will be generated on the fly if
* chromaticities are given
@@ -302,7 +304,7 @@ load_image (const gchar *filename,
{
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
_("Error reading pixel data from '%s'"),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
goto out;
}
}
diff --git a/plug-ins/file-faxg3/faxg3.c b/plug-ins/file-faxg3/faxg3.c
index 805907d97a..639ec44248 100644
--- a/plug-ins/file-faxg3/faxg3.c
+++ b/plug-ins/file-faxg3/faxg3.c
@@ -81,14 +81,14 @@ static GimpValueArray * faxg3_load (GimpProcedure *procedure,
const GimpValueArray *args,
gpointer run_data);
-static GimpImage * load_image (const gchar *filename,
+static GimpImage * load_image (GFile *file,
GError **error);
static GimpImage * emitgimp (gint hcol,
gint row,
const gchar *bitmap,
gint bperrow,
- const gchar *filename);
+ GFile *file);
G_DEFINE_TYPE (Faxg3, faxg3, GIMP_TYPE_PLUG_IN)
@@ -165,7 +165,7 @@ faxg3_load (GimpProcedure *procedure,
INIT_I18N ();
gegl_init (NULL, NULL);
- image = load_image (g_file_get_path (file), &error);
+ image = load_image (file, &error);
if (! image)
return gimp_procedure_new_return_values (procedure,
@@ -214,13 +214,14 @@ static int rs; /* read buffer size */
static GimpImage *
-load_image (const gchar *filename,
- GError **error)
+load_image (GFile *file,
+ GError **error)
{
int data;
int hibit;
struct g3_tree *p;
int nr_pels;
+ gchar *filename;
int fd;
int color;
int i, rr, rsize;
@@ -235,7 +236,7 @@ load_image (const gchar *filename,
gint col, hcol; /* column, highest column ever used */
gimp_progress_init_printf (_("Opening '%s'"),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
/* initialize lookup trees */
build_tree (&white, t_white);
@@ -245,13 +246,15 @@ load_image (const gchar *filename,
init_byte_tab (0, byte_tab);
+ filename = g_file_get_path (file);
fd = g_open (filename, O_RDONLY | _O_BINARY, 0);
+ g_free (filename);
if (fd < 0)
{
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));
+ gimp_file_get_utf8_name (file), g_strerror (errno));
return NULL;
}
@@ -501,7 +504,7 @@ load_image (const gchar *filename,
g_printerr ("consecutive EOLs: %d, max columns: %d\n", cons_eol, hcol);
#endif
- image = emitgimp (hcol, row, bitmap, bperrow, filename);
+ image = emitgimp (hcol, row, bitmap, bperrow, file);
g_free (bitmap);
@@ -519,7 +522,7 @@ emitgimp (gint hcol,
gint row,
const gchar *bitmap,
gint bperrow,
- const gchar *filename)
+ GFile *file)
{
GeglBuffer *buffer;
GimpImage *image;
@@ -539,7 +542,7 @@ emitgimp (gint hcol,
#endif
image = gimp_image_new (hcol, row, GIMP_GRAY);
- gimp_image_set_filename (image, filename);
+ gimp_image_set_file (image, file);
layer = gimp_layer_new (image, _("Background"),
hcol,
diff --git a/plug-ins/file-fits/fits.c b/plug-ins/file-fits/fits.c
index b3e43718c6..db75547a45 100644
--- a/plug-ins/file-fits/fits.c
+++ b/plug-ins/file-fits/fits.c
@@ -100,9 +100,9 @@ static GimpValueArray * fits_save (GimpProcedure *procedure,
const GimpValueArray *args,
gpointer run_data);
-static GimpImage * load_image (const gchar *filename,
+static GimpImage * load_image (GFile *file,
GError **error);
-static gint save_image (const gchar *filename,
+static gint save_image (GFile *file,
GimpImage *image,
GimpDrawable *drawable,
GError **error);
@@ -117,7 +117,7 @@ static gint save_fits (FitsFile *ofp,
GimpImage *image,
GimpDrawable *drawable);
-static GimpImage * create_new_image (const gchar *filename,
+static GimpImage * create_new_image (GFile *file,
guint pagenum,
guint width,
guint height,
@@ -129,7 +129,7 @@ static GimpImage * create_new_image (const gchar *filename,
static void check_load_vals (void);
-static GimpImage * load_fits (const gchar *filename,
+static GimpImage * load_fits (GFile *file,
FitsFile *ifp,
guint picnum,
guint ncompose);
@@ -277,7 +277,7 @@ fits_load (GimpProcedure *procedure,
check_load_vals ();
- image = load_image (g_file_get_path (file), &error);
+ image = load_image (file, &error);
/* Write out error messages of FITS-Library */
show_fits_errors ();
@@ -337,8 +337,7 @@ fits_save (GimpProcedure *procedure,
break;
}
- if (! save_image (g_file_get_path (file),
- image, drawable,
+ if (! save_image (file, image, drawable,
&error))
{
status = GIMP_PDB_EXECUTION_ERROR;
@@ -351,8 +350,8 @@ fits_save (GimpProcedure *procedure,
}
static GimpImage *
-load_image (const gchar *filename,
- GError **error)
+load_image (GFile *file,
+ GError **error)
{
GimpImage *image;
GimpImage **image_list;
@@ -360,27 +359,36 @@ load_image (const gchar *filename,
guint picnum;
gint k, n_images, max_images, hdu_picnum;
gint compose;
+ gchar *filename;
FILE *fp;
FitsFile *ifp;
FitsHduList *hdu;
+ filename = g_file_get_path (file);
fp = g_fopen (filename, "rb");
- if (!fp)
+ g_free (filename);
+
+ if (! fp)
{
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));
+ gimp_file_get_utf8_name (file), g_strerror (errno));
return NULL;
}
+
fclose (fp);
+ filename = g_file_get_path (file);
ifp = fits_open (filename, "r");
- if (ifp == NULL)
+ g_free (filename);
+
+ if (! ifp)
{
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
"%s", _("Error during open of FITS file"));
return NULL;
}
+
if (ifp->n_pic <= 0)
{
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
@@ -409,7 +417,7 @@ load_image (const gchar *filename,
else
compose = 1; /* Load as GRAY */
- image = load_fits (filename, ifp, picnum, compose);
+ image = load_fits (file, ifp, picnum, compose);
/* Write out error messages of FITS-Library */
show_fits_errors ();
@@ -456,11 +464,12 @@ load_image (const gchar *filename,
}
static gint
-save_image (const gchar *filename,
+save_image (GFile *file,
GimpImage *image,
GimpDrawable *drawable,
GError **error)
{
+ gchar *filename;
FitsFile *ofp;
GimpImageType drawable_type;
gint retval;
@@ -489,15 +498,18 @@ save_image (const gchar *filename,
}
gimp_progress_init_printf (_("Exporting '%s'"),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
/* Open the output file. */
+ filename = g_file_get_path (file);
ofp = fits_open (filename, "w");
- if (!ofp)
+ g_free (filename);
+
+ if (! ofp)
{
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));
return (FALSE);
}
@@ -519,7 +531,7 @@ check_load_vals (void)
/* Create an image. Sets layer_ID, drawable and rgn. Returns image_ID */
static GimpImage *
-create_new_image (const gchar *filename,
+create_new_image (GFile *file,
guint pagenum,
guint width,
guint height,
@@ -530,18 +542,22 @@ create_new_image (const gchar *filename,
GeglBuffer **buffer)
{
GimpImage *image;
- gchar *tmp;
+ GFile *new_file;
+ gchar *uri;
+ gchar *new_uri;
image = gimp_image_new_with_precision (width, height, itype, iprecision);
- if ((tmp = g_malloc (strlen (filename) + 64)) != NULL)
- {
- sprintf (tmp, "%s-img%ld", filename, (long)pagenum);
- gimp_image_set_filename (image, tmp);
- g_free (tmp);
- }
- else
- gimp_image_set_filename (image, filename);
+ uri = g_file_get_uri (file);
+
+ new_uri = g_strdup_printf ("%s-img%d", uri, pagenum);
+ g_free (uri);
+
+ new_file = g_file_new_for_uri (new_uri);
+ g_free (new_uri);
+
+ gimp_image_set_file (image, new_file);
+ g_object_unref (new_file);
gimp_image_undo_disable (image);
*layer = gimp_layer_new (image, _("Background"), width, height,
@@ -560,10 +576,10 @@ create_new_image (const gchar *filename,
* 1: GRAY, 2: GRAYA, 3: RGB, 4: RGBA
*/
static GimpImage *
-load_fits (const gchar *filename,
- FitsFile *ifp,
- guint picnum,
- guint ncompose)
+load_fits (GFile *file,
+ FitsFile *ifp,
+ guint picnum,
+ guint ncompose)
{
register guchar *dest, *src;
guchar *data, *data_end, *linebuf;
@@ -669,7 +685,7 @@ load_fits (const gchar *filename,
NULL);
}
- image = create_new_image (filename, picnum, width, height,
+ image = create_new_image (file, picnum, width, height,
itype, dtype, iprecision,
&layer, &buffer);
diff --git a/plug-ins/file-fli/fli-gimp.c b/plug-ins/file-fli/fli-gimp.c
index 2ea191b081..3b71e31e9e 100644
--- a/plug-ins/file-fli/fli-gimp.c
+++ b/plug-ins/file-fli/fli-gimp.c
@@ -110,20 +110,20 @@ static GimpValueArray * fli_info (GimpProcedure *procedure,
const GimpValueArray *args,
gpointer run_data);
-static GimpImage * load_image (const gchar *filename,
+static GimpImage * load_image (GFile *file,
gint32 from_frame,
gint32 to_frame,
GError **error);
-static gboolean load_dialog (const gchar *filename);
+static gboolean load_dialog (GFile *file);
-static gboolean save_image (const gchar *filename,
+static gboolean save_image (GFile *file,
GimpImage *image,
gint32 from_frame,
gint32 to_frame,
GError **error);
static gboolean save_dialog (GimpImage *image);
-static gboolean get_info (const gchar *filename,
+static gboolean get_info (GFile *file,
gint32 *width,
gint32 *height,
gint32 *frames,
@@ -309,7 +309,7 @@ fli_load (GimpProcedure *procedure,
break;
case GIMP_RUN_INTERACTIVE:
- if (! load_dialog (g_file_get_path (file)))
+ if (! load_dialog (file))
return gimp_procedure_new_return_values (procedure,
GIMP_PDB_CANCEL,
NULL);
@@ -322,8 +322,8 @@ fli_load (GimpProcedure *procedure,
break;
}
- image = load_image (g_file_get_path (file),
- from_frame, to_frame, &error);
+ image = load_image (file, from_frame, to_frame,
+ &error);
if (! image)
return gimp_procedure_new_return_values (procedure,
@@ -388,8 +388,8 @@ fli_save (GimpProcedure *procedure,
if (status == GIMP_PDB_SUCCESS)
{
- if (! save_image (g_file_get_path (file), image,
- from_frame, to_frame, &error))
+ if (! save_image (file, image, from_frame, to_frame,
+ &error))
{
status = GIMP_PDB_EXECUTION_ERROR;
}
@@ -415,8 +415,8 @@ fli_info (GimpProcedure *procedure,
file = g_file_new_for_uri (GIMP_VALUES_GET_STRING (args, 0));
- if (! get_info (g_file_get_path (file),
- &width, &height, &frames, &error))
+ if (! get_info (file, &width, &height, &frames,
+ &error))
{
return gimp_procedure_new_return_values (procedure,
GIMP_PDB_EXECUTION_ERROR,
@@ -438,29 +438,32 @@ fli_info (GimpProcedure *procedure,
* Open FLI animation and return header-info
*/
static gboolean
-get_info (const gchar *filename,
- gint32 *width,
- gint32 *height,
- gint32 *frames,
- GError **error)
+get_info (GFile *file,
+ gint32 *width,
+ gint32 *height,
+ gint32 *frames,
+ GError **error)
{
- FILE *file;
+ gchar *filename;
+ FILE *fp;
s_fli_header fli_header;
*width = 0; *height = 0; *frames = 0;
- file = g_fopen (filename ,"rb");
+ filename = g_file_get_path (file);
+ fp = g_fopen (filename ,"rb");
+ g_free (filename);
- if (!file)
+ if (! fp)
{
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));
+ gimp_file_get_utf8_name (file), g_strerror (errno));
return FALSE;
}
- fli_read_header (file, &fli_header);
- fclose (file);
+ fli_read_header (fp, &fli_header);
+ fclose (fp);
*width = fli_header.width;
*height = fli_header.height;
@@ -473,12 +476,13 @@ get_info (const gchar *filename,
* load fli animation and store as framestack
*/
static GimpImage *
-load_image (const gchar *filename,
- gint32 from_frame,
- gint32 to_frame,
- GError **error)
+load_image (GFile *file,
+ gint32 from_frame,
+ gint32 to_frame,
+ GError **error)
{
- FILE *file;
+ gchar *filename;
+ FILE *fp;
GeglBuffer *buffer;
GimpImage *image;
GimpLayer *layer;
@@ -488,26 +492,29 @@ load_image (const gchar *filename,
gint cnt;
gimp_progress_init_printf (_("Opening '%s'"),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
- file = g_fopen (filename ,"rb");
- if (! file)
+ filename = g_file_get_path (file);
+ fp = g_fopen (filename ,"rb");
+ g_free (file);
+
+ if (! fp)
{
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));
+ gimp_file_get_utf8_name (file), g_strerror (errno));
return NULL;
}
- fli_read_header (file, &fli_header);
+ fli_read_header (fp, &fli_header);
if (fli_header.magic == NO_HEADER)
{
- fclose (file);
+ fclose (fp);
return NULL;
}
else
{
- fseek (file, 128, SEEK_SET);
+ fseek (fp, 128, SEEK_SET);
}
/*
@@ -529,13 +536,13 @@ load_image (const gchar *filename,
if (to_frame < 1)
{
/* nothing to do ... */
- fclose (file);
+ fclose (fp);
return NULL;
}
if (from_frame >= fli_header.frames)
{
/* nothing to do ... */
- fclose (file);
+ fclose (fp);
return NULL;
}
if (to_frame > fli_header.frames)
@@ -544,7 +551,7 @@ load_image (const gchar *filename,
}
image = gimp_image_new (fli_header.width, fli_header.height, GIMP_INDEXED);
- gimp_image_set_filename (image, filename);
+ gimp_image_set_file (image, file);
fb = g_malloc (fli_header.width * fli_header.height);
ofb = g_malloc (fli_header.width * fli_header.height);
@@ -554,7 +561,7 @@ load_image (const gchar *filename,
*/
for (cnt = 1; cnt < from_frame; cnt++)
{
- fli_read_frame (file, &fli_header, ofb, ocm, fb, cm);
+ fli_read_frame (fp, &fli_header, ofb, ocm, fb, cm);
memcpy (ocm, cm, 768);
fb_x = fb; fb = ofb; ofb = fb_x;
}
@@ -574,7 +581,7 @@ load_image (const gchar *filename,
buffer = gimp_drawable_get_buffer (GIMP_DRAWABLE (layer));
- fli_read_frame (file, &fli_header, ofb, ocm, fb, cm);
+ fli_read_frame (fp, &fli_header, ofb, ocm, fb, cm);
gegl_buffer_set (buffer, GEGL_RECTANGLE (0, 0,
fli_header.width,
@@ -599,7 +606,7 @@ load_image (const gchar *filename,
gimp_image_set_colormap (image, cm, 256);
- fclose (file);
+ fclose (fp);
g_free (fb);
g_free (ofb);
@@ -617,13 +624,14 @@ load_image (const gchar *filename,
* (some code was taken from the GIF plugin.)
*/
static gboolean
-save_image (const gchar *filename,
- GimpImage *image,
- gint32 from_frame,
- gint32 to_frame,
- GError **error)
+save_image (GFile *file,
+ GimpImage *image,
+ gint32 from_frame,
+ gint32 to_frame,
+ GError **error)
{
- FILE *file;
+ gchar *filename;
+ FILE *fp;
GList *framelist;
GList *iter;
gint nframes;
@@ -722,7 +730,7 @@ save_image (const gchar *filename,
}
gimp_progress_init_printf (_("Exporting '%s'"),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
/*
* First build the fli header.
@@ -749,15 +757,18 @@ save_image (const gchar *filename,
fli_header.aspect_y = 1; /* ... as GIMP supports it. */
fli_header.oframe1 = fli_header.oframe2 = 0; /* will be fixed during the write */
- file = g_fopen (filename ,"wb");
- if (!file)
+ filename = g_file_get_path (file);
+ fp = g_fopen (filename , "wb");
+ g_free (filename);
+
+ if (! fp)
{
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));
return FALSE;
}
- fseek (file, 128, SEEK_SET);
+ fseek (fp, 128, SEEK_SET);
fb = g_malloc (fli_header.width * fli_header.height);
ofb = g_malloc (fli_header.width * fli_header.height);
@@ -823,12 +834,12 @@ save_image (const gchar *filename,
if (cnt > from_frame)
{
/* save frame, allow all codecs */
- fli_write_frame (file, &fli_header, ofb, cm, fb, cm, W_ALL);
+ fli_write_frame (fp, &fli_header, ofb, cm, fb, cm, W_ALL);
}
else
{
/* save first frame, no delta information, allow all codecs */
- fli_write_frame (file, &fli_header, NULL, NULL, fb, cm, W_ALL);
+ fli_write_frame (fp, &fli_header, NULL, NULL, fb, cm, W_ALL);
}
if (cnt < to_frame)
@@ -840,8 +851,8 @@ save_image (const gchar *filename,
/*
* finish fli
*/
- fli_write_header (file, &fli_header);
- fclose (file);
+ fli_write_header (fp, &fli_header);
+ fclose (fp);
g_free (fb);
g_free (ofb);
@@ -856,7 +867,7 @@ save_image (const gchar *filename,
* Dialogs for interactive usage
*/
static gboolean
-load_dialog (const gchar *filename)
+load_dialog (GFile *file)
{
GtkWidget *dialog;
GtkWidget *grid;
@@ -865,7 +876,7 @@ load_dialog (const gchar *filename)
gint32 width, height, nframes;
gboolean run;
- get_info (filename, &width, &height, &nframes, NULL);
+ get_info (file, &width, &height, &nframes, NULL);
from_frame = 1;
to_frame = nframes;
diff --git a/plug-ins/file-ico/ico-load.c b/plug-ins/file-ico/ico-load.c
index 075590cc34..a12ac60138 100644
--- a/plug-ins/file-ico/ico-load.c
+++ b/plug-ins/file-ico/ico-load.c
@@ -650,9 +650,10 @@ ico_load_layer (FILE *fp,
GimpImage *
-ico_load_image (const gchar *filename,
+ico_load_image (GFile *file,
GError **error)
{
+ gchar *filename;
FILE *fp;
IcoLoadInfo *info;
gint max_width, max_height;
@@ -663,14 +664,17 @@ ico_load_image (const gchar *filename,
gint maxsize;
gimp_progress_init_printf (_("Opening '%s'"),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
+ filename = g_file_get_path (file);
fp = g_fopen (filename, "rb");
+ g_free (filename);
+
if (! fp)
{
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));
+ gimp_file_get_utf8_name (file), g_strerror (errno));
return NULL;
}
@@ -707,7 +711,7 @@ ico_load_image (const gchar *filename,
D(("image size: %ix%i\n", max_width, max_height));
image = gimp_image_new (max_width, max_height, GIMP_RGB);
- gimp_image_set_filename (image, filename);
+ gimp_image_set_file (image, file);
maxsize = max_width * max_height * 4;
buf = g_new (guchar, max_width * max_height * 4);
@@ -725,11 +729,12 @@ ico_load_image (const gchar *filename,
}
GimpImage *
-ico_load_thumbnail_image (const gchar *filename,
- gint *width,
- gint *height,
- GError **error)
+ico_load_thumbnail_image (GFile *file,
+ gint *width,
+ gint *height,
+ GError **error)
{
+ gchar *filename;
FILE *fp;
IcoLoadInfo *info;
GimpImage *image;
@@ -741,14 +746,17 @@ ico_load_thumbnail_image (const gchar *filename,
guchar *buf;
gimp_progress_init_printf (_("Opening thumbnail for '%s'"),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
+ filename = g_file_get_path (file);
fp = g_fopen (filename, "rb");
+ g_free (filename);
+
if (! fp)
{
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));
+ gimp_file_get_utf8_name (file), g_strerror (errno));
return NULL;
}
@@ -760,7 +768,7 @@ ico_load_thumbnail_image (const gchar *filename,
}
D(("*** %s: Microsoft icon file, containing %i icon(s)\n",
- filename, icon_count));
+ gimp_file_get_utf8_name (file), icon_count));
info = ico_read_info (fp, icon_count, error);
if (! info)
diff --git a/plug-ins/file-ico/ico-load.h b/plug-ins/file-ico/ico-load.h
index 92205f0edc..5c97cfdf67 100644
--- a/plug-ins/file-ico/ico-load.h
+++ b/plug-ins/file-ico/ico-load.h
@@ -22,9 +22,9 @@
#define __ICO_LOAD_H__
-GimpImage * ico_load_image (const gchar *filename,
+GimpImage * ico_load_image (GFile *file,
GError **error);
-GimpImage * ico_load_thumbnail_image (const gchar *filename,
+GimpImage * ico_load_thumbnail_image (GFile *file,
gint *width,
gint *height,
GError **error);
diff --git a/plug-ins/file-ico/ico-save.c b/plug-ins/file-ico/ico-save.c
index 44043cc914..904336c472 100644
--- a/plug-ins/file-ico/ico-save.c
+++ b/plug-ins/file-ico/ico-save.c
@@ -1061,12 +1061,13 @@ ico_save_info_free (IcoSaveInfo *info)
}
GimpPDBStatusType
-ico_save_image (const gchar *filename,
- GimpImage *image,
- gint32 run_mode,
- GError **error)
+ico_save_image (GFile *file,
+ GimpImage *image,
+ gint32 run_mode,
+ GError **error)
{
- FILE *fp;
+ gchar *filename;
+ FILE *fp;
GList *iter;
gint width;
@@ -1077,7 +1078,8 @@ ico_save_image (const gchar *filename,
gboolean saved;
gint i;
- D(("*** Exporting Microsoft icon file %s\n", filename));
+ D(("*** Exporting Microsoft icon file %s\n",
+ gimp_file_get_utf8_name (file)));
ico_save_init (image, &info);
@@ -1089,22 +1091,26 @@ ico_save_image (const gchar *filename,
}
gimp_progress_init_printf (_("Exporting '%s'"),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
- if (! (fp = g_fopen (filename, "wb")))
+ filename = g_file_get_path (file);
+ fp = g_fopen (filename, "wb");
+ g_free (filename);
+
+ if (! fp)
{
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));
return GIMP_PDB_EXECUTION_ERROR;
}
header.reserved = 0;
header.resource_type = 1;
header.icon_count = info.num_icons;
- if ( !ico_write_int16 (fp, &header.reserved, 1)
- || !ico_write_int16 (fp, &header.resource_type, 1)
- || !ico_write_int16 (fp, &header.icon_count, 1) )
+ if (! ico_write_int16 (fp, &header.reserved, 1) ||
+ ! ico_write_int16 (fp, &header.resource_type, 1) ||
+ ! ico_write_int16 (fp, &header.icon_count, 1))
{
ico_save_info_free (&info);
fclose (fp);
diff --git a/plug-ins/file-ico/ico-save.h b/plug-ins/file-ico/ico-save.h
index 471c2a61a2..8e78ea969f 100644
--- a/plug-ins/file-ico/ico-save.h
+++ b/plug-ins/file-ico/ico-save.h
@@ -22,7 +22,7 @@
#define __ICO_SAVE_H__
-GimpPDBStatusType ico_save_image (const gchar *file_name,
+GimpPDBStatusType ico_save_image (GFile *file,
GimpImage *image,
gint32 run_mode,
GError **error);
diff --git a/plug-ins/file-ico/ico.c b/plug-ins/file-ico/ico.c
index ddd56bbf2f..33b4852d7a 100644
--- a/plug-ins/file-ico/ico.c
+++ b/plug-ins/file-ico/ico.c
@@ -197,18 +197,13 @@ ico_load (GimpProcedure *procedure,
gpointer run_data)
{
GimpValueArray *return_vals;
- gchar *filename;
GimpImage *image;
GError *error = NULL;
INIT_I18N ();
gegl_init (NULL, NULL);
- filename = g_file_get_path (file);
-
- image = ico_load_image (filename, &error);
-
- g_free (filename);
+ image = ico_load_image (file, &error);
if (! image)
return gimp_procedure_new_return_values (procedure,
@@ -232,7 +227,6 @@ ico_load_thumb (GimpProcedure *procedure,
gpointer run_data)
{
GimpValueArray *return_vals;
- gchar *filename;
gint width;
gint height;
GimpImage *image;
@@ -241,11 +235,10 @@ ico_load_thumb (GimpProcedure *procedure,
INIT_I18N ();
gegl_init (NULL, NULL);
- filename = g_file_get_path (file);
- width = size;
- height = size;
+ width = size;
+ height = size;
- image = ico_load_thumbnail_image (filename,
+ image = ico_load_thumbnail_image (file,
&width, &height, &error);
if (image)
@@ -276,17 +269,12 @@ ico_save (GimpProcedure *procedure,
gpointer run_data)
{
GimpPDBStatusType status;
- gchar *filename;
GError *error = NULL;
INIT_I18N ();
gegl_init (NULL, NULL);
- filename = g_file_get_path (file);
-
- status = ico_save_image (filename, image, run_mode, &error);
-
- g_free (filename);
+ status = ico_save_image (file, image, run_mode, &error);
return gimp_procedure_new_return_values (procedure, status, error);
}
diff --git a/plug-ins/file-jpeg/jpeg-load.c b/plug-ins/file-jpeg/jpeg-load.c
index 2e96df3f2f..7ca3324c7f 100644
--- a/plug-ins/file-jpeg/jpeg-load.c
+++ b/plug-ins/file-jpeg/jpeg-load.c
@@ -56,7 +56,7 @@ GimpImage * volatile preview_image;
GimpLayer * preview_layer;
GimpImage *
-load_image (const gchar *filename,
+load_image (GFile *file,
GimpRunMode runmode,
gboolean preview,
gboolean *resolution_loaded,
@@ -67,6 +67,7 @@ load_image (const gchar *filename,
struct jpeg_decompress_struct cinfo;
struct my_error_mgr jerr;
jpeg_saved_marker_ptr marker;
+ gchar *filename;
FILE *infile;
guchar *buf;
guchar **rowbuf;
@@ -88,14 +89,18 @@ load_image (const gchar *filename,
jerr.pub.output_message = my_output_message;
gimp_progress_init_printf (_("Opening '%s'"),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
}
- if ((infile = g_fopen (filename, "rb")) == NULL)
+ filename = g_file_get_path (file);
+ infile = g_fopen (filename, "rb");
+ g_free (filename);
+
+ if (! infile)
{
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));
+ gimp_file_get_utf8_name (file), g_strerror (errno));
return NULL;
}
@@ -231,7 +236,7 @@ load_image (const gchar *filename,
GIMP_PRECISION_U8_NON_LINEAR);
gimp_image_undo_disable (image);
- gimp_image_set_filename (image, filename);
+ gimp_image_set_file (image, file);
/* Step 5.0: save the original JPEG settings in a parasite */
jpeg_detect_original_settings (&cinfo, image);
diff --git a/plug-ins/file-jpeg/jpeg-load.h b/plug-ins/file-jpeg/jpeg-load.h
index 9bf25d8a06..ef2332e70f 100644
--- a/plug-ins/file-jpeg/jpeg-load.h
+++ b/plug-ins/file-jpeg/jpeg-load.h
@@ -18,7 +18,7 @@
#ifndef __JPEG_LOAD_H__
#define __JPEG_LOAD_H__
-GimpImage * load_image (const gchar *filename,
+GimpImage * load_image (GFile *file,
GimpRunMode runmode,
gboolean preview,
gboolean *resolution_loaded,
diff --git a/plug-ins/file-jpeg/jpeg-save.c b/plug-ins/file-jpeg/jpeg-save.c
index ca1fc5ffcf..a339aa5082 100644
--- a/plug-ins/file-jpeg/jpeg-save.c
+++ b/plug-ins/file-jpeg/jpeg-save.c
@@ -86,7 +86,7 @@ typedef struct
guchar *src;
GeglBuffer *buffer;
const Babl *format;
- const gchar *file_name;
+ GFile *file;
gboolean abort_me;
guint source_id;
} PreviewPersistent;
@@ -185,14 +185,13 @@ background_jpeg_save (PreviewPersistent *pp)
g_object_unref (pp->buffer);
/* display the preview stuff */
- if (!pp->abort_me)
+ if (! pp->abort_me)
{
- GFile *file = g_file_new_for_path (pp->file_name);
GFileInfo *info;
gchar *text;
GError *error = NULL;
- info = g_file_query_info (file,
+ info = g_file_query_info (pp->file,
G_FILE_ATTRIBUTE_STANDARD_SIZE,
G_FILE_QUERY_INFO_NONE,
NULL, &error);
@@ -217,14 +216,13 @@ background_jpeg_save (PreviewPersistent *pp)
gtk_label_set_text (GTK_LABEL (preview_size), text);
g_free (text);
- g_object_unref (file);
-
/* and load the preview */
- load_image (pp->file_name, GIMP_RUN_NONINTERACTIVE, TRUE, NULL, NULL);
+ load_image (pp->file, GIMP_RUN_NONINTERACTIVE,
+ TRUE, NULL, NULL);
}
/* we cleanup here (load_image doesn't run in the background) */
- g_unlink (pp->file_name);
+ g_file_delete (pp->file, NULL, NULL);
g_free (pp);
prev_p = NULL;
@@ -260,7 +258,7 @@ background_jpeg_save (PreviewPersistent *pp)
}
gboolean
-save_image (const gchar *filename,
+save_image (GFile *file,
GimpImage *image,
GimpDrawable *drawable,
GimpImage *orig_image,
@@ -276,6 +274,7 @@ save_image (const gchar *filename,
const Babl *format;
const Babl *space;
JpegSubsampling subsampling;
+ gchar *filename;
FILE * volatile outfile;
guchar *data;
guchar *src;
@@ -291,7 +290,7 @@ save_image (const gchar *filename,
if (! preview)
gimp_progress_init_printf (_("Exporting '%s'"),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
/* Step 1: allocate and initialize JPEG compression object */
@@ -330,11 +329,15 @@ save_image (const gchar *filename,
* VERY IMPORTANT: use "b" option to fopen() if you are on a machine that
* requires it in order to write binary files.
*/
- if ((outfile = g_fopen (filename, "wb")) == NULL)
+ filename = g_file_get_path (file);
+ outfile = g_fopen (filename, "wb");
+ g_free (file);
+
+ if (! outfile)
{
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));
return FALSE;
}
@@ -668,7 +671,7 @@ save_image (const gchar *filename,
pp->buffer = buffer;
pp->format = format;
pp->src = NULL;
- pp->file_name = filename;
+ pp->file = file;
pp->abort_me = FALSE;
g_warn_if_fail (prev_p == NULL);
@@ -740,7 +743,10 @@ make_preview (void)
if (jsvals.preview)
{
- gchar *tn = gimp_temp_name ("jpeg");
+ gchar *tn = gimp_temp_name ("jpeg");
+ GFile *file = g_file_new_for_path (tn);
+
+ g_free (tn);
if (! undo_touched)
{
@@ -751,12 +757,14 @@ make_preview (void)
undo_touched = TRUE;
}
- save_image (tn,
+ save_image (file,
preview_image,
drawable_global,
orig_image_global,
TRUE, NULL);
+ g_object_unref (file);
+
if (! display)
display = gimp_display_new (preview_image);
}
diff --git a/plug-ins/file-jpeg/jpeg-save.h b/plug-ins/file-jpeg/jpeg-save.h
index 58b5c4e91d..c2f129b7ba 100644
--- a/plug-ins/file-jpeg/jpeg-save.h
+++ b/plug-ins/file-jpeg/jpeg-save.h
@@ -44,7 +44,7 @@ extern GimpImage *orig_image_global;
extern GimpDrawable *drawable_global;
-gboolean save_image (const gchar *filename,
+gboolean save_image (GFile *file,
GimpImage *image,
GimpDrawable *drawable,
GimpImage *orig_image,
diff --git a/plug-ins/file-jpeg/jpeg.c b/plug-ins/file-jpeg/jpeg.c
index f38347e8b1..d9c334bbd7 100644
--- a/plug-ins/file-jpeg/jpeg.c
+++ b/plug-ins/file-jpeg/jpeg.c
@@ -272,7 +272,6 @@ jpeg_load (GimpProcedure *procedure,
gpointer run_data)
{
GimpValueArray *return_vals;
- gchar *filename;
GimpImage *image;
gboolean resolution_loaded = FALSE;
GError *error = NULL;
@@ -287,8 +286,6 @@ jpeg_load (GimpProcedure *procedure,
orig_subsmp = JPEG_SUBSAMPLING_2x2_1x1_1x1;
num_quant_tables = 0;
- filename = g_file_get_path (file);
-
switch (run_mode)
{
case GIMP_RUN_INTERACTIVE:
@@ -302,7 +299,7 @@ jpeg_load (GimpProcedure *procedure,
break;
}
- image = load_image (filename, run_mode, FALSE,
+ image = load_image (file, run_mode, FALSE,
&resolution_loaded, &error);
if (image)
@@ -327,8 +324,6 @@ jpeg_load (GimpProcedure *procedure,
}
}
- g_free (filename);
-
if (! image)
return gimp_procedure_new_return_values (procedure,
GIMP_PDB_EXECUTION_ERROR,
@@ -399,7 +394,6 @@ jpeg_save (GimpProcedure *procedure,
gpointer run_data)
{
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
- gchar *filename;
GimpParasite *parasite;
GimpMetadata *metadata;
GimpMetadataSaveFlags metadata_flags;
@@ -419,8 +413,6 @@ jpeg_save (GimpProcedure *procedure,
orig_image = image;
- filename = g_file_get_path (file);
-
switch (run_mode)
{
case GIMP_RUN_INTERACTIVE:
@@ -439,7 +431,9 @@ jpeg_save (GimpProcedure *procedure,
NULL, NULL, NULL);
if (tmp)
{
- gimp_image_set_filename (image, tmp);
+ GFile *file = g_file_new_for_path (tmp);
+ gimp_image_set_file (image, file);
+ g_object_unref (file);
g_free (tmp);
}
@@ -605,8 +599,7 @@ jpeg_save (GimpProcedure *procedure,
if (status == GIMP_PDB_SUCCESS)
{
- if (! save_image (filename,
- image, drawable, orig_image, FALSE,
+ if (! save_image (file, image, drawable, orig_image, FALSE,
&error))
{
status = GIMP_PDB_EXECUTION_ERROR;
@@ -688,8 +681,6 @@ jpeg_save (GimpProcedure *procedure,
if (metadata)
g_object_unref (metadata);
- g_free (filename);
-
return gimp_procedure_new_return_values (procedure, status, error);
}
diff --git a/plug-ins/file-psd/psd-load.c b/plug-ins/file-psd/psd-load.c
index 839293e075..1d9718cbe2 100644
--- a/plug-ins/file-psd/psd-load.c
+++ b/plug-ins/file-psd/psd-load.c
@@ -61,7 +61,7 @@ static gint read_merged_image_block (PSDimage *img_a,
GError **error);
static GimpImage * create_gimp_image (PSDimage *img_a,
- const gchar *filename);
+ GFile *file);
static gint add_color_map (GimpImage *image,
PSDimage *img_a);
@@ -113,12 +113,13 @@ static const Babl* get_mask_format (PSDimage *img_a);
/* Main file load function */
GimpImage *
-load_image (const gchar *filename,
+load_image (GFile *file,
gboolean merged_image_only,
gboolean *resolution_loaded,
gboolean *profile_loaded,
GError **load_error)
{
+ gchar *filename;
FILE *f;
struct stat st;
PSDimage img_a;
@@ -126,20 +127,28 @@ load_image (const gchar *filename,
GimpImage *image = NULL;
GError *error = NULL;
+ filename = g_file_get_path (file);
+
/* ----- Open PSD file ----- */
if (g_stat (filename, &st) == -1)
- return NULL;
+ {
+ g_free (filename);
+ return NULL;
+ }
gimp_progress_init_printf (_("Opening '%s'"),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
+
+ IFDBG(1) g_debug ("Open file %s", gimp_file_get_utf8_name (file));
- IFDBG(1) g_debug ("Open file %s", gimp_filename_to_utf8 (filename));
f = g_fopen (filename, "rb");
- if (f == NULL)
+ g_free (filename);
+
+ if (! f)
{
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));
+ gimp_file_get_utf8_name (file), g_strerror (errno));
return NULL;
}
@@ -178,7 +187,7 @@ load_image (const gchar *filename,
/* ----- Create GIMP image ----- */
IFDBG(2) g_debug ("Create GIMP image");
- image = create_gimp_image (&img_a, filename);
+ image = create_gimp_image (&img_a, file);
if (! image)
goto load_error;
gimp_progress_update (0.6);
@@ -975,8 +984,8 @@ read_merged_image_block (PSDimage *img_a,
}
static GimpImage *
-create_gimp_image (PSDimage *img_a,
- const gchar *filename)
+create_gimp_image (PSDimage *img_a,
+ GFile *file)
{
GimpImage *image = NULL;
GimpPrecision precision;
@@ -1031,7 +1040,7 @@ create_gimp_image (PSDimage *img_a,
IFDBG(2) g_debug ("Create image");
image = gimp_image_new_with_precision (img_a->columns, img_a->rows,
img_a->base_type, precision);
- gimp_image_set_filename (image, filename);
+ gimp_image_set_file (image, file);
gimp_image_undo_disable (image);
return image;
diff --git a/plug-ins/file-psd/psd-load.h b/plug-ins/file-psd/psd-load.h
index 66d1d228a5..565f9ef750 100644
--- a/plug-ins/file-psd/psd-load.h
+++ b/plug-ins/file-psd/psd-load.h
@@ -22,7 +22,7 @@
#define __PSD_LOAD_H__
-GimpImage * load_image (const gchar *filename,
+GimpImage * load_image (GFile *file,
gboolean merged_image_only,
gboolean *resolution_loaded,
gboolean *profile_loaded,
diff --git a/plug-ins/file-psd/psd-save.c b/plug-ins/file-psd/psd-save.c
index c20f3df7c9..78318c2eeb 100644
--- a/plug-ins/file-psd/psd-save.c
+++ b/plug-ins/file-psd/psd-save.c
@@ -621,7 +621,7 @@ save_resources (FILE *fd,
/* Get the image title from its filename */
- fileName = gimp_image_get_filename (image);
+ fileName = g_file_get_path (gimp_image_get_file (image));
IFDBG printf ("\tImage title: %s\n", fileName);
/* Get the active layer number id */
@@ -1562,10 +1562,11 @@ clear_image_data (void)
}
gboolean
-save_image (const gchar *filename,
- GimpImage *image,
- GError **error)
+save_image (GFile *file,
+ GimpImage *image,
+ GError **error)
{
+ gchar *filename;
FILE *fd;
GeglBuffer *buffer;
GList *iter;
@@ -1579,12 +1580,12 @@ save_image (const gchar *filename,
_("Unable to export '%s'. The PSD file format does not "
"support images that are more than 30,000 pixels wide "
"or tall."),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
return FALSE;
}
gimp_progress_init_printf (_("Exporting '%s'"),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
get_image_data (image);
@@ -1604,7 +1605,7 @@ save_image (const gchar *filename,
_("Unable to export '%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));
+ gimp_file_get_utf8_name (file));
clear_image_data ();
return FALSE;
}
@@ -1613,18 +1614,21 @@ save_image (const gchar *filename,
}
}
+ filename = g_file_get_path (file);
fd = g_fopen (filename, "wb");
- if (fd == NULL)
+ g_free (filename);
+
+ if (! fd)
{
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));
clear_image_data ();
return FALSE;
}
IFDBG g_print ("\tFile '%s' has been opened\n",
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
save_header (fd, image);
save_color_mode_data (fd, image);
diff --git a/plug-ins/file-psd/psd-save.h b/plug-ins/file-psd/psd-save.h
index 45931b2466..a55792ea8b 100644
--- a/plug-ins/file-psd/psd-save.h
+++ b/plug-ins/file-psd/psd-save.h
@@ -19,9 +19,9 @@
#define __PSD_SAVE_H__
-gboolean save_image (const gchar *filename,
- GimpImage *image,
- GError **error);
+gboolean save_image (GFile *file,
+ GimpImage *image,
+ GError **error);
#endif /* __PSD_SAVE_H__ */
diff --git a/plug-ins/file-psd/psd-thumb-load.c b/plug-ins/file-psd/psd-thumb-load.c
index 73a69cdd67..5368e4d35a 100644
--- a/plug-ins/file-psd/psd-thumb-load.c
+++ b/plug-ins/file-psd/psd-thumb-load.c
@@ -47,7 +47,7 @@ static gint read_image_resource_block (PSDimage *img_a,
GError **error);
static GimpImage * create_gimp_image (PSDimage *img_a,
- const gchar *filename);
+ GFile *file);
static gint add_image_resources (GimpImage *image,
PSDimage *img_a,
@@ -56,31 +56,39 @@ static gint add_image_resources (GimpImage *image,
/* Main file load function */
GimpImage *
-load_thumbnail_image (const gchar *filename,
- gint *width,
- gint *height,
- GError **load_error)
+load_thumbnail_image (GFile *file,
+ gint *width,
+ gint *height,
+ GError **load_error)
{
+ gchar *filename;
FILE *f;
struct stat st;
PSDimage img_a;
GimpImage *image = NULL;
GError *error = NULL;
+ filename = g_file_get_path (file);
+
/* ----- Open PSD file ----- */
if (g_stat (filename, &st) == -1)
- return NULL;
+ {
+ g_free (filename);
+ return NULL;
+ }
gimp_progress_init_printf (_("Opening thumbnail for '%s'"),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
- IFDBG(1) g_debug ("Open file %s", gimp_filename_to_utf8 (filename));
+ IFDBG(1) g_debug ("Open file %s", gimp_file_get_utf8_name (file));
f = g_fopen (filename, "rb");
- if (f == NULL)
+ g_free (filename);
+
+ if (! f)
{
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));
+ gimp_file_get_utf8_name (file), g_strerror (errno));
return NULL;
}
@@ -104,7 +112,7 @@ load_thumbnail_image (const gchar *filename,
/* ----- Create GIMP image ----- */
IFDBG(2) g_debug ("Create GIMP image");
- image = create_gimp_image (&img_a, filename);
+ image = create_gimp_image (&img_a, file);
if (! image)
goto load_error;
@@ -255,8 +263,8 @@ read_image_resource_block (PSDimage *img_a,
}
static GimpImage *
-create_gimp_image (PSDimage *img_a,
- const gchar *filename)
+create_gimp_image (PSDimage *img_a,
+ GFile *file)
{
GimpImage *image = NULL;
@@ -266,7 +274,7 @@ create_gimp_image (PSDimage *img_a,
IFDBG(2) g_debug ("Create image");
image = gimp_image_new (img_a->columns, img_a->rows, img_a->base_type);
- gimp_image_set_filename (image, filename);
+ gimp_image_set_file (image, file);
gimp_image_undo_disable (image);
return image;
diff --git a/plug-ins/file-psd/psd-thumb-load.h b/plug-ins/file-psd/psd-thumb-load.h
index 71935a897d..cd8492e67c 100644
--- a/plug-ins/file-psd/psd-thumb-load.h
+++ b/plug-ins/file-psd/psd-thumb-load.h
@@ -22,10 +22,10 @@
#define __PSD_THUMB_LOAD_H__
-GimpImage * load_thumbnail_image (const gchar *filename,
- gint *width,
- gint *height,
- GError **error);
+GimpImage * load_thumbnail_image (GFile *file,
+ gint *width,
+ gint *height,
+ GError **error);
#endif /* __PSD_THUMB_LOAD_H__ */
diff --git a/plug-ins/file-psd/psd.c b/plug-ins/file-psd/psd.c
index 0b9c71fcaf..f0386be46e 100644
--- a/plug-ins/file-psd/psd.c
+++ b/plug-ins/file-psd/psd.c
@@ -255,7 +255,7 @@ psd_load (GimpProcedure *procedure,
break;
}
- image = load_image (g_file_get_path (file),
+ image = load_image (file,
strcmp (gimp_procedure_get_name (procedure),
LOAD_MERGED_PROC) == 0,
&resolution_loaded,
@@ -303,7 +303,6 @@ psd_load_thumb (GimpProcedure *procedure,
gpointer run_data)
{
GimpValueArray *return_vals;
- gchar *filename;
gint width = 0;
gint height = 0;
GimpImage *image;
@@ -312,9 +311,7 @@ psd_load_thumb (GimpProcedure *procedure,
INIT_I18N ();
gegl_init (NULL, NULL);
- filename = g_file_get_path (file);
-
- image = load_thumbnail_image (filename, &width, &height, &error);
+ image = load_thumbnail_image (file, &width, &height, &error);
if (! image)
return gimp_procedure_new_return_values (procedure,
@@ -379,7 +376,7 @@ psd_save (GimpProcedure *procedure,
"image/x-psd",
&metadata_flags);
- if (save_image (g_file_get_path (file), image, &error))
+ if (save_image (file, image, &error))
{
if (metadata)
{
diff --git a/plug-ins/file-raw/file-darktable.c b/plug-ins/file-raw/file-darktable.c
index 4ccd592b83..1948d2e457 100644
--- a/plug-ins/file-raw/file-darktable.c
+++ b/plug-ins/file-raw/file-darktable.c
@@ -69,10 +69,10 @@ static GimpValueArray * darktable_load_thumb (GimpProcedure *proced
const GimpValueArray *args,
gpointer run_data);
-static GimpImage * load_image (const gchar *filename,
+static GimpImage * load_image (GFile *file,
GimpRunMode run_mode,
GError **error);
-static GimpImage * load_thumbnail_image (const gchar *filename,
+static GimpImage * load_thumbnail_image (GFile *file,
gint thumb_size,
gint *width,
gint *height,
@@ -307,17 +307,12 @@ darktable_load (GimpProcedure *procedure,
gpointer run_data)
{
GimpValueArray *return_vals;
- gchar *filename;
GimpImage *image;
GError *error = NULL;
INIT_I18N ();
- filename = g_file_get_path (file);
-
- image = load_image (filename, run_mode, &error);
-
- g_free (filename);
+ image = load_image (file, run_mode, &error);
if (! image)
return gimp_procedure_new_return_values (procedure,
@@ -351,8 +346,7 @@ darktable_load_thumb (GimpProcedure *procedure,
width = size;
height = size;
- image = load_thumbnail_image (g_file_get_path (file),
- width, &width, &height, &error);
+ image = load_thumbnail_image (file, width, &width, &height, &error);
if (! image)
return gimp_procedure_new_return_values (procedure,
@@ -375,7 +369,7 @@ darktable_load_thumb (GimpProcedure *procedure,
}
static GimpImage *
-load_image (const gchar *filename,
+load_image (GFile *file,
GimpRunMode run_mode,
GError **error)
{
@@ -387,6 +381,7 @@ load_image (const gchar *filename,
gchar *lua_script_escaped = g_strescape (lua_script, "");
gchar *lua_quoted = g_shell_quote (lua_script_escaped);
gchar *lua_cmd = g_strdup_printf ("dofile(%s)", lua_quoted);
+ gchar *filename = g_file_get_path (file);
gchar *filename_out = gimp_temp_name ("exr");
gchar *export_filename = g_strdup_printf ("lua/export_on_exit/export_filename=%s",
filename_out);
@@ -421,7 +416,7 @@ load_image (const gchar *filename,
g_free (lua_quoted);
gimp_progress_init_printf (_("Opening '%s'"),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
if (debug_prints)
{
@@ -444,9 +439,9 @@ load_image (const gchar *filename,
NULL,
error))
{
- image = gimp_file_load (run_mode, filename_out);
+ image = gimp_file_load (run_mode, g_file_new_for_path (filename_out));
if (image)
- gimp_image_set_filename (image, filename);
+ gimp_image_set_file (image, file);
}
if (debug_prints)
@@ -473,14 +468,15 @@ load_image (const gchar *filename,
}
static GimpImage *
-load_thumbnail_image (const gchar *filename,
- gint thumb_size,
- gint *width,
- gint *height,
- GError **error)
+load_thumbnail_image (GFile *file,
+ gint thumb_size,
+ gint *width,
+ gint *height,
+ GError **error)
{
GimpImage *image = NULL;
+ gchar *filename = g_file_get_path (file);
gchar *filename_out = gimp_temp_name ("jpg");
gchar *size = g_strdup_printf ("%d", thumb_size);
GFile *lua_file = gimp_data_directory_file ("file-raw",
@@ -517,7 +513,7 @@ load_thumbnail_image (const gchar *filename,
g_free (lua_quoted);
gimp_progress_init_printf (_("Opening thumbnail for '%s'"),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
*width = *height = thumb_size;
@@ -535,7 +531,8 @@ load_thumbnail_image (const gchar *filename,
{
gimp_progress_update (0.5);
- image = gimp_file_load (GIMP_RUN_NONINTERACTIVE, filename_out);
+ image = gimp_file_load (GIMP_RUN_NONINTERACTIVE,
+ g_file_new_for_path (filename_out));
if (image)
{
/* the size reported by raw files isn't precise,
@@ -548,7 +545,7 @@ load_thumbnail_image (const gchar *filename,
sscanf (start_of_size, "[dt4gimp] %d %d", width, height);
/* is this needed for thumbnails? */
- gimp_image_set_filename (image, filename);
+ gimp_image_set_file (image, file);
}
}
diff --git a/plug-ins/file-raw/file-rawtherapee.c b/plug-ins/file-raw/file-rawtherapee.c
index 83251e1124..db9fb4faf2 100644
--- a/plug-ins/file-raw/file-rawtherapee.c
+++ b/plug-ins/file-raw/file-rawtherapee.c
@@ -70,10 +70,10 @@ static GimpValueArray * rawtherapee_load_thumb (GimpProcedure *proc
const GimpValueArray *args,
gpointer run_data);
-static GimpImage * load_image (const gchar *filename,
+static GimpImage * load_image (GFile *file,
GimpRunMode run_mode,
GError **error);
-static GimpImage * load_thumbnail_image (const gchar *filename,
+static GimpImage * load_thumbnail_image (GFile *file,
gint thumb_size,
GError **error);
@@ -258,17 +258,12 @@ rawtherapee_load (GimpProcedure *procedure,
gpointer run_data)
{
GimpValueArray *return_vals;
- gchar *filename;
GimpImage *image;
GError *error = NULL;
INIT_I18N ();
- filename = g_file_get_path (file);
-
- image = load_image (filename, run_mode, &error);
-
- g_free (filename);
+ image = load_image (file, run_mode, &error);
if (! image)
return gimp_procedure_new_return_values (procedure,
@@ -297,8 +292,7 @@ rawtherapee_load_thumb (GimpProcedure *procedure,
INIT_I18N ();
- image = load_thumbnail_image (g_file_get_path (file),
- size, &error);
+ image = load_thumbnail_image (file, size, &error);
if (! image)
return gimp_procedure_new_return_values (procedure,
@@ -321,11 +315,12 @@ rawtherapee_load_thumb (GimpProcedure *procedure,
}
static GimpImage *
-load_image (const gchar *filename,
+load_image (GFile *file,
GimpRunMode run_mode,
GError **error)
{
GimpImage *image = NULL;
+ gchar *filename = g_file_get_path (file);
gchar *filename_out = gimp_temp_name ("tif");
gchar *rawtherapee_stdout = NULL;
@@ -347,7 +342,7 @@ load_image (const gchar *filename,
};
gimp_progress_init_printf (_("Opening '%s'"),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
if (g_spawn_sync (NULL,
argv,
@@ -362,9 +357,9 @@ load_image (const gchar *filename,
NULL,
error))
{
- image = gimp_file_load (run_mode, filename_out);
+ image = gimp_file_load (run_mode, g_file_new_for_path (filename_out));
if (image)
- gimp_image_set_filename (image, filename);
+ gimp_image_set_file (image, file);
}
/*if (rawtherapee_stdout) printf ("%s\n", rawtherapee_stdout);*/
@@ -380,11 +375,12 @@ load_image (const gchar *filename,
}
static GimpImage *
-load_thumbnail_image (const gchar *filename,
- gint thumb_size,
- GError **error)
+load_thumbnail_image (GFile *file,
+ gint thumb_size,
+ GError **error)
{
GimpImage *image = NULL;
+ gchar *filename = g_file_get_path (file);
gchar *filename_out = gimp_temp_name ("jpg");
gchar *thumb_pp3 = gimp_temp_name ("pp3");
FILE *thumb_pp3_f = fopen (thumb_pp3, "w");
@@ -464,7 +460,7 @@ load_thumbnail_image (const gchar *filename,
}
gimp_progress_init_printf (_("Opening thumbnail for '%s'"),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
if (thumb_pp3_f &&
g_spawn_sync (NULL,
@@ -481,11 +477,12 @@ load_thumbnail_image (const gchar *filename,
{
gimp_progress_update (0.5);
- image = gimp_file_load (GIMP_RUN_NONINTERACTIVE, filename_out);
+ image = gimp_file_load (GIMP_RUN_NONINTERACTIVE,
+ g_file_new_for_path (filename_out));
if (image)
{
/* is this needed for thumbnails? */
- gimp_image_set_filename (image, filename);
+ gimp_image_set_file (image, file);
}
}
diff --git a/plug-ins/file-sgi/sgi.c b/plug-ins/file-sgi/sgi.c
index 3c53cc3d0e..1ad802f8a8 100644
--- a/plug-ins/file-sgi/sgi.c
+++ b/plug-ins/file-sgi/sgi.c
@@ -83,9 +83,9 @@ static GimpValueArray * sgi_save (GimpProcedure *procedure,
const GimpValueArray *args,
gpointer run_data);
-static GimpImage * load_image (const gchar *filename,
+static GimpImage * load_image (GFile *file,
GError **error);
-static gint save_image (const gchar *filename,
+static gint save_image (GFile *file,
GimpImage *image,
GimpDrawable *drawable,
GError **error);
@@ -201,18 +201,13 @@ sgi_load (GimpProcedure *procedure,
gpointer run_data)
{
GimpValueArray *return_vals;
- gchar *filename;
GimpImage *image;
GError *error = NULL;
INIT_I18N ();
gegl_init (NULL, NULL);
- filename = g_file_get_path (file);
-
- image = load_image (filename, &error);
-
- g_free (filename);
+ image = load_image (file, &error);
if (! image)
return gimp_procedure_new_return_values (procedure,
@@ -289,9 +284,7 @@ sgi_save (GimpProcedure *procedure,
if (status == GIMP_PDB_SUCCESS)
{
- gchar *filename = g_file_get_path (file);
-
- if (save_image (filename, image, drawable,
+ if (save_image (file, image, drawable,
&error))
{
gimp_set_data (SAVE_PROC, &compression, sizeof (compression));
@@ -300,8 +293,6 @@ sgi_save (GimpProcedure *procedure,
{
status = GIMP_PDB_EXECUTION_ERROR;
}
-
- g_free (filename);
}
if (export == GIMP_EXPORT_EXPORT)
@@ -311,8 +302,8 @@ sgi_save (GimpProcedure *procedure,
}
static GimpImage *
-load_image (const gchar *filename,
- GError **error)
+load_image (GFile *file,
+ GError **error)
{
gint i, /* Looping var */
x, /* Current X coordinate */
@@ -322,6 +313,7 @@ load_image (const gchar *filename,
tile_height, /* Height of tile in GIMP */
count, /* Count of rows to put in image */
bytes; /* Number of channels to use */
+ gchar *filename;
sgi_t *sgip; /* File pointer */
GimpImage *image; /* Image */
GimpLayer *layer; /* Layer */
@@ -335,14 +327,17 @@ load_image (const gchar *filename,
*/
gimp_progress_init_printf (_("Opening '%s'"),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
+ filename = g_file_get_path (file);
sgip = sgiOpen (filename, SGI_READ, 0, 0, 0, 0, 0);
- if (sgip == NULL)
+ g_free (filename);
+
+ if (! sgip)
{
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
_("Could not open '%s' for reading."),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
return NULL;
};
@@ -414,7 +409,7 @@ load_image (const gchar *filename,
return NULL;
}
- gimp_image_set_filename (image, filename);
+ gimp_image_set_file (image, file);
/*
* Create the "background" layer to hold the image...
@@ -522,7 +517,7 @@ load_image (const gchar *filename,
}
static gint
-save_image (const gchar *filename,
+save_image (GFile *file,
GimpImage *image,
GimpDrawable *drawable,
GError **error)
@@ -535,6 +530,7 @@ save_image (const gchar *filename,
tile_height, /* Height of tile in GIMP */
count, /* Count of rows to put in image */
zsize; /* Number of channels in file */
+ gchar *filename;
sgi_t *sgip; /* File pointer */
GeglBuffer *buffer; /* Buffer for layer */
const Babl *format;
@@ -584,15 +580,18 @@ save_image (const gchar *filename,
*/
gimp_progress_init_printf (_("Exporting '%s'"),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
+ filename = g_file_get_path (file);
sgip = sgiOpen (filename, SGI_WRITE, compression, 1,
width, height, zsize);
- if (sgip == NULL)
+ g_free (filename);
+
+ if (! sgip)
{
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
_("Could not open '%s' for writing."),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
return FALSE;
};
diff --git a/plug-ins/file-tiff/file-tiff-load.c b/plug-ins/file-tiff/file-tiff-load.c
index 2751152502..a56ed6e3d3 100644
--- a/plug-ins/file-tiff/file-tiff-load.c
+++ b/plug-ins/file-tiff/file-tiff-load.c
@@ -811,7 +811,7 @@ load_image (GFile *file,
gchar *fname = g_strdup_printf ("%s-%d", g_file_get_uri (file),
ilayer);
- gimp_image_set_filename (*image, fname);
+ gimp_image_set_file (*image, g_file_new_for_uri (fname));
g_free (fname);
images_list = g_list_prepend (images_list, *image);
@@ -822,12 +822,12 @@ load_image (GFile *file,
g_file_get_uri (file),
pages.n_pages, pages.o_pages);
- gimp_image_set_filename (*image, fname);
+ gimp_image_set_file (*image, g_file_new_for_uri (fname));
g_free (fname);
}
else
{
- gimp_image_set_filename (*image, g_file_get_uri (file));
+ gimp_image_set_file (*image, file);
}
}
diff --git a/plug-ins/file-webp/file-webp-load.c b/plug-ins/file-webp/file-webp-load.c
index f7a8c82179..25dad27f62 100644
--- a/plug-ins/file-webp/file-webp-load.c
+++ b/plug-ins/file-webp/file-webp-load.c
@@ -73,10 +73,11 @@ create_layer (GimpImage *image,
}
GimpImage *
-load_image (const gchar *filename,
- gboolean interactive,
- GError **error)
+load_image (GFile *file,
+ gboolean interactive,
+ GError **error)
{
+ gchar *filename;
uint8_t *indata = NULL;
gsize indatalen;
gint width;
@@ -91,21 +92,26 @@ load_image (const gchar *filename,
gboolean exif = FALSE;
gboolean xmp = FALSE;
+ filename = g_file_get_path (file);
+
/* Attempt to read the file contents from disk */
if (! g_file_get_contents (filename,
(gchar **) &indata,
&indatalen,
error))
{
+ g_free (filename);
return NULL;
}
+ g_free (filename);
+
/* Validate WebP data */
if (! WebPGetInfo (indata, indatalen, &width, &height))
{
g_set_error (error, G_FILE_ERROR, 0,
_("Invalid WebP file '%s'"),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
return NULL;
}
@@ -198,7 +204,7 @@ load_image (const gchar *filename,
{
g_set_error (error, G_FILE_ERROR, 0,
_("Failed to decode animated WebP file '%s'"),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
goto error;
}
@@ -206,7 +212,7 @@ load_image (const gchar *filename,
{
g_set_error (error, G_FILE_ERROR, 0,
_("Failed to decode animated WebP information from '%s'"),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
goto error;
}
@@ -225,7 +231,7 @@ load_image (const gchar *filename,
{
g_set_error (error, G_FILE_ERROR, 0,
_("Failed to decode animated WebP frame from '%s'"),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
goto error;
}
@@ -285,7 +291,7 @@ load_image (const gchar *filename,
WebPMuxDelete (mux);
- gimp_image_set_filename (image, filename);
+ gimp_image_set_file (image, file);
if (profile)
g_object_unref (profile);
diff --git a/plug-ins/file-webp/file-webp-load.h b/plug-ins/file-webp/file-webp-load.h
index 79bd3a2a6c..d24587c8c7 100644
--- a/plug-ins/file-webp/file-webp-load.h
+++ b/plug-ins/file-webp/file-webp-load.h
@@ -23,7 +23,7 @@
#define __WEBP_LOAD_H__
-GimpImage * load_image (const gchar *filename,
+GimpImage * load_image (GFile *file,
gboolean interactive,
GError **error);
diff --git a/plug-ins/file-webp/file-webp-save.c b/plug-ins/file-webp/file-webp-save.c
index 34f6973bcf..744b37c9e8 100644
--- a/plug-ins/file-webp/file-webp-save.c
+++ b/plug-ins/file-webp/file-webp-save.c
@@ -52,14 +52,14 @@ int webp_file_progress (int percent,
const WebPPicture *picture);
const gchar * webp_error_string (WebPEncodingError error_code);
-gboolean save_layer (const gchar *filename,
+gboolean save_layer (GFile *file,
gint32 nLayers,
GimpImage *image,
GimpDrawable *drawable,
WebPSaveParams *params,
GError **error);
-gboolean save_animation (const gchar *filename,
+gboolean save_animation (GFile *file,
gint32 nLayers,
GList *layers,
GimpImage *image,
@@ -140,7 +140,7 @@ webp_error_string (WebPEncodingError error_code)
}
gboolean
-save_layer (const gchar *filename,
+save_layer (GFile *file,
gint32 nLayers,
GimpImage *image,
GimpDrawable *drawable,
@@ -195,17 +195,23 @@ save_layer (const gchar *filename,
do
{
+ gchar *filename;
+
/* Begin displaying export progress */
gimp_progress_init_printf (_("Saving '%s'"),
- gimp_filename_to_utf8(filename));
+ gimp_file_get_utf8_name (file));
/* Attempt to open the output file */
- if ((outfile = g_fopen (filename, "w+b")) == NULL)
+ filename = g_file_get_path (file);
+ outfile = g_fopen (filename, "w+b");
+ g_free (filename);
+
+ if (! outfile)
{
g_set_error (error, G_FILE_ERROR,
g_file_error_from_errno (errno),
_("Unable to open '%s' for writing: %s"),
- gimp_filename_to_utf8 (filename),
+ gimp_file_get_utf8_name (file),
g_strerror (errno));
break;
}
@@ -499,7 +505,7 @@ combine_buffers (GeglBuffer *layer_buffer,
}
gboolean
-save_animation (const gchar *filename,
+save_animation (GFile *file,
gint32 nLayers,
GList *layers,
GimpImage *image,
@@ -553,6 +559,7 @@ save_animation (const gchar *filename,
do
{
+ gchar *filename;
GList *list;
gint loop;
gint default_delay = params->delay;
@@ -560,15 +567,19 @@ save_animation (const gchar *filename,
/* Begin displaying export progress */
gimp_progress_init_printf (_("Saving '%s'"),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
/* Attempt to open the output file */
- if ((outfile = g_fopen (filename, "wb")) == NULL)
+ filename = g_file_get_path (file);
+ outfile = g_fopen (filename, "wb");
+ g_free (file);
+
+ if (! outfile)
{
g_set_error (error, G_FILE_ERROR,
g_file_error_from_errno (errno),
_("Unable to open '%s' for writing: %s"),
- gimp_filename_to_utf8 (filename),
+ gimp_file_get_utf8_name (file),
g_strerror (errno));
status = FALSE;
break;
@@ -807,7 +818,7 @@ save_animation (const gchar *filename,
gboolean
-save_image (const gchar *filename,
+save_image (GFile *file,
GimpImage *image,
GimpDrawable *drawable,
GimpMetadata *metadata,
@@ -815,7 +826,6 @@ save_image (const gchar *filename,
WebPSaveParams *params,
GError **error)
{
- GFile *file;
gboolean status = FALSE;
GList *layers;
@@ -825,18 +835,18 @@ save_image (const gchar *filename,
if (! layers)
return FALSE;
- g_printerr ("Saving WebP file %s\n", filename);
+ g_printerr ("Saving WebP file %s\n", gimp_file_get_utf8_name (file));
if (params->animation)
{
- status = save_animation (filename,
+ status = save_animation (file,
g_list_length (layers), layers,
image, drawable, params,
error);
}
else
{
- status = save_layer (filename,
+ status = save_layer (file,
g_list_length (layers),
image, drawable, params, error);
}
@@ -870,12 +880,10 @@ save_image (const gchar *filename,
else
metadata_flags &= ~GIMP_METADATA_SAVE_COLOR_PROFILE;
- file = g_file_new_for_path (filename);
gimp_image_metadata_save_finish (image,
"image/webp",
metadata, metadata_flags,
file, NULL);
- g_object_unref (file);
}
/* Return the status */
diff --git a/plug-ins/file-webp/file-webp-save.h b/plug-ins/file-webp/file-webp-save.h
index 215570a3de..f61f86613e 100644
--- a/plug-ins/file-webp/file-webp-save.h
+++ b/plug-ins/file-webp/file-webp-save.h
@@ -42,7 +42,7 @@ typedef struct
} WebPSaveParams;
-gboolean save_image (const gchar *filename,
+gboolean save_image (GFile *file,
GimpImage *image,
GimpDrawable *drawable,
GimpMetadata *metadata,
diff --git a/plug-ins/file-webp/file-webp.c b/plug-ins/file-webp/file-webp.c
index 9c0758eae0..b6a6a74252 100644
--- a/plug-ins/file-webp/file-webp.c
+++ b/plug-ins/file-webp/file-webp.c
@@ -258,7 +258,7 @@ webp_load (GimpProcedure *procedure,
INIT_I18N ();
gegl_init (NULL, NULL);
- image = load_image (g_file_get_path (file), FALSE, &error);
+ image = load_image (file, FALSE, &error);
if (! image)
return gimp_procedure_new_return_values (procedure, status, error);
@@ -376,9 +376,7 @@ webp_save (GimpProcedure *procedure,
NULL);
}
- if (! save_image (g_file_get_path (file),
- image,
- drawable,
+ if (! save_image (file, image, drawable,
metadata, metadata_flags,
¶ms,
&error))
diff --git a/plug-ins/screenshot/screenshot-freedesktop.c b/plug-ins/screenshot/screenshot-freedesktop.c
index 87b35aec67..c6c0a3b0f7 100644
--- a/plug-ins/screenshot/screenshot-freedesktop.c
+++ b/plug-ins/screenshot/screenshot-freedesktop.c
@@ -101,16 +101,14 @@ screenshot_freedesktop_dbus_signal (GDBusProxy *proxy,
if (g_variant_lookup (results, "uri", "s", &uri))
{
GFile *file = g_file_new_for_uri (uri);
- gchar *path = g_file_get_path (file);
- *image = gimp_file_load (GIMP_RUN_NONINTERACTIVE, path);
- gimp_image_set_filename (*image, "screenshot.png");
+ *image = gimp_file_load (GIMP_RUN_NONINTERACTIVE, file);
+ gimp_image_set_file (*image, g_file_new_for_path ("screenshot.png"));
/* Delete the actual file. */
g_file_delete (file, NULL, NULL);
g_object_unref (file);
- g_free (path);
g_free (uri);
}
}
diff --git a/plug-ins/screenshot/screenshot-gnome-shell.c b/plug-ins/screenshot/screenshot-gnome-shell.c
index a594f37e7c..c144f32a5b 100644
--- a/plug-ins/screenshot/screenshot-gnome-shell.c
+++ b/plug-ins/screenshot/screenshot-gnome-shell.c
@@ -176,8 +176,9 @@ screenshot_gnome_shell_shoot (ScreenshotValues *shootvals,
{
GimpColorProfile *profile;
- *image = gimp_file_load (GIMP_RUN_NONINTERACTIVE, filename);
- gimp_image_set_filename (*image, "screenshot.png");
+ *image = gimp_file_load (GIMP_RUN_NONINTERACTIVE,
+ g_file_new_for_path (filename));
+ gimp_image_set_file (*image, g_file_new_for_path ("screenshot.png"));
profile = gimp_monitor_get_color_profile (monitor);
diff --git a/plug-ins/screenshot/screenshot-kwin.c b/plug-ins/screenshot/screenshot-kwin.c
index 455e272cf0..154a4f78a3 100644
--- a/plug-ins/screenshot/screenshot-kwin.c
+++ b/plug-ins/screenshot/screenshot-kwin.c
@@ -168,8 +168,9 @@ screenshot_kwin_shoot (ScreenshotValues *shootvals,
{
GimpColorProfile *profile;
- *image = gimp_file_load (GIMP_RUN_NONINTERACTIVE, filename);
- gimp_image_set_filename (*image, "screenshot.png");
+ *image = gimp_file_load (GIMP_RUN_NONINTERACTIVE,
+ g_file_new_for_path (filename));
+ gimp_image_set_file (*image, g_file_new_for_path ("screenshot.png"));
/* This is very wrong in multi-display setups since we have no
* idea which profile is to be used. Let's keep it anyway and
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]