[gimp] pdb, libgimp: add gimp_load_procedure_set_thumbnail_loader()
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] pdb, libgimp: add gimp_load_procedure_set_thumbnail_loader()
- Date: Sun, 11 Aug 2019 12:28:19 +0000 (UTC)
commit fc065f8addf4ea637acfec6a42250dec2674efe0
Author: Michael Natterer <mitch gimp org>
Date: Sun Aug 11 14:27:41 2019 +0200
pdb, libgimp: add gimp_load_procedure_set_thumbnail_loader()
and move the old API to gimplegacy.[ch]
libgimp/gimp.def | 2 ++
libgimp/gimpfileops_pdb.c | 6 +++---
libgimp/gimpfileops_pdb.h | 2 +-
libgimp/gimplegacy.c | 27 ++++++++++++++++++++++++
libgimp/gimplegacy.h | 2 ++
libgimp/gimploadprocedure.c | 50 +++++++++++++++++++++++++++++++++++++++++++++
libgimp/gimploadprocedure.h | 28 ++++++++++++++-----------
pdb/groups/fileops.pdb | 2 ++
8 files changed, 103 insertions(+), 16 deletions(-)
---
diff --git a/libgimp/gimp.def b/libgimp/gimp.def
index 114bc07b8a..657eb5862b 100644
--- a/libgimp/gimp.def
+++ b/libgimp/gimp.def
@@ -569,9 +569,11 @@ EXPORTS
gimp_layer_set_opacity
gimp_layer_set_show_mask
gimp_load_procedure_get_handles_raw
+ gimp_load_procedure_get_thumbnail_loader
gimp_load_procedure_get_type
gimp_load_procedure_new
gimp_load_procedure_set_handles_raw
+ gimp_load_procedure_set_thumbnail_loader
gimp_main
gimp_main_legacy
gimp_message
diff --git a/libgimp/gimpfileops_pdb.c b/libgimp/gimpfileops_pdb.c
index 23cc4b1cc2..dcd7affb3c 100644
--- a/libgimp/gimpfileops_pdb.c
+++ b/libgimp/gimpfileops_pdb.c
@@ -616,7 +616,7 @@ _gimp_register_file_handler_raw (const gchar *procedure_name)
}
/**
- * gimp_register_thumbnail_loader:
+ * _gimp_register_thumbnail_loader:
* @load_proc: The name of the procedure the thumbnail loader with.
* @thumb_proc: The name of the thumbnail load procedure.
*
@@ -634,8 +634,8 @@ _gimp_register_file_handler_raw (const gchar *procedure_name)
* Since: 2.2
**/
gboolean
-gimp_register_thumbnail_loader (const gchar *load_proc,
- const gchar *thumb_proc)
+_gimp_register_thumbnail_loader (const gchar *load_proc,
+ const gchar *thumb_proc)
{
GimpPDB *pdb = gimp_get_pdb ();
GimpValueArray *args;
diff --git a/libgimp/gimpfileops_pdb.h b/libgimp/gimpfileops_pdb.h
index 54be19cbc2..572f5c2ded 100644
--- a/libgimp/gimpfileops_pdb.h
+++ b/libgimp/gimpfileops_pdb.h
@@ -65,7 +65,7 @@ G_GNUC_INTERNAL gboolean _gimp_register_file_handler_mime (const gchar *proc
const gchar *mime_types);
G_GNUC_INTERNAL gboolean _gimp_register_file_handler_uri (const gchar *procedure_name);
G_GNUC_INTERNAL gboolean _gimp_register_file_handler_raw (const gchar *procedure_name);
-gboolean gimp_register_thumbnail_loader (const gchar *load_proc,
+G_GNUC_INTERNAL gboolean _gimp_register_thumbnail_loader (const gchar *load_proc,
const gchar *thumb_proc);
diff --git a/libgimp/gimplegacy.c b/libgimp/gimplegacy.c
index 1af0d02810..efcee94b4c 100644
--- a/libgimp/gimplegacy.c
+++ b/libgimp/gimplegacy.c
@@ -1396,6 +1396,33 @@ gimp_register_file_handler_raw (const gchar *procedure_name)
return _gimp_register_file_handler_raw (procedure_name);
}
+/**
+ * gimp_register_thumbnail_loader:
+ * @load_proc: The name of the procedure the thumbnail loader with.
+ * @thumb_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.
+ *
+ * Returns: TRUE on success.
+ *
+ * Since: 2.2
+ **/
+gboolean
+gimp_register_thumbnail_loader (const gchar *load_proc,
+ const gchar *thumb_proc)
+{
+ ASSERT_NO_PLUG_IN_EXISTS (G_STRFUNC);
+
+ return _gimp_register_thumbnail_loader (load_proc, thumb_proc);
+}
+
/**
* gimp_pdb_temp_name:
*
diff --git a/libgimp/gimplegacy.h b/libgimp/gimplegacy.h
index 44af8b9918..4c5e20b748 100644
--- a/libgimp/gimplegacy.h
+++ b/libgimp/gimplegacy.h
@@ -328,6 +328,8 @@ gboolean gimp_register_file_handler_mime (const gchar *procedure_name,
const gchar *mime_types);
gboolean gimp_register_file_handler_uri (const gchar *procedure_name);
gboolean gimp_register_file_handler_raw (const gchar *procedure_name);
+gboolean gimp_register_thumbnail_loader (const gchar *load_proc,
+ const gchar *thumb_proc);
/* pdb stuff that should now be done using GimpPDB
*/
diff --git a/libgimp/gimploadprocedure.c b/libgimp/gimploadprocedure.c
index 918fb38abc..76e2e5b9b8 100644
--- a/libgimp/gimploadprocedure.c
+++ b/libgimp/gimploadprocedure.c
@@ -34,6 +34,7 @@ struct _GimpLoadProcedurePrivate
GDestroyNotify run_data_destroy;
gboolean handles_raw;
+ gchar *thumbnail_proc;
};
@@ -111,6 +112,8 @@ gimp_load_procedure_finalize (GObject *object)
if (procedure->priv->run_data_destroy)
procedure->priv->run_data_destroy (procedure->priv->run_data);
+ g_clear_pointer (&procedure->priv->thumbnail_proc, g_free);
+
G_OBJECT_CLASS (parent_class)->finalize (object);
}
@@ -153,6 +156,10 @@ gimp_load_procedure_install (GimpProcedure *procedure)
if (load_proc->priv->handles_raw)
_gimp_register_file_handler_raw (gimp_procedure_get_name (procedure));
+
+ if (load_proc->priv->thumbnail_proc)
+ _gimp_register_thumbnail_loader (gimp_procedure_get_name (procedure),
+ load_proc->priv->thumbnail_proc);
}
static GimpValueArray *
@@ -260,3 +267,46 @@ gimp_load_procedure_get_handles_raw (GimpLoadProcedure *procedure)
return procedure->priv->handles_raw;
}
+
+/**
+ * gimp_load_procedure_set_thumbnail_loader:
+ * @procedure: A #GimpLoadProcedure.
+ * @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)
+{
+ g_return_if_fail (GIMP_IS_LOAD_PROCEDURE (procedure));
+
+ g_free (procedure->priv->thumbnail_proc);
+ procedure->priv->thumbnail_proc = g_strdup (thumbnail_proc);
+}
+
+/**
+ * gimp_load_procedure_get_thumbnail_loader:
+ * @procedure: A #GimpLoadProcedure.
+ *
+ * Returns: The procedure's thumbnail loader procedure as set with
+ * gimp_load_procedure_set_thumbnail_procedure().
+ *
+ * Since: 3.0
+ **/
+const gchar *
+gimp_load_procedure_get_thumbnail_loader (GimpLoadProcedure *procedure)
+{
+ g_return_val_if_fail (GIMP_IS_LOAD_PROCEDURE (procedure), NULL);
+
+ return procedure->priv->thumbnail_proc;
+}
diff --git a/libgimp/gimploadprocedure.h b/libgimp/gimploadprocedure.h
index 1b77e03908..4011fbe6a3 100644
--- a/libgimp/gimploadprocedure.h
+++ b/libgimp/gimploadprocedure.h
@@ -76,18 +76,22 @@ struct _GimpLoadProcedureClass
};
-GType gimp_load_procedure_get_type (void) G_GNUC_CONST;
-
-GimpProcedure * gimp_load_procedure_new (GimpPlugIn *plug_in,
- const gchar *name,
- GimpPDBProcType proc_type,
- GimpLoadFunc run_func,
- gpointer run_data,
- GDestroyNotify run_data_destroy);
-
-void gimp_load_procedure_set_handles_raw (GimpLoadProcedure *procedure,
- gboolean handles_raw);
-gboolean gimp_load_procedure_get_handles_raw (GimpLoadProcedure *procedure);
+GType gimp_load_procedure_get_type (void) G_GNUC_CONST;
+
+GimpProcedure * gimp_load_procedure_new (GimpPlugIn *plug_in,
+ const gchar *name,
+ GimpPDBProcType proc_type,
+ GimpLoadFunc run_func,
+ gpointer run_data,
+ GDestroyNotify run_data_destroy);
+
+void gimp_load_procedure_set_handles_raw (GimpLoadProcedure *procedure,
+ gboolean handles_raw);
+gboolean gimp_load_procedure_get_handles_raw (GimpLoadProcedure *procedure);
+
+void gimp_load_procedure_set_thumbnail_loader (GimpLoadProcedure *procedure,
+ const gchar *thumbnail_proc);
+const gchar * gimp_load_procedure_get_thumbnail_loader (GimpLoadProcedure *procedure);
G_END_DECLS
diff --git a/pdb/groups/fileops.pdb b/pdb/groups/fileops.pdb
index a9df8419ea..75e205644e 100644
--- a/pdb/groups/fileops.pdb
+++ b/pdb/groups/fileops.pdb
@@ -712,6 +712,8 @@ HELP
&neo_pdb_misc('2004', '2.2');
+ $lib_private = 1;
+
@inargs = (
{ name => 'load_proc', type => 'string', non_empty => 1,
desc => "The name of the procedure the thumbnail loader with." },
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]