static GimpValueArray * xcf_save_invoker (GimpProcedure *procedure, Gimp *gimp, GimpContext *context, GimpProgress *progress, const GimpValueArray *args, GError **error) { XcfInfo info; GimpValueArray *return_vals; GimpImage *image; const gchar *filename; gboolean success = FALSE; gimp_set_busy (gimp); image = gimp_value_get_image (gimp_value_array_index (args, 1), gimp); filename = g_value_get_string (gimp_value_array_index (args, 3)); info.fp = g_fopen (filename, "wb"); if (info.fp) { info.gimp = gimp; info.progress = progress; info.cp = 0; info.filename = filename; info.active_layer = NULL; info.active_channel = NULL; info.floating_sel_drawable = NULL; info.floating_sel = NULL; info.floating_sel_offset = 0; info.swap_num = 0; info.ref_count = NULL; info.compression = COMPRESS_RLE; if (progress) { gchar *name = g_filename_display_name (filename); gchar *msg = g_strdup_printf (_("Saving '%s'"), name); gimp_progress_start (progress, msg, FALSE); g_free (msg); g_free (name); } xcf_save_choose_format (&info, image); success = xcf_save_image (&info, image, error); if (success) { if (fclose (info.fp) == EOF) { int save_errno = errno; g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (save_errno), _("Error saving XCF file: %s"), g_strerror (save_errno)); success = FALSE; } } else { fclose (info.fp); } if (progress) gimp_progress_end (progress); } else { int save_errno = errno; g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (save_errno), _("Could not open '%s' for writing: %s"), gimp_filename_to_utf8 (filename), g_strerror (save_errno)); } return_vals = gimp_procedure_get_return_values (procedure, success, error ? *error : NULL); gimp_unset_busy (gimp); return return_vals; }
static GimpValueArray * xcf_save_invoker (GimpProcedure *procedure, Gimp *gimp, GimpContext *context, GimpProgress *progress, const GimpValueArray *args, GError **error) { XcfInfo info = { 0, }; GimpValueArray *return_vals; GimpImage *image; const gchar *uri; gchar *filename; GFile *file; gboolean success = FALSE; GError *my_error = NULL; gimp_set_busy (gimp); image = gimp_value_get_image (gimp_value_array_index (args, 1), gimp); uri = g_value_get_string (gimp_value_array_index (args, 3)); #ifdef GIO_IS_FIXED file = g_file_new_for_uri (uri); #else file = g_file_new_for_path (uri); #endif filename = g_file_get_parse_name (file); info.output = G_OUTPUT_STREAM (g_file_replace (file, NULL, FALSE, 0, NULL, &my_error)); if (info.output) { info.gimp = gimp; info.seekable = G_SEEKABLE (info.output); info.progress = progress; info.filename = filename; info.compression = COMPRESS_RLE; if (progress) { gchar *name = g_filename_display_name (filename); gchar *msg = g_strdup_printf (_("Saving '%s'"), name); gimp_progress_start (progress, msg, FALSE); g_free (msg); g_free (name); } xcf_save_choose_format (&info, image); success = xcf_save_image (&info, image, error); g_object_unref (info.output); if (progress) gimp_progress_end (progress); } else { g_propagate_prefixed_error (error, my_error, _("Could not open '%s' for writing: "), filename); } g_free (filename); g_object_unref (file); return_vals = gimp_procedure_get_return_values (procedure, success, error ? *error : NULL); gimp_unset_busy (gimp); return return_vals; }