2006-12-10 05:33:38 +08:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
1997-11-25 06:05:25 +08:00
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
2006-05-04 02:05:06 +08:00
|
|
|
* gimpplugin-message.c
|
2004-09-22 23:12:24 +08:00
|
|
|
*
|
1997-11-25 06:05:25 +08:00
|
|
|
* 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
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
#include <string.h>
|
1999-03-07 20:56:03 +08:00
|
|
|
|
2003-01-30 19:20:12 +08:00
|
|
|
#include <glib-object.h>
|
1998-08-29 07:01:46 +08:00
|
|
|
|
2001-05-21 21:58:46 +08:00
|
|
|
#include "libgimpbase/gimpbase.h"
|
|
|
|
#include "libgimpbase/gimpprotocol.h"
|
|
|
|
#include "libgimpbase/gimpwire.h"
|
2001-05-09 10:32:03 +08:00
|
|
|
|
2001-12-01 08:14:14 +08:00
|
|
|
#include "plug-in-types.h"
|
2001-05-22 04:30:16 +08:00
|
|
|
|
2001-05-15 19:25:25 +08:00
|
|
|
#include "base/tile.h"
|
|
|
|
#include "base/tile-manager.h"
|
|
|
|
|
2001-07-11 20:39:49 +08:00
|
|
|
#include "core/gimp.h"
|
2001-05-09 10:32:03 +08:00
|
|
|
#include "core/gimpdrawable.h"
|
2001-04-18 05:43:29 +08:00
|
|
|
|
2006-04-26 17:13:47 +08:00
|
|
|
#include "pdb/gimppdb.h"
|
2006-04-04 23:54:51 +08:00
|
|
|
#include "pdb/gimp-pdb-compat.h"
|
2006-03-31 17:15:08 +08:00
|
|
|
|
2006-05-04 02:05:06 +08:00
|
|
|
#include "gimpplugin.h"
|
|
|
|
#include "gimpplugin-message.h"
|
2006-04-29 06:26:51 +08:00
|
|
|
#include "gimppluginmanager.h"
|
2007-02-19 09:16:05 +08:00
|
|
|
#include "gimpplugindef.h"
|
2006-05-05 05:49:04 +08:00
|
|
|
#include "gimppluginshm.h"
|
2006-08-06 05:21:01 +08:00
|
|
|
#include "gimptemporaryprocedure.h"
|
2002-03-21 01:46:13 +08:00
|
|
|
#include "plug-in-params.h"
|
Lots of ii8n stuff here and some additions to the de.po. Applied
Wed Oct 14 17:46:15 EDT 1998 Adrian Likins <adrian@gimp.org>
* app/*, po/de.po, de/POTFILES.in, libgimp/gimpintl.h:
Lots of ii8n stuff here and some additions to the de.po.
Applied gimp-egger-981005-1 ,gimp-egger-981006-1,
gimp-egger-981007-1, gimp-egger-981008-1,
gimp-egger-981009-1.patch, gimp-egger-981010-1.patch
* plug-in/guillotine/guillotine.c: added the coordinates
of the split images from the original image to the title.
ie foo.jpg (0,0) for the image in the topleft.
* plug-in/script-fu/scripts/neon-logo.scm,
perspective-shadow.scm, predator.scm,rendermap.scm,
ripply-anim.scm, select_to_image.scm,swirltile.scm,
xach-effect.scm: updated scripts to use new script-fu stuff
wooo boy! a big un!
in testing this, it looks like some of the po files are busted.
but the code stuff seems okay.
-adrian
1998-10-15 07:23:52 +08:00
|
|
|
|
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
|
|
|
|
2003-01-30 19:20:12 +08:00
|
|
|
/* local function prototypes */
|
|
|
|
|
2006-05-04 02:05:06 +08:00
|
|
|
static void gimp_plug_in_handle_quit (GimpPlugIn *plug_in);
|
|
|
|
static void gimp_plug_in_handle_tile_req (GimpPlugIn *plug_in,
|
|
|
|
GPTileReq *tile_req);
|
|
|
|
static void gimp_plug_in_handle_proc_run (GimpPlugIn *plug_in,
|
|
|
|
GPProcRun *proc_run);
|
|
|
|
static void gimp_plug_in_handle_proc_return (GimpPlugIn *plug_in,
|
|
|
|
GPProcReturn *proc_return);
|
|
|
|
static void gimp_plug_in_handle_temp_proc_return (GimpPlugIn *plug_in,
|
|
|
|
GPProcReturn *proc_return);
|
|
|
|
static void gimp_plug_in_handle_proc_install (GimpPlugIn *plug_in,
|
|
|
|
GPProcInstall *proc_install);
|
|
|
|
static void gimp_plug_in_handle_proc_uninstall (GimpPlugIn *plug_in,
|
|
|
|
GPProcUninstall *proc_uninstall);
|
|
|
|
static void gimp_plug_in_handle_extension_ack (GimpPlugIn *plug_in);
|
|
|
|
static void gimp_plug_in_handle_has_init (GimpPlugIn *plug_in);
|
1999-03-07 20:56:03 +08:00
|
|
|
|
1999-05-07 04:56:07 +08:00
|
|
|
|
2003-01-30 19:20:12 +08:00
|
|
|
/* public functions */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
void
|
2006-05-04 02:05:06 +08:00
|
|
|
gimp_plug_in_handle_message (GimpPlugIn *plug_in,
|
|
|
|
GimpWireMessage *msg)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2006-05-04 02:05:06 +08:00
|
|
|
g_return_if_fail (GIMP_IS_PLUG_IN (plug_in));
|
|
|
|
g_return_if_fail (plug_in->open == TRUE);
|
|
|
|
g_return_if_fail (msg != NULL);
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
switch (msg->type)
|
|
|
|
{
|
|
|
|
case GP_QUIT:
|
2006-05-04 02:05:06 +08:00
|
|
|
gimp_plug_in_handle_quit (plug_in);
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
2002-05-21 18:58:50 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
case GP_CONFIG:
|
2006-10-10 02:49:15 +08:00
|
|
|
gimp_message (plug_in->manager->gimp, NULL, GIMP_MESSAGE_ERROR,
|
|
|
|
"Plug-In \"%s\"\n(%s)\n\n"
|
|
|
|
"sent a CONFIG message. This should not happen.",
|
|
|
|
gimp_object_get_name (GIMP_OBJECT (plug_in)),
|
|
|
|
gimp_filename_to_utf8 (plug_in->prog));
|
2006-05-04 02:05:06 +08:00
|
|
|
gimp_plug_in_close (plug_in, TRUE);
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
2002-05-21 18:58:50 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
case GP_TILE_REQ:
|
2006-05-04 02:05:06 +08:00
|
|
|
gimp_plug_in_handle_tile_req (plug_in, msg->data);
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
2002-05-21 18:58:50 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
case GP_TILE_ACK:
|
2006-10-10 02:49:15 +08:00
|
|
|
gimp_message (plug_in->manager->gimp, NULL, GIMP_MESSAGE_ERROR,
|
|
|
|
"Plug-In \"%s\"\n(%s)\n\n"
|
|
|
|
"sent a TILE_ACK message. This should not happen.",
|
|
|
|
gimp_object_get_name (GIMP_OBJECT (plug_in)),
|
|
|
|
gimp_filename_to_utf8 (plug_in->prog));
|
2006-05-04 02:05:06 +08:00
|
|
|
gimp_plug_in_close (plug_in, TRUE);
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
2002-05-21 18:58:50 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
case GP_TILE_DATA:
|
2006-10-10 02:49:15 +08:00
|
|
|
gimp_message (plug_in->manager->gimp, NULL, GIMP_MESSAGE_ERROR,
|
|
|
|
"Plug-In \"%s\"\n(%s)\n\n"
|
|
|
|
"sent a TILE_DATA message. This should not happen.",
|
|
|
|
gimp_object_get_name (GIMP_OBJECT (plug_in)),
|
|
|
|
gimp_filename_to_utf8 (plug_in->prog));
|
2006-05-04 02:05:06 +08:00
|
|
|
gimp_plug_in_close (plug_in, TRUE);
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
2002-05-21 18:58:50 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
case GP_PROC_RUN:
|
2006-05-04 02:05:06 +08:00
|
|
|
gimp_plug_in_handle_proc_run (plug_in, msg->data);
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
2002-05-21 18:58:50 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
case GP_PROC_RETURN:
|
2006-05-04 02:05:06 +08:00
|
|
|
gimp_plug_in_handle_proc_return (plug_in, msg->data);
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
2002-05-21 18:58:50 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
case GP_TEMP_PROC_RUN:
|
2006-10-10 02:49:15 +08:00
|
|
|
gimp_message (plug_in->manager->gimp, NULL, GIMP_MESSAGE_ERROR,
|
|
|
|
"Plug-In \"%s\"\n(%s)\n\n"
|
|
|
|
"sent a TEMP_PROC_RUN message. This should not happen.",
|
|
|
|
gimp_object_get_name (GIMP_OBJECT (plug_in)),
|
|
|
|
gimp_filename_to_utf8 (plug_in->prog));
|
2006-05-04 02:05:06 +08:00
|
|
|
gimp_plug_in_close (plug_in, TRUE);
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
2002-05-21 18:58:50 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
case GP_TEMP_PROC_RETURN:
|
2006-05-04 02:05:06 +08:00
|
|
|
gimp_plug_in_handle_temp_proc_return (plug_in, msg->data);
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
2002-05-21 18:58:50 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
case GP_PROC_INSTALL:
|
2006-05-04 02:05:06 +08:00
|
|
|
gimp_plug_in_handle_proc_install (plug_in, msg->data);
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
2002-05-21 18:58:50 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
case GP_PROC_UNINSTALL:
|
2006-05-04 02:05:06 +08:00
|
|
|
gimp_plug_in_handle_proc_uninstall (plug_in, msg->data);
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
2002-05-21 18:58:50 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
case GP_EXTENSION_ACK:
|
2006-05-04 02:05:06 +08:00
|
|
|
gimp_plug_in_handle_extension_ack (plug_in);
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
2002-05-21 18:58:50 +08:00
|
|
|
|
2002-02-12 15:59:16 +08:00
|
|
|
case GP_HAS_INIT:
|
2006-05-04 02:05:06 +08:00
|
|
|
gimp_plug_in_handle_has_init (plug_in);
|
2002-05-21 18:58:50 +08:00
|
|
|
break;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-01-30 19:20:12 +08:00
|
|
|
|
|
|
|
/* private functions */
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
static void
|
2006-05-04 02:05:06 +08:00
|
|
|
gimp_plug_in_handle_quit (GimpPlugIn *plug_in)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2006-05-04 02:05:06 +08:00
|
|
|
gimp_plug_in_close (plug_in, FALSE);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2006-05-04 02:05:06 +08:00
|
|
|
gimp_plug_in_handle_tile_req (GimpPlugIn *plug_in,
|
|
|
|
GPTileReq *tile_req)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2005-12-13 22:11:56 +08:00
|
|
|
GPTileData tile_data;
|
|
|
|
GPTileData *tile_info;
|
|
|
|
GimpWireMessage msg;
|
|
|
|
GimpDrawable *drawable;
|
|
|
|
TileManager *tm;
|
|
|
|
Tile *tile;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
if (tile_req->drawable_ID == -1)
|
|
|
|
{
|
2002-05-21 18:58:50 +08:00
|
|
|
/* this branch communicates with libgimp/gimptile.c:gimp_tile_put() */
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
tile_data.drawable_ID = -1;
|
2000-07-16 20:49:04 +08:00
|
|
|
tile_data.tile_num = 0;
|
|
|
|
tile_data.shadow = 0;
|
|
|
|
tile_data.bpp = 0;
|
|
|
|
tile_data.width = 0;
|
|
|
|
tile_data.height = 0;
|
2006-05-05 05:49:04 +08:00
|
|
|
tile_data.use_shm = (plug_in->manager->shm != NULL);
|
2000-07-16 20:49:04 +08:00
|
|
|
tile_data.data = NULL;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-05-17 01:41:38 +08:00
|
|
|
if (! gp_tile_data_write (plug_in->my_write, &tile_data, plug_in))
|
2006-04-12 20:49:29 +08:00
|
|
|
{
|
2006-10-10 02:49:15 +08:00
|
|
|
gimp_message (plug_in->manager->gimp, NULL, GIMP_MESSAGE_ERROR,
|
|
|
|
"plug_in_handle_tile_req: ERROR");
|
2006-05-04 02:05:06 +08:00
|
|
|
gimp_plug_in_close (plug_in, TRUE);
|
2006-04-12 20:49:29 +08:00
|
|
|
return;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2005-12-13 22:11:56 +08:00
|
|
|
if (! gimp_wire_read_msg (plug_in->my_read, &msg, plug_in))
|
2006-04-12 20:49:29 +08:00
|
|
|
{
|
2006-10-10 02:49:15 +08:00
|
|
|
gimp_message (plug_in->manager->gimp, NULL, GIMP_MESSAGE_ERROR,
|
|
|
|
"plug_in_handle_tile_req: ERROR");
|
2006-05-04 02:05:06 +08:00
|
|
|
gimp_plug_in_close (plug_in, TRUE);
|
2006-04-12 20:49:29 +08:00
|
|
|
return;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
if (msg.type != GP_TILE_DATA)
|
2006-04-12 20:49:29 +08:00
|
|
|
{
|
2006-10-10 02:49:15 +08:00
|
|
|
gimp_message (plug_in->manager->gimp, NULL, GIMP_MESSAGE_ERROR,
|
|
|
|
"expected tile data and received: %d", msg.type);
|
2006-05-04 02:05:06 +08:00
|
|
|
gimp_plug_in_close (plug_in, TRUE);
|
2006-04-12 20:49:29 +08:00
|
|
|
return;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
tile_info = msg.data;
|
|
|
|
|
2006-04-29 06:26:51 +08:00
|
|
|
drawable = (GimpDrawable *) gimp_item_get_by_ID (plug_in->manager->gimp,
|
2003-12-08 21:29:14 +08:00
|
|
|
tile_info->drawable_ID);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2006-04-08 05:54:55 +08:00
|
|
|
if (! GIMP_IS_DRAWABLE (drawable))
|
2006-04-12 20:49:29 +08:00
|
|
|
{
|
2006-10-10 02:49:15 +08:00
|
|
|
gimp_message (plug_in->manager->gimp, NULL, GIMP_MESSAGE_ERROR,
|
|
|
|
"Plug-In \"%s\"\n(%s)\n\n"
|
|
|
|
"requested invalid drawable (killing)",
|
|
|
|
gimp_object_get_name (GIMP_OBJECT (plug_in)),
|
|
|
|
gimp_filename_to_utf8 (plug_in->prog));
|
2006-05-04 02:05:06 +08:00
|
|
|
gimp_plug_in_close (plug_in, TRUE);
|
2006-04-12 20:49:29 +08:00
|
|
|
return;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-12-08 21:29:14 +08:00
|
|
|
if (tile_info->shadow)
|
2006-04-12 20:49:29 +08:00
|
|
|
tm = gimp_drawable_get_shadow_tiles (drawable);
|
2003-12-08 21:29:14 +08:00
|
|
|
else
|
2006-04-12 20:49:29 +08:00
|
|
|
tm = gimp_drawable_get_tiles (drawable);
|
2003-12-08 21:29:14 +08:00
|
|
|
|
1998-08-16 03:17:36 +08:00
|
|
|
tile = tile_manager_get (tm, tile_info->tile_num, TRUE, TRUE);
|
2003-12-08 21:29:14 +08:00
|
|
|
|
|
|
|
if (! tile)
|
2006-04-12 20:49:29 +08:00
|
|
|
{
|
2006-10-10 02:49:15 +08:00
|
|
|
gimp_message (plug_in->manager->gimp, NULL, GIMP_MESSAGE_ERROR,
|
|
|
|
"Plug-In \"%s\"\n(%s)\n\n"
|
|
|
|
"requested invalid tile (killing)",
|
|
|
|
gimp_object_get_name (GIMP_OBJECT (plug_in)),
|
|
|
|
gimp_filename_to_utf8 (plug_in->prog));
|
2006-05-04 02:05:06 +08:00
|
|
|
gimp_plug_in_close (plug_in, TRUE);
|
2006-04-12 20:49:29 +08:00
|
|
|
return;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
if (tile_data.use_shm)
|
2006-04-12 20:49:29 +08:00
|
|
|
memcpy (tile_data_pointer (tile, 0, 0),
|
2006-05-05 05:49:04 +08:00
|
|
|
gimp_plug_in_shm_get_addr (plug_in->manager->shm),
|
2003-01-30 19:20:12 +08:00
|
|
|
tile_size (tile));
|
1997-11-25 06:05:25 +08:00
|
|
|
else
|
2006-04-12 20:49:29 +08:00
|
|
|
memcpy (tile_data_pointer (tile, 0, 0),
|
2003-01-30 19:20:12 +08:00
|
|
|
tile_info->data,
|
|
|
|
tile_size (tile));
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1998-07-10 10:43:12 +08:00
|
|
|
tile_release (tile, TRUE);
|
2005-12-13 22:11:56 +08:00
|
|
|
gimp_wire_destroy (&msg);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-05-17 01:41:38 +08:00
|
|
|
if (! gp_tile_ack_write (plug_in->my_write, plug_in))
|
2006-04-12 20:49:29 +08:00
|
|
|
{
|
2006-10-10 02:49:15 +08:00
|
|
|
gimp_message (plug_in->manager->gimp, NULL, GIMP_MESSAGE_ERROR,
|
|
|
|
"plug_in_handle_tile_req: ERROR");
|
2006-05-04 02:05:06 +08:00
|
|
|
gimp_plug_in_close (plug_in, TRUE);
|
2006-04-12 20:49:29 +08:00
|
|
|
return;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2002-05-21 18:58:50 +08:00
|
|
|
/* this branch communicates with libgimp/gimptile.c:gimp_tile_get() */
|
|
|
|
|
2006-04-29 06:26:51 +08:00
|
|
|
drawable = (GimpDrawable *) gimp_item_get_by_ID (plug_in->manager->gimp,
|
2003-12-08 21:29:14 +08:00
|
|
|
tile_req->drawable_ID);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2006-04-08 05:54:55 +08:00
|
|
|
if (! GIMP_IS_DRAWABLE (drawable))
|
2006-04-12 20:49:29 +08:00
|
|
|
{
|
2006-10-10 02:49:15 +08:00
|
|
|
gimp_message (plug_in->manager->gimp, NULL, GIMP_MESSAGE_ERROR,
|
|
|
|
"Plug-In \"%s\"\n(%s)\n\n"
|
|
|
|
"requested invalid drawable (killing)",
|
|
|
|
gimp_object_get_name (GIMP_OBJECT (plug_in)),
|
|
|
|
gimp_filename_to_utf8 (plug_in->prog));
|
2006-05-04 02:05:06 +08:00
|
|
|
gimp_plug_in_close (plug_in, TRUE);
|
2006-04-12 20:49:29 +08:00
|
|
|
return;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-12-08 21:29:14 +08:00
|
|
|
if (tile_req->shadow)
|
2006-04-12 20:49:29 +08:00
|
|
|
tm = gimp_drawable_get_shadow_tiles (drawable);
|
2003-12-08 21:29:14 +08:00
|
|
|
else
|
2006-04-12 20:49:29 +08:00
|
|
|
tm = gimp_drawable_get_tiles (drawable);
|
2003-12-08 21:29:14 +08:00
|
|
|
|
1998-08-16 03:17:36 +08:00
|
|
|
tile = tile_manager_get (tm, tile_req->tile_num, TRUE, FALSE);
|
2003-12-08 21:29:14 +08:00
|
|
|
|
2002-03-21 01:46:13 +08:00
|
|
|
if (! tile)
|
2006-04-12 20:49:29 +08:00
|
|
|
{
|
2006-10-10 02:49:15 +08:00
|
|
|
gimp_message (plug_in->manager->gimp, NULL, GIMP_MESSAGE_ERROR,
|
|
|
|
"Plug-In \"%s\"\n(%s)\n\n"
|
|
|
|
"requested invalid tile (killing)",
|
|
|
|
gimp_object_get_name (GIMP_OBJECT (plug_in)),
|
|
|
|
gimp_filename_to_utf8 (plug_in->prog));
|
2006-05-04 02:05:06 +08:00
|
|
|
gimp_plug_in_close (plug_in, TRUE);
|
2006-04-12 20:49:29 +08:00
|
|
|
return;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
tile_data.drawable_ID = tile_req->drawable_ID;
|
2000-05-17 20:29:38 +08:00
|
|
|
tile_data.tile_num = tile_req->tile_num;
|
|
|
|
tile_data.shadow = tile_req->shadow;
|
|
|
|
tile_data.bpp = tile_bpp (tile);
|
|
|
|
tile_data.width = tile_ewidth (tile);
|
|
|
|
tile_data.height = tile_eheight (tile);
|
2006-05-05 05:49:04 +08:00
|
|
|
tile_data.use_shm = (plug_in->manager->shm != NULL);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
if (tile_data.use_shm)
|
2006-05-05 05:49:04 +08:00
|
|
|
memcpy (gimp_plug_in_shm_get_addr (plug_in->manager->shm),
|
2003-01-30 19:20:12 +08:00
|
|
|
tile_data_pointer (tile, 0, 0),
|
|
|
|
tile_size (tile));
|
1997-11-25 06:05:25 +08:00
|
|
|
else
|
2006-04-12 20:49:29 +08:00
|
|
|
tile_data.data = tile_data_pointer (tile, 0, 0);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-05-17 01:41:38 +08:00
|
|
|
if (! gp_tile_data_write (plug_in->my_write, &tile_data, plug_in))
|
2006-04-12 20:49:29 +08:00
|
|
|
{
|
2006-10-10 02:49:15 +08:00
|
|
|
gimp_message (plug_in->manager->gimp, NULL, GIMP_MESSAGE_ERROR,
|
|
|
|
"plug_in_handle_tile_req: ERROR");
|
2006-05-04 02:05:06 +08:00
|
|
|
gimp_plug_in_close (plug_in, TRUE);
|
2006-04-12 20:49:29 +08:00
|
|
|
return;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1998-07-10 10:43:12 +08:00
|
|
|
tile_release (tile, FALSE);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2005-12-13 22:11:56 +08:00
|
|
|
if (! gimp_wire_read_msg (plug_in->my_read, &msg, plug_in))
|
2006-04-12 20:49:29 +08:00
|
|
|
{
|
2006-10-10 02:49:15 +08:00
|
|
|
gimp_message (plug_in->manager->gimp, NULL, GIMP_MESSAGE_ERROR,
|
|
|
|
"plug_in_handle_tile_req: ERROR");
|
2006-05-04 02:05:06 +08:00
|
|
|
gimp_plug_in_close (plug_in, TRUE);
|
2006-04-12 20:49:29 +08:00
|
|
|
return;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
if (msg.type != GP_TILE_ACK)
|
2006-04-12 20:49:29 +08:00
|
|
|
{
|
2006-10-10 02:49:15 +08:00
|
|
|
gimp_message (plug_in->manager->gimp, NULL, GIMP_MESSAGE_ERROR,
|
|
|
|
"expected tile ack and received: %d", msg.type);
|
2006-05-04 02:05:06 +08:00
|
|
|
gimp_plug_in_close (plug_in, TRUE);
|
2006-04-12 20:49:29 +08:00
|
|
|
return;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2005-12-13 22:11:56 +08:00
|
|
|
gimp_wire_destroy (&msg);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2006-05-04 02:05:06 +08:00
|
|
|
gimp_plug_in_handle_proc_run (GimpPlugIn *plug_in,
|
|
|
|
GPProcRun *proc_run)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2006-05-04 02:05:06 +08:00
|
|
|
GimpPlugInProcFrame *proc_frame;
|
|
|
|
gchar *canonical;
|
|
|
|
const gchar *proc_name = NULL;
|
|
|
|
GimpProcedure *procedure;
|
|
|
|
GValueArray *args = NULL;
|
|
|
|
GValueArray *return_vals = NULL;
|
2004-09-22 08:32:00 +08:00
|
|
|
|
2005-08-03 06:52:23 +08:00
|
|
|
canonical = gimp_canonicalize_identifier (proc_run->name);
|
|
|
|
|
2006-05-04 02:05:06 +08:00
|
|
|
proc_frame = gimp_plug_in_get_proc_frame (plug_in);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2006-04-29 06:26:51 +08:00
|
|
|
procedure = gimp_pdb_lookup_procedure (plug_in->manager->gimp->pdb,
|
|
|
|
canonical);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2006-04-01 01:42:13 +08:00
|
|
|
if (! procedure)
|
2003-12-05 21:02:18 +08:00
|
|
|
{
|
2006-04-29 06:26:51 +08:00
|
|
|
proc_name = gimp_pdb_lookup_compat_proc_name (plug_in->manager->gimp->pdb,
|
2006-04-26 17:13:47 +08:00
|
|
|
canonical);
|
2003-12-05 21:02:18 +08:00
|
|
|
|
|
|
|
if (proc_name)
|
2003-12-06 01:08:35 +08:00
|
|
|
{
|
2006-04-29 06:26:51 +08:00
|
|
|
procedure = gimp_pdb_lookup_procedure (plug_in->manager->gimp->pdb,
|
|
|
|
proc_name);
|
2003-12-06 01:08:35 +08:00
|
|
|
|
2006-04-29 06:26:51 +08:00
|
|
|
if (plug_in->manager->gimp->pdb_compat_mode == GIMP_PDB_COMPAT_WARN)
|
2003-12-06 01:08:35 +08:00
|
|
|
{
|
2006-10-10 02:49:15 +08:00
|
|
|
gimp_message (plug_in->manager->gimp, NULL, GIMP_MESSAGE_WARNING,
|
|
|
|
"Plug-In \"%s\"\n(%s)\n"
|
|
|
|
"called deprecated procedure '%s'.\n"
|
|
|
|
"It should call '%s' instead!",
|
|
|
|
gimp_object_get_name (GIMP_OBJECT (plug_in)),
|
|
|
|
gimp_filename_to_utf8 (plug_in->prog),
|
|
|
|
canonical, proc_name);
|
2003-12-06 01:08:35 +08:00
|
|
|
}
|
|
|
|
}
|
2003-12-05 21:02:18 +08:00
|
|
|
}
|
2006-04-01 01:42:13 +08:00
|
|
|
else if (procedure->deprecated)
|
2004-10-06 11:23:09 +08:00
|
|
|
{
|
2006-04-29 06:26:51 +08:00
|
|
|
if (plug_in->manager->gimp->pdb_compat_mode == GIMP_PDB_COMPAT_WARN)
|
2004-10-06 11:23:09 +08:00
|
|
|
{
|
2006-04-01 01:42:13 +08:00
|
|
|
if (! strcmp (procedure->deprecated, "NONE"))
|
2004-11-19 20:38:34 +08:00
|
|
|
{
|
2006-10-10 02:49:15 +08:00
|
|
|
gimp_message (plug_in->manager->gimp, NULL, GIMP_MESSAGE_WARNING,
|
|
|
|
"Plug-In \"%s\"\n(%s)\n"
|
|
|
|
"called deprecated procedure '%s'.",
|
|
|
|
gimp_object_get_name (GIMP_OBJECT (plug_in)),
|
|
|
|
gimp_filename_to_utf8 (plug_in->prog),
|
|
|
|
canonical);
|
2004-11-19 20:38:34 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-10-10 02:49:15 +08:00
|
|
|
gimp_message (plug_in->manager->gimp, NULL, GIMP_MESSAGE_WARNING,
|
|
|
|
"WARNING: Plug-In \"%s\"\n(%s)\n"
|
|
|
|
"called deprecated procedure '%s'.\n"
|
|
|
|
"It should call '%s' instead!",
|
|
|
|
gimp_object_get_name (GIMP_OBJECT (plug_in)),
|
|
|
|
gimp_filename_to_utf8 (plug_in->prog),
|
|
|
|
canonical, procedure->deprecated);
|
2004-11-19 20:38:34 +08:00
|
|
|
}
|
2004-10-06 11:23:09 +08:00
|
|
|
}
|
|
|
|
}
|
2003-12-05 21:02:18 +08:00
|
|
|
|
|
|
|
if (! proc_name)
|
2005-08-03 06:52:23 +08:00
|
|
|
proc_name = canonical;
|
2003-12-05 21:02:18 +08:00
|
|
|
|
2006-09-19 19:58:57 +08:00
|
|
|
args = plug_in_params_to_args (procedure ? procedure->args : NULL,
|
|
|
|
procedure ? procedure->num_args : 0,
|
|
|
|
proc_run->params, proc_run->nparams,
|
|
|
|
FALSE, FALSE);
|
2003-12-05 21:02:18 +08:00
|
|
|
|
2006-04-26 17:13:47 +08:00
|
|
|
/* Execute the procedure even if gimp_pdb_lookup_procedure()
|
|
|
|
* returned NULL, gimp_pdb_execute_procedure_by_name_args() will
|
|
|
|
* return appropriate error return_vals.
|
2003-02-03 21:21:31 +08:00
|
|
|
*/
|
2006-04-30 03:03:44 +08:00
|
|
|
gimp_plug_in_manager_plug_in_push (plug_in->manager, plug_in);
|
2006-04-29 06:26:51 +08:00
|
|
|
return_vals = gimp_pdb_execute_procedure_by_name_args (plug_in->manager->gimp->pdb,
|
2006-04-26 17:13:47 +08:00
|
|
|
proc_frame->context_stack ?
|
|
|
|
proc_frame->context_stack->data :
|
|
|
|
proc_frame->main_context,
|
|
|
|
proc_frame->progress,
|
|
|
|
proc_name,
|
|
|
|
args);
|
2006-04-30 03:03:44 +08:00
|
|
|
gimp_plug_in_manager_plug_in_pop (plug_in->manager);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2006-10-27 21:16:51 +08:00
|
|
|
g_value_array_free (args);
|
2005-08-03 06:52:23 +08:00
|
|
|
g_free (canonical);
|
|
|
|
|
2007-01-16 07:01:55 +08:00
|
|
|
/* Don't bother to send the return value if executing the procedure
|
|
|
|
* closed the plug-in (e.g. if the procedure is gimp-quit)
|
2006-04-08 05:54:55 +08:00
|
|
|
*/
|
2006-10-27 21:16:51 +08:00
|
|
|
if (plug_in->open)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2006-10-27 21:16:51 +08:00
|
|
|
GPProcReturn proc_return;
|
|
|
|
|
|
|
|
/* Return the name we got called with, *not* proc_name or canonical,
|
|
|
|
* since proc_name may have been remapped by gimp->procedural_compat_ht
|
|
|
|
* and canonical may be different too.
|
|
|
|
*/
|
|
|
|
proc_return.name = proc_run->name;
|
|
|
|
proc_return.nparams = return_vals->n_values;
|
|
|
|
proc_return.params = plug_in_args_to_params (return_vals, FALSE);
|
|
|
|
|
|
|
|
if (! gp_proc_return_write (plug_in->my_write, &proc_return, plug_in))
|
|
|
|
{
|
|
|
|
gimp_message (plug_in->manager->gimp, NULL, GIMP_MESSAGE_ERROR,
|
|
|
|
"plug_in_handle_proc_run: ERROR");
|
|
|
|
gimp_plug_in_close (plug_in, TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_free (proc_return.params);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
2003-01-30 19:20:12 +08:00
|
|
|
|
2006-04-08 05:54:55 +08:00
|
|
|
g_value_array_free (return_vals);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2003-01-30 19:20:12 +08:00
|
|
|
static void
|
2006-05-04 02:05:06 +08:00
|
|
|
gimp_plug_in_handle_proc_return (GimpPlugIn *plug_in,
|
|
|
|
GPProcReturn *proc_return)
|
2003-01-30 19:20:12 +08:00
|
|
|
{
|
2006-05-04 02:05:06 +08:00
|
|
|
GimpPlugInProcFrame *proc_frame = &plug_in->main_proc_frame;
|
2003-01-30 19:20:12 +08:00
|
|
|
|
2006-04-08 05:54:55 +08:00
|
|
|
if (proc_frame->main_loop)
|
2006-05-05 05:49:04 +08:00
|
|
|
{
|
|
|
|
proc_frame->return_vals =
|
|
|
|
plug_in_params_to_args (proc_frame->procedure->values,
|
|
|
|
proc_frame->procedure->num_values,
|
|
|
|
proc_return->params,
|
|
|
|
proc_return->nparams,
|
|
|
|
TRUE, TRUE);
|
2006-04-08 05:54:55 +08:00
|
|
|
|
2006-05-05 05:49:04 +08:00
|
|
|
g_main_loop_quit (proc_frame->main_loop);
|
|
|
|
}
|
2003-01-30 19:20:12 +08:00
|
|
|
|
2006-05-04 02:05:06 +08:00
|
|
|
gimp_plug_in_close (plug_in, FALSE);
|
2003-01-30 19:20:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2006-05-04 02:05:06 +08:00
|
|
|
gimp_plug_in_handle_temp_proc_return (GimpPlugIn *plug_in,
|
|
|
|
GPProcReturn *proc_return)
|
2003-01-30 19:20:12 +08:00
|
|
|
{
|
2004-09-22 07:56:40 +08:00
|
|
|
if (plug_in->temp_proc_frames)
|
2003-02-03 21:21:31 +08:00
|
|
|
{
|
2006-05-04 02:05:06 +08:00
|
|
|
GimpPlugInProcFrame *proc_frame = plug_in->temp_proc_frames->data;
|
2006-04-08 05:54:55 +08:00
|
|
|
|
|
|
|
proc_frame->return_vals =
|
|
|
|
plug_in_params_to_args (proc_frame->procedure->values,
|
|
|
|
proc_frame->procedure->num_values,
|
|
|
|
proc_return->params,
|
|
|
|
proc_return->nparams,
|
|
|
|
TRUE, TRUE);
|
2003-02-03 21:21:31 +08:00
|
|
|
|
2006-05-04 02:05:06 +08:00
|
|
|
gimp_plug_in_main_loop_quit (plug_in);
|
|
|
|
gimp_plug_in_proc_frame_pop (plug_in);
|
2003-02-03 21:21:31 +08:00
|
|
|
}
|
|
|
|
else
|
2003-01-30 19:20:12 +08:00
|
|
|
{
|
2006-10-10 02:49:15 +08:00
|
|
|
gimp_message (plug_in->manager->gimp, NULL, GIMP_MESSAGE_ERROR,
|
|
|
|
"Plug-In \"%s\"\n(%s)\n\n"
|
|
|
|
"sent a TEMP_PROC_RETURN message while not running "
|
|
|
|
"a temporary procedure. This should not happen.",
|
|
|
|
gimp_object_get_name (GIMP_OBJECT (plug_in)),
|
|
|
|
gimp_filename_to_utf8 (plug_in->prog));
|
2006-05-04 02:05:06 +08:00
|
|
|
gimp_plug_in_close (plug_in, TRUE);
|
2003-01-30 19:20:12 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
static void
|
2006-05-04 02:05:06 +08:00
|
|
|
gimp_plug_in_handle_proc_install (GimpPlugIn *plug_in,
|
|
|
|
GPProcInstall *proc_install)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2006-04-05 16:38:33 +08:00
|
|
|
GimpPlugInProcedure *proc = NULL;
|
|
|
|
GimpProcedure *procedure = NULL;
|
|
|
|
gchar *canonical;
|
|
|
|
gboolean valid_utf8 = FALSE;
|
|
|
|
gint i;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2005-08-03 06:52:23 +08:00
|
|
|
canonical = gimp_canonicalize_identifier (proc_install->name);
|
|
|
|
|
2000-07-16 20:49:04 +08:00
|
|
|
/* Sanity check for array arguments */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-11-14 23:33:40 +08:00
|
|
|
for (i = 1; i < proc_install->nparams; i++)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-05-21 21:58:46 +08:00
|
|
|
if ((proc_install->params[i].type == GIMP_PDB_INT32ARRAY ||
|
2006-04-12 20:49:29 +08:00
|
|
|
proc_install->params[i].type == GIMP_PDB_INT8ARRAY ||
|
|
|
|
proc_install->params[i].type == GIMP_PDB_FLOATARRAY ||
|
|
|
|
proc_install->params[i].type == GIMP_PDB_STRINGARRAY)
|
2001-09-03 08:26:06 +08:00
|
|
|
&&
|
2006-04-12 20:49:29 +08:00
|
|
|
proc_install->params[i - 1].type != GIMP_PDB_INT32)
|
|
|
|
{
|
2006-10-10 02:49:15 +08:00
|
|
|
gimp_message (plug_in->manager->gimp, NULL, GIMP_MESSAGE_ERROR,
|
|
|
|
"Plug-In \"%s\"\n(%s)\n\n"
|
|
|
|
"attempted to install procedure \"%s\" "
|
|
|
|
"which fails to comply with the array parameter "
|
|
|
|
"passing standard. Argument %d is noncompliant.",
|
|
|
|
gimp_object_get_name (GIMP_OBJECT (plug_in)),
|
|
|
|
gimp_filename_to_utf8 (plug_in->prog),
|
|
|
|
canonical, i);
|
2005-08-03 06:52:23 +08:00
|
|
|
g_free (canonical);
|
2006-04-12 20:49:29 +08:00
|
|
|
return;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
2001-09-03 08:26:06 +08:00
|
|
|
|
|
|
|
/* Sanity check strings for UTF-8 validity */
|
|
|
|
|
2003-11-14 23:33:40 +08:00
|
|
|
if ((proc_install->menu_path == NULL ||
|
2001-09-03 08:26:06 +08:00
|
|
|
g_utf8_validate (proc_install->menu_path, -1, NULL)) &&
|
2005-08-03 06:52:23 +08:00
|
|
|
(g_utf8_validate (canonical, -1, NULL)) &&
|
2003-11-14 23:33:40 +08:00
|
|
|
(proc_install->blurb == NULL ||
|
2001-09-03 08:26:06 +08:00
|
|
|
g_utf8_validate (proc_install->blurb, -1, NULL)) &&
|
2003-11-14 23:33:40 +08:00
|
|
|
(proc_install->help == NULL ||
|
2001-09-03 08:26:06 +08:00
|
|
|
g_utf8_validate (proc_install->help, -1, NULL)) &&
|
|
|
|
(proc_install->author == NULL ||
|
|
|
|
g_utf8_validate (proc_install->author, -1, NULL)) &&
|
2003-11-14 23:33:40 +08:00
|
|
|
(proc_install->copyright == NULL ||
|
2001-09-03 08:26:06 +08:00
|
|
|
g_utf8_validate (proc_install->copyright, -1, NULL)) &&
|
|
|
|
(proc_install->date == NULL ||
|
|
|
|
g_utf8_validate (proc_install->date, -1, NULL)))
|
|
|
|
{
|
2003-01-20 20:17:32 +08:00
|
|
|
valid_utf8 = TRUE;
|
2001-09-03 08:26:06 +08:00
|
|
|
|
2003-01-20 20:17:32 +08:00
|
|
|
for (i = 0; i < proc_install->nparams && valid_utf8; i++)
|
2001-09-03 08:26:06 +08:00
|
|
|
{
|
|
|
|
if (! (g_utf8_validate (proc_install->params[i].name, -1, NULL) &&
|
2003-11-14 23:33:40 +08:00
|
|
|
(proc_install->params[i].description == NULL ||
|
2001-09-03 08:26:06 +08:00
|
|
|
g_utf8_validate (proc_install->params[i].description, -1, NULL))))
|
2003-01-20 20:17:32 +08:00
|
|
|
valid_utf8 = FALSE;
|
2001-09-03 08:26:06 +08:00
|
|
|
}
|
2003-01-30 19:20:12 +08:00
|
|
|
|
2003-01-20 20:17:32 +08:00
|
|
|
for (i = 0; i < proc_install->nreturn_vals && valid_utf8; i++)
|
2001-09-03 08:26:06 +08:00
|
|
|
{
|
|
|
|
if (! (g_utf8_validate (proc_install->return_vals[i].name, -1, NULL) &&
|
|
|
|
(proc_install->return_vals[i].description == NULL ||
|
|
|
|
g_utf8_validate (proc_install->return_vals[i].description, -1, NULL))))
|
2003-01-20 20:17:32 +08:00
|
|
|
valid_utf8 = FALSE;
|
2001-09-03 08:26:06 +08:00
|
|
|
}
|
|
|
|
}
|
2003-11-14 23:33:40 +08:00
|
|
|
|
2003-01-20 20:17:32 +08:00
|
|
|
if (! valid_utf8)
|
2001-09-03 08:26:06 +08:00
|
|
|
{
|
2006-10-10 02:49:15 +08:00
|
|
|
gimp_message (plug_in->manager->gimp, NULL, GIMP_MESSAGE_ERROR,
|
|
|
|
"Plug-In \"%s\"\n(%s)\n\n"
|
|
|
|
"attempted to install a procedure with invalid UTF-8 strings.",
|
|
|
|
gimp_object_get_name (GIMP_OBJECT (plug_in)),
|
|
|
|
gimp_filename_to_utf8 (plug_in->prog));
|
2005-08-03 06:52:23 +08:00
|
|
|
g_free (canonical);
|
2001-09-03 08:26:06 +08:00
|
|
|
return;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2006-04-08 05:54:55 +08:00
|
|
|
/* Create the procedure object */
|
2000-07-16 20:49:04 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
switch (proc_install->type)
|
|
|
|
{
|
2001-05-21 21:58:46 +08:00
|
|
|
case GIMP_PLUGIN:
|
|
|
|
case GIMP_EXTENSION:
|
2006-04-06 18:01:30 +08:00
|
|
|
procedure = gimp_plug_in_procedure_new (proc_install->type,
|
|
|
|
plug_in->prog);
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
|
2001-05-21 21:58:46 +08:00
|
|
|
case GIMP_TEMPORARY:
|
2006-04-06 18:01:30 +08:00
|
|
|
procedure = gimp_temporary_procedure_new (plug_in);
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2006-04-06 18:01:30 +08:00
|
|
|
proc = GIMP_PLUG_IN_PROCEDURE (procedure);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2006-04-05 16:38:33 +08:00
|
|
|
proc->mtime = time (NULL);
|
2006-05-03 02:27:31 +08:00
|
|
|
proc->installed_during_init = (plug_in->call_mode == GIMP_PLUG_IN_CALL_INIT);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2006-04-05 16:38:33 +08:00
|
|
|
gimp_plug_in_procedure_set_image_types (proc, proc_install->image_types);
|
2004-04-16 06:16:21 +08:00
|
|
|
|
2006-04-07 18:04:27 +08:00
|
|
|
gimp_object_take_name (GIMP_OBJECT (procedure), canonical);
|
2006-04-01 00:17:07 +08:00
|
|
|
gimp_procedure_set_strings (procedure,
|
|
|
|
proc_install->name,
|
|
|
|
proc_install->blurb,
|
|
|
|
proc_install->help,
|
|
|
|
proc_install->author,
|
|
|
|
proc_install->copyright,
|
|
|
|
proc_install->date,
|
|
|
|
NULL);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2006-04-01 00:17:07 +08:00
|
|
|
for (i = 0; i < proc_install->nparams; i++)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2006-04-05 18:40:39 +08:00
|
|
|
GParamSpec *pspec =
|
2006-04-29 06:26:51 +08:00
|
|
|
gimp_pdb_compat_param_spec (plug_in->manager->gimp,
|
2006-04-05 18:40:39 +08:00
|
|
|
proc_install->params[i].type,
|
|
|
|
proc_install->params[i].name,
|
|
|
|
proc_install->params[i].description);
|
2006-03-29 03:58:00 +08:00
|
|
|
|
2006-04-05 18:40:39 +08:00
|
|
|
gimp_procedure_add_argument (procedure, pspec);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2006-04-01 00:17:07 +08:00
|
|
|
for (i = 0; i < proc_install->nreturn_vals; i++)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2006-04-05 18:40:39 +08:00
|
|
|
GParamSpec *pspec =
|
2006-04-29 06:26:51 +08:00
|
|
|
gimp_pdb_compat_param_spec (plug_in->manager->gimp,
|
2006-04-05 18:40:39 +08:00
|
|
|
proc_install->return_vals[i].type,
|
|
|
|
proc_install->return_vals[i].name,
|
|
|
|
proc_install->return_vals[i].description);
|
2006-03-29 03:58:00 +08:00
|
|
|
|
2006-04-05 18:40:39 +08:00
|
|
|
gimp_procedure_add_return_value (procedure, pspec);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2006-04-06 18:01:30 +08:00
|
|
|
/* Sanity check menu path */
|
|
|
|
|
2006-04-04 04:54:55 +08:00
|
|
|
if (proc_install->menu_path)
|
|
|
|
{
|
|
|
|
if (proc_install->menu_path[0] == '<')
|
|
|
|
{
|
|
|
|
GError *error = NULL;
|
|
|
|
|
2006-04-10 01:08:56 +08:00
|
|
|
if (! gimp_plug_in_procedure_add_menu_path (proc,
|
|
|
|
proc_install->menu_path,
|
|
|
|
&error))
|
2006-04-04 04:54:55 +08:00
|
|
|
{
|
2006-10-10 02:49:15 +08:00
|
|
|
gimp_message (plug_in->manager->gimp, NULL, GIMP_MESSAGE_WARNING,
|
|
|
|
"%s", error->message);
|
2006-04-04 04:54:55 +08:00
|
|
|
g_clear_error (&error);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-04-05 16:38:33 +08:00
|
|
|
proc->menu_label = g_strdup (proc_install->menu_path);
|
2006-04-04 04:54:55 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-04-06 18:01:30 +08:00
|
|
|
/* Install the procedure */
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
switch (proc_install->type)
|
|
|
|
{
|
2001-05-21 21:58:46 +08:00
|
|
|
case GIMP_PLUGIN:
|
|
|
|
case GIMP_EXTENSION:
|
2007-02-19 09:16:05 +08:00
|
|
|
gimp_plug_in_def_add_procedure (plug_in->plug_in_def, proc);
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
|
2001-05-21 21:58:46 +08:00
|
|
|
case GIMP_TEMPORARY:
|
2006-05-04 02:05:06 +08:00
|
|
|
gimp_plug_in_add_temp_proc (plug_in, GIMP_TEMPORARY_PROCEDURE (proc));
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
}
|
2006-04-07 16:16:26 +08:00
|
|
|
|
|
|
|
g_object_unref (proc);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2006-05-04 02:05:06 +08:00
|
|
|
gimp_plug_in_handle_proc_uninstall (GimpPlugIn *plug_in,
|
|
|
|
GPProcUninstall *proc_uninstall)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2006-04-05 16:38:33 +08:00
|
|
|
GimpPlugInProcedure *proc;
|
|
|
|
gchar *canonical;
|
2005-08-03 06:52:23 +08:00
|
|
|
|
|
|
|
canonical = gimp_canonicalize_identifier (proc_uninstall->name);
|
|
|
|
|
2006-04-07 16:16:26 +08:00
|
|
|
proc = gimp_plug_in_procedure_find (plug_in->temp_procedures, canonical);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2006-04-05 16:38:33 +08:00
|
|
|
if (proc)
|
2006-05-04 02:05:06 +08:00
|
|
|
gimp_plug_in_remove_temp_proc (plug_in, GIMP_TEMPORARY_PROCEDURE (proc));
|
2005-08-03 06:52:23 +08:00
|
|
|
|
|
|
|
g_free (canonical);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
2002-03-21 01:46:13 +08:00
|
|
|
|
2002-05-21 18:58:50 +08:00
|
|
|
static void
|
2006-05-04 02:05:06 +08:00
|
|
|
gimp_plug_in_handle_extension_ack (GimpPlugIn *plug_in)
|
2002-05-21 18:58:50 +08:00
|
|
|
{
|
2003-06-24 02:27:03 +08:00
|
|
|
if (plug_in->ext_main_loop)
|
2003-02-03 21:21:31 +08:00
|
|
|
{
|
2003-06-24 02:27:03 +08:00
|
|
|
g_main_loop_quit (plug_in->ext_main_loop);
|
2003-02-03 21:21:31 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-10-10 02:49:15 +08:00
|
|
|
gimp_message (plug_in->manager->gimp, NULL, GIMP_MESSAGE_ERROR,
|
|
|
|
"Plug-In \"%s\"\n(%s)\n\n"
|
|
|
|
"sent an EXTENSION_ACK message while not being started "
|
|
|
|
"as an extension. This should not happen.",
|
|
|
|
gimp_object_get_name (GIMP_OBJECT (plug_in)),
|
|
|
|
gimp_filename_to_utf8 (plug_in->prog));
|
2006-05-04 02:05:06 +08:00
|
|
|
gimp_plug_in_close (plug_in, TRUE);
|
2003-02-03 21:21:31 +08:00
|
|
|
}
|
2002-05-21 18:58:50 +08:00
|
|
|
}
|
|
|
|
|
2002-02-12 15:59:16 +08:00
|
|
|
static void
|
2006-05-04 02:05:06 +08:00
|
|
|
gimp_plug_in_handle_has_init (GimpPlugIn *plug_in)
|
2002-02-12 15:59:16 +08:00
|
|
|
{
|
2006-05-03 02:27:31 +08:00
|
|
|
if (plug_in->call_mode == GIMP_PLUG_IN_CALL_QUERY)
|
2003-02-03 21:21:31 +08:00
|
|
|
{
|
2007-02-19 09:16:05 +08:00
|
|
|
gimp_plug_in_def_set_has_init (plug_in->plug_in_def, TRUE);
|
2003-02-03 21:21:31 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-10-10 02:49:15 +08:00
|
|
|
gimp_message (plug_in->manager->gimp, NULL, GIMP_MESSAGE_ERROR,
|
|
|
|
"Plug-In \"%s\"\n(%s)\n\n"
|
|
|
|
"sent an HAS_INIT message while not in query(). "
|
|
|
|
"This should not happen.",
|
|
|
|
gimp_object_get_name (GIMP_OBJECT (plug_in)),
|
|
|
|
gimp_filename_to_utf8 (plug_in->prog));
|
2006-05-04 02:05:06 +08:00
|
|
|
gimp_plug_in_close (plug_in, TRUE);
|
2003-02-03 21:21:31 +08:00
|
|
|
}
|
2002-02-12 15:59:16 +08:00
|
|
|
}
|