2006-12-10 05:33:38 +08:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
2006-04-29 06:26:51 +08:00
|
|
|
* Copyright (C) 1995-2002 Spencer Kimball, Peter Mattis, and others
|
1997-11-25 06:05:25 +08:00
|
|
|
*
|
2006-04-29 06:26:51 +08:00
|
|
|
* gimppluginmanager.c
|
2004-09-22 23:12:24 +08:00
|
|
|
*
|
1997-11-25 06:05:25 +08:00
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
1998-04-13 13:44:11 +08:00
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
1997-11-25 06:05:25 +08:00
|
|
|
*/
|
2000-07-16 20:49:04 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
#include "config.h"
|
1999-03-07 20:56:03 +08:00
|
|
|
|
2006-04-10 07:40:45 +08:00
|
|
|
#include <string.h>
|
1999-06-22 04:04:04 +08:00
|
|
|
|
2003-09-11 06:06:45 +08:00
|
|
|
#include <glib-object.h>
|
1999-06-15 06:18:02 +08:00
|
|
|
|
2001-05-21 21:58:46 +08:00
|
|
|
#include "libgimpbase/gimpbase.h"
|
2005-01-26 03:11:26 +08:00
|
|
|
#include "libgimpconfig/gimpconfig.h"
|
2001-05-09 10:32:03 +08:00
|
|
|
|
2001-12-01 08:14:14 +08:00
|
|
|
#include "plug-in-types.h"
|
2001-05-22 04:30:16 +08:00
|
|
|
|
2002-11-19 04:50:31 +08:00
|
|
|
#include "config/gimpcoreconfig.h"
|
|
|
|
|
2001-07-11 20:39:49 +08:00
|
|
|
#include "core/gimp.h"
|
2006-04-29 06:26:51 +08:00
|
|
|
#include "core/gimp-utils.h"
|
2001-10-17 19:33:43 +08:00
|
|
|
#include "core/gimpcontext.h"
|
2006-04-29 06:26:51 +08:00
|
|
|
#include "core/gimpmarshal.h"
|
2001-04-18 05:43:29 +08:00
|
|
|
|
2006-04-26 17:13:47 +08:00
|
|
|
#include "pdb/gimppdb.h"
|
2006-03-31 17:15:08 +08:00
|
|
|
|
2006-04-29 06:26:51 +08:00
|
|
|
#include "gimpenvirontable.h"
|
|
|
|
#include "gimpinterpreterdb.h"
|
2006-05-04 02:05:06 +08:00
|
|
|
#include "gimpplugin.h"
|
2006-04-29 06:26:51 +08:00
|
|
|
#include "gimpplugindebug.h"
|
|
|
|
#include "gimppluginmanager.h"
|
2006-05-03 02:27:31 +08:00
|
|
|
#define __YES_I_NEED_GIMP_PLUG_IN_MANAGER_CALL__
|
|
|
|
#include "gimppluginmanager-call.h"
|
2006-04-29 06:26:51 +08:00
|
|
|
#include "gimppluginmanager-data.h"
|
|
|
|
#include "gimppluginmanager-help-domain.h"
|
2006-08-09 00:14:13 +08:00
|
|
|
#include "gimppluginmanager-history.h"
|
2006-04-29 06:26:51 +08:00
|
|
|
#include "gimppluginmanager-locale-domain.h"
|
|
|
|
#include "gimppluginmanager-menu-branch.h"
|
|
|
|
#include "gimppluginshm.h"
|
2006-08-06 05:21:01 +08:00
|
|
|
#include "gimptemporaryprocedure.h"
|
2002-03-21 01:46:13 +08:00
|
|
|
#include "plug-in-def.h"
|
2001-12-28 07:45:12 +08:00
|
|
|
#include "plug-in-rc.h"
|
2001-12-01 08:14:14 +08:00
|
|
|
|
2003-03-26 00:38:19 +08:00
|
|
|
#include "gimp-intl.h"
|
Lots of ii8n stuff here and some additions to the de.po. Applied
Wed Oct 14 17:46:15 EDT 1998 Adrian Likins <adrian@gimp.org>
* app/*, po/de.po, de/POTFILES.in, libgimp/gimpintl.h:
Lots of ii8n stuff here and some additions to the de.po.
Applied gimp-egger-981005-1 ,gimp-egger-981006-1,
gimp-egger-981007-1, gimp-egger-981008-1,
gimp-egger-981009-1.patch, gimp-egger-981010-1.patch
* plug-in/guillotine/guillotine.c: added the coordinates
of the split images from the original image to the title.
ie foo.jpg (0,0) for the image in the topleft.
* plug-in/script-fu/scripts/neon-logo.scm,
perspective-shadow.scm, predator.scm,rendermap.scm,
ripply-anim.scm, select_to_image.scm,swirltile.scm,
xach-effect.scm: updated scripts to use new script-fu stuff
wooo boy! a big un!
in testing this, it looks like some of the po files are busted.
but the code stuff seems okay.
-adrian
1998-10-15 07:23:52 +08:00
|
|
|
|
Bit of a large checkin this - it's basically three things: 1 - GimpModules
Sun Jan 11 00:24:21 GMT 1999 Austin Donnelly <austin@greenend.org.uk>
Bit of a large checkin this - it's basically three things:
1 - GimpModules using gmodules to dynamically load and
initialise modules at gimp start of day.
2 - Color selectors now register themselves with a color
notebook.
3 - progress bars have been cleaned up a bit, so now have
progress indictations on all transform tool and gradient
fill operations. Not done bucket fill, but that seems to
be the next candidate.
New directories:
* modules/: new directory for dynamically loadable modules.
New files:
* modules/.cvsignore
* modules/Makefile.am
* modules/colorsel_gtk.c: GTK color selector wrapped up as a
color selector the gimp can use.
* app/gimpprogress.[ch]: progress bars within gimp core, either as
popups, or in the status bar. This is mainly code moved out
of plug-in.c
* app/color_notebook.[ch]: color selector notebook, implementing
very similar interface to color_select.h so it can be used as
a drop-in replacement for it.
* libgimp/color_selector.h: API color selectors need to implement
to become a page in the color_notebook.
* libgimp/gimpmodule.h: API gimp modules need to implement to be
initialised by gimp at start of day.
Modified files:
* Makefile.am: add modules/ to SUBDIRS
* libgimp/Makefile.am: install gimpmodule.h and color_selector.h
* app/gimprc.[ch]: recognise module-path variable.
* gimprc.in: set module-path variable to something sensible
(currently "${gimp_dir}/modules:${gimp_plugin_dir}/modules").
* app/Makefile.am: build color notebook and gimpprogress
* app/app_procs.c: register internal GIMP color selector with
color notebook.
* app/asupsample.c: call progress function less frequently for
better performance.
* app/asupsample.h: progress_func_t typedef moved to gimpprogress.h
* app/blend.c: make callbacks to a progress function
* app/color_area.c: use a color notebook rather than a color selector
* app/color_panel.c: ditto
* app/color_select.c: export color selector interface for notebook
* app/color_select.h: color_select_init() prototype
* app/flip_tool.c: flip the image every time, rather than every
second click.
* app/interface.c: move progress bar stuff out to
gimpprogress.c. Make the code actually work while we're at it.
* app/interface.h: move prototypes for progress functions out to
gimpprogress.h
* app/plug_in.c: load and initialise modules (if possible). Move
progress bar handling code out to gimpprogress.c
* app/plug_in.h: keep only a gimp_progress * for each plugin, not
a whole bunch of GtkWidgets.
* app/scale_tool.c
* app/rotate_tool.c
* app/shear_tool.c
* app/perspective_tool.c: progress bar during operation.
De-sensitise the dialog to discourage the user from running
two transforms in parallel.
* app/transform_core.c: recalculate grid coords when bounding box
changes. Only initialise the action area of the dialog once,
to avoid multiple "ok" / "reset" buttons appearing. Undraw
transform tool with correct matrix to get rid of handle
remains on screen. Call a progress function as we apply the
transform matrix. A few new i18n markups. Invalidate
floating selection marching ants after applying matrix.
* app/transform_core.h: transform_core_do() takes an optional
progress callback argument (and data).
* plug-ins/oilify/oilify.c: send progress bar updates after every
pixel region, not only if they processed a multiple of 5
pixels (which was quite unlikely, and therefore gave a jerky
progress indication).
1999-01-11 08:57:33 +08:00
|
|
|
|
2006-04-29 06:26:51 +08:00
|
|
|
enum
|
|
|
|
{
|
2006-05-05 06:51:21 +08:00
|
|
|
PLUG_IN_OPENED,
|
|
|
|
PLUG_IN_CLOSED,
|
2006-04-29 06:26:51 +08:00
|
|
|
MENU_BRANCH_ADDED,
|
2006-08-08 23:36:16 +08:00
|
|
|
HISTORY_CHANGED,
|
2006-04-29 06:26:51 +08:00
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2006-08-09 00:14:13 +08:00
|
|
|
static void gimp_plug_in_manager_dispose (GObject *object);
|
2006-04-29 06:26:51 +08:00
|
|
|
static void gimp_plug_in_manager_finalize (GObject *object);
|
|
|
|
|
|
|
|
static gint64 gimp_plug_in_manager_get_memsize (GimpObject *object,
|
|
|
|
gint64 *gui_size);
|
|
|
|
|
|
|
|
static void gimp_plug_in_manager_add_from_file (const GimpDatafileData *file_data,
|
|
|
|
gpointer data);
|
|
|
|
static void gimp_plug_in_manager_add_from_rc (GimpPlugInManager *manager,
|
|
|
|
PlugInDef *plug_in_def);
|
|
|
|
static void gimp_plug_in_manager_add_to_db (GimpPlugInManager *manager,
|
|
|
|
GimpContext *context,
|
|
|
|
GimpPlugInProcedure *proc);
|
|
|
|
static gint gimp_plug_in_manager_file_proc_compare (gconstpointer a,
|
|
|
|
gconstpointer b,
|
|
|
|
gpointer data);
|
|
|
|
|
|
|
|
|
2006-05-15 17:46:31 +08:00
|
|
|
G_DEFINE_TYPE (GimpPlugInManager, gimp_plug_in_manager, GIMP_TYPE_OBJECT)
|
2006-04-29 06:26:51 +08:00
|
|
|
|
|
|
|
#define parent_class gimp_plug_in_manager_parent_class
|
|
|
|
|
|
|
|
static guint manager_signals[LAST_SIGNAL] = { 0, };
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_plug_in_manager_class_init (GimpPlugInManagerClass *klass)
|
|
|
|
{
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
GimpObjectClass *gimp_object_class = GIMP_OBJECT_CLASS (klass);
|
|
|
|
|
2006-05-05 06:51:21 +08:00
|
|
|
manager_signals[PLUG_IN_OPENED] =
|
|
|
|
g_signal_new ("plug-in-opened",
|
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
G_STRUCT_OFFSET (GimpPlugInManagerClass,
|
|
|
|
plug_in_opened),
|
|
|
|
NULL, NULL,
|
|
|
|
gimp_marshal_VOID__OBJECT,
|
|
|
|
G_TYPE_NONE, 1,
|
|
|
|
GIMP_TYPE_PLUG_IN);
|
|
|
|
|
|
|
|
manager_signals[PLUG_IN_CLOSED] =
|
|
|
|
g_signal_new ("plug-in-closed",
|
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
G_STRUCT_OFFSET (GimpPlugInManagerClass,
|
|
|
|
plug_in_closed),
|
|
|
|
NULL, NULL,
|
|
|
|
gimp_marshal_VOID__OBJECT,
|
|
|
|
G_TYPE_NONE, 1,
|
|
|
|
GIMP_TYPE_PLUG_IN);
|
|
|
|
|
2006-04-29 06:26:51 +08:00
|
|
|
manager_signals[MENU_BRANCH_ADDED] =
|
|
|
|
g_signal_new ("menu-branch-added",
|
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
G_STRUCT_OFFSET (GimpPlugInManagerClass,
|
|
|
|
menu_branch_added),
|
|
|
|
NULL, NULL,
|
|
|
|
gimp_marshal_VOID__STRING_STRING_STRING,
|
|
|
|
G_TYPE_NONE, 1,
|
|
|
|
G_TYPE_STRING,
|
|
|
|
G_TYPE_STRING,
|
|
|
|
G_TYPE_STRING);
|
|
|
|
|
2006-08-08 23:36:16 +08:00
|
|
|
manager_signals[HISTORY_CHANGED] =
|
|
|
|
g_signal_new ("history-changed",
|
2006-04-29 06:26:51 +08:00
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
G_STRUCT_OFFSET (GimpPlugInManagerClass,
|
2006-08-08 23:36:16 +08:00
|
|
|
history_changed),
|
2006-04-29 06:26:51 +08:00
|
|
|
NULL, NULL,
|
|
|
|
gimp_marshal_VOID__VOID,
|
|
|
|
G_TYPE_NONE, 0);
|
|
|
|
|
2006-08-09 00:14:13 +08:00
|
|
|
object_class->dispose = gimp_plug_in_manager_dispose;
|
2006-04-29 06:26:51 +08:00
|
|
|
object_class->finalize = gimp_plug_in_manager_finalize;
|
|
|
|
|
|
|
|
gimp_object_class->get_memsize = gimp_plug_in_manager_get_memsize;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_plug_in_manager_init (GimpPlugInManager *manager)
|
|
|
|
{
|
2006-05-05 05:49:04 +08:00
|
|
|
manager->gimp = NULL;
|
|
|
|
|
|
|
|
manager->plug_in_defs = NULL;
|
|
|
|
manager->write_pluginrc = FALSE;
|
|
|
|
|
2006-04-29 06:26:51 +08:00
|
|
|
manager->plug_in_procedures = NULL;
|
|
|
|
manager->load_procs = NULL;
|
|
|
|
manager->save_procs = NULL;
|
|
|
|
|
2006-05-05 05:49:04 +08:00
|
|
|
manager->current_plug_in = NULL;
|
|
|
|
manager->open_plug_ins = NULL;
|
|
|
|
manager->plug_in_stack = NULL;
|
2006-08-08 23:36:16 +08:00
|
|
|
manager->history = NULL;
|
2006-05-05 05:49:04 +08:00
|
|
|
|
|
|
|
manager->shm = NULL;
|
|
|
|
manager->interpreter_db = gimp_interpreter_db_new ();
|
|
|
|
manager->environ_table = gimp_environ_table_new ();
|
|
|
|
manager->debug = NULL;
|
|
|
|
manager->data_list = NULL;
|
2006-04-29 06:26:51 +08:00
|
|
|
}
|
|
|
|
|
2006-08-09 00:14:13 +08:00
|
|
|
static void
|
|
|
|
gimp_plug_in_manager_dispose (GObject *object)
|
|
|
|
{
|
|
|
|
GimpPlugInManager *manager = GIMP_PLUG_IN_MANAGER (object);
|
|
|
|
|
2006-08-09 00:34:22 +08:00
|
|
|
gimp_plug_in_manager_history_clear (manager);
|
2006-08-09 18:30:01 +08:00
|
|
|
|
|
|
|
G_OBJECT_CLASS (parent_class)->dispose (object);
|
2006-08-09 00:14:13 +08:00
|
|
|
}
|
|
|
|
|
2006-04-29 06:26:51 +08:00
|
|
|
static void
|
|
|
|
gimp_plug_in_manager_finalize (GObject *object)
|
|
|
|
{
|
|
|
|
GimpPlugInManager *manager = GIMP_PLUG_IN_MANAGER (object);
|
|
|
|
|
|
|
|
if (manager->load_procs)
|
|
|
|
{
|
|
|
|
g_slist_free (manager->load_procs);
|
|
|
|
manager->load_procs = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (manager->save_procs)
|
|
|
|
{
|
|
|
|
g_slist_free (manager->save_procs);
|
|
|
|
manager->save_procs = NULL;
|
|
|
|
}
|
|
|
|
|
2006-05-05 05:49:04 +08:00
|
|
|
if (manager->plug_in_procedures)
|
|
|
|
{
|
|
|
|
g_slist_foreach (manager->plug_in_procedures,
|
|
|
|
(GFunc) g_object_unref, NULL);
|
|
|
|
g_slist_free (manager->plug_in_procedures);
|
|
|
|
manager->plug_in_procedures = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (manager->shm)
|
|
|
|
{
|
|
|
|
gimp_plug_in_shm_free (manager->shm);
|
|
|
|
manager->shm = NULL;
|
|
|
|
}
|
|
|
|
|
2006-04-29 06:26:51 +08:00
|
|
|
if (manager->environ_table)
|
|
|
|
{
|
|
|
|
g_object_unref (manager->environ_table);
|
|
|
|
manager->environ_table = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (manager->interpreter_db)
|
|
|
|
{
|
|
|
|
g_object_unref (manager->interpreter_db);
|
|
|
|
manager->interpreter_db = NULL;
|
|
|
|
}
|
|
|
|
|
2006-05-05 05:49:04 +08:00
|
|
|
if (manager->debug)
|
|
|
|
{
|
|
|
|
gimp_plug_in_debug_free (manager->debug);
|
|
|
|
manager->debug = NULL;
|
|
|
|
}
|
|
|
|
|
2006-04-29 06:26:51 +08:00
|
|
|
gimp_plug_in_manager_menu_branch_exit (manager);
|
|
|
|
gimp_plug_in_manager_locale_domain_exit (manager);
|
|
|
|
gimp_plug_in_manager_help_domain_exit (manager);
|
|
|
|
gimp_plug_in_manager_data_free (manager);
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gint64
|
|
|
|
gimp_plug_in_manager_get_memsize (GimpObject *object,
|
|
|
|
gint64 *gui_size)
|
|
|
|
{
|
|
|
|
GimpPlugInManager *manager = GIMP_PLUG_IN_MANAGER (object);
|
|
|
|
gint64 memsize = 0;
|
|
|
|
|
|
|
|
memsize += gimp_g_slist_get_memsize (manager->load_procs, 0 /* FIXME */);
|
|
|
|
memsize += gimp_g_slist_get_memsize (manager->save_procs, 0 /* FIXME */);
|
|
|
|
|
|
|
|
memsize += gimp_g_slist_get_memsize (manager->menu_branches,
|
|
|
|
0 /* FIXME */);
|
|
|
|
memsize += gimp_g_slist_get_memsize (manager->locale_domains,
|
|
|
|
0 /* FIXME */);
|
|
|
|
memsize += gimp_g_slist_get_memsize (manager->help_domains,
|
|
|
|
0 /* FIXME */);
|
|
|
|
memsize += gimp_object_get_memsize (GIMP_OBJECT (manager->interpreter_db),
|
|
|
|
gui_size);
|
|
|
|
memsize += gimp_object_get_memsize (GIMP_OBJECT (manager->environ_table),
|
|
|
|
gui_size);
|
|
|
|
memsize += gimp_g_list_get_memsize (manager->data_list,
|
|
|
|
0 /* FIXME */);
|
|
|
|
|
|
|
|
return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object,
|
|
|
|
gui_size);
|
|
|
|
}
|
|
|
|
|
|
|
|
GimpPlugInManager *
|
|
|
|
gimp_plug_in_manager_new (Gimp *gimp)
|
|
|
|
{
|
|
|
|
GimpPlugInManager *manager;
|
|
|
|
|
|
|
|
manager = g_object_new (GIMP_TYPE_PLUG_IN_MANAGER, NULL);
|
|
|
|
|
|
|
|
manager->gimp = gimp;
|
|
|
|
|
|
|
|
return manager;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_plug_in_manager_initialize (GimpPlugInManager *manager,
|
|
|
|
GimpInitStatusFunc status_callback)
|
|
|
|
{
|
|
|
|
gchar *path;
|
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_PLUG_IN_MANAGER (manager));
|
|
|
|
g_return_if_fail (status_callback != NULL);
|
2006-04-10 07:40:45 +08:00
|
|
|
|
2006-04-29 06:26:51 +08:00
|
|
|
status_callback (NULL, _("Plug-In Interpreters"), 0.8);
|
2000-07-16 20:49:04 +08:00
|
|
|
|
2006-04-29 06:26:51 +08:00
|
|
|
path = gimp_config_path_expand (manager->gimp->config->interpreter_path,
|
|
|
|
TRUE, NULL);
|
|
|
|
gimp_interpreter_db_load (manager->interpreter_db, path);
|
|
|
|
g_free (path);
|
|
|
|
|
|
|
|
status_callback (NULL, _("Plug-In Environment"), 0.9);
|
|
|
|
|
|
|
|
path = gimp_config_path_expand (manager->gimp->config->environ_path,
|
|
|
|
TRUE, NULL);
|
|
|
|
gimp_environ_table_load (manager->environ_table, path);
|
|
|
|
g_free (path);
|
1999-05-07 04:56:07 +08:00
|
|
|
|
2006-10-24 03:19:22 +08:00
|
|
|
/* allocate a piece of shared memory for use in transporting tiles
|
2006-04-29 06:26:51 +08:00
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
if (manager->gimp->use_shm)
|
|
|
|
manager->shm = gimp_plug_in_shm_new ();
|
|
|
|
|
|
|
|
manager->debug = gimp_plug_in_debug_new ();
|
|
|
|
}
|
2003-01-18 02:07:37 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
void
|
2006-04-29 06:26:51 +08:00
|
|
|
gimp_plug_in_manager_restore (GimpPlugInManager *manager,
|
|
|
|
GimpContext *context,
|
|
|
|
GimpInitStatusFunc status_callback)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2006-04-29 06:26:51 +08:00
|
|
|
Gimp *gimp;
|
|
|
|
gchar *pluginrc;
|
|
|
|
GSList *rc_defs;
|
|
|
|
GSList *list;
|
|
|
|
gint n_plugins;
|
|
|
|
gint nth;
|
|
|
|
GError *error = NULL;
|
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_PLUG_IN_MANAGER (manager));
|
2004-07-01 00:55:43 +08:00
|
|
|
g_return_if_fail (GIMP_IS_CONTEXT (context));
|
2001-10-20 00:41:09 +08:00
|
|
|
g_return_if_fail (status_callback != NULL);
|
|
|
|
|
2006-04-29 06:26:51 +08:00
|
|
|
gimp = manager->gimp;
|
2000-07-16 20:49:04 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
/* search for binaries in the plug-in directory path */
|
2006-04-29 06:26:51 +08:00
|
|
|
{
|
|
|
|
gchar *path;
|
2006-04-09 20:33:32 +08:00
|
|
|
|
2006-04-29 06:26:51 +08:00
|
|
|
status_callback (_("Searching Plug-Ins"), "", 0.0);
|
2002-12-30 08:01:30 +08:00
|
|
|
|
2006-04-29 06:26:51 +08:00
|
|
|
path = gimp_config_path_expand (gimp->config->plug_in_path, TRUE, NULL);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2006-04-29 06:26:51 +08:00
|
|
|
gimp_datafiles_read_directories (path,
|
|
|
|
G_FILE_TEST_IS_EXECUTABLE,
|
|
|
|
gimp_plug_in_manager_add_from_file,
|
|
|
|
manager);
|
|
|
|
|
|
|
|
g_free (path);
|
|
|
|
}
|
2002-12-30 08:01:30 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
/* read the pluginrc file for cached data */
|
2002-11-19 04:50:31 +08:00
|
|
|
if (gimp->config->plug_in_rc_path)
|
1998-04-11 13:07:52 +08:00
|
|
|
{
|
2006-04-11 03:47:58 +08:00
|
|
|
pluginrc = gimp_config_path_expand (gimp->config->plug_in_rc_path,
|
2002-12-30 08:18:33 +08:00
|
|
|
TRUE, NULL);
|
|
|
|
|
2006-04-11 03:47:58 +08:00
|
|
|
if (! g_path_is_absolute (pluginrc))
|
2002-12-30 08:18:33 +08:00
|
|
|
{
|
2006-04-11 03:47:58 +08:00
|
|
|
gchar *str = g_build_filename (gimp_directory (), pluginrc, NULL);
|
2003-11-08 07:47:35 +08:00
|
|
|
|
2006-04-11 03:47:58 +08:00
|
|
|
g_free (pluginrc);
|
|
|
|
pluginrc = str;
|
2002-12-30 08:18:33 +08:00
|
|
|
}
|
1998-04-11 13:07:52 +08:00
|
|
|
}
|
|
|
|
else
|
2002-03-21 01:46:13 +08:00
|
|
|
{
|
2006-04-11 03:47:58 +08:00
|
|
|
pluginrc = gimp_personal_rc_file ("pluginrc");
|
2002-03-21 01:46:13 +08:00
|
|
|
}
|
1998-04-11 13:07:52 +08:00
|
|
|
|
2005-11-01 18:20:38 +08:00
|
|
|
status_callback (_("Resource configuration"),
|
2006-04-11 03:47:58 +08:00
|
|
|
gimp_filename_to_utf8 (pluginrc), 0.0);
|
2003-11-08 07:47:35 +08:00
|
|
|
|
2005-11-07 06:01:25 +08:00
|
|
|
if (gimp->be_verbose)
|
2006-04-11 03:47:58 +08:00
|
|
|
g_print (_("Parsing '%s'\n"), gimp_filename_to_utf8 (pluginrc));
|
2005-11-07 06:01:25 +08:00
|
|
|
|
2006-04-11 03:47:58 +08:00
|
|
|
rc_defs = plug_in_rc_parse (gimp, pluginrc, &error);
|
2006-04-09 20:33:32 +08:00
|
|
|
|
|
|
|
if (rc_defs)
|
|
|
|
{
|
|
|
|
for (list = rc_defs; list; list = g_slist_next (list))
|
2006-04-29 06:26:51 +08:00
|
|
|
gimp_plug_in_manager_add_from_rc (manager, list->data); /* consumes list->data */
|
2006-04-09 20:33:32 +08:00
|
|
|
|
|
|
|
g_slist_free (rc_defs);
|
|
|
|
}
|
2006-10-24 03:19:22 +08:00
|
|
|
else if (error)
|
2003-11-08 07:47:35 +08:00
|
|
|
{
|
2004-02-09 02:49:58 +08:00
|
|
|
if (error->code != GIMP_CONFIG_ERROR_OPEN_ENOENT)
|
2006-10-10 02:49:15 +08:00
|
|
|
gimp_message (gimp, NULL, GIMP_MESSAGE_ERROR, "%s", error->message);
|
2004-02-09 02:49:58 +08:00
|
|
|
|
2004-02-03 23:12:11 +08:00
|
|
|
g_clear_error (&error);
|
2003-11-08 07:47:35 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2005-11-01 18:20:38 +08:00
|
|
|
/* query any plug-ins that have changed since we last wrote out
|
|
|
|
* the pluginrc file
|
1997-11-25 06:05:25 +08:00
|
|
|
*/
|
2005-11-05 23:00:35 +08:00
|
|
|
status_callback (_("Querying new Plug-ins"), "", 0.0);
|
2002-08-27 23:23:36 +08:00
|
|
|
|
2006-04-29 06:26:51 +08:00
|
|
|
for (list = manager->plug_in_defs, n_plugins = 0; list; list = list->next)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2004-05-14 08:01:11 +08:00
|
|
|
PlugInDef *plug_in_def = list->data;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-01-18 02:07:37 +08:00
|
|
|
if (plug_in_def->needs_query)
|
2005-10-31 22:30:29 +08:00
|
|
|
n_plugins++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (n_plugins)
|
|
|
|
{
|
2006-04-29 06:26:51 +08:00
|
|
|
manager->write_pluginrc = TRUE;
|
2005-10-31 22:30:29 +08:00
|
|
|
|
2006-04-29 06:26:51 +08:00
|
|
|
for (list = manager->plug_in_defs, nth = 0; list; list = list->next)
|
2005-10-31 22:30:29 +08:00
|
|
|
{
|
|
|
|
PlugInDef *plug_in_def = list->data;
|
|
|
|
|
2006-04-09 07:12:06 +08:00
|
|
|
if (plug_in_def->needs_query)
|
|
|
|
{
|
2006-04-11 03:47:58 +08:00
|
|
|
gchar *basename;
|
|
|
|
|
2006-04-09 07:12:06 +08:00
|
|
|
basename = g_filename_display_basename (plug_in_def->prog);
|
|
|
|
status_callback (NULL, basename,
|
|
|
|
(gdouble) nth++ / (gdouble) n_plugins);
|
|
|
|
g_free (basename);
|
2000-08-15 23:42:14 +08:00
|
|
|
|
2006-04-09 07:12:06 +08:00
|
|
|
if (gimp->be_verbose)
|
|
|
|
g_print (_("Querying plug-in: '%s'\n"),
|
|
|
|
gimp_filename_to_utf8 (plug_in_def->prog));
|
2000-08-15 23:42:14 +08:00
|
|
|
|
2006-05-03 02:27:31 +08:00
|
|
|
gimp_plug_in_manager_call_query (manager, context, plug_in_def);
|
2006-04-09 07:12:06 +08:00
|
|
|
}
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2004-04-16 06:16:21 +08:00
|
|
|
/* initialize the plug-ins */
|
2005-11-05 23:00:35 +08:00
|
|
|
status_callback (_("Initializing Plug-ins"), "", 0.0);
|
2004-04-16 06:16:21 +08:00
|
|
|
|
2006-04-29 06:26:51 +08:00
|
|
|
for (list = manager->plug_in_defs, n_plugins = 0; list; list = list->next)
|
2004-04-16 06:16:21 +08:00
|
|
|
{
|
2004-05-14 08:01:11 +08:00
|
|
|
PlugInDef *plug_in_def = list->data;
|
2004-04-16 06:16:21 +08:00
|
|
|
|
|
|
|
if (plug_in_def->has_init)
|
2005-10-31 22:30:29 +08:00
|
|
|
n_plugins++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (n_plugins)
|
|
|
|
{
|
2006-04-29 06:26:51 +08:00
|
|
|
for (list = manager->plug_in_defs, nth = 0; list; list = list->next)
|
2005-10-31 22:30:29 +08:00
|
|
|
{
|
|
|
|
PlugInDef *plug_in_def = list->data;
|
|
|
|
|
2006-04-09 07:12:06 +08:00
|
|
|
if (plug_in_def->has_init)
|
|
|
|
{
|
2006-04-11 03:47:58 +08:00
|
|
|
gchar *basename;
|
|
|
|
|
2006-04-09 07:12:06 +08:00
|
|
|
basename = g_filename_display_basename (plug_in_def->prog);
|
|
|
|
status_callback (NULL, basename,
|
|
|
|
(gdouble) nth++ / (gdouble) n_plugins);
|
|
|
|
g_free (basename);
|
2005-10-31 22:30:29 +08:00
|
|
|
|
2006-04-09 07:12:06 +08:00
|
|
|
if (gimp->be_verbose)
|
|
|
|
g_print (_("Initializing plug-in: '%s'\n"),
|
|
|
|
gimp_filename_to_utf8 (plug_in_def->prog));
|
2004-04-16 06:16:21 +08:00
|
|
|
|
2006-05-03 02:27:31 +08:00
|
|
|
gimp_plug_in_manager_call_init (manager, context, plug_in_def);
|
2006-04-09 07:12:06 +08:00
|
|
|
}
|
2005-10-31 22:30:29 +08:00
|
|
|
}
|
2004-04-16 06:16:21 +08:00
|
|
|
}
|
|
|
|
|
2005-11-05 23:00:35 +08:00
|
|
|
status_callback (NULL, "", 1.0);
|
2004-04-16 06:16:21 +08:00
|
|
|
|
2006-04-29 06:26:51 +08:00
|
|
|
/* add the procedures to manager->plug_in_procedures */
|
|
|
|
for (list = manager->plug_in_defs; list; list = list->next)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2004-05-14 08:01:11 +08:00
|
|
|
PlugInDef *plug_in_def = list->data;
|
|
|
|
GSList *list2;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2006-04-07 16:16:26 +08:00
|
|
|
for (list2 = plug_in_def->procedures; list2; list2 = list2->next)
|
2006-04-09 20:33:32 +08:00
|
|
|
{
|
2006-04-29 06:26:51 +08:00
|
|
|
gimp_plug_in_manager_add_procedure (manager, list2->data);
|
2006-04-09 20:33:32 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* write the pluginrc file if necessary */
|
2006-04-29 06:26:51 +08:00
|
|
|
if (manager->write_pluginrc)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-12-01 08:14:14 +08:00
|
|
|
if (gimp->be_verbose)
|
2006-04-12 20:49:29 +08:00
|
|
|
g_print (_("Writing '%s'\n"), gimp_filename_to_utf8 (pluginrc));
|
2000-08-15 23:42:14 +08:00
|
|
|
|
2006-04-29 06:26:51 +08:00
|
|
|
if (! plug_in_rc_write (manager->plug_in_defs, pluginrc, &error))
|
2003-03-10 23:48:16 +08:00
|
|
|
{
|
2006-10-10 02:49:15 +08:00
|
|
|
gimp_message (gimp, NULL, GIMP_MESSAGE_ERROR, "%s", error->message);
|
2004-02-03 23:12:11 +08:00
|
|
|
g_clear_error (&error);
|
2003-03-10 23:48:16 +08:00
|
|
|
}
|
|
|
|
|
2006-04-29 06:26:51 +08:00
|
|
|
manager->write_pluginrc = FALSE;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2006-04-11 03:47:58 +08:00
|
|
|
g_free (pluginrc);
|
1999-03-07 20:56:03 +08:00
|
|
|
|
2002-12-11 00:38:16 +08:00
|
|
|
/* create help_path and locale_domain lists */
|
2006-04-29 06:26:51 +08:00
|
|
|
for (list = manager->plug_in_defs; list; list = list->next)
|
2002-12-11 00:38:16 +08:00
|
|
|
{
|
2004-05-14 08:01:11 +08:00
|
|
|
PlugInDef *plug_in_def = list->data;
|
2002-12-11 00:38:16 +08:00
|
|
|
|
2003-08-29 02:49:11 +08:00
|
|
|
if (plug_in_def->locale_domain_name)
|
2006-04-29 06:26:51 +08:00
|
|
|
gimp_plug_in_manager_add_locale_domain (manager,
|
|
|
|
plug_in_def->prog,
|
|
|
|
plug_in_def->locale_domain_name,
|
|
|
|
plug_in_def->locale_domain_path);
|
2002-12-11 00:38:16 +08:00
|
|
|
|
2003-08-29 02:49:11 +08:00
|
|
|
if (plug_in_def->help_domain_name)
|
2006-04-29 06:26:51 +08:00
|
|
|
gimp_plug_in_manager_add_help_domain (manager,
|
|
|
|
plug_in_def->prog,
|
|
|
|
plug_in_def->help_domain_name,
|
|
|
|
plug_in_def->help_domain_uri);
|
2002-12-11 00:38:16 +08:00
|
|
|
}
|
|
|
|
|
2006-04-28 05:53:33 +08:00
|
|
|
/* we're done with the plug-in-defs */
|
2006-04-29 06:26:51 +08:00
|
|
|
g_slist_foreach (manager->plug_in_defs, (GFunc) plug_in_def_free, NULL);
|
|
|
|
g_slist_free (manager->plug_in_defs);
|
|
|
|
manager->plug_in_defs = NULL;
|
2006-04-28 05:53:33 +08:00
|
|
|
|
2006-09-05 17:45:48 +08:00
|
|
|
/* bind plug-in text domains */
|
2006-09-05 18:03:49 +08:00
|
|
|
{
|
|
|
|
gchar **locale_domains;
|
|
|
|
gchar **locale_paths;
|
|
|
|
gint n_domains;
|
|
|
|
gint i;
|
2006-04-28 05:53:33 +08:00
|
|
|
|
2006-09-05 18:03:49 +08:00
|
|
|
n_domains = gimp_plug_in_manager_get_locale_domains (manager,
|
|
|
|
&locale_domains,
|
|
|
|
&locale_paths);
|
2006-04-28 05:53:33 +08:00
|
|
|
|
2006-09-05 18:03:49 +08:00
|
|
|
for (i = 0; i < n_domains; i++)
|
|
|
|
{
|
|
|
|
bindtextdomain (locale_domains[i], locale_paths[i]);
|
2006-04-28 05:53:33 +08:00
|
|
|
#ifdef HAVE_BIND_TEXTDOMAIN_CODESET
|
2006-09-05 18:03:49 +08:00
|
|
|
bind_textdomain_codeset (locale_domains[i], "UTF-8");
|
2006-04-28 05:53:33 +08:00
|
|
|
#endif
|
2006-09-05 18:03:49 +08:00
|
|
|
}
|
2006-04-28 05:53:33 +08:00
|
|
|
|
2006-09-05 18:03:49 +08:00
|
|
|
g_strfreev (locale_domains);
|
|
|
|
g_strfreev (locale_paths);
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2006-04-28 03:36:13 +08:00
|
|
|
/* add the plug-in procs to the procedure database */
|
2006-04-29 06:26:51 +08:00
|
|
|
for (list = manager->plug_in_procedures; list; list = list->next)
|
2006-04-28 03:36:13 +08:00
|
|
|
{
|
2006-04-29 06:26:51 +08:00
|
|
|
gimp_plug_in_manager_add_to_db (manager, context, list->data);
|
2006-04-28 03:36:13 +08:00
|
|
|
}
|
|
|
|
|
2006-09-05 17:45:48 +08:00
|
|
|
/* sort the load and save procedures */
|
2006-09-05 18:03:49 +08:00
|
|
|
manager->load_procs =
|
|
|
|
g_slist_sort_with_data (manager->load_procs,
|
|
|
|
gimp_plug_in_manager_file_proc_compare, manager);
|
|
|
|
manager->save_procs =
|
|
|
|
g_slist_sort_with_data (manager->save_procs,
|
|
|
|
gimp_plug_in_manager_file_proc_compare, manager);
|
2006-09-05 17:45:48 +08:00
|
|
|
|
2006-04-29 06:26:51 +08:00
|
|
|
/* run automatically started extensions */
|
|
|
|
{
|
|
|
|
GList *extensions = NULL;
|
|
|
|
gint n_extensions;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2006-04-29 06:26:51 +08:00
|
|
|
/* build list of automatically started extensions */
|
|
|
|
for (list = manager->plug_in_procedures; list; list = list->next)
|
|
|
|
{
|
|
|
|
GimpPlugInProcedure *proc = list->data;
|
2003-04-15 19:35:31 +08:00
|
|
|
|
2006-04-29 06:26:51 +08:00
|
|
|
if (proc->prog &&
|
|
|
|
GIMP_PROCEDURE (proc)->proc_type == GIMP_EXTENSION &&
|
|
|
|
GIMP_PROCEDURE (proc)->num_args == 0)
|
|
|
|
{
|
|
|
|
extensions = g_list_prepend (extensions, proc);
|
|
|
|
}
|
|
|
|
}
|
2003-04-15 19:35:31 +08:00
|
|
|
|
2006-04-29 06:26:51 +08:00
|
|
|
extensions = g_list_reverse (extensions);
|
|
|
|
n_extensions = g_list_length (extensions);
|
2004-02-01 18:52:23 +08:00
|
|
|
|
2006-04-29 06:26:51 +08:00
|
|
|
/* run the available extensions */
|
|
|
|
if (extensions)
|
|
|
|
{
|
|
|
|
GList *list;
|
2003-04-15 19:35:31 +08:00
|
|
|
|
2006-04-29 06:26:51 +08:00
|
|
|
status_callback (_("Starting Extensions"), "", 0.0);
|
2003-04-15 19:35:31 +08:00
|
|
|
|
2006-04-29 06:26:51 +08:00
|
|
|
for (list = extensions, nth = 0; list; list = g_list_next (list), nth++)
|
|
|
|
{
|
|
|
|
GimpPlugInProcedure *proc = list->data;
|
|
|
|
GValueArray *args;
|
2000-08-15 23:42:14 +08:00
|
|
|
|
2006-04-29 06:26:51 +08:00
|
|
|
if (gimp->be_verbose)
|
|
|
|
g_print (_("Starting extension: '%s'\n"),
|
|
|
|
GIMP_OBJECT (proc)->name);
|
1998-01-26 06:13:00 +08:00
|
|
|
|
2006-04-29 06:26:51 +08:00
|
|
|
status_callback (NULL, GIMP_OBJECT (proc)->name,
|
|
|
|
(gdouble) nth / (gdouble) n_extensions);
|
2006-04-04 18:30:58 +08:00
|
|
|
|
2006-04-29 06:26:51 +08:00
|
|
|
args = g_value_array_new (0);
|
2006-04-04 18:30:58 +08:00
|
|
|
|
2006-04-29 06:26:51 +08:00
|
|
|
gimp_procedure_execute_async (GIMP_PROCEDURE (proc),
|
2006-05-05 16:29:33 +08:00
|
|
|
gimp, context, NULL, args, NULL);
|
2003-04-15 19:35:31 +08:00
|
|
|
|
2006-04-29 06:26:51 +08:00
|
|
|
g_value_array_free (args);
|
|
|
|
}
|
2000-08-15 23:42:14 +08:00
|
|
|
|
2006-04-29 06:26:51 +08:00
|
|
|
g_list_free (extensions);
|
2006-05-16 19:43:55 +08:00
|
|
|
|
|
|
|
status_callback (NULL, "", 1.0);
|
2006-04-29 06:26:51 +08:00
|
|
|
}
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-04-29 06:26:51 +08:00
|
|
|
gimp_plug_in_manager_exit (GimpPlugInManager *manager)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2006-04-29 06:26:51 +08:00
|
|
|
g_return_if_fail (GIMP_IS_PLUG_IN_MANAGER (manager));
|
|
|
|
|
2006-05-05 05:49:04 +08:00
|
|
|
while (manager->open_plug_ins)
|
|
|
|
gimp_plug_in_close (manager->open_plug_ins->data, TRUE);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2006-04-10 04:35:15 +08:00
|
|
|
void
|
2006-04-29 06:26:51 +08:00
|
|
|
gimp_plug_in_manager_add_procedure (GimpPlugInManager *manager,
|
|
|
|
GimpPlugInProcedure *procedure)
|
2006-04-10 04:35:15 +08:00
|
|
|
{
|
|
|
|
GSList *list;
|
|
|
|
|
2006-04-29 06:26:51 +08:00
|
|
|
g_return_if_fail (GIMP_IS_PLUG_IN_MANAGER (manager));
|
|
|
|
g_return_if_fail (GIMP_IS_PLUG_IN_PROCEDURE (procedure));
|
2006-04-10 04:35:15 +08:00
|
|
|
|
2006-04-29 06:26:51 +08:00
|
|
|
for (list = manager->plug_in_procedures; list; list = list->next)
|
2006-04-10 04:35:15 +08:00
|
|
|
{
|
|
|
|
GimpPlugInProcedure *tmp_proc = list->data;
|
|
|
|
|
2006-04-29 06:26:51 +08:00
|
|
|
if (strcmp (GIMP_OBJECT (procedure)->name,
|
2006-04-10 04:35:15 +08:00
|
|
|
GIMP_OBJECT (tmp_proc)->name) == 0)
|
|
|
|
{
|
|
|
|
GSList *list2;
|
|
|
|
|
2006-04-29 06:26:51 +08:00
|
|
|
list->data = g_object_ref (procedure);
|
2006-04-10 04:35:15 +08:00
|
|
|
|
|
|
|
g_printerr ("removing duplicate PDB procedure \"%s\" "
|
|
|
|
"registered by '%s'\n",
|
|
|
|
GIMP_OBJECT (tmp_proc)->name,
|
|
|
|
gimp_filename_to_utf8 (tmp_proc->prog));
|
|
|
|
|
|
|
|
/* search the plugin list to see if any plugins had references to
|
|
|
|
* the tmp_proc.
|
|
|
|
*/
|
2006-04-29 06:26:51 +08:00
|
|
|
for (list2 = manager->plug_in_defs; list2; list2 = list2->next)
|
2006-04-10 04:35:15 +08:00
|
|
|
{
|
|
|
|
PlugInDef *plug_in_def = list2->data;
|
|
|
|
|
|
|
|
if (g_slist_find (plug_in_def->procedures, tmp_proc))
|
|
|
|
plug_in_def_remove_procedure (plug_in_def, tmp_proc);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* also remove it from the lists of load and save procs */
|
2006-04-29 06:26:51 +08:00
|
|
|
manager->load_procs = g_slist_remove (manager->load_procs, tmp_proc);
|
|
|
|
manager->save_procs = g_slist_remove (manager->save_procs, tmp_proc);
|
2006-04-10 04:35:15 +08:00
|
|
|
|
2006-08-09 00:34:22 +08:00
|
|
|
/* and from the history */
|
|
|
|
gimp_plug_in_manager_history_remove (manager, tmp_proc);
|
|
|
|
|
2006-04-10 04:35:15 +08:00
|
|
|
g_object_unref (tmp_proc);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-04-29 06:26:51 +08:00
|
|
|
manager->plug_in_procedures = g_slist_prepend (manager->plug_in_procedures,
|
|
|
|
g_object_ref (procedure));
|
2006-04-10 04:35:15 +08:00
|
|
|
}
|
|
|
|
|
2003-01-18 02:07:37 +08:00
|
|
|
void
|
2006-04-29 06:26:51 +08:00
|
|
|
gimp_plug_in_manager_add_temp_proc (GimpPlugInManager *manager,
|
|
|
|
GimpTemporaryProcedure *procedure)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2006-04-29 06:26:51 +08:00
|
|
|
g_return_if_fail (GIMP_IS_PLUG_IN_MANAGER (manager));
|
|
|
|
g_return_if_fail (GIMP_IS_TEMPORARY_PROCEDURE (procedure));
|
2001-01-14 23:18:37 +08:00
|
|
|
|
2006-04-29 06:26:51 +08:00
|
|
|
gimp_pdb_register_procedure (manager->gimp->pdb, GIMP_PROCEDURE (procedure));
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2006-04-29 06:26:51 +08:00
|
|
|
manager->plug_in_procedures = g_slist_prepend (manager->plug_in_procedures,
|
|
|
|
g_object_ref (procedure));
|
2003-01-18 02:07:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-04-29 06:26:51 +08:00
|
|
|
gimp_plug_in_manager_remove_temp_proc (GimpPlugInManager *manager,
|
|
|
|
GimpTemporaryProcedure *procedure)
|
2003-01-18 02:07:37 +08:00
|
|
|
{
|
2006-04-29 06:26:51 +08:00
|
|
|
g_return_if_fail (GIMP_IS_PLUG_IN_MANAGER (manager));
|
|
|
|
g_return_if_fail (GIMP_IS_TEMPORARY_PROCEDURE (procedure));
|
|
|
|
|
|
|
|
manager->plug_in_procedures = g_slist_remove (manager->plug_in_procedures,
|
|
|
|
procedure);
|
|
|
|
|
2006-08-09 00:34:22 +08:00
|
|
|
gimp_plug_in_manager_history_remove (manager,
|
|
|
|
GIMP_PLUG_IN_PROCEDURE (procedure));
|
|
|
|
|
2006-08-08 23:36:16 +08:00
|
|
|
gimp_pdb_unregister_procedure (manager->gimp->pdb,
|
|
|
|
GIMP_PROCEDURE (procedure));
|
2006-04-29 06:26:51 +08:00
|
|
|
|
|
|
|
g_object_unref (procedure);
|
|
|
|
}
|
|
|
|
|
2006-05-05 06:51:21 +08:00
|
|
|
void
|
|
|
|
gimp_plug_in_manager_add_open_plug_in (GimpPlugInManager *manager,
|
|
|
|
GimpPlugIn *plug_in)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_PLUG_IN_MANAGER (manager));
|
|
|
|
g_return_if_fail (GIMP_IS_PLUG_IN (plug_in));
|
|
|
|
|
|
|
|
manager->open_plug_ins = g_slist_prepend (manager->open_plug_ins,
|
|
|
|
g_object_ref (plug_in));
|
|
|
|
|
|
|
|
g_signal_emit (manager, manager_signals[PLUG_IN_OPENED], 0,
|
|
|
|
plug_in);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_plug_in_manager_remove_open_plug_in (GimpPlugInManager *manager,
|
|
|
|
GimpPlugIn *plug_in)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_PLUG_IN_MANAGER (manager));
|
|
|
|
g_return_if_fail (GIMP_IS_PLUG_IN (plug_in));
|
|
|
|
|
|
|
|
manager->open_plug_ins = g_slist_remove (manager->open_plug_ins, plug_in);
|
|
|
|
|
|
|
|
g_signal_emit (manager, manager_signals[PLUG_IN_CLOSED], 0,
|
|
|
|
plug_in);
|
|
|
|
|
|
|
|
g_object_unref (plug_in);
|
|
|
|
}
|
|
|
|
|
2006-04-30 03:03:44 +08:00
|
|
|
void
|
|
|
|
gimp_plug_in_manager_plug_in_push (GimpPlugInManager *manager,
|
2006-05-04 02:05:06 +08:00
|
|
|
GimpPlugIn *plug_in)
|
2006-04-30 03:03:44 +08:00
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_PLUG_IN_MANAGER (manager));
|
2006-05-04 02:05:06 +08:00
|
|
|
g_return_if_fail (GIMP_IS_PLUG_IN (plug_in));
|
2006-04-30 03:03:44 +08:00
|
|
|
|
|
|
|
manager->current_plug_in = plug_in;
|
|
|
|
|
|
|
|
manager->plug_in_stack = g_slist_prepend (manager->plug_in_stack,
|
|
|
|
manager->current_plug_in);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_plug_in_manager_plug_in_pop (GimpPlugInManager *manager)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_PLUG_IN_MANAGER (manager));
|
|
|
|
|
|
|
|
if (manager->current_plug_in)
|
|
|
|
manager->plug_in_stack = g_slist_remove (manager->plug_in_stack,
|
|
|
|
manager->plug_in_stack->data);
|
|
|
|
|
|
|
|
if (manager->plug_in_stack)
|
|
|
|
manager->current_plug_in = manager->plug_in_stack->data;
|
|
|
|
else
|
|
|
|
manager->current_plug_in = NULL;
|
|
|
|
}
|
|
|
|
|
2006-08-09 00:14:13 +08:00
|
|
|
void
|
|
|
|
gimp_plug_in_manager_history_changed (GimpPlugInManager *manager)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_PLUG_IN_MANAGER (manager));
|
|
|
|
|
|
|
|
g_signal_emit (manager, manager_signals[HISTORY_CHANGED], 0);
|
|
|
|
}
|
|
|
|
|
2003-01-18 02:07:37 +08:00
|
|
|
|
|
|
|
/* private functions */
|
|
|
|
|
2002-03-21 01:46:13 +08:00
|
|
|
static void
|
2006-04-29 06:26:51 +08:00
|
|
|
gimp_plug_in_manager_add_from_file (const GimpDatafileData *file_data,
|
|
|
|
gpointer data)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2006-04-29 06:26:51 +08:00
|
|
|
GimpPlugInManager *manager = data;
|
|
|
|
PlugInDef *plug_in_def;
|
|
|
|
GSList *list;
|
2003-01-18 02:07:37 +08:00
|
|
|
|
2006-04-29 06:26:51 +08:00
|
|
|
for (list = manager->plug_in_defs; list; list = list->next)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2003-01-20 20:17:32 +08:00
|
|
|
gchar *plug_in_name;
|
|
|
|
|
2005-11-01 18:20:38 +08:00
|
|
|
plug_in_def = list->data;
|
2002-03-21 01:46:13 +08:00
|
|
|
plug_in_name = g_path_get_basename (plug_in_def->prog);
|
|
|
|
|
2003-07-03 01:11:00 +08:00
|
|
|
if (g_ascii_strcasecmp (file_data->basename, plug_in_name) == 0)
|
2006-04-12 20:49:29 +08:00
|
|
|
{
|
|
|
|
g_printerr ("skipping duplicate plug-in: '%s'\n",
|
2004-01-19 09:08:43 +08:00
|
|
|
gimp_filename_to_utf8 (file_data->filename));
|
2003-01-18 02:07:37 +08:00
|
|
|
|
|
|
|
g_free (plug_in_name);
|
|
|
|
|
2006-04-12 20:49:29 +08:00
|
|
|
return;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-03-21 01:46:13 +08:00
|
|
|
g_free (plug_in_name);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2003-01-18 02:07:37 +08:00
|
|
|
plug_in_def = plug_in_def_new (file_data->filename);
|
|
|
|
|
|
|
|
plug_in_def_set_mtime (plug_in_def, file_data->mtime);
|
|
|
|
plug_in_def_set_needs_query (plug_in_def, TRUE);
|
Add gimpcolorspace object.
2000-01-04 Tor Lillqvist <tml@iki.fi>
* libgimp/makefile.{cygwin.msc}: Add gimpcolorspace object.
* libgimp/gimp.def: Add functions from it.
Fixes from Hans Breuer:
* app/datafiles.c: redefine the executable flag for Win32
to _S_IREAD, to get _all_ files from the plug-in dirs as
executables (including scripts)
* app/main.c: Win32-specific changes to allow building Gimp as a
console application, with all its benefits (like inheriting the
console), but hide it if the user doesn't want it. Also, if stdout
goes to a console, give the user a chance to read the help or
version messages. (tml: I am not convinced that it is better to
build gimp as a console application, but let's try it this way for
a while.)
* app/makefile.{cygwin,msc}: Build as console application, and
link with shell32 library.
* app/paint_core.c (paint_core_motion): Pass the value of a call
to the function gimage_active_drawable() to the paint_func,
instead of just passing the address of gimage_active_drawable...
(tml: This code is only called when the TOOL_TRACES_ON_WINDOW flag
is on, and only the clone tool sets that, and the clone tool's
paint_func doesn't use the drawable argument, so this hasn't
caused any trouble.)
* app/plug_in.c: On Win32, to support scripts, use new function
xspawn() instead of _spawnv. Add some more code to properly kill
plug-ins.
* libgimp/color_display.h: Add G_MODULE_EXPORT declarations.
2000-01-05 01:46:41 +08:00
|
|
|
|
2006-04-29 06:26:51 +08:00
|
|
|
manager->plug_in_defs = g_slist_prepend (manager->plug_in_defs, plug_in_def);
|
2002-03-21 01:46:13 +08:00
|
|
|
}
|
Add gimpcolorspace object.
2000-01-04 Tor Lillqvist <tml@iki.fi>
* libgimp/makefile.{cygwin.msc}: Add gimpcolorspace object.
* libgimp/gimp.def: Add functions from it.
Fixes from Hans Breuer:
* app/datafiles.c: redefine the executable flag for Win32
to _S_IREAD, to get _all_ files from the plug-in dirs as
executables (including scripts)
* app/main.c: Win32-specific changes to allow building Gimp as a
console application, with all its benefits (like inheriting the
console), but hide it if the user doesn't want it. Also, if stdout
goes to a console, give the user a chance to read the help or
version messages. (tml: I am not convinced that it is better to
build gimp as a console application, but let's try it this way for
a while.)
* app/makefile.{cygwin,msc}: Build as console application, and
link with shell32 library.
* app/paint_core.c (paint_core_motion): Pass the value of a call
to the function gimage_active_drawable() to the paint_func,
instead of just passing the address of gimage_active_drawable...
(tml: This code is only called when the TOOL_TRACES_ON_WINDOW flag
is on, and only the clone tool sets that, and the clone tool's
paint_func doesn't use the drawable argument, so this hasn't
caused any trouble.)
* app/plug_in.c: On Win32, to support scripts, use new function
xspawn() instead of _spawnv. Add some more code to properly kill
plug-ins.
* libgimp/color_display.h: Add G_MODULE_EXPORT declarations.
2000-01-05 01:46:41 +08:00
|
|
|
|
2006-04-09 20:33:32 +08:00
|
|
|
static void
|
2006-04-29 06:26:51 +08:00
|
|
|
gimp_plug_in_manager_add_from_rc (GimpPlugInManager *manager,
|
|
|
|
PlugInDef *plug_in_def)
|
2006-04-09 20:33:32 +08:00
|
|
|
{
|
|
|
|
GSList *list;
|
|
|
|
gchar *basename1;
|
|
|
|
|
2006-04-29 06:26:51 +08:00
|
|
|
g_return_if_fail (GIMP_IS_PLUG_IN_MANAGER (manager));
|
2006-04-09 20:33:32 +08:00
|
|
|
g_return_if_fail (plug_in_def != NULL);
|
|
|
|
g_return_if_fail (plug_in_def->prog != NULL);
|
|
|
|
|
|
|
|
if (! g_path_is_absolute (plug_in_def->prog))
|
|
|
|
{
|
|
|
|
g_warning ("plug_ins_def_add_from_rc: filename not absolute (skipping)");
|
|
|
|
plug_in_def_free (plug_in_def);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
basename1 = g_path_get_basename (plug_in_def->prog);
|
|
|
|
|
|
|
|
/* If this is a file load or save plugin, make sure we have
|
|
|
|
* something for one of the extensions, prefixes, or magic number.
|
2006-09-05 17:45:48 +08:00
|
|
|
* Other bits of code rely on detecting file plugins by the
|
|
|
|
* presence of one of these things, but the raw plug-in needs to be
|
|
|
|
* able to register no extensions, prefixes or magics.
|
2006-04-09 20:33:32 +08:00
|
|
|
*/
|
|
|
|
for (list = plug_in_def->procedures; list; list = list->next)
|
|
|
|
{
|
|
|
|
GimpPlugInProcedure *proc = list->data;
|
|
|
|
|
|
|
|
if (! proc->extensions &&
|
|
|
|
! proc->prefixes &&
|
|
|
|
! proc->magics &&
|
2006-04-12 20:49:29 +08:00
|
|
|
proc->menu_paths &&
|
2006-11-13 04:30:50 +08:00
|
|
|
(g_str_has_prefix (proc->menu_paths->data, "<Load>") ||
|
|
|
|
g_str_has_prefix (proc->menu_paths->data, "<Save>")))
|
2006-04-12 20:49:29 +08:00
|
|
|
{
|
|
|
|
proc->extensions = g_strdup ("");
|
|
|
|
}
|
2006-04-09 20:33:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Check if the entry mentioned in pluginrc matches an executable
|
|
|
|
* found in the plug_in_path.
|
|
|
|
*/
|
2006-04-29 06:26:51 +08:00
|
|
|
for (list = manager->plug_in_defs; list; list = list->next)
|
2006-04-09 20:33:32 +08:00
|
|
|
{
|
|
|
|
PlugInDef *ondisk_plug_in_def = list->data;
|
|
|
|
gchar *basename2;
|
|
|
|
|
|
|
|
basename2 = g_path_get_basename (ondisk_plug_in_def->prog);
|
|
|
|
|
|
|
|
if (! strcmp (basename1, basename2))
|
2006-04-12 20:49:29 +08:00
|
|
|
{
|
|
|
|
if (! g_ascii_strcasecmp (plug_in_def->prog,
|
2006-04-09 20:33:32 +08:00
|
|
|
ondisk_plug_in_def->prog) &&
|
2006-04-12 20:49:29 +08:00
|
|
|
(plug_in_def->mtime == ondisk_plug_in_def->mtime))
|
|
|
|
{
|
|
|
|
/* Use pluginrc entry, deleting ondisk entry */
|
|
|
|
list->data = plug_in_def;
|
|
|
|
plug_in_def_free (ondisk_plug_in_def);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-04-09 20:33:32 +08:00
|
|
|
/* Use ondisk entry, deleting pluginrc entry */
|
2006-04-12 20:49:29 +08:00
|
|
|
plug_in_def_free (plug_in_def);
|
|
|
|
}
|
2006-04-09 20:33:32 +08:00
|
|
|
|
2006-04-12 20:49:29 +08:00
|
|
|
g_free (basename2);
|
|
|
|
g_free (basename1);
|
2006-04-09 20:33:32 +08:00
|
|
|
|
2006-04-12 20:49:29 +08:00
|
|
|
return;
|
|
|
|
}
|
2006-04-09 20:33:32 +08:00
|
|
|
|
|
|
|
g_free (basename2);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_free (basename1);
|
|
|
|
|
2006-04-29 06:26:51 +08:00
|
|
|
manager->write_pluginrc = TRUE;
|
2006-04-09 20:33:32 +08:00
|
|
|
g_printerr ("executable not found: '%s'\n",
|
|
|
|
gimp_filename_to_utf8 (plug_in_def->prog));
|
|
|
|
plug_in_def_free (plug_in_def);
|
|
|
|
}
|
|
|
|
|
2002-03-21 01:46:13 +08:00
|
|
|
static void
|
2006-04-29 06:26:51 +08:00
|
|
|
gimp_plug_in_manager_add_to_db (GimpPlugInManager *manager,
|
|
|
|
GimpContext *context,
|
|
|
|
GimpPlugInProcedure *proc)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2006-04-29 06:26:51 +08:00
|
|
|
gimp_pdb_register_procedure (manager->gimp->pdb, GIMP_PROCEDURE (proc));
|
2002-03-21 01:46:13 +08:00
|
|
|
|
2006-04-11 03:47:58 +08:00
|
|
|
if (proc->file_proc)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2006-04-11 03:47:58 +08:00
|
|
|
GValueArray *return_vals;
|
2002-03-21 01:46:13 +08:00
|
|
|
|
2006-04-11 03:47:58 +08:00
|
|
|
if (proc->image_types)
|
2002-03-21 01:46:13 +08:00
|
|
|
{
|
2006-04-11 03:47:58 +08:00
|
|
|
return_vals =
|
2006-04-29 06:26:51 +08:00
|
|
|
gimp_pdb_execute_procedure_by_name (manager->gimp->pdb,
|
|
|
|
context, NULL,
|
2006-04-26 17:13:47 +08:00
|
|
|
"gimp-register-save-handler",
|
|
|
|
G_TYPE_STRING, GIMP_OBJECT (proc)->name,
|
|
|
|
G_TYPE_STRING, proc->extensions,
|
|
|
|
G_TYPE_STRING, proc->prefixes,
|
|
|
|
G_TYPE_NONE);
|
2006-04-11 03:47:58 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return_vals =
|
2006-04-29 06:26:51 +08:00
|
|
|
gimp_pdb_execute_procedure_by_name (manager->gimp->pdb,
|
|
|
|
context, NULL,
|
2006-04-26 17:13:47 +08:00
|
|
|
"gimp-register-magic-load-handler",
|
|
|
|
G_TYPE_STRING, GIMP_OBJECT (proc)->name,
|
|
|
|
G_TYPE_STRING, proc->extensions,
|
|
|
|
G_TYPE_STRING, proc->prefixes,
|
|
|
|
G_TYPE_STRING, proc->magics,
|
|
|
|
G_TYPE_NONE);
|
2006-04-11 03:47:58 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2006-04-11 03:47:58 +08:00
|
|
|
g_value_array_free (return_vals);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-07-17 05:47:06 +08:00
|
|
|
static gint
|
2006-04-29 06:26:51 +08:00
|
|
|
gimp_plug_in_manager_file_proc_compare (gconstpointer a,
|
|
|
|
gconstpointer b,
|
|
|
|
gpointer data)
|
2004-07-17 05:47:06 +08:00
|
|
|
{
|
2006-04-29 06:26:51 +08:00
|
|
|
const GimpPlugInProcedure *proc_a = a;
|
|
|
|
const GimpPlugInProcedure *proc_b = b;
|
2006-04-05 16:38:33 +08:00
|
|
|
gchar *label_a;
|
|
|
|
gchar *label_b;
|
2006-04-29 06:26:51 +08:00
|
|
|
gint retval = 0;
|
2004-07-17 05:47:06 +08:00
|
|
|
|
2006-11-13 04:30:50 +08:00
|
|
|
if (g_str_has_prefix (proc_a->prog, "gimp-xcf"))
|
2004-07-17 05:47:06 +08:00
|
|
|
return -1;
|
2005-11-01 18:20:38 +08:00
|
|
|
|
2006-11-13 04:30:50 +08:00
|
|
|
if (g_str_has_prefix (proc_b->prog, "gimp-xcf"))
|
2004-07-17 05:47:06 +08:00
|
|
|
return 1;
|
|
|
|
|
2007-02-18 22:25:34 +08:00
|
|
|
label_a = gimp_plug_in_procedure_get_label (proc_a);
|
|
|
|
label_b = gimp_plug_in_procedure_get_label (proc_b);
|
2004-07-17 05:47:06 +08:00
|
|
|
|
|
|
|
if (label_a && label_b)
|
|
|
|
retval = g_utf8_collate (label_a, label_b);
|
|
|
|
|
|
|
|
g_free (label_a);
|
|
|
|
g_free (label_b);
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|