[gimp] libimp*, app: get rid of inline pixbufs in the API and in pluginrc
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] libimp*, app: get rid of inline pixbufs in the API and in pluginrc
- Date: Thu, 8 Aug 2019 22:16:48 +0000 (UTC)
commit 155bc75a75439989473ef100453b3c16572b1e57
Author: Michael Natterer <mitch gimp org>
Date: Fri Aug 9 00:05:49 2019 +0200
libimp*, app: get rid of inline pixbufs in the API and in pluginrc
because they are deprecated.
Change GIMP_ICON_TYPE_INLINE_PIXBUF to GIMP_ICON_TYPE_PIXBUF and the
libgimp API to (icon-name, GdkPixbuf, GFile). Use the file's uri and a
PNG blob of the pixbuf to pass around on the wire and for storage in
pluginrc.
app/plug-in/gimppluginprocedure.c | 46 +++---
app/plug-in/plug-in-rc.c | 6 +-
libgimp/gimp.def | 9 +-
libgimp/gimplegacy.c | 46 ++++--
libgimp/gimplegacy.h | 10 +-
libgimp/gimpprocedure-private.c | 53 ++++++-
libgimp/gimpprocedure.c | 244 +++++++++++++-------------------
libgimp/gimpprocedure.h | 17 +--
libgimpbase/gimpbaseenums.c | 4 +-
libgimpbase/gimpbaseenums.h | 12 +-
pdb/enums.pl | 5 +-
plug-ins/common/plugin-browser.c | 3 +-
plug-ins/goat-exercises/goat-exercise.c | 3 +-
plug-ins/screenshot/screenshot.c | 5 +-
14 files changed, 237 insertions(+), 226 deletions(-)
---
diff --git a/app/plug-in/gimppluginprocedure.c b/app/plug-in/gimppluginprocedure.c
index e432b23f01..2f528c9f9f 100644
--- a/app/plug-in/gimppluginprocedure.c
+++ b/app/plug-in/gimppluginprocedure.c
@@ -200,7 +200,7 @@ gimp_plug_in_procedure_get_memsize (GimpObject *object,
memsize += gimp_string_get_memsize ((const gchar *) proc->icon_data);
break;
- case GIMP_ICON_TYPE_INLINE_PIXBUF:
+ case GIMP_ICON_TYPE_PIXBUF:
memsize += proc->icon_data_length;
break;
}
@@ -806,30 +806,11 @@ gimp_plug_in_procedure_set_icon (GimpPlugInProcedure *proc,
const guint8 *icon_data,
gint icon_data_length)
{
- guint8 *data_copy = NULL;
-
g_return_if_fail (GIMP_IS_PLUG_IN_PROCEDURE (proc));
- switch (icon_type)
- {
- case GIMP_ICON_TYPE_ICON_NAME:
- data_copy = (guint8 *) g_strdup ((gchar *) icon_data);
- break;
-
- case GIMP_ICON_TYPE_INLINE_PIXBUF:
- data_copy = g_memdup (icon_data, icon_data_length);
- break;
-
- case GIMP_ICON_TYPE_IMAGE_FILE:
- data_copy = (guint8 *) g_strdup ((gchar *) icon_data);
- break;
-
- default:
- g_return_if_reached ();
- }
-
gimp_plug_in_procedure_take_icon (proc, icon_type,
- data_copy, icon_data_length);
+ g_memdup (icon_data, icon_data_length),
+ icon_data_length);
}
void
@@ -855,6 +836,8 @@ gimp_plug_in_procedure_take_icon (GimpPlugInProcedure *proc,
switch (proc->icon_type)
{
+ GdkPixbufLoader *loader;
+
case GIMP_ICON_TYPE_ICON_NAME:
proc->icon_data_length = -1;
proc->icon_data = icon_data;
@@ -862,12 +845,23 @@ gimp_plug_in_procedure_take_icon (GimpPlugInProcedure *proc,
icon_name = (const gchar *) proc->icon_data;
break;
- case GIMP_ICON_TYPE_INLINE_PIXBUF:
+ case GIMP_ICON_TYPE_PIXBUF:
proc->icon_data_length = icon_data_length;
proc->icon_data = icon_data;
- icon_pixbuf = gdk_pixbuf_new_from_inline (proc->icon_data_length,
- proc->icon_data, TRUE, &error);
+ loader = gdk_pixbuf_loader_new ();
+
+ gdk_pixbuf_loader_write (loader,
+ proc->icon_data,
+ proc->icon_data_length,
+ NULL);
+ gdk_pixbuf_loader_close (loader, NULL);
+ icon_pixbuf = gdk_pixbuf_loader_get_pixbuf (loader);
+
+ if (icon_pixbuf)
+ g_object_ref (icon_pixbuf);
+
+ g_object_unref (loader);
break;
case GIMP_ICON_TYPE_IMAGE_FILE:
@@ -881,7 +875,7 @@ gimp_plug_in_procedure_take_icon (GimpPlugInProcedure *proc,
if (! icon_pixbuf && error)
{
- g_printerr ("gimp_plug_in_procedure_take_icon: %s\n", error->message);
+ g_printerr ("%s: %s\n", G_STRFUNC, error->message);
g_clear_error (&error);
}
diff --git a/app/plug-in/plug-in-rc.c b/app/plug-in/plug-in-rc.c
index 790060dfbc..5d1fdeaa80 100644
--- a/app/plug-in/plug-in-rc.c
+++ b/app/plug-in/plug-in-rc.c
@@ -40,7 +40,7 @@
#include "gimp-intl.h"
-#define PLUG_IN_RC_FILE_VERSION 7
+#define PLUG_IN_RC_FILE_VERSION 8
/*
@@ -586,7 +586,7 @@ plug_in_icon_deserialize (GScanner *scanner,
icon_data = (guint8 *) icon_name;
break;
- case GIMP_ICON_TYPE_INLINE_PIXBUF:
+ case GIMP_ICON_TYPE_PIXBUF:
if (icon_data_length < 0)
return G_TOKEN_STRING;
@@ -1204,7 +1204,7 @@ plug_in_rc_write (GSList *plug_in_defs,
gimp_config_writer_string (writer, (gchar *) proc->icon_data);
break;
- case GIMP_ICON_TYPE_INLINE_PIXBUF:
+ case GIMP_ICON_TYPE_PIXBUF:
gimp_config_writer_data (writer, proc->icon_data_length,
proc->icon_data);
break;
diff --git a/libgimp/gimp.def b/libgimp/gimp.def
index f2e98e626f..75a8a15b1d 100644
--- a/libgimp/gimp.def
+++ b/libgimp/gimp.def
@@ -667,7 +667,10 @@ EXPORTS
gimp_procedure_get_date
gimp_procedure_get_help
gimp_procedure_get_help_id
- gimp_procedure_get_icon
+ gimp_procedure_get_icon_file
+ gimp_procedure_get_icon_name
+ gimp_procedure_get_icon_pixbuf
+ gimp_procedure_get_icon_type
gimp_procedure_get_image_types
gimp_procedure_get_menu_label
gimp_procedure_get_menu_paths
@@ -682,7 +685,9 @@ EXPORTS
gimp_procedure_run
gimp_procedure_set_attribution
gimp_procedure_set_documentation
- gimp_procedure_set_icon
+ gimp_procedure_set_icon_file
+ gimp_procedure_set_icon_name
+ gimp_procedure_set_icon_pixbuf
gimp_procedure_set_image_types
gimp_procedure_set_menu_label
gimp_progress_cancel
diff --git a/libgimp/gimplegacy.c b/libgimp/gimplegacy.c
index 62e1257263..7bace34b02 100644
--- a/libgimp/gimplegacy.c
+++ b/libgimp/gimplegacy.c
@@ -1159,7 +1159,7 @@ gimp_plugin_menu_register (const gchar *procedure_name,
* gimp_plugin_icon_register:
* @procedure_name: The procedure for which to install the icon.
* @icon_type: The type of the icon.
- * @icon_data: (element-type guint8): The procedure's icon. The format depends on the 'icon_type' parameter.
+ * @icon_data: The procedure's icon. The format depends on @icon_type.
*
* Register an icon for a plug-in procedure.
*
@@ -1170,11 +1170,13 @@ gimp_plugin_menu_register (const gchar *procedure_name,
* Since: 2.2
**/
gboolean
-gimp_plugin_icon_register (const gchar *procedure_name,
- GimpIconType icon_type,
- const guint8 *icon_data)
+gimp_plugin_icon_register (const gchar *procedure_name,
+ GimpIconType icon_type,
+ gconstpointer icon_data)
{
- gint icon_data_length;
+ guint8 *data;
+ gsize data_length;
+ gboolean success;
g_return_val_if_fail (procedure_name != NULL, FALSE);
g_return_val_if_fail (icon_data != NULL, FALSE);
@@ -1184,23 +1186,41 @@ gimp_plugin_icon_register (const gchar *procedure_name,
switch (icon_type)
{
case GIMP_ICON_TYPE_ICON_NAME:
- case GIMP_ICON_TYPE_IMAGE_FILE:
- icon_data_length = strlen ((const gchar *) icon_data) + 1;
+ data = (guint8 *) icon_data;
+ data_length = strlen (icon_data) + 1;
break;
- case GIMP_ICON_TYPE_INLINE_PIXBUF:
- g_return_val_if_fail (g_ntohl (*((gint32 *) icon_data)) == 0x47646b50,
- FALSE);
+ case GIMP_ICON_TYPE_PIXBUF:
+ if (! gdk_pixbuf_save_to_buffer ((GdkPixbuf *) icon_data,
+ (gchar **) &data, &data_length,
+ "png", NULL, NULL))
+ return FALSE;
+ break;
- icon_data_length = g_ntohl (*((gint32 *) (icon_data + 4)));
+ case GIMP_ICON_TYPE_IMAGE_FILE:
+ data = (guint8 *) g_file_get_uri ((GFile *) icon_data);
+ data_length = strlen (icon_data) + 1;
break;
default:
g_return_val_if_reached (FALSE);
}
- return _gimp_plugin_icon_register (procedure_name,
- icon_type, icon_data_length, icon_data);
+ success = _gimp_plugin_icon_register (procedure_name,
+ icon_type, data_length, data);
+
+ switch (icon_type)
+ {
+ case GIMP_ICON_TYPE_ICON_NAME:
+ break;
+
+ case GIMP_ICON_TYPE_PIXBUF:
+ case GIMP_ICON_TYPE_IMAGE_FILE:
+ g_free (data);
+ break;
+ }
+
+ return success;
}
/**
diff --git a/libgimp/gimplegacy.h b/libgimp/gimplegacy.h
index 3c27fddb67..58624796c4 100644
--- a/libgimp/gimplegacy.h
+++ b/libgimp/gimplegacy.h
@@ -303,11 +303,11 @@ GimpPDBErrorHandler
/* gimp_plugin API that should now be done by using GimpProcedure
*/
-gboolean gimp_plugin_menu_register (const gchar *procedure_name,
- const gchar *menu_path);
-gboolean gimp_plugin_icon_register (const gchar *procedure_name,
- GimpIconType icon_type,
- const guint8 *icon_data);
+gboolean gimp_plugin_menu_register (const gchar *procedure_name,
+ const gchar *menu_path);
+gboolean gimp_plugin_icon_register (const gchar *procedure_name,
+ GimpIconType icon_type,
+ gconstpointer icon_data);
/* pdb stuff that should now be done using GimpPDB
*/
diff --git a/libgimp/gimpprocedure-private.c b/libgimp/gimpprocedure-private.c
index 1dede20319..3ebcd491b8 100644
--- a/libgimp/gimpprocedure-private.c
+++ b/libgimp/gimpprocedure-private.c
@@ -45,8 +45,8 @@ _gimp_procedure_register (GimpProcedure *procedure)
GimpPlugIn *plug_in;
GPProcInstall proc_install;
GimpIconType icon_type;
- const guint8 *icon_data;
- gint icon_data_length;
+ guint8 *icon_data = NULL;
+ gsize icon_data_length = 0;
gint i;
g_return_if_fail (GIMP_IS_PROCEDURE (procedure));
@@ -87,12 +87,57 @@ _gimp_procedure_register (GimpProcedure *procedure)
&proc_install, plug_in))
gimp_quit ();
- icon_type = gimp_procedure_get_icon (procedure,
- &icon_data, &icon_data_length);
+ icon_type = gimp_procedure_get_icon_type (procedure);
+
+ switch (icon_type)
+ {
+ case GIMP_ICON_TYPE_ICON_NAME:
+ {
+ icon_data = (guint8 *) gimp_procedure_get_icon_name (procedure);
+ if (icon_data)
+ icon_data_length = strlen ((gchar *) icon_data) + 1;
+ }
+ break;
+
+ case GIMP_ICON_TYPE_PIXBUF:
+ {
+ GdkPixbuf *pixbuf = gimp_procedure_get_icon_pixbuf (procedure);
+
+ if (pixbuf)
+ gdk_pixbuf_save_to_buffer (pixbuf,
+ (gchar **) &icon_data, &icon_data_length,
+ "png", NULL, NULL);
+ }
+ break;
+
+ case GIMP_ICON_TYPE_IMAGE_FILE:
+ {
+ GFile *file = gimp_procedure_get_icon_file (procedure);
+
+ if (file)
+ {
+ icon_data = (guchar *) g_file_get_uri (file);
+ icon_data_length = strlen ((gchar *) icon_data) + 1;
+ }
+ }
+ break;
+ }
+
if (icon_data)
_gimp_plugin_icon_register (gimp_procedure_get_name (procedure),
icon_type, icon_data_length, icon_data);
+ switch (icon_type)
+ {
+ case GIMP_ICON_TYPE_ICON_NAME:
+ break;
+
+ case GIMP_ICON_TYPE_PIXBUF:
+ case GIMP_ICON_TYPE_IMAGE_FILE:
+ g_free (icon_data);
+ break;
+ }
+
g_free (proc_install.params);
g_free (proc_install.return_vals);
diff --git a/libgimp/gimpprocedure.c b/libgimp/gimpprocedure.c
index 44abb69d3c..d2370dc76b 100644
--- a/libgimp/gimpprocedure.c
+++ b/libgimp/gimpprocedure.c
@@ -62,8 +62,7 @@ struct _GimpProcedurePrivate
gchar *date;
GimpIconType icon_type;
- guint8 *icon_data;
- gint icon_data_length;
+ gpointer icon_data;
gint32 n_args;
GParamSpec **args;
@@ -99,6 +98,10 @@ static gboolean gimp_procedure_validate_args (GimpProcedure *procedure,
gboolean return_vals,
GError **error);
+static void gimp_procedure_set_icon (GimpProcedure *procedure,
+ GimpIconType icon_type,
+ gconstpointer icon_data);
+
G_DEFINE_TYPE_WITH_PRIVATE (GimpProcedure, gimp_procedure, G_TYPE_OBJECT)
@@ -188,8 +191,7 @@ gimp_procedure_finalize (GObject *object)
g_list_free_full (procedure->priv->menu_paths, g_free);
procedure->priv->menu_paths = NULL;
- g_clear_pointer (&procedure->priv->icon_data, g_free);
- procedure->priv->icon_data_length = 0;
+ gimp_procedure_set_icon (procedure, GIMP_ICON_TYPE_ICON_NAME, NULL);
if (procedure->priv->args)
{
@@ -704,160 +706,79 @@ gimp_procedure_get_date (GimpProcedure *procedure)
return procedure->priv->date;
}
-/**
- * gimp_procedure_set_icon: (skip)
- * @procedure: a #GimpProcedure.
- * @icon_type: the #GimpIconType of @icon_data.
- * @icon_data: icon representation.
- *
- * Sets the icon for @procedure. @icon_data contents type depends on
- * @icon_type.
- *
- * This procedure is skipped from bindings, where you should use
- * specific gimp_procedure_set_icon_*() instead, such as
- * gimp_procedure_set_icon_name().
- */
-void
-gimp_procedure_set_icon (GimpProcedure *procedure,
- GimpIconType icon_type,
- const guint8 *icon_data)
-{
- g_return_if_fail (GIMP_IS_PROCEDURE (procedure));
- g_return_if_fail (icon_data != NULL);
- g_return_if_fail (icon_data != procedure->priv->icon_data);
-
- g_clear_pointer (&procedure->priv->icon_data, g_free);
- procedure->priv->icon_data_length = 0;
-
- procedure->priv->icon_type = icon_type;
-
- switch (icon_type)
- {
- case GIMP_ICON_TYPE_ICON_NAME:
- case GIMP_ICON_TYPE_IMAGE_FILE:
- procedure->priv->icon_data =
- (guint8 *) g_strdup ((const gchar *) icon_data);
-
- procedure->priv->icon_data_length =
- strlen ((const gchar *) icon_data);
- break;
-
- case GIMP_ICON_TYPE_INLINE_PIXBUF:
- g_return_if_fail (g_ntohl (*((gint32 *) icon_data)) == 0x47646b50);
-
- procedure->priv->icon_data_length =
- g_ntohl (*((gint32 *) (icon_data + 4)));
-
- procedure->priv->icon_data =
- g_memdup (icon_data, procedure->priv->icon_data_length);
- break;
-
- default:
- g_return_if_reached ();
- }
-}
-
/**
* gimp_procedure_set_icon_name:
* @procedure: a #GimpProcedure.
- * @icon_name: an icon name.
+ * @icon_name: (nullable): an icon name.
+ *
+ * Sets the icon for @procedure to the icon referenced by @icon_name.
*
- * Sets the icon for @procedure by its name.
+ * Since: 3.0
*/
void
gimp_procedure_set_icon_name (GimpProcedure *procedure,
const gchar *icon_name)
{
g_return_if_fail (GIMP_IS_PROCEDURE (procedure));
- g_return_if_fail (icon_name != NULL);
gimp_procedure_set_icon (procedure,
GIMP_ICON_TYPE_ICON_NAME,
- (const guint8*) icon_name);
+ icon_name);
}
/**
- * gimp_procedure_set_icon_file:
+ * gimp_procedure_set_icon_pixbuf:
* @procedure: a #GimpProcedure.
- * @icon_path: a file path for an image.
+ * @pixbuf: (nullable): a #GdkPixbuf.
+ *
+ * Sets the icon for @procedure to @pixbuf.
*
- * Sets the icon for @procedure by specifying an image file path in a
- * format supported by GdkPixbuf. @icon_path must be in in the GLib file
- * name encoding.
+ * Since: 3.0
*/
void
-gimp_procedure_set_icon_file (GimpProcedure *procedure,
- const gchar *icon_path)
+gimp_procedure_set_icon_pixbuf (GimpProcedure *procedure,
+ GdkPixbuf *pixbuf)
{
g_return_if_fail (GIMP_IS_PROCEDURE (procedure));
- g_return_if_fail (icon_path != NULL);
+ g_return_if_fail (pixbuf == NULL || GDK_IS_PIXBUF (pixbuf));
gimp_procedure_set_icon (procedure,
- GIMP_ICON_TYPE_IMAGE_FILE,
- (const guint8*) icon_path);
+ GIMP_ICON_TYPE_PIXBUF,
+ pixbuf);
}
/**
- * gimp_procedure_set_icon_inline:
+ * gimp_procedure_set_icon_file:
* @procedure: a #GimpProcedure.
- * @icon_data: inline pixel data for the icon image.
+ * @file: (nullable): a #GFile pointing to an image file.
*
- * Sets the icon for @procedure by specifying inline pixel data. The
- * data must be serialized in the format supported by
- * gdk_pixbuf_new_from_inline(), e.g. as generated by the tool
- * [gdk-pixbuf-csource](https://developer.gnome.org/gdk-pixbuf/stable/gdk-pixbuf-csource.html).
+ * Sets the icon for @procedure to the contents of an image file.
+ *
+ * Since: 3.0
*/
void
-gimp_procedure_set_icon_inline (GimpProcedure *procedure,
- const guint8 *icon_data)
+gimp_procedure_set_icon_file (GimpProcedure *procedure,
+ GFile *file)
{
g_return_if_fail (GIMP_IS_PROCEDURE (procedure));
- g_return_if_fail (icon_data != NULL);
+ g_return_if_fail (file == NULL || G_IS_FILE (file));
gimp_procedure_set_icon (procedure,
- GIMP_ICON_TYPE_INLINE_PIXBUF,
- icon_data);
-}
-
-/**
- * gimp_procedure_get_icon: (skip)
- * @procedure: a #GimpProcedure.
- * @icon_data: icon representation.
- * @icon_data_length: length of @icon_data.
- *
- * Gets the icon for @procedure. @icon_data contents type depends on
- * the returned type.
- *
- * This procedure is skipped from bindings, where you should use
- * specific gimp_procedure_get_icon_type() instead, followed by the
- * relevant specific function, such as gimp_procedure_get_icon_name().
- *
- * Returns: the #GimpIconType of @icon_data.
- */
-GimpIconType
-gimp_procedure_get_icon (GimpProcedure *procedure,
- const guint8 **icon_data,
- gint *icon_data_length)
-{
- g_return_val_if_fail (GIMP_IS_PROCEDURE (procedure), -1);
- g_return_val_if_fail (icon_data != NULL, -1);
- g_return_val_if_fail (icon_data_length != NULL, -1);
-
- *icon_data = (guint8 *) procedure->priv->icon_data;
- *icon_data_length = procedure->priv->icon_data_length;
-
- return procedure->priv->icon_type;
+ GIMP_ICON_TYPE_IMAGE_FILE,
+ file);
}
/**
* gimp_procedure_get_icon_type:
* @procedure: a #GimpProcedure.
*
- * Gets the type of data set as @procedure's icon.
- * Depending on the result, you can call the relevant specific function,
- * such as gimp_procedure_get_icon_name().
+ * Gets the type of data set as @procedure's icon. Depending on the
+ * result, you can call the relevant specific function, such as
+ * gimp_procedure_get_icon_name().
*
- * Returns: the #GimpIconType of @icon_data.
+ * Returns: the #GimpIconType of @procedure's icon.
+ *
+ * Since: 3.0
*/
GimpIconType
gimp_procedure_get_icon_type (GimpProcedure *procedure)
@@ -874,6 +795,8 @@ gimp_procedure_get_icon_type (GimpProcedure *procedure)
* Gets the name of the icon if one was set for @procedure.
*
* Returns: (nullable): the icon name or %NULL if no icon name was set.
+ *
+ * Since: 3.0
*/
const gchar *
gimp_procedure_get_icon_name (GimpProcedure *procedure)
@@ -882,58 +805,51 @@ gimp_procedure_get_icon_name (GimpProcedure *procedure)
if (procedure->priv->icon_type == GIMP_ICON_TYPE_ICON_NAME)
return (const gchar *) procedure->priv->icon_data;
- else
- return NULL;
+
+ return NULL;
}
/**
* gimp_procedure_get_icon_file:
* @procedure: a #GimpProcedure.
*
- * Gets the file path of the icon if one was set for @procedure.
+ * Gets the file of the icon if one was set for @procedure.
*
- * Returns: (nullable): the icon file path or %NULL if no file was set.
+ * Returns: (nullable): the icon #GFile or %NULL if no file was set.
+ *
+ * Since: 3.0
*/
-const gchar *
+GFile *
gimp_procedure_get_icon_file (GimpProcedure *procedure)
{
g_return_val_if_fail (GIMP_IS_PROCEDURE (procedure), NULL);
if (procedure->priv->icon_type == GIMP_ICON_TYPE_IMAGE_FILE)
- return (const gchar *) procedure->priv->icon_data;
- else
- return NULL;
+ return (GFile *) procedure->priv->icon_data;
+
+ return NULL;
}
/**
- * gimp_procedure_get_icon_inline:
+ * gimp_procedure_get_icon_pixbuf:
* @procedure: a #GimpProcedure.
- * @icon_data_length: length of @icon_data.
*
- * Gets the pixel data of the icon if an icon was set this way for
- * @procedure. See gimp_procedure_set_icon_file() for information on the
- * format of returned data.
+ * Gets the #GdkPixbuf of the icon if an icon was set this way for
+ * @procedure.
*
- * Returns: (nullable) (array length=icon_data_length):
- the icon byte data or %NULL if no icon name was set.
+ * Returns: (nullable): the icon pixbuf or %NULL if no icon name was set.
+ *
+ * Since: 3.0
*/
-const guint8 *
-gimp_procedure_get_icon_inline (GimpProcedure *procedure,
- gint *icon_data_length)
+GdkPixbuf *
+gimp_procedure_get_icon_pixbuf (GimpProcedure *procedure)
{
g_return_val_if_fail (GIMP_IS_PROCEDURE (procedure), NULL);
- g_return_val_if_fail (icon_data_length != NULL, NULL);
- if (procedure->priv->icon_type == GIMP_ICON_TYPE_INLINE_PIXBUF)
- {
- *icon_data_length = procedure->priv->icon_data_length;
+ if (procedure->priv->icon_type == GIMP_ICON_TYPE_PIXBUF)
+ return (GdkPixbuf *) procedure->priv->icon_data;
- return (const guint8 *) procedure->priv->icon_data;
- }
- else
- {
- return NULL;
- }
+ return NULL;
}
/**
@@ -1432,3 +1348,43 @@ gimp_procedure_validate_args (GimpProcedure *procedure,
return TRUE;
}
+
+static void
+gimp_procedure_set_icon (GimpProcedure *procedure,
+ GimpIconType icon_type,
+ gconstpointer icon_data)
+{
+ g_return_if_fail (GIMP_IS_PROCEDURE (procedure));
+
+ if (icon_data == procedure->priv->icon_data)
+ return;
+
+ switch (procedure->priv->icon_type)
+ {
+ case GIMP_ICON_TYPE_ICON_NAME:
+ g_clear_pointer (&procedure->priv->icon_data, g_free);
+ break;
+
+ case GIMP_ICON_TYPE_PIXBUF:
+ case GIMP_ICON_TYPE_IMAGE_FILE:
+ g_clear_object (&procedure->priv->icon_data);
+ break;
+ }
+
+ procedure->priv->icon_type = icon_type;
+
+ switch (icon_type)
+ {
+ case GIMP_ICON_TYPE_ICON_NAME:
+ procedure->priv->icon_data = g_strdup (icon_data);
+ break;
+
+ case GIMP_ICON_TYPE_PIXBUF:
+ case GIMP_ICON_TYPE_IMAGE_FILE:
+ g_set_object (&procedure->priv->icon_data, (GObject *) icon_data);
+ break;
+
+ default:
+ g_return_if_reached ();
+ }
+}
diff --git a/libgimp/gimpprocedure.h b/libgimp/gimpprocedure.h
index b991e0012a..fb83c33bfd 100644
--- a/libgimp/gimpprocedure.h
+++ b/libgimp/gimpprocedure.h
@@ -127,24 +127,17 @@ const gchar * gimp_procedure_get_authors (GimpProcedure *proced
const gchar * gimp_procedure_get_copyright (GimpProcedure *procedure);
const gchar * gimp_procedure_get_date (GimpProcedure *procedure);
-void gimp_procedure_set_icon (GimpProcedure *procedure,
- GimpIconType icon_type,
- const guint8 *icon_data);
void gimp_procedure_set_icon_name (GimpProcedure *procedure,
const gchar *icon_name);
void gimp_procedure_set_icon_file (GimpProcedure *procedure,
- const gchar *icon_path);
-void gimp_procedure_set_icon_inline (GimpProcedure *procedure,
- const guint8 *icon_data);
+ GFile *file);
+void gimp_procedure_set_icon_pixbuf (GimpProcedure *procedure,
+ GdkPixbuf *pixbuf);
-GimpIconType gimp_procedure_get_icon (GimpProcedure *procedure,
- const guint8 **icon_data,
- gint *icon_data_length);
GimpIconType gimp_procedure_get_icon_type (GimpProcedure *procedure);
const gchar * gimp_procedure_get_icon_name (GimpProcedure *procedure);
-const gchar * gimp_procedure_get_icon_file (GimpProcedure *procedure);
-const guint8 * gimp_procedure_get_icon_inline (GimpProcedure *procedure,
- gint *icon_data_length);
+GFile * gimp_procedure_get_icon_file (GimpProcedure *procedure);
+GdkPixbuf * gimp_procedure_get_icon_pixbuf (GimpProcedure *procedure);
void gimp_procedure_add_argument (GimpProcedure *procedure,
GParamSpec *pspec);
diff --git a/libgimpbase/gimpbaseenums.c b/libgimpbase/gimpbaseenums.c
index 0f102aaf63..e8372bd02a 100644
--- a/libgimpbase/gimpbaseenums.c
+++ b/libgimpbase/gimpbaseenums.c
@@ -852,7 +852,7 @@ gimp_icon_type_get_type (void)
static const GEnumValue values[] =
{
{ GIMP_ICON_TYPE_ICON_NAME, "GIMP_ICON_TYPE_ICON_NAME", "icon-name" },
- { GIMP_ICON_TYPE_INLINE_PIXBUF, "GIMP_ICON_TYPE_INLINE_PIXBUF", "inline-pixbuf" },
+ { GIMP_ICON_TYPE_PIXBUF, "GIMP_ICON_TYPE_PIXBUF", "pixbuf" },
{ GIMP_ICON_TYPE_IMAGE_FILE, "GIMP_ICON_TYPE_IMAGE_FILE", "image-file" },
{ 0, NULL, NULL }
};
@@ -860,7 +860,7 @@ gimp_icon_type_get_type (void)
static const GimpEnumDesc descs[] =
{
{ GIMP_ICON_TYPE_ICON_NAME, NC_("icon-type", "Icon name"), NULL },
- { GIMP_ICON_TYPE_INLINE_PIXBUF, NC_("icon-type", "Inline pixbuf"), NULL },
+ { GIMP_ICON_TYPE_PIXBUF, NC_("icon-type", "Pixbuf"), NULL },
{ GIMP_ICON_TYPE_IMAGE_FILE, NC_("icon-type", "Image file"), NULL },
{ 0, NULL, NULL }
};
diff --git a/libgimpbase/gimpbaseenums.h b/libgimpbase/gimpbaseenums.h
index 9fd389bd02..4dd9f5e2df 100644
--- a/libgimpbase/gimpbaseenums.h
+++ b/libgimpbase/gimpbaseenums.h
@@ -582,9 +582,9 @@ typedef enum
/**
* GimpIconType:
- * @GIMP_ICON_TYPE_ICON_NAME: Icon name
- * @GIMP_ICON_TYPE_INLINE_PIXBUF: Inline pixbuf
- * @GIMP_ICON_TYPE_IMAGE_FILE: Image file
+ * @GIMP_ICON_TYPE_ICON_NAME: Icon name
+ * @GIMP_ICON_TYPE_PIXBUF: Inline pixbuf
+ * @GIMP_ICON_TYPE_IMAGE_FILE: Image file
*
* Icon types for plug-ins to register.
**/
@@ -594,9 +594,9 @@ GType gimp_icon_type_get_type (void) G_GNUC_CONST;
typedef enum
{
- GIMP_ICON_TYPE_ICON_NAME, /*< desc="Icon name" >*/
- GIMP_ICON_TYPE_INLINE_PIXBUF, /*< desc="Inline pixbuf" >*/
- GIMP_ICON_TYPE_IMAGE_FILE /*< desc="Image file" >*/
+ GIMP_ICON_TYPE_ICON_NAME, /*< desc="Icon name" >*/
+ GIMP_ICON_TYPE_PIXBUF, /*< desc="Pixbuf" >*/
+ GIMP_ICON_TYPE_IMAGE_FILE /*< desc="Image file" >*/
} GimpIconType;
diff --git a/pdb/enums.pl b/pdb/enums.pl
index 0a1f5d75f5..9b4d50544d 100644
--- a/pdb/enums.pl
+++ b/pdb/enums.pl
@@ -284,11 +284,10 @@ package Gimp::CodeGen::enums;
GimpIconType =>
{ contig => 1,
header => 'libgimpbase/gimpbaseenums.h',
- symbols => [ qw(GIMP_ICON_TYPE_ICON_NAME
- GIMP_ICON_TYPE_INLINE_PIXBUF
+ symbols => [ qw(GIMP_ICON_TYPE_ICON_NAME GIMP_ICON_TYPE_PIXBUF
GIMP_ICON_TYPE_IMAGE_FILE) ],
mapping => { GIMP_ICON_TYPE_ICON_NAME => '0',
- GIMP_ICON_TYPE_INLINE_PIXBUF => '1',
+ GIMP_ICON_TYPE_PIXBUF => '1',
GIMP_ICON_TYPE_IMAGE_FILE => '2' }
},
GimpImageBaseType =>
diff --git a/plug-ins/common/plugin-browser.c b/plug-ins/common/plugin-browser.c
index d6baffcafe..bde6413e52 100644
--- a/plug-ins/common/plugin-browser.c
+++ b/plug-ins/common/plugin-browser.c
@@ -167,8 +167,7 @@ browser_create_procedure (GimpPlugIn *plug_in,
gimp_procedure_set_menu_label (procedure, N_("_Plug-In Browser"));
gimp_procedure_add_menu_path (procedure, "<Image>/Help/Programming");
- gimp_procedure_set_icon (procedure, GIMP_ICON_TYPE_ICON_NAME,
- (const guint8 *) GIMP_ICON_PLUGIN);
+ gimp_procedure_set_icon_name (procedure, GIMP_ICON_PLUGIN);
gimp_procedure_set_documentation (procedure,
N_("Display information about plug-ins"),
diff --git a/plug-ins/goat-exercises/goat-exercise.c b/plug-ins/goat-exercises/goat-exercise.c
index 8f7f66c33a..54f4cb984a 100644
--- a/plug-ins/goat-exercises/goat-exercise.c
+++ b/plug-ins/goat-exercises/goat-exercise.c
@@ -120,8 +120,7 @@ goat_create_procedure (GimpPlugIn *plug_in,
"Øyvind Kolås <pippin gimp org>",
"21 march 2012");
- gimp_procedure_set_icon (procedure, GIMP_ICON_TYPE_ICON_NAME,
- (const guint8 *) GIMP_ICON_GEGL);
+ gimp_procedure_set_icon_name (procedure, GIMP_ICON_GEGL);
gimp_procedure_add_argument (procedure,
g_param_spec_enum ("run-mode",
diff --git a/plug-ins/screenshot/screenshot.c b/plug-ins/screenshot/screenshot.c
index ca2731f65e..8942db2f04 100644
--- a/plug-ins/screenshot/screenshot.c
+++ b/plug-ins/screenshot/screenshot.c
@@ -153,8 +153,9 @@ query (void)
args, return_vals);
gimp_plugin_menu_register (PLUG_IN_PROC, "<Image>/File/Create/Acquire");
- gimp_plugin_icon_register (PLUG_IN_PROC, GIMP_ICON_TYPE_INLINE_PIXBUF,
- screenshot_icon);
+ gimp_plugin_icon_register (PLUG_IN_PROC, GIMP_ICON_TYPE_PIXBUF,
+ gdk_pixbuf_new_from_inline (-1, screenshot_icon,
+ FALSE, NULL));
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]