Commit 3fbf7436 authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann

added a GError parameter to file_utils_find_proc().

2006-08-10  Sven Neumann  <sven@gimp.org>

	* app/file/file-utils.[ch]: added a GError parameter to
	file_utils_find_proc().

	* app/actions/file-commands.c
	* app/dialogs/file-save-dialog.c
	* app/file/file-open.c
	* app/widgets/gimpdnd-xds.c
	* tools/pdbgen/pdb/fileops.pdb: changed accordingly.

	* app/pdb/fileops_cmds.c: regenerated.
parent 55d716e2
2006-08-10 Sven Neumann <sven@gimp.org>
* app/file/file-utils.[ch]: added a GError parameter to
file_utils_find_proc().
* app/actions/file-commands.c
* app/dialogs/file-save-dialog.c
* app/file/file-open.c
* app/widgets/gimpdnd-xds.c
* tools/pdbgen/pdb/fileops.pdb: changed accordingly.
* app/pdb/fileops_cmds.c: regenerated.
2006-08-10 Bill Skaggs <weskaggs@primate.ucdavis.edu>
* libgimpwidgets/gimpwidgets.c (gimp_coordinate_callback):
......
......@@ -206,8 +206,9 @@ file_save_cmd_callback (GtkAction *action,
save_proc = gimp_image_get_save_proc (image);
if (uri && ! save_proc)
save_proc = file_utils_find_proc (image->gimp->plug_in_manager->save_procs,
uri);
save_proc =
file_utils_find_proc (image->gimp->plug_in_manager->save_procs,
uri, NULL);
if (! (uri && save_proc))
{
......
......@@ -173,9 +173,9 @@ file_save_dialog_check_uri (GtkWidget *save_dialog,
save_proc = dialog->file_proc;
uri_proc = file_utils_find_proc (gimp->plug_in_manager->save_procs,
uri);
uri, NULL);
basename_proc = file_utils_find_proc (gimp->plug_in_manager->save_procs,
basename);
basename, NULL);
#ifdef DEBUG_SPEW
g_print ("\n\n%s: URI = %s\n",
......@@ -234,10 +234,10 @@ file_save_dialog_check_uri (GtkWidget *save_dialog,
uri = ext_uri;
basename = ext_basename;
uri_proc = file_utils_find_proc (gimp->plug_in_manager->save_procs,
uri);
uri_proc = file_utils_find_proc (gimp->plug_in_manager->save_procs,
uri, NULL);
basename_proc = file_utils_find_proc (gimp->plug_in_manager->save_procs,
basename);
basename, NULL);
utf8 = g_filename_to_utf8 (basename, -1, NULL, NULL, NULL);
gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (save_dialog),
......
......@@ -98,14 +98,11 @@ file_open_image (Gimp *gimp,
*status = GIMP_PDB_EXECUTION_ERROR;
if (! file_proc)
file_proc = file_utils_find_proc (gimp->plug_in_manager->load_procs, uri);
file_proc = file_utils_find_proc (gimp->plug_in_manager->load_procs,
uri, error);
if (! file_proc)
{
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
_("Unknown file type"));
return NULL;
}
return NULL;
filename = file_utils_filename_from_uri (uri);
......@@ -203,7 +200,8 @@ file_open_thumbnail (Gimp *gimp,
*image_width = 0;
*image_height = 0;
file_proc = file_utils_find_proc (gimp->plug_in_manager->load_procs, uri);
file_proc = file_utils_find_proc (gimp->plug_in_manager->load_procs,
uri, NULL);
if (! file_proc || ! file_proc->thumb_loader)
return NULL;
......
......@@ -21,6 +21,7 @@
#include "config.h"
#include <errno.h>
#include <stdlib.h>
#include <string.h>
......@@ -186,7 +187,8 @@ file_utils_filename_from_uri (const gchar *uri)
GimpPlugInProcedure *
file_utils_find_proc (GSList *procs,
const gchar *uri)
const gchar *uri,
GError **error)
{
GimpPlugInProcedure *file_proc;
GSList *all_procs = procs;
......@@ -194,6 +196,7 @@ file_utils_find_proc (GSList *procs,
g_return_val_if_fail (procs != NULL, NULL);
g_return_val_if_fail (uri != NULL, NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
/* First, check magicless prefixes/suffixes */
file_proc = file_proc_find_by_name (all_procs, uri, TRUE);
......@@ -223,8 +226,18 @@ file_utils_find_proc (GSList *procs,
if (head_size == -2)
{
head_size = 0;
if ((ifp = g_fopen (filename, "rb")) != NULL)
head_size = fread ((gchar *) head, 1, sizeof (head), ifp);
{
head_size = fread ((gchar *) head, 1, sizeof (head), ifp);
}
else
{
g_set_error (error,
G_FILE_ERROR,
g_file_error_from_errno (errno),
g_strerror (errno));
}
}
if (head_size >= 4)
......@@ -259,7 +272,13 @@ file_utils_find_proc (GSList *procs,
}
/* As a last resort, try matching by name */
return file_proc_find_by_name (all_procs, uri, FALSE);
file_proc = file_proc_find_by_name (all_procs, uri, FALSE);
if (! file_proc && error && *error == NULL)
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
_("Unknown file type"));
return file_proc;
}
GimpPlugInProcedure *
......
......@@ -36,7 +36,8 @@ gchar * file_utils_uri_display_basename (const gchar *uri);
gchar * file_utils_uri_display_name (const gchar *uri);
GimpPlugInProcedure * file_utils_find_proc (GSList *procs,
const gchar *filename);
const gchar *filename,
GError **error);
GimpPlugInProcedure * file_utils_find_proc_by_extension (GSList *procs,
const gchar *uri);
......
......@@ -63,7 +63,8 @@ file_load_invoker (GimpProcedure *procedure,
if (! uri)
return gimp_procedure_get_return_values (procedure, FALSE);
file_proc = file_utils_find_proc (gimp->plug_in_manager->load_procs, uri);
file_proc =
file_utils_find_proc (gimp->plug_in_manager->load_procs, uri, NULL);
g_free (uri);
......@@ -157,7 +158,8 @@ file_save_invoker (GimpProcedure *procedure,
if (! uri)
return gimp_procedure_get_return_values (procedure, FALSE);
file_proc = file_utils_find_proc (gimp->plug_in_manager->save_procs, uri);
file_proc =
file_utils_find_proc (gimp->plug_in_manager->save_procs, uri, NULL);
g_free (uri);
......
......@@ -141,7 +141,8 @@ gimp_dnd_xds_save_image (GdkDragContext *context,
uri = g_strndup ((const gchar *) data, length);
g_free (data);
proc = file_utils_find_proc (image->gimp->plug_in_manager->save_procs, uri);
proc =
file_utils_find_proc (image->gimp->plug_in_manager->save_procs, uri, NULL);
if (proc)
{
......
......@@ -65,7 +65,8 @@ HELP
if (! uri)
return gimp_procedure_get_return_values (procedure, FALSE);
file_proc = file_utils_find_proc (gimp->plug_in_manager->load_procs, uri);
file_proc =
file_utils_find_proc (gimp->plug_in_manager->load_procs, uri, NULL);
g_free (uri);
......@@ -191,7 +192,8 @@ HELP
if (! uri)
return gimp_procedure_get_return_values (procedure, FALSE);
file_proc = file_utils_find_proc (gimp->plug_in_manager->save_procs, uri);
file_proc =
file_utils_find_proc (gimp->plug_in_manager->save_procs, uri, NULL);
g_free (uri);
......
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