gboolean gimp_pdb_proc_info (GimpPDB *pdb, const gchar *proc_name, gchar **blurb, gchar **help, gchar **author, gchar **copyright, gchar **date, GimpPDBProcType *proc_type, gint *num_args, gint *num_values, GError **error) { GimpProcedure *procedure; PDBStrings strings; g_return_val_if_fail (GIMP_IS_PDB (pdb), FALSE); g_return_val_if_fail (proc_name != NULL, FALSE); g_return_val_if_fail (error == NULL || *error == NULL, FALSE); procedure = gimp_pdb_lookup_procedure (pdb, proc_name); if (procedure) { gimp_pdb_get_strings (&strings, procedure, FALSE); } else { const gchar *compat_name; compat_name = gimp_pdb_lookup_compat_proc_name (pdb, proc_name); if (compat_name) { procedure = gimp_pdb_lookup_procedure (pdb, compat_name); if (procedure) gimp_pdb_get_strings (&strings, procedure, TRUE); } } if (procedure) { *blurb = strings.compat ? strings.blurb : g_strdup (strings.blurb); *help = strings.compat ? strings.help : g_strdup (strings.help); *author = strings.compat ? strings.author : g_strdup (strings.author); *copyright = strings.compat ? strings.copyright : g_strdup (strings.copyright); *date = strings.compat ? strings.date : g_strdup (strings.date); *proc_type = procedure->proc_type; *num_args = procedure->num_args; *num_values = procedure->num_values; return TRUE; } g_set_error (error, GIMP_PDB_ERROR, GIMP_PDB_PROCEDURE_NOT_FOUND, _("Procedure '%s' not found"), proc_name); return FALSE; }
static GimpValueArray * procedural_db_proc_exists_invoker (GimpProcedure *procedure, Gimp *gimp, GimpContext *context, GimpProgress *progress, const GimpValueArray *args, GError **error) { gboolean success = TRUE; GimpValueArray *return_vals; const gchar *procedure_name; gboolean exists = FALSE; procedure_name = g_value_get_string (gimp_value_array_index (args, 0)); if (success) { GimpProcedure *procedure; gchar *canonical; canonical = gimp_canonicalize_identifier (procedure_name); procedure = gimp_pdb_lookup_procedure (gimp->pdb, canonical); if (! procedure) { procedure_name = gimp_pdb_lookup_compat_proc_name (gimp->pdb, canonical); if (procedure_name) procedure = gimp_pdb_lookup_procedure (gimp->pdb, procedure_name); } g_free (canonical); exists = (procedure != NULL); } return_vals = gimp_procedure_get_return_values (procedure, success, error ? *error : NULL); if (success) g_value_set_boolean (gimp_value_array_index (return_vals, 1), exists); return return_vals; }
static GimpValueArray * procedural_db_proc_val_invoker (GimpProcedure *procedure, Gimp *gimp, GimpContext *context, GimpProgress *progress, const GimpValueArray *args, GError **error) { gboolean success = TRUE; GimpValueArray *return_vals; const gchar *procedure_name; gint32 val_num; gint32 val_type = 0; gchar *val_name = NULL; gchar *val_desc = NULL; procedure_name = g_value_get_string (gimp_value_array_index (args, 0)); val_num = g_value_get_int (gimp_value_array_index (args, 1)); if (success) { GimpProcedure *proc; gchar *canonical; canonical = gimp_canonicalize_identifier (procedure_name); proc = gimp_pdb_lookup_procedure (gimp->pdb, canonical); if (! proc) { const gchar *compat_name; compat_name = gimp_pdb_lookup_compat_proc_name (gimp->pdb, canonical); if (compat_name) proc = gimp_pdb_lookup_procedure (gimp->pdb, compat_name); } g_free (canonical); if (proc && (val_num >= 0 && val_num < proc->num_values)) { GParamSpec *pspec = proc->values[val_num]; val_type = gimp_pdb_compat_arg_type_from_gtype (G_PARAM_SPEC_VALUE_TYPE (pspec)); val_name = g_strdup (g_param_spec_get_name (pspec)); val_desc = gimp_param_spec_get_desc (pspec); } else success = FALSE; } return_vals = gimp_procedure_get_return_values (procedure, success, error ? *error : NULL); if (success) { g_value_set_enum (gimp_value_array_index (return_vals, 1), val_type); g_value_take_string (gimp_value_array_index (return_vals, 2), val_name); g_value_take_string (gimp_value_array_index (return_vals, 3), val_desc); } return return_vals; }
static void gimp_plug_in_handle_proc_run (GimpPlugIn *plug_in, GPProcRun *proc_run) { GimpPlugInProcFrame *proc_frame; gchar *canonical; const gchar *proc_name = NULL; GimpProcedure *procedure; GimpValueArray *args = NULL; GimpValueArray *return_vals = NULL; GError *error = NULL; g_return_if_fail (proc_run != NULL); g_return_if_fail (proc_run->name != NULL); canonical = gimp_canonicalize_identifier (proc_run->name); proc_frame = gimp_plug_in_get_proc_frame (plug_in); procedure = gimp_pdb_lookup_procedure (plug_in->manager->gimp->pdb, canonical); if (! procedure) { proc_name = gimp_pdb_lookup_compat_proc_name (plug_in->manager->gimp->pdb, canonical); if (proc_name) { procedure = gimp_pdb_lookup_procedure (plug_in->manager->gimp->pdb, proc_name); if (plug_in->manager->gimp->pdb_compat_mode == GIMP_PDB_COMPAT_WARN) { gimp_message (plug_in->manager->gimp, NULL, GIMP_MESSAGE_WARNING, "Plug-In \"%s\"\n(%s)\n" "called deprecated procedure '%s'.\n" "It should call '%s' instead!", gimp_object_get_name (plug_in), gimp_file_get_utf8_name (plug_in->file), canonical, proc_name); } } } else if (procedure->deprecated) { if (plug_in->manager->gimp->pdb_compat_mode == GIMP_PDB_COMPAT_WARN) { if (! strcmp (procedure->deprecated, "NONE")) { gimp_message (plug_in->manager->gimp, NULL, GIMP_MESSAGE_WARNING, "Plug-In \"%s\"\n(%s)\n" "called deprecated procedure '%s'.", gimp_object_get_name (plug_in), gimp_file_get_utf8_name (plug_in->file), canonical); } else { gimp_message (plug_in->manager->gimp, NULL, GIMP_MESSAGE_WARNING, "WARNING: Plug-In \"%s\"\n(%s)\n" "called deprecated procedure '%s'.\n" "It should call '%s' instead!", gimp_object_get_name (plug_in), gimp_file_get_utf8_name (plug_in->file), canonical, procedure->deprecated); } } } if (! proc_name) proc_name = canonical; args = plug_in_params_to_args (procedure ? procedure->args : NULL, procedure ? procedure->num_args : 0, proc_run->params, proc_run->nparams, FALSE, FALSE); /* Execute the procedure even if gimp_pdb_lookup_procedure() * returned NULL, gimp_pdb_execute_procedure_by_name_args() will * return appropriate error return_vals. */ gimp_plug_in_manager_plug_in_push (plug_in->manager, plug_in); return_vals = gimp_pdb_execute_procedure_by_name_args (plug_in->manager->gimp->pdb, proc_frame->context_stack ? proc_frame->context_stack->data : proc_frame->main_context, proc_frame->progress, &error, proc_name, args); gimp_plug_in_manager_plug_in_pop (plug_in->manager); gimp_value_array_unref (args); if (error) { gimp_plug_in_handle_proc_error (plug_in, proc_frame, canonical, error); g_error_free (error); } g_free (canonical); /* Don't bother to send the return value if executing the procedure * closed the plug-in (e.g. if the procedure is gimp-quit) */ if (plug_in->open) { GPProcReturn proc_return; /* Return the name we got called with, *not* proc_name or canonical, * since proc_name may have been remapped by gimp->procedural_compat_ht * and canonical may be different too. */ proc_return.name = proc_run->name; proc_return.nparams = gimp_value_array_length (return_vals); proc_return.params = plug_in_args_to_params (return_vals, FALSE); if (! gp_proc_return_write (plug_in->my_write, &proc_return, plug_in)) { gimp_message (plug_in->manager->gimp, NULL, GIMP_MESSAGE_ERROR, "%s: ERROR", G_STRFUNC); gimp_plug_in_close (plug_in, TRUE); } g_free (proc_return.params); } gimp_value_array_unref (return_vals); }