added boolean return values to plug_in_progress_install(), uninstall() and

2004-08-30  Michael Natterer  <mitch@gimp.org>

	* app/plug-in/plug-in-progress.[ch]: added boolean return values
	to plug_in_progress_install(), uninstall() and cancel(). Added
	checks to make sure the installed progress_callback exists, has
	the correct signature and was installed by this plug-in.

	* tools/pdbgen/pdb/progress.pdb: use the return values to let the
	PDB wrappers succeed/fail.

	* app/pdb/progress_cmds.c: regenerated.
This commit is contained in:
Michael Natterer 2004-08-30 21:03:52 +00:00 committed by Michael Natterer
parent c603ea417c
commit 7f0456374b
7 changed files with 112 additions and 48 deletions

View File

@ -1,3 +1,15 @@
2004-08-30 Michael Natterer <mitch@gimp.org>
* app/plug-in/plug-in-progress.[ch]: added boolean return values
to plug_in_progress_install(), uninstall() and cancel(). Added
checks to make sure the installed progress_callback exists, has
the correct signature and was installed by this plug-in.
* tools/pdbgen/pdb/progress.pdb: use the return values to let the
PDB wrappers succeed/fail.
* app/pdb/progress_cmds.c: regenerated.
2004-08-30 Michael Schumacher <schumaml@cvs.gnome.org>
* libgimp/gimp.def: added gimp_progress_install &

View File

