GimpValueArray * procedure_commands_get_image_args (GimpProcedure *procedure, GimpImage *image) { GimpValueArray *args; gint n_args = 0; args = gimp_procedure_get_arguments (procedure); /* initialize the first argument */ g_value_set_int (gimp_value_array_index (args, n_args), GIMP_RUN_INTERACTIVE); n_args++; if (gimp_value_array_length (args) > n_args && GIMP_IS_PARAM_SPEC_IMAGE_ID (procedure->args[n_args])) { if (image) { gimp_value_set_image (gimp_value_array_index (args, n_args), image); n_args++; } else { g_warning ("Uh-oh, no active image for the plug-in!"); gimp_value_array_unref (args); return NULL; } } gimp_value_array_truncate (args, n_args); return args; }
GimpValueArray * procedure_commands_get_data_args (GimpProcedure *procedure, GimpObject *object) { GimpValueArray *args; gint n_args = 0; args = gimp_procedure_get_arguments (procedure); /* initialize the first argument */ g_value_set_int (gimp_value_array_index (args, n_args), GIMP_RUN_INTERACTIVE); n_args++; if (gimp_value_array_length (args) > n_args && GIMP_IS_PARAM_SPEC_STRING (procedure->args[n_args])) { if (object) { g_value_set_string (gimp_value_array_index (args, n_args), gimp_object_get_name (object)); n_args++; } else { g_warning ("Uh-oh, no active data object for the plug-in!"); gimp_value_array_unref (args); return NULL; } } gimp_value_array_truncate (args, n_args); return args; }
static void plug_in_procedure_execute (GimpPlugInProcedure *procedure, Gimp *gimp, GimpDisplay *display, GimpValueArray *args, gint n_args) { GError *error = NULL; gimp_value_array_truncate (args, n_args); /* run the plug-in procedure */ gimp_procedure_execute_async (GIMP_PROCEDURE (procedure), gimp, gimp_get_user_context (gimp), GIMP_PROGRESS (display), args, GIMP_OBJECT (display), &error); if (error) { gimp_message_literal (gimp, G_OBJECT (display), GIMP_MESSAGE_ERROR, error->message); g_error_free (error); } else { /* remember only image plug-ins */ if (GIMP_PROCEDURE (procedure)->num_args >= 2 && GIMP_IS_PARAM_SPEC_IMAGE_ID (GIMP_PROCEDURE (procedure)->args[1])) { gimp_plug_in_manager_history_add (gimp->plug_in_manager, procedure); } } }
void vectors_selection_to_vectors_cmd_callback (GtkAction *action, gint value, gpointer data) { GimpImage *image; GtkWidget *widget; GimpProcedure *procedure; GimpValueArray *args; GimpDisplay *display; GError *error = NULL; return_if_no_image (image, data); return_if_no_widget (widget, data); if (value) procedure = gimp_pdb_lookup_procedure (image->gimp->pdb, "plug-in-sel2path-advanced"); else procedure = gimp_pdb_lookup_procedure (image->gimp->pdb, "plug-in-sel2path"); if (! procedure) { gimp_message_literal (image->gimp, G_OBJECT (widget), GIMP_MESSAGE_ERROR, "Selection to path procedure lookup failed."); return; } display = gimp_context_get_display (action_data_get_context (data)); args = gimp_procedure_get_arguments (procedure); gimp_value_array_truncate (args, 2); g_value_set_int (gimp_value_array_index (args, 0), GIMP_RUN_INTERACTIVE); gimp_value_set_image (gimp_value_array_index (args, 1), image); gimp_procedure_execute_async (procedure, image->gimp, action_data_get_context (data), GIMP_PROGRESS (display), args, GIMP_OBJECT (display), &error); gimp_value_array_unref (args); if (error) { gimp_message_literal (image->gimp, G_OBJECT (widget), GIMP_MESSAGE_ERROR, error->message); g_error_free (error); } }
GimpValueArray * procedure_commands_get_run_mode_arg (GimpProcedure *procedure) { GimpValueArray *args; gint n_args = 0; args = gimp_procedure_get_arguments (procedure); /* initialize the first argument */ if (gimp_value_array_length (args) > n_args && GIMP_IS_PARAM_SPEC_INT32 (procedure->args[n_args])) { g_value_set_int (gimp_value_array_index (args, n_args), GIMP_RUN_INTERACTIVE); n_args++; } gimp_value_array_truncate (args, n_args); return args; }
static void gimp_help_call (Gimp *gimp, const gchar *procedure_name, const gchar *help_domain, const gchar *help_locales, const gchar *help_id) { GimpProcedure *procedure; /* Special case the help browser */ if (! strcmp (procedure_name, "extension-gimp-help-browser-temp")) { GValueArray *return_vals; return_vals = gimp_pdb_execute_procedure_by_name (gimp->pdb, gimp_get_user_context (gimp), NULL, procedure_name, G_TYPE_STRING, help_domain, G_TYPE_STRING, help_locales, G_TYPE_STRING, help_id, G_TYPE_NONE); g_value_array_free (return_vals); return; } /* Check if a help parser is already running */ procedure = gimp_pdb_lookup_procedure (gimp->pdb, "extension-gimp-help-temp"); if (! procedure) { GValueArray *args = NULL; gint n_domains = 0; gchar **help_domains = NULL; gchar **help_uris = NULL; procedure = gimp_pdb_lookup_procedure (gimp->pdb, "extension-gimp-help"); if (! procedure) /* FIXME: error msg */ return; n_domains = gimp_plug_in_manager_get_help_domains (gimp->plug_in_manager, &help_domains, &help_uris); args = gimp_procedure_get_arguments (procedure); gimp_value_array_truncate (args, 4); g_value_set_int (&args->values[0], n_domains); gimp_value_take_stringarray (&args->values[1], help_domains, n_domains); g_value_set_int (&args->values[2], n_domains); gimp_value_take_stringarray (&args->values[3], help_uris, n_domains); gimp_procedure_execute_async (procedure, gimp, gimp_get_user_context (gimp), NULL, args, NULL); g_value_array_free (args); } /* Check if the help parser started properly */ procedure = gimp_pdb_lookup_procedure (gimp->pdb, "extension-gimp-help-temp"); if (procedure) { GValueArray *return_vals; #ifdef GIMP_HELP_DEBUG g_printerr ("Calling help via %s: %s %s %s\n", procedure_name, help_domain ? help_domain : "(null)", help_locales ? help_locales : "(null)", help_id ? help_id : "(null)"); #endif return_vals = gimp_pdb_execute_procedure_by_name (gimp->pdb, gimp_get_user_context (gimp), NULL, "extension-gimp-help-temp", G_TYPE_STRING, procedure_name, G_TYPE_STRING, help_domain, G_TYPE_STRING, help_locales, G_TYPE_STRING, help_id, G_TYPE_NONE); g_value_array_free (return_vals); } }
static gboolean gimp_help_browser (Gimp *gimp) { static gboolean busy = FALSE; GimpProcedure *procedure; if (busy) return TRUE; busy = TRUE; /* Check if a help browser is already running */ procedure = gimp_pdb_lookup_procedure (gimp->pdb, "extension-gimp-help-browser-temp"); if (! procedure) { GValueArray *args = NULL; gint n_domains = 0; gchar **help_domains = NULL; gchar **help_uris = NULL; procedure = gimp_pdb_lookup_procedure (gimp->pdb, "extension-gimp-help-browser"); if (! procedure) { gimp_help_browser_error (gimp, _("Help browser not found"), _("Could not find GIMP help browser."), _("The GIMP help browser plug-in appears " "to be missing from your installation.")); busy = FALSE; return FALSE; } n_domains = gimp_plug_in_manager_get_help_domains (gimp->plug_in_manager, &help_domains, &help_uris); args = gimp_procedure_get_arguments (procedure); gimp_value_array_truncate (args, 5); g_value_set_int (&args->values[0], GIMP_RUN_INTERACTIVE); g_value_set_int (&args->values[1], n_domains); gimp_value_take_stringarray (&args->values[2], help_domains, n_domains); g_value_set_int (&args->values[3], n_domains); gimp_value_take_stringarray (&args->values[4], help_uris, n_domains); gimp_procedure_execute_async (procedure, gimp, gimp_get_user_context (gimp), NULL, args, NULL); g_value_array_free (args); } /* Check if the help browser started properly */ procedure = gimp_pdb_lookup_procedure (gimp->pdb, "extension-gimp-help-browser-temp"); if (! procedure) { gimp_help_browser_error (gimp, _("Help browser doesn't start"), _("Could not start the GIMP help browser plug-in."), NULL); busy = FALSE; return FALSE; } busy = FALSE; return TRUE; }
GimpValueArray * procedure_commands_get_display_args (GimpProcedure *procedure, GimpDisplay *display) { GimpValueArray *args; gint n_args = 0; args = gimp_procedure_get_arguments (procedure); /* initialize the first argument */ g_value_set_int (gimp_value_array_index (args, n_args), GIMP_RUN_INTERACTIVE); n_args++; if (gimp_value_array_length (args) > n_args && GIMP_IS_PARAM_SPEC_DISPLAY_ID (procedure->args[n_args])) { if (display) { gimp_value_set_display (gimp_value_array_index (args, n_args), GIMP_OBJECT (display)); n_args++; } else { g_warning ("Uh-oh, no active display for the plug-in!"); gimp_value_array_unref (args); return NULL; } } if (gimp_value_array_length (args) > n_args && GIMP_IS_PARAM_SPEC_IMAGE_ID (procedure->args[n_args])) { GimpImage *image = display ? gimp_display_get_image (display) : NULL; if (image) { gimp_value_set_image (gimp_value_array_index (args, n_args), image); n_args++; if (gimp_value_array_length (args) > n_args && GIMP_IS_PARAM_SPEC_DRAWABLE_ID (procedure->args[n_args])) { GimpDrawable *drawable = gimp_image_get_active_drawable (image); if (drawable) { gimp_value_set_drawable (gimp_value_array_index (args, n_args), drawable); n_args++; } else { g_warning ("Uh-oh, no active drawable for the plug-in!"); gimp_value_array_unref (args); return NULL; } } } } gimp_value_array_truncate (args, n_args); return args; }