added gimp_procedure_new() and gimp_procedure_free() functions.

2006-03-31  Michael Natterer  <mitch@gimp.org>

	* app/pdb/gimpprocedure.[ch]: added gimp_procedure_new() and
	gimp_procedure_free() functions.

	* app/plug-in/plug-in-proc-def.h (struct PlugInProcDef): use a
	ProcRecord pointer instead of including the entire struct.

	* app/plug-in/plug-in-proc-def.c: use the new() and free()
	functions above to allocate/free the ProcRecord.

	* app/actions/plug-in-actions.c
	* app/actions/plug-in-commands.c
	* app/menus/plug-in-menus.c
	* app/plug-in/plug-in-message.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/xcf/xcf.c: changed accordingly.

	Unrelated:

	* app/pdb/gimpprocedure.c (gimp_procedure_execute): be more verbose
	when warning about out-of-bounds parameter values.

	* tools/pdbgen/pdb/fileops.pdb: allow GIMP_RUN_WITH_LAST_VALS for
	file_save because indirect saving (e.g. remote or compressed)
	needs it.

	* app/pdb/fileops_cmds.c: regenerated.
This commit is contained in:
Michael Natterer
2006-03-31 11:49:22 +00:00
committed by Michael Natterer
parent 20a48412bc
commit 49da8cb2d1
27 changed files with 375 additions and 284 deletions

View File

@ -1,3 +1,36 @@
2006-03-31 Michael Natterer <mitch@gimp.org>
* app/pdb/gimpprocedure.[ch]: added gimp_procedure_new() and
gimp_procedure_free() functions.
* app/plug-in/plug-in-proc-def.h (struct PlugInProcDef): use a
ProcRecord pointer instead of including the entire struct.
* app/plug-in/plug-in-proc-def.c: use the new() and free()
functions above to allocate/free the ProcRecord.
* app/actions/plug-in-actions.c
* app/actions/plug-in-commands.c
* app/menus/plug-in-menus.c
* app/plug-in/plug-in-message.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/xcf/xcf.c: changed accordingly.
Unrelated:
* app/pdb/gimpprocedure.c (gimp_procedure_execute): be more verbose
when warning about out-of-bounds parameter values.
* tools/pdbgen/pdb/fileops.pdb: allow GIMP_RUN_WITH_LAST_VALS for
file_save because indirect saving (e.g. remote or compressed)
needs it.
* app/pdb/fileops_cmds.c: regenerated.
2006-03-31 Sven Neumann <sven@gimp.org> 2006-03-31 Sven Neumann <sven@gimp.org>
* app/paint-funcs/scale-funcs.c: fixed compiler warning and * app/paint-funcs/scale-funcs.c: fixed compiler warning and

View File

@ -33,6 +33,8 @@
#include "core/gimpdrawable.h" #include "core/gimpdrawable.h"
#include "core/gimpimage.h" #include "core/gimpimage.h"
#include "pdb/gimpprocedure.h"
#include "plug-in/plug-ins.h" #include "plug-in/plug-ins.h"
#include "plug-in/plug-in-proc-def.h" #include "plug-in/plug-in-proc-def.h"
@ -217,7 +219,7 @@ plug_in_actions_update (GimpActionGroup *group,
gboolean sensitive = plug_in_proc_def_get_sensitive (proc_def, type); gboolean sensitive = plug_in_proc_def_get_sensitive (proc_def, type);
gimp_action_group_set_action_sensitive (group, gimp_action_group_set_action_sensitive (group,
proc_def->db_info.name, proc_def->procedure->name,
sensitive); sensitive);
} }
} }
@ -296,10 +298,10 @@ plug_in_actions_add_proc (GimpActionGroup *group,
label = p2 + 1; label = p2 + 1;
} }
if (proc_def->db_info.blurb) if (proc_def->procedure->blurb)
tooltip = dgettext (locale_domain, proc_def->db_info.blurb); tooltip = dgettext (locale_domain, proc_def->procedure->blurb);
entry.name = proc_def->db_info.name; entry.name = proc_def->procedure->name;
entry.stock_id = plug_in_proc_def_get_stock_id (proc_def); entry.stock_id = plug_in_proc_def_get_stock_id (proc_def);
entry.label = label; entry.label = label;
entry.accelerator = NULL; entry.accelerator = NULL;
@ -308,7 +310,8 @@ plug_in_actions_add_proc (GimpActionGroup *group,
entry.help_id = plug_in_proc_def_get_help_id (proc_def, help_domain); entry.help_id = plug_in_proc_def_get_help_id (proc_def, help_domain);
#if 0 #if 0
g_print ("adding plug-in action '%s' (%s)\n", proc_def->db_info.name, label); g_print ("adding plug-in action '%s' (%s)\n",
proc_def->procedure->name, label);
#endif #endif
gimp_action_group_add_plug_in_actions (group, &entry, 1, gimp_action_group_add_plug_in_actions (group, &entry, 1,
@ -375,13 +378,13 @@ plug_in_actions_remove_proc (GimpActionGroup *group,
g_return_if_fail (proc_def != NULL); g_return_if_fail (proc_def != NULL);
action = gtk_action_group_get_action (GTK_ACTION_GROUP (group), action = gtk_action_group_get_action (GTK_ACTION_GROUP (group),
proc_def->db_info.name); proc_def->procedure->name);
if (action) if (action)
{ {
#if 0 #if 0
g_print ("removing plug-in action '%s'\n", g_print ("removing plug-in action '%s'\n",
proc_def->db_info.name); proc_def->procedure->name);
#endif #endif
gtk_action_group_remove_action (GTK_ACTION_GROUP (group), action); gtk_action_group_remove_action (GTK_ACTION_GROUP (group), action);

View File

@ -37,6 +37,7 @@
#include "plug-in/plug-in-run.h" #include "plug-in/plug-in-run.h"
#include "plug-in/plug-in-proc-def.h" #include "plug-in/plug-in-proc-def.h"
#include "pdb/gimpprocedure.h"
#include "pdb/procedural_db.h" #include "pdb/procedural_db.h"
#include "widgets/gimphelp-ids.h" #include "widgets/gimphelp-ids.h"
@ -75,7 +76,7 @@ plug_in_run_cmd_callback (GtkAction *action,
if (! gimp) if (! gimp)
return; return;
procedure = &proc_def->db_info; procedure = proc_def->procedure;
args = gimp_procedure_get_arguments (procedure); args = gimp_procedure_get_arguments (procedure);

View File

@ -30,6 +30,8 @@
#include "core/gimp.h" #include "core/gimp.h"
#include "pdb/gimpprocedure.h"
#include "plug-in/plug-ins.h" #include "plug-in/plug-ins.h"
#include "plug-in/plug-in-def.h" #include "plug-in/plug-in-def.h"
#include "plug-in/plug-in-proc-def.h" #include "plug-in/plug-in-proc-def.h"
@ -266,7 +268,7 @@ plug_in_menus_add_proc (GimpUIManager *manager,
*p = '\0'; *p = '\0';
} }
merge_key = g_strdup_printf ("%s-merge-id", proc_def->db_info.name); merge_key = g_strdup_printf ("%s-merge-id", proc_def->procedure->name);
merge_id = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (manager), merge_id = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (manager),
merge_key)); merge_key));
@ -303,13 +305,13 @@ plug_in_menus_add_proc (GimpUIManager *manager,
#if 0 #if 0
g_print ("adding menu item for '%s' (@ %s)\n", g_print ("adding menu item for '%s' (@ %s)\n",
proc_def->db_info.name, action_path); proc_def->procedure->name, action_path);
#endif #endif
gtk_ui_manager_add_ui (GTK_UI_MANAGER (manager), merge_id, gtk_ui_manager_add_ui (GTK_UI_MANAGER (manager), merge_id,
action_path, action_path,
proc_def->db_info.name, proc_def->procedure->name,
proc_def->db_info.name, proc_def->procedure->name,
GTK_UI_MANAGER_MENUITEM, GTK_UI_MANAGER_MENUITEM,
FALSE); FALSE);
@ -327,7 +329,7 @@ plug_in_menus_remove_proc (GimpUIManager *manager,
g_return_if_fail (GIMP_IS_UI_MANAGER (manager)); g_return_if_fail (GIMP_IS_UI_MANAGER (manager));
g_return_if_fail (proc_def != NULL); g_return_if_fail (proc_def != NULL);
merge_key = g_strdup_printf ("%s-merge-id", proc_def->db_info.name); merge_key = g_strdup_printf ("%s-merge-id", proc_def->procedure->name);
merge_id = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (manager), merge_id = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (manager),
merge_key)); merge_key));
g_free (merge_key); g_free (merge_key);

View File

