gboolean gimp_plug_in_cleanup_undo_group_start (GimpPlugIn *plug_in, GimpImage *image) { GimpPlugInProcFrame *proc_frame; GimpPlugInCleanupImage *cleanup; g_return_val_if_fail (GIMP_IS_PLUG_IN (plug_in), FALSE); g_return_val_if_fail (GIMP_IS_IMAGE (image), FALSE); proc_frame = gimp_plug_in_get_proc_frame (plug_in); cleanup = gimp_plug_in_cleanup_image_get (proc_frame, image); if (! cleanup) { cleanup = gimp_plug_in_cleanup_image_new (image); cleanup->undo_group_count = gimp_image_get_undo_group_count (image); proc_frame->image_cleanups = g_list_prepend (proc_frame->image_cleanups, cleanup); } return TRUE; }
gboolean gimp_plug_in_cleanup_remove_shadow (GimpPlugIn *plug_in, GimpDrawable *drawable) { GimpPlugInProcFrame *proc_frame; GimpPlugInCleanupItem *cleanup; g_return_val_if_fail (GIMP_IS_PLUG_IN (plug_in), FALSE); g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), FALSE); proc_frame = gimp_plug_in_get_proc_frame (plug_in); cleanup = gimp_plug_in_cleanup_item_get (proc_frame, GIMP_ITEM (drawable)); if (! cleanup) return FALSE; if (! cleanup->shadow_buffer) return FALSE; proc_frame->item_cleanups = g_list_remove (proc_frame->item_cleanups, cleanup); gimp_plug_in_cleanup_item_free (cleanup); return TRUE; }
gboolean gimp_plug_in_cleanup_add_shadow (GimpPlugIn *plug_in, GimpDrawable *drawable) { GimpPlugInProcFrame *proc_frame; GimpPlugInCleanupItem *cleanup; g_return_val_if_fail (GIMP_IS_PLUG_IN (plug_in), FALSE); g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), FALSE); proc_frame = gimp_plug_in_get_proc_frame (plug_in); cleanup = gimp_plug_in_cleanup_item_get (proc_frame, GIMP_ITEM (drawable)); if (! cleanup) { cleanup = gimp_plug_in_cleanup_item_new (GIMP_ITEM (drawable)); proc_frame->item_cleanups = g_list_prepend (proc_frame->item_cleanups, cleanup); } cleanup->shadow_tiles = TRUE; return TRUE; }
void gimp_plug_in_set_error_handler (GimpPlugIn *plug_in, GimpPDBErrorHandler handler) { GimpPlugInProcFrame *proc_frame; g_return_if_fail (GIMP_IS_PLUG_IN (plug_in)); proc_frame = gimp_plug_in_get_proc_frame (plug_in); if (proc_frame) proc_frame->error_handler = handler; }
void gimp_plug_in_progress_set_text (GimpPlugIn *plug_in, const gchar *message) { GimpPlugInProcFrame *proc_frame; g_return_if_fail (GIMP_IS_PLUG_IN (plug_in)); proc_frame = gimp_plug_in_get_proc_frame (plug_in); if (proc_frame->progress) gimp_progress_set_text_literal (proc_frame->progress, message); }
void gimp_plug_in_progress_start (GimpPlugIn *plug_in, const gchar *message, GimpObject *display) { GimpPlugInProcFrame *proc_frame; g_return_if_fail (GIMP_IS_PLUG_IN (plug_in)); g_return_if_fail (display == NULL || GIMP_IS_OBJECT (display)); proc_frame = gimp_plug_in_get_proc_frame (plug_in); if (! proc_frame->progress) { proc_frame->progress = gimp_new_progress (plug_in->manager->gimp, display); if (proc_frame->progress) { proc_frame->progress_created = TRUE; g_object_ref (proc_frame->progress); gimp_plug_in_progress_attach (proc_frame->progress); } } if (proc_frame->progress) { if (! proc_frame->progress_cancel_id) proc_frame->progress_cancel_id = g_signal_connect (proc_frame->progress, "cancel", G_CALLBACK (gimp_plug_in_progress_cancel_callback), plug_in); if (gimp_progress_is_active (proc_frame->progress)) { if (message) gimp_progress_set_text (proc_frame->progress, message); if (gimp_progress_get_value (proc_frame->progress) > 0.0) gimp_progress_set_value (proc_frame->progress, 0.0); } else { gimp_progress_start (proc_frame->progress, message ? message : "", TRUE); } } }
guint32 gimp_plug_in_progress_get_window_id (GimpPlugIn *plug_in) { GimpPlugInProcFrame *proc_frame; g_return_val_if_fail (GIMP_IS_PLUG_IN (plug_in), 0); proc_frame = gimp_plug_in_get_proc_frame (plug_in); if (proc_frame->progress) return gimp_progress_get_window_id (proc_frame->progress); return 0; }
GimpPDBErrorHandler gimp_plug_in_get_error_handler (GimpPlugIn *plug_in) { GimpPlugInProcFrame *proc_frame; g_return_val_if_fail (GIMP_IS_PLUG_IN (plug_in), GIMP_PDB_ERROR_HANDLER_INTERNAL); proc_frame = gimp_plug_in_get_proc_frame (plug_in); if (proc_frame) return proc_frame->error_handler; return GIMP_PDB_ERROR_HANDLER_INTERNAL; }
gboolean gimp_plug_in_progress_install (GimpPlugIn *plug_in, const gchar *progress_callback) { GimpPlugInProcFrame *proc_frame; GimpProcedure *procedure; g_return_val_if_fail (GIMP_IS_PLUG_IN (plug_in), FALSE); g_return_val_if_fail (progress_callback != NULL, FALSE); procedure = gimp_pdb_lookup_procedure (plug_in->manager->gimp->pdb, progress_callback); if (! GIMP_IS_TEMPORARY_PROCEDURE (procedure) || GIMP_TEMPORARY_PROCEDURE (procedure)->plug_in != plug_in || procedure->num_args != 3 || ! GIMP_IS_PARAM_SPEC_INT32 (procedure->args[0]) || ! G_IS_PARAM_SPEC_STRING (procedure->args[1]) || ! G_IS_PARAM_SPEC_DOUBLE (procedure->args[2])) { return FALSE; } proc_frame = gimp_plug_in_get_proc_frame (plug_in); if (proc_frame->progress) { gimp_plug_in_progress_end (plug_in, proc_frame); if (proc_frame->progress) { g_object_unref (proc_frame->progress); proc_frame->progress = NULL; } } proc_frame->progress = g_object_new (GIMP_TYPE_PDB_PROGRESS, "pdb", plug_in->manager->gimp->pdb, "context", proc_frame->main_context, "callback-name", progress_callback, NULL); gimp_plug_in_progress_attach (proc_frame->progress); return TRUE; }
void gimp_plug_in_progress_pulse (GimpPlugIn *plug_in) { GimpPlugInProcFrame *proc_frame; g_return_if_fail (GIMP_IS_PLUG_IN (plug_in)); proc_frame = gimp_plug_in_get_proc_frame (plug_in); if (! proc_frame->progress || ! gimp_progress_is_active (proc_frame->progress) || ! proc_frame->progress_cancel_id) { gimp_plug_in_progress_start (plug_in, NULL, NULL); } if (proc_frame->progress && gimp_progress_is_active (proc_frame->progress)) gimp_progress_pulse (proc_frame->progress); }
static GValueArray * progress_end_invoker (GimpProcedure *procedure, Gimp *gimp, GimpContext *context, GimpProgress *progress, const GValueArray *args) { gboolean success = TRUE; GimpPlugIn *plug_in = gimp->plug_in_manager->current_plug_in; if (plug_in && plug_in->open) { GimpPlugInProcFrame *proc_frame = gimp_plug_in_get_proc_frame (plug_in); gimp_plug_in_progress_end (plug_in, proc_frame); } else success = FALSE; return gimp_procedure_get_return_values (procedure, success); }
const gchar * gimp_plug_in_get_undo_desc (GimpPlugIn *plug_in) { GimpPlugInProcFrame *proc_frame; const gchar *undo_desc = NULL; g_return_val_if_fail (GIMP_IS_PLUG_IN (plug_in), NULL); proc_frame = gimp_plug_in_get_proc_frame (plug_in); if (proc_frame) { GimpPlugInProcedure *proc; proc = GIMP_PLUG_IN_PROCEDURE (proc_frame->procedure); if (proc) undo_desc = gimp_plug_in_procedure_get_label (proc); } return undo_desc ? undo_desc : gimp_object_get_name (plug_in); }
gboolean gimp_plug_in_progress_uninstall (GimpPlugIn *plug_in, const gchar *progress_callback) { GimpPlugInProcFrame *proc_frame; g_return_val_if_fail (GIMP_IS_PLUG_IN (plug_in), FALSE); g_return_val_if_fail (progress_callback != NULL, FALSE); proc_frame = gimp_plug_in_get_proc_frame (plug_in); if (GIMP_IS_PDB_PROGRESS (proc_frame->progress)) { gimp_plug_in_progress_end (plug_in, proc_frame); g_object_unref (proc_frame->progress); proc_frame->progress = NULL; return TRUE; } return FALSE; }
gboolean gimp_plug_in_cleanup_undo_group_end (GimpPlugIn *plug_in, GimpImage *image) { GimpPlugInProcFrame *proc_frame; GimpPlugInCleanupImage *cleanup; g_return_val_if_fail (GIMP_IS_PLUG_IN (plug_in), FALSE); g_return_val_if_fail (GIMP_IS_IMAGE (image), FALSE); proc_frame = gimp_plug_in_get_proc_frame (plug_in); cleanup = gimp_plug_in_cleanup_get_image (proc_frame, image); if (! cleanup) return FALSE; if (cleanup->undo_group_count == image->group_count - 1) { proc_frame->cleanups = g_list_remove (proc_frame->cleanups, cleanup); g_slice_free (GimpPlugInCleanupImage, cleanup); } return TRUE; }
static gboolean gimp_plug_in_recv_message (GIOChannel *channel, GIOCondition cond, gpointer data) { GimpPlugIn *plug_in = data; gboolean got_message = FALSE; #ifdef G_OS_WIN32 /* Workaround for GLib bug #137968: sometimes we are called for no * reason... */ if (cond == 0) return TRUE; #endif if (plug_in->my_read == NULL) return TRUE; g_object_ref (plug_in); if (cond & (G_IO_IN | G_IO_PRI)) { GimpWireMessage msg; memset (&msg, 0, sizeof (GimpWireMessage)); if (! gimp_wire_read_msg (plug_in->my_read, &msg, plug_in)) { gimp_plug_in_close (plug_in, TRUE); } else { gimp_plug_in_handle_message (plug_in, &msg); gimp_wire_destroy (&msg); got_message = TRUE; } } if (cond & (G_IO_ERR | G_IO_HUP)) { if (cond & G_IO_HUP) plug_in->hup = TRUE; if (plug_in->open) gimp_plug_in_close (plug_in, TRUE); } if (! got_message) { GimpPlugInProcFrame *frame = gimp_plug_in_get_proc_frame (plug_in); GimpProgress *progress = frame ? frame->progress : NULL; gimp_message (plug_in->manager->gimp, G_OBJECT (progress), GIMP_MESSAGE_ERROR, _("Plug-in crashed: \"%s\"\n(%s)\n\n" "The dying plug-in may have messed up GIMP's internal " "state. You may want to save your images and restart " "GIMP to be on the safe side."), gimp_object_get_name (plug_in), gimp_filename_to_utf8 (plug_in->prog)); } g_object_unref (plug_in); return TRUE; }
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); }