Made an object out of the plug-in struct. Also change refcounting

2006-05-03  Michael Natterer  <mitch@gimp.org>

	Made an object out of the plug-in struct. Also change refcounting
	considerably:

	- gimp_plug_in_open() adds a reference that is only dropped by
	  gimp_plug_in_close().
	- temporarily ref the plug-in while handling messages.
	- remporarily ref the plug-in while a recursive main loop is
	  running.
	- each caller of gimp_plug_in_new() also unrefs the plug-in before
	  returning, the only reference that persists across functions
	  (that keeps the plug-in alive) is the one added by open().

	* app/plug-in/plug-in.[ch]
	* app/plug-in/plug-in-context.[ch]
	* app/plug-in/plug-in-message.[ch]
	* app/plug-in/plug-in-progress.[ch]: removed these files...

	* app/plug-in/gimpplugin.[ch]
	* app/plug-in/gimpplugin-context.[ch]
	* app/plug-in/gimpplugin-message.[ch]
	* app/plug-in/gimpplugin-progress.[ch]: ...and added here as GObject.

	* app/plug-in/plug-in-proc-frame.[ch]: removed...

	* app/plug-in/gimppluginprocframe.[ch]: ...and added with a namespace.

	* app/plug-in/Makefile.am
	* app/plug-in/plug-in-types.h
	* app/plug-in/gimppluginmanager-call.c
	* app/plug-in/gimppluginmanager-file.c
	* app/plug-in/gimppluginmanager.[ch]
	* app/pdb/gimppluginprocedure.c
	* app/pdb/gimptemporaryprocedure.c
	* app/pdb/gimptemporaryprocedure.h
	* tools/pdbgen/pdb/context.pdb
	* tools/pdbgen/pdb/drawable.pdb
	* tools/pdbgen/pdb/help.pdb
	* tools/pdbgen/pdb/message.pdb
	* tools/pdbgen/pdb/plug_in.pdb
	* tools/pdbgen/pdb/progress.pdb
	* tools/pdbgen/pdb/undo.pdb: changed accordingly.

	* app/pdb/context_cmds.c
	* app/pdb/drawable_cmds.c
	* app/pdb/help_cmds.c
	* app/pdb/message_cmds.c
	* app/pdb/plug_in_cmds.c
	* app/pdb/progress_cmds.c
	* app/pdb/undo_cmds.c: regenerated.
This commit is contained in:
Michael Natterer 2006-05-03 18:05:06 +00:00 committed by Michael Natterer
parent ce320fdf6b
commit 4b917ea28b
47 changed files with 727 additions and 3217 deletions

View File

@ -1,3 +1,55 @@
2006-05-03 Michael Natterer <mitch@gimp.org>
Made an object out of the plug-in struct. Also change refcounting
considerably:
- gimp_plug_in_open() adds a reference that is only dropped by
gimp_plug_in_close().
- temporarily ref the plug-in while handling messages.
- remporarily ref the plug-in while a recursive main loop is
running.
- each caller of gimp_plug_in_new() also unrefs the plug-in before
returning, the only reference that persists across functions
(that keeps the plug-in alive) is the one added by open().
* app/plug-in/plug-in.[ch]
* app/plug-in/plug-in-context.[ch]
* app/plug-in/plug-in-message.[ch]
* app/plug-in/plug-in-progress.[ch]: removed these files...
* app/plug-in/gimpplugin.[ch]
* app/plug-in/gimpplugin-context.[ch]
* app/plug-in/gimpplugin-message.[ch]
* app/plug-in/gimpplugin-progress.[ch]: ...and added here as GObject.
* app/plug-in/plug-in-proc-frame.[ch]: removed...
* app/plug-in/gimppluginprocframe.[ch]: ...and added with a namespace.
* app/plug-in/Makefile.am
* app/plug-in/plug-in-types.h
* app/plug-in/gimppluginmanager-call.c
* app/plug-in/gimppluginmanager-file.c
* app/plug-in/gimppluginmanager.[ch]
* app/pdb/gimppluginprocedure.c
* app/pdb/gimptemporaryprocedure.c
* app/pdb/gimptemporaryprocedure.h
* tools/pdbgen/pdb/context.pdb
* tools/pdbgen/pdb/drawable.pdb
* tools/pdbgen/pdb/help.pdb
* tools/pdbgen/pdb/message.pdb
* tools/pdbgen/pdb/plug_in.pdb
* tools/pdbgen/pdb/progress.pdb
* tools/pdbgen/pdb/undo.pdb: changed accordingly.
* app/pdb/context_cmds.c
* app/pdb/drawable_cmds.c
* app/pdb/help_cmds.c
* app/pdb/message_cmds.c
* app/pdb/plug_in_cmds.c
* app/pdb/progress_cmds.c
* app/pdb/undo_cmds.c: regenerated.
2006-05-03 Sven Neumann <sven@gimp.org>
* plug-ins/common/gifload.c: removed some unused code, untabified.

View File

@ -34,9 +34,9 @@
#include "core/gimpcontainer.h"
#include "core/gimpcontext.h"
#include "core/gimpdatafactory.h"
#include "plug-in/gimpplugin-context.h"
#include "plug-in/gimpplugin.h"
#include "plug-in/gimppluginmanager.h"
#include "plug-in/plug-in-context.h"
#include "plug-in/plug-in.h"
static GValueArray *
@ -47,11 +47,13 @@ context_push_invoker (GimpProcedure *procedure,
const GValueArray *args)
{
gboolean success = TRUE;
if (gimp->plug_in_manager->current_plug_in &&
gimp->plug_in_manager->current_plug_in->open)
success = plug_in_context_push (gimp->plug_in_manager->current_plug_in);
GimpPlugIn *plug_in = gimp->plug_in_manager->current_plug_in;
if (plug_in && plug_in->open)
success = gimp_plug_in_context_push (plug_in);
else
success = FALSE;
return gimp_procedure_get_return_values (procedure, success);
}
@ -63,11 +65,13 @@ context_pop_invoker (GimpProcedure *procedure,
const GValueArray *args)
{
gboolean success = TRUE;
if (gimp->plug_in_manager->current_plug_in &&
gimp->plug_in_manager->current_plug_in->open)
success = plug_in_context_pop (gimp->plug_in_manager->current_plug_in);
GimpPlugIn *plug_in = gimp->plug_in_manager->current_plug_in;
if (plug_in && plug_in->open)
success = gimp_plug_in_context_pop (plug_in);
else
success = FALSE;
return gimp_procedure_get_return_values (procedure, success);
}

View File

