Commit 632b64fe authored by Michael Natterer's avatar Michael Natterer 😴

app: change filename in gimp_vectors_export_file() to GFile

parent 3dbae5e4
......@@ -772,17 +772,17 @@ vectors_export_response (GtkWidget *widget,
{
GtkFileChooser *chooser = GTK_FILE_CHOOSER (widget);
GimpVectors *vectors = NULL;
gchar *filename;
GFile *file;
GError *error = NULL;
vectors_export_active_only = dialog->active_only;
filename = gtk_file_chooser_get_filename (chooser);
file = gtk_file_chooser_get_file (chooser);
if (vectors_export_active_only)
vectors = gimp_image_get_active_vectors (dialog->image);
if (! gimp_vectors_export_file (dialog->image, vectors, filename, &error))
if (! gimp_vectors_export_file (dialog->image, vectors, file, &error))
{
gimp_message (dialog->image->gimp, G_OBJECT (widget),
GIMP_MESSAGE_ERROR,
......@@ -791,7 +791,7 @@ vectors_export_response (GtkWidget *widget,
return;
}
g_free (filename);
g_object_unref (file);
g_object_set_data_full (G_OBJECT (dialog->image->gimp),
"gimp-vectors-export-folder",
......
......@@ -1284,7 +1284,11 @@ vectors_export_to_file_invoker (GimpProcedure *procedure,
if (success)
{
success = gimp_vectors_export_file (image, vectors, filename, error);
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,
......
......@@ -53,7 +53,7 @@ static gchar * gimp_vectors_export_path_data (const GimpVectors *vectors);
* gimp_vectors_export_file:
* @image: the #GimpImage from which to export vectors
* @vectors: a #GimpVectors object or %NULL to export all vectors in @image
* @filename: the name of the file to write
* @file: the file to write
* @error: return location for errors
*
* Exports one or more vectors to a SVG file.
......@@ -64,37 +64,41 @@ static gchar * gimp_vectors_export_path_data (const GimpVectors *vectors);
gboolean
gimp_vectors_export_file (const GimpImage *image,
const GimpVectors *vectors,
const gchar *filename,
GFile *file,
GError **error)
{
FILE *file;
gchar *path;
FILE *f;
GString *str;
g_return_val_if_fail (GIMP_IS_IMAGE (image), FALSE);
g_return_val_if_fail (vectors == NULL || GIMP_IS_VECTORS (vectors), FALSE);
g_return_val_if_fail (filename != NULL, FALSE);
g_return_val_if_fail (G_IS_FILE (file), FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
file = g_fopen (filename, "w");
if (!file)
path = g_file_get_path (file);
f = g_fopen (path, "w");
g_free (path);
if (! f)
{
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;
}
str = gimp_vectors_export (image, vectors);
fprintf (file, "%s", str->str);
fprintf (f, "%s", str->str);
g_string_free (str, TRUE);
if (fclose (file))
if (fclose (f))
{
g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errno),
_("Error while writing '%s': %s"),
gimp_filename_to_utf8 (filename), g_strerror (errno));
gimp_file_get_utf8_name (file), g_strerror (errno));
return FALSE;
}
......
......@@ -21,7 +21,7 @@
gboolean gimp_vectors_export_file (const GimpImage *image,
const GimpVectors *vectors,
const gchar *filename,
GFile *file,
GError **error);
gchar * gimp_vectors_export_string (const GimpImage *image,
const GimpVectors *vectors);
......
......@@ -1264,7 +1264,11 @@ HELP
headers => [ qw("vectors/gimpvectors-export.h") ],
code => <<'CODE'
{
success = gimp_vectors_export_file (image, vectors, filename, error);
GFile *file = g_file_new_for_path (filename);
success = gimp_vectors_export_file (image, vectors, file, error);
g_object_unref (file);
}
CODE
);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment