gimp/app/pdb/plug_in_cmds.c
Michael Natterer 05e15eb1cc Cleanup weekend...
2001-10-29  Michael Natterer  <mitch@gimp.org>

	Cleanup weekend...

	* app/app_procs.c: pass "no_interface" to gimp_new().

	* app/core/gimp.[ch]: added "gboolean no_interface" and the
	load_procs and save_procs GSLists.

	* app/core/gimptoolinfo.[ch]: added a "Gimp" pointer to the
	GimpToolInfo object so more functions find their context without
	accessing the global "the_gimp" variable.

	* app/display/display-types.h: removed the GDisplay -> GimpDisplay
	typedef.

	* app/display/gimpdisplay.c: look at gimp->no_interface, don't
	include "appenv.h".

	* app/file/file-open.[ch]
	* app/file/file-save.[ch]: don't use "the_gimp" any more. Instead,
	pass around lots of "Gimp" pointers. Removed the global load_procs
	and save_procs variables here. Use access() to find out whether a
	file is readable/writable, removed the manual voodoo and it's
	Win32 wrappers. Added an optional (can be NULL) "PlunInProcDef"
	parameter to file_save(), removed file_save_with_proc().

	* app/gui/menus.c: Use the unused "gpointer data" parameter of the
	GtkItemFactory callbacks to pass a "Gimp" pointer to all of them.
	This reduces the usage of the global "the_gimp" hack to zero
	in app/gui/... yeah.

	* app/gui/channels-commands.c
	* app/gui/edit-commands.c
	* app/gui/file-commands.c
	* app/gui/image-commands.c
	* app/gui/layers-commands.c
	* app/gui/palettes-commands.c
	* app/gui/select-commands.c
	* app/gui/test-commands.c
	* app/gui/tools-commands.c
	* app/gui/view-commands.c: use the passed "Gimp" pointer.

	* app/gui/color-area.[ch]
	* app/gui/convert-dialog.c
	* app/gui/dialogs-constructors.c
	* app/gui/file-new-dialog.[ch]
	* app/gui/file-open-dialog.[ch]
	* app/gui/file-save-dialog.[ch]
	* app/gui/gui.c
	* app/gui/info-window.[ch]
	* app/gui/module-browser.[ch]
	* app/gui/palette-editor.c
	* app/gui/palette-import-dialog.[ch]
	* app/gui/paths-dialog.c
	* app/gui/preferences-dialog.[ch]
	* app/gui/resize-dialog.[ch]
	* app/gui/tool-options-dialog.[ch]
	* app/gui/toolbox.c: pass around lots more "Gimp" and
	"GimpContext" pointers and don't use "the_gimp" any more.

	* app/tools/gimptool.h: added a pointer to the corresponding
	GimpToolInfo object (which in turn has a pointer to a Gimp).

	* app/tools/tool_manager.[ch]: set the pointer after creating the
	tool object. Removed tool_manager_get_info_by_tool() as there is a
	tool->tool_info pointer now.

	* app/tools/gimpbezierselecttool.c
	* app/tools/gimpblendtool.c
	* app/tools/gimpbrightnesscontrasttool.c
	* app/tools/gimpclonetool.c
	* app/tools/gimpcolorbalancetool.c
	* app/tools/gimpcolorpickertool.c
	* app/tools/gimpconvolvetool.c
	* app/tools/gimpcroptool.c
	* app/tools/gimpcurvestool.c
	* app/tools/gimpdodgeburntool.c
	* app/tools/gimpdrawtool.c
	* app/tools/gimpeditselectiontool.c
	* app/tools/gimpellipseselecttool.c
	* app/tools/gimperasertool.c
	* app/tools/gimpfliptool.c
	* app/tools/gimphistogramtool.c
	* app/tools/gimphuesaturationtool.c
	* app/tools/gimpinktool.c
	* app/tools/gimplevelstool.c
	* app/tools/gimpmagnifytool.c
	* app/tools/gimpmeasuretool.c
	* app/tools/gimpmovetool.c
	* app/tools/gimppainttool.c
	* app/tools/gimppathtool.c
	* app/tools/gimpperspectivetool.c
	* app/tools/gimpposterizetool.c
	* app/tools/gimprectselecttool.c
	* app/tools/gimprotatetool.c
	* app/tools/gimpscaletool.c
	* app/tools/gimpsheartool.c
	* app/tools/gimptexttool.c
	* app/tools/gimpthresholdtool.c
	* app/tools/path_tool.c
	* app/tools/xinput_airbrush.c: s/GDisplay/GimpDisplay/g.
	Use tool->tool_info and tool_info->gimp in some places to get
	rid of using "the_gimp".

	Removing the remaining ones involves changing the tool options
	system and is scheduled next...

	* app/widgets/gimpdnd.c
	* app/widgets/gimpdocumentview.c: pass a "Gimp" pointer to all
	file_open_*() functions.

	* app/gdisplay_color.[ch]
	* app/gdisplay_color_ui.[ch]
	* app/image_map.[ch]
	* app/nav_window.[ch]
	* app/path.c
	* app/path_bezier.c
	* app/path_transform.h
	* app/qmask.[ch]: s/GDisplay/GimpDisplay/g

	* tools/pdbgen/pdb/fileops.pdb: load_procs and save_procs are
	members of the "Gimp" object now.

	* tools/pdbgen/pdb/plug_in.pdb: use gimp->no_interface, don't
	include "appenv.h".

	* app/pdb/fileops_cmds.c
	* app/pdb/plug_in_cmds.c: regenerated.