@ -41,8 +41,8 @@
#include "core/gimplayer.h"
#include "core/gimplayermask.h"
#include "gimp-intl.h"
#include "plug-in/gimpplugin.h"
#include "plug-in/gimppluginmanager.h"
#include "plug-in/plug-in.h"
static GValueArray *
@ -764,7 +764,7 @@ drawable_merge_shadow_invoker (GimpProcedure *procedure,
gchar *undo_desc = NULL;
if (gimp->plug_in_manager->current_plug_in)
undo_desc = plug_in_get_undo_desc (gimp->plug_in_manager->current_plug_in);
undo_desc = gimp_plug_in_get_undo_desc (gimp->plug_in_manager->current_plug_in);
if (! undo_desc)
undo_desc = g_strdup (_("Plug-In"));

View File

@ -1,7 +1,7 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* plug-in-proc-def.c
* gimppluginprocedure.c
*
* 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
@ -35,7 +35,6 @@
#define __YES_I_NEED_GIMP_PLUG_IN_MANAGER_CALL__
#include "plug-in/gimppluginmanager-call.h"
#include "plug-in/plug-in.h"
#include "gimppluginprocedure.h"

View File

@ -26,9 +26,9 @@
#include "core/gimp.h"
#include "plug-in/gimpplugin.h"
#define __YES_I_NEED_GIMP_PLUG_IN_MANAGER_CALL__
#include "plug-in/gimppluginmanager-call.h"
#include "plug-in/plug-in.h"
#include "gimptemporaryprocedure.h"
@ -128,11 +128,11 @@ gimp_temporary_procedure_get_progname (const GimpPlugInProcedure *procedure)
/* public functions */
GimpProcedure *
gimp_temporary_procedure_new (PlugIn *plug_in)
gimp_temporary_procedure_new (GimpPlugIn *plug_in)
{
GimpTemporaryProcedure *proc;
g_return_val_if_fail (plug_in != NULL, NULL);
g_return_val_if_fail (GIMP_IS_PLUG_IN (plug_in), NULL);
proc = g_object_new (GIMP_TYPE_TEMPORARY_PROCEDURE, NULL);

View File

@ -39,7 +39,7 @@ struct _GimpTemporaryProcedure
{
GimpPlugInProcedure parent_instance;
PlugIn *plug_in;
GimpPlugIn *plug_in;
};
struct _GimpTemporaryProcedureClass
@ -50,7 +50,7 @@ struct _GimpTemporaryProcedureClass
GType gimp_temporary_procedure_get_type (void) G_GNUC_CONST;
GimpProcedure * gimp_temporary_procedure_new (PlugIn *plug_in);
GimpProcedure * gimp_temporary_procedure_new (GimpPlugIn *plug_in);
#endif /* __GIMP_TEMPORARY_PROCEDURE_H__ */

View File

@ -29,9 +29,9 @@
#include "core/gimpparamspecs.h"
#include "core/gimp.h"
#include "plug-in/gimpplugin.h"
#include "plug-in/gimppluginmanager-help-domain.h"
#include "plug-in/gimppluginmanager.h"
#include "plug-in/plug-in.h"
static GValueArray *

View File

@ -31,9 +31,9 @@
#include "core/gimp.h"
#include "gimp-intl.h"
#include "plug-in/gimpplugin-progress.h"
#include "plug-in/gimpplugin.h"
#include "plug-in/gimppluginmanager.h"
#include "plug-in/plug-in-progress.h"
#include "plug-in/plug-in.h"
static GValueArray *
@ -51,7 +51,8 @@ message_invoker (GimpProcedure *procedure,
if (success)
{
if (gimp->plug_in_manager->current_plug_in)
plug_in_progress_message (gimp->plug_in_manager->current_plug_in, message);
gimp_plug_in_progress_message (gimp->plug_in_manager->current_plug_in,
message);
else
gimp_message (gimp, NULL, message);
}

View File

@ -34,11 +34,11 @@
#include "core/gimp.h"
#include "gimppluginprocedure.h"
#include "plug-in/gimpplugin.h"
#include "plug-in/gimppluginmanager-menu-branch.h"
#include "plug-in/gimppluginmanager-query.h"
#include "plug-in/gimppluginmanager.h"
#include "plug-in/plug-in-def.h"
#include "plug-in/plug-in.h"
static GValueArray *
@ -103,7 +103,7 @@ plugin_domain_register_invoker (GimpProcedure *procedure,
if (success)
{
PlugIn *plug_in = gimp->plug_in_manager->current_plug_in;
GimpPlugIn *plug_in = gimp->plug_in_manager->current_plug_in;
if (plug_in && plug_in->call_mode == GIMP_PLUG_IN_CALL_QUERY)
{
@ -133,7 +133,7 @@ plugin_help_register_invoker (GimpProcedure *procedure,
if (success)
{
PlugIn *plug_in = gimp->plug_in_manager->current_plug_in;
GimpPlugIn *plug_in = gimp->plug_in_manager->current_plug_in;
if (plug_in && plug_in->call_mode == GIMP_PLUG_IN_CALL_QUERY)
{
@ -163,12 +163,12 @@ plugin_menu_register_invoker (GimpProcedure *procedure,
if (success)
{
PlugIn *plug_in = gimp->plug_in_manager->current_plug_in;
GimpPlugIn *plug_in = gimp->plug_in_manager->current_plug_in;
if (plug_in)
{
gchar *canonical = gimp_canonicalize_identifier (procedure_name);
success = plug_in_menu_register (plug_in, canonical, menu_path);
success = gimp_plug_in_menu_register (plug_in, canonical, menu_path);
g_free (canonical);
}
else
@ -196,7 +196,7 @@ plugin_menu_branch_register_invoker (GimpProcedure *procedure,
if (success)
{
PlugIn *plug_in = gimp->plug_in_manager->current_plug_in;
GimpPlugIn *plug_in = gimp->plug_in_manager->current_plug_in;
if (plug_in)
{
@ -230,7 +230,7 @@ plugin_icon_register_invoker (GimpProcedure *procedure,
if (success)
{
PlugIn *plug_in = gimp->plug_in_manager->current_plug_in;
GimpPlugIn *plug_in = gimp->plug_in_manager->current_plug_in;
if (plug_in && plug_in->call_mode == GIMP_PLUG_IN_CALL_QUERY)
{

View File

@ -29,9 +29,9 @@
#include "core/gimpparamspecs.h"
#include "core/gimp.h"
#include "plug-in/gimpplugin-progress.h"
#include "plug-in/gimpplugin.h"
#include "plug-in/gimppluginmanager.h"
#include "plug-in/plug-in-progress.h"
#include "plug-in/plug-in.h"
static GValueArray *
@ -50,12 +50,12 @@ progress_init_invoker (GimpProcedure *procedure,
if (success)
{
PlugIn *plug_in = gimp->plug_in_manager->current_plug_in;
GimpPlugIn *plug_in = gimp->plug_in_manager->current_plug_in;
if (plug_in && plug_in->open)
{
if (! gimp->no_interface)
plug_in_progress_start (plug_in, message, gdisplay);
gimp_plug_in_progress_start (plug_in, message, gdisplay);
}
else
success = FALSE;
@ -78,12 +78,12 @@ progress_update_invoker (GimpProcedure *procedure,
if (success)
{
PlugIn *plug_in = gimp->plug_in_manager->current_plug_in;
GimpPlugIn *plug_in = gimp->plug_in_manager->current_plug_in;
if (plug_in && plug_in->open)
{
if (! gimp->no_interface)
plug_in_progress_set_value (plug_in, percentage);
gimp_plug_in_progress_set_value (plug_in, percentage);
}
else
success = FALSE;
@ -100,12 +100,12 @@ progress_pulse_invoker (GimpProcedure *procedure,
const GValueArray *args)
{
gboolean success = TRUE;
PlugIn *plug_in = gimp->plug_in_manager->current_plug_in;
GimpPlugIn *plug_in = gimp->plug_in_manager->current_plug_in;
if (plug_in && plug_in->open)
{
if (! gimp->no_interface)
plug_in_progress_pulse (plug_in);
gimp_plug_in_progress_pulse (plug_in);
}
else
success = FALSE;
@ -127,12 +127,12 @@ progress_set_text_invoker (GimpProcedure *procedure,
if (success)
{
PlugIn *plug_in = gimp->plug_in_manager->current_plug_in;
GimpPlugIn *plug_in = gimp->plug_in_manager->current_plug_in;
if (plug_in && plug_in->open)
{
if (! gimp->no_interface)
plug_in_progress_set_text (plug_in, message);
gimp_plug_in_progress_set_text (plug_in, message);
}
else
success = FALSE;
@ -152,12 +152,12 @@ progress_get_window_handle_invoker (GimpProcedure *procedure,
GValueArray *return_vals;
gint32 window = 0;
PlugIn *plug_in = gimp->plug_in_manager->current_plug_in;
GimpPlugIn *plug_in = gimp->plug_in_manager->current_plug_in;
if (plug_in && plug_in->open)
{
if (! gimp->no_interface)
window = plug_in_progress_get_window (plug_in);
window = gimp_plug_in_progress_get_window (plug_in);
}
else
success = FALSE;
@ -184,10 +184,10 @@ progress_install_invoker (GimpProcedure *procedure,
if (success)
{
PlugIn *plug_in = gimp->plug_in_manager->current_plug_in;
GimpPlugIn *plug_in = gimp->plug_in_manager->current_plug_in;
if (plug_in && plug_in->open)
success = plug_in_progress_install (plug_in, progress_callback);
success = gimp_plug_in_progress_install (plug_in, progress_callback);
else
success = FALSE;
}
@ -209,10 +209,10 @@ progress_uninstall_invoker (GimpProcedure *procedure,
if (success)
{
PlugIn *plug_in = gimp->plug_in_manager->current_plug_in;
GimpPlugIn *plug_in = gimp->plug_in_manager->current_plug_in;
if (plug_in && plug_in->open)
success = plug_in_progress_uninstall (plug_in, progress_callback);
success = gimp_plug_in_progress_uninstall (plug_in, progress_callback);
else
success = FALSE;
}
@ -234,10 +234,10 @@ progress_cancel_invoker (GimpProcedure *procedure,
if (success)
{
PlugIn *plug_in = gimp->plug_in_manager->current_plug_in;
GimpPlugIn *plug_in = gimp->plug_in_manager->current_plug_in;
if (plug_in && plug_in->open)
success = plug_in_progress_cancel (plug_in, progress_callback);
success = gimp_plug_in_progress_cancel (plug_in, progress_callback);
else
success = FALSE;
}

View File

@ -31,8 +31,8 @@
#include "core/gimp.h"
#include "core/gimpimage-undo.h"
#include "core/gimpimage.h"
#include "plug-in/gimpplugin.h"
#include "plug-in/gimppluginmanager.h"
#include "plug-in/plug-in.h"
static GValueArray *
@ -49,11 +49,11 @@ image_undo_group_start_invoker (GimpProcedure *procedure,
if (success)
{
PlugIn *plug_in = gimp->plug_in_manager->current_plug_in;
gchar *undo_desc = NULL;
GimpPlugIn *plug_in = gimp->plug_in_manager->current_plug_in;
gchar *undo_desc = NULL;
if (plug_in)
undo_desc = plug_in_get_undo_desc (plug_in);
undo_desc = gimp_plug_in_get_undo_desc (plug_in);
gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_MISC, undo_desc);

View File

@ -25,6 +25,14 @@ libappplug_in_a_SOURCES = \
gimpinterpreterdb.h \
gimpplugindebug.c \
gimpplugindebug.h \
gimpplugin.c \
gimpplugin.h \
gimpplugin-context.c \
gimpplugin-context.h \
gimpplugin-message.c \
gimpplugin-message.h \
gimpplugin-progress.c \
gimpplugin-progress.h \
gimppluginmanager.c \
gimppluginmanager.h \
gimppluginmanager-call.c \
@ -41,23 +49,15 @@ libappplug_in_a_SOURCES = \
gimppluginmanager-menu-branch.h \
gimppluginmanager-query.c \
gimppluginmanager-query.h \
gimppluginprocframe.c \
gimppluginprocframe.h \
gimppluginshm.c \
gimppluginshm.h \
\
plug-in.c \
plug-in.h \
plug-in-context.c \
plug-in-context.h \
plug-in-def.c \
plug-in-def.h \
plug-in-message.c \
plug-in-message.h \
plug-in-params.c \
plug-in-params.h \
plug-in-proc-frame.c \
plug-in-proc-frame.h \
plug-in-progress.c \
plug-in-progress.h \
plug-in-rc.c \
plug-in-rc.h

View File

@ -1,6 +1,8 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpplugin-context.c
*
* 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
@ -25,21 +27,21 @@
#include "core/gimp.h"
#include "core/gimpcontext.h"
#include "gimpplugin.h"
#include "gimpplugin-context.h"
#include "gimppluginmanager.h"
#include "plug-in.h"
#include "plug-in-context.h"
gboolean
plug_in_context_push (PlugIn *plug_in)
gimp_plug_in_context_push (GimpPlugIn *plug_in)
{
PlugInProcFrame *proc_frame;
GimpContext *parent;
GimpContext *context;
GimpPlugInProcFrame *proc_frame;
GimpContext *parent;
GimpContext *context;
g_return_val_if_fail (plug_in != NULL, FALSE);
g_return_val_if_fail (GIMP_IS_PLUG_IN (plug_in), FALSE);
proc_frame = plug_in_get_proc_frame (plug_in);
proc_frame = gimp_plug_in_get_proc_frame (plug_in);
if (proc_frame->context_stack)
parent = proc_frame->context_stack->data;
@ -56,13 +58,13 @@ plug_in_context_push (PlugIn *plug_in)
}
gboolean
plug_in_context_pop (PlugIn *plug_in)
gimp_plug_in_context_pop (GimpPlugIn *plug_in)
{
PlugInProcFrame *proc_frame;
GimpPlugInProcFrame *proc_frame;
g_return_val_if_fail (plug_in != NULL, FALSE);
g_return_val_if_fail (GIMP_IS_PLUG_IN (plug_in), FALSE);
proc_frame = plug_in_get_proc_frame (plug_in);
proc_frame = gimp_plug_in_get_proc_frame (plug_in);
if (proc_frame->context_stack)
{

View File

@ -1,7 +1,7 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* plug-in-context.h
* gimpplugin-context.h
*
* 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
@ -18,12 +18,12 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __PLUG_IN_CONTEXT_H__
#define __PLUG_IN_CONTEXT_H__
#ifndef __GIMP_PLUG_IN_CONTEXT_H__
#define __GIMP_PLUG_IN_CONTEXT_H__
gboolean plug_in_context_push (PlugIn *plug_in);
gboolean plug_in_context_pop (PlugIn *plug_in);
gboolean gimp_plug_in_context_push (GimpPlugIn *plug_in);
gboolean gimp_plug_in_context_pop (GimpPlugIn *plug_in);
#endif /* __PLUG_IN_CONTEXT_H__ */
#endif /* __GIMP_PLUG_IN_CONTEXT_H__ */

View File

@ -1,7 +1,7 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* plug-in-message.c
* gimpplugin-message.c
*
* 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
@ -40,41 +40,46 @@
#include "pdb/gimp-pdb-compat.h"
#include "pdb/gimptemporaryprocedure.h"
#include "gimpplugin.h"
#include "gimpplugin-message.h"
#include "gimppluginmanager.h"
#include "plug-in.h"
#include "plug-in-def.h"
#include "plug-in-params.h"
/* local function prototypes */
static void plug_in_handle_quit (PlugIn *plug_in);
static void plug_in_handle_tile_req (PlugIn *plug_in,
GPTileReq *tile_req);
static void plug_in_handle_proc_run (PlugIn *plug_in,
GPProcRun *proc_run);
static void plug_in_handle_proc_return (PlugIn *plug_in,
GPProcReturn *proc_return);
static void plug_in_handle_temp_proc_return (PlugIn *plug_in,
GPProcReturn *proc_return);
static void plug_in_handle_proc_install (PlugIn *plug_in,
GPProcInstall *proc_install);
static void plug_in_handle_proc_uninstall (PlugIn *plug_in,
GPProcUninstall *proc_uninstall);
static void plug_in_handle_extension_ack (PlugIn *plug_in);
static void plug_in_handle_has_init (PlugIn *plug_in);
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);
/* public functions */
void
plug_in_handle_message (PlugIn *plug_in,
GimpWireMessage *msg)
gimp_plug_in_handle_message (GimpPlugIn *plug_in,
GimpWireMessage *msg)
{
g_return_if_fail (GIMP_IS_PLUG_IN (plug_in));
g_return_if_fail (plug_in->open == TRUE);
g_return_if_fail (msg != NULL);
switch (msg->type)
{
case GP_QUIT:
plug_in_handle_quit (plug_in);
gimp_plug_in_handle_quit (plug_in);
break;
case GP_CONFIG:
@ -82,11 +87,11 @@ plug_in_handle_message (PlugIn *plug_in,
"sent a CONFIG message. This should not happen.",
gimp_filename_to_utf8 (plug_in->name),
gimp_filename_to_utf8 (plug_in->prog));
plug_in_close (plug_in, TRUE);
gimp_plug_in_close (plug_in, TRUE);
break;
case GP_TILE_REQ:
plug_in_handle_tile_req (plug_in, msg->data);
gimp_plug_in_handle_tile_req (plug_in, msg->data);
break;
case GP_TILE_ACK:
@ -94,7 +99,7 @@ plug_in_handle_message (PlugIn *plug_in,
"sent a TILE_ACK message. This should not happen.",
gimp_filename_to_utf8 (plug_in->name),
gimp_filename_to_utf8 (plug_in->prog));
plug_in_close (plug_in, TRUE);
gimp_plug_in_close (plug_in, TRUE);
break;
case GP_TILE_DATA:
@ -102,15 +107,15 @@ plug_in_handle_message (PlugIn *plug_in,
"sent a TILE_DATA message. This should not happen.",
gimp_filename_to_utf8 (plug_in->name),
gimp_filename_to_utf8 (plug_in->prog));
plug_in_close (plug_in, TRUE);
gimp_plug_in_close (plug_in, TRUE);
break;
case GP_PROC_RUN:
plug_in_handle_proc_run (plug_in, msg->data);
gimp_plug_in_handle_proc_run (plug_in, msg->data);
break;
case GP_PROC_RETURN:
plug_in_handle_proc_return (plug_in, msg->data);
gimp_plug_in_handle_proc_return (plug_in, msg->data);
break;
case GP_TEMP_PROC_RUN:
@ -118,27 +123,27 @@ plug_in_handle_message (PlugIn *plug_in,
"sent a TEMP_PROC_RUN message. This should not happen.",
gimp_filename_to_utf8 (plug_in->name),
gimp_filename_to_utf8 (plug_in->prog));
plug_in_close (plug_in, TRUE);
gimp_plug_in_close (plug_in, TRUE);
break;
case GP_TEMP_PROC_RETURN:
plug_in_handle_temp_proc_return (plug_in, msg->data);
gimp_plug_in_handle_temp_proc_return (plug_in, msg->data);
break;
case GP_PROC_INSTALL:
plug_in_handle_proc_install (plug_in, msg->data);
gimp_plug_in_handle_proc_install (plug_in, msg->data);
break;
case GP_PROC_UNINSTALL:
plug_in_handle_proc_uninstall (plug_in, msg->data);
gimp_plug_in_handle_proc_uninstall (plug_in, msg->data);
break;
case GP_EXTENSION_ACK:
plug_in_handle_extension_ack (plug_in);
gimp_plug_in_handle_extension_ack (plug_in);
break;
case GP_HAS_INIT:
plug_in_handle_has_init (plug_in);
gimp_plug_in_handle_has_init (plug_in);
break;
}
}
@ -147,14 +152,14 @@ plug_in_handle_message (PlugIn *plug_in,
/* private functions */
static void
plug_in_handle_quit (PlugIn *plug_in)
gimp_plug_in_handle_quit (GimpPlugIn *plug_in)
{
plug_in_close (plug_in, FALSE);
gimp_plug_in_close (plug_in, FALSE);
}
static void
plug_in_handle_tile_req (PlugIn *plug_in,
GPTileReq *tile_req)
gimp_plug_in_handle_tile_req (GimpPlugIn *plug_in,
GPTileReq *tile_req)
{
GPTileData tile_data;
GPTileData *tile_info;
@ -182,21 +187,21 @@ plug_in_handle_tile_req (PlugIn *plug_in,
if (! gp_tile_data_write (plug_in->my_write, &tile_data, plug_in))
{
g_warning ("plug_in_handle_tile_req: ERROR");
plug_in_close (plug_in, TRUE);
gimp_plug_in_close (plug_in, TRUE);
return;
}
if (! gimp_wire_read_msg (plug_in->my_read, &msg, plug_in))
{
g_warning ("plug_in_handle_tile_req: ERROR");
plug_in_close (plug_in, TRUE);
gimp_plug_in_close (plug_in, TRUE);
return;
}
if (msg.type != GP_TILE_DATA)
{
g_warning ("expected tile data and received: %d", msg.type);
plug_in_close (plug_in, TRUE);
gimp_plug_in_close (plug_in, TRUE);
return;
}
@ -211,7 +216,7 @@ plug_in_handle_tile_req (PlugIn *plug_in,
"requested invalid drawable (killing)",
gimp_filename_to_utf8 (plug_in->name),
gimp_filename_to_utf8 (plug_in->prog));
plug_in_close (plug_in, TRUE);
gimp_plug_in_close (plug_in, TRUE);
return;
}
@ -228,7 +233,7 @@ plug_in_handle_tile_req (PlugIn *plug_in,
"requested invalid tile (killing)",
gimp_filename_to_utf8 (plug_in->name),
gimp_filename_to_utf8 (plug_in->prog));
plug_in_close (plug_in, TRUE);
gimp_plug_in_close (plug_in, TRUE);
return;
}
@ -247,7 +252,7 @@ plug_in_handle_tile_req (PlugIn *plug_in,
if (! gp_tile_ack_write (plug_in->my_write, plug_in))
{
g_warning ("plug_in_handle_tile_req: ERROR");
plug_in_close (plug_in, TRUE);
gimp_plug_in_close (plug_in, TRUE);
return;
}
}
@ -264,7 +269,7 @@ plug_in_handle_tile_req (PlugIn *plug_in,
"requested invalid drawable (killing)",
gimp_filename_to_utf8 (plug_in->name),
gimp_filename_to_utf8 (plug_in->prog));
plug_in_close (plug_in, TRUE);
gimp_plug_in_close (plug_in, TRUE);
return;
}
@ -281,7 +286,7 @@ plug_in_handle_tile_req (PlugIn *plug_in,
"requested invalid tile (killing)",
gimp_filename_to_utf8 (plug_in->name),
gimp_filename_to_utf8 (plug_in->prog));
plug_in_close (plug_in, TRUE);
gimp_plug_in_close (plug_in, TRUE);
return;
}
@ -303,7 +308,7 @@ plug_in_handle_tile_req (PlugIn *plug_in,
if (! gp_tile_data_write (plug_in->my_write, &tile_data, plug_in))
{
g_message ("plug_in_handle_tile_req: ERROR");
plug_in_close (plug_in, TRUE);
gimp_plug_in_close (plug_in, TRUE);
return;
}
@ -312,14 +317,14 @@ plug_in_handle_tile_req (PlugIn *plug_in,
if (! gimp_wire_read_msg (plug_in->my_read, &msg, plug_in))
{
g_message ("plug_in_handle_tile_req: ERROR");
plug_in_close (plug_in, TRUE);
gimp_plug_in_close (plug_in, TRUE);
return;
}
if (msg.type != GP_TILE_ACK)
{
g_warning ("expected tile ack and received: %d", msg.type);
plug_in_close (plug_in, TRUE);
gimp_plug_in_close (plug_in, TRUE);
return;
}
@ -328,20 +333,20 @@ plug_in_handle_tile_req (PlugIn *plug_in,
}
static void
plug_in_handle_proc_run (PlugIn *plug_in,
GPProcRun *proc_run)
gimp_plug_in_handle_proc_run (GimpPlugIn *plug_in,
GPProcRun *proc_run)
{
PlugInProcFrame *proc_frame;
gchar *canonical;
const gchar *proc_name = NULL;
GimpProcedure *procedure;
GValueArray *args = NULL;
GValueArray *return_vals = NULL;
GPProcReturn proc_return;
GimpPlugInProcFrame *proc_frame;
gchar *canonical;
const gchar *proc_name = NULL;
GimpProcedure *procedure;
GValueArray *args = NULL;
GValueArray *return_vals = NULL;
GPProcReturn proc_return;
canonical = gimp_canonicalize_identifier (proc_run->name);
proc_frame = plug_in_get_proc_frame (plug_in);
proc_frame = gimp_plug_in_get_proc_frame (plug_in);
procedure = gimp_pdb_lookup_procedure (plug_in->manager->gimp->pdb,
canonical);
@ -430,7 +435,7 @@ plug_in_handle_proc_run (PlugIn *plug_in,
if (! gp_proc_return_write (plug_in->my_write, &proc_return, plug_in))
{
g_warning ("plug_in_handle_proc_run: ERROR");
plug_in_close (plug_in, TRUE);
gimp_plug_in_close (plug_in, TRUE);
}
g_value_array_free (args);
@ -439,10 +444,10 @@ plug_in_handle_proc_run (PlugIn *plug_in,
}
static void
plug_in_handle_proc_return (PlugIn *plug_in,
GPProcReturn *proc_return)
gimp_plug_in_handle_proc_return (GimpPlugIn *plug_in,
GPProcReturn *proc_return)
{
PlugInProcFrame *proc_frame = &plug_in->main_proc_frame;
GimpPlugInProcFrame *proc_frame = &plug_in->main_proc_frame;
if (proc_frame->main_loop)
proc_frame->return_vals =
@ -455,16 +460,16 @@ plug_in_handle_proc_return (PlugIn *plug_in,
if (proc_frame->main_loop)
g_main_loop_quit (proc_frame->main_loop);
plug_in_close (plug_in, FALSE);
gimp_plug_in_close (plug_in, FALSE);
}
static void
plug_in_handle_temp_proc_return (PlugIn *plug_in,
GPProcReturn *proc_return)
gimp_plug_in_handle_temp_proc_return (GimpPlugIn *plug_in,
GPProcReturn *proc_return)
{
if (plug_in->temp_proc_frames)
{
PlugInProcFrame *proc_frame = plug_in->temp_proc_frames->data;
GimpPlugInProcFrame *proc_frame = plug_in->temp_proc_frames->data;
proc_frame->return_vals =
plug_in_params_to_args (proc_frame->procedure->values,
@ -473,8 +478,8 @@ plug_in_handle_temp_proc_return (PlugIn *plug_in,
proc_return->nparams,
TRUE, TRUE);
plug_in_main_loop_quit (plug_in);
plug_in_proc_frame_pop (plug_in);
gimp_plug_in_main_loop_quit (plug_in);
gimp_plug_in_proc_frame_pop (plug_in);
}
else
{
@ -483,13 +488,13 @@ plug_in_handle_temp_proc_return (PlugIn *plug_in,
"a temporary procedure. This should not happen.",
gimp_filename_to_utf8 (plug_in->name),
gimp_filename_to_utf8 (plug_in->prog));
plug_in_close (plug_in, TRUE);
gimp_plug_in_close (plug_in, TRUE);
}
}
static void
plug_in_handle_proc_install (PlugIn *plug_in,
GPProcInstall *proc_install)
gimp_plug_in_handle_proc_install (GimpPlugIn *plug_in,
GPProcInstall *proc_install)
{
GimpPlugInProcedure *proc = NULL;
GimpProcedure *procedure = NULL;
@ -587,7 +592,7 @@ plug_in_handle_proc_install (PlugIn *plug_in,
proc = gimp_plug_in_procedure_find (plug_in->temp_procedures, canonical);
if (proc)
plug_in_remove_temp_proc (plug_in, GIMP_TEMPORARY_PROCEDURE (proc));
gimp_plug_in_remove_temp_proc (plug_in, GIMP_TEMPORARY_PROCEDURE (proc));
procedure = gimp_temporary_procedure_new (plug_in);
break;
@ -664,7 +669,7 @@ plug_in_handle_proc_install (PlugIn *plug_in,
break;
case GIMP_TEMPORARY:
plug_in_add_temp_proc (plug_in, GIMP_TEMPORARY_PROCEDURE (proc));
gimp_plug_in_add_temp_proc (plug_in, GIMP_TEMPORARY_PROCEDURE (proc));
break;
}
@ -672,8 +677,8 @@ plug_in_handle_proc_install (PlugIn *plug_in,
}
static void
plug_in_handle_proc_uninstall (PlugIn *plug_in,
GPProcUninstall *proc_uninstall)
gimp_plug_in_handle_proc_uninstall (GimpPlugIn *plug_in,
GPProcUninstall *proc_uninstall)
{
GimpPlugInProcedure *proc;
gchar *canonical;
@ -683,13 +688,13 @@ plug_in_handle_proc_uninstall (PlugIn *plug_in,
proc = gimp_plug_in_procedure_find (plug_in->temp_procedures, canonical);
if (proc)
plug_in_remove_temp_proc (plug_in, GIMP_TEMPORARY_PROCEDURE (proc));
gimp_plug_in_remove_temp_proc (plug_in, GIMP_TEMPORARY_PROCEDURE (proc));
g_free (canonical);
}
static void
plug_in_handle_extension_ack (PlugIn *plug_in)
gimp_plug_in_handle_extension_ack (GimpPlugIn *plug_in)
{
if (plug_in->ext_main_loop)
{
@ -702,12 +707,12 @@ plug_in_handle_extension_ack (PlugIn *plug_in)
"as an extension. This should not happen.",
gimp_filename_to_utf8 (plug_in->name),
gimp_filename_to_utf8 (plug_in->prog));
plug_in_close (plug_in, TRUE);
gimp_plug_in_close (plug_in, TRUE);
}
}
static void
plug_in_handle_has_init (PlugIn *plug_in)
gimp_plug_in_handle_has_init (GimpPlugIn *plug_in)
{
if (plug_in->call_mode == GIMP_PLUG_IN_CALL_QUERY)
{
@ -720,6 +725,6 @@ plug_in_handle_has_init (PlugIn *plug_in)
"This should not happen.",
gimp_filename_to_utf8 (plug_in->name),
gimp_filename_to_utf8 (plug_in->prog));
plug_in_close (plug_in, TRUE);
gimp_plug_in_close (plug_in, TRUE);
}
}

View File

@ -1,7 +1,7 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* plug-in-message.h
* gimpplugin-message.h
*
* 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
@ -18,12 +18,12 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __PLUG_IN_MESSAGE_H__
#define __PLUG_IN_MESSAGE_H__
#ifndef __GIMP_PLUG_IN_MESSAGE_H__
#define __GIMP_PLUG_IN_MESSAGE_H__
void plug_in_handle_message (PlugIn *plug_in,
GimpWireMessage *msg);
void gimp_plug_in_handle_message (GimpPlugIn *plug_in,
GimpWireMessage *msg);
#endif /* __PLUG_IN_MESSAGE_H__ */
#endif /* __GIMP_PLUG_IN_MESSAGE_H__ */

View File

@ -1,7 +1,7 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* plug-in-progress.c
* gimpplugin-progress.c
*
* 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
@ -32,30 +32,30 @@
#include "pdb/gimppdb.h"
#include "pdb/gimptemporaryprocedure.h"
#include "gimpplugin.h"
#include "gimpplugin-progress.h"
#include "gimppluginmanager.h"
#include "plug-in.h"
#include "plug-in-progress.h"
/* local function prototypes */
static void plug_in_progress_cancel_callback (GimpProgress *progress,
PlugIn *plug_in);
static void gimp_plug_in_progress_cancel_callback (GimpProgress *progress,
GimpPlugIn *plug_in);
/* public functions */
void
plug_in_progress_start (PlugIn *plug_in,
const gchar *message,
GimpObject *display)
gimp_plug_in_progress_start (GimpPlugIn *plug_in,
const gchar *message,
GimpObject *display)
{
PlugInProcFrame *proc_frame;
GimpPlugInProcFrame *proc_frame;
g_return_if_fail (plug_in != NULL);
g_return_if_fail (GIMP_IS_PLUG_IN (plug_in));
g_return_if_fail (display == NULL || GIMP_IS_OBJECT (display));
proc_frame = plug_in_get_proc_frame (plug_in);
proc_frame = gimp_plug_in_get_proc_frame (plug_in);
if (! proc_frame->progress)
{
@ -75,7 +75,7 @@ plug_in_progress_start (PlugIn *plug_in,
if (! proc_frame->progress_cancel_id)
proc_frame->progress_cancel_id =
g_signal_connect (proc_frame->progress, "cancel",
G_CALLBACK (plug_in_progress_cancel_callback),
G_CALLBACK (gimp_plug_in_progress_cancel_callback),
plug_in);
if (gimp_progress_is_active (proc_frame->progress))
@ -96,13 +96,13 @@ plug_in_progress_start (PlugIn *plug_in,
}
void
plug_in_progress_end (PlugIn *plug_in)
gimp_plug_in_progress_end (GimpPlugIn *plug_in)
{
PlugInProcFrame *proc_frame;
GimpPlugInProcFrame *proc_frame;
g_return_if_fail (plug_in != NULL);
g_return_if_fail (GIMP_IS_PLUG_IN (plug_in));
proc_frame = plug_in_get_proc_frame (plug_in);
proc_frame = gimp_plug_in_get_proc_frame (plug_in);
if (proc_frame->progress)
{
@ -126,34 +126,34 @@ plug_in_progress_end (PlugIn *plug_in)
}
void
plug_in_progress_set_text (PlugIn *plug_in,
const gchar *message)
gimp_plug_in_progress_set_text (GimpPlugIn *plug_in,
const gchar *message)
{
PlugInProcFrame *proc_frame;
GimpPlugInProcFrame *proc_frame;
g_return_if_fail (plug_in != NULL);
g_return_if_fail (GIMP_IS_PLUG_IN (plug_in));
proc_frame = plug_in_get_proc_frame (plug_in);
proc_frame = gimp_plug_in_get_proc_frame (plug_in);
if (proc_frame->progress)
gimp_progress_set_text (proc_frame->progress, message);
}
void
plug_in_progress_set_value (PlugIn *plug_in,
gdouble percentage)
gimp_plug_in_progress_set_value (GimpPlugIn *plug_in,
gdouble percentage)
{
PlugInProcFrame *proc_frame;
GimpPlugInProcFrame *proc_frame;
g_return_if_fail (plug_in != NULL);
g_return_if_fail (GIMP_IS_PLUG_IN (plug_in));
proc_frame = plug_in_get_proc_frame (plug_in);
proc_frame = gimp_plug_in_get_proc_frame (plug_in);
if (! proc_frame->progress ||
! gimp_progress_is_active (proc_frame->progress) ||
! proc_frame->progress_cancel_id)
{
plug_in_progress_start (plug_in, NULL, NULL);
gimp_plug_in_progress_start (plug_in, NULL, NULL);
}
if (proc_frame->progress && gimp_progress_is_active (proc_frame->progress))
@ -161,19 +161,19 @@ plug_in_progress_set_value (PlugIn *plug_in,
}
void
plug_in_progress_pulse (PlugIn *plug_in)
gimp_plug_in_progress_pulse (GimpPlugIn *plug_in)
{
PlugInProcFrame *proc_frame;
GimpPlugInProcFrame *proc_frame;
g_return_if_fail (plug_in != NULL);
g_return_if_fail (GIMP_IS_PLUG_IN (plug_in));
proc_frame = plug_in_get_proc_frame (plug_in);
proc_frame = gimp_plug_in_get_proc_frame (plug_in);
if (! proc_frame->progress ||
! gimp_progress_is_active (proc_frame->progress) ||
! proc_frame->progress_cancel_id)
{
plug_in_progress_start (plug_in, NULL, NULL);
gimp_plug_in_progress_start (plug_in, NULL, NULL);
}
if (proc_frame->progress && gimp_progress_is_active (proc_frame->progress))
@ -181,13 +181,13 @@ plug_in_progress_pulse (PlugIn *plug_in)
}
guint32
plug_in_progress_get_window (PlugIn *plug_in)
gimp_plug_in_progress_get_window (GimpPlugIn *plug_in)
{
PlugInProcFrame *proc_frame;
GimpPlugInProcFrame *proc_frame;
g_return_val_if_fail (plug_in != NULL, 0);
g_return_val_if_fail (GIMP_IS_PLUG_IN (plug_in), 0);
proc_frame = plug_in_get_proc_frame (plug_in);
proc_frame = gimp_plug_in_get_proc_frame (plug_in);
if (proc_frame->progress)
return gimp_progress_get_window (proc_frame->progress);
@ -196,13 +196,13 @@ plug_in_progress_get_window (PlugIn *plug_in)
}
gboolean
plug_in_progress_install (PlugIn *plug_in,
const gchar *progress_callback)
gimp_plug_in_progress_install (GimpPlugIn *plug_in,
const gchar *progress_callback)
{
PlugInProcFrame *proc_frame;
GimpProcedure *procedure;
GimpPlugInProcFrame *proc_frame;
GimpProcedure *procedure;
g_return_val_if_fail (plug_in != NULL, FALSE);
g_return_val_if_fail (GIMP_IS_PLUG_IN (plug_in), FALSE);
g_return_val_if_fail (progress_callback != NULL, FALSE);
procedure = gimp_pdb_lookup_procedure (plug_in->manager->gimp->pdb,
@ -218,11 +218,11 @@ plug_in_progress_install (PlugIn *plug_in,
return FALSE;
}
proc_frame = plug_in_get_proc_frame (plug_in);
proc_frame = gimp_plug_in_get_proc_frame (plug_in);
if (proc_frame->progress)
{
plug_in_progress_end (plug_in);
gimp_plug_in_progress_end (plug_in);
if (proc_frame->progress)
{
@ -241,19 +241,19 @@ plug_in_progress_install (PlugIn *plug_in,
}
gboolean
plug_in_progress_uninstall (PlugIn *plug_in,
const gchar *progress_callback)
gimp_plug_in_progress_uninstall (GimpPlugIn *plug_in,
const gchar *progress_callback)
{
PlugInProcFrame *proc_frame;
GimpPlugInProcFrame *proc_frame;
g_return_val_if_fail (plug_in != NULL, FALSE);
g_return_val_if_fail (GIMP_IS_PLUG_IN (plug_in), FALSE);
g_return_val_if_fail (progress_callback != NULL, FALSE);
proc_frame = plug_in_get_proc_frame (plug_in);
proc_frame = gimp_plug_in_get_proc_frame (plug_in);
if (GIMP_IS_PDB_PROGRESS (proc_frame->progress))
{
plug_in_progress_end (plug_in);
gimp_plug_in_progress_end (plug_in);
g_object_unref (proc_frame->progress);
proc_frame->progress = NULL;
@ -264,28 +264,28 @@ plug_in_progress_uninstall (PlugIn *plug_in,
}
gboolean
plug_in_progress_cancel (PlugIn *plug_in,
const gchar *progress_callback)
gimp_plug_in_progress_cancel (GimpPlugIn *plug_in,
const gchar *progress_callback)
{
g_return_val_if_fail (plug_in != NULL, FALSE);
g_return_val_if_fail (GIMP_IS_PLUG_IN (plug_in), FALSE);
g_return_val_if_fail (progress_callback != NULL, FALSE);
return FALSE;
}
void
plug_in_progress_message (PlugIn *plug_in,
const gchar *message)
gimp_plug_in_progress_message (GimpPlugIn *plug_in,
const gchar *message)
{
PlugInProcFrame *proc_frame;
gchar *domain;
GimpPlugInProcFrame *proc_frame;
gchar *domain;
g_return_if_fail (plug_in != NULL);
g_return_if_fail (GIMP_IS_PLUG_IN (plug_in));
g_return_if_fail (message != NULL);
proc_frame = plug_in_get_proc_frame (plug_in);
proc_frame = gimp_plug_in_get_proc_frame (plug_in);
domain = plug_in_get_undo_desc (plug_in);
domain = gimp_plug_in_get_undo_desc (plug_in);
if (proc_frame->progress)
{
@ -304,11 +304,11 @@ plug_in_progress_message (PlugIn *plug_in,
/* private functions */
static void
plug_in_progress_cancel_callback (GimpProgress *progress,
PlugIn *plug_in)
gimp_plug_in_progress_cancel_callback (GimpProgress *progress,
GimpPlugIn *plug_in)
{
PlugInProcFrame *proc_frame = &plug_in->main_proc_frame;
GList *list;
GimpPlugInProcFrame *proc_frame = &plug_in->main_proc_frame;
GList *list;
if (proc_frame->main_loop)
{
@ -331,6 +331,5 @@ plug_in_progress_cancel_callback (GimpProgress *progress,
}
}
plug_in_close (plug_in, TRUE);
plug_in_unref (plug_in);
gimp_plug_in_close (plug_in, TRUE);
}

View File

@ -1,7 +1,7 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* plug-in-progress.h
* gimpplugin-progress.h
*
* 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
@ -18,30 +18,30 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __PLUG_IN_PROGRESS_H__
#define __PLUG_IN_PROGRESS_H__
#ifndef __GIMP_PLUG_IN_PROGRESS_H__
#define __GIMP_PLUG_IN_PROGRESS_H__
void plug_in_progress_start (PlugIn *plug_in,
const gchar *message,
GimpObject *display);
void plug_in_progress_end (PlugIn *plug_in);
void plug_in_progress_set_text (PlugIn *plug_in,
const gchar *message);
void plug_in_progress_set_value (PlugIn *plug_in,
gdouble percentage);
void plug_in_progress_pulse (PlugIn *plug_in);
guint32 plug_in_progress_get_window (PlugIn *plug_in);
void gimp_plug_in_progress_start (GimpPlugIn *plug_in,
const gchar *message,
GimpObject *display);
void gimp_plug_in_progress_end (GimpPlugIn *plug_in);
void gimp_plug_in_progress_set_text (GimpPlugIn *plug_in,
const gchar *message);
void gimp_plug_in_progress_set_value (GimpPlugIn *plug_in,
gdouble percentage);
void gimp_plug_in_progress_pulse (GimpPlugIn *plug_in);
guint32 gimp_plug_in_progress_get_window (GimpPlugIn *plug_in);
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);
gboolean gimp_plug_in_progress_install (GimpPlugIn *plug_in,
const gchar *progress_callback);
gboolean gimp_plug_in_progress_uninstall (GimpPlugIn *plug_in,
const gchar *progress_callback);
gboolean gimp_plug_in_progress_cancel (GimpPlugIn *plug_in,
const gchar *progress_callback);
void plug_in_progress_message (PlugIn *plug_in,
const gchar *message);
void gimp_plug_in_progress_message (GimpPlugIn *plug_in,
const gchar *message);
#endif /* __PLUG_IN_PROGRESS_H__ */
#endif /* __GIMP_PLUG_IN_PROGRESS_H__ */

View File

@ -1,7 +1,7 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* plug-in.c
* gimpplugin.c
*
* 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
@ -56,10 +56,10 @@
#endif
#ifdef G_WITH_CYGWIN
#define O_TEXT 0x0100 /* text file */
#define _O_TEXT 0x0100 /* text file */
#define O_BINARY 0x0200 /* binary file */
#define _O_BINARY 0x0200 /* binary file */
#define O_TEXT 0x0100 /* text file */
#define _O_TEXT 0x0100 /* text file */
#define O_BINARY 0x0200 /* binary file */
#define _O_BINARY 0x0200 /* binary file */
#endif
#endif /* G_OS_WIN32 || G_WITH_CYGWIN */
@ -78,98 +78,67 @@
#include "gimpenvirontable.h"
#include "gimpinterpreterdb.h"
#include "gimpplugin.h"
#include "gimpplugin-message.h"
#include "gimpplugin-progress.h"
#include "gimpplugindebug.h"
#include "gimppluginmanager.h"
#include "gimppluginmanager-locale-domain.h"
#include "plug-in.h"
#include "plug-in-def.h"
#include "plug-in-message.h"
#include "plug-in-params.h"
#include "plug-in-progress.h"
#include "gimp-intl.h"
/* local funcion prototypes */
static void gimp_plug_in_finalize (GObject *object);
static gboolean plug_in_write (GIOChannel *channel,
const guint8 *buf,
gulong count,
gpointer data);
static gboolean plug_in_flush (GIOChannel *channel,
gpointer data);
static gboolean gimp_plug_in_write (GIOChannel *channel,
const guint8 *buf,
gulong count,
gpointer data);
static gboolean gimp_plug_in_flush (GIOChannel *channel,
gpointer data);
static gboolean plug_in_recv_message (GIOChannel *channel,
GIOCondition cond,
gpointer data);
static gboolean gimp_plug_in_recv_message (GIOChannel *channel,
GIOCondition cond,
gpointer data);
#if !defined(G_OS_WIN32) && !defined (G_WITH_CYGWIN)
static void plug_in_prep_for_exec (gpointer data);
static void gimp_plug_in_prep_for_exec (gpointer data);
#else
#define gimp_plug_in_prep_for_exec NULL
#endif
void
plug_in_init (GimpPlugInManager *manager)
G_DEFINE_TYPE (GimpPlugIn, gimp_plug_in, GIMP_TYPE_OBJECT);
#define parent_class gimp_plug_in_parent_class
static void
gimp_plug_in_class_init (GimpPlugInClass *klass)
{
g_return_if_fail (GIMP_IS_PLUG_IN_MANAGER (manager));
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->finalize = gimp_plug_in_finalize;
/* initialize the gimp protocol library and set the read and
* write handlers.
*/
gp_init ();
gimp_wire_set_writer (plug_in_write);
gimp_wire_set_flusher (plug_in_flush);
gimp_wire_set_writer (gimp_plug_in_write);
gimp_wire_set_flusher (gimp_plug_in_flush);
}
void
plug_in_exit (GimpPlugInManager *manager)
static void
gimp_plug_in_init (GimpPlugIn *plug_in)
{
GSList *list;
g_return_if_fail (GIMP_IS_PLUG_IN_MANAGER (manager));
list = manager->open_plug_ins;
while (list)
{
PlugIn *plug_in = list->data;
list = list->next;
if (plug_in->open)
plug_in_close (plug_in, TRUE);
plug_in_unref (plug_in);
}
}
PlugIn *
plug_in_new (GimpPlugInManager *manager,
GimpContext *context,
GimpProgress *progress,
GimpProcedure *procedure,
const gchar *prog)
{
PlugIn *plug_in;
g_return_val_if_fail (GIMP_IS_PLUG_IN_MANAGER (manager), NULL);
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
g_return_val_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress), NULL);
g_return_val_if_fail (prog != NULL, NULL);
g_return_val_if_fail (g_path_is_absolute (prog), NULL);
plug_in = g_new0 (PlugIn, 1);
plug_in->manager = manager;
plug_in->ref_count = 1;
plug_in->open = FALSE;
plug_in->call_mode = GIMP_PLUG_IN_CALL_NONE;
plug_in->pid = 0;
plug_in->name = g_path_get_basename (prog);
plug_in->prog = g_strdup (prog);
plug_in->name = NULL;
plug_in->prog = NULL;
plug_in->my_read = NULL;
plug_in->my_write = NULL;
@ -183,51 +152,61 @@ plug_in_new (GimpPlugInManager *manager,
plug_in->ext_main_loop = NULL;
plug_in_proc_frame_init (&plug_in->main_proc_frame,
context, progress, procedure);
plug_in->temp_proc_frames = NULL;
plug_in->plug_in_def = NULL;
}
GimpPlugIn *
gimp_plug_in_new (GimpPlugInManager *manager,
GimpContext *context,
GimpProgress *progress,
GimpPlugInProcedure *procedure,
const gchar *prog)
{
GimpPlugIn *plug_in;
g_return_val_if_fail (GIMP_IS_PLUG_IN_MANAGER (manager), NULL);
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
g_return_val_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress), NULL);
g_return_val_if_fail (procedure == NULL ||
GIMP_IS_PLUG_IN_PROCEDURE (procedure), NULL);
g_return_val_if_fail (prog != NULL, NULL);
g_return_val_if_fail (g_path_is_absolute (prog), NULL);
plug_in = g_object_new (GIMP_TYPE_PLUG_IN, NULL);
plug_in->manager = manager;
plug_in->name = g_path_get_basename (prog);
plug_in->prog = g_strdup (prog);
gimp_plug_in_proc_frame_init (&plug_in->main_proc_frame,
context, progress, procedure);
return plug_in;
}
void
plug_in_ref (PlugIn *plug_in)
static void
gimp_plug_in_finalize (GObject *object)
{
g_return_if_fail (plug_in != NULL);
GimpPlugIn *plug_in = GIMP_PLUG_IN (object);
plug_in->ref_count++;
}
g_printerr ("%s (%s)\n", G_STRFUNC, plug_in->name);
void
plug_in_unref (PlugIn *plug_in)
{
g_return_if_fail (plug_in != NULL);
g_free (plug_in->name);
g_free (plug_in->prog);
plug_in->ref_count--;
gimp_plug_in_proc_frame_dispose (&plug_in->main_proc_frame, plug_in);
if (plug_in->ref_count < 1)
{
if (plug_in->open)
plug_in_close (plug_in, TRUE);
g_free (plug_in->name);
g_free (plug_in->prog);
plug_in_proc_frame_dispose (&plug_in->main_proc_frame, plug_in);
g_free (plug_in);
}
G_OBJECT_CLASS (parent_class)->finalize (object);
}
#if !defined(G_OS_WIN32) && !defined (G_WITH_CYGWIN)
static void
plug_in_prep_for_exec (gpointer data)
gimp_plug_in_prep_for_exec (gpointer data)
{
PlugIn *plug_in = data;
GimpPlugIn *plug_in = data;
g_io_channel_unref (plug_in->my_read);
plug_in->my_read = NULL;
@ -236,16 +215,12 @@ plug_in_prep_for_exec (gpointer data)
plug_in->my_write = NULL;
}
#else
#define plug_in_prep_for_exec NULL
#endif
gboolean
plug_in_open (PlugIn *plug_in,
GimpPlugInCallMode call_mode,
gboolean synchronous)
gimp_plug_in_open (GimpPlugIn *plug_in,
GimpPlugInCallMode call_mode,
gboolean synchronous)
{
gint my_read[2];
gint my_write[2];
@ -260,7 +235,7 @@ plug_in_open (PlugIn *plug_in,
guint debug_flag;
guint spawn_flags;
g_return_val_if_fail (plug_in != NULL, FALSE);
g_return_val_if_fail (GIMP_IS_PLUG_IN (plug_in), FALSE);
g_return_val_if_fail (plug_in->call_mode == GIMP_PLUG_IN_CALL_NONE, FALSE);
/* Open two pipes. (Bidirectional communication).
@ -377,7 +352,7 @@ plug_in_open (PlugIn *plug_in,
* can later use it to kill the filter if necessary.
*/
if (! g_spawn_async (NULL, argv, envp, spawn_flags,
plug_in_prep_for_exec, plug_in,
gimp_plug_in_prep_for_exec, plug_in,
&plug_in->pid,
&error))
{
@ -403,7 +378,7 @@ plug_in_open (PlugIn *plug_in,
G_IO_IN | G_IO_PRI | G_IO_ERR | G_IO_HUP);
g_source_set_callback (source,
(GSourceFunc) plug_in_recv_message, plug_in,
(GSourceFunc) gimp_plug_in_recv_message, plug_in,
NULL);
g_source_set_can_recurse (source, TRUE);
@ -415,10 +390,12 @@ plug_in_open (PlugIn *plug_in,
g_slist_prepend (plug_in->manager->open_plug_ins, plug_in);
}
g_object_ref (plug_in);
plug_in->open = TRUE;
plug_in->call_mode = call_mode;
cleanup:
cleanup:
if (debug)
g_free (argv);
@ -433,16 +410,15 @@ cleanup:
}
void
plug_in_close (PlugIn *plug_in,
gboolean kill_it)
gimp_plug_in_close (GimpPlugIn *plug_in,
gboolean kill_it)
{
GList *list;
g_return_if_fail (plug_in != NULL);
g_return_if_fail (GIMP_IS_PLUG_IN (plug_in));
g_return_if_fail (plug_in->open == TRUE);
if (! plug_in->open)
return;
g_printerr ("%s (%s)\n", G_STRFUNC, plug_in->name);
plug_in->open = FALSE;
@ -547,7 +523,7 @@ plug_in_close (PlugIn *plug_in,
for (list = plug_in->temp_proc_frames; list; list = g_list_next (list))
{
PlugInProcFrame *proc_frame = list->data;
GimpPlugInProcFrame *proc_frame = list->data;
#ifdef GIMP_UNSTABLE
g_printerr ("plug_in_close: plug-in aborted before sending its "
@ -572,8 +548,6 @@ plug_in_close (PlugIn *plug_in,
g_main_loop_quit (plug_in->main_proc_frame.main_loop);
}
plug_in_proc_frame_dispose (&plug_in->main_proc_frame, plug_in);
if (plug_in->ext_main_loop &&
g_main_loop_is_running (plug_in->ext_main_loop))
{
@ -587,22 +561,24 @@ plug_in_close (PlugIn *plug_in,
/* Unregister any temporary procedures. */
while (plug_in->temp_procedures)
plug_in_remove_temp_proc (plug_in, plug_in->temp_procedures->data);
gimp_plug_in_remove_temp_proc (plug_in, plug_in->temp_procedures->data);
/* Close any dialogs that this plugin might have opened */
gimp_pdb_dialogs_check (plug_in->manager->gimp);
plug_in->manager->open_plug_ins =
g_slist_remove (plug_in->manager->open_plug_ins, plug_in);
g_object_unref (plug_in);
}
static gboolean
plug_in_recv_message (GIOChannel *channel,
GIOCondition cond,
gpointer data)
gimp_plug_in_recv_message (GIOChannel *channel,
GIOCondition cond,
gpointer data)
{
PlugIn *plug_in = data;
gboolean got_message = FALSE;
GimpPlugIn *plug_in = data;
gboolean got_message = FALSE;
#ifdef G_OS_WIN32
/* Workaround for GLib bug #137968: sometimes we are called for no
@ -615,6 +591,8 @@ plug_in_recv_message (GIOChannel *channel,
if (plug_in->my_read == NULL)
return TRUE;
g_object_ref (plug_in);
if (cond & (G_IO_IN | G_IO_PRI))
{
GimpWireMessage msg;
@ -623,11 +601,11 @@ plug_in_recv_message (GIOChannel *channel,
if (! gimp_wire_read_msg (plug_in->my_read, &msg, plug_in))
{
plug_in_close (plug_in, TRUE);
gimp_plug_in_close (plug_in, TRUE);
}
else
{
plug_in_handle_message (plug_in, &msg);
gimp_plug_in_handle_message (plug_in, &msg);
gimp_wire_destroy (&msg);
got_message = TRUE;
}
@ -636,9 +614,7 @@ plug_in_recv_message (GIOChannel *channel,
if (cond & (G_IO_ERR | G_IO_HUP))
{
if (plug_in->open)
{
plug_in_close (plug_in, TRUE);
}
gimp_plug_in_close (plug_in, TRUE);
}
if (! got_message)
@ -649,20 +625,19 @@ plug_in_recv_message (GIOChannel *channel,
gimp_filename_to_utf8 (plug_in->name),
gimp_filename_to_utf8 (plug_in->prog));
if (! plug_in->open)
plug_in_unref (plug_in);
g_object_unref (plug_in);
return TRUE;
}
static gboolean
plug_in_write (GIOChannel *channel,
const guint8 *buf,
gulong count,
gpointer data)
gimp_plug_in_write (GIOChannel *channel,
const guint8 *buf,
gulong count,
gpointer data)
{
PlugIn *plug_in = data;
gulong bytes;
GimpPlugIn *plug_in = data;
gulong bytes;
while (count > 0)
{
@ -691,10 +666,10 @@ plug_in_write (GIOChannel *channel,
}
static gboolean
plug_in_flush (GIOChannel *channel,
gpointer data)
gimp_plug_in_flush (GIOChannel *channel,
gpointer data)
{
PlugIn *plug_in = data;
GimpPlugIn *plug_in = data;
if (plug_in->write_buffer_index > 0)
{
@ -744,10 +719,10 @@ plug_in_flush (GIOChannel *channel,
return TRUE;
}
PlugInProcFrame *
plug_in_get_proc_frame (PlugIn *plug_in)
GimpPlugInProcFrame *
gimp_plug_in_get_proc_frame (GimpPlugIn *plug_in)
{
g_return_val_if_fail (plug_in != NULL, NULL);
g_return_val_if_fail (GIMP_IS_PLUG_IN (plug_in), NULL);
if (plug_in->temp_proc_frames)
return plug_in->temp_proc_frames->data;
@ -755,20 +730,20 @@ plug_in_get_proc_frame (PlugIn *plug_in)
return &plug_in->main_proc_frame;
}
PlugInProcFrame *
plug_in_proc_frame_push (PlugIn *plug_in,
GimpContext *context,
GimpProgress *progress,
GimpProcedure *procedure)
GimpPlugInProcFrame *
gimp_plug_in_proc_frame_push (GimpPlugIn *plug_in,
GimpContext *context,
GimpProgress *progress,
GimpTemporaryProcedure *procedure)
{
PlugInProcFrame *proc_frame;
GimpPlugInProcFrame *proc_frame;
g_return_val_if_fail (plug_in != NULL, NULL);
g_return_val_if_fail (GIMP_IS_PLUG_IN (plug_in), NULL);
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
g_return_val_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress), NULL);
g_return_val_if_fail (GIMP_IS_PROCEDURE (procedure), NULL);
g_return_val_if_fail (GIMP_IS_TEMPORARY_PROCEDURE (procedure), NULL);
proc_frame = plug_in_proc_frame_new (context, progress, procedure);
proc_frame = gimp_plug_in_proc_frame_new (context, progress, procedure);
plug_in->temp_proc_frames = g_list_prepend (plug_in->temp_proc_frames,
proc_frame);
@ -777,30 +752,30 @@ plug_in_proc_frame_push (PlugIn *plug_in,
}
void
plug_in_proc_frame_pop (PlugIn *plug_in)
gimp_plug_in_proc_frame_pop (GimpPlugIn *plug_in)
{
PlugInProcFrame *proc_frame;
GimpPlugInProcFrame *proc_frame;
g_return_if_fail (plug_in != NULL);
g_return_if_fail (GIMP_IS_PLUG_IN (plug_in));
g_return_if_fail (plug_in->temp_proc_frames != NULL);
proc_frame = (PlugInProcFrame *) plug_in->temp_proc_frames->data;
proc_frame = (GimpPlugInProcFrame *) plug_in->temp_proc_frames->data;
plug_in_proc_frame_unref (proc_frame, plug_in);
gimp_plug_in_proc_frame_unref (proc_frame, plug_in);
plug_in->temp_proc_frames = g_list_remove (plug_in->temp_proc_frames,
proc_frame);
}
void
plug_in_main_loop (PlugIn *plug_in)
gimp_plug_in_main_loop (GimpPlugIn *plug_in)
{
PlugInProcFrame *proc_frame;
GimpPlugInProcFrame *proc_frame;
g_return_if_fail (plug_in != NULL);
g_return_if_fail (GIMP_IS_PLUG_IN (plug_in));
g_return_if_fail (plug_in->temp_proc_frames != NULL);
proc_frame = (PlugInProcFrame *) plug_in->temp_proc_frames->data;
proc_frame = (GimpPlugInProcFrame *) plug_in->temp_proc_frames->data;
g_return_if_fail (proc_frame->main_loop == NULL);
@ -815,14 +790,14 @@ plug_in_main_loop (PlugIn *plug_in)
}
void
plug_in_main_loop_quit (PlugIn *plug_in)
gimp_plug_in_main_loop_quit (GimpPlugIn *plug_in)
{
PlugInProcFrame *proc_frame;
GimpPlugInProcFrame *proc_frame;
g_return_if_fail (plug_in != NULL);
g_return_if_fail (GIMP_IS_PLUG_IN (plug_in));
g_return_if_fail (plug_in->temp_proc_frames != NULL);
proc_frame = (PlugInProcFrame *) plug_in->temp_proc_frames->data;
proc_frame = (GimpPlugInProcFrame *) plug_in->temp_proc_frames->data;
g_return_if_fail (proc_frame->main_loop != NULL);
@ -830,15 +805,15 @@ plug_in_main_loop_quit (PlugIn *plug_in)
}
gchar *
plug_in_get_undo_desc (PlugIn *plug_in)
gimp_plug_in_get_undo_desc (GimpPlugIn *plug_in)
{
PlugInProcFrame *proc_frame = NULL;
GimpPlugInProcFrame *proc_frame = NULL;
GimpPlugInProcedure *proc = NULL;
gchar *undo_desc = NULL;
g_return_val_if_fail (plug_in != NULL, NULL);
g_return_val_if_fail (GIMP_IS_PLUG_IN (plug_in), NULL);
proc_frame = plug_in_get_proc_frame (plug_in);
proc_frame = gimp_plug_in_get_proc_frame (plug_in);
if (proc_frame)
proc = GIMP_PLUG_IN_PROCEDURE (proc_frame->procedure);
@ -861,14 +836,14 @@ plug_in_get_undo_desc (PlugIn *plug_in)
/* called from the PDB (gimp_plugin_menu_register) */
gboolean
plug_in_menu_register (PlugIn *plug_in,
const gchar *proc_name,
const gchar *menu_path)
gimp_plug_in_menu_register (GimpPlugIn *plug_in,
const gchar *proc_name,
const gchar *menu_path)
{
GimpPlugInProcedure *proc = NULL;
GError *error = NULL;
g_return_val_if_fail (plug_in != NULL, FALSE);
g_return_val_if_fail (GIMP_IS_PLUG_IN (plug_in), FALSE);
g_return_val_if_fail (proc_name != NULL, FALSE);
g_return_val_if_fail (menu_path != NULL, FALSE);
@ -936,10 +911,10 @@ plug_in_menu_register (PlugIn *plug_in,
}
void
plug_in_add_temp_proc (PlugIn *plug_in,
GimpTemporaryProcedure *proc)
gimp_plug_in_add_temp_proc (GimpPlugIn *plug_in,
GimpTemporaryProcedure *proc)
{
g_return_if_fail (plug_in != NULL);
g_return_if_fail (GIMP_IS_PLUG_IN (plug_in));
g_return_if_fail (GIMP_IS_TEMPORARY_PROCEDURE (proc));
plug_in->temp_procedures = g_slist_prepend (plug_in->temp_procedures,
@ -948,10 +923,10 @@ plug_in_add_temp_proc (PlugIn *plug_in,
}
void
plug_in_remove_temp_proc (PlugIn *plug_in,
GimpTemporaryProcedure *proc)
gimp_plug_in_remove_temp_proc (GimpPlugIn *plug_in,
GimpTemporaryProcedure *proc)
{
g_return_if_fail (plug_in != NULL);
g_return_if_fail (GIMP_IS_PLUG_IN (plug_in));
g_return_if_fail (GIMP_IS_TEMPORARY_PROCEDURE (proc));
plug_in->temp_procedures = g_slist_remove (plug_in->temp_procedures,

View File

@ -1,7 +1,7 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* plug-in.h
* gimpplugin.h
*
* 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
@ -18,91 +18,106 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __PLUG_IN_H__
#define __PLUG_IN_H__
#ifndef __GIMP_PLUG_IN_H__
#define __GIMP_PLUG_IN_H__
#include "plug-in-proc-frame.h"
#include "core/gimpobject.h"
#include "gimppluginprocframe.h"
#define WRITE_BUFFER_SIZE 512
struct _PlugIn
#define GIMP_TYPE_PLUG_IN (gimp_plug_in_get_type ())
#define GIMP_PLUG_IN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_PLUG_IN, GimpPlugIn))
#define GIMP_PLUG_IN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_PLUG_IN, GimpPlugInClass))
#define GIMP_IS_PLUG_IN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_PLUG_IN))
#define GIMP_IS_PLUG_IN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_PLUG_IN))
typedef struct _GimpPlugInClass GimpPlugInClass;
struct _GimpPlugIn
{
GimpPlugInManager *manager;
GimpObject parent_instance;
gint ref_count;
GimpPlugInManager *manager;
guint open : 1; /* Is the plug-in open? */
GimpPlugInCallMode call_mode;
gint ref_count;
GPid pid; /* Plug-in's process id */
guint open : 1; /* Is the plug-in open? */
GimpPlugInCallMode call_mode;
gchar *name; /* Plug-in's name */
gchar *prog; /* Plug-in's full path name */
GPid pid; /* Plug-in's process id */
GIOChannel *my_read; /* App's read and write channels */
GIOChannel *my_write;
GIOChannel *his_read; /* Plug-in's read and write channels */
GIOChannel *his_write;
gchar *name; /* Plug-in's name */
gchar *prog; /* Plug-in's full path name */
guint input_id; /* Id of input proc */
GIOChannel *my_read; /* App's read and write channels */
GIOChannel *my_write;
GIOChannel *his_read; /* Plug-in's read and write channels */
GIOChannel *his_write;
gchar write_buffer[WRITE_BUFFER_SIZE]; /* Buffer for writing */
gint write_buffer_index; /* Buffer index */
guint input_id; /* Id of input proc */
GSList *temp_procedures; /* Temporary procedures */
gchar write_buffer[WRITE_BUFFER_SIZE]; /* Buffer for writing */
gint write_buffer_index; /* Buffer index */
GMainLoop *ext_main_loop; /* for waiting for extension_ack */
GSList *temp_procedures; /* Temporary procedures */
PlugInProcFrame main_proc_frame;
GMainLoop *ext_main_loop; /* for waiting for extension_ack */
GList *temp_proc_frames;
GimpPlugInProcFrame main_proc_frame;
PlugInDef *plug_in_def; /* Valid during query() and init() */
GList *temp_proc_frames;
PlugInDef *plug_in_def; /* Valid during query() and init() */
};
struct _GimpPlugInClass
{
GimpObjectClass parent_class;
};
void plug_in_init (GimpPlugInManager *manager);
void plug_in_exit (GimpPlugInManager *manager);
GType gimp_plug_in_get_type (void) G_GNUC_CONST;
PlugIn * plug_in_new (GimpPlugInManager *manager,
GimpContext *context,
GimpProgress *progress,
GimpProcedure *procedure,
const gchar *prog);
GimpPlugIn * gimp_plug_in_new (GimpPlugInManager *manager,
GimpContext *context,
GimpProgress *progress,
GimpPlugInProcedure *procedure,
const gchar *prog);
void plug_in_ref (PlugIn *plug_in);
void plug_in_unref (PlugIn *plug_in);
gboolean gimp_plug_in_open (GimpPlugIn *plug_in,
GimpPlugInCallMode call_mode,
gboolean synchronous);
void gimp_plug_in_close (GimpPlugIn *plug_in,
gboolean kill_it);
gboolean plug_in_open (PlugIn *plug_in,
GimpPlugInCallMode call_mode,
gboolean synchronous);
void plug_in_close (PlugIn *plug_in,
gboolean kill_it);
GimpPlugInProcFrame *
gimp_plug_in_get_proc_frame (GimpPlugIn *plug_in);
PlugInProcFrame * plug_in_get_proc_frame (PlugIn *plug_in);
GimpPlugInProcFrame *
gimp_plug_in_proc_frame_push (GimpPlugIn *plug_in,
GimpContext *context,
GimpProgress *progress,
GimpTemporaryProcedure *procedure);
void gimp_plug_in_proc_frame_pop (GimpPlugIn *plug_in);
PlugInProcFrame * plug_in_proc_frame_push (PlugIn *plug_in,
GimpContext *context,
GimpProgress *progress,
GimpProcedure *procedure);
void plug_in_proc_frame_pop (PlugIn *plug_in);
void gimp_plug_in_main_loop (GimpPlugIn *plug_in);
void gimp_plug_in_main_loop_quit (GimpPlugIn *plug_in);
void plug_in_main_loop (PlugIn *plug_in);
void plug_in_main_loop_quit (PlugIn *plug_in);
gchar * gimp_plug_in_get_undo_desc (GimpPlugIn *plug_in);
gchar * plug_in_get_undo_desc (PlugIn *plug_in);
gboolean gimp_plug_in_menu_register (GimpPlugIn *plug_in,
const gchar *proc_name,
const gchar *menu_path);
gboolean plug_in_menu_register (PlugIn *plug_in,
const gchar *proc_name,
const gchar *menu_path);
void plug_in_add_temp_proc (PlugIn *plug_in,
GimpTemporaryProcedure *proc);
void plug_in_remove_temp_proc (PlugIn *plug_in,
GimpTemporaryProcedure *proc);
void gimp_plug_in_add_temp_proc (GimpPlugIn *plug_in,
GimpTemporaryProcedure *procedure);
void gimp_plug_in_remove_temp_proc (GimpPlugIn *plug_in,
GimpTemporaryProcedure *procedure);
#endif /* __PLUG_IN_H__ */
#endif /* __GIMP_PLUG_IN_H__ */

View File

@ -38,12 +38,12 @@
#include "pdb/gimptemporaryprocedure.h"
#include "gimpplugin.h"
#include "gimpplugin-message.h"
#include "gimppluginmanager.h"
#define __YES_I_NEED_GIMP_PLUG_IN_MANAGER_CALL__
#include "gimppluginmanager-call.h"
#include "plug-in.h"
#include "plug-in-def.h"
#include "plug-in-message.h"
#include "plug-in-params.h"
#include "gimp-intl.h"
@ -56,19 +56,20 @@ gimp_plug_in_manager_call_query (GimpPlugInManager *manager,
GimpContext *context,
PlugInDef *plug_in_def)
{
PlugIn *plug_in;
GimpPlugIn *plug_in;
g_return_if_fail (GIMP_IS_PLUG_IN_MANAGER (manager));
g_return_if_fail (GIMP_IS_CONTEXT (context));
g_return_if_fail (plug_in_def != NULL);
plug_in = plug_in_new (manager, context, NULL, NULL, plug_in_def->prog);
plug_in = gimp_plug_in_new (manager, context, NULL,
NULL, plug_in_def->prog);
if (plug_in)
{
plug_in->plug_in_def = plug_in_def;
if (plug_in_open (plug_in, GIMP_PLUG_IN_CALL_QUERY, TRUE))
if (gimp_plug_in_open (plug_in, GIMP_PLUG_IN_CALL_QUERY, TRUE))
{
while (plug_in->open)
{
@ -76,17 +77,17 @@ gimp_plug_in_manager_call_query (GimpPlugInManager *manager,
if (! gimp_wire_read_msg (plug_in->my_read, &msg, plug_in))
{
plug_in_close (plug_in, TRUE);
gimp_plug_in_close (plug_in, TRUE);
}
else
{
plug_in_handle_message (plug_in, &msg);
gimp_plug_in_handle_message (plug_in, &msg);
gimp_wire_destroy (&msg);
}
}
}
plug_in_unref (plug_in);
g_object_unref (plug_in);
}
}
@ -95,19 +96,20 @@ gimp_plug_in_manager_call_init (GimpPlugInManager *manager,
GimpContext *context,
PlugInDef *plug_in_def)
{
PlugIn *plug_in;
GimpPlugIn *plug_in;
g_return_if_fail (GIMP_IS_PLUG_IN_MANAGER (manager));
g_return_if_fail (GIMP_IS_CONTEXT (context));
g_return_if_fail (plug_in_def != NULL);
plug_in = plug_in_new (manager, context, NULL, NULL, plug_in_def->prog);
plug_in = gimp_plug_in_new (manager, context, NULL,
NULL, plug_in_def->prog);
if (plug_in)
{
plug_in->plug_in_def = plug_in_def;
if (plug_in_open (plug_in, GIMP_PLUG_IN_CALL_INIT, TRUE))
if (gimp_plug_in_open (plug_in, GIMP_PLUG_IN_CALL_INIT, TRUE))
{
while (plug_in->open)
{
@ -115,17 +117,17 @@ gimp_plug_in_manager_call_init (GimpPlugInManager *manager,
if (! gimp_wire_read_msg (plug_in->my_read, &msg, plug_in))
{
plug_in_close (plug_in, TRUE);
gimp_plug_in_close (plug_in, TRUE);
}
else
{
plug_in_handle_message (plug_in, &msg);
gimp_plug_in_handle_message (plug_in, &msg);
gimp_wire_destroy (&msg);
}
}
}
plug_in_unref (plug_in);
g_object_unref (plug_in);
}
}
@ -140,7 +142,7 @@ gimp_plug_in_manager_call_run (GimpPlugInManager *manager,
gint display_ID)
{
GValueArray *return_vals = NULL;
PlugIn *plug_in;
GimpPlugIn *plug_in;
g_return_val_if_fail (GIMP_IS_PLUG_IN_MANAGER (manager), NULL);
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
@ -148,9 +150,9 @@ gimp_plug_in_manager_call_run (GimpPlugInManager *manager,
g_return_val_if_fail (GIMP_IS_PLUG_IN_PROCEDURE (procedure), NULL);
g_return_val_if_fail (args != NULL, NULL);
plug_in = plug_in_new (manager, context, progress,
GIMP_PROCEDURE (procedure),
procedure->prog);
plug_in = gimp_plug_in_new (manager, context, progress,
GIMP_PROCEDURE (procedure),
procedure->prog);
if (plug_in)
{
@ -161,9 +163,9 @@ gimp_plug_in_manager_call_run (GimpPlugInManager *manager,
GPProcRun proc_run;
gint monitor;
if (! plug_in_open (plug_in, GIMP_PLUG_IN_CALL_RUN, FALSE))
if (! gimp_plug_in_open (plug_in, GIMP_PLUG_IN_CALL_RUN, FALSE))
{
plug_in_unref (plug_in);
g_object_unref (plug_in);
goto done;
}
@ -204,14 +206,13 @@ gimp_plug_in_manager_call_run (GimpPlugInManager *manager,
return_vals =
gimp_procedure_get_return_values (GIMP_PROCEDURE (procedure), FALSE);
g_object_unref (plug_in);
goto done;
}
g_free (config.display_name);
g_free (proc_run.params);
plug_in_ref (plug_in);
/* If this is an extension,
* wait for an installation-confirmation message
*/
@ -223,7 +224,7 @@ gimp_plug_in_manager_call_run (GimpPlugInManager *manager,
g_main_loop_run (plug_in->ext_main_loop);
gimp_threads_enter (manager->gimp);
/* main_loop is quit in plug_in_handle_extension_ack() */
/* main_loop is quit in gimp_plug_in_handle_extension_ack() */
g_main_loop_unref (plug_in->ext_main_loop);
plug_in->ext_main_loop = NULL;
@ -234,7 +235,7 @@ gimp_plug_in_manager_call_run (GimpPlugInManager *manager,
*/
if (synchronous)
{
PlugInProcFrame *proc_frame = &plug_in->main_proc_frame;
GimpPlugInProcFrame *proc_frame = &plug_in->main_proc_frame;
proc_frame->main_loop = g_main_loop_new (NULL, FALSE);
@ -242,15 +243,15 @@ gimp_plug_in_manager_call_run (GimpPlugInManager *manager,
g_main_loop_run (proc_frame->main_loop);
gimp_threads_enter (manager->gimp);
/* main_loop is quit in plug_in_handle_proc_return() */
/* main_loop is quit in gimp_plug_in_handle_proc_return() */
g_main_loop_unref (proc_frame->main_loop);
proc_frame->main_loop = NULL;
return_vals = plug_in_proc_frame_get_return_vals (proc_frame);
return_vals = gimp_plug_in_proc_frame_get_return_vals (proc_frame);
}
plug_in_unref (plug_in);
g_object_unref (plug_in);
}
done:
@ -271,7 +272,7 @@ gimp_plug_in_manager_call_run_temp (GimpPlugInManager *manager,
GValueArray *args)
{
GValueArray *return_vals = NULL;
PlugIn *plug_in;
GimpPlugIn *plug_in;
g_return_val_if_fail (GIMP_IS_PLUG_IN_MANAGER (manager), NULL);
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
@ -283,11 +284,11 @@ gimp_plug_in_manager_call_run_temp (GimpPlugInManager *manager,
if (plug_in)
{
PlugInProcFrame *proc_frame;
GPProcRun proc_run;
GimpPlugInProcFrame *proc_frame;
GPProcRun proc_run;
proc_frame = plug_in_proc_frame_push (plug_in, context, progress,
GIMP_PROCEDURE (procedure));
proc_frame = gimp_plug_in_proc_frame_push (plug_in, context, progress,
GIMP_PROCEDURE (procedure));
proc_run.name = GIMP_PROCEDURE (procedure)->original_name;
proc_run.nparams = args->n_values;
@ -297,7 +298,7 @@ gimp_plug_in_manager_call_run_temp (GimpPlugInManager *manager,
! gimp_wire_flush (plug_in->my_write, plug_in))
{
g_free (proc_run.params);
plug_in_proc_frame_pop (plug_in);
gimp_plug_in_proc_frame_pop (plug_in);
return_vals =
gimp_procedure_get_return_values (GIMP_PROCEDURE (procedure), FALSE);
@ -307,19 +308,19 @@ gimp_plug_in_manager_call_run_temp (GimpPlugInManager *manager,
g_free (proc_run.params);
plug_in_ref (plug_in);
plug_in_proc_frame_ref (proc_frame);
g_object_ref (plug_in);
gimp_plug_in_proc_frame_ref (proc_frame);
plug_in_main_loop (plug_in);
gimp_plug_in_main_loop (plug_in);
/* main_loop is quit and proc_frame is popped in
* plug_in_handle_temp_proc_return()
* gimp_plug_in_handle_temp_proc_return()
*/
return_vals = plug_in_proc_frame_get_return_vals (proc_frame);
return_vals = gimp_plug_in_proc_frame_get_return_vals (proc_frame);
plug_in_proc_frame_unref (proc_frame, plug_in);
plug_in_unref (plug_in);
gimp_plug_in_proc_frame_unref (proc_frame, plug_in);
g_object_unref (plug_in);
}
done:

View File

@ -30,9 +30,9 @@
#include "pdb/gimp-pdb.h"
#include "pdb/gimppluginprocedure.h"
#include "gimpplugin.h"
#include "gimppluginmanager.h"
#include "gimppluginmanager-file.h"
#include "plug-in.h"
#include "plug-in-def.h"

View File

@ -41,6 +41,7 @@
#include "gimpenvirontable.h"
#include "gimpinterpreterdb.h"
#include "gimpplugin.h"
#include "gimpplugindebug.h"
#include "gimppluginmanager.h"
#define __YES_I_NEED_GIMP_PLUG_IN_MANAGER_CALL__
@ -50,7 +51,6 @@
#include "gimppluginmanager-locale-domain.h"
#include "gimppluginmanager-menu-branch.h"
#include "gimppluginshm.h"
#include "plug-in.h"
#include "plug-in-def.h"
#include "plug-in-rc.h"
@ -241,8 +241,6 @@ gimp_plug_in_manager_initialize (GimpPlugInManager *manager,
gimp_environ_table_load (manager->environ_table, path);
g_free (path);
plug_in_init (manager);
/* allocate a piece of shared memory for use in transporting tiles
* to plug-ins. if we can't allocate a piece of shared memory then
* we'll fall back on sending the data over the pipe.
@ -550,6 +548,8 @@ gimp_plug_in_manager_restore (GimpPlugInManager *manager,
void
gimp_plug_in_manager_exit (GimpPlugInManager *manager)
{
GSList *list;
g_return_if_fail (GIMP_IS_PLUG_IN_MANAGER (manager));
if (manager->debug)
@ -564,7 +564,15 @@ gimp_plug_in_manager_exit (GimpPlugInManager *manager)
manager->shm = NULL;
}
plug_in_exit (manager);
list = manager->open_plug_ins;
while (list)
{
GimpPlugIn *plug_in = list->data;
list = list->next;
gimp_plug_in_close (plug_in, TRUE);
}
g_slist_foreach (manager->plug_in_procedures, (GFunc) g_object_unref, NULL);
g_slist_free (manager->plug_in_procedures);
@ -693,10 +701,10 @@ gimp_plug_in_manager_get_shm_addr (GimpPlugInManager *manager)
void
gimp_plug_in_manager_plug_in_push (GimpPlugInManager *manager,
PlugIn *plug_in)
GimpPlugIn *plug_in)
{
g_return_if_fail (GIMP_IS_PLUG_IN_MANAGER (manager));
g_return_if_fail (plug_in != NULL);
g_return_if_fail (GIMP_IS_PLUG_IN (plug_in));
manager->current_plug_in = plug_in;

View File

@ -52,7 +52,7 @@ struct _GimpPlugInManager
GSList *locale_domains;
GSList *help_domains;
PlugIn *current_plug_in;
GimpPlugIn *current_plug_in;
GSList *open_plug_ins;
GSList *plug_in_stack;
GSList *last_plug_ins;
@ -106,7 +106,7 @@ gint gimp_plug_in_manager_get_shm_ID (GimpPlugInManager *manager);
guchar * gimp_plug_in_manager_get_shm_addr (GimpPlugInManager *manager);
void gimp_plug_in_manager_plug_in_push (GimpPlugInManager *manager,
PlugIn *plug_in);
GimpPlugIn *plug_in);
void gimp_plug_in_manager_plug_in_pop (GimpPlugInManager *manager);

View File

@ -1,7 +1,7 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* plug-in-proc-def.c
* gimppluginprocedure.c
*
* 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
@ -35,7 +35,6 @@
#define __YES_I_NEED_GIMP_PLUG_IN_MANAGER_CALL__
#include "plug-in/gimppluginmanager-call.h"
#include "plug-in/plug-in.h"
#include "gimppluginprocedure.h"

View File

@ -1,7 +1,7 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* plug-in-proc-frame.c
* gimppluginprocframe.c
*
* 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
@ -29,51 +29,49 @@
#include "core/gimpcontext.h"
#include "core/gimpprogress.h"
#include "pdb/gimpprocedure.h"
#include "pdb/gimppluginprocedure.h"
#include "plug-in-proc-frame.h"
#include "plug-in-progress.h"
static void plug_in_proc_frame_free (PlugInProcFrame *proc_frame,
PlugIn *plug_in);
#include "gimpplugin.h"
#include "gimpplugin-progress.h"
/* publuc functions */
PlugInProcFrame *
plug_in_proc_frame_new (GimpContext *context,
GimpProgress *progress,
GimpProcedure *procedure)
GimpPlugInProcFrame *
gimp_plug_in_proc_frame_new (GimpContext *context,
GimpProgress *progress,
GimpPlugInProcedure *procedure)
{
PlugInProcFrame *proc_frame;
GimpPlugInProcFrame *proc_frame;
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
g_return_val_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress), NULL);
g_return_val_if_fail (GIMP_IS_PROCEDURE (procedure), NULL);
g_return_val_if_fail (GIMP_IS_PLUG_IN_PROCEDURE (procedure), NULL);
proc_frame = g_new0 (PlugInProcFrame, 1);
proc_frame = g_new0 (GimpPlugInProcFrame, 1);
proc_frame->ref_count = 1;
plug_in_proc_frame_init (proc_frame, context, progress, procedure);
gimp_plug_in_proc_frame_init (proc_frame, context, progress, procedure);
return proc_frame;
}
void
plug_in_proc_frame_init (PlugInProcFrame *proc_frame,
GimpContext *context,
GimpProgress *progress,
GimpProcedure *procedure)
gimp_plug_in_proc_frame_init (GimpPlugInProcFrame *proc_frame,
GimpContext *context,
GimpProgress *progress,
GimpPlugInProcedure *procedure)
{
g_return_if_fail (proc_frame != NULL);
g_return_if_fail (GIMP_IS_CONTEXT (context));
g_return_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress));
g_return_if_fail (procedure == NULL ||
GIMP_IS_PLUG_IN_PROCEDURE (procedure));
proc_frame->main_context = g_object_ref (context);
proc_frame->context_stack = NULL;
proc_frame->procedure = procedure;
proc_frame->procedure = GIMP_PROCEDURE (procedure);
proc_frame->main_loop = NULL;
proc_frame->return_vals = NULL;
proc_frame->progress = progress ? g_object_ref (progress) : NULL;
@ -82,15 +80,15 @@ plug_in_proc_frame_init (PlugInProcFrame *proc_frame,
}
void
plug_in_proc_frame_dispose (PlugInProcFrame *proc_frame,
PlugIn *plug_in)
gimp_plug_in_proc_frame_dispose (GimpPlugInProcFrame *proc_frame,
GimpPlugIn *plug_in)
{
g_return_if_fail (proc_frame != NULL);
g_return_if_fail (plug_in != NULL);
g_return_if_fail (GIMP_IS_PLUG_IN (plug_in));
if (proc_frame->progress)
{
plug_in_progress_end (plug_in);
gimp_plug_in_progress_end (plug_in);
if (proc_frame->progress)
{
@ -111,22 +109,22 @@ plug_in_proc_frame_dispose (PlugInProcFrame *proc_frame,
g_object_unref (proc_frame->main_context);
proc_frame->main_context = NULL;
}
if (proc_frame->return_vals)
{
g_value_array_free (proc_frame->return_vals);
proc_frame->return_vals = NULL;
}
if (proc_frame->main_loop)
{
g_main_loop_unref (proc_frame->main_loop);
proc_frame->main_loop = NULL;
}
}
static void
plug_in_proc_frame_free (PlugInProcFrame *proc_frame,
PlugIn *plug_in)
{
g_return_if_fail (proc_frame != NULL);
g_return_if_fail (plug_in != NULL);
plug_in_proc_frame_dispose (proc_frame, plug_in);
g_free (proc_frame);
}
PlugInProcFrame *
plug_in_proc_frame_ref (PlugInProcFrame *proc_frame)
GimpPlugInProcFrame *
gimp_plug_in_proc_frame_ref (GimpPlugInProcFrame *proc_frame)
{
g_return_val_if_fail (proc_frame != NULL, NULL);
@ -136,20 +134,23 @@ plug_in_proc_frame_ref (PlugInProcFrame *proc_frame)
}
void
plug_in_proc_frame_unref (PlugInProcFrame *proc_frame,
PlugIn *plug_in)
gimp_plug_in_proc_frame_unref (GimpPlugInProcFrame *proc_frame,
GimpPlugIn *plug_in)
{
g_return_if_fail (proc_frame != NULL);
g_return_if_fail (plug_in != NULL);
g_return_if_fail (GIMP_IS_PLUG_IN (plug_in));
proc_frame->ref_count--;
if (proc_frame->ref_count < 1)
plug_in_proc_frame_free (proc_frame, plug_in);
{
gimp_plug_in_proc_frame_dispose (proc_frame, plug_in);
g_free (proc_frame);
}
}
GValueArray *
plug_in_proc_frame_get_return_vals (PlugInProcFrame *proc_frame)
gimp_plug_in_proc_frame_get_return_vals (GimpPlugInProcFrame *proc_frame)
{
GValueArray *return_vals;

View File

@ -1,7 +1,7 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* plug-in-proc-frame.h
* gimppluginprocframe.h
*
* 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
@ -18,11 +18,11 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __PLUG_IN_PROC_FRAME_H__
#define __PLUG_IN_PRON_FRAME_H__
#ifndef __GIMP_PLUG_IN_PROC_FRAME_H__
#define __GIMP_PLUG_IN_PRON_FRAME_H__
struct _PlugInProcFrame
struct _GimpPlugInProcFrame
{
gint ref_count;
@ -40,22 +40,22 @@ struct _PlugInProcFrame
};
PlugInProcFrame * plug_in_proc_frame_new (GimpContext *context,
GimpProgress *progress,
GimpProcedure *procedure);
void plug_in_proc_frame_init (PlugInProcFrame *proc_frame,
GimpContext *context,
GimpProgress *progress,
GimpProcedure *procedure);
GimpPlugInProcFrame * gimp_plug_in_proc_frame_new (GimpContext *context,
GimpProgress *progress,
GimpPlugInProcedure *procedure);
void gimp_plug_in_proc_frame_init (GimpPlugInProcFrame *proc_frame,
GimpContext *context,
GimpProgress *progress,
GimpPlugInProcedure *procedure);
void plug_in_proc_frame_dispose (PlugInProcFrame *proc_frame,
PlugIn *plug_in);
void gimp_plug_in_proc_frame_dispose (GimpPlugInProcFrame *proc_frame,
GimpPlugIn *plug_in);
PlugInProcFrame * plug_in_proc_frame_ref (PlugInProcFrame *proc_frame);
void plug_in_proc_frame_unref (PlugInProcFrame *proc_frame,
PlugIn *plug_in);
GimpPlugInProcFrame * gimp_plug_in_proc_frame_ref (GimpPlugInProcFrame *proc_frame);
void gimp_plug_in_proc_frame_unref (GimpPlugInProcFrame *proc_frame,
GimpPlugIn *plug_in);
GValueArray * plug_in_proc_frame_get_return_vals (PlugInProcFrame *proc_frame);
GValueArray * gimp_plug_in_proc_frame_get_return_vals (GimpPlugInProcFrame *proc_frame);
#endif /* __PLUG_IN_PROC_FRAME_H__ */
#endif /* __GIMP_PLUG_IN_PROC_FRAME_H__ */

View File

@ -26,9 +26,9 @@
#include "core/gimp.h"
#include "plug-in/gimpplugin.h"
#define __YES_I_NEED_GIMP_PLUG_IN_MANAGER_CALL__
#include "plug-in/gimppluginmanager-call.h"
#include "plug-in/plug-in.h"
#include "gimptemporaryprocedure.h"
@ -128,11 +128,11 @@ gimp_temporary_procedure_get_progname (const GimpPlugInProcedure *procedure)
/* public functions */
GimpProcedure *
gimp_temporary_procedure_new (PlugIn *plug_in)
gimp_temporary_procedure_new (GimpPlugIn *plug_in)
{
GimpTemporaryProcedure *proc;
g_return_val_if_fail (plug_in != NULL, NULL);
g_return_val_if_fail (GIMP_IS_PLUG_IN (plug_in), NULL);
proc = g_object_new (GIMP_TYPE_TEMPORARY_PROCEDURE, NULL);

View File

@ -39,7 +39,7 @@ struct _GimpTemporaryProcedure
{
GimpPlugInProcedure parent_instance;
PlugIn *plug_in;
GimpPlugIn *plug_in;
};
struct _GimpTemporaryProcedureClass
@ -50,7 +50,7 @@ struct _GimpTemporaryProcedureClass
GType gimp_temporary_procedure_get_type (void) G_GNUC_CONST;
GimpProcedure * gimp_temporary_procedure_new (PlugIn *plug_in);
GimpProcedure * gimp_temporary_procedure_new (GimpPlugIn *plug_in);
#endif /* __GIMP_TEMPORARY_PROCEDURE_H__ */

View File

@ -1,79 +0,0 @@
/* 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
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <glib-object.h>
#include "plug-in-types.h"
#include "core/gimp.h"
#include "core/gimpcontext.h"
#include "gimppluginmanager.h"
#include "plug-in.h"
#include "plug-in-context.h"
gboolean
plug_in_context_push (PlugIn *plug_in)
{
PlugInProcFrame *proc_frame;
GimpContext *parent;
GimpContext *context;
g_return_val_if_fail (plug_in != NULL, FALSE);
proc_frame = plug_in_get_proc_frame (plug_in);
if (proc_frame->context_stack)
parent = proc_frame->context_stack->data;
else
parent = proc_frame->main_context;
context = gimp_context_new (plug_in->manager->gimp, "plug-in context", NULL);
gimp_context_copy_properties (parent, context, GIMP_CONTEXT_ALL_PROPS_MASK);
proc_frame->context_stack = g_list_prepend (proc_frame->context_stack,
context);
return TRUE;
}
gboolean
plug_in_context_pop (PlugIn *plug_in)
{
PlugInProcFrame *proc_frame;
g_return_val_if_fail (plug_in != NULL, FALSE);
proc_frame = plug_in_get_proc_frame (plug_in);
if (proc_frame->context_stack)
{
GimpContext *context = proc_frame->context_stack->data;
proc_frame->context_stack = g_list_remove (proc_frame->context_stack,
context);
g_object_unref (context);
return TRUE;
}
return FALSE;
}

View File

@ -1,29 +0,0 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* plug-in-context.h
*
* 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.
*/
#ifndef __PLUG_IN_CONTEXT_H__
#define __PLUG_IN_CONTEXT_H__
gboolean plug_in_context_push (PlugIn *plug_in);
gboolean plug_in_context_pop (PlugIn *plug_in);
#endif /* __PLUG_IN_CONTEXT_H__ */

View File

@ -1,725 +0,0 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* plug-in-message.c
*
* 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 "libgimpbase/gimpbase.h"
#include "libgimpbase/gimpprotocol.h"
#include "libgimpbase/gimpwire.h"
#include "plug-in-types.h"
#include "base/tile.h"
#include "base/tile-manager.h"
#include "core/gimp.h"
#include "core/gimpdrawable.h"
#include "pdb/gimppdb.h"
#include "pdb/gimp-pdb-compat.h"
#include "pdb/gimptemporaryprocedure.h"
#include "gimppluginmanager.h"
#include "plug-in.h"
#include "plug-in-def.h"
#include "plug-in-params.h"
/* local function prototypes */
static void plug_in_handle_quit (PlugIn *plug_in);
static void plug_in_handle_tile_req (PlugIn *plug_in,
GPTileReq *tile_req);
static void plug_in_handle_proc_run (PlugIn *plug_in,
GPProcRun *proc_run);
static void plug_in_handle_proc_return (PlugIn *plug_in,
GPProcReturn *proc_return);
static void plug_in_handle_temp_proc_return (PlugIn *plug_in,
GPProcReturn *proc_return);
static void plug_in_handle_proc_install (PlugIn *plug_in,
GPProcInstall *proc_install);
static void plug_in_handle_proc_uninstall (PlugIn *plug_in,
GPProcUninstall *proc_uninstall);
static void plug_in_handle_extension_ack (PlugIn *plug_in);
static void plug_in_handle_has_init (PlugIn *plug_in);
/* public functions */
void
plug_in_handle_message (PlugIn *plug_in,
GimpWireMessage *msg)
{
switch (msg->type)
{
case GP_QUIT:
plug_in_handle_quit (plug_in);
break;
case GP_CONFIG:
g_message ("Plug-In \"%s\"\n(%s)\n\n"
"sent a CONFIG message. This should not happen.",
gimp_filename_to_utf8 (plug_in->name),
gimp_filename_to_utf8 (plug_in->prog));
plug_in_close (plug_in, TRUE);
break;
case GP_TILE_REQ:
plug_in_handle_tile_req (plug_in, msg->data);
break;
case GP_TILE_ACK:
g_message ("Plug-In \"%s\"\n(%s)\n\n"
"sent a TILE_ACK message. This should not happen.",
gimp_filename_to_utf8 (plug_in->name),
gimp_filename_to_utf8 (plug_in->prog));
plug_in_close (plug_in, TRUE);
break;
case GP_TILE_DATA:
g_message ("Plug-In \"%s\"\n(%s)\n\n"
"sent a TILE_DATA message. This should not happen.",
gimp_filename_to_utf8 (plug_in->name),
gimp_filename_to_utf8 (plug_in->prog));
plug_in_close (plug_in, TRUE);
break;
case GP_PROC_RUN:
plug_in_handle_proc_run (plug_in, msg->data);
break;
case GP_PROC_RETURN:
plug_in_handle_proc_return (plug_in, msg->data);
break;
case GP_TEMP_PROC_RUN:
g_message ("Plug-In \"%s\"\n(%s)\n\n"
"sent a TEMP_PROC_RUN message. This should not happen.",
gimp_filename_to_utf8 (plug_in->name),
gimp_filename_to_utf8 (plug_in->prog));
plug_in_close (plug_in, TRUE);
break;
case GP_TEMP_PROC_RETURN:
plug_in_handle_temp_proc_return (plug_in, msg->data);
break;
case GP_PROC_INSTALL:
plug_in_handle_proc_install (plug_in, msg->data);
break;
case GP_PROC_UNINSTALL:
plug_in_handle_proc_uninstall (plug_in, msg->data);
break;
case GP_EXTENSION_ACK:
plug_in_handle_extension_ack (plug_in);
break;
case GP_HAS_INIT:
plug_in_handle_has_init (plug_in);
break;
}
}
/* private functions */
static void
plug_in_handle_quit (PlugIn *plug_in)
{
plug_in_close (plug_in, FALSE);
}
static void
plug_in_handle_tile_req (PlugIn *plug_in,
GPTileReq *tile_req)
{
GPTileData tile_data;
GPTileData *tile_info;
GimpWireMessage msg;
GimpDrawable *drawable;
TileManager *tm;
Tile *tile;
gint shm_ID;
shm_ID = gimp_plug_in_manager_get_shm_ID (plug_in->manager);
if (tile_req->drawable_ID == -1)
{
/* this branch communicates with libgimp/gimptile.c:gimp_tile_put() */
tile_data.drawable_ID = -1;
tile_data.tile_num = 0;
tile_data.shadow = 0;
tile_data.bpp = 0;
tile_data.width = 0;
tile_data.height = 0;
tile_data.use_shm = (shm_ID == -1) ? FALSE : TRUE;
tile_data.data = NULL;
if (! gp_tile_data_write (plug_in->my_write, &tile_data, plug_in))
{
g_warning ("plug_in_handle_tile_req: ERROR");
plug_in_close (plug_in, TRUE);
return;
}
if (! gimp_wire_read_msg (plug_in->my_read, &msg, plug_in))
{
g_warning ("plug_in_handle_tile_req: ERROR");
plug_in_close (plug_in, TRUE);
return;
}
if (msg.type != GP_TILE_DATA)
{
g_warning ("expected tile data and received: %d", msg.type);
plug_in_close (plug_in, TRUE);
return;
}
tile_info = msg.data;
drawable = (GimpDrawable *) gimp_item_get_by_ID (plug_in->manager->gimp,
tile_info->drawable_ID);
if (! GIMP_IS_DRAWABLE (drawable))
{
g_message ("Plug-In \"%s\"\n(%s)\n\n"
"requested invalid drawable (killing)",
gimp_filename_to_utf8 (plug_in->name),
gimp_filename_to_utf8 (plug_in->prog));
plug_in_close (plug_in, TRUE);
return;
}
if (tile_info->shadow)
tm = gimp_drawable_get_shadow_tiles (drawable);
else
tm = gimp_drawable_get_tiles (drawable);
tile = tile_manager_get (tm, tile_info->tile_num, TRUE, TRUE);
if (! tile)
{
g_message ("Plug-In \"%s\"\n(%s)\n\n"
"requested invalid tile (killing)",
gimp_filename_to_utf8 (plug_in->name),
gimp_filename_to_utf8 (plug_in->prog));
plug_in_close (plug_in, TRUE);
return;
}
if (tile_data.use_shm)
memcpy (tile_data_pointer (tile, 0, 0),
gimp_plug_in_manager_get_shm_addr (plug_in->manager),
tile_size (tile));
else
memcpy (tile_data_pointer (tile, 0, 0),
tile_info->data,
tile_size (tile));
tile_release (tile, TRUE);
gimp_wire_destroy (&msg);
if (! gp_tile_ack_write (plug_in->my_write, plug_in))
{
g_warning ("plug_in_handle_tile_req: ERROR");
plug_in_close (plug_in, TRUE);
return;
}
}
else
{
/* this branch communicates with libgimp/gimptile.c:gimp_tile_get() */
drawable = (GimpDrawable *) gimp_item_get_by_ID (plug_in->manager->gimp,
tile_req->drawable_ID);
if (! GIMP_IS_DRAWABLE (drawable))
{
g_message ("Plug-In \"%s\"\n(%s)\n\n"
"requested invalid drawable (killing)",
gimp_filename_to_utf8 (plug_in->name),
gimp_filename_to_utf8 (plug_in->prog));
plug_in_close (plug_in, TRUE);
return;
}
if (tile_req->shadow)
tm = gimp_drawable_get_shadow_tiles (drawable);
else
tm = gimp_drawable_get_tiles (drawable);
tile = tile_manager_get (tm, tile_req->tile_num, TRUE, FALSE);
if (! tile)
{
g_message ("Plug-In \"%s\"\n(%s)\n\n"
"requested invalid tile (killing)",
gimp_filename_to_utf8 (plug_in->name),
gimp_filename_to_utf8 (plug_in->prog));
plug_in_close (plug_in, TRUE);
return;
}
tile_data.drawable_ID = tile_req->drawable_ID;
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);
tile_data.use_shm = (shm_ID == -1) ? FALSE : TRUE;
if (tile_data.use_shm)
memcpy (gimp_plug_in_manager_get_shm_addr (plug_in->manager),
tile_data_pointer (tile, 0, 0),
tile_size (tile));
else
tile_data.data = tile_data_pointer (tile, 0, 0);
if (! gp_tile_data_write (plug_in->my_write, &tile_data, plug_in))
{
g_message ("plug_in_handle_tile_req: ERROR");
plug_in_close (plug_in, TRUE);
return;
}
tile_release (tile, FALSE);
if (! gimp_wire_read_msg (plug_in->my_read, &msg, plug_in))
{
g_message ("plug_in_handle_tile_req: ERROR");
plug_in_close (plug_in, TRUE);
return;
}
if (msg.type != GP_TILE_ACK)
{
g_warning ("expected tile ack and received: %d", msg.type);
plug_in_close (plug_in, TRUE);
return;
}
gimp_wire_destroy (&msg);
}
}
static void
plug_in_handle_proc_run (PlugIn *plug_in,
GPProcRun *proc_run)
{
PlugInProcFrame *proc_frame;
gchar *canonical;
const gchar *proc_name = NULL;
GimpProcedure *procedure;
GValueArray *args = NULL;
GValueArray *return_vals = NULL;
GPProcReturn proc_return;
canonical = gimp_canonicalize_identifier (proc_run->name);
proc_frame = plug_in_get_proc_frame (plug_in);
procedure = gimp_pdb_lookup_procedure (plug_in->manager->gimp->pdb,
canonical);
if (! procedure)
{
proc_name = gimp_pdb_lookup_compat_proc_name (plug_in->manager->gimp->pdb,
canonical);
if (proc_name)
{
procedure = gimp_pdb_lookup_procedure (plug_in->manager->gimp->pdb,
proc_name);
if (plug_in->manager->gimp->pdb_compat_mode == GIMP_PDB_COMPAT_WARN)
{
g_message ("WARNING: Plug-In \"%s\"\n(%s)\n"
"called deprecated procedure '%s'.\n"
"It should call '%s' instead!",
gimp_filename_to_utf8 (plug_in->name),
gimp_filename_to_utf8 (plug_in->prog),
canonical, proc_name);
}
}
}
else if (procedure->deprecated)
{
if (plug_in->manager->gimp->pdb_compat_mode == GIMP_PDB_COMPAT_WARN)
{
if (! strcmp (procedure->deprecated, "NONE"))
{
g_message ("WARNING: Plug-In \"%s\"\n(%s)\n"
"called deprecated procedure '%s'.",
gimp_filename_to_utf8 (plug_in->name),
gimp_filename_to_utf8 (plug_in->prog),
canonical);
}
else
{
g_message ("WARNING: Plug-In \"%s\"\n(%s)\n"
"called deprecated procedure '%s'.\n"
"It should call '%s' instead!",
gimp_filename_to_utf8 (plug_in->name),
gimp_filename_to_utf8 (plug_in->prog),
canonical, procedure->deprecated);
}
}
else if (plug_in->manager->gimp->pdb_compat_mode == GIMP_PDB_COMPAT_OFF)
{
procedure = NULL;
}
}
if (! proc_name)
proc_name = canonical;
if (procedure)
args = plug_in_params_to_args (procedure->args, procedure->num_args,
proc_run->params, proc_run->nparams,
FALSE, FALSE);
/* Execute the procedure even if gimp_pdb_lookup_procedure()
* returned NULL, gimp_pdb_execute_procedure_by_name_args() will
* return appropriate error return_vals.
*/
gimp_plug_in_manager_plug_in_push (plug_in->manager, plug_in);
return_vals = gimp_pdb_execute_procedure_by_name_args (plug_in->manager->gimp->pdb,
proc_frame->context_stack ?
proc_frame->context_stack->data :
proc_frame->main_context,
proc_frame->progress,
proc_name,
args);
gimp_plug_in_manager_plug_in_pop (plug_in->manager);
g_free (canonical);
/* 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))
{
g_warning ("plug_in_handle_proc_run: ERROR");
plug_in_close (plug_in, TRUE);
}
g_value_array_free (args);
g_value_array_free (return_vals);
g_free (proc_return.params);
}
static void
plug_in_handle_proc_return (PlugIn *plug_in,
GPProcReturn *proc_return)
{
PlugInProcFrame *proc_frame = &plug_in->main_proc_frame;
if (proc_frame->main_loop)
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);
if (proc_frame->main_loop)
g_main_loop_quit (proc_frame->main_loop);
plug_in_close (plug_in, FALSE);
}
static void
plug_in_handle_temp_proc_return (PlugIn *plug_in,
GPProcReturn *proc_return)
{
if (plug_in->temp_proc_frames)
{
PlugInProcFrame *proc_frame = plug_in->temp_proc_frames->data;
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);
plug_in_main_loop_quit (plug_in);
plug_in_proc_frame_pop (plug_in);
}
else
{
g_message ("Plug-In \"%s\"\n(%s)\n\n"
"sent a TEMP_PROC_RETURN message while not running "
"a temporary procedure. This should not happen.",
gimp_filename_to_utf8 (plug_in->name),
gimp_filename_to_utf8 (plug_in->prog));
plug_in_close (plug_in, TRUE);
}
}
static void
plug_in_handle_proc_install (PlugIn *plug_in,
GPProcInstall *proc_install)
{
GimpPlugInProcedure *proc = NULL;
GimpProcedure *procedure = NULL;
gchar *canonical;
gboolean valid_utf8 = FALSE;
gint i;
canonical = gimp_canonicalize_identifier (proc_install->name);
/* Sanity check for array arguments */
for (i = 1; i < proc_install->nparams; i++)
{
if ((proc_install->params[i].type == GIMP_PDB_INT32ARRAY ||
proc_install->params[i].type == GIMP_PDB_INT8ARRAY ||
proc_install->params[i].type == GIMP_PDB_FLOATARRAY ||
proc_install->params[i].type == GIMP_PDB_STRINGARRAY)
&&
proc_install->params[i - 1].type != GIMP_PDB_INT32)
{
g_message ("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_filename_to_utf8 (plug_in->name),
gimp_filename_to_utf8 (plug_in->prog),
canonical, i);
g_free (canonical);
return;
}
}
/* Sanity check strings for UTF-8 validity */
if ((proc_install->menu_path == NULL ||
g_utf8_validate (proc_install->menu_path, -1, NULL)) &&
(g_utf8_validate (canonical, -1, NULL)) &&
(proc_install->blurb == NULL ||
g_utf8_validate (proc_install->blurb, -1, NULL)) &&
(proc_install->help == NULL ||
g_utf8_validate (proc_install->help, -1, NULL)) &&
(proc_install->author == NULL ||
g_utf8_validate (proc_install->author, -1, NULL)) &&
(proc_install->copyright == NULL ||
g_utf8_validate (proc_install->copyright, -1, NULL)) &&
(proc_install->date == NULL ||
g_utf8_validate (proc_install->date, -1, NULL)))
{
valid_utf8 = TRUE;
for (i = 0; i < proc_install->nparams && valid_utf8; i++)
{
if (! (g_utf8_validate (proc_install->params[i].name, -1, NULL) &&
(proc_install->params[i].description == NULL ||
g_utf8_validate (proc_install->params[i].description, -1, NULL))))
valid_utf8 = FALSE;
}
for (i = 0; i < proc_install->nreturn_vals && valid_utf8; i++)
{
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))))
valid_utf8 = FALSE;
}
}
if (! valid_utf8)
{
g_message ("Plug-In \"%s\"\n(%s)\n\n"
"attempted to install a procedure with invalid UTF-8 strings.",
gimp_filename_to_utf8 (plug_in->name),
gimp_filename_to_utf8 (plug_in->prog));
g_free (canonical);
return;
}
/* Create the procedure object */
switch (proc_install->type)
{
case GIMP_PLUGIN:
case GIMP_EXTENSION:
proc = gimp_plug_in_procedure_find (plug_in->plug_in_def->procedures,
canonical);
if (proc)
plug_in_def_remove_procedure (plug_in->plug_in_def, proc);
procedure = gimp_plug_in_procedure_new (proc_install->type,
plug_in->prog);
break;
case GIMP_TEMPORARY:
proc = gimp_plug_in_procedure_find (plug_in->temp_procedures, canonical);
if (proc)
plug_in_remove_temp_proc (plug_in, GIMP_TEMPORARY_PROCEDURE (proc));
procedure = gimp_temporary_procedure_new (plug_in);
break;
}
proc = GIMP_PLUG_IN_PROCEDURE (procedure);
proc->mtime = time (NULL);
proc->installed_during_init = (plug_in->call_mode == GIMP_PLUG_IN_CALL_INIT);
gimp_plug_in_procedure_set_image_types (proc, proc_install->image_types);
gimp_object_take_name (GIMP_OBJECT (procedure), canonical);
gimp_procedure_set_strings (procedure,
proc_install->name,
proc_install->blurb,
proc_install->help,
proc_install->author,
proc_install->copyright,
proc_install->date,
NULL);
for (i = 0; i < proc_install->nparams; i++)
{
GParamSpec *pspec =
gimp_pdb_compat_param_spec (plug_in->manager->gimp,
proc_install->params[i].type,
proc_install->params[i].name,
proc_install->params[i].description);
gimp_procedure_add_argument (procedure, pspec);
}
for (i = 0; i < proc_install->nreturn_vals; i++)
{
GParamSpec *pspec =
gimp_pdb_compat_param_spec (plug_in->manager->gimp,
proc_install->return_vals[i].type,
proc_install->return_vals[i].name,
proc_install->return_vals[i].description);
gimp_procedure_add_return_value (procedure, pspec);
}
/* Sanity check menu path */
if (proc_install->menu_path)
{
if (proc_install->menu_path[0] == '<')
{
GError *error = NULL;
if (! gimp_plug_in_procedure_add_menu_path (proc,
proc_install->menu_path,
&error))
{
g_message (error->message);
g_clear_error (&error);
}
}
else
{
proc->menu_label = g_strdup (proc_install->menu_path);
}
}
/* Install the procedure */
switch (proc_install->type)
{
case GIMP_PLUGIN:
case GIMP_EXTENSION:
plug_in_def_add_procedure (plug_in->plug_in_def, proc);
break;
case GIMP_TEMPORARY:
plug_in_add_temp_proc (plug_in, GIMP_TEMPORARY_PROCEDURE (proc));
break;
}
g_object_unref (proc);
}
static void
plug_in_handle_proc_uninstall (PlugIn *plug_in,
GPProcUninstall *proc_uninstall)
{
GimpPlugInProcedure *proc;
gchar *canonical;
canonical = gimp_canonicalize_identifier (proc_uninstall->name);
proc = gimp_plug_in_procedure_find (plug_in->temp_procedures, canonical);
if (proc)
plug_in_remove_temp_proc (plug_in, GIMP_TEMPORARY_PROCEDURE (proc));
g_free (canonical);
}
static void
plug_in_handle_extension_ack (PlugIn *plug_in)
{
if (plug_in->ext_main_loop)
{
g_main_loop_quit (plug_in->ext_main_loop);
}
else
{
g_message ("Plug-In \"%s\"\n(%s)\n\n"
"sent an EXTENSION_ACK message while not being started "
"as an extension. This should not happen.",
gimp_filename_to_utf8 (plug_in->name),
gimp_filename_to_utf8 (plug_in->prog));
plug_in_close (plug_in, TRUE);
}
}
static void
plug_in_handle_has_init (PlugIn *plug_in)
{
if (plug_in->call_mode == GIMP_PLUG_IN_CALL_QUERY)
{
plug_in_def_set_has_init (plug_in->plug_in_def, TRUE);
}
else
{
g_message ("Plug-In \"%s\"\n(%s)\n\n"
"sent an HAS_INIT message while not in query(). "
"This should not happen.",
gimp_filename_to_utf8 (plug_in->name),
gimp_filename_to_utf8 (plug_in->prog));
plug_in_close (plug_in, TRUE);
}
}

View File

@ -1,29 +0,0 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* plug-in-message.h
*
* 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.
*/
#ifndef __PLUG_IN_MESSAGE_H__
#define __PLUG_IN_MESSAGE_H__
void plug_in_handle_message (PlugIn *plug_in,
GimpWireMessage *msg);
#endif /* __PLUG_IN_MESSAGE_H__ */

View File

@ -1,192 +0,0 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* plug-in-proc-frame.c
*
* 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 "plug-in-types.h"
#include "core/gimpcontext.h"
#include "core/gimpprogress.h"
#include "pdb/gimpprocedure.h"
#include "plug-in-proc-frame.h"
#include "plug-in-progress.h"
static void plug_in_proc_frame_free (PlugInProcFrame *proc_frame,
PlugIn *plug_in);
/* publuc functions */
PlugInProcFrame *
plug_in_proc_frame_new (GimpContext *context,
GimpProgress *progress,
GimpProcedure *procedure)
{
PlugInProcFrame *proc_frame;
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
g_return_val_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress), NULL);
g_return_val_if_fail (GIMP_IS_PROCEDURE (procedure), NULL);
proc_frame = g_new0 (PlugInProcFrame, 1);
proc_frame->ref_count = 1;
plug_in_proc_frame_init (proc_frame, context, progress, procedure);
return proc_frame;
}
void
plug_in_proc_frame_init (PlugInProcFrame *proc_frame,
GimpContext *context,
GimpProgress *progress,
GimpProcedure *procedure)
{
g_return_if_fail (proc_frame != NULL);
g_return_if_fail (GIMP_IS_CONTEXT (context));
g_return_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress));
proc_frame->main_context = g_object_ref (context);
proc_frame->context_stack = NULL;
proc_frame->procedure = procedure;
proc_frame->main_loop = NULL;
proc_frame->return_vals = NULL;
proc_frame->progress = progress ? g_object_ref (progress) : NULL;
proc_frame->progress_created = FALSE;
proc_frame->progress_cancel_id = 0;
}
void
plug_in_proc_frame_dispose (PlugInProcFrame *proc_frame,
PlugIn *plug_in)
{
g_return_if_fail (proc_frame != NULL);
g_return_if_fail (plug_in != NULL);
if (proc_frame->progress)
{
plug_in_progress_end (plug_in);
if (proc_frame->progress)
{
g_object_unref (proc_frame->progress);
proc_frame->progress = NULL;
}
}
if (proc_frame->context_stack)
{
g_list_foreach (proc_frame->context_stack, (GFunc) g_object_unref, NULL);
g_list_free (proc_frame->context_stack);
proc_frame->context_stack = NULL;
}
if (proc_frame->main_context)
{
g_object_unref (proc_frame->main_context);
proc_frame->main_context = NULL;
}
}
static void
plug_in_proc_frame_free (PlugInProcFrame *proc_frame,
PlugIn *plug_in)
{
g_return_if_fail (proc_frame != NULL);
g_return_if_fail (plug_in != NULL);
plug_in_proc_frame_dispose (proc_frame, plug_in);
g_free (proc_frame);
}
PlugInProcFrame *
plug_in_proc_frame_ref (PlugInProcFrame *proc_frame)
{
g_return_val_if_fail (proc_frame != NULL, NULL);
proc_frame->ref_count++;
return proc_frame;
}
void
plug_in_proc_frame_unref (PlugInProcFrame *proc_frame,
PlugIn *plug_in)
{
g_return_if_fail (proc_frame != NULL);
g_return_if_fail (plug_in != NULL);
proc_frame->ref_count--;
if (proc_frame->ref_count < 1)
plug_in_proc_frame_free (proc_frame, plug_in);
}
GValueArray *
plug_in_proc_frame_get_return_vals (PlugInProcFrame *proc_frame)
{
GValueArray *return_vals;
g_return_val_if_fail (proc_frame != NULL, NULL);
if (proc_frame->return_vals &&
proc_frame->return_vals->n_values ==
proc_frame->procedure->num_values + 1)
{
return_vals = proc_frame->return_vals;
}
else if (proc_frame->return_vals)
{
/* Allocate new return values of the correct size. */
return_vals = gimp_procedure_get_return_values (proc_frame->procedure,
FALSE);
/* Copy all of the arguments we can. */
memcpy (return_vals->values, proc_frame->return_vals->values,
sizeof (GValue) * MIN (proc_frame->return_vals->n_values,
proc_frame->procedure->num_values + 1));
/* Free the old argument pointer. This will cause a memory leak
* only if there were more values returned than we need (which
* shouldn't ever happen).
*/
g_free (proc_frame->return_vals);
}
else
{
/* Just return a dummy set of values. */
return_vals = gimp_procedure_get_return_values (proc_frame->procedure,
FALSE);
}
/* We have consumed any saved values, so clear them. */
proc_frame->return_vals = NULL;
return return_vals;
}

View File

@ -1,61 +0,0 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* plug-in-proc-frame.h
*
* 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.
*/
#ifndef __PLUG_IN_PROC_FRAME_H__
#define __PLUG_IN_PRON_FRAME_H__
struct _PlugInProcFrame
{
gint ref_count;
GimpContext *main_context;
GList *context_stack;
GimpProcedure *procedure;
GMainLoop *main_loop;
GValueArray *return_vals;
GimpProgress *progress;
gboolean progress_created;
gulong progress_cancel_id;
};
PlugInProcFrame * plug_in_proc_frame_new (GimpContext *context,
GimpProgress *progress,
GimpProcedure *procedure);
void plug_in_proc_frame_init (PlugInProcFrame *proc_frame,
GimpContext *context,
GimpProgress *progress,
GimpProcedure *procedure);
void plug_in_proc_frame_dispose (PlugInProcFrame *proc_frame,
PlugIn *plug_in);
PlugInProcFrame * plug_in_proc_frame_ref (PlugInProcFrame *proc_frame);
void plug_in_proc_frame_unref (PlugInProcFrame *proc_frame,
PlugIn *plug_in);
GValueArray * plug_in_proc_frame_get_return_vals (PlugInProcFrame *proc_frame);
#endif /* __PLUG_IN_PROC_FRAME_H__ */

View File

@ -1,336 +0,0 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* plug-in-progress.c
*
* 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 <glib-object.h>
#include "plug-in-types.h"
#include "core/gimp.h"
#include "core/gimpparamspecs.h"
#include "core/gimppdbprogress.h"
#include "core/gimpprogress.h"
#include "pdb/gimppdb.h"
#include "pdb/gimptemporaryprocedure.h"
#include "gimppluginmanager.h"
#include "plug-in.h"
#include "plug-in-progress.h"
/* local function prototypes */
static void plug_in_progress_cancel_callback (GimpProgress *progress,
PlugIn *plug_in);
/* public functions */
void
plug_in_progress_start (PlugIn *plug_in,
const gchar *message,
GimpObject *display)
{
PlugInProcFrame *proc_frame;
g_return_if_fail (plug_in != NULL);
g_return_if_fail (display == NULL || GIMP_IS_OBJECT (display));
proc_frame = plug_in_get_proc_frame (plug_in);
if (! proc_frame->progress)
{
proc_frame->progress = gimp_new_progress (plug_in->manager->gimp,
display);
if (proc_frame->progress)
{
proc_frame->progress_created = TRUE;
g_object_ref (proc_frame->progress);
}
}
if (proc_frame->progress)
{
if (! proc_frame->progress_cancel_id)
proc_frame->progress_cancel_id =
g_signal_connect (proc_frame->progress, "cancel",
G_CALLBACK (plug_in_progress_cancel_callback),
plug_in);
if (gimp_progress_is_active (proc_frame->progress))
{
if (message)
gimp_progress_set_text (proc_frame->progress, message);
if (gimp_progress_get_value (proc_frame->progress) > 0.0)
gimp_progress_set_value (proc_frame->progress, 0.0);
}
else
{
gimp_progress_start (proc_frame->progress,
message ? message : "",
TRUE);
}
}
}
void
plug_in_progress_end (PlugIn *plug_in)
{
PlugInProcFrame *proc_frame;
g_return_if_fail (plug_in != NULL);
proc_frame = plug_in_get_proc_frame (plug_in);
if (proc_frame->progress)
{
if (proc_frame->progress_cancel_id)
{
g_signal_handler_disconnect (proc_frame->progress,
proc_frame->progress_cancel_id);
proc_frame->progress_cancel_id = 0;
}
if (gimp_progress_is_active (proc_frame->progress))
gimp_progress_end (proc_frame->progress);
if (proc_frame->progress_created)
{
gimp_free_progress (plug_in->manager->gimp, proc_frame->progress);
g_object_unref (proc_frame->progress);
proc_frame->progress = NULL;
}
}
}
void
plug_in_progress_set_text (PlugIn *plug_in,
const gchar *message)
{
PlugInProcFrame *proc_frame;
g_return_if_fail (plug_in != NULL);
proc_frame = plug_in_get_proc_frame (plug_in);
if (proc_frame->progress)
gimp_progress_set_text (proc_frame->progress, message);
}
void
plug_in_progress_set_value (PlugIn *plug_in,
gdouble percentage)
{
PlugInProcFrame *proc_frame;
g_return_if_fail (plug_in != NULL);
proc_frame = plug_in_get_proc_frame (plug_in);
if (! proc_frame->progress ||
! gimp_progress_is_active (proc_frame->progress) ||
! proc_frame->progress_cancel_id)
{
plug_in_progress_start (plug_in, NULL, NULL);
}
if (proc_frame->progress && gimp_progress_is_active (proc_frame->progress))
gimp_progress_set_value (proc_frame->progress, percentage);
}
void
plug_in_progress_pulse (PlugIn *plug_in)
{
PlugInProcFrame *proc_frame;
g_return_if_fail (plug_in != NULL);
proc_frame = plug_in_get_proc_frame (plug_in);
if (! proc_frame->progress ||
! gimp_progress_is_active (proc_frame->progress) ||
! proc_frame->progress_cancel_id)
{
plug_in_progress_start (plug_in, NULL, NULL);
}
if (proc_frame->progress && gimp_progress_is_active (proc_frame->progress))
gimp_progress_pulse (proc_frame->progress);
}
guint32
plug_in_progress_get_window (PlugIn *plug_in)
{
PlugInProcFrame *proc_frame;
g_return_val_if_fail (plug_in != NULL, 0);
proc_frame = plug_in_get_proc_frame (plug_in);
if (proc_frame->progress)
return gimp_progress_get_window (proc_frame->progress);
return 0;
}
gboolean
plug_in_progress_install (PlugIn *plug_in,
const gchar *progress_callback)
{
PlugInProcFrame *proc_frame;
GimpProcedure *procedure;
g_return_val_if_fail (plug_in != NULL, FALSE);
g_return_val_if_fail (progress_callback != NULL, FALSE);
procedure = gimp_pdb_lookup_procedure (plug_in->manager->gimp->pdb,
progress_callback);
if (! GIMP_IS_TEMPORARY_PROCEDURE (procedure) ||
GIMP_TEMPORARY_PROCEDURE (procedure)->plug_in != plug_in ||
procedure->num_args != 3 ||
! GIMP_IS_PARAM_SPEC_INT32 (procedure->args[0]) ||
! G_IS_PARAM_SPEC_STRING (procedure->args[1]) ||
! G_IS_PARAM_SPEC_DOUBLE (procedure->args[2]))
{
return FALSE;
}
proc_frame = plug_in_get_proc_frame (plug_in);
if (proc_frame->progress)
{
plug_in_progress_end (plug_in);
if (proc_frame->progress)
{
g_object_unref (proc_frame->progress);
proc_frame->progress = NULL;
}
}
proc_frame->progress = g_object_new (GIMP_TYPE_PDB_PROGRESS,
"pdb", plug_in->manager->gimp->pdb,
"context", proc_frame->main_context,
"callback-name", progress_callback,
NULL);
return TRUE;
}
gboolean
plug_in_progress_uninstall (PlugIn *plug_in,
const gchar *progress_callback)
{
PlugInProcFrame *proc_frame;
g_return_val_if_fail (plug_in != NULL, FALSE);
g_return_val_if_fail (progress_callback != NULL, FALSE);
proc_frame = plug_in_get_proc_frame (plug_in);
if (GIMP_IS_PDB_PROGRESS (proc_frame->progress))
{
plug_in_progress_end (plug_in);
g_object_unref (proc_frame->progress);
proc_frame->progress = NULL;
return TRUE;
}
return FALSE;
}
gboolean
plug_in_progress_cancel (PlugIn *plug_in,
const gchar *progress_callback)
{
g_return_val_if_fail (plug_in != NULL, FALSE);
g_return_val_if_fail (progress_callback != NULL, FALSE);
return FALSE;
}
void
plug_in_progress_message (PlugIn *plug_in,
const gchar *message)
{
PlugInProcFrame *proc_frame;
gchar *domain;
g_return_if_fail (plug_in != NULL);
g_return_if_fail (message != NULL);
proc_frame = plug_in_get_proc_frame (plug_in);
domain = plug_in_get_undo_desc (plug_in);
if (proc_frame->progress)
{
gimp_progress_message (proc_frame->progress,
plug_in->manager->gimp, domain, message);
}
else
{
gimp_message (plug_in->manager->gimp, domain, message);
}
g_free (domain);
}
/* private functions */
static void
plug_in_progress_cancel_callback (GimpProgress *progress,
PlugIn *plug_in)
{
PlugInProcFrame *proc_frame = &plug_in->main_proc_frame;
GList *list;
if (proc_frame->main_loop)
{
proc_frame->return_vals = gimp_procedure_get_return_values (NULL,
FALSE);
g_value_set_enum (proc_frame->return_vals->values, GIMP_PDB_CANCEL);
}
for (list = plug_in->temp_proc_frames; list; list = g_list_next (list))
{
proc_frame = list->data;
if (proc_frame->main_loop)
{
proc_frame->return_vals = gimp_procedure_get_return_values (NULL,
FALSE);
g_value_set_enum (proc_frame->return_vals->values, GIMP_PDB_CANCEL);
}
}
plug_in_close (plug_in, TRUE);
plug_in_unref (plug_in);
}

View File

@ -1,47 +0,0 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* plug-in-progress.h
*
* 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.
*/
#ifndef __PLUG_IN_PROGRESS_H__
#define __PLUG_IN_PROGRESS_H__
void plug_in_progress_start (PlugIn *plug_in,
const gchar *message,
GimpObject *display);
void plug_in_progress_end (PlugIn *plug_in);
void plug_in_progress_set_text (PlugIn *plug_in,
const gchar *message);
void plug_in_progress_set_value (PlugIn *plug_in,
gdouble percentage);
void plug_in_progress_pulse (PlugIn *plug_in);
guint32 plug_in_progress_get_window (PlugIn *plug_in);
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);
void plug_in_progress_message (PlugIn *plug_in,
const gchar *message);
#endif /* __PLUG_IN_PROGRESS_H__ */

View File

@ -25,12 +25,12 @@
#include "plug-in/plug-in-enums.h"
typedef struct _GimpPlugIn GimpPlugIn;
typedef struct _GimpPlugInManager GimpPlugInManager;
typedef struct _GimpPlugInMenuBranch GimpPlugInMenuBranch;
typedef struct _GimpPlugInProcFrame GimpPlugInProcFrame;
typedef struct _GimpPlugInShm GimpPlugInShm;
typedef struct _PlugIn PlugIn;
typedef struct _PlugInDef PlugInDef;
typedef struct _PlugInProcFrame PlugInProcFrame;
#endif /* __PLUG_IN_TYPES_H__ */

View File

@ -1,961 +0,0 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* plug-in.c
*
* 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 <errno.h>
#include <signal.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef HAVE_SYS_WAIT_H
#include <sys/wait.h>
#endif
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
#include <glib-object.h>
#if defined(G_OS_WIN32) || defined(G_WITH_CYGWIN)
#define STRICT
#include <windows.h>
#include <process.h>
#ifdef G_OS_WIN32
#include <fcntl.h>
#include <io.h>
#endif
#ifdef G_WITH_CYGWIN
#define O_TEXT 0x0100 /* text file */
#define _O_TEXT 0x0100 /* text file */
#define O_BINARY 0x0200 /* binary file */
#define _O_BINARY 0x0200 /* binary file */
#endif
#endif /* G_OS_WIN32 || G_WITH_CYGWIN */
#include "libgimpbase/gimpbase.h"
#include "libgimpbase/gimpprotocol.h"
#include "libgimpbase/gimpwire.h"
#include "plug-in-types.h"
#include "core/gimp.h"
#include "core/gimpcontext.h"
#include "core/gimpprogress.h"
#include "pdb/gimptemporaryprocedure.h"
#include "gimpenvirontable.h"
#include "gimpinterpreterdb.h"
#include "gimpplugindebug.h"
#include "gimppluginmanager.h"
#include "gimppluginmanager-locale-domain.h"
#include "plug-in.h"
#include "plug-in-def.h"
#include "plug-in-message.h"
#include "plug-in-params.h"
#include "plug-in-progress.h"
#include "gimp-intl.h"
/* local funcion prototypes */
static gboolean plug_in_write (GIOChannel *channel,
const guint8 *buf,
gulong count,
gpointer data);
static gboolean plug_in_flush (GIOChannel *channel,
gpointer data);
static gboolean plug_in_recv_message (GIOChannel *channel,
GIOCondition cond,
gpointer data);
#if !defined(G_OS_WIN32) && !defined (G_WITH_CYGWIN)
static void plug_in_prep_for_exec (gpointer data);
#endif
void
plug_in_init (GimpPlugInManager *manager)
{
g_return_if_fail (GIMP_IS_PLUG_IN_MANAGER (manager));
/* initialize the gimp protocol library and set the read and
* write handlers.
*/
gp_init ();
gimp_wire_set_writer (plug_in_write);
gimp_wire_set_flusher (plug_in_flush);
}
void
plug_in_exit (GimpPlugInManager *manager)
{
GSList *list;
g_return_if_fail (GIMP_IS_PLUG_IN_MANAGER (manager));
list = manager->open_plug_ins;
while (list)
{
PlugIn *plug_in = list->data;
list = list->next;
if (plug_in->open)
plug_in_close (plug_in, TRUE);
plug_in_unref (plug_in);
}
}
PlugIn *
plug_in_new (GimpPlugInManager *manager,
GimpContext *context,
GimpProgress *progress,
GimpProcedure *procedure,
const gchar *prog)
{
PlugIn *plug_in;
g_return_val_if_fail (GIMP_IS_PLUG_IN_MANAGER (manager), NULL);
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
g_return_val_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress), NULL);
g_return_val_if_fail (prog != NULL, NULL);
g_return_val_if_fail (g_path_is_absolute (prog), NULL);
plug_in = g_new0 (PlugIn, 1);
plug_in->manager = manager;
plug_in->ref_count = 1;
plug_in->open = FALSE;
plug_in->call_mode = GIMP_PLUG_IN_CALL_NONE;
plug_in->pid = 0;
plug_in->name = g_path_get_basename (prog);
plug_in->prog = g_strdup (prog);
plug_in->my_read = NULL;
plug_in->my_write = NULL;
plug_in->his_read = NULL;
plug_in->his_write = NULL;
plug_in->input_id = 0;
plug_in->write_buffer_index = 0;
plug_in->temp_procedures = NULL;
plug_in->ext_main_loop = NULL;
plug_in_proc_frame_init (&plug_in->main_proc_frame,
context, progress, procedure);
plug_in->temp_proc_frames = NULL;
plug_in->plug_in_def = NULL;
return plug_in;
}
void
plug_in_ref (PlugIn *plug_in)
{
g_return_if_fail (plug_in != NULL);
plug_in->ref_count++;
}
void
plug_in_unref (PlugIn *plug_in)
{
g_return_if_fail (plug_in != NULL);
plug_in->ref_count--;
if (plug_in->ref_count < 1)
{
if (plug_in->open)
plug_in_close (plug_in, TRUE);
g_free (plug_in->name);
g_free (plug_in->prog);
plug_in_proc_frame_dispose (&plug_in->main_proc_frame, plug_in);
g_free (plug_in);
}
}
#if !defined(G_OS_WIN32) && !defined (G_WITH_CYGWIN)
static void
plug_in_prep_for_exec (gpointer data)
{
PlugIn *plug_in = data;
g_io_channel_unref (plug_in->my_read);
plug_in->my_read = NULL;
g_io_channel_unref (plug_in->my_write);
plug_in->my_write = NULL;
}
#else
#define plug_in_prep_for_exec NULL
#endif
gboolean
plug_in_open (PlugIn *plug_in,
GimpPlugInCallMode call_mode,
gboolean synchronous)
{
gint my_read[2];
gint my_write[2];
gchar **envp;
gchar *args[9], **argv;
gint argc;
gchar *interp, *interp_arg;
gchar *read_fd, *write_fd;
gchar *mode, *stm;
GError *error = NULL;
gboolean debug;
guint debug_flag;
guint spawn_flags;
g_return_val_if_fail (plug_in != NULL, FALSE);
g_return_val_if_fail (plug_in->call_mode == GIMP_PLUG_IN_CALL_NONE, FALSE);
/* Open two pipes. (Bidirectional communication).
*/
if ((pipe (my_read) == -1) || (pipe (my_write) == -1))
{
g_message ("Unable to run plug-in \"%s\"\n(%s)\n\npipe() failed: %s",
gimp_filename_to_utf8 (plug_in->name),
gimp_filename_to_utf8 (plug_in->prog),
g_strerror (errno));
return FALSE;
}
#if defined(G_WITH_CYGWIN)
/* Set to binary mode */
setmode (my_read[0], _O_BINARY);
setmode (my_write[0], _O_BINARY);
setmode (my_read[1], _O_BINARY);
setmode (my_write[1], _O_BINARY);
#endif
plug_in->my_read = g_io_channel_unix_new (my_read[0]);
plug_in->my_write = g_io_channel_unix_new (my_write[1]);
plug_in->his_read = g_io_channel_unix_new (my_write[0]);
plug_in->his_write = g_io_channel_unix_new (my_read[1]);
g_io_channel_set_encoding (plug_in->my_read, NULL, NULL);
g_io_channel_set_encoding (plug_in->my_write, NULL, NULL);
g_io_channel_set_encoding (plug_in->his_read, NULL, NULL);
g_io_channel_set_encoding (plug_in->his_write, NULL, NULL);
g_io_channel_set_buffered (plug_in->my_read, FALSE);
g_io_channel_set_buffered (plug_in->my_write, FALSE);
g_io_channel_set_buffered (plug_in->his_read, FALSE);
g_io_channel_set_buffered (plug_in->his_write, FALSE);
g_io_channel_set_close_on_unref (plug_in->my_read, TRUE);
g_io_channel_set_close_on_unref (plug_in->my_write, TRUE);
g_io_channel_set_close_on_unref (plug_in->his_read, TRUE);
g_io_channel_set_close_on_unref (plug_in->his_write, TRUE);
/* Remember the file descriptors for the pipes.
*/
read_fd = g_strdup_printf ("%d",
g_io_channel_unix_get_fd (plug_in->his_read));
write_fd = g_strdup_printf ("%d",
g_io_channel_unix_get_fd (plug_in->his_write));
switch (call_mode)
{
case GIMP_PLUG_IN_CALL_QUERY:
mode = "-query";
debug_flag = GIMP_DEBUG_WRAP_QUERY;
break;
case GIMP_PLUG_IN_CALL_INIT:
mode = "-init";
debug_flag = GIMP_DEBUG_WRAP_INIT;
break;
case GIMP_PLUG_IN_CALL_RUN:
mode = "-run";
debug_flag = GIMP_DEBUG_WRAP_RUN;
break;
default:
g_assert_not_reached ();
}
stm = g_strdup_printf ("%d", plug_in->manager->gimp->stack_trace_mode);
interp = gimp_interpreter_db_resolve (plug_in->manager->interpreter_db,
plug_in->prog, &interp_arg);
argc = 0;
if (interp)
args[argc++] = interp;
if (interp_arg)
args[argc++] = interp_arg;
args[argc++] = plug_in->prog;
args[argc++] = "-gimp";
args[argc++] = read_fd;
args[argc++] = write_fd;
args[argc++] = mode;
args[argc++] = stm;
args[argc++] = NULL;
argv = args;
envp = gimp_environ_table_get_envp (plug_in->manager->environ_table);
spawn_flags = (G_SPAWN_LEAVE_DESCRIPTORS_OPEN |
G_SPAWN_DO_NOT_REAP_CHILD |
G_SPAWN_CHILD_INHERITS_STDIN);
debug = FALSE;
if (plug_in->manager->debug)
{
gchar **debug_argv = gimp_plug_in_debug_argv (plug_in->manager->debug,
plug_in->name,
debug_flag, args);
if (debug_argv)
{
debug = TRUE;
argv = debug_argv;
spawn_flags |= G_SPAWN_SEARCH_PATH;
}
}
/* Fork another process. We'll remember the process id so that we
* can later use it to kill the filter if necessary.
*/
if (! g_spawn_async (NULL, argv, envp, spawn_flags,
plug_in_prep_for_exec, plug_in,
&plug_in->pid,
&error))
{
g_message ("Unable to run plug-in \"%s\"\n(%s)\n\n%s",
gimp_filename_to_utf8 (plug_in->name),
gimp_filename_to_utf8 (plug_in->prog),
error->message);
g_error_free (error);
goto cleanup;
}
g_io_channel_unref (plug_in->his_read);
plug_in->his_read = NULL;
g_io_channel_unref (plug_in->his_write);
plug_in->his_write = NULL;
if (! synchronous)
{
GSource *source;
source = g_io_create_watch (plug_in->my_read,
G_IO_IN | G_IO_PRI | G_IO_ERR | G_IO_HUP);
g_source_set_callback (source,
(GSourceFunc) plug_in_recv_message, plug_in,
NULL);
g_source_set_can_recurse (source, TRUE);
plug_in->input_id = g_source_attach (source, NULL);
g_source_unref (source);
plug_in->manager->open_plug_ins =
g_slist_prepend (plug_in->manager->open_plug_ins, plug_in);
}
plug_in->open = TRUE;
plug_in->call_mode = call_mode;
cleanup:
if (debug)
g_free (argv);
g_free (read_fd);
g_free (write_fd);
g_free (stm);
g_free (interp);
g_free (interp_arg);
return plug_in->open;
}
void
plug_in_close (PlugIn *plug_in,
gboolean kill_it)
{
GList *list;
g_return_if_fail (plug_in != NULL);
g_return_if_fail (plug_in->open == TRUE);
if (! plug_in->open)
return;
plug_in->open = FALSE;
if (plug_in->pid)
{
#ifndef G_OS_WIN32
gint status;
#endif
/* Ask the filter to exit gracefully */
if (kill_it)
{
gp_quit_write (plug_in->my_write, plug_in);
/* give the plug-in some time (10 ms) */
g_usleep (10000);
}
/* If necessary, kill the filter. */
#ifndef G_OS_WIN32
if (kill_it)
{
if (plug_in->manager->gimp->be_verbose)
g_print (_("Terminating plug-in: '%s'\n"),
gimp_filename_to_utf8 (plug_in->prog));
status = kill (plug_in->pid, SIGKILL);
}
/* Wait for the process to exit. This will happen
* immediately if it was just killed.
*/
waitpid (plug_in->pid, &status, 0);
#else /* G_OS_WIN32 */
if (kill_it)
{
/* Trying to avoid TerminateProcess (does mostly work).
* Otherwise some of our needed DLLs may get into an
* unstable state (see Win32 API docs).
*/
DWORD dwExitCode = STILL_ACTIVE;
DWORD dwTries = 10;
while (dwExitCode == dwExitCode &&
GetExitCodeProcess ((HANDLE) plug_in->pid, &dwExitCode) &&
(dwTries > 0))
{
Sleep (10);
dwTries--;
}
if (dwExitCode == STILL_ACTIVE)
{
if (plug_in->manager->gimp->be_verbose)
g_print (_("Terminating plug-in: '%s'\n"),
gimp_filename_to_utf8 (plug_in->prog));
TerminateProcess ((HANDLE) plug_in->pid, 0);
}
}
#endif /* G_OS_WIN32 */
g_spawn_close_pid (plug_in->pid);
plug_in->pid = 0;
}
/* Remove the input handler. */
if (plug_in->input_id)
{
g_source_remove (plug_in->input_id);
plug_in->input_id = 0;
}
/* Close the pipes. */
if (plug_in->my_read != NULL)
{
g_io_channel_unref (plug_in->my_read);
plug_in->my_read = NULL;
}
if (plug_in->my_write != NULL)
{
g_io_channel_unref (plug_in->my_write);
plug_in->my_write = NULL;
}
if (plug_in->his_read != NULL)
{
g_io_channel_unref (plug_in->his_read);
plug_in->his_read = NULL;
}
if (plug_in->his_write != NULL)
{
g_io_channel_unref (plug_in->his_write);
plug_in->his_write = NULL;
}
gimp_wire_clear_error ();
for (list = plug_in->temp_proc_frames; list; list = g_list_next (list))
{
PlugInProcFrame *proc_frame = list->data;
#ifdef GIMP_UNSTABLE
g_printerr ("plug_in_close: plug-in aborted before sending its "
"temporary procedure return values\n");
#endif
if (proc_frame->main_loop &&
g_main_loop_is_running (proc_frame->main_loop))
{
g_main_loop_quit (proc_frame->main_loop);
}
}
if (plug_in->main_proc_frame.main_loop &&
g_main_loop_is_running (plug_in->main_proc_frame.main_loop))
{
#ifdef GIMP_UNSTABLE
g_printerr ("plug_in_close: plug-in aborted before sending its "
"procedure return values\n");
#endif
g_main_loop_quit (plug_in->main_proc_frame.main_loop);
}
plug_in_proc_frame_dispose (&plug_in->main_proc_frame, plug_in);
if (plug_in->ext_main_loop &&
g_main_loop_is_running (plug_in->ext_main_loop))
{
#ifdef GIMP_UNSTABLE
g_printerr ("plug_in_close: extension aborted before sending its "
"extension_ack message\n");
#endif
g_main_loop_quit (plug_in->ext_main_loop);
}
/* Unregister any temporary procedures. */
while (plug_in->temp_procedures)
plug_in_remove_temp_proc (plug_in, plug_in->temp_procedures->data);
/* Close any dialogs that this plugin might have opened */
gimp_pdb_dialogs_check (plug_in->manager->gimp);
plug_in->manager->open_plug_ins =
g_slist_remove (plug_in->manager->open_plug_ins, plug_in);
}
static gboolean
plug_in_recv_message (GIOChannel *channel,
GIOCondition cond,
gpointer data)
{
PlugIn *plug_in = data;
gboolean got_message = FALSE;
#ifdef G_OS_WIN32
/* Workaround for GLib bug #137968: sometimes we are called for no
* reason...
*/
if (cond == 0)
return TRUE;
#endif
if (plug_in->my_read == NULL)
return TRUE;
if (cond & (G_IO_IN | G_IO_PRI))
{
GimpWireMessage msg;
memset (&msg, 0, sizeof (GimpWireMessage));
if (! gimp_wire_read_msg (plug_in->my_read, &msg, plug_in))
{
plug_in_close (plug_in, TRUE);
}
else
{
plug_in_handle_message (plug_in, &msg);
gimp_wire_destroy (&msg);
got_message = TRUE;
}
}
if (cond & (G_IO_ERR | G_IO_HUP))
{
if (plug_in->open)
{
plug_in_close (plug_in, TRUE);
}
}
if (! got_message)
g_message (_("Plug-in crashed: \"%s\"\n(%s)\n\n"
"The dying plug-in may have messed up GIMP's internal state. "
"You may want to save your images and restart GIMP "
"to be on the safe side."),
gimp_filename_to_utf8 (plug_in->name),
gimp_filename_to_utf8 (plug_in->prog));
if (! plug_in->open)
plug_in_unref (plug_in);
return TRUE;
}
static gboolean
plug_in_write (GIOChannel *channel,
const guint8 *buf,
gulong count,
gpointer data)
{
PlugIn *plug_in = data;
gulong bytes;
while (count > 0)
{
if ((plug_in->write_buffer_index + count) >= WRITE_BUFFER_SIZE)
{
bytes = WRITE_BUFFER_SIZE - plug_in->write_buffer_index;
memcpy (&plug_in->write_buffer[plug_in->write_buffer_index],
buf, bytes);
plug_in->write_buffer_index += bytes;
if (! gimp_wire_flush (channel, plug_in))
return FALSE;
}
else
{
bytes = count;
memcpy (&plug_in->write_buffer[plug_in->write_buffer_index],
buf, bytes);
plug_in->write_buffer_index += bytes;
}
buf += bytes;
count -= bytes;
}
return TRUE;
}
static gboolean
plug_in_flush (GIOChannel *channel,
gpointer data)
{
PlugIn *plug_in = data;
if (plug_in->write_buffer_index > 0)
{
GIOStatus status;
GError *error = NULL;
gint count;
gsize bytes;
count = 0;
while (count != plug_in->write_buffer_index)
{
do
{
bytes = 0;
status = g_io_channel_write_chars (channel,
&plug_in->write_buffer[count],
(plug_in->write_buffer_index - count),
&bytes,
&error);
}
while (status == G_IO_STATUS_AGAIN);
if (status != G_IO_STATUS_NORMAL)
{
if (error)
{
g_warning ("%s: plug_in_flush(): error: %s",
gimp_filename_to_utf8 (g_get_prgname ()),
error->message);
g_error_free (error);
}
else
{
g_warning ("%s: plug_in_flush(): error",
gimp_filename_to_utf8 (g_get_prgname ()));
}
return FALSE;
}
count += bytes;
}
plug_in->write_buffer_index = 0;
}
return TRUE;
}
PlugInProcFrame *
plug_in_get_proc_frame (PlugIn *plug_in)
{
g_return_val_if_fail (plug_in != NULL, NULL);
if (plug_in->temp_proc_frames)
return plug_in->temp_proc_frames->data;
else
return &plug_in->main_proc_frame;
}
PlugInProcFrame *
plug_in_proc_frame_push (PlugIn *plug_in,
GimpContext *context,
GimpProgress *progress,
GimpProcedure *procedure)
{
PlugInProcFrame *proc_frame;
g_return_val_if_fail (plug_in != NULL, NULL);
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
g_return_val_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress), NULL);
g_return_val_if_fail (GIMP_IS_PROCEDURE (procedure), NULL);
proc_frame = plug_in_proc_frame_new (context, progress, procedure);
plug_in->temp_proc_frames = g_list_prepend (plug_in->temp_proc_frames,
proc_frame);
return proc_frame;
}
void
plug_in_proc_frame_pop (PlugIn *plug_in)
{
PlugInProcFrame *proc_frame;
g_return_if_fail (plug_in != NULL);
g_return_if_fail (plug_in->temp_proc_frames != NULL);
proc_frame = (PlugInProcFrame *) plug_in->temp_proc_frames->data;
plug_in_proc_frame_unref (proc_frame, plug_in);
plug_in->temp_proc_frames = g_list_remove (plug_in->temp_proc_frames,
proc_frame);
}
void
plug_in_main_loop (PlugIn *plug_in)
{
PlugInProcFrame *proc_frame;
g_return_if_fail (plug_in != NULL);
g_return_if_fail (plug_in->temp_proc_frames != NULL);
proc_frame = (PlugInProcFrame *) plug_in->temp_proc_frames->data;
g_return_if_fail (proc_frame->main_loop == NULL);
proc_frame->main_loop = g_main_loop_new (NULL, FALSE);
gimp_threads_leave (plug_in->manager->gimp);
g_main_loop_run (proc_frame->main_loop);
gimp_threads_enter (plug_in->manager->gimp);
g_main_loop_unref (proc_frame->main_loop);
proc_frame->main_loop = NULL;
}
void
plug_in_main_loop_quit (PlugIn *plug_in)
{
PlugInProcFrame *proc_frame;
g_return_if_fail (plug_in != NULL);
g_return_if_fail (plug_in->temp_proc_frames != NULL);
proc_frame = (PlugInProcFrame *) plug_in->temp_proc_frames->data;
g_return_if_fail (proc_frame->main_loop != NULL);
g_main_loop_quit (proc_frame->main_loop);
}
gchar *
plug_in_get_undo_desc (PlugIn *plug_in)
{
PlugInProcFrame *proc_frame = NULL;
GimpPlugInProcedure *proc = NULL;
gchar *undo_desc = NULL;
g_return_val_if_fail (plug_in != NULL, NULL);
proc_frame = plug_in_get_proc_frame (plug_in);
if (proc_frame)
proc = GIMP_PLUG_IN_PROCEDURE (proc_frame->procedure);
if (proc)
{
const gchar *domain;
domain = gimp_plug_in_manager_get_locale_domain (plug_in->manager,
plug_in->prog, NULL);
undo_desc = gimp_plug_in_procedure_get_label (proc, domain);
}
if (! undo_desc)
undo_desc = g_filename_display_name (plug_in->name);
return undo_desc;
}
/* called from the PDB (gimp_plugin_menu_register) */
gboolean
plug_in_menu_register (PlugIn *plug_in,
const gchar *proc_name,
const gchar *menu_path)
{
GimpPlugInProcedure *proc = NULL;
GError *error = NULL;
g_return_val_if_fail (plug_in != NULL, FALSE);
g_return_val_if_fail (proc_name != NULL, FALSE);
g_return_val_if_fail (menu_path != NULL, FALSE);
if (plug_in->plug_in_def)
proc = gimp_plug_in_procedure_find (plug_in->plug_in_def->procedures,
proc_name);
if (! proc)
proc = gimp_plug_in_procedure_find (plug_in->temp_procedures, proc_name);
if (! proc)
{
g_message ("Plug-in \"%s\"\n(%s)\n"
"attempted to register the menu item \"%s\" "
"for the procedure \"%s\".\n"
"It has however not installed that procedure. This "
"is not allowed.",
gimp_filename_to_utf8 (plug_in->name),
gimp_filename_to_utf8 (plug_in->prog),
menu_path, proc_name);
return FALSE;
}
switch (GIMP_PROCEDURE (proc)->proc_type)
{
case GIMP_INTERNAL:
return FALSE;
case GIMP_PLUGIN:
case GIMP_EXTENSION:
if (plug_in->call_mode != GIMP_PLUG_IN_CALL_QUERY &&
plug_in->call_mode != GIMP_PLUG_IN_CALL_INIT)
return FALSE;
case GIMP_TEMPORARY:
break;
}
if (! proc->menu_label)
{
g_message ("Plug-in \"%s\"\n(%s)\n"
"attempted to register the menu item \"%s\" "
"for procedure \"%s\".\n"
"The menu label given in gimp_install_procedure() "
"already contained a path. To make this work, "
"pass just the menu's label to "
"gimp_install_procedure().",
gimp_filename_to_utf8 (plug_in->name),
gimp_filename_to_utf8 (plug_in->prog),
menu_path, proc_name);
return FALSE;
}
if (! gimp_plug_in_procedure_add_menu_path (proc, menu_path, &error))
{
g_message (error->message);
g_clear_error (&error);
return FALSE;
}
return TRUE;
}
void
plug_in_add_temp_proc (PlugIn *plug_in,
GimpTemporaryProcedure *proc)
{
g_return_if_fail (plug_in != NULL);
g_return_if_fail (GIMP_IS_TEMPORARY_PROCEDURE (proc));
plug_in->temp_procedures = g_slist_prepend (plug_in->temp_procedures,
g_object_ref (proc));
gimp_plug_in_manager_add_temp_proc (plug_in->manager, proc);
}
void
plug_in_remove_temp_proc (PlugIn *plug_in,
GimpTemporaryProcedure *proc)
{
g_return_if_fail (plug_in != NULL);
g_return_if_fail (GIMP_IS_TEMPORARY_PROCEDURE (proc));
plug_in->temp_procedures = g_slist_remove (plug_in->temp_procedures,
proc);
gimp_plug_in_manager_remove_temp_proc (plug_in->manager, proc);
g_object_unref (proc);
}

View File

@ -1,108 +0,0 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* plug-in.h
*
* 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.
*/
#ifndef __PLUG_IN_H__
#define __PLUG_IN_H__
#include "plug-in-proc-frame.h"
#define WRITE_BUFFER_SIZE 512
struct _PlugIn
{
GimpPlugInManager *manager;
gint ref_count;
guint open : 1; /* Is the plug-in open? */
GimpPlugInCallMode call_mode;
GPid pid; /* Plug-in's process id */
gchar *name; /* Plug-in's name */
gchar *prog; /* Plug-in's full path name */
GIOChannel *my_read; /* App's read and write channels */
GIOChannel *my_write;
GIOChannel *his_read; /* Plug-in's read and write channels */
GIOChannel *his_write;
guint input_id; /* Id of input proc */
gchar write_buffer[WRITE_BUFFER_SIZE]; /* Buffer for writing */
gint write_buffer_index; /* Buffer index */
GSList *temp_procedures; /* Temporary procedures */
GMainLoop *ext_main_loop; /* for waiting for extension_ack */
PlugInProcFrame main_proc_frame;
GList *temp_proc_frames;
PlugInDef *plug_in_def; /* Valid during query() and init() */
};
void plug_in_init (GimpPlugInManager *manager);
void plug_in_exit (GimpPlugInManager *manager);
PlugIn * plug_in_new (GimpPlugInManager *manager,
GimpContext *context,
GimpProgress *progress,
GimpProcedure *procedure,
const gchar *prog);
void plug_in_ref (PlugIn *plug_in);
void plug_in_unref (PlugIn *plug_in);
gboolean plug_in_open (PlugIn *plug_in,
GimpPlugInCallMode call_mode,
gboolean synchronous);
void plug_in_close (PlugIn *plug_in,
gboolean kill_it);
PlugInProcFrame * plug_in_get_proc_frame (PlugIn *plug_in);
PlugInProcFrame * plug_in_proc_frame_push (PlugIn *plug_in,
GimpContext *context,
GimpProgress *progress,
GimpProcedure *procedure);
void plug_in_proc_frame_pop (PlugIn *plug_in);
void plug_in_main_loop (PlugIn *plug_in);
void plug_in_main_loop_quit (PlugIn *plug_in);
gchar * plug_in_get_undo_desc (PlugIn *plug_in);
gboolean plug_in_menu_register (PlugIn *plug_in,
const gchar *proc_name,
const gchar *menu_path);
void plug_in_add_temp_proc (PlugIn *plug_in,
GimpTemporaryProcedure *proc);
void plug_in_remove_temp_proc (PlugIn *plug_in,
GimpTemporaryProcedure *proc);
#endif /* __PLUG_IN_H__ */

View File

@ -38,9 +38,10 @@ HELP
%invoke = (
code => <<'CODE'
{
if (gimp->plug_in_manager->current_plug_in &&
gimp->plug_in_manager->current_plug_in->open)
success = plug_in_context_push (gimp->plug_in_manager->current_plug_in);
GimpPlugIn *plug_in = gimp->plug_in_manager->current_plug_in;
if (plug_in && plug_in->open)
success = gimp_plug_in_context_push (plug_in);
else
success = FALSE;
}
@ -62,9 +63,10 @@ HELP
%invoke = (
code => <<'CODE'
{
if (gimp->plug_in_manager->current_plug_in &&
gimp->plug_in_manager->current_plug_in->open)
success = plug_in_context_pop (gimp->plug_in_manager->current_plug_in);
GimpPlugIn *plug_in = gimp->plug_in_manager->current_plug_in;
if (plug_in && plug_in->open)
success = gimp_plug_in_context_pop (plug_in);
else
success = FALSE;
}
@ -684,10 +686,13 @@ CODE
}
@headers = qw("core/gimp.h" "core/gimpcontainer.h" "core/gimpcontext.h"
@headers = qw("core/gimp.h"
"core/gimpcontainer.h"
"core/gimpcontext.h"
"core/gimpdatafactory.h"
"plug-in/gimppluginmanager.h" "plug-in/plug-in.h"
"plug-in/plug-in-context.h");
"plug-in/gimpplugin.h"
"plug-in/gimpplugin-context.h"
"plug-in/gimppluginmanager.h");
@procs = qw(context_push context_pop
context_get_paint_method context_set_paint_method

View File

@ -38,7 +38,7 @@ HELP
);
%invoke = (
headers => [ qw("plug-in/gimppluginmanager.h" "plug-in/plug-in.h") ],
headers => [ qw("plug-in/gimpplugin.h" "plug-in/gimppluginmanager.h") ],
code => <<'CODE'
{
if (gimp_item_is_attached (GIMP_ITEM (drawable)))
@ -46,7 +46,7 @@ HELP
gchar *undo_desc = NULL;
if (gimp->plug_in_manager->current_plug_in)
undo_desc = plug_in_get_undo_desc (gimp->plug_in_manager->current_plug_in);
undo_desc = gimp_plug_in_get_undo_desc (gimp->plug_in_manager->current_plug_in);
if (! undo_desc)
undo_desc = g_strdup (_("Plug-In"));
@ -1237,10 +1237,15 @@ CODE
}
@headers = qw("base/tile.h" "base/tile-manager.h" "base/temp-buf.h"
@headers = qw("base/tile.h"
"base/tile-manager.h"
"base/temp-buf.h"
"config/gimpcoreconfig.h"
"core/gimp.h" "core/gimplayer.h" "core/gimplayermask.h"
"core/gimpdrawable-offset.h" "gimp-intl.h");
"core/gimp.h"
"core/gimpdrawable-offset.h"
"core/gimplayer.h"
"core/gimplayermask.h"
"gimp-intl.h");
@procs = qw(drawable_delete
drawable_is_layer drawable_is_layer_mask drawable_is_channel

View File

@ -57,9 +57,9 @@ CODE
@headers = qw("core/gimp.h"
"plug-in/gimpplugin.h"
"plug-in/gimppluginmanager.h"
"plug-in/gimppluginmanager-help-domain.h"
"plug-in/plug-in.h");
"plug-in/gimppluginmanager-help-domain.h");
@procs = qw(help);

View File

@ -36,7 +36,8 @@ HELP
code => <<'CODE'
{
if (gimp->plug_in_manager->current_plug_in)
plug_in_progress_message (gimp->plug_in_manager->current_plug_in, message);
gimp_plug_in_progress_message (gimp->plug_in_manager->current_plug_in,
message);
else
gimp_message (gimp, NULL, message);
}
@ -95,9 +96,12 @@ CODE
}
@headers = qw(<string.h> "core/gimp.h"
"plug-in/gimppluginmanager.h" "plug-in/plug-in.h"
"plug-in/plug-in-progress.h" "gimp-intl.h");
@headers = qw(<string.h>
"core/gimp.h"
"plug-in/gimpplugin.h"
"plug-in/gimpplugin-progress.h"
"plug-in/gimppluginmanager.h"
"gimp-intl.h");
@procs = qw(message message_get_handler message_set_handler);

View File

@ -99,7 +99,7 @@ HELP
%invoke = (
code => <<'CODE'
{
PlugIn *plug_in = gimp->plug_in_manager->current_plug_in;
GimpPlugIn *plug_in = gimp->plug_in_manager->current_plug_in;
if (plug_in && plug_in->call_mode == GIMP_PLUG_IN_CALL_QUERY)
{
@ -134,7 +134,7 @@ HELP
%invoke = (
code => <<'CODE'
{
PlugIn *plug_in = gimp->plug_in_manager->current_plug_in;
GimpPlugIn *plug_in = gimp->plug_in_manager->current_plug_in;
if (plug_in && plug_in->call_mode == GIMP_PLUG_IN_CALL_QUERY)
{
@ -167,12 +167,12 @@ HELP
%invoke = (
code => <<'CODE'
{
PlugIn *plug_in = gimp->plug_in_manager->current_plug_in;
GimpPlugIn *plug_in = gimp->plug_in_manager->current_plug_in;
if (plug_in)
{
gchar *canonical = gimp_canonicalize_identifier (procedure_name);
success = plug_in_menu_register (plug_in, canonical, menu_path);
success = gimp_plug_in_menu_register (plug_in, canonical, menu_path);
g_free (canonical);
}
else
@ -203,7 +203,7 @@ HELP
%invoke = (
code => <<'CODE'
{
PlugIn *plug_in = gimp->plug_in_manager->current_plug_in;
GimpPlugIn *plug_in = gimp->plug_in_manager->current_plug_in;
if (plug_in)
{
@ -241,7 +241,7 @@ HELP
%invoke = (
code => <<'CODE'
{
PlugIn *plug_in = gimp->plug_in_manager->current_plug_in;
GimpPlugIn *plug_in = gimp->plug_in_manager->current_plug_in;
if (plug_in && plug_in->call_mode == GIMP_PLUG_IN_CALL_QUERY)
{
@ -271,10 +271,10 @@ CODE
@headers = qw(<string.h> <stdlib.h>
"libgimpbase/gimpbase.h" "core/gimp.h"
"plug-in/gimpplugin.h"
"plug-in/gimppluginmanager.h"
"plug-in/gimppluginmanager-menu-branch.h"
"plug-in/gimppluginmanager-query.h"
"plug-in/plug-in.h"
"plug-in/plug-in-def.h"
"gimppluginprocedure.h");

View File

@ -38,12 +38,12 @@ HELP
%invoke = (
code => <<'CODE'
{
PlugIn *plug_in = gimp->plug_in_manager->current_plug_in;
GimpPlugIn *plug_in = gimp->plug_in_manager->current_plug_in;
if (plug_in && plug_in->open)
{
if (! gimp->no_interface)
plug_in_progress_start (plug_in, message, gdisplay);
gimp_plug_in_progress_start (plug_in, message, gdisplay);
}
else
success = FALSE;
@ -71,12 +71,12 @@ HELP
%invoke = (
code => <<'CODE'
{
PlugIn *plug_in = gimp->plug_in_manager->current_plug_in;
GimpPlugIn *plug_in = gimp->plug_in_manager->current_plug_in;
if (plug_in && plug_in->open)
{
if (! gimp->no_interface)
plug_in_progress_set_value (plug_in, percentage);
gimp_plug_in_progress_set_value (plug_in, percentage);
}
else
success = FALSE;
@ -101,12 +101,12 @@ HELP
%invoke = (
code => <<'CODE'
{
PlugIn *plug_in = gimp->plug_in_manager->current_plug_in;
GimpPlugIn *plug_in = gimp->plug_in_manager->current_plug_in;
if (plug_in && plug_in->open)
{
if (! gimp->no_interface)
plug_in_progress_pulse (plug_in);
gimp_plug_in_progress_pulse (plug_in);
}
else
success = FALSE;
@ -134,12 +134,12 @@ HELP
%invoke = (
code => <<'CODE'
{
PlugIn *plug_in = gimp->plug_in_manager->current_plug_in;
GimpPlugIn *plug_in = gimp->plug_in_manager->current_plug_in;
if (plug_in && plug_in->open)
{
if (! gimp->no_interface)
plug_in_progress_set_text (plug_in, message);
gimp_plug_in_progress_set_text (plug_in, message);
}
else
success = FALSE;
@ -165,12 +165,12 @@ HELP
%invoke = (
code => <<'CODE'
{
PlugIn *plug_in = gimp->plug_in_manager->current_plug_in;
GimpPlugIn *plug_in = gimp->plug_in_manager->current_plug_in;
if (plug_in && plug_in->open)
{
if (! gimp->no_interface)
window = plug_in_progress_get_window (plug_in);
window = gimp_plug_in_progress_get_window (plug_in);
}
else
success = FALSE;
@ -199,10 +199,10 @@ HELP
%invoke = (
code => <<'CODE'
{
PlugIn *plug_in = gimp->plug_in_manager->current_plug_in;
GimpPlugIn *plug_in = gimp->plug_in_manager->current_plug_in;
if (plug_in && plug_in->open)
success = plug_in_progress_install (plug_in, progress_callback);
success = gimp_plug_in_progress_install (plug_in, progress_callback);
else
success = FALSE;
}
@ -229,10 +229,10 @@ HELP
%invoke = (
code => <<'CODE'
{
PlugIn *plug_in = gimp->plug_in_manager->current_plug_in;
GimpPlugIn *plug_in = gimp->plug_in_manager->current_plug_in;
if (plug_in && plug_in->open)
success = plug_in_progress_uninstall (plug_in, progress_callback);
success = gimp_plug_in_progress_uninstall (plug_in, progress_callback);
else
success = FALSE;
}
@ -257,10 +257,10 @@ HELP
%invoke = (
code => <<'CODE'
{
PlugIn *plug_in = gimp->plug_in_manager->current_plug_in;
GimpPlugIn *plug_in = gimp->plug_in_manager->current_plug_in;
if (plug_in && plug_in->open)
success = plug_in_progress_cancel (plug_in, progress_callback);
success = gimp_plug_in_progress_cancel (plug_in, progress_callback);
else
success = FALSE;
}
@ -269,8 +269,10 @@ CODE
}
@headers = qw("core/gimp.h" "plug-in/gimppluginmanager.h"
"plug-in/plug-in.h" "plug-in/plug-in-progress.h");
@headers = qw("core/gimp.h"
"plug-in/gimpplugin.h"
"plug-in/gimpplugin-progress.h"
"plug-in/gimppluginmanager.h");
@procs = qw(progress_init progress_update progress_pulse progress_set_text
progress_get_window_handle

View File

@ -36,14 +36,14 @@ HELP
%invoke = (
headers => [ qw("core/gimp.h" "plug-in/gimppluginmanager.h"
"plug-in/plug-in.h") ],
"plug-in/gimpplugin.h") ],
code => <<'CODE'
{
PlugIn *plug_in = gimp->plug_in_manager->current_plug_in;
gchar *undo_desc = NULL;
GimpPlugIn *plug_in = gimp->plug_in_manager->current_plug_in;
gchar *undo_desc = NULL;
if (plug_in)
undo_desc = plug_in_get_undo_desc (plug_in);
undo_desc = gimp_plug_in_get_undo_desc (plug_in);
gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_MISC, undo_desc);