2019-08-11 02:25:37 +08:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
|
|
|
* gimploadprocedure.c
|
|
|
|
* Copyright (C) 2019 Michael Natterer <mitch@gimp.org>
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include "gimp.h"
|
2019-08-11 19:21:55 +08:00
|
|
|
|
2023-10-15 22:34:11 +08:00
|
|
|
#include "libgimpbase/gimpwire.h" /* FIXME kill this include */
|
|
|
|
|
2019-08-11 02:25:37 +08:00
|
|
|
#include "gimploadprocedure.h"
|
2019-09-11 03:24:09 +08:00
|
|
|
#include "gimppdb_pdb.h"
|
2023-10-15 22:34:11 +08:00
|
|
|
#include "gimpplugin-private.h"
|
2023-10-15 23:01:47 +08:00
|
|
|
#include "gimpprocedureconfig-private.h"
|
2019-08-11 02:25:37 +08:00
|
|
|
|
2023-08-06 00:58:57 +08:00
|
|
|
#include "libgimp-intl.h"
|
|
|
|
|
2019-08-11 02:25:37 +08:00
|
|
|
|
2021-12-30 02:08:22 +08:00
|
|
|
/**
|
|
|
|
* GimpLoadProcedure:
|
|
|
|
*
|
|
|
|
* A [class@Procedure] subclass that makes it easier to write file load
|
|
|
|
* procedures.
|
|
|
|
*
|
|
|
|
* It automatically adds the standard
|
|
|
|
*
|
|
|
|
* ( [enum@RunMode], [iface@Gio.File] )
|
|
|
|
*
|
|
|
|
* arguments and the standard
|
|
|
|
*
|
|
|
|
* ( [class@Image] )
|
|
|
|
*
|
|
|
|
* return value of a load procedure. It is possible to add additional
|
|
|
|
* arguments.
|
|
|
|
*
|
|
|
|
* When invoked via [method@Procedure.run], it unpacks these standard
|
|
|
|
* arguments and calls @run_func which is a [callback@RunImageFunc]. The
|
|
|
|
* "args" [struct@ValueArray] of [callback@RunImageFunc] only contains
|
|
|
|
* additionally added arguments.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
typedef struct _GimpLoadProcedurePrivate
|
2019-08-11 02:25:37 +08:00
|
|
|
{
|
2019-08-11 20:58:55 +08:00
|
|
|
GimpRunLoadFunc run_func;
|
|
|
|
gpointer run_data;
|
|
|
|
GDestroyNotify run_data_destroy;
|
2019-08-11 02:25:37 +08:00
|
|
|
|
2019-08-11 20:58:55 +08:00
|
|
|
gboolean handles_raw;
|
|
|
|
gchar *thumbnail_proc;
|
2024-07-10 21:03:15 +08:00
|
|
|
} GimpLoadProcedurePrivate;
|
2019-08-11 02:25:37 +08:00
|
|
|
|
|
|
|
|
2019-09-24 06:59:50 +08:00
|
|
|
static void gimp_load_procedure_constructed (GObject *object);
|
|
|
|
static void gimp_load_procedure_finalize (GObject *object);
|
2019-08-11 02:25:37 +08:00
|
|
|
|
2019-09-24 06:59:50 +08:00
|
|
|
static void gimp_load_procedure_install (GimpProcedure *procedure);
|
2019-08-11 02:25:37 +08:00
|
|
|
static GimpValueArray *
|
2019-09-24 06:59:50 +08:00
|
|
|
gimp_load_procedure_run (GimpProcedure *procedure,
|
|
|
|
const GimpValueArray *args);
|
|
|
|
static GimpProcedureConfig *
|
|
|
|
gimp_load_procedure_create_config (GimpProcedure *procedure,
|
|
|
|
GParamSpec **args,
|
|
|
|
gint n_args);
|
2019-08-11 02:25:37 +08:00
|
|
|
|
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
G_DEFINE_TYPE_WITH_PRIVATE (GimpLoadProcedure, gimp_load_procedure, GIMP_TYPE_FILE_PROCEDURE)
|
2019-08-11 02:25:37 +08:00
|
|
|
|
|
|
|
#define parent_class gimp_load_procedure_parent_class
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_load_procedure_class_init (GimpLoadProcedureClass *klass)
|
|
|
|
{
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
GimpProcedureClass *procedure_class = GIMP_PROCEDURE_CLASS (klass);
|
|
|
|
|
2019-09-24 06:59:50 +08:00
|
|
|
object_class->constructed = gimp_load_procedure_constructed;
|
|
|
|
object_class->finalize = gimp_load_procedure_finalize;
|
2019-08-11 02:25:37 +08:00
|
|
|
|
2019-09-24 06:59:50 +08:00
|
|
|
procedure_class->install = gimp_load_procedure_install;
|
|
|
|
procedure_class->run = gimp_load_procedure_run;
|
|
|
|
procedure_class->create_config = gimp_load_procedure_create_config;
|
2019-08-11 02:25:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_load_procedure_init (GimpLoadProcedure *procedure)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_load_procedure_constructed (GObject *object)
|
|
|
|
{
|
|
|
|
GimpProcedure *procedure = GIMP_PROCEDURE (object);
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (parent_class)->constructed (object);
|
|
|
|
|
2024-06-13 00:53:12 +08:00
|
|
|
gimp_procedure_add_file_argument (procedure, "file",
|
|
|
|
"File",
|
|
|
|
"The file to load",
|
|
|
|
GIMP_PARAM_READWRITE);
|
|
|
|
|
|
|
|
gimp_procedure_add_image_return_value (procedure, "image",
|
|
|
|
"Image",
|
|
|
|
"Output image",
|
|
|
|
TRUE,
|
|
|
|
GIMP_PARAM_READWRITE);
|
2019-08-11 02:25:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_load_procedure_finalize (GObject *object)
|
|
|
|
{
|
2024-07-10 21:03:15 +08:00
|
|
|
GimpLoadProcedure *procedure = GIMP_LOAD_PROCEDURE (object);
|
|
|
|
GimpLoadProcedurePrivate *priv;
|
2019-08-11 02:25:37 +08:00
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
priv = gimp_load_procedure_get_instance_private (procedure);
|
2019-08-11 02:25:37 +08:00
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
if (priv->run_data_destroy)
|
|
|
|
priv->run_data_destroy (priv->run_data);
|
|
|
|
|
|
|
|
g_clear_pointer (&priv->thumbnail_proc, g_free);
|
2019-08-11 20:27:41 +08:00
|
|
|
|
2019-08-11 02:25:37 +08:00
|
|
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_load_procedure_install (GimpProcedure *procedure)
|
|
|
|
{
|
2024-07-10 21:03:15 +08:00
|
|
|
GimpLoadProcedurePrivate *priv;
|
|
|
|
GimpLoadProcedure *load_proc = GIMP_LOAD_PROCEDURE (procedure);
|
|
|
|
GimpFileProcedure *file_proc = GIMP_FILE_PROCEDURE (procedure);
|
|
|
|
const gchar *mime_types;
|
|
|
|
gint priority;
|
|
|
|
|
|
|
|
priv = gimp_load_procedure_get_instance_private (load_proc);
|
2019-08-11 02:25:37 +08:00
|
|
|
|
|
|
|
GIMP_PROCEDURE_CLASS (parent_class)->install (procedure);
|
|
|
|
|
2019-09-11 03:24:09 +08:00
|
|
|
_gimp_pdb_set_file_proc_load_handler (gimp_procedure_get_name (procedure),
|
|
|
|
gimp_file_procedure_get_extensions (file_proc),
|
|
|
|
gimp_file_procedure_get_prefixes (file_proc),
|
|
|
|
gimp_file_procedure_get_magics (file_proc));
|
2019-08-11 02:25:37 +08:00
|
|
|
|
2019-08-19 18:05:12 +08:00
|
|
|
if (gimp_file_procedure_get_handles_remote (file_proc))
|
2019-09-11 03:24:09 +08:00
|
|
|
_gimp_pdb_set_file_proc_handles_remote (gimp_procedure_get_name (procedure));
|
2019-08-11 02:25:37 +08:00
|
|
|
|
|
|
|
mime_types = gimp_file_procedure_get_mime_types (file_proc);
|
|
|
|
if (mime_types)
|
2019-09-11 03:24:09 +08:00
|
|
|
_gimp_pdb_set_file_proc_mime_types (gimp_procedure_get_name (procedure),
|
|
|
|
mime_types);
|
2019-08-11 02:25:37 +08:00
|
|
|
|
|
|
|
priority = gimp_file_procedure_get_priority (file_proc);
|
|
|
|
if (priority != 0)
|
2019-09-11 03:24:09 +08:00
|
|
|
_gimp_pdb_set_file_proc_priority (gimp_procedure_get_name (procedure),
|
|
|
|
priority);
|
2019-08-11 02:25:37 +08:00
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
if (priv->handles_raw)
|
2019-09-11 03:24:09 +08:00
|
|
|
_gimp_pdb_set_file_proc_handles_raw (gimp_procedure_get_name (procedure));
|
2019-08-11 20:27:41 +08:00
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
if (priv->thumbnail_proc)
|
2019-09-11 03:24:09 +08:00
|
|
|
_gimp_pdb_set_file_proc_thumbnail_loader (gimp_procedure_get_name (procedure),
|
2024-07-10 21:03:15 +08:00
|
|
|
priv->thumbnail_proc);
|
2019-08-11 02:25:37 +08:00
|
|
|
}
|
|
|
|
|
2019-09-24 06:59:50 +08:00
|
|
|
#define ARG_OFFSET 2
|
|
|
|
|
2019-08-11 02:25:37 +08:00
|
|
|
static GimpValueArray *
|
|
|
|
gimp_load_procedure_run (GimpProcedure *procedure,
|
|
|
|
const GimpValueArray *args)
|
|
|
|
{
|
2024-07-10 21:03:15 +08:00
|
|
|
GimpLoadProcedurePrivate *priv;
|
|
|
|
GimpPlugIn *plug_in;
|
|
|
|
GimpLoadProcedure *load_proc = GIMP_LOAD_PROCEDURE (procedure);
|
|
|
|
GimpValueArray *remaining;
|
|
|
|
GimpValueArray *return_values;
|
|
|
|
GimpProcedureConfig *config;
|
|
|
|
GimpImage *image = NULL;
|
|
|
|
GimpMetadata *metadata = NULL;
|
|
|
|
gchar *mimetype = NULL;
|
|
|
|
GimpMetadataLoadFlags flags = GIMP_METADATA_LOAD_ALL;
|
|
|
|
GimpPDBStatusType status = GIMP_PDB_EXECUTION_ERROR;
|
|
|
|
GimpRunMode run_mode;
|
|
|
|
GFile *file;
|
|
|
|
gint i;
|
|
|
|
|
|
|
|
priv = gimp_load_procedure_get_instance_private (load_proc);
|
2019-08-11 02:25:37 +08:00
|
|
|
|
2019-09-12 03:48:34 +08:00
|
|
|
run_mode = GIMP_VALUES_GET_ENUM (args, 0);
|
|
|
|
file = GIMP_VALUES_GET_FILE (args, 1);
|
2019-08-11 02:25:37 +08:00
|
|
|
|
2019-09-24 06:59:50 +08:00
|
|
|
remaining = gimp_value_array_new (gimp_value_array_length (args) - ARG_OFFSET);
|
2019-08-11 02:25:37 +08:00
|
|
|
|
2019-09-24 06:59:50 +08:00
|
|
|
for (i = ARG_OFFSET; i < gimp_value_array_length (args); i++)
|
2019-08-11 02:25:37 +08:00
|
|
|
{
|
|
|
|
GValue *value = gimp_value_array_index (args, i);
|
|
|
|
|
|
|
|
gimp_value_array_append (remaining, value);
|
|
|
|
}
|
|
|
|
|
2024-05-02 03:47:55 +08:00
|
|
|
config = _gimp_procedure_create_run_config (procedure);
|
2023-08-06 09:21:27 +08:00
|
|
|
mimetype = (gchar *) gimp_file_procedure_get_mime_types (GIMP_FILE_PROCEDURE (procedure));
|
2023-08-06 00:58:57 +08:00
|
|
|
|
2023-08-06 09:21:27 +08:00
|
|
|
if (mimetype != NULL)
|
|
|
|
{
|
|
|
|
char *delim;
|
|
|
|
|
|
|
|
mimetype = g_strdup (mimetype);
|
|
|
|
mimetype = g_strstrip (mimetype);
|
|
|
|
delim = strstr (mimetype, ",");
|
|
|
|
if (delim)
|
|
|
|
*delim = '\0';
|
|
|
|
/* Though docs only writes about the list being comma-separated, our
|
|
|
|
* code apparently also split by spaces.
|
|
|
|
*/
|
|
|
|
delim = strstr (mimetype, " ");
|
|
|
|
if (delim)
|
|
|
|
*delim = '\0';
|
|
|
|
delim = strstr (mimetype, "\t");
|
|
|
|
if (delim)
|
|
|
|
*delim = '\0';
|
|
|
|
|
|
|
|
metadata = gimp_metadata_load_from_file (file, NULL);
|
|
|
|
g_free (mimetype);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
flags = GIMP_METADATA_LOAD_NONE;
|
|
|
|
}
|
2023-08-06 00:58:57 +08:00
|
|
|
|
2023-08-06 09:21:27 +08:00
|
|
|
if (metadata == NULL)
|
|
|
|
metadata = gimp_metadata_new ();
|
2023-08-06 00:58:57 +08:00
|
|
|
|
2023-10-15 23:01:47 +08:00
|
|
|
_gimp_procedure_config_begin_run (config, image, run_mode, remaining);
|
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
return_values = priv->run_func (procedure, run_mode,
|
|
|
|
file, metadata, &flags,
|
|
|
|
config, priv->run_data);
|
2023-08-06 00:58:57 +08:00
|
|
|
|
2023-08-06 09:21:27 +08:00
|
|
|
if (return_values != NULL &&
|
|
|
|
gimp_value_array_length (return_values) > 0 &&
|
|
|
|
G_VALUE_HOLDS_ENUM (gimp_value_array_index (return_values, 0)))
|
|
|
|
status = GIMP_VALUES_GET_ENUM (return_values, 0);
|
2023-08-06 00:58:57 +08:00
|
|
|
|
2023-10-15 23:01:47 +08:00
|
|
|
_gimp_procedure_config_end_run (config, status);
|
2023-08-06 00:58:57 +08:00
|
|
|
|
2023-08-06 09:21:27 +08:00
|
|
|
if (status == GIMP_PDB_SUCCESS)
|
|
|
|
{
|
|
|
|
if (gimp_value_array_length (return_values) < 2 ||
|
|
|
|
! GIMP_VALUE_HOLDS_IMAGE (gimp_value_array_index (return_values, 1)))
|
2023-08-06 00:58:57 +08:00
|
|
|
{
|
2023-08-06 09:21:27 +08:00
|
|
|
GError *error = NULL;
|
|
|
|
|
|
|
|
status = GIMP_PDB_EXECUTION_ERROR;
|
|
|
|
g_set_error (&error, GIMP_PLUG_IN_ERROR, 0,
|
|
|
|
_("This file loading plug-in returned SUCCESS as a status without an image. "
|
|
|
|
"This is a bug in the plug-in code. Contact the plug-in developer."));
|
|
|
|
gimp_value_array_unref (return_values);
|
|
|
|
return_values = gimp_procedure_new_return_values (procedure, status, error);
|
2023-08-06 00:58:57 +08:00
|
|
|
}
|
2023-08-06 09:21:27 +08:00
|
|
|
else
|
|
|
|
{
|
|
|
|
image = GIMP_VALUES_GET_IMAGE (return_values, 1);
|
|
|
|
}
|
|
|
|
}
|
2023-08-06 00:58:57 +08:00
|
|
|
|
2023-08-06 09:21:27 +08:00
|
|
|
if (image != NULL && metadata != NULL && flags != GIMP_METADATA_LOAD_NONE)
|
|
|
|
gimp_image_metadata_load_finish (image, NULL, metadata, flags);
|
2023-08-06 00:58:57 +08:00
|
|
|
|
2023-08-06 09:21:27 +08:00
|
|
|
/* This is debug printing to help plug-in developers figure out best
|
|
|
|
* practices.
|
|
|
|
*/
|
2023-10-15 22:34:11 +08:00
|
|
|
plug_in = gimp_procedure_get_plug_in (procedure);
|
|
|
|
if (G_OBJECT (config)->ref_count > 1 &&
|
|
|
|
_gimp_plug_in_manage_memory_manually (plug_in))
|
2024-04-20 11:08:57 +08:00
|
|
|
g_printerr ("%s: ERROR: the GimpExportProcedureConfig object was refed "
|
2023-08-06 09:21:27 +08:00
|
|
|
"by plug-in, it MUST NOT do that!\n", G_STRFUNC);
|
2019-08-11 02:25:37 +08:00
|
|
|
|
2023-08-06 09:21:27 +08:00
|
|
|
g_object_unref (config);
|
|
|
|
g_clear_object (&metadata);
|
2019-08-11 02:25:37 +08:00
|
|
|
gimp_value_array_unref (remaining);
|
|
|
|
|
|
|
|
return return_values;
|
|
|
|
}
|
|
|
|
|
2019-09-24 06:59:50 +08:00
|
|
|
static GimpProcedureConfig *
|
|
|
|
gimp_load_procedure_create_config (GimpProcedure *procedure,
|
|
|
|
GParamSpec **args,
|
|
|
|
gint n_args)
|
|
|
|
{
|
|
|
|
if (n_args > ARG_OFFSET)
|
|
|
|
{
|
|
|
|
args += ARG_OFFSET;
|
|
|
|
n_args -= ARG_OFFSET;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
args = NULL;
|
|
|
|
n_args = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return GIMP_PROCEDURE_CLASS (parent_class)->create_config (procedure,
|
|
|
|
args,
|
|
|
|
n_args);
|
|
|
|
}
|
|
|
|
|
2019-08-11 02:25:37 +08:00
|
|
|
|
|
|
|
/* public functions */
|
|
|
|
|
2019-08-11 20:58:55 +08:00
|
|
|
/**
|
|
|
|
* gimp_load_procedure_new:
|
|
|
|
* @plug_in: a #GimpPlugIn.
|
|
|
|
* @name: the new procedure's name.
|
|
|
|
* @proc_type: the new procedure's #GimpPDBProcType.
|
|
|
|
* @run_func: the run function for the new procedure.
|
|
|
|
* @run_data: user data passed to @run_func.
|
|
|
|
* @run_data_destroy: (nullable): free function for @run_data, or %NULL.
|
|
|
|
*
|
|
|
|
* Creates a new load procedure named @name which will call @run_func
|
|
|
|
* when invoked.
|
|
|
|
*
|
|
|
|
* See gimp_procedure_new() for information about @proc_type.
|
|
|
|
*
|
2021-12-30 02:08:22 +08:00
|
|
|
* Returns: (transfer full): a new #GimpProcedure.
|
2019-08-11 20:58:55 +08:00
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
**/
|
2019-08-11 02:25:37 +08:00
|
|
|
GimpProcedure *
|
|
|
|
gimp_load_procedure_new (GimpPlugIn *plug_in,
|
|
|
|
const gchar *name,
|
|
|
|
GimpPDBProcType proc_type,
|
2019-08-11 20:58:55 +08:00
|
|
|
GimpRunLoadFunc run_func,
|
2019-08-11 02:25:37 +08:00
|
|
|
gpointer run_data,
|
|
|
|
GDestroyNotify run_data_destroy)
|
|
|
|
{
|
2024-07-10 21:03:15 +08:00
|
|
|
GimpLoadProcedure *procedure;
|
|
|
|
GimpLoadProcedurePrivate *priv;
|
2019-08-11 02:25:37 +08:00
|
|
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_PLUG_IN (plug_in), NULL);
|
|
|
|
g_return_val_if_fail (gimp_is_canonical_identifier (name), NULL);
|
2019-08-30 18:52:28 +08:00
|
|
|
g_return_val_if_fail (proc_type != GIMP_PDB_PROC_TYPE_INTERNAL, NULL);
|
|
|
|
g_return_val_if_fail (proc_type != GIMP_PDB_PROC_TYPE_EXTENSION, NULL);
|
2019-08-11 02:25:37 +08:00
|
|
|
g_return_val_if_fail (run_func != NULL, NULL);
|
|
|
|
|
|
|
|
procedure = g_object_new (GIMP_TYPE_LOAD_PROCEDURE,
|
|
|
|
"plug-in", plug_in,
|
|
|
|
"name", name,
|
|
|
|
"procedure-type", proc_type,
|
|
|
|
NULL);
|
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
priv = gimp_load_procedure_get_instance_private (procedure);
|
|
|
|
|
|
|
|
priv->run_func = run_func;
|
|
|
|
priv->run_data = run_data;
|
|
|
|
priv->run_data_destroy = run_data_destroy;
|
2019-08-11 02:25:37 +08:00
|
|
|
|
|
|
|
return GIMP_PROCEDURE (procedure);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gimp_load_procedure_set_handles_raw:
|
2021-12-30 02:08:22 +08:00
|
|
|
* @procedure: A load procedure object.
|
2019-08-11 02:25:37 +08:00
|
|
|
* @handles_raw: The procedure's handles raw flag.
|
|
|
|
*
|
2021-12-30 02:08:22 +08:00
|
|
|
* Registers a load procedure as capable of handling raw digital camera loads.
|
2019-08-11 02:25:37 +08:00
|
|
|
*
|
2024-04-24 19:34:01 +08:00
|
|
|
* Note that you cannot call this function on [class@VectorLoadProcedure]
|
app, libgimp, pdb: new GimpVectorLoadProcedure class.
It's still basic but will help to share code for support of various vector-able
formats, such as the logic for dimensioning them, but also the generated GUI.
Not only this, but we are paving the way for the link layers (though it'll be
after GIMP 3, we want plug-in procedures' API to stay stable) by giving a way
for a plug-in procedure to advertize a vector format support. This way, the core
will know when a source file is vector and can be directly reloaded at any
target size (right now, in my MR for link layers, the list of "vector" formats
is hardcoded, which is not reliable).
2024-04-23 05:11:37 +08:00
|
|
|
* subclass objects.
|
|
|
|
*
|
2019-08-11 02:25:37 +08:00
|
|
|
* Since: 3.0
|
|
|
|
**/
|
|
|
|
void
|
|
|
|
gimp_load_procedure_set_handles_raw (GimpLoadProcedure *procedure,
|
|
|
|
gint handles_raw)
|
|
|
|
{
|
2024-07-10 21:03:15 +08:00
|
|
|
GimpLoadProcedurePrivate *priv;
|
|
|
|
|
2019-08-11 02:25:37 +08:00
|
|
|
g_return_if_fail (GIMP_IS_LOAD_PROCEDURE (procedure));
|
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
priv = gimp_load_procedure_get_instance_private (procedure);
|
|
|
|
|
|
|
|
priv->handles_raw = handles_raw;
|
2019-08-11 02:25:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gimp_load_procedure_get_handles_raw:
|
2021-12-30 02:08:22 +08:00
|
|
|
* @procedure: A load procedure object.
|
|
|
|
*
|
|
|
|
* Returns the procedure's 'handles raw' flag as set with
|
|
|
|
* [method@GimpLoadProcedure.set_handles_raw].
|
2019-08-11 02:25:37 +08:00
|
|
|
*
|
2021-12-30 02:08:22 +08:00
|
|
|
* Returns: The procedure's 'handles raw' flag.
|
2019-08-11 02:25:37 +08:00
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
**/
|
|
|
|
gint
|
|
|
|
gimp_load_procedure_get_handles_raw (GimpLoadProcedure *procedure)
|
|
|
|
{
|
2024-07-10 21:03:15 +08:00
|
|
|
GimpLoadProcedurePrivate *priv;
|
|
|
|
|
2019-08-11 02:25:37 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_LOAD_PROCEDURE (procedure), 0);
|
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
priv = gimp_load_procedure_get_instance_private (procedure);
|
|
|
|
|
|
|
|
return priv->handles_raw;
|
2019-08-11 02:25:37 +08:00
|
|
|
}
|
2019-08-11 20:27:41 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* gimp_load_procedure_set_thumbnail_loader:
|
2021-12-30 02:08:22 +08:00
|
|
|
* @procedure: A load procedure object.
|
2019-08-11 20:27:41 +08:00
|
|
|
* @thumbnail_proc: The name of the thumbnail load procedure.
|
|
|
|
*
|
|
|
|
* Associates a thumbnail loader with a file load procedure.
|
|
|
|
*
|
|
|
|
* Some file formats allow for embedded thumbnails, other file formats
|
|
|
|
* contain a scalable image or provide the image data in different
|
|
|
|
* resolutions. A file plug-in for such a format may register a
|
|
|
|
* special procedure that allows GIMP to load a thumbnail preview of
|
|
|
|
* the image. This procedure is then associated with the standard
|
|
|
|
* load procedure using this function.
|
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
**/
|
|
|
|
void
|
|
|
|
gimp_load_procedure_set_thumbnail_loader (GimpLoadProcedure *procedure,
|
|
|
|
const gchar *thumbnail_proc)
|
|
|
|
{
|
2024-07-10 21:03:15 +08:00
|
|
|
GimpLoadProcedurePrivate *priv;
|
|
|
|
|
2019-08-11 20:27:41 +08:00
|
|
|
g_return_if_fail (GIMP_IS_LOAD_PROCEDURE (procedure));
|
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
priv = gimp_load_procedure_get_instance_private (procedure);
|
|
|
|
g_free (priv->thumbnail_proc);
|
|
|
|
priv->thumbnail_proc = g_strdup (thumbnail_proc);
|
2019-08-11 20:27:41 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gimp_load_procedure_get_thumbnail_loader:
|
2021-12-30 02:08:22 +08:00
|
|
|
* @procedure: A load procedure object.
|
|
|
|
*
|
|
|
|
* Returns the procedure's thumbnail loader procedure as set with
|
|
|
|
* [method@GimpLoadProcedure.set_thumbnail_loader].
|
2019-08-11 20:27:41 +08:00
|
|
|
*
|
2021-12-30 02:08:22 +08:00
|
|
|
* Returns: The procedure's thumbnail loader procedure
|
2019-08-11 20:27:41 +08:00
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
**/
|
|
|
|
const gchar *
|
|
|
|
gimp_load_procedure_get_thumbnail_loader (GimpLoadProcedure *procedure)
|
|
|
|
{
|
2024-07-10 21:03:15 +08:00
|
|
|
GimpLoadProcedurePrivate *priv;
|
|
|
|
|
2019-08-11 20:27:41 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_LOAD_PROCEDURE (procedure), NULL);
|
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
priv = gimp_load_procedure_get_instance_private (procedure);
|
|
|
|
|
|
|
|
return priv->thumbnail_proc;
|
2019-08-11 20:27:41 +08:00
|
|
|
}
|