gimp/app/plug-in/gimppluginprocedure.c

284 lines
6.6 KiB
C
Raw Normal View History

/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* plug-in-proc-def.c
*
* 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 2 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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <string.h>
#include <glib-object.h>
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.
2004-05-19 05:19:43 +08:00
#include <gdk-pixbuf/gdk-pixbuf.h>
#include "libgimpbase/gimpbase.h"
#include "plug-in-types.h"
#include "core/gimp.h"
One more Plug-In cleanup, it's still a mess... 2003-01-17 Michael Natterer <mitch@gimp.org> One more Plug-In cleanup, it's still a mess... * app/plug-in/plug-in-def.[ch]: renamed "gboolean query" field to "needs_query". Added setters for all values. Added g_return_if_fail() stuff to all functions. * app/plug-in/plug-in-proc.[ch]: added plug_in_proc_def_new(). Removed the "gboolean data_only" parameter from plug_in_proc_def_destroy() and renamed it to plug_in_proc_def_free(). Added plug_in_proc_def_get_progname() which handles GIMP_TEMPORARY procedures correctly. * app/plug-in/plug-in-rc.c: use the new stuff above. * app/plug-in/plug-in.[ch]: renamed field "user_data" to "plug_in_def" and added a comment that it is valid only during query() and init(). Use the new APIs above. Pass meaningful locale_domains and help_paths when adding temporary procedures (fixes Scrip-Fu menu translation the right way (TM)). Cleanup. * app/plug-in/plug-ins.[ch]: renamed plug_ins_def_add() to plug_ins_def_add_from_rc(). Renamed plug_ins_proc_def_[add|remove]() to plug_ins_temp_proc_def_[add|remove](). Added "Gimp" parameters to plug_ins_help_path() and plug_ins_locale_domain(). Removed unused pre-1.2 cruft "gimprc_prof_defs" and plug_ins_image_types(). Reverse gimp->load_procs and gimp->save_procs after all procedures are registered. Removed Script-Fu translation hack. Reordered stuff. * app/gui/plug-in-menus.[ch]: changed accordingly. Named all public functions plug_in_menus_*(). Fixed Script-Fu menu translation by using plug_in_proc_def_get_progname(). Cleanup. * app/gui/file-open-menu.c * app/gui/file-save-menu.c: don't g_slist_reverse() gimp->load_procs and gimp->save_procs here. * app/gui/toolbox-menu.c * app/gui/image-menu.c * tools/pdbgen/pdb/help.pdb * tools/pdbgen/pdb/plug_in.pdb: changed accordingly. * app/pdb/help_cmds.c * app/pdb/plug_in_cmds.c: regenerated. Unrelated: * app/gui/image-menu.c * app/widgets/gimpitemfactory.c: s/"tearoff1"/"tearoff"/g. I don't get why the "1" was there. Minor cleanup.
2003-01-18 02:07:37 +08:00
#include "plug-in.h"
#include "plug-ins.h"
#include "plug-in-proc-def.h"
#include "gimp-intl.h"
One more Plug-In cleanup, it's still a mess... 2003-01-17 Michael Natterer <mitch@gimp.org> One more Plug-In cleanup, it's still a mess... * app/plug-in/plug-in-def.[ch]: renamed "gboolean query" field to "needs_query". Added setters for all values. Added g_return_if_fail() stuff to all functions. * app/plug-in/plug-in-proc.[ch]: added plug_in_proc_def_new(). Removed the "gboolean data_only" parameter from plug_in_proc_def_destroy() and renamed it to plug_in_proc_def_free(). Added plug_in_proc_def_get_progname() which handles GIMP_TEMPORARY procedures correctly. * app/plug-in/plug-in-rc.c: use the new stuff above. * app/plug-in/plug-in.[ch]: renamed field "user_data" to "plug_in_def" and added a comment that it is valid only during query() and init(). Use the new APIs above. Pass meaningful locale_domains and help_paths when adding temporary procedures (fixes Scrip-Fu menu translation the right way (TM)). Cleanup. * app/plug-in/plug-ins.[ch]: renamed plug_ins_def_add() to plug_ins_def_add_from_rc(). Renamed plug_ins_proc_def_[add|remove]() to plug_ins_temp_proc_def_[add|remove](). Added "Gimp" parameters to plug_ins_help_path() and plug_ins_locale_domain(). Removed unused pre-1.2 cruft "gimprc_prof_defs" and plug_ins_image_types(). Reverse gimp->load_procs and gimp->save_procs after all procedures are registered. Removed Script-Fu translation hack. Reordered stuff. * app/gui/plug-in-menus.[ch]: changed accordingly. Named all public functions plug_in_menus_*(). Fixed Script-Fu menu translation by using plug_in_proc_def_get_progname(). Cleanup. * app/gui/file-open-menu.c * app/gui/file-save-menu.c: don't g_slist_reverse() gimp->load_procs and gimp->save_procs here. * app/gui/toolbox-menu.c * app/gui/image-menu.c * tools/pdbgen/pdb/help.pdb * tools/pdbgen/pdb/plug_in.pdb: changed accordingly. * app/pdb/help_cmds.c * app/pdb/plug_in_cmds.c: regenerated. Unrelated: * app/gui/image-menu.c * app/widgets/gimpitemfactory.c: s/"tearoff1"/"tearoff"/g. I don't get why the "1" was there. Minor cleanup.
2003-01-18 02:07:37 +08:00
PlugInProcDef *
plug_in_proc_def_new (void)
{
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.
2004-05-19 05:19:43 +08:00
PlugInProcDef *proc_def = g_new0 (PlugInProcDef, 1);
proc_def->icon_data_length = -1;
return proc_def;
}
void
One more Plug-In cleanup, it's still a mess... 2003-01-17 Michael Natterer <mitch@gimp.org> One more Plug-In cleanup, it's still a mess... * app/plug-in/plug-in-def.[ch]: renamed "gboolean query" field to "needs_query". Added setters for all values. Added g_return_if_fail() stuff to all functions. * app/plug-in/plug-in-proc.[ch]: added plug_in_proc_def_new(). Removed the "gboolean data_only" parameter from plug_in_proc_def_destroy() and renamed it to plug_in_proc_def_free(). Added plug_in_proc_def_get_progname() which handles GIMP_TEMPORARY procedures correctly. * app/plug-in/plug-in-rc.c: use the new stuff above. * app/plug-in/plug-in.[ch]: renamed field "user_data" to "plug_in_def" and added a comment that it is valid only during query() and init(). Use the new APIs above. Pass meaningful locale_domains and help_paths when adding temporary procedures (fixes Scrip-Fu menu translation the right way (TM)). Cleanup. * app/plug-in/plug-ins.[ch]: renamed plug_ins_def_add() to plug_ins_def_add_from_rc(). Renamed plug_ins_proc_def_[add|remove]() to plug_ins_temp_proc_def_[add|remove](). Added "Gimp" parameters to plug_ins_help_path() and plug_ins_locale_domain(). Removed unused pre-1.2 cruft "gimprc_prof_defs" and plug_ins_image_types(). Reverse gimp->load_procs and gimp->save_procs after all procedures are registered. Removed Script-Fu translation hack. Reordered stuff. * app/gui/plug-in-menus.[ch]: changed accordingly. Named all public functions plug_in_menus_*(). Fixed Script-Fu menu translation by using plug_in_proc_def_get_progname(). Cleanup. * app/gui/file-open-menu.c * app/gui/file-save-menu.c: don't g_slist_reverse() gimp->load_procs and gimp->save_procs here. * app/gui/toolbox-menu.c * app/gui/image-menu.c * tools/pdbgen/pdb/help.pdb * tools/pdbgen/pdb/plug_in.pdb: changed accordingly. * app/pdb/help_cmds.c * app/pdb/plug_in_cmds.c: regenerated. Unrelated: * app/gui/image-menu.c * app/widgets/gimpitemfactory.c: s/"tearoff1"/"tearoff"/g. I don't get why the "1" was there. Minor cleanup.
2003-01-18 02:07:37 +08:00
plug_in_proc_def_free (PlugInProcDef *proc_def)
{
gint i;
g_return_if_fail (proc_def != NULL);
g_free (proc_def->db_info.name);
g_free (proc_def->db_info.blurb);
g_free (proc_def->db_info.help);
g_free (proc_def->db_info.author);
g_free (proc_def->db_info.copyright);
g_free (proc_def->db_info.date);
for (i = 0; i < proc_def->db_info.num_args; i++)
{
g_free (proc_def->db_info.args[i].name);
g_free (proc_def->db_info.args[i].description);
}
for (i = 0; i < proc_def->db_info.num_values; i++)
{
g_free (proc_def->db_info.values[i].name);
g_free (proc_def->db_info.values[i].description);
}
g_free (proc_def->db_info.args);
g_free (proc_def->db_info.values);
g_free (proc_def->prog);
Changed plug-in menu registration again to allow passing just the menu 2004-05-07 Michael Natterer <mitch@gimp.org> Changed plug-in menu registration again to allow passing just the menu item's label (not the full path) in gimp_install_procedure() and only the path (excluding the item's label) in gimp_plugin_menu_register(). Matches the internal action system better and makes translating the menu paths much easier. (Of yourse it's still possible to use the old syntax for backward compatibility). * app/plug-in/plug-in-proc.[ch]: added "gchar *menu_label". * app/plug-in/plug-in-params.[ch]: added new functions plug_in_param_defs_check() and plug_in_proc_args_check() which check if a procedure's parameters match its menu location (e.g. <Image> needs RUN-MODE, IMAGE, DRAWABLE). * app/plug-in/plug-in-message.c (plug_in_handle_proc_install): if registering an old-style (full) menu_path, use plug_in_param_defs_check(), set proc_def->menu_label otherwise. * tools/pdbgen/pdb/plug_in.pdb (plugin_menu_register): use plug_in_proc_args_check() on the passed menu_path and make sugre old and new style menu registration are not mixed. * app/pdb/plug_in_cmds.c: regenerated. * app/plug-in/plug-in-rc.c: save/restore "menu_label". * app/actions/file-dialog-actions.c * app/actions/plug-in-actions.c * app/menus/plug-in-menus.c: changed action/menu creation accordingly. Some hacks needed to allow both old and new style menu_label/menu_paths. * app/plug-in/plug-in.c * app/widgets/gimpfiledialog.c * app/xcf/xcf.c: changed accordingly. * plug-ins/common/align_layers.c * plug-ins/common/animationplay.c * plug-ins/common/animoptimize.c * plug-ins/common/apply_lens.c * plug-ins/common/autocrop.c * plug-ins/common/autostretch_hsv.c * plug-ins/common/blinds.c * plug-ins/common/blur.c * plug-ins/common/borderaverage.c * plug-ins/common/bumpmap.c * plug-ins/common/c_astretch.c * plug-ins/common/ccanalyze.c * plug-ins/common/channel_mixer.c * plug-ins/common/checkerboard.c * plug-ins/common/color_enhance.c * plug-ins/common/colorify.c * plug-ins/common/colortoalpha.c * plug-ins/common/compose.c * plug-ins/common/convmatrix.c * plug-ins/common/cubism.c * plug-ins/common/curve_bend.c * plug-ins/common/decompose.c * plug-ins/common/deinterlace.c * plug-ins/common/depthmerge.c * plug-ins/common/destripe.c * plug-ins/common/diffraction.c * plug-ins/common/displace.c * plug-ins/common/edge.c * plug-ins/common/emboss.c * plug-ins/common/engrave.c * plug-ins/common/exchange.c * plug-ins/common/film.c * plug-ins/common/flarefx.c * plug-ins/common/fractaltrace.c * plug-ins/common/screenshot.c: ported the first few plug-ins to the new registration scheme.
2004-05-07 08:30:24 +08:00
g_free (proc_def->menu_label);
Enabled multiple menu entries per plug-in procedure: 2004-05-06 Michael Natterer <mitch@gimp.org> Enabled multiple menu entries per plug-in procedure: * app/plug-in/plug-in-proc.[ch]: changed "gchar *menu_path" to "GList *menu_paths". * app/plug-in/plug-in-message.c * app/plug-in/plug-in-rc.c * app/plug-in/plug-in.c * app/plug-in/plug-ins.c * app/menus/menus.c * app/widgets/gimpfiledialog.c * app/xcf/xcf.c: changed accordingly. * app/actions/file-dialog-actions.c * app/actions/plug-in-actions.c: create an action for the first element of proc_def->menu_paths. * app/gui/gui-vtable.c * app/menus/plug-in-menus.[ch]: create proxy widgets for each element of proc_def->menu_paths. * tools/pdbgen/pdb/plug_in.pdb: added new function gimp_plugin_menu_add() which can be called during query() and adds a menu path to a procedure registered by the calling plugin. * app/pdb/internal_procs.c * app/pdb/plug_in_cmds.c * libgimp/gimpplugin_pdb.[ch]: regenerated. * menus/image-menu.xml.in * menus/toolbox-menu.xml.in: added lots of <placeholder>s for logical groups (like Image/Resize, Image/Scale, Image/Crop etc.). Added empty placeholder File/Send for stuff like print and mail. Added an "Acquire" menu under <Image>/File * plug-ins/common/mail.c * plug-ins/print/print.c * plug-ins/common/winprint.c: register under File/Send. * plug-ins/common/screenshot.c * plug-ins/winsnap/winsnap.c: also register under <Image>/File/Acquire. * plug-ins/common/autocrop.c * plug-ins/common/ccanalyze.c * plug-ins/common/colortoalpha.c * plug-ins/common/threshold_alpha.c * plug-ins/common/zealouscrop.c: register additional menu entries under placeholders in the "Image" and "Layer" menus. This is not meant to be final but just a hint to keep in mind when reorganizing the plug-in menus.
2004-05-06 21:51:56 +08:00
g_list_foreach (proc_def->menu_paths, (GFunc) g_free, NULL);
g_list_free (proc_def->menu_paths);
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.
2004-05-19 05:19:43 +08:00
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);
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.
2004-05-19 05:19:43 +08:00
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);
One more Plug-In cleanup, it's still a mess... 2003-01-17 Michael Natterer <mitch@gimp.org> One more Plug-In cleanup, it's still a mess... * app/plug-in/plug-in-def.[ch]: renamed "gboolean query" field to "needs_query". Added setters for all values. Added g_return_if_fail() stuff to all functions. * app/plug-in/plug-in-proc.[ch]: added plug_in_proc_def_new(). Removed the "gboolean data_only" parameter from plug_in_proc_def_destroy() and renamed it to plug_in_proc_def_free(). Added plug_in_proc_def_get_progname() which handles GIMP_TEMPORARY procedures correctly. * app/plug-in/plug-in-rc.c: use the new stuff above. * app/plug-in/plug-in.[ch]: renamed field "user_data" to "plug_in_def" and added a comment that it is valid only during query() and init(). Use the new APIs above. Pass meaningful locale_domains and help_paths when adding temporary procedures (fixes Scrip-Fu menu translation the right way (TM)). Cleanup. * app/plug-in/plug-ins.[ch]: renamed plug_ins_def_add() to plug_ins_def_add_from_rc(). Renamed plug_ins_proc_def_[add|remove]() to plug_ins_temp_proc_def_[add|remove](). Added "Gimp" parameters to plug_ins_help_path() and plug_ins_locale_domain(). Removed unused pre-1.2 cruft "gimprc_prof_defs" and plug_ins_image_types(). Reverse gimp->load_procs and gimp->save_procs after all procedures are registered. Removed Script-Fu translation hack. Reordered stuff. * app/gui/plug-in-menus.[ch]: changed accordingly. Named all public functions plug_in_menus_*(). Fixed Script-Fu menu translation by using plug_in_proc_def_get_progname(). Cleanup. * app/gui/file-open-menu.c * app/gui/file-save-menu.c: don't g_slist_reverse() gimp->load_procs and gimp->save_procs here. * app/gui/toolbox-menu.c * app/gui/image-menu.c * tools/pdbgen/pdb/help.pdb * tools/pdbgen/pdb/plug_in.pdb: changed accordingly. * app/pdb/help_cmds.c * app/pdb/plug_in_cmds.c: regenerated. Unrelated: * app/gui/image-menu.c * app/widgets/gimpitemfactory.c: s/"tearoff1"/"tearoff"/g. I don't get why the "1" was there. Minor cleanup.
2003-01-18 02:07:37 +08:00
g_free (proc_def);
}
const ProcRecord *
plug_in_proc_def_get_proc (const PlugInProcDef *proc_def)
One more Plug-In cleanup, it's still a mess... 2003-01-17 Michael Natterer <mitch@gimp.org> One more Plug-In cleanup, it's still a mess... * app/plug-in/plug-in-def.[ch]: renamed "gboolean query" field to "needs_query". Added setters for all values. Added g_return_if_fail() stuff to all functions. * app/plug-in/plug-in-proc.[ch]: added plug_in_proc_def_new(). Removed the "gboolean data_only" parameter from plug_in_proc_def_destroy() and renamed it to plug_in_proc_def_free(). Added plug_in_proc_def_get_progname() which handles GIMP_TEMPORARY procedures correctly. * app/plug-in/plug-in-rc.c: use the new stuff above. * app/plug-in/plug-in.[ch]: renamed field "user_data" to "plug_in_def" and added a comment that it is valid only during query() and init(). Use the new APIs above. Pass meaningful locale_domains and help_paths when adding temporary procedures (fixes Scrip-Fu menu translation the right way (TM)). Cleanup. * app/plug-in/plug-ins.[ch]: renamed plug_ins_def_add() to plug_ins_def_add_from_rc(). Renamed plug_ins_proc_def_[add|remove]() to plug_ins_temp_proc_def_[add|remove](). Added "Gimp" parameters to plug_ins_help_path() and plug_ins_locale_domain(). Removed unused pre-1.2 cruft "gimprc_prof_defs" and plug_ins_image_types(). Reverse gimp->load_procs and gimp->save_procs after all procedures are registered. Removed Script-Fu translation hack. Reordered stuff. * app/gui/plug-in-menus.[ch]: changed accordingly. Named all public functions plug_in_menus_*(). Fixed Script-Fu menu translation by using plug_in_proc_def_get_progname(). Cleanup. * app/gui/file-open-menu.c * app/gui/file-save-menu.c: don't g_slist_reverse() gimp->load_procs and gimp->save_procs here. * app/gui/toolbox-menu.c * app/gui/image-menu.c * tools/pdbgen/pdb/help.pdb * tools/pdbgen/pdb/plug_in.pdb: changed accordingly. * app/pdb/help_cmds.c * app/pdb/plug_in_cmds.c: regenerated. Unrelated: * app/gui/image-menu.c * app/widgets/gimpitemfactory.c: s/"tearoff1"/"tearoff"/g. I don't get why the "1" was there. Minor cleanup.
2003-01-18 02:07:37 +08:00
{
g_return_val_if_fail (proc_def != NULL, NULL);
return &proc_def->db_info;
}
const gchar *
plug_in_proc_def_get_progname (const PlugInProcDef *proc_def)
One more Plug-In cleanup, it's still a mess... 2003-01-17 Michael Natterer <mitch@gimp.org> One more Plug-In cleanup, it's still a mess... * app/plug-in/plug-in-def.[ch]: renamed "gboolean query" field to "needs_query". Added setters for all values. Added g_return_if_fail() stuff to all functions. * app/plug-in/plug-in-proc.[ch]: added plug_in_proc_def_new(). Removed the "gboolean data_only" parameter from plug_in_proc_def_destroy() and renamed it to plug_in_proc_def_free(). Added plug_in_proc_def_get_progname() which handles GIMP_TEMPORARY procedures correctly. * app/plug-in/plug-in-rc.c: use the new stuff above. * app/plug-in/plug-in.[ch]: renamed field "user_data" to "plug_in_def" and added a comment that it is valid only during query() and init(). Use the new APIs above. Pass meaningful locale_domains and help_paths when adding temporary procedures (fixes Scrip-Fu menu translation the right way (TM)). Cleanup. * app/plug-in/plug-ins.[ch]: renamed plug_ins_def_add() to plug_ins_def_add_from_rc(). Renamed plug_ins_proc_def_[add|remove]() to plug_ins_temp_proc_def_[add|remove](). Added "Gimp" parameters to plug_ins_help_path() and plug_ins_locale_domain(). Removed unused pre-1.2 cruft "gimprc_prof_defs" and plug_ins_image_types(). Reverse gimp->load_procs and gimp->save_procs after all procedures are registered. Removed Script-Fu translation hack. Reordered stuff. * app/gui/plug-in-menus.[ch]: changed accordingly. Named all public functions plug_in_menus_*(). Fixed Script-Fu menu translation by using plug_in_proc_def_get_progname(). Cleanup. * app/gui/file-open-menu.c * app/gui/file-save-menu.c: don't g_slist_reverse() gimp->load_procs and gimp->save_procs here. * app/gui/toolbox-menu.c * app/gui/image-menu.c * tools/pdbgen/pdb/help.pdb * tools/pdbgen/pdb/plug_in.pdb: changed accordingly. * app/pdb/help_cmds.c * app/pdb/plug_in_cmds.c: regenerated. Unrelated: * app/gui/image-menu.c * app/widgets/gimpitemfactory.c: s/"tearoff1"/"tearoff"/g. I don't get why the "1" was there. Minor cleanup.
2003-01-18 02:07:37 +08:00
{
g_return_val_if_fail (proc_def != NULL, NULL);
switch (proc_def->db_info.proc_type)
{
case GIMP_PLUGIN:
case GIMP_EXTENSION:
return proc_def->prog;
case GIMP_TEMPORARY:
return ((PlugIn *) proc_def->db_info.exec_method.temporary.plug_in)->prog;
One more Plug-In cleanup, it's still a mess... 2003-01-17 Michael Natterer <mitch@gimp.org> One more Plug-In cleanup, it's still a mess... * app/plug-in/plug-in-def.[ch]: renamed "gboolean query" field to "needs_query". Added setters for all values. Added g_return_if_fail() stuff to all functions. * app/plug-in/plug-in-proc.[ch]: added plug_in_proc_def_new(). Removed the "gboolean data_only" parameter from plug_in_proc_def_destroy() and renamed it to plug_in_proc_def_free(). Added plug_in_proc_def_get_progname() which handles GIMP_TEMPORARY procedures correctly. * app/plug-in/plug-in-rc.c: use the new stuff above. * app/plug-in/plug-in.[ch]: renamed field "user_data" to "plug_in_def" and added a comment that it is valid only during query() and init(). Use the new APIs above. Pass meaningful locale_domains and help_paths when adding temporary procedures (fixes Scrip-Fu menu translation the right way (TM)). Cleanup. * app/plug-in/plug-ins.[ch]: renamed plug_ins_def_add() to plug_ins_def_add_from_rc(). Renamed plug_ins_proc_def_[add|remove]() to plug_ins_temp_proc_def_[add|remove](). Added "Gimp" parameters to plug_ins_help_path() and plug_ins_locale_domain(). Removed unused pre-1.2 cruft "gimprc_prof_defs" and plug_ins_image_types(). Reverse gimp->load_procs and gimp->save_procs after all procedures are registered. Removed Script-Fu translation hack. Reordered stuff. * app/gui/plug-in-menus.[ch]: changed accordingly. Named all public functions plug_in_menus_*(). Fixed Script-Fu menu translation by using plug_in_proc_def_get_progname(). Cleanup. * app/gui/file-open-menu.c * app/gui/file-save-menu.c: don't g_slist_reverse() gimp->load_procs and gimp->save_procs here. * app/gui/toolbox-menu.c * app/gui/image-menu.c * tools/pdbgen/pdb/help.pdb * tools/pdbgen/pdb/plug_in.pdb: changed accordingly. * app/pdb/help_cmds.c * app/pdb/plug_in_cmds.c: regenerated. Unrelated: * app/gui/image-menu.c * app/widgets/gimpitemfactory.c: s/"tearoff1"/"tearoff"/g. I don't get why the "1" was there. Minor cleanup.
2003-01-18 02:07:37 +08:00
default:
break;
}
return NULL;
}
gchar *
plug_in_proc_def_get_label (const PlugInProcDef *proc_def,
const gchar *locale_domain)
{
const gchar *path;
gchar *stripped;
gchar *ellipses;
gchar *label;
g_return_val_if_fail (proc_def != NULL, NULL);
if (proc_def->menu_label)
path = dgettext (locale_domain, proc_def->menu_label);
else if (proc_def->menu_paths)
path = dgettext (locale_domain, proc_def->menu_paths->data);
else
return NULL;
stripped = gimp_strip_uline (path);
if (proc_def->menu_label)
label = g_strdup (stripped);
else
label = g_path_get_basename (stripped);
g_free (stripped);
ellipses = strstr (label, "...");
if (ellipses && ellipses == (label + strlen (label) - 3))
*ellipses = '\0';
return label;
}
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.
2004-05-19 05:19:43 +08:00
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)
{
gchar *help_id;
gchar *p;
g_return_val_if_fail (proc_def != NULL, NULL);
help_id = g_strdup (proc_def->db_info.name);
for (p = help_id; p && *p; p++)
if (*p == '_')
*p = '-';
Completed the new help infrastructure. Needs some polishing but basically 2003-08-28 Michael Natterer <mitch@gimp.org> Completed the new help infrastructure. Needs some polishing but basically works as proposed: * tools/pdbgen/pdb/plug_in.pdb: changed gimp_plugin_help_register() to take a "domain_name" (which is the XML namespace) and a "domain_uri" (which is the root of the plug-in's help pages). * tools/pdbgen/pdb/help.pdb: changed gimp_help() to take help_id instead of a non-UTF-8 help_path. * app/plug-in/plug-in-def.[ch] * app/plug-in/plug-in-proc.[ch] * app/plug-in/plug-in-rc.c * app/plug-in/plug-ins.[ch]: remember the plug-ins' help_domain and help_uri instead of just help_path. Changed all plug-in APIs to reflect this change. * app/widgets/gimphelp.[ch]: on helpbrowser startup, pass it the whole list of help domains. The actual help request is now made using the browser's temporary procedure. * app/core/gimp.h * app/gui/file-open-menu.c * app/gui/file-save-menu.c * app/gui/plug-in-menus.[ch] * app/widgets/gimpitemfactory.c: changed accordingly. * app/pdb/help_cmds.c * app/pdb/plug_in_cmds.c * libgimp/gimphelp_pdb.[ch] * libgimp/gimpplugin_pdb.[ch]: regenerated. Changed the help broser to load the pages according to the new system: - moved the browser window stuff to dialog.[ch] - moved help domain handling to domain.[ch] - added gimp-help.xml parsing to domain.c - tons of cleanup * plug-ins/helpbrowser/Makefile.am * plug-ins/helpbrowser/dialog.[ch] * plug-ins/helpbrowser/domain.[ch]: new files. * plug-ins/helpbrowser/helpbrowser.c: chopped.
2003-08-29 02:49:11 +08:00
if (help_domain)
{
Completed the new help infrastructure. Needs some polishing but basically 2003-08-28 Michael Natterer <mitch@gimp.org> Completed the new help infrastructure. Needs some polishing but basically works as proposed: * tools/pdbgen/pdb/plug_in.pdb: changed gimp_plugin_help_register() to take a "domain_name" (which is the XML namespace) and a "domain_uri" (which is the root of the plug-in's help pages). * tools/pdbgen/pdb/help.pdb: changed gimp_help() to take help_id instead of a non-UTF-8 help_path. * app/plug-in/plug-in-def.[ch] * app/plug-in/plug-in-proc.[ch] * app/plug-in/plug-in-rc.c * app/plug-in/plug-ins.[ch]: remember the plug-ins' help_domain and help_uri instead of just help_path. Changed all plug-in APIs to reflect this change. * app/widgets/gimphelp.[ch]: on helpbrowser startup, pass it the whole list of help domains. The actual help request is now made using the browser's temporary procedure. * app/core/gimp.h * app/gui/file-open-menu.c * app/gui/file-save-menu.c * app/gui/plug-in-menus.[ch] * app/widgets/gimpitemfactory.c: changed accordingly. * app/pdb/help_cmds.c * app/pdb/plug_in_cmds.c * libgimp/gimphelp_pdb.[ch] * libgimp/gimpplugin_pdb.[ch]: regenerated. Changed the help broser to load the pages according to the new system: - moved the browser window stuff to dialog.[ch] - moved help domain handling to domain.[ch] - added gimp-help.xml parsing to domain.c - tons of cleanup * plug-ins/helpbrowser/Makefile.am * plug-ins/helpbrowser/dialog.[ch] * plug-ins/helpbrowser/domain.[ch]: new files. * plug-ins/helpbrowser/helpbrowser.c: chopped.
2003-08-29 02:49:11 +08:00
gchar *domain_and_id;
Completed the new help infrastructure. Needs some polishing but basically 2003-08-28 Michael Natterer <mitch@gimp.org> Completed the new help infrastructure. Needs some polishing but basically works as proposed: * tools/pdbgen/pdb/plug_in.pdb: changed gimp_plugin_help_register() to take a "domain_name" (which is the XML namespace) and a "domain_uri" (which is the root of the plug-in's help pages). * tools/pdbgen/pdb/help.pdb: changed gimp_help() to take help_id instead of a non-UTF-8 help_path. * app/plug-in/plug-in-def.[ch] * app/plug-in/plug-in-proc.[ch] * app/plug-in/plug-in-rc.c * app/plug-in/plug-ins.[ch]: remember the plug-ins' help_domain and help_uri instead of just help_path. Changed all plug-in APIs to reflect this change. * app/widgets/gimphelp.[ch]: on helpbrowser startup, pass it the whole list of help domains. The actual help request is now made using the browser's temporary procedure. * app/core/gimp.h * app/gui/file-open-menu.c * app/gui/file-save-menu.c * app/gui/plug-in-menus.[ch] * app/widgets/gimpitemfactory.c: changed accordingly. * app/pdb/help_cmds.c * app/pdb/plug_in_cmds.c * libgimp/gimphelp_pdb.[ch] * libgimp/gimpplugin_pdb.[ch]: regenerated. Changed the help broser to load the pages according to the new system: - moved the browser window stuff to dialog.[ch] - moved help domain handling to domain.[ch] - added gimp-help.xml parsing to domain.c - tons of cleanup * plug-ins/helpbrowser/Makefile.am * plug-ins/helpbrowser/dialog.[ch] * plug-ins/helpbrowser/domain.[ch]: new files. * plug-ins/helpbrowser/helpbrowser.c: chopped.
2003-08-29 02:49:11 +08:00
domain_and_id = g_strconcat (help_domain, "?", help_id, NULL);
g_free (help_id);
Completed the new help infrastructure. Needs some polishing but basically 2003-08-28 Michael Natterer <mitch@gimp.org> Completed the new help infrastructure. Needs some polishing but basically works as proposed: * tools/pdbgen/pdb/plug_in.pdb: changed gimp_plugin_help_register() to take a "domain_name" (which is the XML namespace) and a "domain_uri" (which is the root of the plug-in's help pages). * tools/pdbgen/pdb/help.pdb: changed gimp_help() to take help_id instead of a non-UTF-8 help_path. * app/plug-in/plug-in-def.[ch] * app/plug-in/plug-in-proc.[ch] * app/plug-in/plug-in-rc.c * app/plug-in/plug-ins.[ch]: remember the plug-ins' help_domain and help_uri instead of just help_path. Changed all plug-in APIs to reflect this change. * app/widgets/gimphelp.[ch]: on helpbrowser startup, pass it the whole list of help domains. The actual help request is now made using the browser's temporary procedure. * app/core/gimp.h * app/gui/file-open-menu.c * app/gui/file-save-menu.c * app/gui/plug-in-menus.[ch] * app/widgets/gimpitemfactory.c: changed accordingly. * app/pdb/help_cmds.c * app/pdb/plug_in_cmds.c * libgimp/gimphelp_pdb.[ch] * libgimp/gimpplugin_pdb.[ch]: regenerated. Changed the help broser to load the pages according to the new system: - moved the browser window stuff to dialog.[ch] - moved help domain handling to domain.[ch] - added gimp-help.xml parsing to domain.c - tons of cleanup * plug-ins/helpbrowser/Makefile.am * plug-ins/helpbrowser/dialog.[ch] * plug-ins/helpbrowser/domain.[ch]: new files. * plug-ins/helpbrowser/helpbrowser.c: chopped.
2003-08-29 02:49:11 +08:00
return domain_and_id;
}
return help_id;
}
gboolean
plug_in_proc_def_get_sensitive (const PlugInProcDef *proc_def,
GimpImageType image_type)
{
gboolean sensitive;
g_return_val_if_fail (proc_def != NULL, FALSE);
switch (image_type)
{
case GIMP_RGB_IMAGE:
sensitive = proc_def->image_types_val & PLUG_IN_RGB_IMAGE;
break;
case GIMP_RGBA_IMAGE:
sensitive = proc_def->image_types_val & PLUG_IN_RGBA_IMAGE;
break;
case GIMP_GRAY_IMAGE:
sensitive = proc_def->image_types_val & PLUG_IN_GRAY_IMAGE;
break;
case GIMP_GRAYA_IMAGE:
sensitive = proc_def->image_types_val & PLUG_IN_GRAYA_IMAGE;
break;
case GIMP_INDEXED_IMAGE:
sensitive = proc_def->image_types_val & PLUG_IN_INDEXED_IMAGE;
break;
case GIMP_INDEXEDA_IMAGE:
sensitive = proc_def->image_types_val & PLUG_IN_INDEXEDA_IMAGE;
break;
default:
sensitive = FALSE;
break;
}
return sensitive ? TRUE : FALSE;
}