Gimp/app/plug-in/plug-in-progress.c
Michael Natterer 2db2ef6185 removed gimp_main_loop() and gimp_main_loop_quit() because they were a
2003-02-03  Michael Natterer  <mitch@gimp.org>

	* app/core/gimp.[ch]: removed gimp_main_loop() and
	gimp_main_loop_quit() because they were a temp_hack until plug-ins
	have their own main loops. Added gimp_threads_enter() and
	gimp_threads_leave() instead.

	* app/gui/gui.c: ditto: removed the main loop stuff and added
	functions which call GDK_THREADS_ENTER() and GDK_THREADS_LEAVE()
	instead.

	* app/app_procs.c: create the main GMainLoop here and use
	gimp_threads_enter,leave().

	* app/plug-in/plug-in.[ch]: added a ref_count per plug-in so the
	plug-in is not destroyed under our feet while running a recursive
	main loop. Added plug_in_ref(). Changed plug_in_destroy() to
	plug_in_unref(). Don't destroy the plug-in if plug_in_open()
	fails. Call gimp_threads_enter,leave() around g_main_loop_run().
	Changed the way plug_in_push,pop() are used: "current_plug_in" is
	no longer the plug-in which currently uses the wire, but the
	plug-in which currently preforms a PDB call (the former meaning
	was needed when wire callbacks had no plug-in context but needed
	to get the plug-in from the global "current_plug_in" variable).
	Removed all calls to plug_in_push,pop() from this file.

	* app/plug-in/plug-in-message.c (plug_in_handle_proc_run): added
	plug_in_push,pop() around procedural_db_execute(). No need
	to construct an error return value if the procedure was not found
	because procedural_db_execute() already does this.

	Removed all other plug_in_push,pop(). Added more checks to plug-in
	message handlers and kill the plug-in if it misbehaves. Cleanup.

	* app/plug-in/plug-in-progress.c (plug_in_progress_cancel): if the
	plug-in runs synchronously, provide a GIMP_PDB_CANCEL return value
	so we don't see error messages about the "failed" procedure.

	* app/plug-in/plug-in-run.c: removed plug_in_push,pop() stuff.
	Set the new plug_in->starting_ext boolean while starting an
	extension so the extension_ack handler knows that it wasn't called
	from a buggy plug-in. Cleanup.

	* app/plug-in/plug-ins.c: Cleanup.
2003-02-03 13:21:31 +00:00

114 lines
2.9 KiB
C

/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <gtk/gtk.h>
#include "plug-in-types.h"
#ifdef __GNUC__
#warning FIXME #include "display/display-types.h"
#endif
#include "display/display-types.h"
#include "pdb/procedural_db.h"
#include "display/gimpdisplay.h"
#include "display/gimpprogress.h"
#include "plug-in.h"
#include "plug-in-progress.h"
/* local function prototypes */
static void plug_in_progress_cancel (GtkWidget *widget,
PlugIn *plug_in);
/* public functions */
void
plug_in_progress_start (PlugIn *plug_in,
const gchar *message,
gint gdisp_ID)
{
GimpDisplay *gdisp = NULL;
g_return_if_fail (plug_in != NULL);
if (! message)
message = plug_in->args[0];
if (gdisp_ID > 0)
gdisp = gimp_display_get_by_ID (plug_in->gimp, gdisp_ID);
if (plug_in->progress)
plug_in->progress = gimp_progress_restart (plug_in->progress, message,
G_CALLBACK (plug_in_progress_cancel),
plug_in);
else
plug_in->progress = gimp_progress_start (gdisp, message, TRUE,
G_CALLBACK (plug_in_progress_cancel),
plug_in);
}
void
plug_in_progress_update (PlugIn *plug_in,
gdouble percentage)
{
g_return_if_fail (plug_in != NULL);
if (! plug_in->progress)
plug_in_progress_start (plug_in, NULL, -1);
gimp_progress_update (plug_in->progress, percentage);
}
void
plug_in_progress_end (PlugIn *plug_in)
{
g_return_if_fail (plug_in != NULL);
if (plug_in->progress)
{
gimp_progress_end (plug_in->progress);
plug_in->progress = NULL;
}
}
/* private functions */
static void
plug_in_progress_cancel (GtkWidget *widget,
PlugIn *plug_in)
{
if (plug_in->recurse)
{
plug_in->return_vals = g_new (Argument, 1);
plug_in->n_return_vals = 1;
plug_in->return_vals->arg_type = GIMP_PDB_STATUS;
plug_in->return_vals->value.pdb_int = GIMP_PDB_CANCEL;
}
plug_in_close (plug_in, TRUE);
plug_in_unref (plug_in);
}