Commit 3fb934b2 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

Allow plug-ins to register menu icons. Fixes bug #120500.

2004-05-18  Michael Natterer  <mitch@gimp.org>

	Allow plug-ins to register menu icons. Fixes bug #120500.

	* app/core/core-enums.[ch]: added enum GimpIconType which can
	be one of { STOCK_ID, IMAGE_FILE, INLINE_PIXBUF }.

	* app/config/gimpconfigwriter.[ch] (gimp_config_writer_data)
	* app/config/gimpscanner.[ch] (gimp_scanner_parse_data): new
	functions which write/parse raw binary data. Needed for storing
	inline pixbufs in pluginrc.

	* app/config/gimpconfigwriter.[ch] (gimp_config_writer_identifier):
	new function which writes out an unquoted and unescaped string.

	* app/plug-in/plug-in-proc.[ch] (struct PlugInProcDef): added
	new members "icon_type", "icon_data_length" and "icon_data".
	Reordered members so file_proc specific stuff is at the end.

	(plug_in_proc_def_get_stock_id)
	(plug_in_proc_def_get_pixbuf): new functions to access the
	procedure's icon.

	* app/plug-in/plug-in-rc.c: save/restore the registered icons.

	* app/actions/file-dialog-actions.c
	* app/actions/plug-in-actions.c: set the action's stock ID from
	the procedure's stock ID.

	* app/widgets/gimppluginaction.c
	(gimp_plug_in_action_connect_proxy): if the procedure provides a
	pixbuf, set it as icon for the menu item.

	* app/menus/file-dialog-menu.[ch]
	* app/menus/file-open-menu.c
	* app/menus/file-save-menu.c
	* app/xcf/xcf.c: changed accordingly.

	* tools/pdbgen/pdb/plug_in.pdb (plugin_icon_register): new PDB
	function which can be called during query().

	* tools/pdbgen/enums.pl
	* app/pdb/internal_procs.c
	* app/pdb/plug_in_cmds.c
	* libgimp/gimpenums.h
	* libgimp/gimpplugin_pdb.c
	* libgimp/gimpplugin_pdb.h
	* plug-ins/pygimp/gimpenums.py
	* plug-ins/script-fu/script-fu-constants.c: regenerated.

	* plug-ins/common/plugindetails.c
	* plug-ins/common/uniteditor.c
	* plug-ins/print/print.c: register stock_id icons.

	* plug-ins/common/screenshot.c: register an inline_pixbuf icon for
	testing purposes (used emblem-camera.png from gnome-icon-theme).

	* app/actions/dialogs-actions.c
	* app/actions/file-actions.c: unrelated: added some more icons
	to menu items.