@ -169,7 +169,8 @@ progress_install_invoker (Gimp *gimp,
if (success)
{
if (gimp->current_plug_in && gimp->current_plug_in->open)
plug_in_progress_install (gimp->current_plug_in, progress_callback);
success = plug_in_progress_install (gimp->current_plug_in,
progress_callback);
else
success = FALSE;
}
@ -218,7 +219,8 @@ progress_uninstall_invoker (Gimp *gimp,
if (success)
{
if (gimp->current_plug_in && gimp->current_plug_in->open)
plug_in_progress_uninstall (gimp->current_plug_in, progress_callback);
success = plug_in_progress_uninstall (gimp->current_plug_in,
progress_callback);
else
success = FALSE;
}
@ -267,7 +269,8 @@ progress_cancel_invoker (Gimp *gimp,
if (success)
{
if (gimp->current_plug_in && gimp->current_plug_in->open)
plug_in_progress_cancel (gimp->current_plug_in, progress_callback);
success = plug_in_progress_cancel (gimp->current_plug_in,
progress_callback);
else
success = FALSE;
}

View File

@ -125,12 +125,27 @@ plug_in_progress_end (PlugIn *plug_in)
}
}
void
gboolean
plug_in_progress_install (PlugIn *plug_in,
const gchar *progress_callback)
{
g_return_if_fail (plug_in != NULL);
g_return_if_fail (progress_callback != NULL);
ProcRecord *proc_rec;
g_return_val_if_fail (plug_in != NULL, FALSE);
g_return_val_if_fail (progress_callback != NULL, FALSE);
proc_rec = procedural_db_lookup (plug_in->gimp, progress_callback);
if (! proc_rec ||
proc_rec->num_args != 3 ||
proc_rec->args[0].arg_type != GIMP_PDB_INT32 ||
proc_rec->args[1].arg_type != GIMP_PDB_STRING ||
proc_rec->args[2].arg_type != GIMP_PDB_FLOAT ||
proc_rec->proc_type != GIMP_TEMPORARY ||
proc_rec->exec_method.temporary.plug_in != plug_in)
{
return FALSE;
}
if (plug_in->progress)
{
@ -147,29 +162,37 @@ plug_in_progress_install (PlugIn *plug_in,
"context", plug_in->context,
"callback-name", progress_callback,
NULL);
return TRUE;
}
void
gboolean
plug_in_progress_uninstall (PlugIn *plug_in,
const gchar *progress_callback)
{
g_return_if_fail (plug_in != NULL);
g_return_if_fail (progress_callback != NULL);
g_return_val_if_fail (plug_in != NULL, FALSE);
g_return_val_if_fail (progress_callback != NULL, FALSE);
if (GIMP_IS_PDB_PROGRESS (plug_in->progress))
{
plug_in_progress_end (plug_in);
g_object_unref (plug_in->progress);
plug_in->progress = NULL;
return TRUE;
}
return FALSE;
}
void
gboolean
plug_in_progress_cancel (PlugIn *plug_in,
const gchar *progress_callback)
{
g_return_if_fail (plug_in != NULL);
g_return_if_fail (progress_callback != NULL);
g_return_val_if_fail (plug_in != NULL, FALSE);
g_return_val_if_fail (progress_callback != NULL, FALSE);
return FALSE;
}

View File

@ -20,19 +20,19 @@
#define __PLUG_IN_PROGRESS_H__
void plug_in_progress_start (PlugIn *plug_in,
const gchar *message,
gint display_ID);
void plug_in_progress_update (PlugIn *plug_in,
gdouble percentage);
void plug_in_progress_end (PlugIn *plug_in);
void plug_in_progress_start (PlugIn *plug_in,
const gchar *message,
gint display_ID);
void plug_in_progress_update (PlugIn *plug_in,
gdouble percentage);
void plug_in_progress_end (PlugIn *plug_in);
void plug_in_progress_install (PlugIn *plug_in,
const gchar *progress_callback);
void plug_in_progress_uninstall (PlugIn *plug_in,
const gchar *progress_callback);
void plug_in_progress_cancel (PlugIn *plug_in,
const gchar *progress_callback);
gboolean plug_in_progress_install (PlugIn *plug_in,
const gchar *progress_callback);
gboolean plug_in_progress_uninstall (PlugIn *plug_in,
const gchar *progress_callback);
gboolean plug_in_progress_cancel (PlugIn *plug_in,
const gchar *progress_callback);
#endif /* __PLUG_IN_PROGRESS_H__ */

View File

@ -125,12 +125,27 @@ plug_in_progress_end (PlugIn *plug_in)
}
}
void
gboolean
plug_in_progress_install (PlugIn *plug_in,
const gchar *progress_callback)
{
g_return_if_fail (plug_in != NULL);
g_return_if_fail (progress_callback != NULL);
ProcRecord *proc_rec;
g_return_val_if_fail (plug_in != NULL, FALSE);
g_return_val_if_fail (progress_callback != NULL, FALSE);
proc_rec = procedural_db_lookup (plug_in->gimp, progress_callback);
if (! proc_rec ||
proc_rec->num_args != 3 ||
proc_rec->args[0].arg_type != GIMP_PDB_INT32 ||
proc_rec->args[1].arg_type != GIMP_PDB_STRING ||
proc_rec->args[2].arg_type != GIMP_PDB_FLOAT ||
proc_rec->proc_type != GIMP_TEMPORARY ||
proc_rec->exec_method.temporary.plug_in != plug_in)
{
return FALSE;
}
if (plug_in->progress)
{
@ -147,29 +162,37 @@ plug_in_progress_install (PlugIn *plug_in,
"context", plug_in->context,
"callback-name", progress_callback,
NULL);
return TRUE;
}
void
gboolean
plug_in_progress_uninstall (PlugIn *plug_in,
const gchar *progress_callback)
{
g_return_if_fail (plug_in != NULL);
g_return_if_fail (progress_callback != NULL);
g_return_val_if_fail (plug_in != NULL, FALSE);
g_return_val_if_fail (progress_callback != NULL, FALSE);
if (GIMP_IS_PDB_PROGRESS (plug_in->progress))
{
plug_in_progress_end (plug_in);
g_object_unref (plug_in->progress);
plug_in->progress = NULL;
return TRUE;
}
return FALSE;
}
void
gboolean
plug_in_progress_cancel (PlugIn *plug_in,
const gchar *progress_callback)
{
g_return_if_fail (plug_in != NULL);
g_return_if_fail (progress_callback != NULL);
g_return_val_if_fail (plug_in != NULL, FALSE);
g_return_val_if_fail (progress_callback != NULL, FALSE);
return FALSE;
}

View File

@ -20,19 +20,19 @@
#define __PLUG_IN_PROGRESS_H__
void plug_in_progress_start (PlugIn *plug_in,
const gchar *message,
gint display_ID);
void plug_in_progress_update (PlugIn *plug_in,
gdouble percentage);
void plug_in_progress_end (PlugIn *plug_in);
void plug_in_progress_start (PlugIn *plug_in,
const gchar *message,
gint display_ID);
void plug_in_progress_update (PlugIn *plug_in,
gdouble percentage);
void plug_in_progress_end (PlugIn *plug_in);
void plug_in_progress_install (PlugIn *plug_in,
const gchar *progress_callback);
void plug_in_progress_uninstall (PlugIn *plug_in,
const gchar *progress_callback);
void plug_in_progress_cancel (PlugIn *plug_in,
const gchar *progress_callback);
gboolean plug_in_progress_install (PlugIn *plug_in,
const gchar *progress_callback);
gboolean plug_in_progress_uninstall (PlugIn *plug_in,
const gchar *progress_callback);
gboolean plug_in_progress_cancel (PlugIn *plug_in,
const gchar *progress_callback);
#endif /* __PLUG_IN_PROGRESS_H__ */

View File

@ -109,7 +109,8 @@ HELP
code => <<'CODE'
{
if (gimp->current_plug_in && gimp->current_plug_in->open)
plug_in_progress_install (gimp->current_plug_in, progress_callback);
success = plug_in_progress_install (gimp->current_plug_in,
progress_callback);
else
success = FALSE;
}
@ -137,7 +138,8 @@ HELP
code => <<'CODE'
{
if (gimp->current_plug_in && gimp->current_plug_in->open)
plug_in_progress_uninstall (gimp->current_plug_in, progress_callback);
success = plug_in_progress_uninstall (gimp->current_plug_in,
progress_callback);
else
success = FALSE;
}
@ -163,7 +165,8 @@ HELP
code => <<'CODE'
{
if (gimp->current_plug_in && gimp->current_plug_in->open)
plug_in_progress_cancel (gimp->current_plug_in, progress_callback);
success = plug_in_progress_cancel (gimp->current_plug_in,
progress_callback);
else
success = FALSE;
}