2001-10-29 11:47:11 +00:00

525 lines
13 KiB
C

/* The GIMP -- an image manipulation program
* Copyright (C) 1995-2000 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* NOTE: This file is autogenerated by pdbgen.pl. */
#include "config.h"
#include <stdlib.h>
#include <string.h>
#include <glib-object.h>
#include "libgimpbase/gimpbasetypes.h"
#include "pdb-types.h"
#include "procedural_db.h"
#include "core/gimp.h"
#include "plug_in.h"
#ifdef HAVE_GLIBC_REGEX
#include <regex.h>
#else
#include "regexrepl/regex.h"
#endif
static ProcRecord progress_init_proc;
static ProcRecord progress_update_proc;
static ProcRecord temp_PDB_name_proc;
static ProcRecord plugins_query_proc;
static ProcRecord plugin_domain_register_proc;
static ProcRecord plugin_help_register_proc;
void
register_plug_in_procs (Gimp *gimp)
{
procedural_db_register (gimp, &progress_init_proc);
procedural_db_register (gimp, &progress_update_proc);
procedural_db_register (gimp, &temp_PDB_name_proc);
procedural_db_register (gimp, &plugins_query_proc);
procedural_db_register (gimp, &plugin_domain_register_proc);
procedural_db_register (gimp, &plugin_help_register_proc);
}
static int
match_strings (regex_t *preg,
gchar *a)
{
return regexec (preg, a, 0, NULL, 0);
}
static Argument *
progress_init_invoker (Gimp *gimp,
Argument *args)
{
gboolean success = FALSE;
gchar *message;
gint32 gdisplay;
message = (gchar *) args[0].value.pdb_pointer;
gdisplay = args[1].value.pdb_int;
if (current_plug_in && current_plug_in->open)
{
success = TRUE;
if (! gimp->no_interface)
plug_in_progress_init (current_plug_in, message, gdisplay);
}
return procedural_db_return_args (&progress_init_proc, success);
}
static ProcArg progress_init_inargs[] =
{
{
GIMP_PDB_STRING,
"message",
"Message to use in the progress dialog"
},
{
GIMP_PDB_INT32,
"gdisplay",
"GimpDisplay to update progressbar in, or -1 for a seperate window"
}
};
static ProcRecord progress_init_proc =
{
"gimp_progress_init",
"Initializes the progress bar for the current plug-in.",
"Initializes the progress bar for the current plug-in. It is only valid to call this procedure from a plug-in.",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996",
GIMP_INTERNAL,
2,
progress_init_inargs,
0,
NULL,
{ { progress_init_invoker } }
};
static Argument *
progress_update_invoker (Gimp *gimp,
Argument *args)
{
gboolean success = FALSE;
gdouble percentage;
percentage = args[0].value.pdb_float;
if (current_plug_in && current_plug_in->open)
{
success = TRUE;
if (! gimp->no_interface)
plug_in_progress_update (current_plug_in, percentage);
}
return procedural_db_return_args (&progress_update_proc, success);
}
static ProcArg progress_update_inargs[] =
{
{
GIMP_PDB_FLOAT,
"percentage",
"Percentage of progress completed"
}
};
static ProcRecord progress_update_proc =
{
"gimp_progress_update",
"Updates the progress bar for the current plug-in.",
"Updates the progress bar for the current plug-in. It is only valid to call this procedure from a plug-in.",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996",
GIMP_INTERNAL,
1,
progress_update_inargs,
0,
NULL,
{ { progress_update_invoker } }
};
static Argument *
temp_PDB_name_invoker (Gimp *gimp,
Argument *args)
{
Argument *return_args;
gchar *temp_name;
static gint proc_number = 0;
temp_name = g_strdup_printf ("temp_plugin_number_%d", proc_number++);
return_args = procedural_db_return_args (&temp_PDB_name_proc, TRUE);
return_args[1].value.pdb_pointer = temp_name;
return return_args;
}
static ProcArg temp_PDB_name_outargs[] =
{
{
GIMP_PDB_STRING,
"temp_name",
"A unique temporary name for a temporary PDB entry"
}
};
static ProcRecord temp_PDB_name_proc =
{
"gimp_temp_PDB_name",
"Generates a unique temporary PDB name.",
"This procedure generates a temporary PDB entry name that is guaranteed to be unique. It is many used by the interactive popup dialogs to generate a PDB entry name.",
"Andy Thomas",
"Andy Thomas",
"1998",
GIMP_INTERNAL,
0,
NULL,
1,
temp_PDB_name_outargs,
{ { temp_PDB_name_invoker } }
};
static Argument *
plugins_query_invoker (Gimp *gimp,
Argument *args)
{
Argument *return_args;
gchar *search_str;
gint32 num_plugins = 0;
gchar **menu_strs;
gchar **accel_strs;
gchar **prog_strs;
gchar **types_strs;
gint32 *time_ints;
gchar **realname_strs;
PlugInProcDef *proc_def;
GSList *tmp = NULL;
gint i = 0;
regex_t sregex;
search_str = (gchar *) args[0].value.pdb_pointer;
if (search_str && strlen (search_str))
regcomp (&sregex, search_str, REG_ICASE);
else
search_str = NULL;
/* count number of plugin entries, then allocate 4 arrays of correct size
* where we can store the strings.
*/
tmp = proc_defs;
while (tmp)
{
proc_def = tmp->data;
tmp = tmp->next;
if (proc_def->prog && proc_def->menu_path)
{
gchar *name = strrchr (proc_def->menu_path, '/');
if (name)
name = name + 1;
else
name = proc_def->menu_path;
if (search_str && match_strings (&sregex, name))
continue;
num_plugins++;
}
}
menu_strs = g_new (gchar *, num_plugins);
accel_strs = g_new (gchar *, num_plugins);
prog_strs = g_new (gchar *, num_plugins);
types_strs = g_new (gchar *, num_plugins);
realname_strs = g_new (gchar *, num_plugins);
time_ints = g_new (gint , num_plugins);
tmp = proc_defs;
while (tmp)
{
if (i > num_plugins)
g_error ("Internal error counting plugins");
proc_def = tmp->data;
tmp = tmp->next;
if (proc_def->prog && proc_def->menu_path)
{
ProcRecord *pr = &proc_def->db_info;
gchar *name = strrchr (proc_def->menu_path, '/');
if (name)
name = name + 1;
else
name = proc_def->menu_path;
if (search_str && match_strings(&sregex,name))
continue;
menu_strs[i] = g_strdup (proc_def->menu_path);
accel_strs[i] = g_strdup (proc_def->accelerator);
prog_strs[i] = g_strdup (proc_def->prog);
types_strs[i] = g_strdup (proc_def->image_types);
realname_strs[i] = g_strdup (pr->name);
time_ints[i] = proc_def->mtime;
i++;
}
}
/* This I hope frees up internal stuff */
if (search_str)
free (sregex.buffer);
return_args = procedural_db_return_args (&plugins_query_proc, TRUE);
return_args[1].value.pdb_int = num_plugins;
return_args[2].value.pdb_pointer = menu_strs;
return_args[3].value.pdb_int = num_plugins;
return_args[4].value.pdb_pointer = accel_strs;
return_args[5].value.pdb_int = num_plugins;
return_args[6].value.pdb_pointer = prog_strs;
return_args[7].value.pdb_int = num_plugins;
return_args[8].value.pdb_pointer = types_strs;
return_args[9].value.pdb_int = num_plugins;
return_args[10].value.pdb_pointer = time_ints;
return_args[11].value.pdb_int = num_plugins;
return_args[12].value.pdb_pointer = realname_strs;
return return_args;
}
static ProcArg plugins_query_inargs[] =
{
{
GIMP_PDB_STRING,
"search_string",
"If not an empty string then use this as a search pattern"
}
};
static ProcArg plugins_query_outargs[] =
{
{
GIMP_PDB_INT32,
"num_plugins",
"The number of plugins"
},
{
GIMP_PDB_STRINGARRAY,
"menu_path",
"The menu path of the plugin"
},
{
GIMP_PDB_INT32,
"num_plugins",
"The number of plugins"
},
{
GIMP_PDB_STRINGARRAY,
"plugin_accelerator",
"String representing keyboard accelerator (could be empty string)"
},
{
GIMP_PDB_INT32,
"num_plugins",
"The number of plugins"
},
{
GIMP_PDB_STRINGARRAY,
"plugin_location",
"Location of the plugin program"
},
{
GIMP_PDB_INT32,
"num_plugins",
"The number of plugins"
},
{
GIMP_PDB_STRINGARRAY,
"plugin_image_type",
"Type of image that this plugin will work on"
},
{
GIMP_PDB_INT32,
"num_plugins",
"The number of plugins"
},
{
GIMP_PDB_INT32ARRAY,
"plugin_install_time",
"Time that the plugin was installed"
},
{
GIMP_PDB_INT32,
"num_plugins",
"The number of plugins"
},
{
GIMP_PDB_STRINGARRAY,
"plugin_real_name",
"The internal name of the plugin"
}
};
static ProcRecord plugins_query_proc =
{
"gimp_plugins_query",
"Queries the plugin database for its contents.",
"This procedure queries the contents of the plugin database.",
"Andy Thomas",
"Andy Thomas",
"1998",
GIMP_INTERNAL,
1,
plugins_query_inargs,
12,
plugins_query_outargs,
{ { plugins_query_invoker } }
};
static Argument *
plugin_domain_register_invoker (Gimp *gimp,
Argument *args)
{
gboolean success = TRUE;
gchar *domain_name;
gchar *domain_path;
PlugInDef *plug_in_def;
domain_name = (gchar *) args[0].value.pdb_pointer;
if (domain_name == NULL)
success = FALSE;
domain_path = (gchar *) args[1].value.pdb_pointer;
if (success)
{
if (current_plug_in && current_plug_in->query)
{
plug_in_def = current_plug_in->user_data;
if (plug_in_def->locale_domain)
g_free (plug_in_def->locale_domain);
plug_in_def->locale_domain = g_strdup (domain_name);
if (plug_in_def->locale_path);
g_free (plug_in_def->locale_path);
plug_in_def->locale_path = domain_path ? g_strdup (domain_path) : NULL;
}
}
return procedural_db_return_args (&plugin_domain_register_proc, success);
}
static ProcArg plugin_domain_register_inargs[] =
{
{
GIMP_PDB_STRING,
"domain_name",
"The name of the textdomain (must be unique)."
},
{
GIMP_PDB_STRING,
"domain_path",
"The absolute path to the compiled message catalog (may be NULL)."
}
};
static ProcRecord plugin_domain_register_proc =
{
"gimp_plugin_domain_register",
"Registers a textdomain for localisation.",
"This procedure adds a textdomain to the list of domains Gimp searches for strings when translating its menu entries. There is no need to call this function for plug-ins that have their strings included in the gimp-std-plugins domain as that is used by default. If the compiled message catalog is not in the standard location, you may specify an absolute path to another location. This procedure can only be called in the query function of a plug-in and it has to be called before any procedure is installed.",
"Sven Neumann",
"Sven Neumann",
"2000",
GIMP_INTERNAL,
2,
plugin_domain_register_inargs,
0,
NULL,
{ { plugin_domain_register_invoker } }
};
static Argument *
plugin_help_register_invoker (Gimp *gimp,
Argument *args)
{
gboolean success = TRUE;
gchar *help_path;
PlugInDef *plug_in_def;
help_path = (gchar *) args[0].value.pdb_pointer;
if (help_path == NULL)
success = FALSE;
if (success)
{
if (current_plug_in && current_plug_in->query)
{
plug_in_def = current_plug_in->user_data;
if (plug_in_def->help_path)
g_free (plug_in_def->help_path);
plug_in_def->help_path = g_strdup (help_path);
}
}
return procedural_db_return_args (&plugin_help_register_proc, success);
}
static ProcArg plugin_help_register_inargs[] =
{
{
GIMP_PDB_STRING,
"help_path",
"The rootdir of the plug-in's help pages"
}
};
static ProcRecord plugin_help_register_proc =
{
"gimp_plugin_help_register",
"Register a help path for a plug-in.",
"This procedure changes the help rootdir for the plug-in which calls it. All subsequent calls of gimp_help from this plug-in will be interpreted relative to this rootdir. This procedure can only be called in the query function of a plug-in and it has to be called before any procedure is installed.",
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer <mitch@gimp.org>",
"2000",
GIMP_INTERNAL,
1,
plugin_help_register_inargs,
0,
NULL,
{ { plugin_help_register_invoker } }
};