parent 5784e3ee
2004-05-18 Michael Natterer <mitch@gimp.org>
Allow plug-ins to register menu icons. Fixes bug #120500.
* app/core/core-enums.[ch]: added enum GimpIconType which can
be one of { STOCK_ID, IMAGE_FILE, INLINE_PIXBUF }.
* app/config/gimpconfigwriter.[ch] (gimp_config_writer_data)
* app/config/gimpscanner.[ch] (gimp_scanner_parse_data): new
functions which write/parse raw binary data. Needed for storing
inline pixbufs in pluginrc.
* app/config/gimpconfigwriter.[ch] (gimp_config_writer_identifier):
new function which writes out an unquoted and unescaped string.
* app/plug-in/plug-in-proc.[ch] (struct PlugInProcDef): added
new members "icon_type", "icon_data_length" and "icon_data".
Reordered members so file_proc specific stuff is at the end.
(plug_in_proc_def_get_stock_id)
(plug_in_proc_def_get_pixbuf): new functions to access the
procedure's icon.
* app/plug-in/plug-in-rc.c: save/restore the registered icons.
* app/actions/file-dialog-actions.c
* app/actions/plug-in-actions.c: set the action's stock ID from
the procedure's stock ID.
* app/widgets/gimppluginaction.c
(gimp_plug_in_action_connect_proxy): if the procedure provides a
pixbuf, set it as icon for the menu item.
* app/menus/file-dialog-menu.[ch]
* app/menus/file-open-menu.c
* app/menus/file-save-menu.c
* app/xcf/xcf.c: changed accordingly.
* tools/pdbgen/pdb/plug_in.pdb (plugin_icon_register): new PDB
function which can be called during query().
* tools/pdbgen/enums.pl
* app/pdb/internal_procs.c
* app/pdb/plug_in_cmds.c
* libgimp/gimpenums.h
* libgimp/gimpplugin_pdb.c
* libgimp/gimpplugin_pdb.h
* plug-ins/pygimp/gimpenums.py
* plug-ins/script-fu/script-fu-constants.c: regenerated.
* plug-ins/common/plugindetails.c
* plug-ins/common/uniteditor.c
* plug-ins/print/print.c: register stock_id icons.
* plug-ins/common/screenshot.c: register an inline_pixbuf icon for
testing purposes (used emblem-camera.png from gnome-icon-theme).
* app/actions/dialogs-actions.c
* app/actions/file-actions.c: unrelated: added some more icons
to menu items.
2004-05-18 Maurits Rijk <m.rijk@chello.nl>
* plug-ins/common/sel_gauss.c: HIGified, fixed indendation, speed
......
......@@ -181,7 +181,7 @@ static GimpStringActionEntry dialogs_toplevel_actions[] =
"gimp-preferences-dialog",
GIMP_HELP_PREFS_DIALOG },
{ "dialogs-module-manager", NULL,
{ "dialogs-module-manager", GTK_STOCK_EXECUTE,
N_("_Module Manager"), NULL, NULL,
"gimp-module-manager-dialog",
GIMP_HELP_MODULE_DIALOG },
......
......@@ -56,9 +56,13 @@ static void file_actions_last_opened_reorder (GimpContainer *container,
static GimpActionEntry file_actions[] =
{
{ "file-menu", NULL, N_("_File") },
{ "file-open-recent-menu", NULL, N_("Open _Recent") },
{ "file-acquire-menu", NULL, N_("_Acquire") },
{ "file-menu", NULL, N_("_File") },
{ "file-open-recent-menu", GTK_STOCK_OPEN,
N_("Open _Recent"), "", NULL },
{ "file-acquire-menu", NULL,
N_("_Acquire"), NULL, NULL },
{ "file-new", GTK_STOCK_NEW,
N_("_New..."), "<control>N", NULL,
......
......@@ -48,7 +48,6 @@ file_dialog_actions_setup (GimpActionGroup *group,
for (list = file_procs; list; list = g_slist_next (list))
{
PlugInProcDef *file_proc = list->data;
const gchar *stock_id = NULL;
gchar *help_id;
GimpPlugInActionEntry entry;
gchar *label;
......@@ -61,8 +60,7 @@ file_dialog_actions_setup (GimpActionGroup *group,
if (is_xcf)
{
stock_id = GIMP_STOCK_WILBER;
help_id = g_strdup (GIMP_HELP_FILE_SAVE_XCF);
help_id = g_strdup (GIMP_HELP_FILE_SAVE_XCF);
}
else
{
......@@ -84,7 +82,7 @@ file_dialog_actions_setup (GimpActionGroup *group,
label = strrchr (file_proc->menu_paths->data, '/') + 1;
entry.name = file_proc->db_info.name;
entry.stock_id = stock_id;
entry.stock_id = plug_in_proc_def_get_stock_id (file_proc);
entry.label = label;
entry.accelerator = NULL;
entry.tooltip = NULL;
......
......@@ -283,7 +283,7 @@ plug_in_actions_add_proc (GimpActionGroup *group,
}
entry.name = proc_def->db_info.name;
entry.stock_id = NULL;
entry.stock_id = plug_in_proc_def_get_stock_id (proc_def);
entry.label = label_translated;
entry.accelerator = NULL;
entry.tooltip = NULL;
......
......@@ -319,6 +319,54 @@ gimp_config_writer_string (GimpConfigWriter *writer,
gimp_config_string_append_escaped (writer->buffer, string);
}
/**
* gimp_config_writer_identifier:
* @writer: a #GimpConfigWriter
* @string: a NUL-terminated string
*
* Writes an identifier to @writer. The @string is *not* quoted and special
* characters are *not* escaped.
**/
void
gimp_config_writer_identifier (GimpConfigWriter *writer,
const gchar *identifier)
{
g_return_if_fail (writer != NULL);
g_return_if_fail (identifier != NULL);
if (writer->error)
return;
g_string_append_printf (writer->buffer, " %s", identifier);
}
void
gimp_config_writer_data (GimpConfigWriter *writer,
gint length,
const guint8 *data)
{
gint i;
g_return_if_fail (writer != NULL);
g_return_if_fail (length > 0);
g_return_if_fail (data != NULL);
if (writer->error)
return;
g_string_append (writer->buffer, " \"");
for (i = 0; i < length; i++)
{
if (g_ascii_isalpha (data[i]))
g_string_append_c (writer->buffer, data[i]);
else
g_string_append_printf (writer->buffer, "\\%o", data[i]);
}
g_string_append (writer->buffer, "\"");
}
/**
* gimp_config_writer_revert:
* @writer: a #GimpConfigWriter
......
......@@ -41,8 +41,13 @@ void gimp_config_writer_print (GimpConfigWriter *writer,
void gimp_config_writer_printf (GimpConfigWriter *writer,
const gchar *format,
...);
void gimp_config_writer_identifier (GimpConfigWriter *writer,
const gchar *identifier);
void gimp_config_writer_string (GimpConfigWriter *writer,
const gchar *string);
void gimp_config_writer_data (GimpConfigWriter *writer,
gint length,
const guint8 *data);
void gimp_config_writer_comment (GimpConfigWriter *writer,
const gchar *comment);
void gimp_config_writer_linefeed (GimpConfigWriter *writer);
......
......@@ -248,6 +248,24 @@ gimp_scanner_parse_string_no_validate (GScanner *scanner,
return TRUE;
}
gboolean
gimp_scanner_parse_data (GScanner *scanner,
gint length,
guint8 **dest)
{
if (g_scanner_peek_next_token (scanner) != G_TOKEN_STRING)
return FALSE;
g_scanner_get_next_token (scanner);
if (scanner->value.v_string)
*dest = g_memdup (scanner->value.v_string, length);
else
*dest = NULL;
return TRUE;
}
gboolean
gimp_scanner_parse_int (GScanner *scanner,
gint *dest)
......
......@@ -39,6 +39,9 @@ gboolean gimp_scanner_parse_string (GScanner *scanner,
gchar **dest);
gboolean gimp_scanner_parse_string_no_validate (GScanner *scanner,
gchar **dest);
gboolean gimp_scanner_parse_data (GScanner *scanner,
gint length,
guint8 **dest);
gboolean gimp_scanner_parse_int (GScanner *scanner,
gint *dest);
gboolean gimp_scanner_parse_float (GScanner *scanner,
......
......@@ -343,6 +343,26 @@ gimp_dash_preset_get_type (void)
}
static const GEnumValue gimp_icon_type_enum_values[] =
{
{ GIMP_ICON_TYPE_STOCK_ID, N_("Stock ID"), "stock-id" },
{ GIMP_ICON_TYPE_INLINE_PIXBUF, N_("Inline Pixbuf"), "inline-pixbuf" },
{ GIMP_ICON_TYPE_IMAGE_FILE, N_("Image File"), "image-file" },
{ 0, NULL, NULL }
};
GType
gimp_icon_type_get_type (void)
{
static GType enum_type = 0;
if (!enum_type)
enum_type = g_enum_register_static ("GimpIconType", gimp_icon_type_enum_values);
return enum_type;
}
static const GEnumValue gimp_image_base_type_enum_values[] =
{
{ GIMP_RGB, N_("RGB Color"), "rgb" },
......
......@@ -251,6 +251,18 @@ typedef enum /*< pdb-skip >*/
} GimpDashPreset;
#define GIMP_TYPE_ICON_TYPE (gimp_icon_type_get_type ())
GType gimp_icon_type_get_type (void) G_GNUC_CONST;
typedef enum
{
GIMP_ICON_TYPE_STOCK_ID, /*< desc="Stock ID" >*/
GIMP_ICON_TYPE_INLINE_PIXBUF, /*< desc="Inline Pixbuf" >*/
GIMP_ICON_TYPE_IMAGE_FILE /*< desc="Image File" >*/
} GimpIconType;
#define GIMP_TYPE_IMAGE_BASE_TYPE (gimp_image_base_type_get_type ())
GType gimp_image_base_type_get_type (void) G_GNUC_CONST;
......
......@@ -34,8 +34,7 @@
void
file_dialog_menu_setup (GimpUIManager *manager,
const gchar *ui_path,
GSList *file_procs,
const gchar *xcf_proc_name)
GSList *file_procs)
{
GSList *list;
guint merge_id;
......@@ -46,12 +45,15 @@ file_dialog_menu_setup (GimpUIManager *manager,
{
PlugInProcDef *file_proc = list->data;
gchar *path;
gchar *p;
if (! file_proc->menu_paths)
continue;
if (! strcmp (file_proc->db_info.name, xcf_proc_name))
path = g_strdup_printf ("%s/%s", ui_path, "Internal");
p = strchr (file_proc->menu_paths->data, '/');
if (p)
path = g_strdup_printf ("%s%s", ui_path, p);
else
path = g_strdup (ui_path);
......
......@@ -22,8 +22,7 @@
void file_dialog_menu_setup (GimpUIManager *manager,
const gchar *ui_path,
GSList *file_procs,
const gchar *xcf_proc_name);
GSList *file_procs);
#endif /* __FILE_DIALOG_MENU_H__ */
......@@ -34,7 +34,5 @@ void
file_open_menu_setup (GimpUIManager *manager,
const gchar *ui_path)
{
file_dialog_menu_setup (manager, ui_path,
manager->gimp->load_procs,
"gimp_xcf_load");
file_dialog_menu_setup (manager, ui_path, manager->gimp->load_procs);
}
......@@ -34,7 +34,5 @@ void
file_save_menu_setup (GimpUIManager *manager,
const gchar *ui_path)
{
file_dialog_menu_setup (manager, ui_path,
manager->gimp->save_procs,
"gimp_xcf_save");
file_dialog_menu_setup (manager, ui_path, manager->gimp->save_procs);
}
......@@ -21,6 +21,7 @@
#include <string.h>
#include <glib-object.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include "libgimpbase/gimpbase.h"
......@@ -38,7 +39,11 @@
PlugInProcDef *
plug_in_proc_def_new (void)
{
return g_new0 (PlugInProcDef, 1);
PlugInProcDef *proc_def = g_new0 (PlugInProcDef, 1);
proc_def->icon_data_length = -1;
return proc_def;
}
void
......@@ -76,11 +81,22 @@ plug_in_proc_def_free (PlugInProcDef *proc_def)
g_list_foreach (proc_def->menu_paths, (GFunc) g_free, NULL);
g_list_free (proc_def->menu_paths);
g_free (proc_def->icon_data);
g_free (proc_def->image_types);
g_free (proc_def->extensions);
g_free (proc_def->prefixes);
g_free (proc_def->magics);
g_free (proc_def->mime_type);
g_free (proc_def->image_types);
g_slist_foreach (proc_def->extensions_list, (GFunc) g_free, NULL);
g_slist_free (proc_def->extensions_list);
g_slist_foreach (proc_def->prefixes_list, (GFunc) g_free, NULL);
g_slist_free (proc_def->prefixes_list);
g_slist_foreach (proc_def->magics_list, (GFunc) g_free, NULL);
g_slist_free (proc_def->magics_list);
g_free (proc_def);
}
......@@ -149,6 +165,57 @@ plug_in_proc_def_get_label (const PlugInProcDef *proc_def,
return label;
}
const gchar *
plug_in_proc_def_get_stock_id (const PlugInProcDef *proc_def)
{
g_return_val_if_fail (proc_def != NULL, NULL);
switch (proc_def->icon_type)
{
case GIMP_ICON_TYPE_STOCK_ID:
return proc_def->icon_data;
default:
return NULL;
}
}
GdkPixbuf *
plug_in_proc_def_get_pixbuf (const PlugInProcDef *proc_def)
{
GdkPixbuf *pixbuf = NULL;
GError *error = NULL;
g_return_val_if_fail (proc_def != NULL, NULL);
switch (proc_def->icon_type)
{
case GIMP_ICON_TYPE_INLINE_PIXBUF:
pixbuf = gdk_pixbuf_new_from_inline (proc_def->icon_data_length,
proc_def->icon_data, TRUE, &error);
if (! pixbuf)
{
g_printerr (error->message);
g_clear_error (&error);
}
break;
case GIMP_ICON_TYPE_IMAGE_FILE:
pixbuf = gdk_pixbuf_new_from_file (proc_def->icon_data, &error);
if (! pixbuf)
{
g_printerr (error->message);
g_clear_error (&error);
}
break;
default:
break;
}
return pixbuf;
}
gchar *
plug_in_proc_def_get_help_id (const PlugInProcDef *proc_def,
const gchar *help_domain)
......
......@@ -21,26 +21,34 @@
#include <time.h> /* time_t */
#include <gdk-pixbuf/gdk-pixbuf.h>
#include "pdb/procedural_db.h" /* ProcRecord */
struct _PlugInProcDef
{
/* common members */
gchar *prog;
gchar *menu_label;
GList *menu_paths;
GimpIconType icon_type;
gint icon_data_length;
gchar *icon_data;
gchar *image_types;
PlugInImageType image_types_val;
time_t mtime;
gboolean installed_during_init;
ProcRecord db_info;
/* file proc specific members */
gchar *extensions;
gchar *prefixes;
gchar *magics;
gchar *mime_type;
gchar *image_types;
PlugInImageType image_types_val;
ProcRecord db_info;
GSList *extensions_list;
GSList *prefixes_list;
GSList *magics_list;
time_t mtime;
gboolean installed_during_init;
};
......@@ -51,6 +59,8 @@ const ProcRecord * plug_in_proc_def_get_proc (const PlugInProcDef *proc_def)
const gchar * plug_in_proc_def_get_progname (const PlugInProcDef *proc_def);
gchar * plug_in_proc_def_get_label (const PlugInProcDef *proc_def,
const gchar *locale_domain);
const gchar * plug_in_proc_def_get_stock_id (const PlugInProcDef *proc_def);
GdkPixbuf * plug_in_proc_def_get_pixbuf (const PlugInProcDef *proc_def);
gchar * plug_in_proc_def_get_help_id (const PlugInProcDef *proc_def,
const gchar *help_domain);
......
......@@ -68,7 +68,7 @@ void register_transform_tools_procs (Gimp *gimp);
void register_undo_procs (Gimp *gimp);
void register_unit_procs (Gimp *gimp);
/* 349 procedures registered total */
/* 350 procedures registered total */
void
internal_procs_init (Gimp *gimp,
......@@ -92,82 +92,82 @@ internal_procs_init (Gimp *gimp,
(* status_callback) (NULL, _("Convert"), 0.103);
register_convert_procs (gimp);
(* status_callback) (NULL, _("Display procedures"), 0.112);
(* status_callback) (NULL, _("Display procedures"), 0.111);
register_display_procs (gimp);
(* status_callback) (NULL, _("Drawable procedures"), 0.123);
register_drawable_procs (gimp);
(* status_callback) (NULL, _("Edit procedures"), 0.215);
(* status_callback) (NULL, _("Edit procedures"), 0.214);
register_edit_procs (gimp);
(* status_callback) (NULL, _("File Operations"), 0.238);
(* status_callback) (NULL, _("File Operations"), 0.237);
register_fileops_procs (gimp);
(* status_callback) (NULL, _("Floating selections"), 0.264);
(* status_callback) (NULL, _("Floating selections"), 0.263);
register_floating_sel_procs (gimp);
(* status_callback) (NULL, _("Font UI"), 0.281);
(* status_callback) (NULL, _("Font UI"), 0.28);
register_font_select_procs (gimp);
(* status_callback) (NULL, _("Fonts"), 0.289);
register_fonts_procs (gimp);
(* status_callback) (NULL, _("Gimprc procedures"), 0.295);
(* status_callback) (NULL, _("Gimprc procedures"), 0.294);
register_gimprc_procs (gimp);
(* status_callback) (NULL, _("Gradient UI"), 0.312);
(* status_callback) (NULL, _("Gradient UI"), 0.311);
register_gradient_select_procs (gimp);
(* status_callback) (NULL, _("Gradients"), 0.321);
(* status_callback) (NULL, _("Gradients"), 0.32);
register_gradients_procs (gimp);
(* status_callback) (NULL, _("Guide procedures"), 0.341);
(* status_callback) (NULL, _("Guide procedures"), 0.34);
register_guides_procs (gimp);
(* status_callback) (NULL, _("Help procedures"), 0.358);
(* status_callback) (NULL, _("Help procedures"), 0.357);
register_help_procs (gimp);
(* status_callback) (NULL, _("Image"), 0.361);
(* status_callback) (NULL, _("Image"), 0.36);
register_image_procs (gimp);
(* status_callback) (NULL, _("Layer"), 0.536);
(* status_callback) (NULL, _("Layer"), 0.534);
register_layer_procs (gimp);
(* status_callback) (NULL, _("Message procedures"), 0.61);
(* status_callback) (NULL, _("Message procedures"), 0.609);
register_message_procs (gimp);
(* status_callback) (NULL, _("Miscellaneous"), 0.619);
(* status_callback) (NULL, _("Miscellaneous"), 0.617);
register_misc_procs (gimp);
(* status_callback) (NULL, _("Paint Tool procedures"), 0.625);
(* status_callback) (NULL, _("Paint Tool procedures"), 0.623);
register_paint_tools_procs (gimp);
(* status_callback) (NULL, _("Palette"), 0.668);
(* status_callback) (NULL, _("Palette"), 0.666);
register_palette_procs (gimp);
(* status_callback) (NULL, _("Palette UI"), 0.685);
(* status_callback) (NULL, _("Palette UI"), 0.683);
register_palette_select_procs (gimp);
(* status_callback) (NULL, _("Palettes"), 0.693);
(* status_callback) (NULL, _("Palettes"), 0.691);
register_palettes_procs (gimp);
(* status_callback) (NULL, _("Parasite procedures"), 0.708);
(* status_callback) (NULL, _("Parasite procedures"), 0.706);
register_parasite_procs (gimp);
(* status_callback) (NULL, _("Paths"), 0.742);
(* status_callback) (NULL, _("Paths"), 0.74);
register_paths_procs (gimp);
(* status_callback) (NULL, _("Pattern UI"), 0.785);
(* status_callback) (NULL, _("Pattern UI"), 0.783);
register_pattern_select_procs (gimp);
(* status_callback) (NULL, _("Patterns"), 0.794);
(* status_callback) (NULL, _("Patterns"), 0.791);
register_patterns_procs (gimp);
(* status_callback) (NULL, _("Plug-in"), 0.808);
(* status_callback) (NULL, _("Plug-in"), 0.806);
register_plug_in_procs (gimp);
(* status_callback) (NULL, _("Procedural database"), 0.825);
(* status_callback) (NULL, _("Procedural database"), 0.826);
register_procedural_db_procs (gimp);
(* status_callback) (NULL, _("Image mask"), 0.851);
......@@ -179,7 +179,7 @@ internal_procs_init (Gimp *gimp,
(* status_callback) (NULL, _("Text procedures"), 0.917);
register_text_tool_procs (gimp);
(* status_callback) (NULL, _("Transform Tool procedures"), 0.928);
(* status_callback) (NULL, _("Transform Tool procedures"), 0.929);
register_transform_tools_procs (gimp);
(* status_callback) (NULL, _("Undo"), 0.946);
......
......@@ -53,6 +53,7 @@ static ProcRecord plugins_query_proc;
static ProcRecord plugin_domain_register_proc;
static ProcRecord plugin_help_register_proc;
static ProcRecord plugin_menu_register_proc;
static ProcRecord plugin_icon_register_proc;
void
register_plug_in_procs (Gimp *gimp)
......@@ -63,6 +64,7 @@ register_plug_in_procs (Gimp *gimp)
procedural_db_register (gimp, &plugin_domain_register_proc);
procedural_db_register (gimp, &plugin_help_register_proc);
procedural_db_register (gimp, &plugin_menu_register_proc);
procedural_db_register (gimp, &plugin_icon_register_proc);
}
static int
......@@ -625,3 +627,116 @@ static ProcRecord plugin_menu_register_proc =
NULL,
{ { plugin_menu_register_invoker } }
};
static Argument *
plugin_icon_register_invoker (Gimp *gimp,
GimpContext *context,
Argument *args)
{
gboolean success = TRUE;
gchar *procedure_name;
gint32 icon_type;
gint32 icon_data_length;
guint8 *icon_data;
procedure_name = (gchar *) args[0].value.pdb_pointer;
if (procedure_name == NULL || !g_utf8_validate (procedure_name, -1, NULL))
success = FALSE;
icon_type = args[1].value.pdb_int;
if (icon_type < GIMP_ICON_TYPE_STOCK_ID || icon_type > GIMP_ICON_TYPE_IMAGE_FILE)
success = FALSE;
icon_data_length = args[2].value.pdb_int;
icon_data = (guint8 *) args[3].value.pdb_pointer;
if (success)
{
if (gimp->current_plug_in && gimp->current_plug_in->query)
{
GSList *list;
for (list = gimp->current_plug_in->plug_in_def->proc_defs;
list;
list = g_slist_next (list))
{
PlugInProcDef *proc_def = list->data;
if (! strcmp (procedure_name, proc_def->db_info.name))
{
if (proc_def->icon_data)
{
g_free (proc_def->icon_data);
proc_def->icon_data_length = -1;
proc_def->icon_data = NULL;
}
proc_def->icon_type = icon_type;
switch (proc_def->icon_type)
{
case GIMP_ICON_TYPE_STOCK_ID:
case GIMP_ICON_TYPE_IMAGE_FILE:
proc_def->icon_data_length = -1;
proc_def->icon_data = g_strdup (icon_data);
break;
case GIMP_ICON_TYPE_INLINE_PIXBUF:
proc_def->icon_data_length = icon_data_length;
proc_def->icon_data = g_memdup (icon_data,
icon_data_length);
break;
}
break;
}
}
if (! list)
success = FALSE;
}
}
return procedural_db_return_args (&plugin_icon_register_proc, success);
}
static ProcArg plugin_icon_register_inargs[] =
{
{
GIMP_PDB_STRING,
"procedure_name",
"The procedure for which to install the icon"
},
{
GIMP_PDB_INT32,
"icon_type",