gimp/app/pdb/gimpprocedure.c

790 lines
27 KiB
C
Raw Normal View History

/* GIMP - The GNU Image Manipulation Program
1997-11-25 06:05:25 +08:00
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software: you can redistribute it and/or modify
1997-11-25 06:05:25 +08:00
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
1997-11-25 06:05:25 +08:00
* (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, see <http://www.gnu.org/licenses/>.
1997-11-25 06:05:25 +08:00
*/
#include "config.h"
1997-11-25 06:05:25 +08:00
#include <stdarg.h>
app/Makefile.am app/channel_pvt.h app/drawable_pvt.h app/gdisplayF.h 2000-12-29 Michael Natterer <mitch@gimp.org> * app/Makefile.am * app/channel_pvt.h * app/drawable_pvt.h * app/gdisplayF.h * app/gimpdrawableP.h * app/gimpimageP.h * app/layer_pvt.h * app/toolsF.h: removed these files. * app/apptypes.h * tools/pdbgen/enums.pl: added tons of opaque typedefs and enums. * tools/pdbgen/pdb/brush_select.pdb * tools/pdbgen/pdb/brushes.pdb * tools/pdbgen/pdb/channel.pdb * tools/pdbgen/pdb/color.pdb * tools/pdbgen/pdb/convert.pdb * tools/pdbgen/pdb/display.pdb * tools/pdbgen/pdb/drawable.pdb * tools/pdbgen/pdb/fileops.pdb * tools/pdbgen/pdb/gradient_select.pdb * tools/pdbgen/pdb/gradients.pdb * tools/pdbgen/pdb/help.pdb * tools/pdbgen/pdb/image.pdb * tools/pdbgen/pdb/layer.pdb * tools/pdbgen/pdb/pattern_select.pdb * tools/pdbgen/pdb/patterns.pdb * tools/pdbgen/pdb/selection.pdb * tools/pdbgen/pdb/tools.pdb * app/*: chainsaw #include cleanup: - Never (never!!) include stuff in header files except where we need access to structures' contents (like derived objects). - Added prototypes and proper formating in many files. - The #include order in *all* *.c files is as follows: #include "config.h" #include <system stuff> #include <gtk/gtk.h> #include "apptypes.h" #include "gimp stuff" #include "libgimp stuff" #include "libgimp/gimpintl.h" By following this scheme we can easily see a file's dependencies from it's #include's and can grep for the inclusion to find out where a file is used. * tools/pdbgen/app.pl: changed to follow the include scheme above. * libgimp/Makefile.am * libgimp/gimpuitypes.h: new file, included from libgimp/gimpui.h and from app/apptypes.h. * libgimp/gimpcolorbutton.[ch] * libgimp/gimpdialog.[ch] * libgimp/gimphelpui.[ch] * libgimp/gimpparasite.[ch] * libgimp/gimppatheditor.[ch] * libgimp/gimpprotocol.c * libgimp/gimpquerybox.[ch] * libgimp/gimpsizeentry.[ch] * libgimp/gimptypes.h * libgimp/gimpui.h * libgimp/gimpunit.h * libgimp/gimpunitmenu.[ch] * libgimp/gimpwidgets.[ch]: changed accordingly. * plug-ins/FractalExplorer/Dialogs.c * plug-ins/gdyntext/message_window.c * plug-ins/imagemap/imap_default_dialog.c * plug-ins/imagemap/imap_file.c: these files used to include "libgimp/gimpui.h" without including "libgimp/gimp.h". This is no longer possible because the libgimpui headers don't inlcude "libgimp/gimpunit.h" any more.
2000-12-29 23:22:01 +08:00
#include <sys/types.h>
#include <gegl.h>
badly chopped into the new files below. Pass around much more "PlugIn" and 2002-03-20 Michael Natterer <mitch@gimp.org> * app/plug-in/plug-in.[ch]: badly chopped into the new files below. Pass around much more "PlugIn" and "Gimp" pointers instead of using "current_plug_in" and "the_gimp". Needs much more hacking though... :( * app/plug-in/Makefile.am * app/plug-in/plug-in-def.[ch] * app/plug-in/plug-in-params.[ch] * app/plug-in/plug-in-progress.[ch] * app/plug-in/plug-ins.[ch]: new files. * app/gui/Makefile.am * app/gui/plug-in-commands.[ch] * app/gui/plug-in-menus.[ch]: ditto. * app/plug-in/plug-in-rc.c * app/plug-in/plug-in-types.h: changed accordingly. * app/pdb/procedural_db.c: changed procedural_db_destroy_args() so it can be used from plug_in_args_destroy(). Fixed a parasite memory leak (or introduced a new SEGV, we'll see...). * app/display/Makefile.am: another "truly ugly hack" until the plug-in menu stuff is chopped even more... * app/gui/commands.[ch]: removed filters_repeat_cmd_callback() here, it is now in plug-in-commands.[ch]. * app/widgets/gimpitemfactory.[ch]: removed all gimp_menu_item_*() hacks. We have a GimpItemFactory available in most cases we used to call this functions, and can use gimp_item_factors_from_path() in all other cases. The item factory stuff needs more work anyway... * app/app_procs.c * app/gimphelp.c * app/display/gimpdisplayshell.c * app/gui/file-dialog-utils.c * app/gui/file-open-dialog.[ch] * app/gui/file-save-dialog.[ch] * app/gui/gui.c * app/gui/menus.c * app/gui/paths-dialog.c * app/xcf/xcf.c * tools/pdbgen/pdb/fileops.pdb * tools/pdbgen/pdb/help.pdb * tools/pdbgen/pdb/plug_in.pdb: changed accordingly (includes, renamed functions and gimp_menu_item_*() removal). * app/pdb/fileops_cmds.c * app/pdb/help_cmds.c * app/pdb/plug_in_cmds.c: regenerated.
2002-03-21 01:46:13 +08:00
#include "libgimpbase/gimpbase.h"
added app/display/ and app/plug-in/. Empty for now except for the types 2001-08-17 Michael Natterer <mitch@gimp.org> * configure.in: added app/display/ and app/plug-in/. Empty for now except for the types files. * app/Makefile.am * app/appenums.h * app/apptypes.h: removed. * app/display/Makefile.am * app/display/display-types.h * app/plug-in/Makefile.am * app/plug-in/plug-in-types.h * app/gui/Makefile.am * app/gui/gui-types.h * app/pdb/Makefile.am * app/pdb/pdb-types.h: new files for typedefs. * app/appenv.h: added MessageHandlerType and StackTraceMode here. * app/undo_types.h: moved undo struct typedefs here. * app/tools/tools-types.h * app/core/core-types.h: added some enums and Tattoo here (renamed to GimpTattoo). * app/gdisplay.h: temp_hack: #include "display/display-types.h" * app/gimphelp.c: s/gtk_idle_add/g_idle_add/ * app/gimprc.c: don't use "gimprc" in token handlers but the passed "val1p" and "val2p". * app/image_map.[ch]: cleanup in preparation of making a GObject out of it. * app/base/pixel-region.[ch]: no need to pass the PixelRegionIterator around as void pointer. * app/core/gimp.[ch] * app/core/gimpcontext.[ch] * app/core/gimptoolinfo.[ch] * app/tools/tool_manager.c * app/widgets/gimpdnd.c: added the standard_tool_info to the Gimp object. * app/batch.c * app/file-open.c * app/file-save.c * app/file-utils.c * app/interface.c * app/main.c * app/path.[ch] * app/pathP.h * app/plug_in.h * app/core/gimpdrawable.[ch] * app/core/gimpimage-mask.c * app/core/gimpimage.[ch] * app/core/gimplayer.c * app/gui/color-area.c * app/gui/color-notebook.c * app/gui/colormap-dialog.c * app/gui/dialogs-commands.c * app/gui/dialogs-constructors.c * app/gui/error-console-dialog.c * app/gui/gradient-editor.c * app/gui/gradient-select.c * app/gui/indicator-area.c * app/gui/info-dialog.c * app/gui/palette-editor.c * app/gui/palette-select.c * app/gui/pattern-select.c * app/gui/session.c * app/gui/splash.c * app/gui/view-commands.c * app/tools/gimpinktool-blob.c * app/widgets/gimpcolorpanel.c * app/widgets/gimpdockbook.c * app/widgets/gimppreview.c * app/xcf/xcf-load.c * app/xcf/xcf-save.c * app/xcf/xcf.c: changed accordingly: s/Tattoo/GimpTattoo/, include the new types files, include <glib-object.h> instead of >gtk/gtk.h>. Bad hacks to get rid of SELECTION_OFF and friends in core/ (will be replaced ba a signal soon). * tools/pdbgen/Makefile.am: changed list of headers scanned for enums accordingly. * app/pdb/procedural_db.c * tools/pdbgen/app.pl * tools/pdbgen/pdb/channel.pdb * tools/pdbgen/pdb/display.pdb * tools/pdbgen/pdb/gradient_select.pdb * tools/pdbgen/pdb/image.pdb * tools/pdbgen/pdb/layer.pdb * tools/pdbgen/pdb/pattern_select.pdb: same fixes as above, added hacks to ensure that all foo-types.h files are included before all other gimp internal includes, include "pdb-types.h" unconditionally. * tools/pdbgen/enums.pl * app/pdb/*_cmds.c: regenerated.
2001-08-17 22:27:31 +08:00
#include "pdb-types.h"
app/core/Makefile.am app/core/core-types.h added an "application object" 2001-07-04 Michael Natterer <mitch@gimp.org> * app/core/Makefile.am * app/core/core-types.h * app/core/gimp.[ch]: added an "application object" called Gimp. Currently, it contains the image list, the clipboard, the data factories, the procedural hashtable and the tool info list. It's the toplevel object of the core object system. Finally, creating a Gimp object will return a standalone gimp core engine instance with no other global states/variables involved. * app/app_procs.[ch]: allocate a "Gimp" instance called "the_gimp" :) Removed stuff which is now done by the "Gimp" object. Merged gimp_init() into app_init() because gimp_init() is taken now. * app/context_manager.[ch]: removed stuff done by "Gimp". * app/batch.[ch] * app/gimage.[ch] * app/xcf/xcf-load.[ch] * app/xcf/xcf.[ch] * app/core/gimpedit.[ch] * app/tools/tool_manager.[ch]: pass around an additional "Gimp" argument. * app/pdb/procedural_db.[ch]: pass a "Gimp" pointer as first parameter to all internal procedures and to all procedural_db_* functions. * app/core/gimpcontext.[ch] * app/core/gimpimage.[ch]: added a "Gimp" pointer to the structs. * app/devices.c * app/errors.c * app/file-open.c * app/file-save.c * app/gimphelp.c * app/gimpunit.c * app/image_new.c * app/main.c * app/nav_window.c * app/plug_in.c * app/base/base.c * app/core/gimpdatafactory.c * app/core/gimpimage-duplicate.c * app/core/gimpimage-mask.c * app/core/gimptoolinfo.[ch] * app/gui/brush-select.c * app/gui/convert-dialog.c * app/gui/dialogs-constructors.c * app/gui/edit-commands.c * app/gui/file-open-dialog.c * app/gui/file-save-dialog.c * app/gui/gradient-editor.c * app/gui/gradient-select.c * app/gui/gui.c * app/gui/image-commands.c * app/gui/info-window.c * app/gui/menus.c * app/gui/palette-editor.c * app/gui/palette-import-dialog.c * app/gui/palette-select.c * app/gui/paths-dialog.c * app/gui/pattern-select.c * app/gui/preferences-dialog.c * app/gui/test-commands.c * app/gui/toolbox.c * app/gui/tools-commands.c * app/tools/gimpbezierselecttool.c * app/tools/gimpbucketfilltool.c * app/tools/gimppainttool.h * app/tools/gimptexttool.c * app/tools/gimptransformtool.h * app/widgets/gimpbufferview.c * app/widgets/gimpcontainerview-utils.c * app/widgets/gimpcursor.c * app/widgets/gimpdnd.c * app/widgets/gimpimagedock.c: changed accordingly. Cleaned up lots of includes. Many files still access the global "the_gimp" variable exported by app_procs.h. * tools/pdbgen/app.pl * tools/pdbgen/pdb/brush_select.pdb * tools/pdbgen/pdb/brushes.pdb * tools/pdbgen/pdb/convert.pdb * tools/pdbgen/pdb/edit.pdb * tools/pdbgen/pdb/fileops.pdb * tools/pdbgen/pdb/gradient_select.pdb * tools/pdbgen/pdb/gradients.pdb * tools/pdbgen/pdb/image.pdb * tools/pdbgen/pdb/palette.pdb * tools/pdbgen/pdb/pattern_select.pdb * tools/pdbgen/pdb/patterns.pdb * tools/pdbgen/pdb/procedural_db.pdb: changed accordingly. Don't use "the_gimp" here because all procedures get passed a "Gimp" pointer now. * app/pdb/*: regenerated.
2001-07-05 03:31:35 +08:00
#include "core/gimp.h"
#include "core/gimp-utils.h"
#include "core/gimpchannel.h"
#include "core/gimplayer.h"
#include "core/gimpparamspecs.h"
Redid the whole internal progress stuff: don't pass around 2004-08-10 Michael Natterer <mitch@gimp.org> Redid the whole internal progress stuff: don't pass around progress_callback and progress_data; instead, provide a pointer to a GimpProgressInterface which can be implemented by a variety of backends. Addresses (but not yet fixes) bugs #6010, #97266 and #135185. * app/display/Makefile.am * app/display/gimpprogress.[ch]: removed the old progress hack. * app/core/Makefile.am * app/core/core-types.h * app/core/gimpprogress.[ch]: implement GimpProgressInterface. * app/widgets/Makefile.am * app/widgets/widgets-types.h * app/widgets/gimpprogressdialog.[ch]: the standalone progress dialog as widget implementing GimpProgressInterface. * app/display/gimpdisplay.c * app/display/gimpstatusbar.[ch] * app/widgets/gimpfiledialog.[ch] * app/widgets/gimpthumbbox.[ch]: added GimpProgressInterface implementation to these classes. * app/core/gimp-gui.[ch] * app/gui/gui-vtable.c: replaced the old progress vtable entries by two new to create and destroy a GimpProgressDialog in case no other progress is available. * app/pdb/procedural_db.[ch] * app/plug-in/plug-in-run.[ch] * tools/pdbgen/app.pl: pass a GimpProgress to all PDB wrappers and all plug-ins. * app/plug-in/plug-in.[ch] * app/plug-in/plug-ins.c * app/plug-in/plug-in-message.c * app/plug-in/plug-in-progress.c: handle the case there the plug-in was crated with a progress as well as the case where it wasn't. * app/app_procs.c * app/batch.c * app/xcf/xcf.c * app/file/file-open.[ch] * app/file/file-save.[ch] * app/widgets/gimphelp.c * app/widgets/gimpbrushselect.c * app/widgets/gimpfontselect.c * app/widgets/gimpgradientselect.c * app/widgets/gimppaletteselect.c * app/widgets/gimppatternselect.c: changed accordingly. * app/core/gimpimagefile.[ch] * app/display/gimpdisplayshell-dnd.c * app/gui/file-open-dialog.c * app/gui/file-open-location-dialog.c * app/gui/file-save-dialog.c * app/widgets/gimplayertreeview.c * app/widgets/gimptoolbox-dnd.c: pass a GimpProgress to all file related functions. Embed the progress in the file dialog where possible. * app/core/gimpdrawable-blend.[ch] * app/core/gimpdrawable-transform.[ch] * app/core/gimpimage-convert.[ch] * app/core/gimpimage-flip.[ch] * app/core/gimpimage-resize.[ch] * app/core/gimpimage-rotate.[ch] * app/core/gimpimage-scale.[ch] * app/core/gimpitem-linked.[ch] * app/core/gimpitem.[ch] * app/core/gimpchannel.c * app/core/gimpdrawable.c * app/core/gimplayer.c * app/core/gimpselection.c * app/vectors/gimpvectors.c: replaced callback/data by GimpProgress. * app/tools/gimpblendtool.c * app/tools/gimptransformtool.c * app/gui/convert-dialog.c * app/actions/documents-commands.c * app/actions/file-commands.c * app/actions/image-commands.c * app/actions/layers-commands.c * app/actions/plug-in-commands.c * app/actions/vectors-commands.c * tools/pdbgen/pdb/convert.pdb * tools/pdbgen/pdb/edit.pdb * tools/pdbgen/pdb/image.pdb * tools/pdbgen/pdb/layer.pdb: changed callers accordingly. * app/pdb/*_cmds.c: regenerated.
2004-08-11 02:47:21 +08:00
#include "core/gimpprogress.h"
app/core/Makefile.am app/core/core-types.h added an "application object" 2001-07-04 Michael Natterer <mitch@gimp.org> * app/core/Makefile.am * app/core/core-types.h * app/core/gimp.[ch]: added an "application object" called Gimp. Currently, it contains the image list, the clipboard, the data factories, the procedural hashtable and the tool info list. It's the toplevel object of the core object system. Finally, creating a Gimp object will return a standalone gimp core engine instance with no other global states/variables involved. * app/app_procs.[ch]: allocate a "Gimp" instance called "the_gimp" :) Removed stuff which is now done by the "Gimp" object. Merged gimp_init() into app_init() because gimp_init() is taken now. * app/context_manager.[ch]: removed stuff done by "Gimp". * app/batch.[ch] * app/gimage.[ch] * app/xcf/xcf-load.[ch] * app/xcf/xcf.[ch] * app/core/gimpedit.[ch] * app/tools/tool_manager.[ch]: pass around an additional "Gimp" argument. * app/pdb/procedural_db.[ch]: pass a "Gimp" pointer as first parameter to all internal procedures and to all procedural_db_* functions. * app/core/gimpcontext.[ch] * app/core/gimpimage.[ch]: added a "Gimp" pointer to the structs. * app/devices.c * app/errors.c * app/file-open.c * app/file-save.c * app/gimphelp.c * app/gimpunit.c * app/image_new.c * app/main.c * app/nav_window.c * app/plug_in.c * app/base/base.c * app/core/gimpdatafactory.c * app/core/gimpimage-duplicate.c * app/core/gimpimage-mask.c * app/core/gimptoolinfo.[ch] * app/gui/brush-select.c * app/gui/convert-dialog.c * app/gui/dialogs-constructors.c * app/gui/edit-commands.c * app/gui/file-open-dialog.c * app/gui/file-save-dialog.c * app/gui/gradient-editor.c * app/gui/gradient-select.c * app/gui/gui.c * app/gui/image-commands.c * app/gui/info-window.c * app/gui/menus.c * app/gui/palette-editor.c * app/gui/palette-import-dialog.c * app/gui/palette-select.c * app/gui/paths-dialog.c * app/gui/pattern-select.c * app/gui/preferences-dialog.c * app/gui/test-commands.c * app/gui/toolbox.c * app/gui/tools-commands.c * app/tools/gimpbezierselecttool.c * app/tools/gimpbucketfilltool.c * app/tools/gimppainttool.h * app/tools/gimptexttool.c * app/tools/gimptransformtool.h * app/widgets/gimpbufferview.c * app/widgets/gimpcontainerview-utils.c * app/widgets/gimpcursor.c * app/widgets/gimpdnd.c * app/widgets/gimpimagedock.c: changed accordingly. Cleaned up lots of includes. Many files still access the global "the_gimp" variable exported by app_procs.h. * tools/pdbgen/app.pl * tools/pdbgen/pdb/brush_select.pdb * tools/pdbgen/pdb/brushes.pdb * tools/pdbgen/pdb/convert.pdb * tools/pdbgen/pdb/edit.pdb * tools/pdbgen/pdb/fileops.pdb * tools/pdbgen/pdb/gradient_select.pdb * tools/pdbgen/pdb/gradients.pdb * tools/pdbgen/pdb/image.pdb * tools/pdbgen/pdb/palette.pdb * tools/pdbgen/pdb/pattern_select.pdb * tools/pdbgen/pdb/patterns.pdb * tools/pdbgen/pdb/procedural_db.pdb: changed accordingly. Don't use "the_gimp" here because all procedures get passed a "Gimp" pointer now. * app/pdb/*: regenerated.
2001-07-05 03:31:35 +08:00
#include "vectors/gimpvectors.h"
#include "gimppdbcontext.h"
#include "gimppdberror.h"
#include "gimpprocedure.h"
#include "gimp-intl.h"
static void gimp_procedure_finalize (GObject *object);
static gint64 gimp_procedure_get_memsize (GimpObject *object,
gint64 *gui_size);
static GimpValueArray * gimp_procedure_real_execute (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
GimpValueArray *args,
GError **error);
static void gimp_procedure_real_execute_async (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
GimpValueArray *args,
GimpObject *display);
static void gimp_procedure_free_strings (GimpProcedure *procedure);
static gboolean gimp_procedure_validate_args (GimpProcedure *procedure,
GParamSpec **param_specs,
gint n_param_specs,
GimpValueArray *args,
gboolean return_vals,
GError **error);
G_DEFINE_TYPE (GimpProcedure, gimp_procedure, GIMP_TYPE_OBJECT)
#define parent_class gimp_procedure_parent_class
static void
gimp_procedure_class_init (GimpProcedureClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GimpObjectClass *gimp_object_class = GIMP_OBJECT_CLASS (klass);
object_class->finalize = gimp_procedure_finalize;
gimp_object_class->get_memsize = gimp_procedure_get_memsize;
klass->execute = gimp_procedure_real_execute;
klass->execute_async = gimp_procedure_real_execute_async;
}
static void
gimp_procedure_init (GimpProcedure *procedure)
{
app/plug-in/Makefile.am app/plug-in/plug-in-types.h removed... 2006-04-06 Michael Natterer <mitch@gimp.org> * app/plug-in/Makefile.am * app/plug-in/plug-in-types.h * app/plug-in/plug-in-proc-def.[ch]: removed... * app/pdb/Makefile.am * app/pdb/pdb-types.h * app/pdb/gimppluginprocedure.[ch]: ...and added here. Virtualized get_progname(). * app/pdb/gimptemporaryprocedure.[ch]: new class derived from GimpPlugInProcedure. * app/pdb/gimpprocedure.[ch] (struct GimpProcedure): remove union exec_method and all the structs it needed. Procedure execution is properly virtualized now. Removed gimp_procedure_initialize() and grow the args and values arrays dynamically in gimp_procedure_add_argument()/return_value(). Added marshal_func parameter to gimp_procedure_new(). * app/actions/plug-in-actions.c * app/actions/plug-in-commands.c * app/core/gimp-gui.c * app/dialogs/file-save-dialog.c * app/file/file-open.c * app/file/file-save.c * app/file/file-utils.c * app/gui/gui-vtable.c * app/menus/plug-in-menus.c * app/plug-in/plug-in-def.c * app/plug-in/plug-in-message.c * app/plug-in/plug-in-progress.c * app/plug-in/plug-in-rc.c * app/plug-in/plug-in-run.c * app/plug-in/plug-in.c * app/plug-in/plug-ins-query.c * app/plug-in/plug-ins.c * app/widgets/gimpfiledialog.c * app/widgets/gimpfileprocview.c * app/widgets/gimppluginaction.c * app/xcf/xcf.c * tools/pdbgen/pdb/fileops.pdb * tools/pdbgen/pdb/plug_in.pdb * tools/pdbgen/app.pl: changed accordingly. * app/pdb/*_cmds.c: regenerated. * app/pdb/gimp-pdb.c: added uglyness to make the app link again.
2006-04-06 18:01:30 +08:00
procedure->proc_type = GIMP_INTERNAL;
}
static void
gimp_procedure_finalize (GObject *object)
{
GimpProcedure *procedure = GIMP_PROCEDURE (object);
gint i;
gimp_procedure_free_strings (procedure);
if (procedure->args)
{
for (i = 0; i < procedure->num_args; i++)
g_param_spec_unref (procedure->args[i]);
g_free (procedure->args);
procedure->args = NULL;
}
if (procedure->values)
{
for (i = 0; i < procedure->num_values; i++)
g_param_spec_unref (procedure->values[i]);
g_free (procedure->values);
procedure->values = NULL;
}
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static gint64
gimp_procedure_get_memsize (GimpObject *object,
gint64 *gui_size)
{
GimpProcedure *procedure = GIMP_PROCEDURE (object);
gint64 memsize = 0;
gint i;
if (! procedure->static_strings)
{
memsize += gimp_string_get_memsize (procedure->original_name);
memsize += gimp_string_get_memsize (procedure->blurb);
memsize += gimp_string_get_memsize (procedure->help);
memsize += gimp_string_get_memsize (procedure->author);
memsize += gimp_string_get_memsize (procedure->copyright);
memsize += gimp_string_get_memsize (procedure->date);
memsize += gimp_string_get_memsize (procedure->deprecated);
}
memsize += procedure->num_args * sizeof (GParamSpec *);
for (i = 0; i < procedure->num_args; i++)
memsize += gimp_g_param_spec_get_memsize (procedure->args[i]);
memsize += procedure->num_values * sizeof (GParamSpec *);
for (i = 0; i < procedure->num_values; i++)
memsize += gimp_g_param_spec_get_memsize (procedure->values[i]);
return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object,
gui_size);
}
static GimpValueArray *
gimp_procedure_real_execute (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
GimpValueArray *args,
GError **error)
{
g_return_val_if_fail (gimp_value_array_length (args) >=
procedure->num_args, NULL);
app/plug-in/Makefile.am app/plug-in/plug-in-types.h removed... 2006-04-06 Michael Natterer <mitch@gimp.org> * app/plug-in/Makefile.am * app/plug-in/plug-in-types.h * app/plug-in/plug-in-proc-def.[ch]: removed... * app/pdb/Makefile.am * app/pdb/pdb-types.h * app/pdb/gimppluginprocedure.[ch]: ...and added here. Virtualized get_progname(). * app/pdb/gimptemporaryprocedure.[ch]: new class derived from GimpPlugInProcedure. * app/pdb/gimpprocedure.[ch] (struct GimpProcedure): remove union exec_method and all the structs it needed. Procedure execution is properly virtualized now. Removed gimp_procedure_initialize() and grow the args and values arrays dynamically in gimp_procedure_add_argument()/return_value(). Added marshal_func parameter to gimp_procedure_new(). * app/actions/plug-in-actions.c * app/actions/plug-in-commands.c * app/core/gimp-gui.c * app/dialogs/file-save-dialog.c * app/file/file-open.c * app/file/file-save.c * app/file/file-utils.c * app/gui/gui-vtable.c * app/menus/plug-in-menus.c * app/plug-in/plug-in-def.c * app/plug-in/plug-in-message.c * app/plug-in/plug-in-progress.c * app/plug-in/plug-in-rc.c * app/plug-in/plug-in-run.c * app/plug-in/plug-in.c * app/plug-in/plug-ins-query.c * app/plug-in/plug-ins.c * app/widgets/gimpfiledialog.c * app/widgets/gimpfileprocview.c * app/widgets/gimppluginaction.c * app/xcf/xcf.c * tools/pdbgen/pdb/fileops.pdb * tools/pdbgen/pdb/plug_in.pdb * tools/pdbgen/app.pl: changed accordingly. * app/pdb/*_cmds.c: regenerated. * app/pdb/gimp-pdb.c: added uglyness to make the app link again.
2006-04-06 18:01:30 +08:00
return procedure->marshal_func (procedure, gimp,
context, progress,
args, error);
}
static void
gimp_procedure_real_execute_async (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
GimpValueArray *args,
GimpObject *display)
{
GimpValueArray *return_vals;
GError *error = NULL;
g_return_if_fail (gimp_value_array_length (args) >= procedure->num_args);
return_vals = GIMP_PROCEDURE_GET_CLASS (procedure)->execute (procedure,
gimp,
context,
progress,
args,
&error);
gimp_value_array_unref (return_vals);
if (error)
{
bumped minimum required version of GLib to 2.18.0. 2008-11-04 Sven Neumann <sven@sven> * configure.in: bumped minimum required version of GLib to 2.18.0. * INSTALL: document the updated dependency. * app/core/gimp.[ch]: introduced gimp_message_literal(), a variant of gimp_message() that takes a literal string. * app/errors.[ch]: removed format arguments from gimp_fatal_error() and gimp_terminate() and let them take a literal string instead. * app/tools/gimptool.[ch]: introduced gimp_tool_message_literal(), a variant of gimp_tool_message() that takes a literal string. * app/actions/documents-commands.c * app/actions/drawable-commands.c * app/actions/edit-commands.c * app/actions/error-console-commands.c * app/actions/file-commands.c * app/actions/gradients-commands.c * app/actions/image-commands.c * app/actions/layers-commands.c * app/actions/palettes-commands.c * app/actions/plug-in-commands.c * app/actions/select-commands.c * app/actions/vectors-commands.c * app/config/gimprc.c * app/core/gimp-modules.c * app/core/gimp-parasites.c * app/core/gimp-templates.c * app/core/gimp-units.c * app/core/gimpchannel.c * app/core/gimpcontainer-filter.c * app/core/gimpdrawable-bucket-fill.c * app/core/gimpimage-convert.c * app/core/gimpimage-merge.c * app/core/gimpimage.c * app/core/gimpimagefile.c * app/core/gimplayer-floating-sel.c * app/core/gimplayer.c * app/core/gimpselection.c * app/dialogs/convert-dialog.c * app/dialogs/dialogs.c * app/dialogs/palette-import-dialog.c * app/dialogs/preferences-dialog.c * app/dialogs/quit-dialog.c * app/dialogs/stroke-dialog.c * app/display/gimpdisplayshell-dnd.c * app/file/file-open.c * app/file/file-procedure.c * app/file/file-save.c * app/file/file-utils.c * app/gegl/gimpcurvesconfig.c * app/gegl/gimplevelsconfig.c * app/gui/gui-message.c * app/gui/gui.c * app/gui/session.c * app/paint/gimpbrushcore.c * app/paint/gimpclone.c * app/paint/gimpheal.c * app/paint/gimpperspectiveclone.c * app/paint/gimpsourcecore.c * app/pdb/gimppdb-utils.c * app/pdb/gimpprocedure.c * app/plug-in/gimpplugin-message.c * app/plug-in/gimpplugin.c * app/plug-in/gimppluginmanager-restore.c * app/plug-in/gimppluginprocedure.c * app/text/gimptextlayer.c * app/tools/gimp-tools.c * app/tools/gimpaligntool.c * app/tools/gimpblendtool.c * app/tools/gimpbrightnesscontrasttool.c * app/tools/gimpbucketfilltool.c * app/tools/gimpcolorbalancetool.c * app/tools/gimpcolorpickertool.c * app/tools/gimpcurvestool.c * app/tools/gimpdesaturatetool.c * app/tools/gimpeditselectiontool.c * app/tools/gimpforegroundselecttool.c * app/tools/gimpfreeselecttool.c * app/tools/gimpgegltool.c * app/tools/gimphuesaturationtool.c * app/tools/gimpimagemaptool-settings.c * app/tools/gimpiscissorstool.c * app/tools/gimplevelstool.c * app/tools/gimpmeasuretool.c * app/tools/gimppainttool.c * app/tools/gimpposterizetool.c * app/tools/gimpselectiontool.c * app/tools/gimpsourcetool.c * app/tools/gimpthresholdtool.c * app/tools/gimptransformtool.c * app/tools/gimpvectortool.c * app/widgets/gimpactionview.c * app/widgets/gimpcontrollerlist.c * app/widgets/gimpcontrollers.c * app/widgets/gimpdataeditor.c * app/widgets/gimpdevices.c * app/widgets/gimpdnd-xds.c * app/widgets/gimperrordialog.c * app/widgets/gimphelp.c * app/widgets/gimpitemtreeview.c * app/widgets/gimppdbdialog.c * app/widgets/gimpsettingsbox.c * app/widgets/gimpvectorstreeview.c * app/widgets/gimpwidgets-utils.c * app/xcf/xcf-load.c * tools/pdbgen/pdb/convert.pdb * tools/pdbgen/pdb/edit.pdb * tools/pdbgen/pdb/floating_sel.pdb * tools/pdbgen/pdb/image.pdb: use the _literal variants for g_set_error(), gimp_message() and gimp_tool_message(). * app/pdb/convert-cmds.c * app/pdb/edit-cmds.c * app/pdb/floating-sel-cmds.c * app/pdb/image-cmds.c: regenerated. svn path=/trunk/; revision=27548
2008-11-04 20:33:09 +08:00
gimp_message_literal (gimp, G_OBJECT (progress), GIMP_MESSAGE_ERROR,
error->message);
g_error_free (error);
}
}
/* public functions */
GimpProcedure *
app/plug-in/Makefile.am app/plug-in/plug-in-types.h removed... 2006-04-06 Michael Natterer <mitch@gimp.org> * app/plug-in/Makefile.am * app/plug-in/plug-in-types.h * app/plug-in/plug-in-proc-def.[ch]: removed... * app/pdb/Makefile.am * app/pdb/pdb-types.h * app/pdb/gimppluginprocedure.[ch]: ...and added here. Virtualized get_progname(). * app/pdb/gimptemporaryprocedure.[ch]: new class derived from GimpPlugInProcedure. * app/pdb/gimpprocedure.[ch] (struct GimpProcedure): remove union exec_method and all the structs it needed. Procedure execution is properly virtualized now. Removed gimp_procedure_initialize() and grow the args and values arrays dynamically in gimp_procedure_add_argument()/return_value(). Added marshal_func parameter to gimp_procedure_new(). * app/actions/plug-in-actions.c * app/actions/plug-in-commands.c * app/core/gimp-gui.c * app/dialogs/file-save-dialog.c * app/file/file-open.c * app/file/file-save.c * app/file/file-utils.c * app/gui/gui-vtable.c * app/menus/plug-in-menus.c * app/plug-in/plug-in-def.c * app/plug-in/plug-in-message.c * app/plug-in/plug-in-progress.c * app/plug-in/plug-in-rc.c * app/plug-in/plug-in-run.c * app/plug-in/plug-in.c * app/plug-in/plug-ins-query.c * app/plug-in/plug-ins.c * app/widgets/gimpfiledialog.c * app/widgets/gimpfileprocview.c * app/widgets/gimppluginaction.c * app/xcf/xcf.c * tools/pdbgen/pdb/fileops.pdb * tools/pdbgen/pdb/plug_in.pdb * tools/pdbgen/app.pl: changed accordingly. * app/pdb/*_cmds.c: regenerated. * app/pdb/gimp-pdb.c: added uglyness to make the app link again.
2006-04-06 18:01:30 +08:00
gimp_procedure_new (GimpMarshalFunc marshal_func)
{
app/plug-in/Makefile.am app/plug-in/plug-in-types.h removed... 2006-04-06 Michael Natterer <mitch@gimp.org> * app/plug-in/Makefile.am * app/plug-in/plug-in-types.h * app/plug-in/plug-in-proc-def.[ch]: removed... * app/pdb/Makefile.am * app/pdb/pdb-types.h * app/pdb/gimppluginprocedure.[ch]: ...and added here. Virtualized get_progname(). * app/pdb/gimptemporaryprocedure.[ch]: new class derived from GimpPlugInProcedure. * app/pdb/gimpprocedure.[ch] (struct GimpProcedure): remove union exec_method and all the structs it needed. Procedure execution is properly virtualized now. Removed gimp_procedure_initialize() and grow the args and values arrays dynamically in gimp_procedure_add_argument()/return_value(). Added marshal_func parameter to gimp_procedure_new(). * app/actions/plug-in-actions.c * app/actions/plug-in-commands.c * app/core/gimp-gui.c * app/dialogs/file-save-dialog.c * app/file/file-open.c * app/file/file-save.c * app/file/file-utils.c * app/gui/gui-vtable.c * app/menus/plug-in-menus.c * app/plug-in/plug-in-def.c * app/plug-in/plug-in-message.c * app/plug-in/plug-in-progress.c * app/plug-in/plug-in-rc.c * app/plug-in/plug-in-run.c * app/plug-in/plug-in.c * app/plug-in/plug-ins-query.c * app/plug-in/plug-ins.c * app/widgets/gimpfiledialog.c * app/widgets/gimpfileprocview.c * app/widgets/gimppluginaction.c * app/xcf/xcf.c * tools/pdbgen/pdb/fileops.pdb * tools/pdbgen/pdb/plug_in.pdb * tools/pdbgen/app.pl: changed accordingly. * app/pdb/*_cmds.c: regenerated. * app/pdb/gimp-pdb.c: added uglyness to make the app link again.
2006-04-06 18:01:30 +08:00
GimpProcedure *procedure;
app/plug-in/Makefile.am app/plug-in/plug-in-types.h removed... 2006-04-06 Michael Natterer <mitch@gimp.org> * app/plug-in/Makefile.am * app/plug-in/plug-in-types.h * app/plug-in/plug-in-proc-def.[ch]: removed... * app/pdb/Makefile.am * app/pdb/pdb-types.h * app/pdb/gimppluginprocedure.[ch]: ...and added here. Virtualized get_progname(). * app/pdb/gimptemporaryprocedure.[ch]: new class derived from GimpPlugInProcedure. * app/pdb/gimpprocedure.[ch] (struct GimpProcedure): remove union exec_method and all the structs it needed. Procedure execution is properly virtualized now. Removed gimp_procedure_initialize() and grow the args and values arrays dynamically in gimp_procedure_add_argument()/return_value(). Added marshal_func parameter to gimp_procedure_new(). * app/actions/plug-in-actions.c * app/actions/plug-in-commands.c * app/core/gimp-gui.c * app/dialogs/file-save-dialog.c * app/file/file-open.c * app/file/file-save.c * app/file/file-utils.c * app/gui/gui-vtable.c * app/menus/plug-in-menus.c * app/plug-in/plug-in-def.c * app/plug-in/plug-in-message.c * app/plug-in/plug-in-progress.c * app/plug-in/plug-in-rc.c * app/plug-in/plug-in-run.c * app/plug-in/plug-in.c * app/plug-in/plug-ins-query.c * app/plug-in/plug-ins.c * app/widgets/gimpfiledialog.c * app/widgets/gimpfileprocview.c * app/widgets/gimppluginaction.c * app/xcf/xcf.c * tools/pdbgen/pdb/fileops.pdb * tools/pdbgen/pdb/plug_in.pdb * tools/pdbgen/app.pl: changed accordingly. * app/pdb/*_cmds.c: regenerated. * app/pdb/gimp-pdb.c: added uglyness to make the app link again.
2006-04-06 18:01:30 +08:00
g_return_val_if_fail (marshal_func != NULL, NULL);
app/plug-in/Makefile.am app/plug-in/plug-in-types.h removed... 2006-04-06 Michael Natterer <mitch@gimp.org> * app/plug-in/Makefile.am * app/plug-in/plug-in-types.h * app/plug-in/plug-in-proc-def.[ch]: removed... * app/pdb/Makefile.am * app/pdb/pdb-types.h * app/pdb/gimppluginprocedure.[ch]: ...and added here. Virtualized get_progname(). * app/pdb/gimptemporaryprocedure.[ch]: new class derived from GimpPlugInProcedure. * app/pdb/gimpprocedure.[ch] (struct GimpProcedure): remove union exec_method and all the structs it needed. Procedure execution is properly virtualized now. Removed gimp_procedure_initialize() and grow the args and values arrays dynamically in gimp_procedure_add_argument()/return_value(). Added marshal_func parameter to gimp_procedure_new(). * app/actions/plug-in-actions.c * app/actions/plug-in-commands.c * app/core/gimp-gui.c * app/dialogs/file-save-dialog.c * app/file/file-open.c * app/file/file-save.c * app/file/file-utils.c * app/gui/gui-vtable.c * app/menus/plug-in-menus.c * app/plug-in/plug-in-def.c * app/plug-in/plug-in-message.c * app/plug-in/plug-in-progress.c * app/plug-in/plug-in-rc.c * app/plug-in/plug-in-run.c * app/plug-in/plug-in.c * app/plug-in/plug-ins-query.c * app/plug-in/plug-ins.c * app/widgets/gimpfiledialog.c * app/widgets/gimpfileprocview.c * app/widgets/gimppluginaction.c * app/xcf/xcf.c * tools/pdbgen/pdb/fileops.pdb * tools/pdbgen/pdb/plug_in.pdb * tools/pdbgen/app.pl: changed accordingly. * app/pdb/*_cmds.c: regenerated. * app/pdb/gimp-pdb.c: added uglyness to make the app link again.
2006-04-06 18:01:30 +08:00
procedure = g_object_new (GIMP_TYPE_PROCEDURE, NULL);
app/plug-in/Makefile.am app/plug-in/plug-in-types.h removed... 2006-04-06 Michael Natterer <mitch@gimp.org> * app/plug-in/Makefile.am * app/plug-in/plug-in-types.h * app/plug-in/plug-in-proc-def.[ch]: removed... * app/pdb/Makefile.am * app/pdb/pdb-types.h * app/pdb/gimppluginprocedure.[ch]: ...and added here. Virtualized get_progname(). * app/pdb/gimptemporaryprocedure.[ch]: new class derived from GimpPlugInProcedure. * app/pdb/gimpprocedure.[ch] (struct GimpProcedure): remove union exec_method and all the structs it needed. Procedure execution is properly virtualized now. Removed gimp_procedure_initialize() and grow the args and values arrays dynamically in gimp_procedure_add_argument()/return_value(). Added marshal_func parameter to gimp_procedure_new(). * app/actions/plug-in-actions.c * app/actions/plug-in-commands.c * app/core/gimp-gui.c * app/dialogs/file-save-dialog.c * app/file/file-open.c * app/file/file-save.c * app/file/file-utils.c * app/gui/gui-vtable.c * app/menus/plug-in-menus.c * app/plug-in/plug-in-def.c * app/plug-in/plug-in-message.c * app/plug-in/plug-in-progress.c * app/plug-in/plug-in-rc.c * app/plug-in/plug-in-run.c * app/plug-in/plug-in.c * app/plug-in/plug-ins-query.c * app/plug-in/plug-ins.c * app/widgets/gimpfiledialog.c * app/widgets/gimpfileprocview.c * app/widgets/gimppluginaction.c * app/xcf/xcf.c * tools/pdbgen/pdb/fileops.pdb * tools/pdbgen/pdb/plug_in.pdb * tools/pdbgen/app.pl: changed accordingly. * app/pdb/*_cmds.c: regenerated. * app/pdb/gimp-pdb.c: added uglyness to make the app link again.
2006-04-06 18:01:30 +08:00
procedure->marshal_func = marshal_func;
return procedure;
}
void
gimp_procedure_set_strings (GimpProcedure *procedure,
const gchar *original_name,
const gchar *blurb,
const gchar *help,
const gchar *author,
const gchar *copyright,
const gchar *date,
const gchar *deprecated)
{
g_return_if_fail (GIMP_IS_PROCEDURE (procedure));
gimp_procedure_free_strings (procedure);
procedure->original_name = g_strdup (original_name);
procedure->blurb = g_strdup (blurb);
procedure->help = g_strdup (help);
procedure->author = g_strdup (author);
procedure->copyright = g_strdup (copyright);
procedure->date = g_strdup (date);
procedure->deprecated = g_strdup (deprecated);
procedure->static_strings = FALSE;
}
void
gimp_procedure_set_static_strings (GimpProcedure *procedure,
const gchar *original_name,
const gchar *blurb,
const gchar *help,
const gchar *author,
const gchar *copyright,
const gchar *date,
const gchar *deprecated)
{
g_return_if_fail (GIMP_IS_PROCEDURE (procedure));
gimp_procedure_free_strings (procedure);
procedure->original_name = (gchar *) original_name;
procedure->blurb = (gchar *) blurb;
procedure->help = (gchar *) help;
procedure->author = (gchar *) author;
procedure->copyright = (gchar *) copyright;
procedure->date = (gchar *) date;
procedure->deprecated = (gchar *) deprecated;
procedure->static_strings = TRUE;
}
void
gimp_procedure_take_strings (GimpProcedure *procedure,
gchar *original_name,
gchar *blurb,
gchar *help,
gchar *author,
gchar *copyright,
gchar *date,
gchar *deprecated)
{
g_return_if_fail (GIMP_IS_PROCEDURE (procedure));
gimp_procedure_free_strings (procedure);
procedure->original_name = original_name;
procedure->blurb = blurb;
procedure->help = help;
procedure->author = author;
procedure->copyright = copyright;
procedure->date = date;
procedure->deprecated = deprecated;
procedure->static_strings = FALSE;
}
GimpValueArray *
gimp_procedure_execute (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
GimpValueArray *args,
GError **error)
replace the value union by a GValue. 2006-03-30 Michael Natterer <mitch@gimp.org> * app/pdb/procedural_db.[ch] (struct Argument): replace the value union by a GValue. (procedural_db_argument_init) (procedural_db_compat_arg_init): new functions to initialize an Argument. They call g_value_init() on the Argument's value. (procedural_db_arguments) (procedural_db_return_values): initialize the returned Argument arrays so their GValues are ready to use. Allow to get the (unsuccessful) return values of a NULL ProcRecord. (procedural_db_destroy_args): g_value_unset() the values. Added a "gboolean full_destroy" parameter. Its only effect is to destroy PDB arrays, everything else is nicely memory managed by GValue. (procedural_db_execute) (procedural_db_run_proc): do GValue stuff. Added n_args and n_return_vals parameters to execute(). (procedural_db_execute_proc): private function to execute a procedure. Validates the passed in arguments using the registered GParamSpecs before passing them to the resp. exec method. * app/plug-in/plug-in-params.[ch] (plug_in_params_to_args): needs an array of ProcArgs now in order to initialize the Arguments' GValues correctly. Passing NULL ProcArgs uses procedural_db_compat_arg_init(), so procedures (plug-ins) returning more values than expected work. (plug_in_args_to_params): do GValue stuff here too. (plug_in_args_destroy): removed this function, procedural_db_destroy_args() does the same now. * app/plug-in/plug-in-message.c (plug_in_handle_proc_run): simplified quite a bit because everything returns n_return_values now. Call plug_in_params_to_args() only of the procedure was found. (plug_in_handle_proc_return_priv): pass ProcRecs to plug_in_params_to_args(). * app/batch.c * app/actions/plug-in-commands.c * app/actions/vectors-commands.c * app/core/gimppdbprogress.c * app/dialogs/about-dialog.c * app/file/file-open.c * app/file/file-save.c * app/plug-in/plug-ins.c * app/plug-in/plug-in-progress.c * app/plug-in/plug-in-run.[ch] * app/widgets/gimphelp.c * app/widgets/gimppdbdialog.c * app/xcf/xcf.c * tools/pdbgen/pdb/fileops.pdb: changed accordingly: don't g_new/g_free Argument arrays, always use procedural_db_foo() functions. Use GValue functions to get/set Arguments. * tools/pdbgen/pdb.pl: added get_value_func and set_value_func to all PDB types. Removed id_func, id_ret_func and check_func. Added flags which indicated that a type is an ID. Removed unused utility functions. * tools/pdbgen/lib.pl: use the flag instead of looking at functions and value types. * tools/pdbgen/app.pl: use the get_value_func and set_value_func to marshal inargs and outargs. Removed all checks performed on inargs because that's done by GParamSpec validation now. Added the missing bits to register excluded values with GimpParamSpecEnum. * app/pdb/*_cmds.c: regenerated.
2006-03-30 07:56:07 +08:00
{
GimpValueArray *return_vals;
GError *pdb_error = NULL;
replace the value union by a GValue. 2006-03-30 Michael Natterer <mitch@gimp.org> * app/pdb/procedural_db.[ch] (struct Argument): replace the value union by a GValue. (procedural_db_argument_init) (procedural_db_compat_arg_init): new functions to initialize an Argument. They call g_value_init() on the Argument's value. (procedural_db_arguments) (procedural_db_return_values): initialize the returned Argument arrays so their GValues are ready to use. Allow to get the (unsuccessful) return values of a NULL ProcRecord. (procedural_db_destroy_args): g_value_unset() the values. Added a "gboolean full_destroy" parameter. Its only effect is to destroy PDB arrays, everything else is nicely memory managed by GValue. (procedural_db_execute) (procedural_db_run_proc): do GValue stuff. Added n_args and n_return_vals parameters to execute(). (procedural_db_execute_proc): private function to execute a procedure. Validates the passed in arguments using the registered GParamSpecs before passing them to the resp. exec method. * app/plug-in/plug-in-params.[ch] (plug_in_params_to_args): needs an array of ProcArgs now in order to initialize the Arguments' GValues correctly. Passing NULL ProcArgs uses procedural_db_compat_arg_init(), so procedures (plug-ins) returning more values than expected work. (plug_in_args_to_params): do GValue stuff here too. (plug_in_args_destroy): removed this function, procedural_db_destroy_args() does the same now. * app/plug-in/plug-in-message.c (plug_in_handle_proc_run): simplified quite a bit because everything returns n_return_values now. Call plug_in_params_to_args() only of the procedure was found. (plug_in_handle_proc_return_priv): pass ProcRecs to plug_in_params_to_args(). * app/batch.c * app/actions/plug-in-commands.c * app/actions/vectors-commands.c * app/core/gimppdbprogress.c * app/dialogs/about-dialog.c * app/file/file-open.c * app/file/file-save.c * app/plug-in/plug-ins.c * app/plug-in/plug-in-progress.c * app/plug-in/plug-in-run.[ch] * app/widgets/gimphelp.c * app/widgets/gimppdbdialog.c * app/xcf/xcf.c * tools/pdbgen/pdb/fileops.pdb: changed accordingly: don't g_new/g_free Argument arrays, always use procedural_db_foo() functions. Use GValue functions to get/set Arguments. * tools/pdbgen/pdb.pl: added get_value_func and set_value_func to all PDB types. Removed id_func, id_ret_func and check_func. Added flags which indicated that a type is an ID. Removed unused utility functions. * tools/pdbgen/lib.pl: use the flag instead of looking at functions and value types. * tools/pdbgen/app.pl: use the get_value_func and set_value_func to marshal inargs and outargs. Removed all checks performed on inargs because that's done by GParamSpec validation now. Added the missing bits to register excluded values with GimpParamSpecEnum. * app/pdb/*_cmds.c: regenerated.
2006-03-30 07:56:07 +08:00
g_return_val_if_fail (GIMP_IS_PROCEDURE (procedure), NULL);
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
g_return_val_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress), NULL);
g_return_val_if_fail (args != NULL, NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
if (! gimp_procedure_validate_args (procedure,
procedure->args, procedure->num_args,
args, FALSE, &pdb_error))
replace the value union by a GValue. 2006-03-30 Michael Natterer <mitch@gimp.org> * app/pdb/procedural_db.[ch] (struct Argument): replace the value union by a GValue. (procedural_db_argument_init) (procedural_db_compat_arg_init): new functions to initialize an Argument. They call g_value_init() on the Argument's value. (procedural_db_arguments) (procedural_db_return_values): initialize the returned Argument arrays so their GValues are ready to use. Allow to get the (unsuccessful) return values of a NULL ProcRecord. (procedural_db_destroy_args): g_value_unset() the values. Added a "gboolean full_destroy" parameter. Its only effect is to destroy PDB arrays, everything else is nicely memory managed by GValue. (procedural_db_execute) (procedural_db_run_proc): do GValue stuff. Added n_args and n_return_vals parameters to execute(). (procedural_db_execute_proc): private function to execute a procedure. Validates the passed in arguments using the registered GParamSpecs before passing them to the resp. exec method. * app/plug-in/plug-in-params.[ch] (plug_in_params_to_args): needs an array of ProcArgs now in order to initialize the Arguments' GValues correctly. Passing NULL ProcArgs uses procedural_db_compat_arg_init(), so procedures (plug-ins) returning more values than expected work. (plug_in_args_to_params): do GValue stuff here too. (plug_in_args_destroy): removed this function, procedural_db_destroy_args() does the same now. * app/plug-in/plug-in-message.c (plug_in_handle_proc_run): simplified quite a bit because everything returns n_return_values now. Call plug_in_params_to_args() only of the procedure was found. (plug_in_handle_proc_return_priv): pass ProcRecs to plug_in_params_to_args(). * app/batch.c * app/actions/plug-in-commands.c * app/actions/vectors-commands.c * app/core/gimppdbprogress.c * app/dialogs/about-dialog.c * app/file/file-open.c * app/file/file-save.c * app/plug-in/plug-ins.c * app/plug-in/plug-in-progress.c * app/plug-in/plug-in-run.[ch] * app/widgets/gimphelp.c * app/widgets/gimppdbdialog.c * app/xcf/xcf.c * tools/pdbgen/pdb/fileops.pdb: changed accordingly: don't g_new/g_free Argument arrays, always use procedural_db_foo() functions. Use GValue functions to get/set Arguments. * tools/pdbgen/pdb.pl: added get_value_func and set_value_func to all PDB types. Removed id_func, id_ret_func and check_func. Added flags which indicated that a type is an ID. Removed unused utility functions. * tools/pdbgen/lib.pl: use the flag instead of looking at functions and value types. * tools/pdbgen/app.pl: use the get_value_func and set_value_func to marshal inargs and outargs. Removed all checks performed on inargs because that's done by GParamSpec validation now. Added the missing bits to register excluded values with GimpParamSpecEnum. * app/pdb/*_cmds.c: regenerated.
2006-03-30 07:56:07 +08:00
{
return_vals = gimp_procedure_get_return_values (procedure, FALSE,
pdb_error);
g_propagate_error (error, pdb_error);
return return_vals;
replace the value union by a GValue. 2006-03-30 Michael Natterer <mitch@gimp.org> * app/pdb/procedural_db.[ch] (struct Argument): replace the value union by a GValue. (procedural_db_argument_init) (procedural_db_compat_arg_init): new functions to initialize an Argument. They call g_value_init() on the Argument's value. (procedural_db_arguments) (procedural_db_return_values): initialize the returned Argument arrays so their GValues are ready to use. Allow to get the (unsuccessful) return values of a NULL ProcRecord. (procedural_db_destroy_args): g_value_unset() the values. Added a "gboolean full_destroy" parameter. Its only effect is to destroy PDB arrays, everything else is nicely memory managed by GValue. (procedural_db_execute) (procedural_db_run_proc): do GValue stuff. Added n_args and n_return_vals parameters to execute(). (procedural_db_execute_proc): private function to execute a procedure. Validates the passed in arguments using the registered GParamSpecs before passing them to the resp. exec method. * app/plug-in/plug-in-params.[ch] (plug_in_params_to_args): needs an array of ProcArgs now in order to initialize the Arguments' GValues correctly. Passing NULL ProcArgs uses procedural_db_compat_arg_init(), so procedures (plug-ins) returning more values than expected work. (plug_in_args_to_params): do GValue stuff here too. (plug_in_args_destroy): removed this function, procedural_db_destroy_args() does the same now. * app/plug-in/plug-in-message.c (plug_in_handle_proc_run): simplified quite a bit because everything returns n_return_values now. Call plug_in_params_to_args() only of the procedure was found. (plug_in_handle_proc_return_priv): pass ProcRecs to plug_in_params_to_args(). * app/batch.c * app/actions/plug-in-commands.c * app/actions/vectors-commands.c * app/core/gimppdbprogress.c * app/dialogs/about-dialog.c * app/file/file-open.c * app/file/file-save.c * app/plug-in/plug-ins.c * app/plug-in/plug-in-progress.c * app/plug-in/plug-in-run.[ch] * app/widgets/gimphelp.c * app/widgets/gimppdbdialog.c * app/xcf/xcf.c * tools/pdbgen/pdb/fileops.pdb: changed accordingly: don't g_new/g_free Argument arrays, always use procedural_db_foo() functions. Use GValue functions to get/set Arguments. * tools/pdbgen/pdb.pl: added get_value_func and set_value_func to all PDB types. Removed id_func, id_ret_func and check_func. Added flags which indicated that a type is an ID. Removed unused utility functions. * tools/pdbgen/lib.pl: use the flag instead of looking at functions and value types. * tools/pdbgen/app.pl: use the get_value_func and set_value_func to marshal inargs and outargs. Removed all checks performed on inargs because that's done by GParamSpec validation now. Added the missing bits to register excluded values with GimpParamSpecEnum. * app/pdb/*_cmds.c: regenerated.
2006-03-30 07:56:07 +08:00
}
if (GIMP_IS_PDB_CONTEXT (context))
context = g_object_ref (context);
else
context = gimp_pdb_context_new (gimp, context, TRUE);
replace the value union by a GValue. 2006-03-30 Michael Natterer <mitch@gimp.org> * app/pdb/procedural_db.[ch] (struct Argument): replace the value union by a GValue. (procedural_db_argument_init) (procedural_db_compat_arg_init): new functions to initialize an Argument. They call g_value_init() on the Argument's value. (procedural_db_arguments) (procedural_db_return_values): initialize the returned Argument arrays so their GValues are ready to use. Allow to get the (unsuccessful) return values of a NULL ProcRecord. (procedural_db_destroy_args): g_value_unset() the values. Added a "gboolean full_destroy" parameter. Its only effect is to destroy PDB arrays, everything else is nicely memory managed by GValue. (procedural_db_execute) (procedural_db_run_proc): do GValue stuff. Added n_args and n_return_vals parameters to execute(). (procedural_db_execute_proc): private function to execute a procedure. Validates the passed in arguments using the registered GParamSpecs before passing them to the resp. exec method. * app/plug-in/plug-in-params.[ch] (plug_in_params_to_args): needs an array of ProcArgs now in order to initialize the Arguments' GValues correctly. Passing NULL ProcArgs uses procedural_db_compat_arg_init(), so procedures (plug-ins) returning more values than expected work. (plug_in_args_to_params): do GValue stuff here too. (plug_in_args_destroy): removed this function, procedural_db_destroy_args() does the same now. * app/plug-in/plug-in-message.c (plug_in_handle_proc_run): simplified quite a bit because everything returns n_return_values now. Call plug_in_params_to_args() only of the procedure was found. (plug_in_handle_proc_return_priv): pass ProcRecs to plug_in_params_to_args(). * app/batch.c * app/actions/plug-in-commands.c * app/actions/vectors-commands.c * app/core/gimppdbprogress.c * app/dialogs/about-dialog.c * app/file/file-open.c * app/file/file-save.c * app/plug-in/plug-ins.c * app/plug-in/plug-in-progress.c * app/plug-in/plug-in-run.[ch] * app/widgets/gimphelp.c * app/widgets/gimppdbdialog.c * app/xcf/xcf.c * tools/pdbgen/pdb/fileops.pdb: changed accordingly: don't g_new/g_free Argument arrays, always use procedural_db_foo() functions. Use GValue functions to get/set Arguments. * tools/pdbgen/pdb.pl: added get_value_func and set_value_func to all PDB types. Removed id_func, id_ret_func and check_func. Added flags which indicated that a type is an ID. Removed unused utility functions. * tools/pdbgen/lib.pl: use the flag instead of looking at functions and value types. * tools/pdbgen/app.pl: use the get_value_func and set_value_func to marshal inargs and outargs. Removed all checks performed on inargs because that's done by GParamSpec validation now. Added the missing bits to register excluded values with GimpParamSpecEnum. * app/pdb/*_cmds.c: regenerated.
2006-03-30 07:56:07 +08:00
/* call the procedure */
return_vals = GIMP_PROCEDURE_GET_CLASS (procedure)->execute (procedure,
gimp,
context,
progress,
args,
error);
replace the value union by a GValue. 2006-03-30 Michael Natterer <mitch@gimp.org> * app/pdb/procedural_db.[ch] (struct Argument): replace the value union by a GValue. (procedural_db_argument_init) (procedural_db_compat_arg_init): new functions to initialize an Argument. They call g_value_init() on the Argument's value. (procedural_db_arguments) (procedural_db_return_values): initialize the returned Argument arrays so their GValues are ready to use. Allow to get the (unsuccessful) return values of a NULL ProcRecord. (procedural_db_destroy_args): g_value_unset() the values. Added a "gboolean full_destroy" parameter. Its only effect is to destroy PDB arrays, everything else is nicely memory managed by GValue. (procedural_db_execute) (procedural_db_run_proc): do GValue stuff. Added n_args and n_return_vals parameters to execute(). (procedural_db_execute_proc): private function to execute a procedure. Validates the passed in arguments using the registered GParamSpecs before passing them to the resp. exec method. * app/plug-in/plug-in-params.[ch] (plug_in_params_to_args): needs an array of ProcArgs now in order to initialize the Arguments' GValues correctly. Passing NULL ProcArgs uses procedural_db_compat_arg_init(), so procedures (plug-ins) returning more values than expected work. (plug_in_args_to_params): do GValue stuff here too. (plug_in_args_destroy): removed this function, procedural_db_destroy_args() does the same now. * app/plug-in/plug-in-message.c (plug_in_handle_proc_run): simplified quite a bit because everything returns n_return_values now. Call plug_in_params_to_args() only of the procedure was found. (plug_in_handle_proc_return_priv): pass ProcRecs to plug_in_params_to_args(). * app/batch.c * app/actions/plug-in-commands.c * app/actions/vectors-commands.c * app/core/gimppdbprogress.c * app/dialogs/about-dialog.c * app/file/file-open.c * app/file/file-save.c * app/plug-in/plug-ins.c * app/plug-in/plug-in-progress.c * app/plug-in/plug-in-run.[ch] * app/widgets/gimphelp.c * app/widgets/gimppdbdialog.c * app/xcf/xcf.c * tools/pdbgen/pdb/fileops.pdb: changed accordingly: don't g_new/g_free Argument arrays, always use procedural_db_foo() functions. Use GValue functions to get/set Arguments. * tools/pdbgen/pdb.pl: added get_value_func and set_value_func to all PDB types. Removed id_func, id_ret_func and check_func. Added flags which indicated that a type is an ID. Removed unused utility functions. * tools/pdbgen/lib.pl: use the flag instead of looking at functions and value types. * tools/pdbgen/app.pl: use the get_value_func and set_value_func to marshal inargs and outargs. Removed all checks performed on inargs because that's done by GParamSpec validation now. Added the missing bits to register excluded values with GimpParamSpecEnum. * app/pdb/*_cmds.c: regenerated.
2006-03-30 07:56:07 +08:00
g_object_unref (context);
if (return_vals)
{
switch (g_value_get_enum (gimp_value_array_index (return_vals, 0)))
{
case GIMP_PDB_CALLING_ERROR:
case GIMP_PDB_EXECUTION_ERROR:
/* If the error has not already been set, construct one
* from the error message that is optionally passed with
* the return values.
*/
if (error && *error == NULL)
{
if (gimp_value_array_length (return_vals) > 1 &&
G_VALUE_HOLDS_STRING (gimp_value_array_index (return_vals, 1)))
{
GValue *value = gimp_value_array_index (return_vals, 1);
g_set_error_literal (error, GIMP_PDB_ERROR,
GIMP_PDB_ERROR_FAILED,
g_value_get_string (value));
}
}
break;
default:
break;
}
}
else
replace the value union by a GValue. 2006-03-30 Michael Natterer <mitch@gimp.org> * app/pdb/procedural_db.[ch] (struct Argument): replace the value union by a GValue. (procedural_db_argument_init) (procedural_db_compat_arg_init): new functions to initialize an Argument. They call g_value_init() on the Argument's value. (procedural_db_arguments) (procedural_db_return_values): initialize the returned Argument arrays so their GValues are ready to use. Allow to get the (unsuccessful) return values of a NULL ProcRecord. (procedural_db_destroy_args): g_value_unset() the values. Added a "gboolean full_destroy" parameter. Its only effect is to destroy PDB arrays, everything else is nicely memory managed by GValue. (procedural_db_execute) (procedural_db_run_proc): do GValue stuff. Added n_args and n_return_vals parameters to execute(). (procedural_db_execute_proc): private function to execute a procedure. Validates the passed in arguments using the registered GParamSpecs before passing them to the resp. exec method. * app/plug-in/plug-in-params.[ch] (plug_in_params_to_args): needs an array of ProcArgs now in order to initialize the Arguments' GValues correctly. Passing NULL ProcArgs uses procedural_db_compat_arg_init(), so procedures (plug-ins) returning more values than expected work. (plug_in_args_to_params): do GValue stuff here too. (plug_in_args_destroy): removed this function, procedural_db_destroy_args() does the same now. * app/plug-in/plug-in-message.c (plug_in_handle_proc_run): simplified quite a bit because everything returns n_return_values now. Call plug_in_params_to_args() only of the procedure was found. (plug_in_handle_proc_return_priv): pass ProcRecs to plug_in_params_to_args(). * app/batch.c * app/actions/plug-in-commands.c * app/actions/vectors-commands.c * app/core/gimppdbprogress.c * app/dialogs/about-dialog.c * app/file/file-open.c * app/file/file-save.c * app/plug-in/plug-ins.c * app/plug-in/plug-in-progress.c * app/plug-in/plug-in-run.[ch] * app/widgets/gimphelp.c * app/widgets/gimppdbdialog.c * app/xcf/xcf.c * tools/pdbgen/pdb/fileops.pdb: changed accordingly: don't g_new/g_free Argument arrays, always use procedural_db_foo() functions. Use GValue functions to get/set Arguments. * tools/pdbgen/pdb.pl: added get_value_func and set_value_func to all PDB types. Removed id_func, id_ret_func and check_func. Added flags which indicated that a type is an ID. Removed unused utility functions. * tools/pdbgen/lib.pl: use the flag instead of looking at functions and value types. * tools/pdbgen/app.pl: use the get_value_func and set_value_func to marshal inargs and outargs. Removed all checks performed on inargs because that's done by GParamSpec validation now. Added the missing bits to register excluded values with GimpParamSpecEnum. * app/pdb/*_cmds.c: regenerated.
2006-03-30 07:56:07 +08:00
{
g_warning ("%s: no return values, shouldn't happen", G_STRFUNC);
pdb_error = g_error_new (GIMP_PDB_ERROR,
GIMP_PDB_ERROR_INVALID_RETURN_VALUE,
_("Procedure '%s' returned no return values"),
gimp_object_get_name (procedure));
replace the value union by a GValue. 2006-03-30 Michael Natterer <mitch@gimp.org> * app/pdb/procedural_db.[ch] (struct Argument): replace the value union by a GValue. (procedural_db_argument_init) (procedural_db_compat_arg_init): new functions to initialize an Argument. They call g_value_init() on the Argument's value. (procedural_db_arguments) (procedural_db_return_values): initialize the returned Argument arrays so their GValues are ready to use. Allow to get the (unsuccessful) return values of a NULL ProcRecord. (procedural_db_destroy_args): g_value_unset() the values. Added a "gboolean full_destroy" parameter. Its only effect is to destroy PDB arrays, everything else is nicely memory managed by GValue. (procedural_db_execute) (procedural_db_run_proc): do GValue stuff. Added n_args and n_return_vals parameters to execute(). (procedural_db_execute_proc): private function to execute a procedure. Validates the passed in arguments using the registered GParamSpecs before passing them to the resp. exec method. * app/plug-in/plug-in-params.[ch] (plug_in_params_to_args): needs an array of ProcArgs now in order to initialize the Arguments' GValues correctly. Passing NULL ProcArgs uses procedural_db_compat_arg_init(), so procedures (plug-ins) returning more values than expected work. (plug_in_args_to_params): do GValue stuff here too. (plug_in_args_destroy): removed this function, procedural_db_destroy_args() does the same now. * app/plug-in/plug-in-message.c (plug_in_handle_proc_run): simplified quite a bit because everything returns n_return_values now. Call plug_in_params_to_args() only of the procedure was found. (plug_in_handle_proc_return_priv): pass ProcRecs to plug_in_params_to_args(). * app/batch.c * app/actions/plug-in-commands.c * app/actions/vectors-commands.c * app/core/gimppdbprogress.c * app/dialogs/about-dialog.c * app/file/file-open.c * app/file/file-save.c * app/plug-in/plug-ins.c * app/plug-in/plug-in-progress.c * app/plug-in/plug-in-run.[ch] * app/widgets/gimphelp.c * app/widgets/gimppdbdialog.c * app/xcf/xcf.c * tools/pdbgen/pdb/fileops.pdb: changed accordingly: don't g_new/g_free Argument arrays, always use procedural_db_foo() functions. Use GValue functions to get/set Arguments. * tools/pdbgen/pdb.pl: added get_value_func and set_value_func to all PDB types. Removed id_func, id_ret_func and check_func. Added flags which indicated that a type is an ID. Removed unused utility functions. * tools/pdbgen/lib.pl: use the flag instead of looking at functions and value types. * tools/pdbgen/app.pl: use the get_value_func and set_value_func to marshal inargs and outargs. Removed all checks performed on inargs because that's done by GParamSpec validation now. Added the missing bits to register excluded values with GimpParamSpecEnum. * app/pdb/*_cmds.c: regenerated.
2006-03-30 07:56:07 +08:00
return_vals = gimp_procedure_get_return_values (procedure, FALSE,
pdb_error);
if (error && *error == NULL)
g_propagate_error (error, pdb_error);
else
g_error_free (pdb_error);
replace the value union by a GValue. 2006-03-30 Michael Natterer <mitch@gimp.org> * app/pdb/procedural_db.[ch] (struct Argument): replace the value union by a GValue. (procedural_db_argument_init) (procedural_db_compat_arg_init): new functions to initialize an Argument. They call g_value_init() on the Argument's value. (procedural_db_arguments) (procedural_db_return_values): initialize the returned Argument arrays so their GValues are ready to use. Allow to get the (unsuccessful) return values of a NULL ProcRecord. (procedural_db_destroy_args): g_value_unset() the values. Added a "gboolean full_destroy" parameter. Its only effect is to destroy PDB arrays, everything else is nicely memory managed by GValue. (procedural_db_execute) (procedural_db_run_proc): do GValue stuff. Added n_args and n_return_vals parameters to execute(). (procedural_db_execute_proc): private function to execute a procedure. Validates the passed in arguments using the registered GParamSpecs before passing them to the resp. exec method. * app/plug-in/plug-in-params.[ch] (plug_in_params_to_args): needs an array of ProcArgs now in order to initialize the Arguments' GValues correctly. Passing NULL ProcArgs uses procedural_db_compat_arg_init(), so procedures (plug-ins) returning more values than expected work. (plug_in_args_to_params): do GValue stuff here too. (plug_in_args_destroy): removed this function, procedural_db_destroy_args() does the same now. * app/plug-in/plug-in-message.c (plug_in_handle_proc_run): simplified quite a bit because everything returns n_return_values now. Call plug_in_params_to_args() only of the procedure was found. (plug_in_handle_proc_return_priv): pass ProcRecs to plug_in_params_to_args(). * app/batch.c * app/actions/plug-in-commands.c * app/actions/vectors-commands.c * app/core/gimppdbprogress.c * app/dialogs/about-dialog.c * app/file/file-open.c * app/file/file-save.c * app/plug-in/plug-ins.c * app/plug-in/plug-in-progress.c * app/plug-in/plug-in-run.[ch] * app/widgets/gimphelp.c * app/widgets/gimppdbdialog.c * app/xcf/xcf.c * tools/pdbgen/pdb/fileops.pdb: changed accordingly: don't g_new/g_free Argument arrays, always use procedural_db_foo() functions. Use GValue functions to get/set Arguments. * tools/pdbgen/pdb.pl: added get_value_func and set_value_func to all PDB types. Removed id_func, id_ret_func and check_func. Added flags which indicated that a type is an ID. Removed unused utility functions. * tools/pdbgen/lib.pl: use the flag instead of looking at functions and value types. * tools/pdbgen/app.pl: use the get_value_func and set_value_func to marshal inargs and outargs. Removed all checks performed on inargs because that's done by GParamSpec validation now. Added the missing bits to register excluded values with GimpParamSpecEnum. * app/pdb/*_cmds.c: regenerated.
2006-03-30 07:56:07 +08:00
}
return return_vals;
}
void
gimp_procedure_execute_async (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
GimpValueArray *args,
GimpObject *display,
GError **error)
{
g_return_if_fail (GIMP_IS_PROCEDURE (procedure));
g_return_if_fail (GIMP_IS_GIMP (gimp));
g_return_if_fail (GIMP_IS_CONTEXT (context));
g_return_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress));
g_return_if_fail (args != NULL);
g_return_if_fail (display == NULL || GIMP_IS_OBJECT (display));
g_return_if_fail (error == NULL || *error == NULL);
if (gimp_procedure_validate_args (procedure,
procedure->args, procedure->num_args,
args, FALSE, error))
{
if (GIMP_IS_PDB_CONTEXT (context))
context = g_object_ref (context);
else
context = gimp_pdb_context_new (gimp, context, TRUE);
GIMP_PROCEDURE_GET_CLASS (procedure)->execute_async (procedure, gimp,
context, progress,
args, display);
g_object_unref (context);
}
}
GimpValueArray *
gimp_procedure_get_arguments (GimpProcedure *procedure)
1997-11-25 06:05:25 +08:00
{
GimpValueArray *args;
GValue value = { 0, };
gint i;
1997-11-25 06:05:25 +08:00
g_return_val_if_fail (GIMP_IS_PROCEDURE (procedure), NULL);
args = gimp_value_array_new (procedure->num_args);
Changed the semantics of GIMP_EXTENSION and (to some extent) of 2003-06-19 Michael Natterer <mitch@gimp.org> Changed the semantics of GIMP_EXTENSION and (to some extent) of GIMP_PLUGIN: The old meaning of EXTENSION was "I live in the toolbox" and PLUGIN meant "I take RUN-MODE,IMAGE,DRAWABLE args (but only if I am invoked interactively)". This is completely useless, since living in the toolbox means having "<Toolbox>" in the menu_path and taking RUN-MODE,IMAGE,DRAWABLE means just that, regardless of what type of procedure we are. The new meaning of GIMP_PLUGIN is just "I am an ordinary procedure, I am invoked, do my job and finish", while GIMP_EXTENSION means "I will install temporary procedures and I will keep running to keep them available". (A GIMP_EXTENSION *must* call gimp_extension_ack() now to tell the core that it's ready to run, or the core will block waiting for the message !!!). * configure.in: bumped version number to 1.3.16. * libgimpbase/gimpprotocol.h: increased protocol version number so old extensions will refuse to load. * app/gui/plug-in-commands.c (plug_in_run_cmd_callback): don't blindly pass RUN-MODE,IMAGE,DRAWABLE to GIMP_PLUGIN procedures but look at their parameters and pass them either RUN-MODE, or RUN-MODE,IMAGE, or RUN-MODE,IMAGE,DRAWABLE. * app/pdb/procedural_db.c: cleaned up, better error reporting, replaced an impossible error message by g_return_if_fail() * app/plug-in/plug-in-message.c (plug_in_handle_proc_install): better error messages. * app/plug-in/plug-in-params.c: allocate parameter arrays using g_new0() so we don't have to worry about uninitialized stuff later. * app/plug-in/plug-in-run.c (plug_in_run): wait for gimp_extension_ack() installation confirmation for ALL extensions, not just for automatically started ones. * app/plug-in/plug-ins.c: cleanup. * libgimp/gimp.[ch]: cleaned up and API-documented massively. Made all magic values given in the GPConfig message static and added accessor functions for them. Added gimp_tile_width()/height(). Added new function gimp_extension_enable() which turns on asynchronous processing of temp_proc run requests without having to enter an endless gimp_extension_process() loop. Moved all private functions to the end of the file. Added tons of g_return_if_fail() all over the place. Call gimp_run_procedure2() from gimp_run_procedure() instead of duplicating the code. Indentation, spacing, stuff... * libgimp/gimptile.[ch]: removed gimp_tile_width()/height(). * libgimp/gimpdrawable.c * libgimp/gimppixelrgn.c * libgimp/gimptile.c: use the gimp_tile_width()/height() accessor functions. * libgimp/gimp.def: added gimp_extension_enable. * libgimp/gimpmenu.c: removed evil code which connected to _readchannel manually and use gimp_extension_enable() for watching temp_procs. * plug-ins/helpbrowser/helpbrowser.c: removed the same evil code here and call gimp_extension_enable(). Call gimp_extension_ack() to let the core know that the temp_proc is installed. * plug-ins/script-fu/script-fu.c: made all procedures except the permanently running "extension_script_fu" ordinary GIMP_PLUGIN procedures. * plug-ins/common/curve_bend.c * plug-ins/common/plugindetails.c * plug-ins/common/screenshot.c * plug-ins/common/uniteditor.c * plug-ins/common/winclipboard.c * plug-ins/dbbrowser/dbbrowser.c * plug-ins/gfli/gfli.c * plug-ins/twain/twain.c * plug-ins/webbrowser/webbrowser.c * plug-ins/winsnap/winsnap.c: made them all ordinary GIMP_PLUGIN procedures and renamed them from "extension_*" to "plug_in_*". Random cleanups. * app/widgets/gimphelp.c * plug-ins/maze/maze_face.c: call "plug_in_web_browser" now.
2003-06-20 01:12:00 +08:00
for (i = 0; i < procedure->num_args; i++)
{
g_value_init (&value, G_PARAM_SPEC_VALUE_TYPE (procedure->args[i]));
gimp_value_array_append (args, &value);
g_value_unset (&value);
}
return args;
}
GimpValueArray *
gimp_procedure_get_return_values (GimpProcedure *procedure,
gboolean success,
const GError *error)
{
GimpValueArray *args;
GValue value = { 0, };
gint i;
g_return_val_if_fail (success == FALSE || GIMP_IS_PROCEDURE (procedure),
NULL);
if (success)
{
args = gimp_value_array_new (procedure->num_values + 1);
g_value_init (&value, GIMP_TYPE_PDB_STATUS_TYPE);
g_value_set_enum (&value, GIMP_PDB_SUCCESS);
gimp_value_array_append (args, &value);
g_value_unset (&value);
replace the value union by a GValue. 2006-03-30 Michael Natterer <mitch@gimp.org> * app/pdb/procedural_db.[ch] (struct Argument): replace the value union by a GValue. (procedural_db_argument_init) (procedural_db_compat_arg_init): new functions to initialize an Argument. They call g_value_init() on the Argument's value. (procedural_db_arguments) (procedural_db_return_values): initialize the returned Argument arrays so their GValues are ready to use. Allow to get the (unsuccessful) return values of a NULL ProcRecord. (procedural_db_destroy_args): g_value_unset() the values. Added a "gboolean full_destroy" parameter. Its only effect is to destroy PDB arrays, everything else is nicely memory managed by GValue. (procedural_db_execute) (procedural_db_run_proc): do GValue stuff. Added n_args and n_return_vals parameters to execute(). (procedural_db_execute_proc): private function to execute a procedure. Validates the passed in arguments using the registered GParamSpecs before passing them to the resp. exec method. * app/plug-in/plug-in-params.[ch] (plug_in_params_to_args): needs an array of ProcArgs now in order to initialize the Arguments' GValues correctly. Passing NULL ProcArgs uses procedural_db_compat_arg_init(), so procedures (plug-ins) returning more values than expected work. (plug_in_args_to_params): do GValue stuff here too. (plug_in_args_destroy): removed this function, procedural_db_destroy_args() does the same now. * app/plug-in/plug-in-message.c (plug_in_handle_proc_run): simplified quite a bit because everything returns n_return_values now. Call plug_in_params_to_args() only of the procedure was found. (plug_in_handle_proc_return_priv): pass ProcRecs to plug_in_params_to_args(). * app/batch.c * app/actions/plug-in-commands.c * app/actions/vectors-commands.c * app/core/gimppdbprogress.c * app/dialogs/about-dialog.c * app/file/file-open.c * app/file/file-save.c * app/plug-in/plug-ins.c * app/plug-in/plug-in-progress.c * app/plug-in/plug-in-run.[ch] * app/widgets/gimphelp.c * app/widgets/gimppdbdialog.c * app/xcf/xcf.c * tools/pdbgen/pdb/fileops.pdb: changed accordingly: don't g_new/g_free Argument arrays, always use procedural_db_foo() functions. Use GValue functions to get/set Arguments. * tools/pdbgen/pdb.pl: added get_value_func and set_value_func to all PDB types. Removed id_func, id_ret_func and check_func. Added flags which indicated that a type is an ID. Removed unused utility functions. * tools/pdbgen/lib.pl: use the flag instead of looking at functions and value types. * tools/pdbgen/app.pl: use the get_value_func and set_value_func to marshal inargs and outargs. Removed all checks performed on inargs because that's done by GParamSpec validation now. Added the missing bits to register excluded values with GimpParamSpecEnum. * app/pdb/*_cmds.c: regenerated.
2006-03-30 07:56:07 +08:00
for (i = 0; i < procedure->num_values; i++)
{
g_value_init (&value, G_PARAM_SPEC_VALUE_TYPE (procedure->values[i]));
gimp_value_array_append (args, &value);
g_value_unset (&value);
}
}
replace the value union by a GValue. 2006-03-30 Michael Natterer <mitch@gimp.org> * app/pdb/procedural_db.[ch] (struct Argument): replace the value union by a GValue. (procedural_db_argument_init) (procedural_db_compat_arg_init): new functions to initialize an Argument. They call g_value_init() on the Argument's value. (procedural_db_arguments) (procedural_db_return_values): initialize the returned Argument arrays so their GValues are ready to use. Allow to get the (unsuccessful) return values of a NULL ProcRecord. (procedural_db_destroy_args): g_value_unset() the values. Added a "gboolean full_destroy" parameter. Its only effect is to destroy PDB arrays, everything else is nicely memory managed by GValue. (procedural_db_execute) (procedural_db_run_proc): do GValue stuff. Added n_args and n_return_vals parameters to execute(). (procedural_db_execute_proc): private function to execute a procedure. Validates the passed in arguments using the registered GParamSpecs before passing them to the resp. exec method. * app/plug-in/plug-in-params.[ch] (plug_in_params_to_args): needs an array of ProcArgs now in order to initialize the Arguments' GValues correctly. Passing NULL ProcArgs uses procedural_db_compat_arg_init(), so procedures (plug-ins) returning more values than expected work. (plug_in_args_to_params): do GValue stuff here too. (plug_in_args_destroy): removed this function, procedural_db_destroy_args() does the same now. * app/plug-in/plug-in-message.c (plug_in_handle_proc_run): simplified quite a bit because everything returns n_return_values now. Call plug_in_params_to_args() only of the procedure was found. (plug_in_handle_proc_return_priv): pass ProcRecs to plug_in_params_to_args(). * app/batch.c * app/actions/plug-in-commands.c * app/actions/vectors-commands.c * app/core/gimppdbprogress.c * app/dialogs/about-dialog.c * app/file/file-open.c * app/file/file-save.c * app/plug-in/plug-ins.c * app/plug-in/plug-in-progress.c * app/plug-in/plug-in-run.[ch] * app/widgets/gimphelp.c * app/widgets/gimppdbdialog.c * app/xcf/xcf.c * tools/pdbgen/pdb/fileops.pdb: changed accordingly: don't g_new/g_free Argument arrays, always use procedural_db_foo() functions. Use GValue functions to get/set Arguments. * tools/pdbgen/pdb.pl: added get_value_func and set_value_func to all PDB types. Removed id_func, id_ret_func and check_func. Added flags which indicated that a type is an ID. Removed unused utility functions. * tools/pdbgen/lib.pl: use the flag instead of looking at functions and value types. * tools/pdbgen/app.pl: use the get_value_func and set_value_func to marshal inargs and outargs. Removed all checks performed on inargs because that's done by GParamSpec validation now. Added the missing bits to register excluded values with GimpParamSpecEnum. * app/pdb/*_cmds.c: regenerated.
2006-03-30 07:56:07 +08:00
else
{
args = gimp_value_array_new ((error && error->message) ? 2 : 1);
g_value_init (&value, GIMP_TYPE_PDB_STATUS_TYPE);
/* errors in the GIMP_PDB_ERROR domain are calling errors */
if (error && error->domain == GIMP_PDB_ERROR)
{
switch ((GimpPdbErrorCode) error->code)
{
case GIMP_PDB_ERROR_FAILED:
case GIMP_PDB_ERROR_PROCEDURE_NOT_FOUND:
case GIMP_PDB_ERROR_INVALID_ARGUMENT:
case GIMP_PDB_ERROR_INVALID_RETURN_VALUE:
case GIMP_PDB_ERROR_INTERNAL_ERROR:
g_value_set_enum (&value, GIMP_PDB_CALLING_ERROR);
break;
case GIMP_PDB_ERROR_CANCELLED:
g_value_set_enum (&value, GIMP_PDB_CANCEL);
break;
default:
g_assert_not_reached ();
}
}
else
{
g_value_set_enum (&value, GIMP_PDB_EXECUTION_ERROR);
}
1997-11-25 06:05:25 +08:00
gimp_value_array_append (args, &value);
g_value_unset (&value);
if (error && error->message)
{
g_value_init (&value, G_TYPE_STRING);
g_value_set_string (&value, error->message);
gimp_value_array_append (args, &value);
g_value_unset (&value);
}
}
1997-11-25 06:05:25 +08:00
return args;
1997-11-25 06:05:25 +08:00
}
void
added a shitload of new GTypes and corresponding GParamSpecs to use them 2006-04-03 Michael Natterer <mitch@gimp.org> * app/core/gimpparamspecs.[ch]: added a shitload of new GTypes and corresponding GParamSpecs to use them as PDB arguments. Each GimpPDBArgType has one or more corresponding GTypes in the core now. * app/pdb/gimpargument.[ch] (struct GimpArgument) (struct GimpArgumentSpec): removed "value" member because the GValue's/GParamSpec's GType carries just as much information now. (gimp_argument_type_to_pdb_arg_type): new function which maps GTypes to GimpPDBArgType. (gimp_pdb_arg_type_to_string): formerly known as procedural_db_type_name(). * app/pdb/gimpprocedure.[ch] * app/pdb/procedural_db.[ch]: completely switch to GValue. Use the new GParamSpecs for procedure arguments. GimpPDBArgType is only used for adding compat args/values of plug-in procedures. (procedural_db_run_proc): the va_list expects a sequence of (GType, value, GType, value, ..., G_TYPE_NONE) now. * app/plug-in/plug-in-params.[ch]: changed accordingly. (plug_in_param_defs_check): removed this function. * app/plug-in/plug-in-message.c (plug_in_handle_proc_install): use plug_in_proc_args_check() instead and initialize the GimpProcedure before doing so. * tools/pdbgen/app.pl * tools/pdbgen/pdb.pl: use the new param spec types and their utility functions. Changed argument/value registration accordingly. * app/pdb/procedural-db-query.c * app/actions/plug-in-commands.c * app/actions/vectors-commands.c * app/core/gimppdbprogress.c * app/dialogs/about-dialog.c * app/file/file-open.c * app/file/file-save.c * app/plug-in/plug-in-progress.c * app/plug-in/plug-in-rc.c * app/plug-in/plug-ins.c * app/widgets/gimpbrushselect.c * app/widgets/gimpfontselect.c * app/widgets/gimpgradientselect.c * app/widgets/gimphelp.c * app/widgets/gimppaletteselect.c * app/widgets/gimppatternselect.c * tools/pdbgen/pdb/fileops.pdb * tools/pdbgen/pdb/image.pdb * tools/pdbgen/pdb/procedural_db.pdb: changed accordingly. * app/pdb/*_cmds.c: regenerated.
2006-04-04 04:54:55 +08:00
gimp_procedure_add_argument (GimpProcedure *procedure,
GParamSpec *pspec)
{
g_return_if_fail (GIMP_IS_PROCEDURE (procedure));
g_return_if_fail (G_IS_PARAM_SPEC (pspec));
app/plug-in/Makefile.am app/plug-in/plug-in-types.h removed... 2006-04-06 Michael Natterer <mitch@gimp.org> * app/plug-in/Makefile.am * app/plug-in/plug-in-types.h * app/plug-in/plug-in-proc-def.[ch]: removed... * app/pdb/Makefile.am * app/pdb/pdb-types.h * app/pdb/gimppluginprocedure.[ch]: ...and added here. Virtualized get_progname(). * app/pdb/gimptemporaryprocedure.[ch]: new class derived from GimpPlugInProcedure. * app/pdb/gimpprocedure.[ch] (struct GimpProcedure): remove union exec_method and all the structs it needed. Procedure execution is properly virtualized now. Removed gimp_procedure_initialize() and grow the args and values arrays dynamically in gimp_procedure_add_argument()/return_value(). Added marshal_func parameter to gimp_procedure_new(). * app/actions/plug-in-actions.c * app/actions/plug-in-commands.c * app/core/gimp-gui.c * app/dialogs/file-save-dialog.c * app/file/file-open.c * app/file/file-save.c * app/file/file-utils.c * app/gui/gui-vtable.c * app/menus/plug-in-menus.c * app/plug-in/plug-in-def.c * app/plug-in/plug-in-message.c * app/plug-in/plug-in-progress.c * app/plug-in/plug-in-rc.c * app/plug-in/plug-in-run.c * app/plug-in/plug-in.c * app/plug-in/plug-ins-query.c * app/plug-in/plug-ins.c * app/widgets/gimpfiledialog.c * app/widgets/gimpfileprocview.c * app/widgets/gimppluginaction.c * app/xcf/xcf.c * tools/pdbgen/pdb/fileops.pdb * tools/pdbgen/pdb/plug_in.pdb * tools/pdbgen/app.pl: changed accordingly. * app/pdb/*_cmds.c: regenerated. * app/pdb/gimp-pdb.c: added uglyness to make the app link again.
2006-04-06 18:01:30 +08:00
procedure->args = g_renew (GParamSpec *, procedure->args,
procedure->num_args + 1);
app/plug-in/Makefile.am app/plug-in/plug-in-types.h removed... 2006-04-06 Michael Natterer <mitch@gimp.org> * app/plug-in/Makefile.am * app/plug-in/plug-in-types.h * app/plug-in/plug-in-proc-def.[ch]: removed... * app/pdb/Makefile.am * app/pdb/pdb-types.h * app/pdb/gimppluginprocedure.[ch]: ...and added here. Virtualized get_progname(). * app/pdb/gimptemporaryprocedure.[ch]: new class derived from GimpPlugInProcedure. * app/pdb/gimpprocedure.[ch] (struct GimpProcedure): remove union exec_method and all the structs it needed. Procedure execution is properly virtualized now. Removed gimp_procedure_initialize() and grow the args and values arrays dynamically in gimp_procedure_add_argument()/return_value(). Added marshal_func parameter to gimp_procedure_new(). * app/actions/plug-in-actions.c * app/actions/plug-in-commands.c * app/core/gimp-gui.c * app/dialogs/file-save-dialog.c * app/file/file-open.c * app/file/file-save.c * app/file/file-utils.c * app/gui/gui-vtable.c * app/menus/plug-in-menus.c * app/plug-in/plug-in-def.c * app/plug-in/plug-in-message.c * app/plug-in/plug-in-progress.c * app/plug-in/plug-in-rc.c * app/plug-in/plug-in-run.c * app/plug-in/plug-in.c * app/plug-in/plug-ins-query.c * app/plug-in/plug-ins.c * app/widgets/gimpfiledialog.c * app/widgets/gimpfileprocview.c * app/widgets/gimppluginaction.c * app/xcf/xcf.c * tools/pdbgen/pdb/fileops.pdb * tools/pdbgen/pdb/plug_in.pdb * tools/pdbgen/app.pl: changed accordingly. * app/pdb/*_cmds.c: regenerated. * app/pdb/gimp-pdb.c: added uglyness to make the app link again.
2006-04-06 18:01:30 +08:00
procedure->args[procedure->num_args] = pspec;
g_param_spec_ref_sink (pspec);
app/plug-in/Makefile.am app/plug-in/plug-in-types.h removed... 2006-04-06 Michael Natterer <mitch@gimp.org> * app/plug-in/Makefile.am * app/plug-in/plug-in-types.h * app/plug-in/plug-in-proc-def.[ch]: removed... * app/pdb/Makefile.am * app/pdb/pdb-types.h * app/pdb/gimppluginprocedure.[ch]: ...and added here. Virtualized get_progname(). * app/pdb/gimptemporaryprocedure.[ch]: new class derived from GimpPlugInProcedure. * app/pdb/gimpprocedure.[ch] (struct GimpProcedure): remove union exec_method and all the structs it needed. Procedure execution is properly virtualized now. Removed gimp_procedure_initialize() and grow the args and values arrays dynamically in gimp_procedure_add_argument()/return_value(). Added marshal_func parameter to gimp_procedure_new(). * app/actions/plug-in-actions.c * app/actions/plug-in-commands.c * app/core/gimp-gui.c * app/dialogs/file-save-dialog.c * app/file/file-open.c * app/file/file-save.c * app/file/file-utils.c * app/gui/gui-vtable.c * app/menus/plug-in-menus.c * app/plug-in/plug-in-def.c * app/plug-in/plug-in-message.c * app/plug-in/plug-in-progress.c * app/plug-in/plug-in-rc.c * app/plug-in/plug-in-run.c * app/plug-in/plug-in.c * app/plug-in/plug-ins-query.c * app/plug-in/plug-ins.c * app/widgets/gimpfiledialog.c * app/widgets/gimpfileprocview.c * app/widgets/gimppluginaction.c * app/xcf/xcf.c * tools/pdbgen/pdb/fileops.pdb * tools/pdbgen/pdb/plug_in.pdb * tools/pdbgen/app.pl: changed accordingly. * app/pdb/*_cmds.c: regenerated. * app/pdb/gimp-pdb.c: added uglyness to make the app link again.
2006-04-06 18:01:30 +08:00
procedure->num_args++;
}
void
added a shitload of new GTypes and corresponding GParamSpecs to use them 2006-04-03 Michael Natterer <mitch@gimp.org> * app/core/gimpparamspecs.[ch]: added a shitload of new GTypes and corresponding GParamSpecs to use them as PDB arguments. Each GimpPDBArgType has one or more corresponding GTypes in the core now. * app/pdb/gimpargument.[ch] (struct GimpArgument) (struct GimpArgumentSpec): removed "value" member because the GValue's/GParamSpec's GType carries just as much information now. (gimp_argument_type_to_pdb_arg_type): new function which maps GTypes to GimpPDBArgType. (gimp_pdb_arg_type_to_string): formerly known as procedural_db_type_name(). * app/pdb/gimpprocedure.[ch] * app/pdb/procedural_db.[ch]: completely switch to GValue. Use the new GParamSpecs for procedure arguments. GimpPDBArgType is only used for adding compat args/values of plug-in procedures. (procedural_db_run_proc): the va_list expects a sequence of (GType, value, GType, value, ..., G_TYPE_NONE) now. * app/plug-in/plug-in-params.[ch]: changed accordingly. (plug_in_param_defs_check): removed this function. * app/plug-in/plug-in-message.c (plug_in_handle_proc_install): use plug_in_proc_args_check() instead and initialize the GimpProcedure before doing so. * tools/pdbgen/app.pl * tools/pdbgen/pdb.pl: use the new param spec types and their utility functions. Changed argument/value registration accordingly. * app/pdb/procedural-db-query.c * app/actions/plug-in-commands.c * app/actions/vectors-commands.c * app/core/gimppdbprogress.c * app/dialogs/about-dialog.c * app/file/file-open.c * app/file/file-save.c * app/plug-in/plug-in-progress.c * app/plug-in/plug-in-rc.c * app/plug-in/plug-ins.c * app/widgets/gimpbrushselect.c * app/widgets/gimpfontselect.c * app/widgets/gimpgradientselect.c * app/widgets/gimphelp.c * app/widgets/gimppaletteselect.c * app/widgets/gimppatternselect.c * tools/pdbgen/pdb/fileops.pdb * tools/pdbgen/pdb/image.pdb * tools/pdbgen/pdb/procedural_db.pdb: changed accordingly. * app/pdb/*_cmds.c: regenerated.
2006-04-04 04:54:55 +08:00
gimp_procedure_add_return_value (GimpProcedure *procedure,
GParamSpec *pspec)
{
g_return_if_fail (GIMP_IS_PROCEDURE (procedure));
g_return_if_fail (G_IS_PARAM_SPEC (pspec));
app/plug-in/Makefile.am app/plug-in/plug-in-types.h removed... 2006-04-06 Michael Natterer <mitch@gimp.org> * app/plug-in/Makefile.am * app/plug-in/plug-in-types.h * app/plug-in/plug-in-proc-def.[ch]: removed... * app/pdb/Makefile.am * app/pdb/pdb-types.h * app/pdb/gimppluginprocedure.[ch]: ...and added here. Virtualized get_progname(). * app/pdb/gimptemporaryprocedure.[ch]: new class derived from GimpPlugInProcedure. * app/pdb/gimpprocedure.[ch] (struct GimpProcedure): remove union exec_method and all the structs it needed. Procedure execution is properly virtualized now. Removed gimp_procedure_initialize() and grow the args and values arrays dynamically in gimp_procedure_add_argument()/return_value(). Added marshal_func parameter to gimp_procedure_new(). * app/actions/plug-in-actions.c * app/actions/plug-in-commands.c * app/core/gimp-gui.c * app/dialogs/file-save-dialog.c * app/file/file-open.c * app/file/file-save.c * app/file/file-utils.c * app/gui/gui-vtable.c * app/menus/plug-in-menus.c * app/plug-in/plug-in-def.c * app/plug-in/plug-in-message.c * app/plug-in/plug-in-progress.c * app/plug-in/plug-in-rc.c * app/plug-in/plug-in-run.c * app/plug-in/plug-in.c * app/plug-in/plug-ins-query.c * app/plug-in/plug-ins.c * app/widgets/gimpfiledialog.c * app/widgets/gimpfileprocview.c * app/widgets/gimppluginaction.c * app/xcf/xcf.c * tools/pdbgen/pdb/fileops.pdb * tools/pdbgen/pdb/plug_in.pdb * tools/pdbgen/app.pl: changed accordingly. * app/pdb/*_cmds.c: regenerated. * app/pdb/gimp-pdb.c: added uglyness to make the app link again.
2006-04-06 18:01:30 +08:00
procedure->values = g_renew (GParamSpec *, procedure->values,
procedure->num_values + 1);
app/plug-in/Makefile.am app/plug-in/plug-in-types.h removed... 2006-04-06 Michael Natterer <mitch@gimp.org> * app/plug-in/Makefile.am * app/plug-in/plug-in-types.h * app/plug-in/plug-in-proc-def.[ch]: removed... * app/pdb/Makefile.am * app/pdb/pdb-types.h * app/pdb/gimppluginprocedure.[ch]: ...and added here. Virtualized get_progname(). * app/pdb/gimptemporaryprocedure.[ch]: new class derived from GimpPlugInProcedure. * app/pdb/gimpprocedure.[ch] (struct GimpProcedure): remove union exec_method and all the structs it needed. Procedure execution is properly virtualized now. Removed gimp_procedure_initialize() and grow the args and values arrays dynamically in gimp_procedure_add_argument()/return_value(). Added marshal_func parameter to gimp_procedure_new(). * app/actions/plug-in-actions.c * app/actions/plug-in-commands.c * app/core/gimp-gui.c * app/dialogs/file-save-dialog.c * app/file/file-open.c * app/file/file-save.c * app/file/file-utils.c * app/gui/gui-vtable.c * app/menus/plug-in-menus.c * app/plug-in/plug-in-def.c * app/plug-in/plug-in-message.c * app/plug-in/plug-in-progress.c * app/plug-in/plug-in-rc.c * app/plug-in/plug-in-run.c * app/plug-in/plug-in.c * app/plug-in/plug-ins-query.c * app/plug-in/plug-ins.c * app/widgets/gimpfiledialog.c * app/widgets/gimpfileprocview.c * app/widgets/gimppluginaction.c * app/xcf/xcf.c * tools/pdbgen/pdb/fileops.pdb * tools/pdbgen/pdb/plug_in.pdb * tools/pdbgen/app.pl: changed accordingly. * app/pdb/*_cmds.c: regenerated. * app/pdb/gimp-pdb.c: added uglyness to make the app link again.
2006-04-06 18:01:30 +08:00
procedure->values[procedure->num_values] = pspec;
g_param_spec_ref_sink (pspec);
app/plug-in/Makefile.am app/plug-in/plug-in-types.h removed... 2006-04-06 Michael Natterer <mitch@gimp.org> * app/plug-in/Makefile.am * app/plug-in/plug-in-types.h * app/plug-in/plug-in-proc-def.[ch]: removed... * app/pdb/Makefile.am * app/pdb/pdb-types.h * app/pdb/gimppluginprocedure.[ch]: ...and added here. Virtualized get_progname(). * app/pdb/gimptemporaryprocedure.[ch]: new class derived from GimpPlugInProcedure. * app/pdb/gimpprocedure.[ch] (struct GimpProcedure): remove union exec_method and all the structs it needed. Procedure execution is properly virtualized now. Removed gimp_procedure_initialize() and grow the args and values arrays dynamically in gimp_procedure_add_argument()/return_value(). Added marshal_func parameter to gimp_procedure_new(). * app/actions/plug-in-actions.c * app/actions/plug-in-commands.c * app/core/gimp-gui.c * app/dialogs/file-save-dialog.c * app/file/file-open.c * app/file/file-save.c * app/file/file-utils.c * app/gui/gui-vtable.c * app/menus/plug-in-menus.c * app/plug-in/plug-in-def.c * app/plug-in/plug-in-message.c * app/plug-in/plug-in-progress.c * app/plug-in/plug-in-rc.c * app/plug-in/plug-in-run.c * app/plug-in/plug-in.c * app/plug-in/plug-ins-query.c * app/plug-in/plug-ins.c * app/widgets/gimpfiledialog.c * app/widgets/gimpfileprocview.c * app/widgets/gimppluginaction.c * app/xcf/xcf.c * tools/pdbgen/pdb/fileops.pdb * tools/pdbgen/pdb/plug_in.pdb * tools/pdbgen/app.pl: changed accordingly. * app/pdb/*_cmds.c: regenerated. * app/pdb/gimp-pdb.c: added uglyness to make the app link again.
2006-04-06 18:01:30 +08:00
procedure->num_values++;
}
/**
* gimp_procedure_create_override:
* @procedure:
* @new_marshal_func:
*
* Creates a new GimpProcedure that can be used to override the
* existing @procedure.
*
* Returns: The new #GimpProcedure.
**/
GimpProcedure *
gimp_procedure_create_override (GimpProcedure *procedure,
GimpMarshalFunc new_marshal_func)
{
GimpProcedure *new_procedure = NULL;
const gchar *name = NULL;
int i = 0;
new_procedure = gimp_procedure_new (new_marshal_func);
name = gimp_object_get_name (procedure);
gimp_object_set_static_name (GIMP_OBJECT (new_procedure), name);
for (i = 0; i < procedure->num_args; i++)
gimp_procedure_add_argument (new_procedure, procedure->args[i]);
for (i = 0; i < procedure->num_values; i++)
gimp_procedure_add_return_value (new_procedure, procedure->values[i]);
return new_procedure;
}
2011-05-05 06:08:37 +08:00
gint
gimp_procedure_name_compare (GimpProcedure *proc1,
GimpProcedure *proc2)
{
/* Assume there always is a name, don't bother with NULL checks */
return strcmp (proc1->original_name,
proc2->original_name);
}
/* private functions */
static void
gimp_procedure_free_strings (GimpProcedure *procedure)
{
if (! procedure->static_strings)
{
g_free (procedure->original_name);
g_free (procedure->blurb);
g_free (procedure->help);
g_free (procedure->author);
g_free (procedure->copyright);
g_free (procedure->date);
g_free (procedure->deprecated);
}
procedure->original_name = NULL;
procedure->blurb = NULL;
procedure->help = NULL;
procedure->author = NULL;
procedure->copyright = NULL;
procedure->date = NULL;
procedure->deprecated = NULL;
procedure->static_strings = FALSE;
}
static gboolean
gimp_procedure_validate_args (GimpProcedure *procedure,
GParamSpec **param_specs,
gint n_param_specs,
GimpValueArray *args,
gboolean return_vals,
GError **error)
{
gint i;
for (i = 0; i < MIN (gimp_value_array_length (args), n_param_specs); i++)
{
GValue *arg = gimp_value_array_index (args, i);
GParamSpec *pspec = param_specs[i];
GType arg_type = G_VALUE_TYPE (arg);
GType spec_type = G_PARAM_SPEC_VALUE_TYPE (pspec);
if (arg_type != spec_type)
{
if (return_vals)
{
g_set_error (error,
GIMP_PDB_ERROR, GIMP_PDB_ERROR_INVALID_RETURN_VALUE,
_("Procedure '%s' returned a wrong value type "
"for return value '%s' (#%d). "
"Expected %s, got %s."),
gimp_object_get_name (procedure),
g_param_spec_get_name (pspec),
i + 1, g_type_name (spec_type),
g_type_name (arg_type));
}
else
{
g_set_error (error,
GIMP_PDB_ERROR, GIMP_PDB_ERROR_INVALID_ARGUMENT,
_("Procedure '%s' has been called with a "
"wrong value type for argument '%s' (#%d). "
"Expected %s, got %s."),
gimp_object_get_name (procedure),
g_param_spec_get_name (pspec),
i + 1, g_type_name (spec_type),
g_type_name (arg_type));
}
return FALSE;
}
else if (! (pspec->flags & GIMP_PARAM_NO_VALIDATE))
{
GValue string_value = { 0, };
g_value_init (&string_value, G_TYPE_STRING);
if (g_value_type_transformable (arg_type, G_TYPE_STRING))
g_value_transform (arg, &string_value);
else
g_value_set_static_string (&string_value,
"<not transformable to string>");
if (g_param_value_validate (pspec, arg))
{
if (GIMP_IS_PARAM_SPEC_DRAWABLE_ID (pspec) &&
g_value_get_int (arg) == -1)
{
if (return_vals)
{
g_set_error (error,
GIMP_PDB_ERROR,
GIMP_PDB_ERROR_INVALID_RETURN_VALUE,
_("Procedure '%s' returned an "
"invalid ID for argument '%s'. "
"Most likely a plug-in is trying "
"to work on a layer that doesn't "
"exist any longer."),
gimp_object_get_name (procedure),
g_param_spec_get_name (pspec));
}
else
{
g_set_error (error,
GIMP_PDB_ERROR,
GIMP_PDB_ERROR_INVALID_ARGUMENT,
_("Procedure '%s' has been called with an "
"invalid ID for argument '%s'. "
"Most likely a plug-in is trying "
"to work on a layer that doesn't "
"exist any longer."),
gimp_object_get_name (procedure),
g_param_spec_get_name (pspec));
}
}
else if (GIMP_IS_PARAM_SPEC_IMAGE_ID (pspec) &&
g_value_get_int (arg) == -1)
{
if (return_vals)
{
g_set_error (error,
GIMP_PDB_ERROR,
GIMP_PDB_ERROR_INVALID_RETURN_VALUE,
_("Procedure '%s' returned an "
"invalid ID for argument '%s'. "
"Most likely a plug-in is trying "
"to work on an image that doesn't "
"exist any longer."),
gimp_object_get_name (procedure),
g_param_spec_get_name (pspec));
}
else
{
g_set_error (error,
GIMP_PDB_ERROR,
GIMP_PDB_ERROR_INVALID_ARGUMENT,
_("Procedure '%s' has been called with an "
"invalid ID for argument '%s'. "
"Most likely a plug-in is trying "
"to work on an image that doesn't "
"exist any longer."),
gimp_object_get_name (procedure),
g_param_spec_get_name (pspec));
}
}
else
{
const gchar *value = g_value_get_string (&string_value);
if (value == NULL)
value = "(null)";
if (return_vals)
{
g_set_error (error,
GIMP_PDB_ERROR,
GIMP_PDB_ERROR_INVALID_RETURN_VALUE,
_("Procedure '%s' returned "
"'%s' as return value '%s' "
"(#%d, type %s). "
"This value is out of range."),
gimp_object_get_name (procedure),
value,
g_param_spec_get_name (pspec),
i + 1, g_type_name (spec_type));
}
else
{
g_set_error (error,
GIMP_PDB_ERROR,
GIMP_PDB_ERROR_INVALID_ARGUMENT,
_("Procedure '%s' has been called with "
"value '%s' for argument '%s' "
"(#%d, type %s). "
"This value is out of range."),
gimp_object_get_name (procedure),
value,
g_param_spec_get_name (pspec),
i + 1, g_type_name (spec_type));
}
}
2012-02-07 21:06:12 +08:00
g_value_unset (&string_value);
return FALSE;
}
g_value_unset (&string_value);
}
}
return TRUE;
}