gboolean procedure_commands_run_procedure (GimpProcedure *procedure, Gimp *gimp, GimpProgress *progress, GimpRunMode run_mode, GimpValueArray *args, GimpDisplay *display) { GError *error = NULL; g_return_val_if_fail (GIMP_IS_PROCEDURE (procedure), FALSE); g_return_val_if_fail (GIMP_IS_GIMP (gimp), FALSE); g_return_val_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress), FALSE); g_return_val_if_fail (display == NULL || GIMP_IS_DISPLAY (display), FALSE); g_return_val_if_fail (args != NULL, FALSE); g_value_set_int (gimp_value_array_index (args, 0), run_mode); gimp_procedure_execute_async (procedure, gimp, gimp_get_user_context (gimp), progress, args, GIMP_OBJECT (display), &error); if (error) { gimp_message_literal (gimp, G_OBJECT (progress), GIMP_MESSAGE_ERROR, error->message); g_clear_error (&error); return FALSE; } return TRUE; }
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); } }
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; }
/* run automatically started extensions */ static void gimp_plug_in_manager_run_extensions (GimpPlugInManager *manager, GimpContext *context, GimpInitStatusFunc status_callback) { Gimp *gimp = manager->gimp; GSList *list; GList *extensions = NULL; gint n_extensions; /* build list of automatically started extensions */ for (list = manager->plug_in_procedures; list; list = list->next) { GimpPlugInProcedure *proc = list->data; if (proc->prog && GIMP_PROCEDURE (proc)->proc_type == GIMP_EXTENSION && GIMP_PROCEDURE (proc)->num_args == 0) { extensions = g_list_prepend (extensions, proc); } } extensions = g_list_reverse (extensions); n_extensions = g_list_length (extensions); /* run the available extensions */ if (extensions) { GList *list; gint nth; status_callback (_("Starting Extensions"), "", 0.0); for (list = extensions, nth = 0; list; list = g_list_next (list), nth++) { GimpPlugInProcedure *proc = list->data; GValueArray *args; GError *error = NULL; if (gimp->be_verbose) g_print ("Starting extension: '%s'\n", gimp_object_get_name (proc)); status_callback (NULL, gimp_object_get_name (proc), (gdouble) nth / (gdouble) n_extensions); args = g_value_array_new (0); gimp_procedure_execute_async (GIMP_PROCEDURE (proc), gimp, context, NULL, args, NULL, &error); g_value_array_free (args); if (error) { gimp_message_literal (gimp, NULL, GIMP_MESSAGE_ERROR, error->message); g_clear_error (&error); } } g_list_free (extensions); status_callback (NULL, "", 1.0); } }