Commit be86df2a authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

app/Makefile.am removed.

2001-10-18  Michael Natterer  <mitch@gimp.org>

	* app/Makefile.am
	* app/module_db.[ch]: removed.

	* app/core/Makefile.am
	* app/core/core-types.h
	* app/core/gimpmoduleinfo.[ch]
	* app/core/gimpmodules.[ch]: new files containing the module info
	object and the module list handling code.

	* app/gui/Makefile.am
	* app/gui/module-browser.[ch]: new files containing the GUI.

	* app/xcf/xcf.[ch]: pass a "Gimp" pointer to xcf_exit().

	* app/core/gimp.[ch]: handle modules and xcf init/exit here too.

	* app/app_procs.c: don't touch the modules and xcf stuff any more.

	* app/gui/dialogs-constructors.c: changed accordingly.

2001-10-18  Michael Natterer  <mitch@gimp.org>

	* POTFILES.in: module_db.c has moved.
parent 31f690cf
2001-10-18 Michael Natterer <mitch@gimp.org>
* app/Makefile.am
* app/module_db.[ch]: removed.
* app/core/Makefile.am
* app/core/core-types.h
* app/core/gimpmoduleinfo.[ch]
* app/core/gimpmodules.[ch]: new files containing the module info
object and the module list handling code.
* app/gui/Makefile.am
* app/gui/module-browser.[ch]: new files containing the GUI.
* app/xcf/xcf.[ch]: pass a "Gimp" pointer to xcf_exit().
* app/core/gimp.[ch]: handle modules and xcf init/exit here too.
* app/app_procs.c: don't touch the modules and xcf stuff any more.
* app/gui/dialogs-constructors.c: changed accordingly.
2001-10-18 Michael Natterer <mitch@gimp.org>
* app/core/gimpcontainer.[ch]: added properties for "children_type"
......
......@@ -31,8 +31,6 @@ gimp_SOURCES = @STRIP_BEGIN@ \
##
image_map.c \
image_map.h \
module_db.c \
module_db.h \
user_install.c \
user_install.h \
##
......@@ -130,10 +128,10 @@ gimp_LDADD = @STRIP_BEGIN@ \
tools/libapptools.a \
display/libappdisplay.a \
widgets/libappwidgets.a \
xcf/libappxcf.a \
plug-in/libappplug-in.a \
pdb/libapppdb.a \
core/libappcore.a \
xcf/libappxcf.a \
paint-funcs/libapppaint-funcs.a \
base/libappbase.a \
$(top_builddir)/libgimpcolor/libgimpcolor-$(LT_RELEASE).la \
......
......@@ -43,8 +43,6 @@
#include "pdb/internal_procs.h"
#include "xcf/xcf.h"
#include "display/gimpdisplay-foreach.h"
#include "tools/tool_manager.h"
......@@ -60,7 +58,6 @@
#include "docindex.h"
#include "errors.h"
#include "gimprc.h"
#include "module_db.h"
#include "plug_in.h"
#include "undo.h"
#include "user_install.h"
......@@ -99,7 +96,7 @@ app_init (gint gimp_argc,
/* Create an instance of the "Gimp" object which is the root of the
* core object system
*/
the_gimp = gimp_new ();
the_gimp = gimp_new (be_verbose);
/* Check if the user's gimp_directory exists
*/
......@@ -162,10 +159,6 @@ app_init (gint gimp_argc,
app_init_update_status (_("Procedural Database"), NULL, -1);
internal_procs_init (the_gimp);
/* Initialize the xcf file format routines
*/
xcf_init (the_gimp);
/* Now we are ready to draw the splash-screen-image
* to the start-up window
*/
......@@ -179,7 +172,6 @@ app_init (gint gimp_argc,
gimp_restore (the_gimp, no_data);
plug_in_init (); /* initialize the plug in structures */
module_db_init (); /* load any modules we need */
if (! no_interface)
{
......@@ -241,7 +233,6 @@ app_exit_finish (void)
gui_shutdown (the_gimp);
}
module_db_free ();
plug_in_kill ();
tool_manager_exit (the_gimp);
......@@ -251,8 +242,6 @@ app_exit_finish (void)
gui_exit (the_gimp);
}
xcf_exit ();
gimp_shutdown (the_gimp);
g_object_unref (G_OBJECT (the_gimp));
......
......@@ -89,6 +89,10 @@ libappcore_a_sources = @STRIP_BEGIN@ \
gimplayermask.h \
gimplist.c \
gimplist.h \
gimpmoduleinfo.c \
gimpmoduleinfo.h \
gimpmodules.c \
gimpmodules.h \
gimpobject.c \
gimpobject.h \
gimppattern.c \
......
......@@ -165,6 +165,8 @@ typedef struct _Gimp Gimp;
typedef struct _GimpParasiteList GimpParasiteList;
typedef struct _GimpModuleInfoObj GimpModuleInfoObj;
typedef struct _GimpContainer GimpContainer;
typedef struct _GimpList GimpList;
typedef struct _GimpDataList GimpDataList;
......
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpmodules.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 <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <time.h>
#include <glib-object.h>
#include "libgimpbase/gimpbase.h"
#include "core-types.h"
#include "core/gimp.h"
#include "core/gimpcoreconfig.h"
#include "core/gimpdatafiles.h"
#include "core/gimplist.h"
#include "core/gimpmoduleinfo.h"
#include "core/gimpmodules.h"
#include "gimprc.h"
#include "libgimp/gimpintl.h"
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);
#ifdef DUMP_DB
static void print_module_info (gpointer data,
gpointer user_data);
#endif
static gboolean gimp_modules_write_modulerc (Gimp *gimp);
static void gimp_modules_module_free_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
gimp_modules_init (Gimp *gimp)
{
g_return_if_fail (GIMP_IS_GIMP (gimp));
gimp->modules = gimp_list_new (GIMP_TYPE_MODULE_INFO,
GIMP_CONTAINER_POLICY_STRONG);
gimp->write_modulerc = FALSE;
}
void
gimp_modules_exit (Gimp *gimp)
{
g_return_if_fail (GIMP_IS_GIMP (gimp));
if (gimp->modules)
{
g_object_unref (G_OBJECT (gimp->modules));
gimp->modules = NULL;
}
}
void
gimp_modules_load (Gimp *gimp)
{
gchar *filename;
g_return_if_fail (GIMP_IS_GIMP (gimp));
filename = gimp_personal_rc_file ("modulerc");
gimprc_parse_file (filename);
g_free (filename);
if (g_module_supported ())
gimp_datafiles_read_directories (gimp->config->module_path,
0 /* no flags */,
gimp_modules_module_initialize,
gimp);
#ifdef DUMP_DB
gimp_container_foreach (modules, print_module_info, NULL);
#endif
}
void
gimp_modules_unload (Gimp *gimp)
{
g_return_if_fail (GIMP_IS_GIMP (gimp));
if (gimp->write_modulerc)
{
if (gimp_modules_write_modulerc (gimp))
{
gimp->write_modulerc = FALSE;
}
}
gimp_container_foreach (gimp->modules, gimp_modules_module_free_func, NULL);
}
void
gimp_modules_refresh (Gimp *gimp)
{
GList *kill_list = NULL;
g_return_if_fail (GIMP_IS_GIMP (gimp));
/* remove modules we don't have on disk anymore */
gimp_container_foreach (gimp->modules,
gimp_modules_module_on_disk_func,
&kill_list);
g_list_foreach (kill_list,
gimp_modules_module_remove_func,
gimp);
g_list_free (kill_list);
/* walk filesystem and add new things we find */
gimp_datafiles_read_directories (gimp->config->module_path,
0 /* no flags */,
gimp_modules_module_initialize,
gimp);
}
static void
gimp_modules_module_free_func (gpointer data,
gpointer user_data)
{
GimpModuleInfoObj *module_info = data;
if (module_info->module &&
module_info->unload &&
module_info->state == GIMP_MODULE_STATE_LOADED_OK)
{
gimp_module_info_module_unload (module_info, FALSE);
}
}
static void
add_to_inhibit_string (gpointer data,
gpointer user_data)
{
GimpModuleInfoObj *module_info = data;
GString *str = user_data;
if (module_info->load_inhibit)
{
str = g_string_append_c (str, G_SEARCHPATH_SEPARATOR);
str = g_string_append (str, module_info->fullpath);
}
}
static gboolean
gimp_modules_write_modulerc (Gimp *gimp)
{
GString *str;
gchar *p;
gchar *filename;
FILE *fp;
gboolean saved = FALSE;
str = g_string_new (NULL);
gimp_container_foreach (gimp->modules, add_to_inhibit_string, str);
if (str->len > 0)
p = str->str + 1;
else
p = "";
filename = gimp_personal_rc_file ("modulerc");
fp = fopen (filename, "wt");
g_free (filename);
if (fp)
{
fprintf (fp, "(module-load-inhibit \"%s\")\n", p);
fclose (fp);
saved = TRUE;
}
g_string_free (str, TRUE);
return saved;
}
/* name must be of the form lib*.so (Unix) or *.dll (Win32) */
static gboolean
valid_module_name (const gchar *filename)
{
gchar *basename;
gint len;
basename = g_path_get_basename (filename);
len = strlen (basename);
#if !defined(G_OS_WIN32) && !defined(G_WITH_CYGWIN) && !defined(__EMX__)
if (len < 3 + 1 + 3)
goto no_module;
if (strncmp (basename, "lib", 3))
goto no_module;
if (strcmp (basename + len - 3, ".so"))
goto no_module;
#else
if (len < 1 + 4)
goto no_module;
if (g_strcasecmp (basename + len - 4, ".dll"))
goto no_module;
#endif
g_free (basename);
return TRUE;
no_module:
g_free (basename);
return FALSE;
}
static void
gimp_modules_module_initialize (const gchar *filename,
gpointer loader_data)
{
GimpModuleInfoObj *module_info;
Gimp *gimp;
gimp = GIMP (loader_data);
if (! valid_module_name (filename))
return;
/* don't load if we already know about it */
if (gimp_modules_module_find_by_path (gimp, filename))
return;
module_info = gimp_module_info_new (filename);
gimp_module_info_set_load_inhibit (module_info,
gimp->config->module_db_load_inhibit);
if (! module_info->load_inhibit)
{
if (gimp->be_verbose)
g_print (_("load module: \"%s\"\n"), filename);
gimp_module_info_module_load (module_info, TRUE);
}
else
{
if (gimp->be_verbose)
g_print (_("skipping module: \"%s\"\n"), filename);
module_info->state = GIMP_MODULE_STATE_UNLOADED_OK;
}
gimp_container_add (gimp->modules, GIMP_OBJECT (module_info));
g_object_unref (G_OBJECT (module_info));
}
typedef struct
{
const gchar *search_key;
GimpModuleInfoObj *found;
} find_by_path_closure;
static void
gimp_modules_module_path_cmp_func (gpointer data,
gpointer user_data)
{
GimpModuleInfoObj *module_info;
find_by_path_closure *closure;
module_info = (GimpModuleInfoObj *) data;
closure = (find_by_path_closure *) user_data;
if (! strcmp (module_info->fullpath, closure->search_key))
closure->found = module_info;
}
static GimpModuleInfoObj *
gimp_modules_module_find_by_path (Gimp *gimp,
const char *fullpath)
{
find_by_path_closure cl;
cl.found = NULL;
cl.search_key = fullpath;
gimp_container_foreach (gimp->modules,
gimp_modules_module_path_cmp_func, &cl);
return cl.found;
}
#ifdef DUMP_DB
static void
print_module_info (gpointer data,
gpointer user_data)
{
GimpModuleInfoObj *i = data;
g_print ("\n%s: %s\n",
i->fullpath, statename[i->state]);
g_print (" module:%p lasterr:%s init:%p unload:%p\n",
i->module, i->last_module_error? i->last_module_error : "NONE",
i->init, i->unload);
if (i->info)
{
g_print (" shutdown_data: %p\n"
" purpose: %s\n"
" author: %s\n"
" version: %s\n"
" copyright: %s\n"
" date: %s\n",
i->info->shutdown_data,
i->info->purpose, i->info->author, i->info->version,
i->info->copyright, i->info->date);
}
}
#endif
static void
gimp_modules_module_on_disk_func (gpointer data,
gpointer user_data)
{
GimpModuleInfoObj *module_info;
GList **kill_list;
gint old_on_disk;
struct stat statbuf;
gint ret;
module_info = (GimpModuleInfoObj *) data;
kill_list = (GList **) user_data;
old_on_disk = module_info->on_disk;
ret = stat (module_info->fullpath, &statbuf);
if (ret != 0)
module_info->on_disk = FALSE;
else
module_info->on_disk = TRUE;
/* 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)
{
*kill_list = g_list_append (*kill_list, module_info);
module_info = NULL;
}
if (module_info && module_info->on_disk != old_on_disk)
gimp_module_info_modified (module_info);
}
static void
gimp_modules_module_remove_func (gpointer data,
gpointer user_data)
{
GimpModuleInfoObj *module_info;
Gimp *gimp;
module_info = (GimpModuleInfoObj *) data;
gimp = (Gimp *) user_data;
gimp_container_remove (gimp->modules, GIMP_OBJECT (module_info));
}
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* module_db.h (C) 1999 Austin Donnelly <austin@gimp.org>
* gimpmodules.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
......@@ -18,16 +19,17 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __MODULE_DB_H__
#ifndef __GIMP_MODULES_H__
#define __GIMP_MODULES_H__
/* Load any modules we find on the module-path set in the gimprc */
void module_db_init (void);
void gimp_modules_init (Gimp *gimp);
void gimp_modules_exit (Gimp *gimp);
/* Unload all modules, in case a module needs some cleanups */
void module_db_free (void);
void gimp_modules_load (Gimp *gimp);
void gimp_modules_unload (Gimp *gimp);
GtkWidget * module_db_browser_new (void);
void gimp_modules_refresh (Gimp *gimp);
#endif /* __MODULE_DB_H__ */
#endif /* __GIMP_MODULES_H__ */
......@@ -31,6 +31,8 @@
#include "pdb/procedural_db.h"
#include "xcf/xcf.h"
#include "gimp.h"
#include "gimpbrush.h"
#include "gimpbrushgenerated.h"
......@@ -45,6 +47,7 @@
#include "gimpimage-new.h"
#include "gimpimagefile.h"
#include "gimplist.h"
#include "gimpmodules.h"
#include "gimppalette.h"
#include "gimppattern.h"
#include "gimpparasite.h"
......@@ -115,6 +118,8 @@ gimp_init (Gimp *gimp)
{
gimp_core_config_init (gimp);
gimp->be_verbose = FALSE;
gimp->create_display_func = NULL;
gimp->gui_set_busy_func = NULL;
gimp->gui_unset_busy_func = NULL;
......@@ -126,6 +131,8 @@ gimp_init (Gimp *gimp)
gimp_parasites_init (gimp);
gimp_modules_init (gimp);
gimp->images = gimp_list_new (GIMP_TYPE_IMAGE,
GIMP_CONTAINER_POLICY_WEAK);
gimp->next_image_ID = 1;
......@@ -145,6 +152,8 @@ gimp_init (Gimp *gimp)
procedural_db_init (gimp);
xcf_init (gimp);
gimp->tool_info_list = gimp_list_new (GIMP_TYPE_TOOL_INFO,
GIMP_CONTAINER_POLICY_STRONG);
gimp->standard_tool_info = NULL;
......@@ -220,6 +229,8 @@ gimp_finalize (GObject *object)
gimp->tool_info_list = NULL;
}
xcf_exit (gimp);
if (gimp->procedural_ht)
procedural_db_free (gimp);
......@@ -277,6 +288,9 @@ gimp_finalize (GObject *object)
gimp->images = NULL;
}
if (gimp->modules)
gimp_modules_exit (gimp);
if (gimp->parasites)
gimp_parasites_exit (gimp);
......@@ -287,12 +301,14 @@ gimp_finalize (GObject *object)
}
Gimp *
gimp_new (void)
gimp_new (gboolean be_verbose)
{
Gimp *gimp;
gimp = g_object_new (GIMP_TYPE_GIMP, NULL);
gimp->be_verbose = be_verbose ? TRUE : FALSE;
return gimp;
}
......@@ -412,6 +428,8 @@ gimp_restore (Gimp *gimp,
gimp_documents_load (gimp);
app_init_update_status (NULL, NULL, 1.00);
gimp_modules_load (gimp);
}
void
......@@ -419,6 +437,7 @@ gimp_shutdown (Gimp *gimp)
{
g_return_if_fail (GIMP_IS_GIMP (gimp));
gimp_modules_unload (gimp);
gimp_data_factory_data_save (gimp->brush_factory);
gimp_data_factory_data_save (gimp->pattern_factory);
gimp_data_factory_data_save (gimp->gradient_factory);
......
......@@ -44,6 +44,8 @@ struct _Gimp
GimpCoreConfig *config;
gboolean be_verbose;
GimpCreateDisplayFunc create_display_func;
GimpSetBusyFunc gui_set_busy_func;
GimpUnsetBusyFunc gui_unset_busy_func;
......@@ -56,6 +58,9 @@ struct _Gimp
GimpParasiteList *parasites;
GimpContainer *modules;
gboolean write_modulerc;
GimpContainer *images;
gint next_image_ID;
guint32 next_guide_ID;
......@@ -110,7 +115,7 @@ struct _GimpClass
GType gimp_get_type (void);
Gimp * gimp_new (void);
Gimp * gimp_new (gboolean be_verbose);
void gimp_initialize (Gimp *gimp);
......
/* 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 "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 guint module_info_signals[LAST_SIGNAL];
static GimpObjectClass *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 (GIMP_TYPE_OBJECT,