1997-11-24 22:05:25 +00: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 05:44:11 +00:00
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
1997-11-24 22:05:25 +00:00
|
|
|
*/
|
2000-07-16 12:49:04 +00:00
|
|
|
|
1997-11-24 22:05:25 +00:00
|
|
|
#include "config.h"
|
1999-03-07 12:56:03 +00:00
|
|
|
|
2002-03-20 17:46:13 +00:00
|
|
|
#include <gtk/gtk.h>
|
2000-07-16 12:49:04 +00:00
|
|
|
|
2002-03-20 17:46:13 +00:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
1999-10-03 16:54:17 +00:00
|
|
|
|
2002-03-20 17:46:13 +00:00
|
|
|
#include "gui-types.h"
|
2000-07-16 12:49:04 +00:00
|
|
|
|
2002-03-20 17:46:13 +00:00
|
|
|
#include "core/gimp.h"
|
|
|
|
#include "core/gimpcontext.h"
|
|
|
|
#include "core/gimpimage.h"
|
|
|
|
#include "core/gimpitem.h"
|
1999-10-03 16:54:17 +00:00
|
|
|
|
2002-03-20 17:46:13 +00:00
|
|
|
#include "plug-in/plug-in.h"
|
|
|
|
#include "plug-in/plug-in-proc.h"
|
2000-05-07 22:04:51 +00:00
|
|
|
|
2002-03-20 17:46:13 +00:00
|
|
|
#include "display/gimpdisplay.h"
|
2000-05-07 22:04:51 +00:00
|
|
|
|
2002-03-20 17:46:13 +00:00
|
|
|
#include "plug-in-commands.h"
|
2000-05-07 22:04:51 +00:00
|
|
|
|
2002-03-20 17:46:13 +00:00
|
|
|
#include "app_procs.h"
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2000-02-23 20:25:24 +00:00
|
|
|
|
2002-03-20 17:46:13 +00:00
|
|
|
void
|
|
|
|
plug_in_run_cmd_callback (GtkWidget *widget,
|
|
|
|
gpointer data,
|
|
|
|
guint action)
|
1997-11-24 22:05:25 +00:00
|
|
|
{
|
2001-10-17 11:33:43 +00:00
|
|
|
GimpDisplay *gdisplay;
|
|
|
|
ProcRecord *proc_rec;
|
|
|
|
Argument *args;
|
|
|
|
gint i;
|
|
|
|
gint gdisp_ID = -1;
|
|
|
|
gint argc = 0; /* calm down a gcc warning. */
|
1997-11-24 22:05:25 +00:00
|
|
|
|
|
|
|
/* get the active gdisplay */
|
2001-10-17 11:33:43 +00:00
|
|
|
gdisplay = gimp_context_get_display (gimp_get_user_context (the_gimp));
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2002-03-20 17:46:13 +00:00
|
|
|
proc_rec = (ProcRecord *) data;
|
1997-11-24 22:05:25 +00:00
|
|
|
|
|
|
|
/* construct the procedures arguments */
|
2000-07-16 12:49:04 +00:00
|
|
|
args = g_new0 (Argument, proc_rec->num_args);
|
1997-11-24 22:05:25 +00:00
|
|
|
|
|
|
|
/* initialize the argument types */
|
|
|
|
for (i = 0; i < proc_rec->num_args; i++)
|
|
|
|
args[i].arg_type = proc_rec->args[i].arg_type;
|
|
|
|
|
|
|
|
switch (proc_rec->proc_type)
|
|
|
|
{
|
2001-05-21 13:58:46 +00:00
|
|
|
case GIMP_EXTENSION:
|
1997-11-24 22:05:25 +00:00
|
|
|
/* initialize the first argument */
|
2001-12-19 00:13:16 +00:00
|
|
|
args[0].value.pdb_int = GIMP_RUN_INTERACTIVE;
|
1998-10-21 19:10:14 +00:00
|
|
|
argc = 1;
|
1997-11-24 22:05:25 +00:00
|
|
|
break;
|
|
|
|
|
2001-05-21 13:58:46 +00:00
|
|
|
case GIMP_PLUGIN:
|
1997-11-24 22:05:25 +00:00
|
|
|
if (gdisplay)
|
|
|
|
{
|
2002-03-20 17:46:13 +00:00
|
|
|
gdisp_ID = gimp_display_get_ID (gdisplay);
|
1998-06-14 04:33:27 +00:00
|
|
|
|
1997-11-24 22:05:25 +00:00
|
|
|
/* initialize the first 3 plug-in arguments */
|
2001-12-19 00:13:16 +00:00
|
|
|
args[0].value.pdb_int = GIMP_RUN_INTERACTIVE;
|
2001-04-13 14:50:43 +00:00
|
|
|
args[1].value.pdb_int = gimp_image_get_ID (gdisplay->gimage);
|
2002-02-25 17:58:50 +00:00
|
|
|
args[2].value.pdb_int = gimp_item_get_ID (GIMP_ITEM (gimp_image_active_drawable (gdisplay->gimage)));
|
1998-10-21 19:10:14 +00:00
|
|
|
argc = 3;
|
1997-11-24 22:05:25 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
1999-06-05 23:41:45 +00:00
|
|
|
g_warning ("Uh-oh, no active gdisplay for the plug-in!");
|
1997-11-24 22:05:25 +00:00
|
|
|
g_free (args);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2001-05-21 13:58:46 +00:00
|
|
|
case GIMP_TEMPORARY:
|
2001-12-19 00:13:16 +00:00
|
|
|
args[0].value.pdb_int = GIMP_RUN_INTERACTIVE;
|
1998-10-24 20:11:17 +00:00
|
|
|
argc = 1;
|
1997-11-24 22:05:25 +00:00
|
|
|
if (proc_rec->num_args >= 3 &&
|
2001-05-21 13:58:46 +00:00
|
|
|
proc_rec->args[1].arg_type == GIMP_PDB_IMAGE &&
|
|
|
|
proc_rec->args[2].arg_type == GIMP_PDB_DRAWABLE)
|
1997-11-24 22:05:25 +00:00
|
|
|
{
|
|
|
|
if (gdisplay)
|
|
|
|
{
|
1998-06-14 04:33:27 +00:00
|
|
|
gdisp_ID = gdisplay->ID;
|
|
|
|
|
2001-04-13 14:50:43 +00:00
|
|
|
args[1].value.pdb_int = gimp_image_get_ID (gdisplay->gimage);
|
2002-02-25 17:58:50 +00:00
|
|
|
args[2].value.pdb_int = gimp_item_get_ID (GIMP_ITEM (gimp_image_active_drawable (gdisplay->gimage)));
|
1998-10-21 19:10:14 +00:00
|
|
|
argc = 3;
|
1997-11-24 22:05:25 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
1999-06-05 23:41:45 +00:00
|
|
|
g_warning ("Uh-oh, no active gdisplay for the temporary procedure!");
|
1997-11-24 22:05:25 +00:00
|
|
|
g_free (args);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
1999-09-23 11:49:16 +00:00
|
|
|
g_error ("Unknown procedure type.");
|
1998-10-21 19:10:14 +00:00
|
|
|
g_free (args);
|
|
|
|
return;
|
1997-11-24 22:05:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* run the plug-in procedure */
|
2002-03-20 17:46:13 +00:00
|
|
|
plug_in_run (the_gimp, proc_rec, args, argc, FALSE, TRUE, gdisp_ID);
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2001-05-21 13:58:46 +00:00
|
|
|
if (proc_rec->proc_type == GIMP_PLUGIN)
|
1997-11-24 22:05:25 +00:00
|
|
|
last_plug_in = proc_rec;
|
|
|
|
|
|
|
|
g_free (args);
|
|
|
|
}
|
|
|
|
|
1999-05-03 19:22:58 +00:00
|
|
|
void
|
2002-03-20 17:46:13 +00:00
|
|
|
plug_in_repeat_cmd_callback (GtkWidget *widget,
|
|
|
|
gpointer data,
|
|
|
|
guint action)
|
2001-05-16 18:09:45 +00:00
|
|
|
{
|
2002-03-20 17:46:13 +00:00
|
|
|
GimpDisplay *gdisp;
|
|
|
|
GimpDrawable *drawable;
|
|
|
|
gboolean interactive;
|
2001-05-16 18:09:45 +00:00
|
|
|
|
2002-03-20 17:46:13 +00:00
|
|
|
gdisp = gimp_context_get_display (gimp_get_user_context (GIMP (data)));
|
2001-05-16 18:09:45 +00:00
|
|
|
|
2002-03-20 17:46:13 +00:00
|
|
|
if (! gdisp)
|
|
|
|
return;
|
2001-05-16 18:09:45 +00:00
|
|
|
|
2002-03-20 17:46:13 +00:00
|
|
|
drawable = gimp_image_active_drawable (gdisp->gimage);
|
2001-10-24 15:56:33 +00:00
|
|
|
|
2002-03-20 17:46:13 +00:00
|
|
|
if (! drawable)
|
|
|
|
return;
|
2001-05-16 18:09:45 +00:00
|
|
|
|
2002-03-20 17:46:13 +00:00
|
|
|
interactive = action ? TRUE : FALSE;
|
2001-05-16 18:09:45 +00:00
|
|
|
|
2002-03-20 17:46:13 +00:00
|
|
|
plug_in_repeat (GIMP (data),
|
|
|
|
gimp_display_get_ID (gdisp),
|
|
|
|
gimp_image_get_ID (gdisp->gimage),
|
|
|
|
gimp_item_get_ID (GIMP_ITEM (drawable)),
|
|
|
|
interactive);
|
2001-05-16 18:09:45 +00:00
|
|
|
}
|