From 540aa5ce669297f4747699824d9a9267755bb7ff Mon Sep 17 00:00:00 2001 From: Michael Natterer Date: Tue, 18 May 2004 22:54:41 +0000 Subject: [PATCH] made plugin_icon_register() an underscore-prefixed function which needs to 2004-05-19 Michael Natterer * tools/pdbgen/pdb/plug_in.pdb: made plugin_icon_register() an underscore-prefixed function which needs to be wrapped. * libgimp/gimpplugin_pdb.[ch]: regenerated. * libgimp/Makefile.am * libgimp/gimp.h * libgimp/gimpplugin.[ch]: new files containing gimp_plugin_icon_register() which has no "icon_data_length" parameter and determines it from the passed icon data. * libgimp/gimp.def: added gimp_plugin_icon_register. * plug-ins/common/plugindetails.c * plug-ins/common/screenshot.c * plug-ins/common/uniteditor.c * plug-ins/print/print.c: don't pass the icon_data_length. --- ChangeLog | 20 ++++++++++ libgimp/Makefile.am | 3 ++ libgimp/gimp.def | 1 + libgimp/gimp.h | 3 +- libgimp/gimpplugin.c | 58 +++++++++++++++++++++++++++++ libgimp/gimpplugin.h | 37 ++++++++++++++++++ libgimp/gimpplugin_pdb.c | 10 ++--- libgimp/gimpplugin_pdb.h | 2 +- plug-ins/common/plugin-browser.c | 4 +- plug-ins/common/plugindetails.c | 4 +- plug-ins/common/screenshot.c | 3 +- plug-ins/common/uniteditor.c | 4 +- plug-ins/dbbrowser/plugin-browser.c | 4 +- plug-ins/print/print.c | 4 +- tools/pdbgen/pdb/plug_in.pdb | 2 +- 15 files changed, 134 insertions(+), 25 deletions(-) create mode 100644 libgimp/gimpplugin.c create mode 100644 libgimp/gimpplugin.h diff --git a/ChangeLog b/ChangeLog index 0298b19a6e..3cc17bc289 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,23 @@ +2004-05-19 Michael Natterer + + * tools/pdbgen/pdb/plug_in.pdb: made plugin_icon_register() an + underscore-prefixed function which needs to be wrapped. + + * libgimp/gimpplugin_pdb.[ch]: regenerated. + + * libgimp/Makefile.am + * libgimp/gimp.h + * libgimp/gimpplugin.[ch]: new files containing + gimp_plugin_icon_register() which has no "icon_data_length" + parameter and determines it from the passed icon data. + + * libgimp/gimp.def: added gimp_plugin_icon_register. + + * plug-ins/common/plugindetails.c + * plug-ins/common/screenshot.c + * plug-ins/common/uniteditor.c + * plug-ins/print/print.c: don't pass the icon_data_length. + 2004-05-18 Sven Neumann * plug-ins/common/checkerboard.c diff --git a/libgimp/Makefile.am b/libgimp/Makefile.am index f505c7bf5e..5ee6cc1a51 100644 --- a/libgimp/Makefile.am +++ b/libgimp/Makefile.am @@ -179,6 +179,8 @@ libgimp_2_0_la_SOURCES = \ gimppixelfetcher.h \ gimppixelrgn.c \ gimppixelrgn.h \ + gimpplugin.c \ + gimpplugin.h \ gimpproceduraldb.c \ gimpproceduraldb.h \ gimpregioniterator.c \ @@ -231,6 +233,7 @@ gimpinclude_HEADERS = \ gimppatternselect.h \ gimppixelfetcher.h \ gimppixelrgn.h \ + gimpplugin.h \ gimpproceduraldb.h \ gimpregioniterator.h \ gimpselection.h \ diff --git a/libgimp/gimp.def b/libgimp/gimp.def index 6600f797ab..f0a7614fae 100644 --- a/libgimp/gimp.def +++ b/libgimp/gimp.def @@ -334,6 +334,7 @@ EXPORTS gimp_pixel_rgns_register2 gimp_plugin_domain_register gimp_plugin_help_register + gimp_plugin_icon_register gimp_plugin_menu_register gimp_posterize gimp_procedural_db_dump diff --git a/libgimp/gimp.h b/libgimp/gimp.h index 8ea08eceda..4109a5e54b 100644 --- a/libgimp/gimp.h +++ b/libgimp/gimp.h @@ -41,8 +41,9 @@ #include #include #include -#include +#include #include +#include #include #include diff --git a/libgimp/gimpplugin.c b/libgimp/gimpplugin.c new file mode 100644 index 0000000000..8edf0deea0 --- /dev/null +++ b/libgimp/gimpplugin.c @@ -0,0 +1,58 @@ +/* LIBGIMP - The GIMP Library + * Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball + * + * gimpplugin.c + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include "config.h" + +#include + +#include "gimp.h" + +gboolean +gimp_plugin_icon_register (const gchar *procedure_name, + GimpIconType icon_type, + const guint8 *icon_data) +{ + gint icon_data_length; + + g_return_val_if_fail (procedure_name != NULL, FALSE); + g_return_val_if_fail (icon_data != NULL, FALSE); + + switch (icon_type) + { + case GIMP_ICON_TYPE_STOCK_ID: + case GIMP_ICON_TYPE_IMAGE_FILE: + icon_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); + + icon_data_length = g_ntohl (*((gint32 *) (icon_data + 4))); + break; + + default: + g_return_val_if_reached (FALSE); + } + + return _gimp_plugin_icon_register (procedure_name, + icon_type, icon_data_length, icon_data); +} diff --git a/libgimp/gimpplugin.h b/libgimp/gimpplugin.h new file mode 100644 index 0000000000..58aba1602d --- /dev/null +++ b/libgimp/gimpplugin.h @@ -0,0 +1,37 @@ +/* LIBGIMP - The GIMP Library + * Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball + * + * gimpplugin.h + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef __GIMP_PLUG_IN_H__ +#define __GIMP_PLUG_IN_H__ + +G_BEGIN_DECLS + +/* For information look into the C source or the html documentation */ + + +gboolean gimp_plugin_icon_register (const gchar *procedure_name, + GimpIconType icon_type, + const guint8 *icon_data); + + +G_END_DECLS + +#endif /* __GIMP_PLUG_IN_H__ */ diff --git a/libgimp/gimpplugin_pdb.c b/libgimp/gimpplugin_pdb.c index 64c949c12f..b3d68584ed 100644 --- a/libgimp/gimpplugin_pdb.c +++ b/libgimp/gimpplugin_pdb.c @@ -196,7 +196,7 @@ gimp_plugin_menu_register (const gchar *procedure_name, } /** - * gimp_plugin_icon_register: + * _gimp_plugin_icon_register: * @procedure_name: The procedure for which to install the icon. * @icon_type: The type of the icon. * @icon_data_length: The length of 'icon_data'. @@ -211,10 +211,10 @@ gimp_plugin_menu_register (const gchar *procedure_name, * Since: GIMP 2.2 */ gboolean -gimp_plugin_icon_register (const gchar *procedure_name, - GimpIconType icon_type, - gint icon_data_length, - const guint8 *icon_data) +_gimp_plugin_icon_register (const gchar *procedure_name, + GimpIconType icon_type, + gint icon_data_length, + const guint8 *icon_data) { GimpParam *return_vals; gint nreturn_vals; diff --git a/libgimp/gimpplugin_pdb.h b/libgimp/gimpplugin_pdb.h index a3ccbc0f31..05cadbb0bc 100644 --- a/libgimp/gimpplugin_pdb.h +++ b/libgimp/gimpplugin_pdb.h @@ -37,7 +37,7 @@ gboolean gimp_plugin_help_register (const gchar *domain_name, const gchar *domain_uri); gboolean gimp_plugin_menu_register (const gchar *procedure_name, const gchar *menu_path); -gboolean gimp_plugin_icon_register (const gchar *procedure_name, +gboolean _gimp_plugin_icon_register (const gchar *procedure_name, GimpIconType icon_type, gint icon_data_length, const guint8 *icon_data); diff --git a/plug-ins/common/plugin-browser.c b/plug-ins/common/plugin-browser.c index ca40906d86..1c8bfd5633 100644 --- a/plug-ins/common/plugin-browser.c +++ b/plug-ins/common/plugin-browser.c @@ -159,9 +159,7 @@ query (void) gimp_plugin_menu_register ("plug_in_plug_in_details", N_("/Xtns/Extensions")); gimp_plugin_icon_register ("plug_in_plug_in_details", - GIMP_ICON_TYPE_STOCK_ID, - strlen (GIMP_STOCK_PLUGIN) + 1, - GIMP_STOCK_PLUGIN); + GIMP_ICON_TYPE_STOCK_ID, GIMP_STOCK_PLUGIN); } static void diff --git a/plug-ins/common/plugindetails.c b/plug-ins/common/plugindetails.c index ca40906d86..1c8bfd5633 100644 --- a/plug-ins/common/plugindetails.c +++ b/plug-ins/common/plugindetails.c @@ -159,9 +159,7 @@ query (void) gimp_plugin_menu_register ("plug_in_plug_in_details", N_("/Xtns/Extensions")); gimp_plugin_icon_register ("plug_in_plug_in_details", - GIMP_ICON_TYPE_STOCK_ID, - strlen (GIMP_STOCK_PLUGIN) + 1, - GIMP_STOCK_PLUGIN); + GIMP_ICON_TYPE_STOCK_ID, GIMP_STOCK_PLUGIN); } static void diff --git a/plug-ins/common/screenshot.c b/plug-ins/common/screenshot.c index a00f3fba5c..a94d66db54 100644 --- a/plug-ins/common/screenshot.c +++ b/plug-ins/common/screenshot.c @@ -265,8 +265,7 @@ query (void) /* gimp_plugin_menu_register (PLUG_IN_NAME, N_("/File/Acquire")); */ gimp_plugin_icon_register (PLUG_IN_NAME, - GIMP_ICON_TYPE_INLINE_PIXBUF, - sizeof (screenshot_icon) - 1, screenshot_icon); + GIMP_ICON_TYPE_INLINE_PIXBUF, screenshot_icon); } static void diff --git a/plug-ins/common/uniteditor.c b/plug-ins/common/uniteditor.c index fc23b4fec4..7e08675ebe 100644 --- a/plug-ins/common/uniteditor.c +++ b/plug-ins/common/uniteditor.c @@ -123,9 +123,7 @@ query (void) gimp_plugin_menu_register ("plug_in_unit_editor", N_("/Xtns/Extensions")); gimp_plugin_icon_register ("plug_in_unit_editor", - GIMP_ICON_TYPE_STOCK_ID, - strlen (GIMP_STOCK_TOOL_MEASURE) + 1, - GIMP_STOCK_TOOL_MEASURE); + GIMP_ICON_TYPE_STOCK_ID, GIMP_STOCK_TOOL_MEASURE); } static void diff --git a/plug-ins/dbbrowser/plugin-browser.c b/plug-ins/dbbrowser/plugin-browser.c index ca40906d86..1c8bfd5633 100644 --- a/plug-ins/dbbrowser/plugin-browser.c +++ b/plug-ins/dbbrowser/plugin-browser.c @@ -159,9 +159,7 @@ query (void) gimp_plugin_menu_register ("plug_in_plug_in_details", N_("/Xtns/Extensions")); gimp_plugin_icon_register ("plug_in_plug_in_details", - GIMP_ICON_TYPE_STOCK_ID, - strlen (GIMP_STOCK_PLUGIN) + 1, - GIMP_STOCK_PLUGIN); + GIMP_ICON_TYPE_STOCK_ID, GIMP_STOCK_PLUGIN); } static void diff --git a/plug-ins/print/print.c b/plug-ins/print/print.c index d86dff0434..3861e60818 100644 --- a/plug-ins/print/print.c +++ b/plug-ins/print/print.c @@ -170,9 +170,7 @@ query (void) gimp_plugin_menu_register ("file_print_gimp", N_("/File/Send")); gimp_plugin_icon_register ("file_print_gimp", - GIMP_ICON_TYPE_STOCK_ID, - strlen (GTK_STOCK_PRINT) + 1, - GTK_STOCK_PRINT); + GIMP_ICON_TYPE_STOCK_ID, GTK_STOCK_PRINT); } diff --git a/tools/pdbgen/pdb/plug_in.pdb b/tools/pdbgen/pdb/plug_in.pdb index 924d95043a..d7f946ad04 100644 --- a/tools/pdbgen/pdb/plug_in.pdb +++ b/tools/pdbgen/pdb/plug_in.pdb @@ -401,7 +401,7 @@ HELP $since = '2.2'; @inargs = ( - { name => 'procedure_name', type => 'string', + { name => 'procedure_name', type => 'string', wrap => 1, desc => 'The procedure for which to install the icon' }, { name => 'icon_type', type => 'enum GimpIconType', desc => 'The type of the icon' },