@ -187,14 +187,12 @@ register_fileops_procs (Gimp *gimp)
procedure = gimp_procedure_init (&file_save_proc, 5, 0); procedure = gimp_procedure_init (&file_save_proc, 5, 0);
gimp_procedure_add_argument (procedure, gimp_procedure_add_argument (procedure,
GIMP_PDB_INT32, GIMP_PDB_INT32,
gimp_param_spec_enum ("run-mode", g_param_spec_enum ("run-mode",
"run mode", "run mode",
"The run mode: { GIMP_RUN_INTERACTIVE (0), GIMP_RUN_NONINTERACTIVE (1) }", "The run mode: { GIMP_RUN_INTERACTIVE (0), GIMP_RUN_NONINTERACTIVE (1), GIMP_RUN_WITH_LAST_VALS (2) }",
GIMP_TYPE_RUN_MODE, GIMP_TYPE_RUN_MODE,
GIMP_RUN_INTERACTIVE, GIMP_RUN_INTERACTIVE,
GIMP_PARAM_READWRITE)); GIMP_PARAM_READWRITE));
gimp_param_spec_enum_exclude_value (GIMP_PARAM_SPEC_ENUM (procedure->args[0].pspec),
GIMP_RUN_WITH_LAST_VALS);
gimp_procedure_add_argument (procedure, gimp_procedure_add_argument (procedure,
GIMP_PDB_IMAGE, GIMP_PDB_IMAGE,
gimp_param_spec_image_id ("image", gimp_param_spec_image_id ("image",
@ -502,14 +500,14 @@ file_load_invoker (ProcRecord *proc_record,
for (i = 3; i < proc->num_args; i++) for (i = 3; i < proc->num_args; i++)
if (proc->args[i].type == GIMP_PDB_STRING) if (proc->args[i].type == GIMP_PDB_STRING)
g_value_set_string (&new_args[i].value, ""); g_value_set_static_string (&new_args[i].value, "");
return_vals = procedural_db_execute (gimp, context, progress, return_vals = procedural_db_execute (gimp, context, progress,
proc->name, proc->name,
new_args, proc->num_args, new_args, proc->num_args,
&n_return_vals); &n_return_vals);
procedural_db_destroy_args (new_args, proc->num_args, FALSE); procedural_db_destroy_args (new_args, proc->num_args, TRUE);
return return_vals; return return_vals;
} }
@ -722,14 +720,14 @@ file_save_invoker (ProcRecord *proc_record,
for (i = 5; i < proc->num_args; i++) for (i = 5; i < proc->num_args; i++)
if (proc->args[i].type == GIMP_PDB_STRING) if (proc->args[i].type == GIMP_PDB_STRING)
g_value_set_string (&new_args[i].value, ""); g_value_set_static_string (&new_args[i].value, "");
return_vals = procedural_db_execute (gimp, context, progress, return_vals = procedural_db_execute (gimp, context, progress,
proc->name, proc->name,
new_args, proc->num_args, new_args, proc->num_args,
&n_return_vals); &n_return_vals);
procedural_db_destroy_args (new_args, proc->num_args, FALSE); procedural_db_destroy_args (new_args, proc->num_args, TRUE);
return return_vals; return return_vals;
} }
@ -826,7 +824,9 @@ temp_name_invoker (ProcRecord *proc_record,
extension = (gchar *) g_value_get_string (&args[0].value); extension = (gchar *) g_value_get_string (&args[0].value);
if (success) if (success)
{
name = gimp_get_temp_filename (gimp, extension); name = gimp_get_temp_filename (gimp, extension);
}
return_vals = gimp_procedure_get_return_values (proc_record, success); return_vals = gimp_procedure_get_return_values (proc_record, success);

View File

@ -31,6 +31,7 @@
#include "core/gimp.h" #include "core/gimp.h"
#include "pdb/gimpprocedure.h"
#include "pdb/procedural_db.h" #include "pdb/procedural_db.h"
#include "plug-in.h" #include "plug-in.h"
@ -47,6 +48,8 @@ plug_in_proc_def_new (void)
proc_def->icon_data_length = -1; proc_def->icon_data_length = -1;
proc_def->procedure = gimp_procedure_new ();
return proc_def; return proc_def;
} }
@ -57,22 +60,7 @@ plug_in_proc_def_free (PlugInProcDef *proc_def)
g_return_if_fail (proc_def != NULL); g_return_if_fail (proc_def != NULL);
g_free (proc_def->db_info.name); gimp_procedure_free (proc_def->procedure);
g_free (proc_def->db_info.original_name);
g_free (proc_def->db_info.blurb);
g_free (proc_def->db_info.help);
g_free (proc_def->db_info.author);
g_free (proc_def->db_info.copyright);
g_free (proc_def->db_info.date);
for (i = 0; i < proc_def->db_info.num_args; i++)
g_param_spec_unref (proc_def->db_info.args[i].pspec);
for (i = 0; i < proc_def->db_info.num_values; i++)
g_param_spec_unref (proc_def->db_info.values[i].pspec);
g_free (proc_def->db_info.args);
g_free (proc_def->db_info.values);
g_free (proc_def->prog); g_free (proc_def->prog);
g_free (proc_def->menu_label); g_free (proc_def->menu_label);
@ -112,7 +100,7 @@ plug_in_proc_def_find (GSList *list,
{ {
PlugInProcDef *proc_def = l->data; PlugInProcDef *proc_def = l->data;
if (! strcmp (proc_name, proc_def->db_info.name)) if (! strcmp (proc_name, proc_def->procedure->name))
return proc_def; return proc_def;
} }
@ -124,7 +112,7 @@ plug_in_proc_def_get_proc (const PlugInProcDef *proc_def)
{ {
g_return_val_if_fail (proc_def != NULL, NULL); g_return_val_if_fail (proc_def != NULL, NULL);
return &proc_def->db_info; return proc_def->procedure;
} }
const gchar * const gchar *
@ -132,14 +120,14 @@ plug_in_proc_def_get_progname (const PlugInProcDef *proc_def)
{ {
g_return_val_if_fail (proc_def != NULL, NULL); g_return_val_if_fail (proc_def != NULL, NULL);
switch (proc_def->db_info.proc_type) switch (proc_def->procedure->proc_type)
{ {
case GIMP_PLUGIN: case GIMP_PLUGIN:
case GIMP_EXTENSION: case GIMP_EXTENSION:
return proc_def->prog; return proc_def->prog;
case GIMP_TEMPORARY: case GIMP_TEMPORARY:
return ((PlugIn *) proc_def->db_info.exec_method.temporary.plug_in)->prog; return ((PlugIn *) proc_def->procedure->exec_method.temporary.plug_in)->prog;
default: default:
break; break;
@ -276,9 +264,9 @@ plug_in_proc_def_get_help_id (const PlugInProcDef *proc_def,
g_return_val_if_fail (proc_def != NULL, NULL); g_return_val_if_fail (proc_def != NULL, NULL);
if (help_domain) if (help_domain)
return g_strconcat (help_domain, "?", proc_def->db_info.name, NULL); return g_strconcat (help_domain, "?", proc_def->procedure->name, NULL);
return g_strdup (proc_def->db_info.name); return g_strdup (proc_def->procedure->name);
} }
gboolean gboolean

View File

@ -25,8 +25,6 @@
#include <gdk-pixbuf/gdk-pixbuf.h> #include <gdk-pixbuf/gdk-pixbuf.h>
#include "pdb/gimpprocedure.h" /* ProcRecord */
struct _PlugInProcDef struct _PlugInProcDef
{ {
@ -41,7 +39,8 @@ struct _PlugInProcDef
PlugInImageType image_types_val; PlugInImageType image_types_val;
time_t mtime; time_t mtime;
gboolean installed_during_init; gboolean installed_during_init;
ProcRecord db_info;
ProcRecord *procedure;
/* file proc specific members */ /* file proc specific members */
gboolean file_proc; gboolean file_proc;

View File

@ -48,6 +48,61 @@
/* public functions */ /* public functions */
ProcRecord *
gimp_procedure_new (void)
{
ProcRecord *procedure = g_new0 (ProcRecord, 1);
return procedure;
}
void
gimp_procedure_free (ProcRecord *procedure)
{
gint i;
g_return_if_fail (procedure != NULL);
g_free (procedure->name);
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);
for (i = 0; i < procedure->num_args; i++)
g_param_spec_unref (procedure->args[i].pspec);
for (i = 0; i < procedure->num_values; i++)
g_param_spec_unref (procedure->values[i].pspec);
g_free (procedure->args);
g_free (procedure->values);
g_free (procedure);
}
ProcRecord *
gimp_procedure_init (ProcRecord *procedure,
gint n_arguments,
gint n_return_values)
{
g_return_val_if_fail (procedure != NULL, procedure);
g_return_val_if_fail (procedure->args == NULL, procedure);
g_return_val_if_fail (procedure->values == NULL, procedure);
g_return_val_if_fail (n_arguments >= 0, procedure);
g_return_val_if_fail (n_return_values >= 0, procedure);
procedure->num_args = n_arguments;
procedure->args = g_new0 (ProcArg, n_arguments);
procedure->num_values = n_return_values;
procedure->values = g_new0 (ProcArg, n_return_values);
return procedure;
}
Argument * Argument *
gimp_procedure_execute (ProcRecord *procedure, gimp_procedure_execute (ProcRecord *procedure,
Gimp *gimp, Gimp *gimp,
@ -86,24 +141,59 @@ gimp_procedure_execute (ProcRecord *procedure,
return return_vals; return return_vals;
} }
else if (! (procedure->args[i].pspec->flags & GIMP_PARAM_NO_VALIDATE) && else if (! (procedure->args[i].pspec->flags & GIMP_PARAM_NO_VALIDATE))
g_param_value_validate (procedure->args[i].pspec,
&args[i].value))
{ {
gchar *type_name = procedural_db_type_name (procedure->args[i].type); GValue string_value = { 0, };
g_message (_("PDB calling error for procedure '%s':\n" g_value_init (&string_value, G_TYPE_STRING);
"Argument '%s' (#%d, type %s) out of bounds."),
procedure->name,
g_param_spec_get_name (procedure->args[i].pspec),
i + 1, type_name);
g_free (type_name); if (g_value_type_transformable (args[i].value.g_type,
G_TYPE_STRING))
g_value_transform (&args[i].value, &string_value);
else
g_value_set_static_string (&string_value,
"<not transformable to string>");
return_vals = gimp_procedure_get_return_values (procedure, FALSE); if (g_param_value_validate (procedure->args[i].pspec,
g_value_set_enum (&return_vals->value, GIMP_PDB_CALLING_ERROR); &args[i].value))
{
gchar *type_name;
gchar *old_value;
gchar *new_value;
return return_vals; type_name = procedural_db_type_name (procedure->args[i].type);
old_value = g_value_dup_string (&string_value);
if (g_value_type_transformable (args[i].value.g_type,
G_TYPE_STRING))
g_value_transform (&args[i].value, &string_value);
else
g_value_set_static_string (&string_value,
"<not transformable to string>");
new_value = g_value_dup_string (&string_value);
g_value_unset (&string_value);
g_message (_("PDB calling error for procedure '%s':\n"
"Argument '%s' (#%d, type %s) out of bounds "
"(value '%s' was changed to '%s')"),
procedure->name,
g_param_spec_get_name (procedure->args[i].pspec),
i + 1, type_name,
old_value, new_value);
g_free (type_name);
g_free (old_value);
g_free (new_value);
return_vals = gimp_procedure_get_return_values (procedure, FALSE);
g_value_set_enum (&return_vals->value, GIMP_PDB_CALLING_ERROR);
return return_vals;
}
g_value_unset (&string_value);
} }
} }
@ -188,26 +278,6 @@ gimp_procedure_get_return_values (const ProcRecord *procedure,
return args; return args;
} }
ProcRecord *
gimp_procedure_init (ProcRecord *procedure,
gint n_arguments,
gint n_return_values)
{
g_return_val_if_fail (procedure != NULL, procedure);
g_return_val_if_fail (procedure->args == NULL, procedure);
g_return_val_if_fail (procedure->values == NULL, procedure);
g_return_val_if_fail (n_arguments >= 0, procedure);
g_return_val_if_fail (n_return_values >= 0, procedure);
procedure->num_args = n_arguments;
procedure->args = g_new0 (ProcArg, n_arguments);
procedure->num_values = n_return_values;
procedure->values = g_new0 (ProcArg, n_return_values);
return procedure;
}
void void
gimp_procedure_add_argument (ProcRecord *procedure, gimp_procedure_add_argument (ProcRecord *procedure,
GimpPDBArgType arg_type, GimpPDBArgType arg_type,

View File

@ -95,6 +95,9 @@ struct _ProcRecord
/* Functions */ /* Functions */
ProcRecord * gimp_procedure_new (void);
void gimp_procedure_free (ProcRecord *procedure);
ProcRecord * gimp_procedure_init (ProcRecord *procedure, ProcRecord * gimp_procedure_init (ProcRecord *procedure,
gint n_arguments, gint n_arguments,
gint n_return_vals); gint n_return_vals);

View File

@ -36,6 +36,7 @@
#include "core/gimp.h" #include "core/gimp.h"
#include "core/gimpdrawable.h" #include "core/gimpdrawable.h"
#include "pdb/gimpprocedure.h"
#include "pdb/procedural_db.h" #include "pdb/procedural_db.h"
#include "plug-in.h" #include "plug-in.h"
@ -737,7 +738,7 @@ plug_in_handle_proc_install (PlugIn *plug_in,
/* The procedural database procedure */ /* The procedural database procedure */
proc = &proc_def->db_info; proc = proc_def->procedure;
proc->name = canonical; proc->name = canonical;
proc->original_name = g_strdup (proc_install->name); proc->original_name = g_strdup (proc_install->name);

View File

@ -76,6 +76,8 @@
#include "core/gimpinterpreterdb.h" #include "core/gimpinterpreterdb.h"
#include "core/gimpprogress.h" #include "core/gimpprogress.h"
#include "pdb/gimpprocedure.h"
#include "plug-in.h" #include "plug-in.h"
#include "plug-ins.h" #include "plug-ins.h"
#include "plug-in-debug.h" #include "plug-in-debug.h"
@ -1054,10 +1056,10 @@ plug_in_menu_register (PlugIn *plug_in,
plug_in->prog, plug_in->prog,
proc_name, proc_name,
menu_path, menu_path,
proc_def->db_info.args, proc_def->procedure->args,
proc_def->db_info.num_args, proc_def->procedure->num_args,
proc_def->db_info.values, proc_def->procedure->values,
proc_def->db_info.num_values, proc_def->procedure->num_values,
&error)) &error))
{ {
g_message (error->message); g_message (error->message);
@ -1066,7 +1068,7 @@ plug_in_menu_register (PlugIn *plug_in,
return FALSE; return FALSE;
} }
switch (proc_def->db_info.proc_type) switch (proc_def->procedure->proc_type)
{ {
case GIMP_INTERNAL: case GIMP_INTERNAL:
return FALSE; return FALSE;
@ -1083,7 +1085,7 @@ plug_in_menu_register (PlugIn *plug_in,
proc_def->menu_paths = g_list_append (proc_def->menu_paths, proc_def->menu_paths = g_list_append (proc_def->menu_paths,
g_strdup (menu_path)); g_strdup (menu_path));
if (proc_def->db_info.proc_type == GIMP_TEMPORARY if (proc_def->procedure->proc_type == GIMP_TEMPORARY
&& ! plug_in->gimp->no_interface) && ! plug_in->gimp->no_interface)
{ {
gimp_menus_create_item (plug_in->gimp, proc_def, menu_path); gimp_menus_create_item (plug_in->gimp, proc_def, menu_path);

View File

@ -38,6 +38,7 @@
#include "core/gimpcontext.h" #include "core/gimpcontext.h"
#include "core/gimpprogress.h" #include "core/gimpprogress.h"
#include "pdb/gimpprocedure.h"
#include "pdb/procedural_db.h" #include "pdb/procedural_db.h"
#include "plug-in.h" #include "plug-in.h"
@ -220,8 +221,7 @@ plug_in_repeat (Gimp *gimp,
if (proc_def) if (proc_def)
{ {
/* construct the procedures arguments */ args = gimp_procedure_get_arguments (proc_def->procedure);
args = gimp_procedure_get_arguments (&proc_def->db_info);
g_value_set_int (&args[0].value, g_value_set_int (&args[0].value,
with_interface ? with_interface ?
@ -230,11 +230,11 @@ plug_in_repeat (Gimp *gimp,
g_value_set_int (&args[2].value, drawable_ID); g_value_set_int (&args[2].value, drawable_ID);
/* run the plug-in procedure */ /* run the plug-in procedure */
plug_in_run (gimp, context, progress, &proc_def->db_info, plug_in_run (gimp, context, progress, proc_def->procedure,
args, 3 /* not proc_def->db_info.num_args */, args, 3 /* not proc_def->procedure->num_args */,
FALSE, TRUE, display_ID); FALSE, TRUE, display_ID);
procedural_db_destroy_args (args, proc_def->db_info.num_args, TRUE); procedural_db_destroy_args (args, proc_def->procedure->num_args, TRUE);
} }
} }

View File

@ -36,6 +36,7 @@
#include "core/gimp.h" #include "core/gimp.h"
#include "pdb/gimpprocedure.h"
#include "pdb/procedural_db.h" #include "pdb/procedural_db.h"
#include "plug-in-proc-def.h" #include "plug-in-proc-def.h"
@ -135,7 +136,7 @@ plug_ins_query (Gimp *gimp,
for (list = matched; list; list = g_slist_next (list)) for (list = matched; list; list = g_slist_next (list))
{ {
PlugInProcDef *proc_def = list->data; PlugInProcDef *proc_def = list->data;
ProcRecord *proc_rec = &proc_def->db_info; ProcRecord *proc_rec = proc_def->procedure;
gchar *name; gchar *name;
if (proc_def->menu_label) if (proc_def->menu_label)

View File

@ -38,6 +38,7 @@
#include "core/gimpcontext.h" #include "core/gimpcontext.h"
#include "core/gimpprogress.h" #include "core/gimpprogress.h"
#include "pdb/gimpprocedure.h"
#include "pdb/procedural_db.h" #include "pdb/procedural_db.h"
#include "plug-in.h" #include "plug-in.h"
@ -220,8 +221,7 @@ plug_in_repeat (Gimp *gimp,
if (proc_def) if (proc_def)
{ {
/* construct the procedures arguments */ args = gimp_procedure_get_arguments (proc_def->procedure);
args = gimp_procedure_get_arguments (&proc_def->db_info);
g_value_set_int (&args[0].value, g_value_set_int (&args[0].value,
with_interface ? with_interface ?
@ -230,11 +230,11 @@ plug_in_repeat (Gimp *gimp,
g_value_set_int (&args[2].value, drawable_ID); g_value_set_int (&args[2].value, drawable_ID);
/* run the plug-in procedure */ /* run the plug-in procedure */
plug_in_run (gimp, context, progress, &proc_def->db_info, plug_in_run (gimp, context, progress, proc_def->procedure,
args, 3 /* not proc_def->db_info.num_args */, args, 3 /* not proc_def->procedure->num_args */,
FALSE, TRUE, display_ID); FALSE, TRUE, display_ID);
procedural_db_destroy_args (args, proc_def->db_info.num_args, TRUE); procedural_db_destroy_args (args, proc_def->procedure->num_args, TRUE);
} }
} }

View File

@ -38,6 +38,7 @@
#include "core/gimpdrawable.h" #include "core/gimpdrawable.h"
#include "core/gimpimage.h" #include "core/gimpimage.h"
#include "pdb/gimpprocedure.h"
#include "pdb/procedural_db.h" #include "pdb/procedural_db.h"
#include "plug-in.h" #include "plug-in.h"
@ -244,7 +245,7 @@ plug_ins_init (Gimp *gimp,
g_printerr ("removing duplicate PDB procedure \"%s\" " g_printerr ("removing duplicate PDB procedure \"%s\" "
"registered by '%s'\n", "registered by '%s'\n",
overridden_proc_def->db_info.name, overridden_proc_def->procedure->name,
gimp_filename_to_utf8 (overridden_proc_def->prog)); gimp_filename_to_utf8 (overridden_proc_def->prog));
/* search the plugin list to see if any plugins had references to /* search the plugin list to see if any plugins had references to
@ -325,9 +326,9 @@ plug_ins_init (Gimp *gimp,
{ {
PlugInProcDef *proc_def = list->data; PlugInProcDef *proc_def = list->data;
if (proc_def->prog && if (proc_def->prog &&
proc_def->db_info.proc_type == GIMP_EXTENSION && proc_def->procedure->proc_type == GIMP_EXTENSION &&
proc_def->db_info.num_args == 0) proc_def->procedure->num_args == 0)
{ {
extensions = g_list_prepend (extensions, proc_def); extensions = g_list_prepend (extensions, proc_def);
} }
@ -348,12 +349,13 @@ plug_ins_init (Gimp *gimp,
PlugInProcDef *proc_def = list->data; PlugInProcDef *proc_def = list->data;
if (gimp->be_verbose) if (gimp->be_verbose)
g_print (_("Starting extension: '%s'\n"), proc_def->db_info.name); g_print (_("Starting extension: '%s'\n"),
proc_def->procedure->name);
status_callback (NULL, proc_def->db_info.name, status_callback (NULL, proc_def->procedure->name,
(gdouble) nth / (gdouble) n_extensions); (gdouble) nth / (gdouble) n_extensions);
plug_in_run (gimp, context, NULL, &proc_def->db_info, plug_in_run (gimp, context, NULL, proc_def->procedure,
NULL, 0, FALSE, TRUE, -1); NULL, 0, FALSE, TRUE, -1);
} }
@ -646,7 +648,7 @@ plug_ins_temp_proc_def_add (Gimp *gimp,
} }
/* Register the procedural database entry */ /* Register the procedural database entry */
procedural_db_register (gimp, &proc_def->db_info); procedural_db_register (gimp, proc_def->procedure);
/* Add the definition to the global list */ /* Add the definition to the global list */
gimp->plug_in_proc_defs = g_slist_prepend (gimp->plug_in_proc_defs, proc_def); gimp->plug_in_proc_defs = g_slist_prepend (gimp->plug_in_proc_defs, proc_def);
@ -666,7 +668,7 @@ plug_ins_temp_proc_def_remove (Gimp *gimp,
} }
/* Unregister the procedural database entry */ /* Unregister the procedural database entry */
procedural_db_unregister (gimp, proc_def->db_info.name); procedural_db_unregister (gimp, proc_def->procedure->name);
/* Remove the definition from the global list */ /* Remove the definition from the global list */
gimp->plug_in_proc_defs = g_slist_remove (gimp->plug_in_proc_defs, proc_def); gimp->plug_in_proc_defs = g_slist_remove (gimp->plug_in_proc_defs, proc_def);
@ -868,7 +870,7 @@ plug_ins_proc_def_find (Gimp *gimp,
{ {
PlugInProcDef *proc_def = list->data; PlugInProcDef *proc_def = list->data;
if (proc_rec == &proc_def->db_info) if (proc_rec == proc_def->procedure)
return proc_def; return proc_def;
} }
@ -1044,10 +1046,10 @@ plug_ins_add_to_db (Gimp *gimp,
{ {
proc_def = list->data; proc_def = list->data;
if (proc_def->prog && (proc_def->db_info.proc_type != GIMP_INTERNAL)) if (proc_def->prog && (proc_def->procedure->proc_type != GIMP_INTERNAL))
{ {
proc_def->db_info.exec_method.plug_in.filename = proc_def->prog; proc_def->procedure->exec_method.plug_in.filename = proc_def->prog;
procedural_db_register (gimp, &proc_def->db_info); procedural_db_register (gimp, proc_def->procedure);
} }
} }
@ -1066,7 +1068,7 @@ plug_ins_add_to_db (Gimp *gimp,
procedural_db_run_proc (gimp, context, NULL, procedural_db_run_proc (gimp, context, NULL,
"gimp-register-save-handler", "gimp-register-save-handler",
&n_return_vals, &n_return_vals,
GIMP_PDB_STRING, proc_def->db_info.name, GIMP_PDB_STRING, proc_def->procedure->name,
GIMP_PDB_STRING, proc_def->extensions, GIMP_PDB_STRING, proc_def->extensions,
GIMP_PDB_STRING, proc_def->prefixes, GIMP_PDB_STRING, proc_def->prefixes,
GIMP_PDB_END); GIMP_PDB_END);
@ -1077,7 +1079,7 @@ plug_ins_add_to_db (Gimp *gimp,
procedural_db_run_proc (gimp, context, NULL, procedural_db_run_proc (gimp, context, NULL,
"gimp-register-magic-load-handler", "gimp-register-magic-load-handler",
&n_return_vals, &n_return_vals,
GIMP_PDB_STRING, proc_def->db_info.name, GIMP_PDB_STRING, proc_def->procedure->name,
GIMP_PDB_STRING, proc_def->extensions, GIMP_PDB_STRING, proc_def->extensions,
GIMP_PDB_STRING, proc_def->prefixes, GIMP_PDB_STRING, proc_def->prefixes,
GIMP_PDB_STRING, proc_def->magics, GIMP_PDB_STRING, proc_def->magics,
@ -1099,7 +1101,7 @@ plug_ins_proc_def_insert (Gimp *gimp,
{ {
PlugInProcDef *tmp_proc_def = list->data; PlugInProcDef *tmp_proc_def = list->data;
if (strcmp (proc_def->db_info.name, tmp_proc_def->db_info.name) == 0) if (strcmp (proc_def->procedure->name, tmp_proc_def->procedure->name) == 0)
{ {
list->data = proc_def; list->data = proc_def;

View File

@ -31,6 +31,7 @@
#include "core/gimp.h" #include "core/gimp.h"
#include "pdb/gimpprocedure.h"
#include "pdb/procedural_db.h" #include "pdb/procedural_db.h"
#include "plug-in.h" #include "plug-in.h"
@ -47,6 +48,8 @@ plug_in_proc_def_new (void)
proc_def->icon_data_length = -1; proc_def->icon_data_length = -1;
proc_def->procedure = gimp_procedure_new ();
return proc_def; return proc_def;
} }
@ -57,22 +60,7 @@ plug_in_proc_def_free (PlugInProcDef *proc_def)
g_return_if_fail (proc_def != NULL); g_return_if_fail (proc_def != NULL);
g_free (proc_def->db_info.name); gimp_procedure_free (proc_def->procedure);
g_free (proc_def->db_info.original_name);
g_free (proc_def->db_info.blurb);
g_free (proc_def->db_info.help);
g_free (proc_def->db_info.author);
g_free (proc_def->db_info.copyright);
g_free (proc_def->db_info.date);
for (i = 0; i < proc_def->db_info.num_args; i++)
g_param_spec_unref (proc_def->db_info.args[i].pspec);
for (i = 0; i < proc_def->db_info.num_values; i++)
g_param_spec_unref (proc_def->db_info.values[i].pspec);
g_free (proc_def->db_info.args);
g_free (proc_def->db_info.values);
g_free (proc_def->prog); g_free (proc_def->prog);
g_free (proc_def->menu_label); g_free (proc_def->menu_label);
@ -112,7 +100,7 @@ plug_in_proc_def_find (GSList *list,
{ {
PlugInProcDef *proc_def = l->data; PlugInProcDef *proc_def = l->data;
if (! strcmp (proc_name, proc_def->db_info.name)) if (! strcmp (proc_name, proc_def->procedure->name))
return proc_def; return proc_def;
} }
@ -124,7 +112,7 @@ plug_in_proc_def_get_proc (const PlugInProcDef *proc_def)
{ {
g_return_val_if_fail (proc_def != NULL, NULL); g_return_val_if_fail (proc_def != NULL, NULL);
return &proc_def->db_info; return proc_def->procedure;
} }
const gchar * const gchar *
@ -132,14 +120,14 @@ plug_in_proc_def_get_progname (const PlugInProcDef *proc_def)
{ {
g_return_val_if_fail (proc_def != NULL, NULL); g_return_val_if_fail (proc_def != NULL, NULL);
switch (proc_def->db_info.proc_type) switch (proc_def->procedure->proc_type)
{ {
case GIMP_PLUGIN: case GIMP_PLUGIN:
case GIMP_EXTENSION: case GIMP_EXTENSION:
return proc_def->prog; return proc_def->prog;
case GIMP_TEMPORARY: case GIMP_TEMPORARY:
return ((PlugIn *) proc_def->db_info.exec_method.temporary.plug_in)->prog; return ((PlugIn *) proc_def->procedure->exec_method.temporary.plug_in)->prog;
default: default:
break; break;
@ -276,9 +264,9 @@ plug_in_proc_def_get_help_id (const PlugInProcDef *proc_def,
g_return_val_if_fail (proc_def != NULL, NULL); g_return_val_if_fail (proc_def != NULL, NULL);
if (help_domain) if (help_domain)
return g_strconcat (help_domain, "?", proc_def->db_info.name, NULL); return g_strconcat (help_domain, "?", proc_def->procedure->name, NULL);
return g_strdup (proc_def->db_info.name); return g_strdup (proc_def->procedure->name);
} }
gboolean gboolean

View File

@ -25,8 +25,6 @@
#include <gdk-pixbuf/gdk-pixbuf.h> #include <gdk-pixbuf/gdk-pixbuf.h>
#include "pdb/gimpprocedure.h" /* ProcRecord */
struct _PlugInProcDef struct _PlugInProcDef
{ {
@ -41,7 +39,8 @@ struct _PlugInProcDef
PlugInImageType image_types_val; PlugInImageType image_types_val;
time_t mtime; time_t mtime;
gboolean installed_during_init; gboolean installed_during_init;
ProcRecord db_info;
ProcRecord *procedure;
/* file proc specific members */ /* file proc specific members */
gboolean file_proc; gboolean file_proc;

View File

@ -36,6 +36,7 @@
#include "core/gimp.h" #include "core/gimp.h"
#include "core/gimpdrawable.h" #include "core/gimpdrawable.h"
#include "pdb/gimpprocedure.h"
#include "pdb/procedural_db.h" #include "pdb/procedural_db.h"
#include "plug-in.h" #include "plug-in.h"
@ -737,7 +738,7 @@ plug_in_handle_proc_install (PlugIn *plug_in,
/* The procedural database procedure */ /* The procedural database procedure */
proc = &proc_def->db_info; proc = proc_def->procedure;
proc->name = canonical; proc->name = canonical;
proc->original_name = g_strdup (proc_install->name); proc->original_name = g_strdup (proc_install->name);

View File

@ -31,6 +31,7 @@
#include "core/gimp.h" #include "core/gimp.h"
#include "pdb/gimpprocedure.h"
#include "pdb/procedural_db.h" #include "pdb/procedural_db.h"
#include "plug-in.h" #include "plug-in.h"
@ -47,6 +48,8 @@ plug_in_proc_def_new (void)
proc_def->icon_data_length = -1; proc_def->icon_data_length = -1;
proc_def->procedure = gimp_procedure_new ();
return proc_def; return proc_def;
} }
@ -57,22 +60,7 @@ plug_in_proc_def_free (PlugInProcDef *proc_def)
g_return_if_fail (proc_def != NULL); g_return_if_fail (proc_def != NULL);
g_free (proc_def->db_info.name); gimp_procedure_free (proc_def->procedure);
g_free (proc_def->db_info.original_name);
g_free (proc_def->db_info.blurb);
g_free (proc_def->db_info.help);
g_free (proc_def->db_info.author);
g_free (proc_def->db_info.copyright);
g_free (proc_def->db_info.date);
for (i = 0; i < proc_def->db_info.num_args; i++)
g_param_spec_unref (proc_def->db_info.args[i].pspec);
for (i = 0; i < proc_def->db_info.num_values; i++)
g_param_spec_unref (proc_def->db_info.values[i].pspec);
g_free (proc_def->db_info.args);
g_free (proc_def->db_info.values);
g_free (proc_def->prog); g_free (proc_def->prog);
g_free (proc_def->menu_label); g_free (proc_def->menu_label);
@ -112,7 +100,7 @@ plug_in_proc_def_find (GSList *list,
{ {
PlugInProcDef *proc_def = l->data; PlugInProcDef *proc_def = l->data;
if (! strcmp (proc_name, proc_def->db_info.name)) if (! strcmp (proc_name, proc_def->procedure->name))
return proc_def; return proc_def;
} }
@ -124,7 +112,7 @@ plug_in_proc_def_get_proc (const PlugInProcDef *proc_def)
{ {
g_return_val_if_fail (proc_def != NULL, NULL); g_return_val_if_fail (proc_def != NULL, NULL);
return &proc_def->db_info; return proc_def->procedure;
} }
const gchar * const gchar *
@ -132,14 +120,14 @@ plug_in_proc_def_get_progname (const PlugInProcDef *proc_def)
{ {
g_return_val_if_fail (proc_def != NULL, NULL); g_return_val_if_fail (proc_def != NULL, NULL);
switch (proc_def->db_info.proc_type) switch (proc_def->procedure->proc_type)
{ {
case GIMP_PLUGIN: case GIMP_PLUGIN:
case GIMP_EXTENSION: case GIMP_EXTENSION:
return proc_def->prog; return proc_def->prog;
case GIMP_TEMPORARY: case GIMP_TEMPORARY:
return ((PlugIn *) proc_def->db_info.exec_method.temporary.plug_in)->prog; return ((PlugIn *) proc_def->procedure->exec_method.temporary.plug_in)->prog;
default: default:
break; break;
@ -276,9 +264,9 @@ plug_in_proc_def_get_help_id (const PlugInProcDef *proc_def,
g_return_val_if_fail (proc_def != NULL, NULL); g_return_val_if_fail (proc_def != NULL, NULL);
if (help_domain) if (help_domain)
return g_strconcat (help_domain, "?", proc_def->db_info.name, NULL); return g_strconcat (help_domain, "?", proc_def->procedure->name, NULL);
return g_strdup (proc_def->db_info.name); return g_strdup (proc_def->procedure->name);
} }
gboolean gboolean

View File

@ -25,8 +25,6 @@
#include <gdk-pixbuf/gdk-pixbuf.h> #include <gdk-pixbuf/gdk-pixbuf.h>
#include "pdb/gimpprocedure.h" /* ProcRecord */
struct _PlugInProcDef struct _PlugInProcDef
{ {
@ -41,7 +39,8 @@ struct _PlugInProcDef
PlugInImageType image_types_val; PlugInImageType image_types_val;
time_t mtime; time_t mtime;
gboolean installed_during_init; gboolean installed_during_init;
ProcRecord db_info;
ProcRecord *procedure;
/* file proc specific members */ /* file proc specific members */
gboolean file_proc; gboolean file_proc;

View File

@ -31,6 +31,7 @@
#include "core/gimp.h" #include "core/gimp.h"
#include "pdb/gimpprocedure.h"
#include "pdb/procedural_db.h" #include "pdb/procedural_db.h"
#include "plug-ins.h" #include "plug-ins.h"
@ -313,29 +314,31 @@ plug_in_proc_def_deserialize (GScanner *scanner,
Gimp *gimp, Gimp *gimp,
PlugInProcDef *proc_def) PlugInProcDef *proc_def)
{ {
GTokenType token; ProcRecord *procedure;
gint n_args; GTokenType token;
gint n_return_vals; gint n_args;
gint n_menu_paths; gint n_return_vals;
gint i; gint n_menu_paths;
gint i;
if (! gimp_scanner_parse_string (scanner, &proc_def->db_info.original_name)) procedure = proc_def->procedure;
if (! gimp_scanner_parse_string (scanner, &procedure->original_name))
return G_TOKEN_STRING; return G_TOKEN_STRING;
proc_def->db_info.name = procedure->name = gimp_canonicalize_identifier (procedure->original_name);
gimp_canonicalize_identifier (proc_def->db_info.original_name);
if (! gimp_scanner_parse_int (scanner, (gint *) &proc_def->db_info.proc_type)) if (! gimp_scanner_parse_int (scanner, (gint *) &procedure->proc_type))
return G_TOKEN_INT; return G_TOKEN_INT;
if (! gimp_scanner_parse_string (scanner, &proc_def->db_info.blurb)) if (! gimp_scanner_parse_string (scanner, &procedure->blurb))
return G_TOKEN_STRING; return G_TOKEN_STRING;
if (! gimp_scanner_parse_string (scanner, &proc_def->db_info.help)) if (! gimp_scanner_parse_string (scanner, &procedure->help))
return G_TOKEN_STRING; return G_TOKEN_STRING;
if (! gimp_scanner_parse_string (scanner, &proc_def->db_info.author)) if (! gimp_scanner_parse_string (scanner, &procedure->author))
return G_TOKEN_STRING; return G_TOKEN_STRING;
if (! gimp_scanner_parse_string (scanner, &proc_def->db_info.copyright)) if (! gimp_scanner_parse_string (scanner, &procedure->copyright))
return G_TOKEN_STRING; return G_TOKEN_STRING;
if (! gimp_scanner_parse_string (scanner, &proc_def->db_info.date)) if (! gimp_scanner_parse_string (scanner, &procedure->date))
return G_TOKEN_STRING; return G_TOKEN_STRING;
if (! gimp_scanner_parse_string (scanner, &proc_def->menu_label)) if (! gimp_scanner_parse_string (scanner, &proc_def->menu_label))
return G_TOKEN_STRING; return G_TOKEN_STRING;
@ -369,20 +372,18 @@ plug_in_proc_def_deserialize (GScanner *scanner,
if (! gimp_scanner_parse_int (scanner, (gint *) &n_return_vals)) if (! gimp_scanner_parse_int (scanner, (gint *) &n_return_vals))
return G_TOKEN_INT; return G_TOKEN_INT;
gimp_procedure_init (&proc_def->db_info, n_args, n_return_vals); gimp_procedure_init (procedure, n_args, n_return_vals);
for (i = 0; i < n_args; i++) for (i = 0; i < n_args; i++)
{ {
token = plug_in_proc_arg_deserialize (scanner, gimp, token = plug_in_proc_arg_deserialize (scanner, gimp, procedure, FALSE);
&proc_def->db_info, FALSE);
if (token != G_TOKEN_LEFT_PAREN) if (token != G_TOKEN_LEFT_PAREN)
return token; return token;
} }
for (i = 0; i < n_return_vals; i++) for (i = 0; i < n_return_vals; i++)
{ {
token = plug_in_proc_arg_deserialize (scanner, gimp, token = plug_in_proc_arg_deserialize (scanner, gimp, procedure, TRUE);
&proc_def->db_info, TRUE);
if (token != G_TOKEN_LEFT_PAREN) if (token != G_TOKEN_LEFT_PAREN)
return token; return token;
} }
@ -490,7 +491,7 @@ plug_in_icon_deserialize (GScanner *scanner,
if (! gimp_scanner_parse_string_no_validate (scanner, &icon_name)) if (! gimp_scanner_parse_string_no_validate (scanner, &icon_name))
return G_TOKEN_STRING; return G_TOKEN_STRING;
icon_data = icon_name; icon_data = (guint8 *) icon_name;
break; break;
case GIMP_ICON_TYPE_INLINE_PIXBUF: case GIMP_ICON_TYPE_INLINE_PIXBUF:
@ -504,7 +505,7 @@ plug_in_icon_deserialize (GScanner *scanner,
proc_def->icon_type = icon_type; proc_def->icon_type = icon_type;
proc_def->icon_data_length = icon_data_length; proc_def->icon_data_length = icon_data_length;
proc_def->icon_data = icon_data; proc_def->icon_data = (gchar *) icon_data;
if (! gimp_scanner_parse_token (scanner, G_TOKEN_RIGHT_PAREN)) if (! gimp_scanner_parse_token (scanner, G_TOKEN_RIGHT_PAREN))
return G_TOKEN_RIGHT_PAREN; return G_TOKEN_RIGHT_PAREN;
@ -730,12 +731,7 @@ plug_in_rc_write (GSList *plug_in_defs,
{ {
GimpConfigWriter *writer; GimpConfigWriter *writer;
GEnumClass *enum_class; GEnumClass *enum_class;
PlugInDef *plug_in_def;
PlugInProcDef *proc_def;
GSList *list; GSList *list;
GSList *list2;
GList *list3;
gint i;
writer = gimp_config_writer_new_file (filename, writer = gimp_config_writer_new_file (filename,
FALSE, FALSE,
@ -756,37 +752,41 @@ plug_in_rc_write (GSList *plug_in_defs,
for (list = plug_in_defs; list; list = list->next) for (list = plug_in_defs; list; list = list->next)
{ {
plug_in_def = list->data; PlugInDef *plug_in_def = list->data;
if (plug_in_def->proc_defs) if (plug_in_def->proc_defs)
{ {
GSList *list2;
gimp_config_writer_open (writer, "plug-in-def"); gimp_config_writer_open (writer, "plug-in-def");
gimp_config_writer_string (writer, plug_in_def->prog); gimp_config_writer_string (writer, plug_in_def->prog);
gimp_config_writer_printf (writer, "%ld", plug_in_def->mtime); gimp_config_writer_printf (writer, "%ld", plug_in_def->mtime);
for (list2 = plug_in_def->proc_defs; list2; list2 = list2->next) for (list2 = plug_in_def->proc_defs; list2; list2 = list2->next)
{ {
GEnumValue *enum_value; PlugInProcDef *proc_def = list2->data;
ProcRecord *procedure = proc_def->procedure;
proc_def = list2->data; GEnumValue *enum_value;
GList *list3;
gint i;
if (proc_def->installed_during_init) if (proc_def->installed_during_init)
continue; continue;
gimp_config_writer_open (writer, "proc-def"); gimp_config_writer_open (writer, "proc-def");
gimp_config_writer_printf (writer, "\"%s\" %d", gimp_config_writer_printf (writer, "\"%s\" %d",
proc_def->db_info.original_name, procedure->original_name,
proc_def->db_info.proc_type); procedure->proc_type);
gimp_config_writer_linefeed (writer); gimp_config_writer_linefeed (writer);
gimp_config_writer_string (writer, proc_def->db_info.blurb); gimp_config_writer_string (writer, procedure->blurb);
gimp_config_writer_linefeed (writer); gimp_config_writer_linefeed (writer);
gimp_config_writer_string (writer, proc_def->db_info.help); gimp_config_writer_string (writer, procedure->help);
gimp_config_writer_linefeed (writer); gimp_config_writer_linefeed (writer);
gimp_config_writer_string (writer, proc_def->db_info.author); gimp_config_writer_string (writer, procedure->author);
gimp_config_writer_linefeed (writer); gimp_config_writer_linefeed (writer);
gimp_config_writer_string (writer, proc_def->db_info.copyright); gimp_config_writer_string (writer, procedure->copyright);
gimp_config_writer_linefeed (writer); gimp_config_writer_linefeed (writer);
gimp_config_writer_string (writer, proc_def->db_info.date); gimp_config_writer_string (writer, procedure->date);
gimp_config_writer_linefeed (writer); gimp_config_writer_linefeed (writer);
gimp_config_writer_string (writer, proc_def->menu_label); gimp_config_writer_string (writer, proc_def->menu_label);
gimp_config_writer_linefeed (writer); gimp_config_writer_linefeed (writer);
@ -815,7 +815,7 @@ plug_in_rc_write (GSList *plug_in_defs,
case GIMP_ICON_TYPE_INLINE_PIXBUF: case GIMP_ICON_TYPE_INLINE_PIXBUF:
gimp_config_writer_data (writer, proc_def->icon_data_length, gimp_config_writer_data (writer, proc_def->icon_data_length,
proc_def->icon_data); (guint8 *) proc_def->icon_data);
break; break;
} }
@ -876,33 +876,33 @@ plug_in_rc_write (GSList *plug_in_defs,
gimp_config_writer_linefeed (writer); gimp_config_writer_linefeed (writer);
gimp_config_writer_printf (writer, "%d %d", gimp_config_writer_printf (writer, "%d %d",
proc_def->db_info.num_args, procedure->num_args,
proc_def->db_info.num_values); procedure->num_values);
for (i = 0; i < proc_def->db_info.num_args; i++) for (i = 0; i < procedure->num_args; i++)
{ {
gimp_config_writer_open (writer, "proc-arg"); gimp_config_writer_open (writer, "proc-arg");
gimp_config_writer_printf (writer, "%d", gimp_config_writer_printf (writer, "%d",
proc_def->db_info.args[i].type); procedure->args[i].type);
gimp_config_writer_string (writer, gimp_config_writer_string (writer,
g_param_spec_get_name (proc_def->db_info.args[i].pspec)); g_param_spec_get_name (procedure->args[i].pspec));
gimp_config_writer_string (writer, gimp_config_writer_string (writer,
g_param_spec_get_blurb (proc_def->db_info.args[i].pspec)); g_param_spec_get_blurb (procedure->args[i].pspec));
gimp_config_writer_close (writer); gimp_config_writer_close (writer);
} }
for (i = 0; i < proc_def->db_info.num_values; i++) for (i = 0; i < procedure->num_values; i++)
{ {
gimp_config_writer_open (writer, "proc-arg"); gimp_config_writer_open (writer, "proc-arg");
gimp_config_writer_printf (writer, "%d", gimp_config_writer_printf (writer, "%d",
proc_def->db_info.values[i].type); procedure->values[i].type);
gimp_config_writer_string (writer, gimp_config_writer_string (writer,
g_param_spec_get_name (proc_def->db_info.values[i].pspec)); g_param_spec_get_name (procedure->values[i].pspec));
gimp_config_writer_string (writer, gimp_config_writer_string (writer,
g_param_spec_get_blurb (proc_def->db_info.values[i].pspec)); g_param_spec_get_blurb (procedure->values[i].pspec));
gimp_config_writer_close (writer); gimp_config_writer_close (writer);
} }

View File

@ -38,6 +38,7 @@
#include "core/gimpcontext.h" #include "core/gimpcontext.h"
#include "core/gimpprogress.h" #include "core/gimpprogress.h"
#include "pdb/gimpprocedure.h"
#include "pdb/procedural_db.h" #include "pdb/procedural_db.h"
#include "plug-in.h" #include "plug-in.h"
@ -220,8 +221,7 @@ plug_in_repeat (Gimp *gimp,
if (proc_def) if (proc_def)
{ {
/* construct the procedures arguments */ args = gimp_procedure_get_arguments (proc_def->procedure);
args = gimp_procedure_get_arguments (&proc_def->db_info);
g_value_set_int (&args[0].value, g_value_set_int (&args[0].value,
with_interface ? with_interface ?
@ -230,11 +230,11 @@ plug_in_repeat (Gimp *gimp,
g_value_set_int (&args[2].value, drawable_ID); g_value_set_int (&args[2].value, drawable_ID);
/* run the plug-in procedure */ /* run the plug-in procedure */
plug_in_run (gimp, context, progress, &proc_def->db_info, plug_in_run (gimp, context, progress, proc_def->procedure,
args, 3 /* not proc_def->db_info.num_args */, args, 3 /* not proc_def->procedure->num_args */,
FALSE, TRUE, display_ID); FALSE, TRUE, display_ID);
procedural_db_destroy_args (args, proc_def->db_info.num_args, TRUE); procedural_db_destroy_args (args, proc_def->procedure->num_args, TRUE);
} }
} }

View File

@ -76,6 +76,8 @@
#include "core/gimpinterpreterdb.h" #include "core/gimpinterpreterdb.h"
#include "core/gimpprogress.h" #include "core/gimpprogress.h"
#include "pdb/gimpprocedure.h"
#include "plug-in.h" #include "plug-in.h"
#include "plug-ins.h" #include "plug-ins.h"
#include "plug-in-debug.h" #include "plug-in-debug.h"
@ -1054,10 +1056,10 @@ plug_in_menu_register (PlugIn *plug_in,
plug_in->prog, plug_in->prog,
proc_name, proc_name,
menu_path, menu_path,
proc_def->db_info.args, proc_def->procedure->args,
proc_def->db_info.num_args, proc_def->procedure->num_args,
proc_def->db_info.values, proc_def->procedure->values,
proc_def->db_info.num_values, proc_def->procedure->num_values,
&error)) &error))
{ {
g_message (error->message); g_message (error->message);
@ -1066,7 +1068,7 @@ plug_in_menu_register (PlugIn *plug_in,
return FALSE; return FALSE;
} }
switch (proc_def->db_info.proc_type) switch (proc_def->procedure->proc_type)
{ {
case GIMP_INTERNAL: case GIMP_INTERNAL:
return FALSE; return FALSE;
@ -1083,7 +1085,7 @@ plug_in_menu_register (PlugIn *plug_in,
proc_def->menu_paths = g_list_append (proc_def->menu_paths, proc_def->menu_paths = g_list_append (proc_def->menu_paths,
g_strdup (menu_path)); g_strdup (menu_path));
if (proc_def->db_info.proc_type == GIMP_TEMPORARY if (proc_def->procedure->proc_type == GIMP_TEMPORARY
&& ! plug_in->gimp->no_interface) && ! plug_in->gimp->no_interface)
{ {
gimp_menus_create_item (plug_in->gimp, proc_def, menu_path); gimp_menus_create_item (plug_in->gimp, proc_def, menu_path);

View File

@ -36,6 +36,7 @@
#include "core/gimp.h" #include "core/gimp.h"
#include "pdb/gimpprocedure.h"
#include "pdb/procedural_db.h" #include "pdb/procedural_db.h"
#include "plug-in-proc-def.h" #include "plug-in-proc-def.h"
@ -135,7 +136,7 @@ plug_ins_query (Gimp *gimp,
for (list = matched; list; list = g_slist_next (list)) for (list = matched; list; list = g_slist_next (list))
{ {
PlugInProcDef *proc_def = list->data; PlugInProcDef *proc_def = list->data;
ProcRecord *proc_rec = &proc_def->db_info; ProcRecord *proc_rec = proc_def->procedure;
gchar *name; gchar *name;
if (proc_def->menu_label) if (proc_def->menu_label)

View File

@ -38,6 +38,7 @@
#include "core/gimpdrawable.h" #include "core/gimpdrawable.h"
#include "core/gimpimage.h" #include "core/gimpimage.h"
#include "pdb/gimpprocedure.h"
#include "pdb/procedural_db.h" #include "pdb/procedural_db.h"
#include "plug-in.h" #include "plug-in.h"
@ -244,7 +245,7 @@ plug_ins_init (Gimp *gimp,
g_printerr ("removing duplicate PDB procedure \"%s\" " g_printerr ("removing duplicate PDB procedure \"%s\" "
"registered by '%s'\n", "registered by '%s'\n",
overridden_proc_def->db_info.name, overridden_proc_def->procedure->name,
gimp_filename_to_utf8 (overridden_proc_def->prog)); gimp_filename_to_utf8 (overridden_proc_def->prog));
/* search the plugin list to see if any plugins had references to /* search the plugin list to see if any plugins had references to
@ -325,9 +326,9 @@ plug_ins_init (Gimp *gimp,
{ {
PlugInProcDef *proc_def = list->data; PlugInProcDef *proc_def = list->data;
if (proc_def->prog && if (proc_def->prog &&
proc_def->db_info.proc_type == GIMP_EXTENSION && proc_def->procedure->proc_type == GIMP_EXTENSION &&
proc_def->db_info.num_args == 0) proc_def->procedure->num_args == 0)
{ {
extensions = g_list_prepend (extensions, proc_def); extensions = g_list_prepend (extensions, proc_def);
} }
@ -348,12 +349,13 @@ plug_ins_init (Gimp *gimp,
PlugInProcDef *proc_def = list->data; PlugInProcDef *proc_def = list->data;
if (gimp->be_verbose) if (gimp->be_verbose)
g_print (_("Starting extension: '%s'\n"), proc_def->db_info.name); g_print (_("Starting extension: '%s'\n"),
proc_def->procedure->name);
status_callback (NULL, proc_def->db_info.name, status_callback (NULL, proc_def->procedure->name,
(gdouble) nth / (gdouble) n_extensions); (gdouble) nth / (gdouble) n_extensions);
plug_in_run (gimp, context, NULL, &proc_def->db_info, plug_in_run (gimp, context, NULL, proc_def->procedure,
NULL, 0, FALSE, TRUE, -1); NULL, 0, FALSE, TRUE, -1);
} }
@ -646,7 +648,7 @@ plug_ins_temp_proc_def_add (Gimp *gimp,
} }
/* Register the procedural database entry */ /* Register the procedural database entry */
procedural_db_register (gimp, &proc_def->db_info); procedural_db_register (gimp, proc_def->procedure);
/* Add the definition to the global list */ /* Add the definition to the global list */
gimp->plug_in_proc_defs = g_slist_prepend (gimp->plug_in_proc_defs, proc_def); gimp->plug_in_proc_defs = g_slist_prepend (gimp->plug_in_proc_defs, proc_def);
@ -666,7 +668,7 @@ plug_ins_temp_proc_def_remove (Gimp *gimp,
} }
/* Unregister the procedural database entry */ /* Unregister the procedural database entry */
procedural_db_unregister (gimp, proc_def->db_info.name); procedural_db_unregister (gimp, proc_def->procedure->name);
/* Remove the definition from the global list */ /* Remove the definition from the global list */
gimp->plug_in_proc_defs = g_slist_remove (gimp->plug_in_proc_defs, proc_def); gimp->plug_in_proc_defs = g_slist_remove (gimp->plug_in_proc_defs, proc_def);
@ -868,7 +870,7 @@ plug_ins_proc_def_find (Gimp *gimp,
{ {
PlugInProcDef *proc_def = list->data; PlugInProcDef *proc_def = list->data;
if (proc_rec == &proc_def->db_info) if (proc_rec == proc_def->procedure)
return proc_def; return proc_def;
} }
@ -1044,10 +1046,10 @@ plug_ins_add_to_db (Gimp *gimp,
{ {
proc_def = list->data; proc_def = list->data;
if (proc_def->prog && (proc_def->db_info.proc_type != GIMP_INTERNAL)) if (proc_def->prog && (proc_def->procedure->proc_type != GIMP_INTERNAL))
{ {
proc_def->db_info.exec_method.plug_in.filename = proc_def->prog; proc_def->procedure->exec_method.plug_in.filename = proc_def->prog;
procedural_db_register (gimp, &proc_def->db_info); procedural_db_register (gimp, proc_def->procedure);
} }
} }
@ -1066,7 +1068,7 @@ plug_ins_add_to_db (Gimp *gimp,
procedural_db_run_proc (gimp, context, NULL, procedural_db_run_proc (gimp, context, NULL,
"gimp-register-save-handler", "gimp-register-save-handler",
&n_return_vals, &n_return_vals,
GIMP_PDB_STRING, proc_def->db_info.name, GIMP_PDB_STRING, proc_def->procedure->name,
GIMP_PDB_STRING, proc_def->extensions, GIMP_PDB_STRING, proc_def->extensions,
GIMP_PDB_STRING, proc_def->prefixes, GIMP_PDB_STRING, proc_def->prefixes,
GIMP_PDB_END); GIMP_PDB_END);
@ -1077,7 +1079,7 @@ plug_ins_add_to_db (Gimp *gimp,
procedural_db_run_proc (gimp, context, NULL, procedural_db_run_proc (gimp, context, NULL,
"gimp-register-magic-load-handler", "gimp-register-magic-load-handler",
&n_return_vals, &n_return_vals,
GIMP_PDB_STRING, proc_def->db_info.name, GIMP_PDB_STRING, proc_def->procedure->name,
GIMP_PDB_STRING, proc_def->extensions, GIMP_PDB_STRING, proc_def->extensions,
GIMP_PDB_STRING, proc_def->prefixes, GIMP_PDB_STRING, proc_def->prefixes,
GIMP_PDB_STRING, proc_def->magics, GIMP_PDB_STRING, proc_def->magics,
@ -1099,7 +1101,7 @@ plug_ins_proc_def_insert (Gimp *gimp,
{ {
PlugInProcDef *tmp_proc_def = list->data; PlugInProcDef *tmp_proc_def = list->data;
if (strcmp (proc_def->db_info.name, tmp_proc_def->db_info.name) == 0) if (strcmp (proc_def->procedure->name, tmp_proc_def->procedure->name) == 0)
{ {
list->data = proc_def; list->data = proc_def;

View File

@ -64,6 +64,23 @@ static Argument * xcf_save_invoker (ProcRecord *procedure,
Argument *args); Argument *args);
static ProcRecord xcf_load_procedure =
{
"gimp-xcf-load",
"gimp-xcf-load",
"loads file saved in the .xcf file format",
"The xcf file format has been designed specifically for loading and "
"saving tiled and layered images in the GIMP. This procedure will load "
"the specified file.",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996",
NULL,
GIMP_INTERNAL,
0, NULL, 0, NULL,
{ { xcf_load_invoker } }
};
static PlugInProcDef xcf_plug_in_load_proc = static PlugInProcDef xcf_plug_in_load_proc =
{ {
"gimp-xcf-load", "gimp-xcf-load",
@ -76,21 +93,7 @@ static PlugInProcDef xcf_plug_in_load_proc =
0, /* ignored for load */ 0, /* ignored for load */
0, 0,
FALSE, FALSE,
{ &xcf_load_procedure,
"gimp-xcf-load",
"gimp-xcf-load",
"loads file saved in the .xcf file format",
"The xcf file format has been designed specifically for loading and "
"saving tiled and layered images in the GIMP. This procedure will load "
"the specified file.",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996",
NULL,
GIMP_INTERNAL,
0, NULL, 0, NULL,
{ { xcf_load_invoker } },
},
TRUE, TRUE,
"xcf", "xcf",
"", "",
@ -101,6 +104,23 @@ static PlugInProcDef xcf_plug_in_load_proc =
NULL /* fill me in at runtime */ NULL /* fill me in at runtime */
}; };
static ProcRecord xcf_save_procedure =
{
"gimp-xcf-save",
"gimp-xcf-save",
"saves file in the .xcf file format",
"The xcf file format has been designed specifically for loading and "
"saving tiled and layered images in the GIMP. This procedure will save "
"the specified image in the xcf file format.",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996",
NULL,
GIMP_INTERNAL,
0, NULL, 0, NULL,
{ { xcf_save_invoker } }
};
static PlugInProcDef xcf_plug_in_save_proc = static PlugInProcDef xcf_plug_in_save_proc =
{ {
"gimp-xcf-save", "gimp-xcf-save",
@ -113,21 +133,7 @@ static PlugInProcDef xcf_plug_in_save_proc =
0, /* fill me in at runtime */ 0, /* fill me in at runtime */
0, 0,
FALSE, FALSE,
{ &xcf_save_procedure,
"gimp-xcf-save",
"gimp-xcf-save",
"saves file in the .xcf file format",
"The xcf file format has been designed specifically for loading and "
"saving tiled and layered images in the GIMP. This procedure will save "
"the specified image in the xcf file format.",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996",
NULL,
GIMP_INTERNAL,
0, NULL, 0, NULL,
{ { xcf_save_invoker } },
},
TRUE, TRUE,
"xcf", "xcf",
"", "",
@ -162,7 +168,7 @@ xcf_init (Gimp *gimp)
* though they are internal. The only thing it requires is using a * though they are internal. The only thing it requires is using a
* PlugInProcDef struct. -josh * PlugInProcDef struct. -josh
*/ */
procedure = gimp_procedure_init (&xcf_plug_in_save_proc.db_info, 5, 0); procedure = gimp_procedure_init (&xcf_save_procedure, 5, 0);
gimp_procedure_add_compat_arg (procedure, gimp, gimp_procedure_add_compat_arg (procedure, gimp,
GIMP_PDB_INT32, GIMP_PDB_INT32,
"dummy-param", "dummy-param",
@ -189,7 +195,7 @@ xcf_init (Gimp *gimp)
plug_ins_image_types_parse (xcf_plug_in_save_proc.image_types); plug_ins_image_types_parse (xcf_plug_in_save_proc.image_types);
plug_ins_add_internal (gimp, &xcf_plug_in_save_proc); plug_ins_add_internal (gimp, &xcf_plug_in_save_proc);
procedure = gimp_procedure_init (&xcf_plug_in_load_proc.db_info, 3, 1); procedure = gimp_procedure_init (&xcf_load_procedure, 3, 1);
gimp_procedure_add_compat_arg (procedure, gimp, gimp_procedure_add_compat_arg (procedure, gimp,
GIMP_PDB_INT32, GIMP_PDB_INT32,
"dummy-param", "dummy-param",
@ -318,7 +324,7 @@ xcf_save_invoker (ProcRecord *procedure,
Argument *return_vals; Argument *return_vals;
GimpImage *image; GimpImage *image;
const gchar *filename; const gchar *filename;
gboolean success = FALSE; gboolean success = FALSE;
gimp_set_busy (gimp); gimp_set_busy (gimp);

View File

@ -82,14 +82,14 @@ HELP
for (i = 3; i < proc->num_args; i++) for (i = 3; i < proc->num_args; i++)
if (proc->args[i].type == GIMP_PDB_STRING) if (proc->args[i].type == GIMP_PDB_STRING)
g_value_set_string (&new_args[i].value, ""); g_value_set_static_string (&new_args[i].value, "");
return_vals = procedural_db_execute (gimp, context, progress, return_vals = procedural_db_execute (gimp, context, progress,
proc->name, proc->name,
new_args, proc->num_args, new_args, proc->num_args,
&n_return_vals); &n_return_vals);
procedural_db_destroy_args (new_args, proc->num_args, FALSE); procedural_db_destroy_args (new_args, proc->num_args, TRUE);
return return_vals; return return_vals;
} }
@ -161,8 +161,7 @@ HELP
&josh_pdb_misc('1997'); &josh_pdb_misc('1997');
@inargs = ( @inargs = (
{ name => 'run_mode', { name => 'run_mode', type => 'enum GimpRunMode',
type => 'enum GimpRunMode (no GIMP_RUN_WITH_LAST_VALS)',
desc => 'The run mode: %%desc%%' }, desc => 'The run mode: %%desc%%' },
{ name => 'image', type => 'image', { name => 'image', type => 'image',
desc => 'Input image' }, desc => 'Input image' },
@ -174,7 +173,6 @@ HELP
desc => 'The name as entered by the user' } desc => 'The name as entered by the user' }
); );
%invoke = ( %invoke = (
headers => [ qw(<string.h>) ], headers => [ qw(<string.h>) ],
no_marshalling => 1, no_marshalling => 1,
@ -211,14 +209,14 @@ HELP
for (i = 5; i < proc->num_args; i++) for (i = 5; i < proc->num_args; i++)
if (proc->args[i].type == GIMP_PDB_STRING) if (proc->args[i].type == GIMP_PDB_STRING)
g_value_set_string (&new_args[i].value, ""); g_value_set_static_string (&new_args[i].value, "");
return_vals = procedural_db_execute (gimp, context, progress, return_vals = procedural_db_execute (gimp, context, progress,
proc->name, proc->name,
new_args, proc->num_args, new_args, proc->num_args,
&n_return_vals); &n_return_vals);
procedural_db_destroy_args (new_args, proc->num_args, FALSE); procedural_db_destroy_args (new_args, proc->num_args, TRUE);
return return_vals; return return_vals;
} }
@ -388,7 +386,9 @@ HELP
%invoke = ( %invoke = (
headers => [ qw("core/gimp-utils.h") ], headers => [ qw("core/gimp-utils.h") ],
code => <<'CODE' code => <<'CODE'
{
name = gimp_get_temp_filename (gimp, extension); name = gimp_get_temp_filename (gimp, extension);
}
CODE CODE
); );
} }