Commit 5c9114ae authored by Jehan's avatar Jehan

app: allow core file procedure which don't return an image.

This is useful to be able to support file formats other than image
formats. In particular I will use this in the next commit to support a
"GIMP extension" format. When GIMP will open such file, it will
install an extension (not open an image on canvas).

This is an internal flag only, i.e. only usable from core GIMP. File
formats which a plug-in can register are still only image file formats.
parent aee6d44b
......@@ -219,7 +219,7 @@ file_open_dialog_open_image (GtkWidget *dialog,
G_OBJECT (gimp_widget_get_monitor (dialog)),
&status, &error);
if (! image && status != GIMP_PDB_CANCEL)
if (! image && status != GIMP_PDB_SUCCESS && status != GIMP_PDB_CANCEL)
{
gimp_message (gimp, G_OBJECT (dialog), GIMP_MESSAGE_ERROR,
_("Opening '%s' failed:\n\n%s"),
......
......@@ -575,7 +575,7 @@ gimp_display_shell_drop_uri_list (GtkWidget *widget,
g_list_free (new_layers);
}
else if (status != GIMP_PDB_CANCEL)
else if (status != GIMP_PDB_CANCEL && status != GIMP_PDB_SUCCESS)
{
warn = TRUE;
}
......@@ -591,7 +591,7 @@ gimp_display_shell_drop_uri_list (GtkWidget *widget,
G_OBJECT (gimp_widget_get_monitor (widget)),
&status, &error);
if (! new_image && status != GIMP_PDB_CANCEL)
if (! new_image && status != GIMP_PDB_CANCEL && status != GIMP_PDB_SUCCESS)
warn = TRUE;
}
else
......@@ -607,7 +607,7 @@ gimp_display_shell_drop_uri_list (GtkWidget *widget,
{
g_object_ref (image);
}
else if (status != GIMP_PDB_CANCEL)
else if (status != GIMP_PDB_CANCEL && status != GIMP_PDB_SUCCESS)
{
warn = TRUE;
}
......
......@@ -224,7 +224,7 @@ file_open_image (Gimp *gimp,
*status = g_value_get_enum (gimp_value_array_index (return_vals, 0));
if (*status == GIMP_PDB_SUCCESS)
if (*status == GIMP_PDB_SUCCESS && ! file_proc->generic_file_proc)
image = gimp_value_get_image (gimp_value_array_index (return_vals, 1),
gimp);
......@@ -250,7 +250,7 @@ file_open_image (Gimp *gimp,
if (mime_type)
*mime_type = g_slist_nth_data (file_proc->mime_types_list, 0);
}
else
else if (! file_proc->generic_file_proc)
{
if (error && ! *error)
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
......@@ -709,7 +709,7 @@ file_open_from_command_line (Gimp *gimp,
g_object_ref (file),
(GDestroyNotify) g_object_unref);
}
else if (status != GIMP_PDB_CANCEL && display)
else if (status != GIMP_PDB_SUCCESS && status != GIMP_PDB_CANCEL && display)
{
gimp_message (gimp, G_OBJECT (display), GIMP_MESSAGE_ERROR,
_("Opening '%s' failed: %s"),
......
......@@ -74,12 +74,13 @@ gimp_plug_in_manager_register_load_handler (GimpPlugInManager *manager,
procedure = GIMP_PROCEDURE (file_proc);
if ((procedure->num_args < 3) ||
(procedure->num_values < 1) ||
! GIMP_IS_PARAM_SPEC_INT32 (procedure->args[0]) ||
! G_IS_PARAM_SPEC_STRING (procedure->args[1]) ||
! G_IS_PARAM_SPEC_STRING (procedure->args[2]) ||
! GIMP_IS_PARAM_SPEC_IMAGE_ID (procedure->values[0]))
if (((procedure->num_args < 3) ||
(procedure->num_values < 1) ||
! GIMP_IS_PARAM_SPEC_INT32 (procedure->args[0]) ||
! G_IS_PARAM_SPEC_STRING (procedure->args[1]) ||
! G_IS_PARAM_SPEC_STRING (procedure->args[2]) ||
(! file_proc->generic_file_proc &&
! GIMP_IS_PARAM_SPEC_IMAGE_ID (procedure->values[0]))))
{
gimp_message (manager->gimp, NULL, GIMP_MESSAGE_ERROR,
"load handler \"%s\" does not take the standard "
......
......@@ -1022,9 +1022,6 @@ gimp_plug_in_manager_sort_file_procs (GimpPlugInManager *manager)
g_free (path);
}
/* finally, remove all raw loaders except the configured one from
* the list of load_procs
*/
list = manager->load_procs;
while (list)
{
......@@ -1032,6 +1029,9 @@ gimp_plug_in_manager_sort_file_procs (GimpPlugInManager *manager)
list = g_slist_next (list);
/* finally, remove all raw loaders except the configured one from
* the list of load_procs
*/
if (file_proc->handles_raw &&
! g_file_equal (gimp_plug_in_procedure_get_file (file_proc),
raw_plug_in))
......@@ -1041,6 +1041,11 @@ gimp_plug_in_manager_sort_file_procs (GimpPlugInManager *manager)
manager->display_load_procs =
g_slist_remove (manager->display_load_procs, file_proc);
}
/* Remove generic (non-image) loaders from the display loader
* list. */
if (file_proc->generic_file_proc)
manager->display_load_procs =
g_slist_remove (manager->display_load_procs, file_proc);
}
}
......
......@@ -1162,6 +1162,13 @@ gimp_plug_in_procedure_set_file_proc (GimpPlugInProcedure *proc,
proc->magics_list = extensions_parse (proc->magics);
}
void
gimp_plug_in_procedure_set_generic_file_proc (GimpPlugInProcedure *proc,
gboolean is_generic_file_proc)
{
proc->generic_file_proc = is_generic_file_proc;
}
void
gimp_plug_in_procedure_set_priority (GimpPlugInProcedure *proc,
gint priority)
......
......@@ -57,6 +57,7 @@ struct _GimpPlugInProcedure
/* file proc specific members */
gboolean file_proc;
gboolean generic_file_proc; /* not returning an image. */
gchar *extensions;
gchar *prefixes;
gchar *magics;
......@@ -121,6 +122,8 @@ void gimp_plug_in_procedure_set_file_proc (GimpPlugInProcedure *pro
const gchar *extensions,
const gchar *prefixes,
const gchar *magics);
void gimp_plug_in_procedure_set_generic_file_proc (GimpPlugInProcedure *proc,
gboolean is_generic_file_proc);
void gimp_plug_in_procedure_set_priority (GimpPlugInProcedure *proc,
gint priority);
void gimp_plug_in_procedure_set_mime_types (GimpPlugInProcedure *proc,
......
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