app: factorize detection of XCF load proc into a single function.
This commit is contained in:
parent
a34907987f
commit
9e5fbe13c5
4 changed files with 50 additions and 57 deletions
|
|
@ -82,7 +82,6 @@ static void file_open_convert_items (GimpImage *dest_ima
|
|||
static GList * file_open_get_layers (GimpImage *image,
|
||||
gboolean merge_visible,
|
||||
gint *n_visible);
|
||||
static gboolean file_open_file_proc_is_import (GimpPlugInProcedure *file_proc);
|
||||
static gboolean file_open_valid_permissions (GFile *file,
|
||||
GError **error);
|
||||
|
||||
|
|
@ -294,7 +293,7 @@ file_open_image (Gimp *gimp,
|
|||
{
|
||||
gimp_image_undo_disable (image);
|
||||
|
||||
if (file_open_file_proc_is_import (file_proc))
|
||||
if (! gimp_plug_in_procedure_is_xcf_load (file_proc))
|
||||
{
|
||||
file_import_image (image, context, orig_file,
|
||||
run_mode == GIMP_RUN_INTERACTIVE,
|
||||
|
|
@ -561,7 +560,7 @@ file_open_with_proc_and_display (Gimp *gimp,
|
|||
if (! file_proc)
|
||||
file_proc = gimp_image_get_load_proc (image);
|
||||
|
||||
if (file_open_file_proc_is_import (file_proc) &&
|
||||
if (! gimp_plug_in_procedure_is_xcf_load (file_proc) &&
|
||||
gimp_image_get_n_layers (image) == 1)
|
||||
{
|
||||
GimpObject *layer = gimp_image_get_layer_iter (image)->data;
|
||||
|
|
@ -807,11 +806,10 @@ file_open_link_image (Gimp *gimp,
|
|||
|
||||
if (g_file_is_native (file) && file_proc != NULL)
|
||||
{
|
||||
const gchar *proc_name = gimp_object_get_name (file_proc);
|
||||
GFile *dest_file = dest_image ? gimp_image_get_file (dest_image) : NULL;
|
||||
gboolean loop_found = FALSE;
|
||||
GFile *dest_file = dest_image ? gimp_image_get_file (dest_image) : NULL;
|
||||
gboolean loop_found = FALSE;
|
||||
|
||||
if (dest_file && g_strcmp0 (proc_name, "gimp-xcf-load") == 0)
|
||||
if (dest_file && gimp_plug_in_procedure_is_xcf_load (file_proc))
|
||||
{
|
||||
loop_found = xcf_load_file_equal (dest_file, file);
|
||||
|
||||
|
|
@ -996,22 +994,6 @@ file_open_get_layers (GimpImage *image,
|
|||
return layers;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
file_open_file_proc_is_import (GimpPlugInProcedure *file_proc)
|
||||
{
|
||||
const gchar *proc_name;
|
||||
|
||||
g_return_val_if_fail (file_proc != NULL, TRUE);
|
||||
|
||||
proc_name = gimp_object_get_name (file_proc);
|
||||
|
||||
/* Even when loading through an intermediate container format plug-in
|
||||
* (e.g. file-compressor), the stored procedure shall be the inner
|
||||
* format.
|
||||
*/
|
||||
return (g_strcmp0 (proc_name, "gimp-xcf-load") != 0);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
file_open_valid_permissions (GFile *file,
|
||||
GError **error)
|
||||
|
|
|
|||
|
|
@ -1449,3 +1449,20 @@ gimp_plug_in_procedure_handle_return_values (GimpPlugInProcedure *proc,
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
gboolean
|
||||
gimp_plug_in_procedure_is_xcf_load (GimpPlugInProcedure *file_proc)
|
||||
{
|
||||
const gchar *proc_name;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_PLUG_IN_PROCEDURE (file_proc), TRUE);
|
||||
|
||||
proc_name = gimp_object_get_name (file_proc);
|
||||
|
||||
/* Even when loading through an intermediate container format plug-in
|
||||
* (e.g. file-compressor), the stored procedure shall be the inner
|
||||
* format.
|
||||
* See commit bb9d8df855b.
|
||||
*/
|
||||
return (g_strcmp0 (proc_name, "gimp-xcf-load") == 0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -153,5 +153,6 @@ void gimp_plug_in_procedure_set_batch_interpreter (GimpPlugInProcedure
|
|||
void gimp_plug_in_procedure_handle_return_values (GimpPlugInProcedure *proc,
|
||||
Gimp *gimp,
|
||||
GimpProgress *progress,
|
||||
|
||||
GimpValueArray *return_vals);
|
||||
|
||||
gboolean gimp_plug_in_procedure_is_xcf_load (GimpPlugInProcedure *file_proc);
|
||||
|
|
|
|||
|
|
@ -86,6 +86,7 @@
|
|||
#include "path/gimpvectorlayeroptions.h"
|
||||
|
||||
#include "plug-in/gimppluginmanager-file.h"
|
||||
#include "plug-in/gimppluginprocedure.h"
|
||||
|
||||
#include "text/gimptextlayer.h"
|
||||
#include "text/gimptextlayer-xcf.h"
|
||||
|
|
@ -582,42 +583,34 @@ xcf_load_image_header (Gimp *gimp,
|
|||
file_proc = gimp_plug_in_manager_file_procedure_find (gimp->plug_in_manager,
|
||||
GIMP_FILE_PROCEDURE_GROUP_OPEN,
|
||||
link_file, error);
|
||||
if (file_proc)
|
||||
if (file_proc && gimp_plug_in_procedure_is_xcf_load (file_proc))
|
||||
{
|
||||
const gchar *proc_name = gimp_object_get_name (file_proc);
|
||||
GInputStream *input;
|
||||
GList *parent_files;
|
||||
XcfInfo info2 = { 0, };
|
||||
gint width2;
|
||||
gint height2;
|
||||
gint type2;
|
||||
GimpPrecision precision2;
|
||||
gboolean subloop_found = FALSE;
|
||||
|
||||
/* This will work even with container formats. See
|
||||
* commit bb9d8df855b.
|
||||
*/
|
||||
if (g_strcmp0 (proc_name, "gimp-xcf-load") == 0)
|
||||
parent_files = g_list_copy (prev_files);
|
||||
parent_files = g_list_prepend (parent_files, link_file);
|
||||
|
||||
input = G_INPUT_STREAM (g_file_read (link_file, NULL, NULL));
|
||||
if (input && xcf_load_magic_version (gimp, input, link_file, NULL, &info2))
|
||||
xcf_load_image_header (gimp, &info2, &width2, &height2, &type2, &precision2,
|
||||
parent_files, loop_files, &subloop_found, NULL);
|
||||
|
||||
g_clear_object (&input);
|
||||
g_list_free (parent_files);
|
||||
|
||||
if (subloop_found)
|
||||
{
|
||||
GInputStream *input;
|
||||
GList *parent_files;
|
||||
XcfInfo info2 = { 0, };
|
||||
gint width2;
|
||||
gint height2;
|
||||
gint type2;
|
||||
GimpPrecision precision2;
|
||||
gboolean subloop_found = FALSE;
|
||||
|
||||
parent_files = g_list_copy (prev_files);
|
||||
parent_files = g_list_prepend (parent_files, link_file);
|
||||
|
||||
input = G_INPUT_STREAM (g_file_read (link_file, NULL, NULL));
|
||||
if (input && xcf_load_magic_version (gimp, input, link_file, NULL, &info2))
|
||||
xcf_load_image_header (gimp, &info2, &width2, &height2, &type2, &precision2,
|
||||
parent_files, loop_files, &subloop_found, NULL);
|
||||
|
||||
g_clear_object (&input);
|
||||
g_list_free (parent_files);
|
||||
|
||||
if (subloop_found)
|
||||
{
|
||||
*loop_files = g_list_prepend (*loop_files, link_file);
|
||||
if (loop_found)
|
||||
*loop_found = TRUE;
|
||||
break;
|
||||
}
|
||||
*loop_files = g_list_prepend (*loop_files, link_file);
|
||||
if (loop_found)
|
||||
*loop_found = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue