Commit 0f77b422 authored by Michael Natterer's avatar Michael Natterer Committed by Michael Natterer

Makefile.am libgimpmodule/.cvsignore libgimpmodule/Makefile.am

2002-10-21  Michael Natterer  <mitch@gimp.org>

	* Makefile.am
	* libgimpmodule/.cvsignore
	* libgimpmodule/Makefile.am
	* libgimpmodule/gimpmodule.[ch]
	* libgimpmodule/gimpmodule.def
	* libgimpmodule/gimpmoduletypes.h
	* libgimpmodule/makefile.msc: new library for module loading.

	* configure.in: generate Makefiles for libgimpmodule and its
	devel-docs. Added GMODULE_CFLAGS and GMODULE_LIBS.

	* app/Makefile.am: link the app against it.

	* libgimp/gimpmodule.h
	* app/core/gimpmoduleinfo.[ch]: removed.

	* libgimp/Makefile.am
	* app/core/Makefile.am
	* app/core/core-types.h
	* app/core/gimpmodules.c
	* app/gui/module-browser.c: changed accordingly.

	* modules/cdisplay_gamma.c
	* modules/cdisplay_highcontrast.c
	* modules/colorsel_triangle.c
	* modules/colorsel_water.c: #include "libgimpmodule/gimpmodule.h"

2002-10-21  Michael Natterer  <mitch@gimp.org>

	* Makefile.am
	* libgimpmodule/.cvsignore
	* libgimpmodule/Makefile.am
	* libgimpmodule/libgimpmodule-docs.sgml
	* libgimpmodule/libgimpmodule-sections.txt
	* libgimpmodule/libgimpmodule.types
	* libgimpmodule/tmpl/.cvsignore
	* libgimpmodule/tmpl/gimpmodule.sgml
	* libgimpmodule/tmpl/gimpmoduletypes.sgml: added API docs for the
	new module loading lib.

	* libgimp/tmpl/gimpmodule.sgml: removed.

	* libgimp/libgimp-docs.sgml
	* libgimp/libgimp-sections.txt: changed accordingly.

	* libgimpwidgets/tmpl/gimpcolordisplay.sgml
	* libgimpwidgets/tmpl/gimpcolorselect.sgml
	* libgimpwidgets/tmpl/gimpcolorselector.sgml: updated.

2002-10-21  Michael Natterer  <mitch@gimp.org>

	* POTFILES.in: removed app/core/gimpmoduleinfo.c

2002-10-21  Michael Natterer  <mitch@gimp.org>

	* POTFILES.in: added libgimpmodule/gimpmodule.c
