1997-11-25 06:05:25 +08:00
|
|
|
/* 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
|
1998-04-13 13:44:11 +08:00
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
1997-11-25 06:05:25 +08:00
|
|
|
*/
|
2000-07-16 20:49:04 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
#include "config.h"
|
1999-03-07 20:56:03 +08:00
|
|
|
|
2003-09-11 06:06:45 +08:00
|
|
|
#include <glib-object.h>
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-03-21 01:46:13 +08:00
|
|
|
#include "plug-in-types.h"
|
2001-12-28 01:58:30 +08:00
|
|
|
|
2003-09-11 06:06:45 +08:00
|
|
|
#include "core/gimp.h"
|
2004-08-11 02:47:21 +08:00
|
|
|
#include "core/gimpprogress.h"
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-02-03 21:21:31 +08:00
|
|
|
#include "pdb/procedural_db.h"
|
|
|
|
|
2002-03-21 01:46:13 +08:00
|
|
|
#include "plug-in.h"
|
|
|
|
#include "plug-in-progress.h"
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
|
2002-03-21 01:46:13 +08:00
|
|
|
/* local function prototypes */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2004-08-11 02:47:21 +08:00
|
|
|
static void plug_in_progress_cancel (GimpProgress *progress,
|
|
|
|
PlugIn *plug_in);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
|
2002-03-21 01:46:13 +08:00
|
|
|
/* public functions */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-05-04 03:22:58 +08:00
|
|
|
void
|
2003-01-20 20:17:32 +08:00
|
|
|
plug_in_progress_start (PlugIn *plug_in,
|
|
|
|
const gchar *message,
|
|
|
|
gint gdisp_ID)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2003-01-20 20:17:32 +08:00
|
|
|
g_return_if_fail (plug_in != NULL);
|
|
|
|
|
|
|
|
if (! message)
|
2003-02-11 09:21:21 +08:00
|
|
|
message = plug_in->prog;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2004-08-11 02:47:21 +08:00
|
|
|
if (! plug_in->progress)
|
|
|
|
{
|
|
|
|
plug_in->progress = gimp_new_progress (plug_in->gimp);
|
|
|
|
|
|
|
|
if (plug_in->progress)
|
|
|
|
plug_in->progress_created = TRUE;
|
|
|
|
}
|
|
|
|
|
Bit of a large checkin this - it's basically three things: 1 - GimpModules
Sun Jan 11 00:24:21 GMT 1999 Austin Donnelly <austin@greenend.org.uk>
Bit of a large checkin this - it's basically three things:
1 - GimpModules using gmodules to dynamically load and
initialise modules at gimp start of day.
2 - Color selectors now register themselves with a color
notebook.
3 - progress bars have been cleaned up a bit, so now have
progress indictations on all transform tool and gradient
fill operations. Not done bucket fill, but that seems to
be the next candidate.
New directories:
* modules/: new directory for dynamically loadable modules.
New files:
* modules/.cvsignore
* modules/Makefile.am
* modules/colorsel_gtk.c: GTK color selector wrapped up as a
color selector the gimp can use.
* app/gimpprogress.[ch]: progress bars within gimp core, either as
popups, or in the status bar. This is mainly code moved out
of plug-in.c
* app/color_notebook.[ch]: color selector notebook, implementing
very similar interface to color_select.h so it can be used as
a drop-in replacement for it.
* libgimp/color_selector.h: API color selectors need to implement
to become a page in the color_notebook.
* libgimp/gimpmodule.h: API gimp modules need to implement to be
initialised by gimp at start of day.
Modified files:
* Makefile.am: add modules/ to SUBDIRS
* libgimp/Makefile.am: install gimpmodule.h and color_selector.h
* app/gimprc.[ch]: recognise module-path variable.
* gimprc.in: set module-path variable to something sensible
(currently "${gimp_dir}/modules:${gimp_plugin_dir}/modules").
* app/Makefile.am: build color notebook and gimpprogress
* app/app_procs.c: register internal GIMP color selector with
color notebook.
* app/asupsample.c: call progress function less frequently for
better performance.
* app/asupsample.h: progress_func_t typedef moved to gimpprogress.h
* app/blend.c: make callbacks to a progress function
* app/color_area.c: use a color notebook rather than a color selector
* app/color_panel.c: ditto
* app/color_select.c: export color selector interface for notebook
* app/color_select.h: color_select_init() prototype
* app/flip_tool.c: flip the image every time, rather than every
second click.
* app/interface.c: move progress bar stuff out to
gimpprogress.c. Make the code actually work while we're at it.
* app/interface.h: move prototypes for progress functions out to
gimpprogress.h
* app/plug_in.c: load and initialise modules (if possible). Move
progress bar handling code out to gimpprogress.c
* app/plug_in.h: keep only a gimp_progress * for each plugin, not
a whole bunch of GtkWidgets.
* app/scale_tool.c
* app/rotate_tool.c
* app/shear_tool.c
* app/perspective_tool.c: progress bar during operation.
De-sensitise the dialog to discourage the user from running
two transforms in parallel.
* app/transform_core.c: recalculate grid coords when bounding box
changes. Only initialise the action area of the dialog once,
to avoid multiple "ok" / "reset" buttons appearing. Undraw
transform tool with correct matrix to get rid of handle
remains on screen. Call a progress function as we apply the
transform matrix. A few new i18n markups. Invalidate
floating selection marching ants after applying matrix.
* app/transform_core.h: transform_core_do() takes an optional
progress callback argument (and data).
* plug-ins/oilify/oilify.c: send progress bar updates after every
pixel region, not only if they processed a multiple of 5
pixels (which was quite unlikely, and therefore gave a jerky
progress indication).
1999-01-11 08:57:33 +08:00
|
|
|
if (plug_in->progress)
|
2004-08-11 02:47:21 +08:00
|
|
|
{
|
|
|
|
if (plug_in->progress_active)
|
|
|
|
plug_in_progress_end (plug_in);
|
|
|
|
|
|
|
|
if (gimp_progress_start (plug_in->progress, message, TRUE))
|
|
|
|
{
|
|
|
|
g_signal_connect (plug_in->progress, "cancel",
|
|
|
|
G_CALLBACK (plug_in_progress_cancel),
|
|
|
|
plug_in);
|
|
|
|
|
|
|
|
plug_in->progress_active = TRUE;
|
|
|
|
}
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
1999-05-04 03:22:58 +08:00
|
|
|
void
|
2000-02-25 00:11:26 +08:00
|
|
|
plug_in_progress_update (PlugIn *plug_in,
|
|
|
|
gdouble percentage)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2003-01-20 20:17:32 +08:00
|
|
|
g_return_if_fail (plug_in != NULL);
|
|
|
|
|
2004-08-11 02:47:21 +08:00
|
|
|
if (! plug_in->progress && plug_in->progress_active)
|
2003-01-20 20:17:32 +08:00
|
|
|
plug_in_progress_start (plug_in, NULL, -1);
|
2002-02-22 23:08:47 +08:00
|
|
|
|
2004-08-11 02:47:21 +08:00
|
|
|
if (plug_in->progress && plug_in->progress_active)
|
|
|
|
gimp_progress_set_value (plug_in->progress, percentage);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
2001-05-17 02:09:45 +08:00
|
|
|
|
2002-03-21 01:46:13 +08:00
|
|
|
void
|
|
|
|
plug_in_progress_end (PlugIn *plug_in)
|
2001-05-17 02:09:45 +08:00
|
|
|
{
|
2003-01-20 20:17:32 +08:00
|
|
|
g_return_if_fail (plug_in != NULL);
|
|
|
|
|
2002-03-21 01:46:13 +08:00
|
|
|
if (plug_in->progress)
|
2001-05-17 02:09:45 +08:00
|
|
|
{
|
2004-08-11 02:47:21 +08:00
|
|
|
if (plug_in->progress_active)
|
|
|
|
{
|
|
|
|
g_signal_handlers_disconnect_by_func (plug_in->progress,
|
|
|
|
plug_in_progress_cancel,
|
|
|
|
plug_in);
|
|
|
|
gimp_progress_end (plug_in->progress);
|
|
|
|
|
|
|
|
plug_in->progress_active = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (plug_in->progress_created)
|
|
|
|
{
|
|
|
|
gimp_free_progress (plug_in->gimp, plug_in->progress);
|
|
|
|
plug_in->progress = NULL;
|
|
|
|
}
|
2001-05-17 02:09:45 +08:00
|
|
|
}
|
2002-03-21 01:46:13 +08:00
|
|
|
}
|
2001-05-17 02:09:45 +08:00
|
|
|
|
|
|
|
|
2002-03-21 01:46:13 +08:00
|
|
|
/* private functions */
|
|
|
|
|
|
|
|
static void
|
2004-08-11 02:47:21 +08:00
|
|
|
plug_in_progress_cancel (GimpProgress *progress,
|
|
|
|
PlugIn *plug_in)
|
2002-03-21 01:46:13 +08:00
|
|
|
{
|
2003-06-24 02:27:03 +08:00
|
|
|
if (plug_in->recurse_main_loop || plug_in->temp_main_loops)
|
2003-02-03 21:21:31 +08:00
|
|
|
{
|
|
|
|
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);
|
2001-05-17 02:09:45 +08:00
|
|
|
}
|