gimp/app/core/gimppdbprogress.c

406 lines
13 KiB
C
Raw Normal View History

/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimppdbprogress.c
* Copyright (C) 2004 Michael Natterer <mitch@gimp.org>
*
* 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 <string.h>
#include <glib-object.h>
#include "core-types.h"
#include "core/gimpcontext.h"
#include "pdb/gimpargument.h"
#include "pdb/procedural_db.h"
#include "gimppdbprogress.h"
#include "gimpprogress.h"
#include "gimp-intl.h"
enum
{
PROP_0,
PROP_CONTEXT,
PROP_CALLBACK_NAME
};
static void gimp_pdb_progress_class_init (GimpPdbProgressClass *klass);
static void gimp_pdb_progress_init (GimpPdbProgress *progress,
GimpPdbProgressClass *klass);
static void gimp_pdb_progress_progress_iface_init (GimpProgressInterface *iface);
static GObject * gimp_pdb_progress_constructor (GType type,
guint n_params,
GObjectConstructParam *params);
static void gimp_pdb_progress_dispose (GObject *object);
static void gimp_pdb_progress_finalize (GObject *object);
static void gimp_pdb_progress_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec);
Added parent window API to the GimpProgress interface and to the libgimp 2005-09-09 Michael Natterer <mitch@gimp.org> Added parent window API to the GimpProgress interface and to the libgimp progress stuff. Might look strange, but does the right thing in almost all cases (image window, file dialog, script-fu dialog etc). Fixes bug #62988. * app/core/gimpprogress.[ch]: added GimpProgress::get_window() which should return a toplevel window ID if the progress is in a window that wants to be the transient parent of plug-in dialogs. * app/widgets/gimpwidgets-utils.[ch] (gimp_window_get_native): new function which returns the window handle of a GtkWindow's GdkWindow. * app/widgets/gimpfiledialog.c: implement ::get_window(). * app/display/gimpdisplay.[ch]: ditto. Removed window handle API. * app/gui/gui-vtable.c: changed accordingly. * libgimpbase/gimpbaseenums.[ch] (enum GimpProgressCommand): added GIMP_PROGRESS_COMMAND_GET_WINDOW. * app/plug-in/plug-in-progress.[ch] (plug_in_progress_get_window): new function. Also renamed some functions to match the GimpProgress interface, and not the legacy PDB procedure names. * tools/pdbgen/pdb/progress.pdb * app/core/gimppdbprogress.c: implement get_window() on both sides of the wire, keeping backward compatibility (hopefully). * libgimp/gimpprogress.[ch]: deprecated gimp_progress_install() and added gimp_progress_install_vtable() which takes a vtable with padding to be extensible. Added get_window() vtable entry and dispatch it accordingly. Also added pulse() which was implemented in a hackish way before. Everything is of course backward compatible. * libgimp/gimpprogressbar.c: inmplement the get_window() stuff so a plug-in dialog containing a progress can be the transient parent of another dialog in another plug-in. * libgimp/gimpui.[ch] (gimp_ui_get_progress_window): new function which returns a foreign GdkWindow of this plug-ins progress window. Renamed gimp_window_set_transient_for_default_display() to gimp_window_set_transient() and make it use the progress' window handle instead of the display's (which is the right thing to do in almost all cases). * libgimp/gimp.def * libgimp/gimpui.def: add the new functions. * tools/pdbgen/enums.pl * app/pdb/internal_procs.c * app/pdb/progress_cmds.c * libgimp/gimpprogress_pdb.[ch]: regenerated. * libgimp/gimpexport.c * plug-ins/*/*.c: follow API change.
2005-09-10 02:07:31 +08:00
static GimpProgress * gimp_pdb_progress_progress_start(GimpProgress *progress,
const gchar *message,
gboolean cancelable);
static void gimp_pdb_progress_progress_end (GimpProgress *progress);
static gboolean gimp_pdb_progress_progress_is_active (GimpProgress *progress);
static void gimp_pdb_progress_progress_set_text (GimpProgress *progress,
const gchar *message);
static void gimp_pdb_progress_progress_set_value (GimpProgress *progress,
gdouble percentage);
static gdouble gimp_pdb_progress_progress_get_value (GimpProgress *progress);
static void gimp_pdb_progress_progress_pulse (GimpProgress *progress);
static guint32 gimp_pdb_progress_progress_get_window (GimpProgress *progress);
static GObjectClass *parent_class = NULL;
GType
gimp_pdb_progress_get_type (void)
{
static GType type = 0;
if (! type)
{
static const GTypeInfo info =
{
sizeof (GimpPdbProgressClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) gimp_pdb_progress_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GimpPdbProgress),
0, /* n_preallocs */
(GInstanceInitFunc) gimp_pdb_progress_init,
};
static const GInterfaceInfo progress_iface_info =
{
(GInterfaceInitFunc) gimp_pdb_progress_progress_iface_init,
NULL, /* iface_finalize */
NULL /* iface_data */
};
type = g_type_register_static (G_TYPE_OBJECT,
"GimpPdbProgress",
&info, 0);
g_type_add_interface_static (type, GIMP_TYPE_PROGRESS,
&progress_iface_info);
}
return type;
}
static void
gimp_pdb_progress_class_init (GimpPdbProgressClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
object_class->constructor = gimp_pdb_progress_constructor;
object_class->dispose = gimp_pdb_progress_dispose;
object_class->finalize = gimp_pdb_progress_finalize;
object_class->set_property = gimp_pdb_progress_set_property;
g_object_class_install_property (object_class, PROP_CONTEXT,
g_param_spec_object ("context", NULL, NULL,
GIMP_TYPE_CONTEXT,
GIMP_PARAM_WRITABLE |
G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property (object_class, PROP_CALLBACK_NAME,
g_param_spec_string ("callback-name",
NULL, NULL,
NULL,
GIMP_PARAM_WRITABLE |
G_PARAM_CONSTRUCT_ONLY));
}
static void
gimp_pdb_progress_init (GimpPdbProgress *progress,
GimpPdbProgressClass *klass)
{
klass->progresses = g_list_prepend (klass->progresses, progress);
}
static void
gimp_pdb_progress_progress_iface_init (GimpProgressInterface *iface)
{
iface->start = gimp_pdb_progress_progress_start;
iface->end = gimp_pdb_progress_progress_end;
iface->is_active = gimp_pdb_progress_progress_is_active;
iface->set_text = gimp_pdb_progress_progress_set_text;
iface->set_value = gimp_pdb_progress_progress_set_value;
iface->get_value = gimp_pdb_progress_progress_get_value;
iface->pulse = gimp_pdb_progress_progress_pulse;
iface->get_window = gimp_pdb_progress_progress_get_window;
}
static GObject *
gimp_pdb_progress_constructor (GType type,
guint n_params,
GObjectConstructParam *params)
{
GObject *object;
GimpPdbProgress *progress;
object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
progress = GIMP_PDB_PROGRESS (object);
g_assert (GIMP_IS_CONTEXT (progress->context));
return object;
}
static void
gimp_pdb_progress_dispose (GObject *object)
{
GimpPdbProgressClass *klass = GIMP_PDB_PROGRESS_GET_CLASS (object);
klass->progresses = g_list_remove (klass->progresses, object);
G_OBJECT_CLASS (parent_class)->dispose (object);
}
static void
gimp_pdb_progress_finalize (GObject *object)
{
GimpPdbProgress *progress = GIMP_PDB_PROGRESS (object);
if (progress->context)
{
g_object_unref (progress->context);
progress->context = NULL;
}
if (progress->callback_name)
{
g_free (progress->callback_name);
progress->callback_name = NULL;
}
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
gimp_pdb_progress_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
GimpPdbProgress *progress = GIMP_PDB_PROGRESS (object);
switch (property_id)
{
case PROP_CONTEXT:
if (progress->context)
g_object_unref (progress->context);
progress->context = (GimpContext *) g_value_dup_object (value);
break;
case PROP_CALLBACK_NAME:
if (progress->callback_name)
g_free (progress->callback_name);
progress->callback_name = g_value_dup_string (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
Added parent window API to the GimpProgress interface and to the libgimp 2005-09-09 Michael Natterer <mitch@gimp.org> Added parent window API to the GimpProgress interface and to the libgimp progress stuff. Might look strange, but does the right thing in almost all cases (image window, file dialog, script-fu dialog etc). Fixes bug #62988. * app/core/gimpprogress.[ch]: added GimpProgress::get_window() which should return a toplevel window ID if the progress is in a window that wants to be the transient parent of plug-in dialogs. * app/widgets/gimpwidgets-utils.[ch] (gimp_window_get_native): new function which returns the window handle of a GtkWindow's GdkWindow. * app/widgets/gimpfiledialog.c: implement ::get_window(). * app/display/gimpdisplay.[ch]: ditto. Removed window handle API. * app/gui/gui-vtable.c: changed accordingly. * libgimpbase/gimpbaseenums.[ch] (enum GimpProgressCommand): added GIMP_PROGRESS_COMMAND_GET_WINDOW. * app/plug-in/plug-in-progress.[ch] (plug_in_progress_get_window): new function. Also renamed some functions to match the GimpProgress interface, and not the legacy PDB procedure names. * tools/pdbgen/pdb/progress.pdb * app/core/gimppdbprogress.c: implement get_window() on both sides of the wire, keeping backward compatibility (hopefully). * libgimp/gimpprogress.[ch]: deprecated gimp_progress_install() and added gimp_progress_install_vtable() which takes a vtable with padding to be extensible. Added get_window() vtable entry and dispatch it accordingly. Also added pulse() which was implemented in a hackish way before. Everything is of course backward compatible. * libgimp/gimpprogressbar.c: inmplement the get_window() stuff so a plug-in dialog containing a progress can be the transient parent of another dialog in another plug-in. * libgimp/gimpui.[ch] (gimp_ui_get_progress_window): new function which returns a foreign GdkWindow of this plug-ins progress window. Renamed gimp_window_set_transient_for_default_display() to gimp_window_set_transient() and make it use the progress' window handle instead of the display's (which is the right thing to do in almost all cases). * libgimp/gimp.def * libgimp/gimpui.def: add the new functions. * tools/pdbgen/enums.pl * app/pdb/internal_procs.c * app/pdb/progress_cmds.c * libgimp/gimpprogress_pdb.[ch]: regenerated. * libgimp/gimpexport.c * plug-ins/*/*.c: follow API change.
2005-09-10 02:07:31 +08:00
static gdouble
gimp_pdb_progress_run_callback (GimpPdbProgress *progress,
GimpProgressCommand command,
const gchar *text,
gdouble value)
{
Added parent window API to the GimpProgress interface and to the libgimp 2005-09-09 Michael Natterer <mitch@gimp.org> Added parent window API to the GimpProgress interface and to the libgimp progress stuff. Might look strange, but does the right thing in almost all cases (image window, file dialog, script-fu dialog etc). Fixes bug #62988. * app/core/gimpprogress.[ch]: added GimpProgress::get_window() which should return a toplevel window ID if the progress is in a window that wants to be the transient parent of plug-in dialogs. * app/widgets/gimpwidgets-utils.[ch] (gimp_window_get_native): new function which returns the window handle of a GtkWindow's GdkWindow. * app/widgets/gimpfiledialog.c: implement ::get_window(). * app/display/gimpdisplay.[ch]: ditto. Removed window handle API. * app/gui/gui-vtable.c: changed accordingly. * libgimpbase/gimpbaseenums.[ch] (enum GimpProgressCommand): added GIMP_PROGRESS_COMMAND_GET_WINDOW. * app/plug-in/plug-in-progress.[ch] (plug_in_progress_get_window): new function. Also renamed some functions to match the GimpProgress interface, and not the legacy PDB procedure names. * tools/pdbgen/pdb/progress.pdb * app/core/gimppdbprogress.c: implement get_window() on both sides of the wire, keeping backward compatibility (hopefully). * libgimp/gimpprogress.[ch]: deprecated gimp_progress_install() and added gimp_progress_install_vtable() which takes a vtable with padding to be extensible. Added get_window() vtable entry and dispatch it accordingly. Also added pulse() which was implemented in a hackish way before. Everything is of course backward compatible. * libgimp/gimpprogressbar.c: inmplement the get_window() stuff so a plug-in dialog containing a progress can be the transient parent of another dialog in another plug-in. * libgimp/gimpui.[ch] (gimp_ui_get_progress_window): new function which returns a foreign GdkWindow of this plug-ins progress window. Renamed gimp_window_set_transient_for_default_display() to gimp_window_set_transient() and make it use the progress' window handle instead of the display's (which is the right thing to do in almost all cases). * libgimp/gimp.def * libgimp/gimpui.def: add the new functions. * tools/pdbgen/enums.pl * app/pdb/internal_procs.c * app/pdb/progress_cmds.c * libgimp/gimpprogress_pdb.[ch]: regenerated. * libgimp/gimpexport.c * plug-ins/*/*.c: follow API change.
2005-09-10 02:07:31 +08:00
gdouble retval = 0;
if (progress->callback_name && ! progress->callback_busy)
{
GimpArgument *return_vals;
gint n_return_vals;
progress->callback_busy = TRUE;
return_vals = procedural_db_run_proc (progress->context->gimp,
progress->context,
NULL,
progress->callback_name,
&n_return_vals,
GIMP_PDB_INT32, command,
GIMP_PDB_STRING, text,
GIMP_PDB_FLOAT, value,
GIMP_PDB_END);
if (g_value_get_enum (&return_vals[0].value) != GIMP_PDB_SUCCESS)
{
g_message (_("Unable to run %s callback. "
"The corresponding plug-in may have crashed."),
g_type_name (G_TYPE_FROM_INSTANCE (progress)));
}
else if (n_return_vals >= 2 && return_vals[1].type == GIMP_PDB_FLOAT)
Added parent window API to the GimpProgress interface and to the libgimp 2005-09-09 Michael Natterer <mitch@gimp.org> Added parent window API to the GimpProgress interface and to the libgimp progress stuff. Might look strange, but does the right thing in almost all cases (image window, file dialog, script-fu dialog etc). Fixes bug #62988. * app/core/gimpprogress.[ch]: added GimpProgress::get_window() which should return a toplevel window ID if the progress is in a window that wants to be the transient parent of plug-in dialogs. * app/widgets/gimpwidgets-utils.[ch] (gimp_window_get_native): new function which returns the window handle of a GtkWindow's GdkWindow. * app/widgets/gimpfiledialog.c: implement ::get_window(). * app/display/gimpdisplay.[ch]: ditto. Removed window handle API. * app/gui/gui-vtable.c: changed accordingly. * libgimpbase/gimpbaseenums.[ch] (enum GimpProgressCommand): added GIMP_PROGRESS_COMMAND_GET_WINDOW. * app/plug-in/plug-in-progress.[ch] (plug_in_progress_get_window): new function. Also renamed some functions to match the GimpProgress interface, and not the legacy PDB procedure names. * tools/pdbgen/pdb/progress.pdb * app/core/gimppdbprogress.c: implement get_window() on both sides of the wire, keeping backward compatibility (hopefully). * libgimp/gimpprogress.[ch]: deprecated gimp_progress_install() and added gimp_progress_install_vtable() which takes a vtable with padding to be extensible. Added get_window() vtable entry and dispatch it accordingly. Also added pulse() which was implemented in a hackish way before. Everything is of course backward compatible. * libgimp/gimpprogressbar.c: inmplement the get_window() stuff so a plug-in dialog containing a progress can be the transient parent of another dialog in another plug-in. * libgimp/gimpui.[ch] (gimp_ui_get_progress_window): new function which returns a foreign GdkWindow of this plug-ins progress window. Renamed gimp_window_set_transient_for_default_display() to gimp_window_set_transient() and make it use the progress' window handle instead of the display's (which is the right thing to do in almost all cases). * libgimp/gimp.def * libgimp/gimpui.def: add the new functions. * tools/pdbgen/enums.pl * app/pdb/internal_procs.c * app/pdb/progress_cmds.c * libgimp/gimpprogress_pdb.[ch]: regenerated. * libgimp/gimpexport.c * plug-ins/*/*.c: follow API change.
2005-09-10 02:07:31 +08:00
{
replace the value union by a GValue. 2006-03-30 Michael Natterer <mitch@gimp.org> * app/pdb/procedural_db.[ch] (struct Argument): replace the value union by a GValue. (procedural_db_argument_init) (procedural_db_compat_arg_init): new functions to initialize an Argument. They call g_value_init() on the Argument's value. (procedural_db_arguments) (procedural_db_return_values): initialize the returned Argument arrays so their GValues are ready to use. Allow to get the (unsuccessful) return values of a NULL ProcRecord. (procedural_db_destroy_args): g_value_unset() the values. Added a "gboolean full_destroy" parameter. Its only effect is to destroy PDB arrays, everything else is nicely memory managed by GValue. (procedural_db_execute) (procedural_db_run_proc): do GValue stuff. Added n_args and n_return_vals parameters to execute(). (procedural_db_execute_proc): private function to execute a procedure. Validates the passed in arguments using the registered GParamSpecs before passing them to the resp. exec method. * app/plug-in/plug-in-params.[ch] (plug_in_params_to_args): needs an array of ProcArgs now in order to initialize the Arguments' GValues correctly. Passing NULL ProcArgs uses procedural_db_compat_arg_init(), so procedures (plug-ins) returning more values than expected work. (plug_in_args_to_params): do GValue stuff here too. (plug_in_args_destroy): removed this function, procedural_db_destroy_args() does the same now. * app/plug-in/plug-in-message.c (plug_in_handle_proc_run): simplified quite a bit because everything returns n_return_values now. Call plug_in_params_to_args() only of the procedure was found. (plug_in_handle_proc_return_priv): pass ProcRecs to plug_in_params_to_args(). * app/batch.c * app/actions/plug-in-commands.c * app/actions/vectors-commands.c * app/core/gimppdbprogress.c * app/dialogs/about-dialog.c * app/file/file-open.c * app/file/file-save.c * app/plug-in/plug-ins.c * app/plug-in/plug-in-progress.c * app/plug-in/plug-in-run.[ch] * app/widgets/gimphelp.c * app/widgets/gimppdbdialog.c * app/xcf/xcf.c * tools/pdbgen/pdb/fileops.pdb: changed accordingly: don't g_new/g_free Argument arrays, always use procedural_db_foo() functions. Use GValue functions to get/set Arguments. * tools/pdbgen/pdb.pl: added get_value_func and set_value_func to all PDB types. Removed id_func, id_ret_func and check_func. Added flags which indicated that a type is an ID. Removed unused utility functions. * tools/pdbgen/lib.pl: use the flag instead of looking at functions and value types. * tools/pdbgen/app.pl: use the get_value_func and set_value_func to marshal inargs and outargs. Removed all checks performed on inargs because that's done by GParamSpec validation now. Added the missing bits to register excluded values with GimpParamSpecEnum. * app/pdb/*_cmds.c: regenerated.
2006-03-30 07:56:07 +08:00
retval = g_value_get_double (&return_vals[1].value);
Added parent window API to the GimpProgress interface and to the libgimp 2005-09-09 Michael Natterer <mitch@gimp.org> Added parent window API to the GimpProgress interface and to the libgimp progress stuff. Might look strange, but does the right thing in almost all cases (image window, file dialog, script-fu dialog etc). Fixes bug #62988. * app/core/gimpprogress.[ch]: added GimpProgress::get_window() which should return a toplevel window ID if the progress is in a window that wants to be the transient parent of plug-in dialogs. * app/widgets/gimpwidgets-utils.[ch] (gimp_window_get_native): new function which returns the window handle of a GtkWindow's GdkWindow. * app/widgets/gimpfiledialog.c: implement ::get_window(). * app/display/gimpdisplay.[ch]: ditto. Removed window handle API. * app/gui/gui-vtable.c: changed accordingly. * libgimpbase/gimpbaseenums.[ch] (enum GimpProgressCommand): added GIMP_PROGRESS_COMMAND_GET_WINDOW. * app/plug-in/plug-in-progress.[ch] (plug_in_progress_get_window): new function. Also renamed some functions to match the GimpProgress interface, and not the legacy PDB procedure names. * tools/pdbgen/pdb/progress.pdb * app/core/gimppdbprogress.c: implement get_window() on both sides of the wire, keeping backward compatibility (hopefully). * libgimp/gimpprogress.[ch]: deprecated gimp_progress_install() and added gimp_progress_install_vtable() which takes a vtable with padding to be extensible. Added get_window() vtable entry and dispatch it accordingly. Also added pulse() which was implemented in a hackish way before. Everything is of course backward compatible. * libgimp/gimpprogressbar.c: inmplement the get_window() stuff so a plug-in dialog containing a progress can be the transient parent of another dialog in another plug-in. * libgimp/gimpui.[ch] (gimp_ui_get_progress_window): new function which returns a foreign GdkWindow of this plug-ins progress window. Renamed gimp_window_set_transient_for_default_display() to gimp_window_set_transient() and make it use the progress' window handle instead of the display's (which is the right thing to do in almost all cases). * libgimp/gimp.def * libgimp/gimpui.def: add the new functions. * tools/pdbgen/enums.pl * app/pdb/internal_procs.c * app/pdb/progress_cmds.c * libgimp/gimpprogress_pdb.[ch]: regenerated. * libgimp/gimpexport.c * plug-ins/*/*.c: follow API change.
2005-09-10 02:07:31 +08:00
}
added struct GimpArray which can keep static or allocated data. Added 2006-04-01 Michael Natterer <mitch@gimp.org> * app/core/gimpparamspecs.[ch]: added struct GimpArray which can keep static or allocated data. Added boxed types GIMP_TYPE_ARRAY and GIMP_TYPE_STRING_ARRAY. Added GParamSpecs for PDB int32, int16, int8, float and string arrays. Added functions to get, dup, set and set_static the various arrays from/to GValues. * app/pdb/gimpprocedure.c * app/pdb/procedural_db.c * app/plug-in/plug-in-params.c * tools/pdbgen/app.pl * tools/pdbgen/pdb.pl: use the new param pspecs and gimp_value functions to keep arrays in GimpArguments. * app/pdb/gimpargument.[ch] (gimp_arguments_destroy): removed parameter "gboolean full_destroy". It's not needed any longer because the GValues fully memory-manage all their data now. * app/batch.c * app/actions/plug-in-commands.c * app/actions/vectors-commands.c * app/core/gimppdbprogress.c * app/dialogs/about-dialog.c * app/dialogs/print-size-dialog.c * app/dialogs/resize-dialog.c * app/display/gimpdisplayshell-handlers.c * app/file/file-open.c * app/file/file-save.c * app/plug-in/plug-in-message.c * app/plug-in/plug-in-run.c * app/plug-in/plug-ins.c * app/widgets/gimphelp.c * app/widgets/gimppdbdialog.c * tools/pdbgen/pdb/fileops.pdb: changed accordingly. * app/pdb/brush_cmds.c * app/pdb/brushes_cmds.c * app/pdb/buffer_cmds.c * app/pdb/color_cmds.c * app/pdb/drawable_cmds.c * app/pdb/fileops_cmds.c * app/pdb/fonts_cmds.c * app/pdb/gimpargument.c * app/pdb/gimpargument.h * app/pdb/gimpprocedure.c * app/pdb/gradient_cmds.c * app/pdb/gradients_cmds.c * app/pdb/image_cmds.c * app/pdb/paint_tools_cmds.c * app/pdb/palettes_cmds.c * app/pdb/parasite_cmds.c * app/pdb/paths_cmds.c * app/pdb/pattern_cmds.c * app/pdb/patterns_cmds.c * app/pdb/plug_in_cmds.c * app/pdb/procedural_db.c * app/pdb/procedural_db_cmds.c * app/pdb/selection_tools_cmds.c * app/pdb/vectors_cmds.c: regenerated. ... and ported everything to perl btw...
2006-04-01 09:33:28 +08:00
gimp_arguments_destroy (return_vals, n_return_vals);
progress->callback_busy = FALSE;
}
Added parent window API to the GimpProgress interface and to the libgimp 2005-09-09 Michael Natterer <mitch@gimp.org> Added parent window API to the GimpProgress interface and to the libgimp progress stuff. Might look strange, but does the right thing in almost all cases (image window, file dialog, script-fu dialog etc). Fixes bug #62988. * app/core/gimpprogress.[ch]: added GimpProgress::get_window() which should return a toplevel window ID if the progress is in a window that wants to be the transient parent of plug-in dialogs. * app/widgets/gimpwidgets-utils.[ch] (gimp_window_get_native): new function which returns the window handle of a GtkWindow's GdkWindow. * app/widgets/gimpfiledialog.c: implement ::get_window(). * app/display/gimpdisplay.[ch]: ditto. Removed window handle API. * app/gui/gui-vtable.c: changed accordingly. * libgimpbase/gimpbaseenums.[ch] (enum GimpProgressCommand): added GIMP_PROGRESS_COMMAND_GET_WINDOW. * app/plug-in/plug-in-progress.[ch] (plug_in_progress_get_window): new function. Also renamed some functions to match the GimpProgress interface, and not the legacy PDB procedure names. * tools/pdbgen/pdb/progress.pdb * app/core/gimppdbprogress.c: implement get_window() on both sides of the wire, keeping backward compatibility (hopefully). * libgimp/gimpprogress.[ch]: deprecated gimp_progress_install() and added gimp_progress_install_vtable() which takes a vtable with padding to be extensible. Added get_window() vtable entry and dispatch it accordingly. Also added pulse() which was implemented in a hackish way before. Everything is of course backward compatible. * libgimp/gimpprogressbar.c: inmplement the get_window() stuff so a plug-in dialog containing a progress can be the transient parent of another dialog in another plug-in. * libgimp/gimpui.[ch] (gimp_ui_get_progress_window): new function which returns a foreign GdkWindow of this plug-ins progress window. Renamed gimp_window_set_transient_for_default_display() to gimp_window_set_transient() and make it use the progress' window handle instead of the display's (which is the right thing to do in almost all cases). * libgimp/gimp.def * libgimp/gimpui.def: add the new functions. * tools/pdbgen/enums.pl * app/pdb/internal_procs.c * app/pdb/progress_cmds.c * libgimp/gimpprogress_pdb.[ch]: regenerated. * libgimp/gimpexport.c * plug-ins/*/*.c: follow API change.
2005-09-10 02:07:31 +08:00
return retval;
}
static GimpProgress *
gimp_pdb_progress_progress_start (GimpProgress *progress,
const gchar *message,
gboolean cancelable)
{
GimpPdbProgress *pdb_progress = GIMP_PDB_PROGRESS (progress);
if (! pdb_progress->active)
{
gimp_pdb_progress_run_callback (pdb_progress,
GIMP_PROGRESS_COMMAND_START,
message, 0.0);
pdb_progress->active = TRUE;
pdb_progress->value = 0.0;
return progress;
}
return NULL;
}
static void
gimp_pdb_progress_progress_end (GimpProgress *progress)
{
GimpPdbProgress *pdb_progress = GIMP_PDB_PROGRESS (progress);
if (pdb_progress->active)
{
gimp_pdb_progress_run_callback (pdb_progress,
GIMP_PROGRESS_COMMAND_END,
NULL, 0.0);
pdb_progress->active = FALSE;
pdb_progress->value = 0.0;
}
}
static gboolean
gimp_pdb_progress_progress_is_active (GimpProgress *progress)
{
GimpPdbProgress *pdb_progress = GIMP_PDB_PROGRESS (progress);
return pdb_progress->active;
}
static void
gimp_pdb_progress_progress_set_text (GimpProgress *progress,
const gchar *message)
{
GimpPdbProgress *pdb_progress = GIMP_PDB_PROGRESS (progress);
if (pdb_progress->active)
gimp_pdb_progress_run_callback (pdb_progress,
GIMP_PROGRESS_COMMAND_SET_TEXT,
message, 0.0);
}
static void
gimp_pdb_progress_progress_set_value (GimpProgress *progress,
gdouble percentage)
{
GimpPdbProgress *pdb_progress = GIMP_PDB_PROGRESS (progress);
if (pdb_progress->active)
{
gimp_pdb_progress_run_callback (pdb_progress,
GIMP_PROGRESS_COMMAND_SET_VALUE,
NULL, percentage);
pdb_progress->value = percentage;
}
}
static gdouble
gimp_pdb_progress_progress_get_value (GimpProgress *progress)
{
GimpPdbProgress *pdb_progress = GIMP_PDB_PROGRESS (progress);
return pdb_progress->value;
}
static void
gimp_pdb_progress_progress_pulse (GimpProgress *progress)
{
GimpPdbProgress *pdb_progress = GIMP_PDB_PROGRESS (progress);
if (pdb_progress->active)
gimp_pdb_progress_run_callback (pdb_progress,
GIMP_PROGRESS_COMMAND_PULSE,
NULL, 0.0);
}
Added parent window API to the GimpProgress interface and to the libgimp 2005-09-09 Michael Natterer <mitch@gimp.org> Added parent window API to the GimpProgress interface and to the libgimp progress stuff. Might look strange, but does the right thing in almost all cases (image window, file dialog, script-fu dialog etc). Fixes bug #62988. * app/core/gimpprogress.[ch]: added GimpProgress::get_window() which should return a toplevel window ID if the progress is in a window that wants to be the transient parent of plug-in dialogs. * app/widgets/gimpwidgets-utils.[ch] (gimp_window_get_native): new function which returns the window handle of a GtkWindow's GdkWindow. * app/widgets/gimpfiledialog.c: implement ::get_window(). * app/display/gimpdisplay.[ch]: ditto. Removed window handle API. * app/gui/gui-vtable.c: changed accordingly. * libgimpbase/gimpbaseenums.[ch] (enum GimpProgressCommand): added GIMP_PROGRESS_COMMAND_GET_WINDOW. * app/plug-in/plug-in-progress.[ch] (plug_in_progress_get_window): new function. Also renamed some functions to match the GimpProgress interface, and not the legacy PDB procedure names. * tools/pdbgen/pdb/progress.pdb * app/core/gimppdbprogress.c: implement get_window() on both sides of the wire, keeping backward compatibility (hopefully). * libgimp/gimpprogress.[ch]: deprecated gimp_progress_install() and added gimp_progress_install_vtable() which takes a vtable with padding to be extensible. Added get_window() vtable entry and dispatch it accordingly. Also added pulse() which was implemented in a hackish way before. Everything is of course backward compatible. * libgimp/gimpprogressbar.c: inmplement the get_window() stuff so a plug-in dialog containing a progress can be the transient parent of another dialog in another plug-in. * libgimp/gimpui.[ch] (gimp_ui_get_progress_window): new function which returns a foreign GdkWindow of this plug-ins progress window. Renamed gimp_window_set_transient_for_default_display() to gimp_window_set_transient() and make it use the progress' window handle instead of the display's (which is the right thing to do in almost all cases). * libgimp/gimp.def * libgimp/gimpui.def: add the new functions. * tools/pdbgen/enums.pl * app/pdb/internal_procs.c * app/pdb/progress_cmds.c * libgimp/gimpprogress_pdb.[ch]: regenerated. * libgimp/gimpexport.c * plug-ins/*/*.c: follow API change.
2005-09-10 02:07:31 +08:00
static guint32
gimp_pdb_progress_progress_get_window (GimpProgress *progress)
{
GimpPdbProgress *pdb_progress = GIMP_PDB_PROGRESS (progress);
return (guint32)
gimp_pdb_progress_run_callback (pdb_progress,
GIMP_PROGRESS_COMMAND_GET_WINDOW,
NULL, 0.0);
}
GimpPdbProgress *
gimp_pdb_progress_get_by_callback (GimpPdbProgressClass *klass,
const gchar *callback_name)
{
GList *list;
g_return_val_if_fail (GIMP_IS_PDB_PROGRESS_CLASS (klass), NULL);
g_return_val_if_fail (callback_name != NULL, NULL);
for (list = klass->progresses; list; list = g_list_next (list))
{
GimpPdbProgress *progress = list->data;
if (progress->callback_name &&
strcmp (callback_name, progress->callback_name) == 0)
return progress;
}
return NULL;
}