parent fc451d33
2002-10-21 Michael Natterer <mitch@gimp.org>
* Makefile.am
* libgimpmodule/.cvsignore
* libgimpmodule/Makefile.am
* libgimpmodule/gimpmodule.[ch]
* libgimpmodule/gimpmodule.def
* libgimpmodule/gimpmoduletypes.h
* libgimpmodule/makefile.msc: new library for module loading.
* configure.in: generate Makefiles for libgimpmodule and its
devel-docs. Added GMODULE_CFLAGS and GMODULE_LIBS.
* app/Makefile.am: link the app against it.
* libgimp/gimpmodule.h
* app/core/gimpmoduleinfo.[ch]: removed.
* libgimp/Makefile.am
* app/core/Makefile.am
* app/core/core-types.h
* app/core/gimpmodules.c
* app/gui/module-browser.c: changed accordingly.
* modules/cdisplay_gamma.c
* modules/cdisplay_highcontrast.c
* modules/colorsel_triangle.c
* modules/colorsel_water.c: #include "libgimpmodule/gimpmodule.h"
2002-10-20 Michael Natterer <mitch@gimp.org>
* app/core/gimpmoduleinfo.[ch]
......
......@@ -15,9 +15,10 @@ SUBDIRS = \
data \
etc \
tips \
libgimpbase \
libgimpcolor \
libgimpmath \
libgimpbase \
libgimpmodule \
libgimpwidgets \
libgimpproxy \
libgimptool \
......
......@@ -115,6 +115,7 @@ gimp_1_3_LDADD = \
$(top_builddir)/libgimpcolor/libgimpcolor-$(LT_RELEASE).la \
$(top_builddir)/libgimpmath/libgimpmath-$(LT_RELEASE).la \
$(top_builddir)/libgimpbase/libgimpbase-$(LT_RELEASE).la \
$(top_builddir)/libgimpmodule/libgimpmodule-$(LT_RELEASE).la \
$(top_builddir)/libgimpwidgets/libgimpwidgets-$(LT_RELEASE).la \
$(top_builddir)/libgimptool/libgimptool-$(LT_RELEASE).la \
$(GTK_LIBS) \
......
......@@ -134,8 +134,6 @@ libappcore_a_sources = \
gimplayermask.h \
gimplist.c \
gimplist.h \
gimpmoduleinfo.c \
gimpmoduleinfo.h \
gimpmodules.c \
gimpmodules.h \
gimpobject.c \
......
......@@ -23,6 +23,7 @@
#include "libgimpmath/gimpmath.h"
#include "libgimpmodule/gimpmoduletypes.h"
#include "base/base-types.h"
......@@ -106,8 +107,6 @@ typedef struct _Gimp Gimp;
typedef struct _GimpParasiteList GimpParasiteList;
typedef struct _GimpModuleInfoObj GimpModuleInfoObj;
typedef struct _GimpContainer GimpContainer;
typedef struct _GimpList GimpList;
typedef struct _GimpDataList GimpDataList;
......
......@@ -32,6 +32,7 @@
#include <glib-object.h>
#include "libgimpbase/gimpbase.h"
#include "libgimpmodule/gimpmodule.h"
#include "core-types.h"
......@@ -39,7 +40,6 @@
#include "gimpcoreconfig.h"
#include "gimpdatafiles.h"
#include "gimplist.h"
#include "gimpmoduleinfo.h"
#include "gimpmodules.h"
#include "gimprc.h"
......@@ -50,23 +50,23 @@
#define DUMP_DB 1
static void gimp_modules_module_initialize (const gchar *filename,
gpointer loader_data);
static void gimp_modules_module_initialize (const gchar *filename,
gpointer loader_data);
static GimpModuleInfoObj * gimp_modules_module_find_by_path (Gimp *gimp,
const char *fullpath);
static GimpModule * gimp_modules_module_find_by_path (Gimp *gimp,
const char *fullpath);
#ifdef DUMP_DB
static void print_module_info (gpointer data,
gpointer user_data);
static void gimp_modules_dump_module (gpointer data,
gpointer user_data);
#endif
static gboolean gimp_modules_write_modulerc (Gimp *gimp);
static gboolean gimp_modules_write_modulerc (Gimp *gimp);
static void gimp_modules_module_on_disk_func (gpointer data,
gpointer user_data);
static void gimp_modules_module_remove_func (gpointer data,
gpointer user_data);
static void gimp_modules_module_on_disk_func (gpointer data,
gpointer user_data);
static void gimp_modules_module_remove_func (gpointer data,
gpointer user_data);
void
......@@ -74,7 +74,7 @@ gimp_modules_init (Gimp *gimp)
{
g_return_if_fail (GIMP_IS_GIMP (gimp));
gimp->modules = gimp_list_new (GIMP_TYPE_MODULE_INFO,
gimp->modules = gimp_list_new (GIMP_TYPE_MODULE,
GIMP_CONTAINER_POLICY_STRONG);
gimp_object_set_name (GIMP_OBJECT (gimp->modules), "modules");
......@@ -111,7 +111,7 @@ gimp_modules_load (Gimp *gimp)
gimp);
#ifdef DUMP_DB
gimp_container_foreach (gimp->modules, print_module_info, NULL);
gimp_container_foreach (gimp->modules, gimp_modules_dump_module, NULL);
#endif
}
......@@ -156,13 +156,13 @@ static void
add_to_inhibit_string (gpointer data,
gpointer user_data)
{
GimpModuleInfoObj *module_info = data;
GString *str = user_data;
GimpModule *module = data;
GString *str = user_data;
if (module_info->load_inhibit)
if (module->load_inhibit)
{
str = g_string_append_c (str, G_SEARCHPATH_SEPARATOR);
str = g_string_append (str, module_info->filename);
str = g_string_append (str, module->filename);
}
}
......@@ -239,8 +239,8 @@ static void
gimp_modules_module_initialize (const gchar *filename,
gpointer loader_data)
{
GimpModuleInfoObj *module_info;
Gimp *gimp;
GimpModule *module;
Gimp *gimp;
gimp = GIMP (loader_data);
......@@ -251,26 +251,26 @@ gimp_modules_module_initialize (const gchar *filename,
if (gimp_modules_module_find_by_path (gimp, filename))
return;
module_info = gimp_module_info_new (filename,
gimp->config->module_db_load_inhibit,
gimp->be_verbose);
module = gimp_module_new (filename,
gimp->config->module_db_load_inhibit,
gimp->be_verbose);
gimp_container_add (gimp->modules, (GimpObject *) module_info);
gimp_container_add (gimp->modules, (GimpObject *) module);
}
static GimpModuleInfoObj *
static GimpModule *
gimp_modules_module_find_by_path (Gimp *gimp,
const char *fullpath)
{
GimpModuleInfoObj *module_info;
GList *list;
GimpModule *module;
GList *list;
for (list = GIMP_LIST (gimp->modules)->list; list; list = g_list_next (list))
{
module_info = (GimpModuleInfoObj *) list->data;
module = (GimpModule *) list->data;
if (! strcmp (module_info->filename, fullpath))
return module_info;
if (! strcmp (module->filename, fullpath))
return module;
}
return NULL;
......@@ -278,10 +278,10 @@ gimp_modules_module_find_by_path (Gimp *gimp,
#ifdef DUMP_DB
static void
print_module_info (gpointer data,
gpointer user_data)
gimp_modules_dump_module (gpointer data,
gpointer user_data)
{
GimpModuleInfoObj *i = data;
GimpModule *i = data;
g_print ("\n%s: %i\n",
i->filename,
......@@ -293,16 +293,19 @@ print_module_info (gpointer data,
i->query_module,
i->register_module);
g_print (" purpose: %s\n"
" author: %s\n"
" version: %s\n"
" copyright: %s\n"
" date: %s\n",
i->info.purpose ? i->info.purpose : "NONE",
i->info.author ? i->info.author : "NONE",
i->info.version ? i->info.version : "NONE",
i->info.copyright ? i->info.copyright : "NONE",
i->info.date ? i->info.date : "NONE");
if (i->info)
{
g_print (" purpose: %s\n"
" author: %s\n"
" version: %s\n"
" copyright: %s\n"
" date: %s\n",
i->info->purpose ? i->info->purpose : "NONE",
i->info->author ? i->info->author : "NONE",
i->info->version ? i->info->version : "NONE",
i->info->copyright ? i->info->copyright : "NONE",
i->info->date ? i->info->date : "NONE");
}
}
#endif
......@@ -310,40 +313,39 @@ static void
gimp_modules_module_on_disk_func (gpointer data,
gpointer user_data)
{
GimpModuleInfoObj *module_info;
GList **kill_list;
gint old_on_disk;
GimpModule *module;
GList **kill_list;
gint old_on_disk;
module_info = (GimpModuleInfoObj *) data;
kill_list = (GList **) user_data;
module = (GimpModule *) data;
kill_list = (GList **) user_data;
old_on_disk = module_info->on_disk;
old_on_disk = module->on_disk;
module_info->on_disk = g_file_test (module_info->filename,
G_FILE_TEST_IS_REGULAR);
module->on_disk = g_file_test (module->filename, G_FILE_TEST_IS_REGULAR);
/* if it's not on the disk, and it isn't in memory, mark it to be
* removed later.
*/
if (! module_info->on_disk && ! module_info->module)
if (! module->on_disk && ! module->module)
{
*kill_list = g_list_append (*kill_list, module_info);
module_info = NULL;
*kill_list = g_list_append (*kill_list, module);
module = NULL;
}
if (module_info && module_info->on_disk != old_on_disk)
gimp_module_info_modified (module_info);
if (module && module->on_disk != old_on_disk)
gimp_module_modified (module);
}
static void
gimp_modules_module_remove_func (gpointer data,
gpointer user_data)
{
GimpModuleInfoObj *module_info;
Gimp *gimp;
GimpModule *module;
Gimp *gimp;
module_info = (GimpModuleInfoObj *) data;
gimp = (Gimp *) user_data;
module = (GimpModule *) data;
gimp = (Gimp *) user_data;
gimp_container_remove (gimp->modules, (GimpObject *) module_info);
gimp_container_remove (gimp->modules, (GimpObject *) module);
}
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpmoduleinfo.c
* (C) 1999 Austin Donnelly <austin@gimp.org>
*
* 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 "libgimp/gimpmodule.h"
#include "core-types.h"
#include "gimpmarshal.h"
#include "gimpmoduleinfo.h"
#include "libgimp/gimpintl.h"
enum
{
MODIFIED,
LAST_SIGNAL
};
static void gimp_module_info_class_init (GimpModuleInfoObjClass *klass);
static void gimp_module_info_init (GimpModuleInfoObj *mod);
static void gimp_module_info_finalize (GObject *object);
static gboolean gimp_module_info_load (GTypeModule *module);
static void gimp_module_info_unload (GTypeModule *module);
static void gimp_module_info_set_last_error (GimpModuleInfoObj *module_info,
const gchar *error_str);
static guint module_info_signals[LAST_SIGNAL];
static GTypeModuleClass *parent_class = NULL;
GType
gimp_module_info_get_type (void)
{
static GType module_info_type = 0;
if (! module_info_type)
{
static const GTypeInfo module_info_info =
{
sizeof (GimpModuleInfoObjClass),
NULL, /* base_init */
NULL, /* base_finalize */
(GClassInitFunc) gimp_module_info_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GimpModuleInfoObj),
0, /* n_preallocs */
(GInstanceInitFunc) gimp_module_info_init,
};
module_info_type = g_type_register_static (G_TYPE_TYPE_MODULE,
"GimpModuleInfoObj",
&module_info_info, 0);
}
return module_info_type;
}
static void
gimp_module_info_class_init (GimpModuleInfoObjClass *klass)
{
GObjectClass *object_class;
GTypeModuleClass *module_class;
object_class = G_OBJECT_CLASS (klass);
module_class = G_TYPE_MODULE_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
module_info_signals[MODIFIED] =
g_signal_new ("modified",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GimpModuleInfoObjClass, modified),
NULL, NULL,
gimp_marshal_VOID__VOID,
G_TYPE_NONE, 0);
object_class->finalize = gimp_module_info_finalize;
module_class->load = gimp_module_info_load;
module_class->unload = gimp_module_info_unload;
klass->modified = NULL;
}
static void
gimp_module_info_init (GimpModuleInfoObj *module_info)
{
module_info->filename = NULL;
module_info->verbose = FALSE;
module_info->state = GIMP_MODULE_STATE_ERROR;
module_info->on_disk = FALSE;
module_info->load_inhibit = FALSE;
module_info->module = NULL;
module_info->last_module_error = NULL;
module_info->register_module = NULL;
}
static void
gimp_module_info_finalize (GObject *object)
{
GimpModuleInfoObj *mod;
mod = GIMP_MODULE_INFO (object);
if (mod->last_module_error)
{
g_free (mod->last_module_error);
mod->last_module_error = NULL;
}
if (mod->filename)
{
g_free (mod->filename);
mod->filename = NULL;
}
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static gboolean
gimp_module_info_load (GTypeModule *module)
{
GimpModuleInfoObj *module_info;
const GimpModuleInfo *info;
gpointer symbol;
gboolean retval;
g_return_val_if_fail (GIMP_IS_MODULE_INFO (module), FALSE);
module_info = GIMP_MODULE_INFO (module);
g_return_val_if_fail (module_info->filename != NULL, FALSE);
g_return_val_if_fail (module_info->module == NULL, FALSE);
if (module_info->verbose)
g_print (_("loading module: '%s'\n"), module_info->filename);
module_info->module = g_module_open (module_info->filename,
G_MODULE_BIND_LAZY);
if (! module_info->module)
{
module_info->state = GIMP_MODULE_STATE_ERROR;
gimp_module_info_set_last_error (module_info, g_module_error ());
if (module_info->verbose)
g_message (_("Module '%s' load error:\n%s"),
module_info->filename, module_info->last_module_error);
return FALSE;
}
/* find the gimp_module_query symbol */
if (! g_module_symbol (module_info->module, "gimp_module_query", &symbol))
{
module_info->state = GIMP_MODULE_STATE_ERROR;
gimp_module_info_set_last_error (module_info,
_("Missing gimp_module_query() symbol"));
if (module_info->verbose)
g_message (_("Module '%s' load error:\n%s"),
module_info->filename, module_info->last_module_error);
g_module_close (module_info->module);
module_info->module = NULL;
return FALSE;
}
module_info->query_module = symbol;
info = module_info->query_module (module);
if (! info)
{
module_info->state = GIMP_MODULE_STATE_ERROR;
gimp_module_info_set_last_error (module_info,
_("gimp_module_query() returned NULL"));
if (module_info->verbose)
g_message (_("Module '%s' load error:\n%s"),
module_info->filename, module_info->last_module_error);
g_module_close (module_info->module);
module_info->module = NULL;
module_info->query_module = NULL;
return FALSE;
}
g_free ((gchar *) module_info->info.purpose);
module_info->info.purpose = g_strdup (info->purpose);
g_free ((gchar *) module_info->info.author);
module_info->info.author = g_strdup (info->author);
g_free ((gchar *) module_info->info.version);
module_info->info.version = g_strdup (info->version);
g_free ((gchar *) module_info->info.copyright);
module_info->info.copyright = g_strdup (info->copyright);
g_free ((gchar *) module_info->info.date);
module_info->info.date = g_strdup (info->date);
/* find the gimp_module_register symbol */
if (! g_module_symbol (module_info->module, "gimp_module_register", &symbol))
{
module_info->state = GIMP_MODULE_STATE_ERROR;
gimp_module_info_set_last_error (module_info,
_("Missing gimp_module_register() symbol"));
if (module_info->verbose)
g_message (_("Module '%s' load error:\n%s"),
module_info->filename, module_info->last_module_error);
g_module_close (module_info->module);
module_info->module = NULL;
return FALSE;
}
module_info->register_module = symbol;
retval = module_info->register_module (module);
if (retval)
module_info->state = GIMP_MODULE_STATE_LOADED_OK;
else
module_info->state = GIMP_MODULE_STATE_LOAD_FAILED;
return retval;
}
static void
gimp_module_info_unload (GTypeModule *module)
{
GimpModuleInfoObj *module_info;
g_return_if_fail (GIMP_IS_MODULE_INFO (module));
module_info = GIMP_MODULE_INFO (module);
g_return_if_fail (module_info->module != NULL);
g_module_close (module_info->module); /* FIXME: error handling */
module_info->module = NULL;
module_info->query_module = NULL;
module_info->register_module = NULL;
module_info->state = GIMP_MODULE_STATE_UNLOADED_OK;
}
GimpModuleInfoObj *
gimp_module_info_new (const gchar *filename,
const gchar *inhibit_list,
gboolean verbose)
{
GimpModuleInfoObj *module_info;
g_return_val_if_fail (filename != NULL, NULL);
module_info = g_object_new (GIMP_TYPE_MODULE_INFO, NULL);
module_info->filename = g_strdup (filename);
module_info->verbose = verbose ? TRUE : FALSE;
module_info->on_disk = TRUE;
gimp_module_info_set_load_inhibit (module_info, inhibit_list);
if (! module_info->load_inhibit)
{
if (gimp_module_info_load (G_TYPE_MODULE (module_info)))
gimp_module_info_unload (G_TYPE_MODULE (module_info));
}
else
{
if (verbose)
g_print (_("skipping module: '%s'\n"), filename);
module_info->state = GIMP_MODULE_STATE_UNLOADED_OK;
}
return module_info;
}
void
gimp_module_info_modified (GimpModuleInfoObj *module_info)
{
g_return_if_fail (GIMP_IS_MODULE_INFO (module_info));
g_signal_emit (G_OBJECT (module_info), module_info_signals[MODIFIED], 0);
}
void
gimp_module_info_set_load_inhibit (GimpModuleInfoObj *module_info,
const gchar *inhibit_list)
{
gchar *p;
gint pathlen;
const gchar *start;
const gchar *end;
g_return_if_fail (GIMP_IS_MODULE_INFO (module_info));
g_return_if_fail (module_info->filename != NULL);
module_info->load_inhibit = FALSE;
if (! inhibit_list || ! strlen (inhibit_list))
return;
p = strstr (inhibit_list, module_info->filename);
if (!p)
return;
/* we have a substring, but check for colons either side */
start = p;
while (start != inhibit_list && *start != G_SEARCHPATH_SEPARATOR)
start--;
if (*start == G_SEARCHPATH_SEPARATOR)
start++;
end = strchr (p, G_SEARCHPATH_SEPARATOR);
if (! end)
end = inhibit_list + strlen (inhibit_list);
pathlen = strlen (module_info->filename);
if ((end - start) == pathlen)
module_info->load_inhibit = TRUE;
}
static void
gimp_module_info_set_last_error (GimpModuleInfoObj *module_info,
const gchar *error_str)
{
if (module_info->last_module_error)
g_free (module_info->last_module_error);
module_info->last_module_error = g_strdup (error_str);
}
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpmoduleinfo.h
* (C) 1999 Austin Donnelly <austin@gimp.org>
*
* 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 __GIMP_MODULE_INFO_H__
#define __GIMP_MODULE_INFO_H__
#include "libgimp/gimpmodule.h"
typedef enum
{
GIMP_MODULE_STATE_ERROR, /* missing module_load function or other error */
GIMP_MODULE_STATE_LOADED_OK, /* happy and running (normal state of affairs) */
GIMP_MODULE_STATE_LOAD_FAILED, /* module_load returned GIMP_MODULE_UNLOAD */
GIMP_MODULE_STATE_UNLOAD_REQUESTED, /* sent unload request, waiting for callback */
GIMP_MODULE_STATE_UNLOADED_OK /* callback arrived, module not in memory anymore */
} GimpModuleState;
#define GIMP_TYPE_MODULE_INFO (gimp_module_info_get_type ())