2003-11-23 23:35:27 +08:00
|
|
|
/* LIBGIMP - The GIMP Library
|
|
|
|
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
2001-10-19 01:27:36 +08:00
|
|
|
*
|
2009-01-18 06:28:01 +08:00
|
|
|
* This library is free software: you can redistribute it and/or
|
2003-11-23 23:35:27 +08:00
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
2009-01-18 06:28:01 +08:00
|
|
|
* version 3 of the License, or (at your option) any later version.
|
2001-10-19 01:27:36 +08:00
|
|
|
*
|
2003-11-23 23:35:27 +08:00
|
|
|
* This library is distributed in the hope that it will be useful,
|
2001-10-19 01:27:36 +08:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2003-11-23 23:35:27 +08:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
2001-10-19 01:27:36 +08:00
|
|
|
*
|
2003-11-23 23:35:27 +08:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2009-01-18 06:28:01 +08:00
|
|
|
* License along with this library. If not, see
|
2018-07-12 05:27:07 +08:00
|
|
|
* <https://www.gnu.org/licenses/>.
|
2001-10-19 01:27:36 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <string.h>
|
2002-02-18 22:34:50 +08:00
|
|
|
|
2013-10-15 07:58:39 +08:00
|
|
|
#include <gio/gio.h>
|
2001-10-19 01:27:36 +08:00
|
|
|
|
|
|
|
#include "libgimpbase/gimpbase.h"
|
2014-08-04 00:30:02 +08:00
|
|
|
#include "libgimpconfig/gimpconfig.h"
|
2001-10-19 01:27:36 +08:00
|
|
|
|
2002-10-23 22:55:07 +08:00
|
|
|
#include "gimpmoduletypes.h"
|
2001-10-19 01:27:36 +08:00
|
|
|
|
2002-10-23 22:55:07 +08:00
|
|
|
#include "gimpmodule.h"
|
|
|
|
#include "gimpmoduledb.h"
|
2001-10-19 01:27:36 +08:00
|
|
|
|
2019-09-13 19:11:23 +08:00
|
|
|
#include "libgimp/libgimp-intl.h"
|
|
|
|
|
2001-10-19 01:27:36 +08:00
|
|
|
|
2010-06-30 04:35:34 +08:00
|
|
|
/**
|
|
|
|
* SECTION: gimpmoduledb
|
|
|
|
* @title: GimpModuleDB
|
|
|
|
* @short_description: Keeps a list of #GimpModule's found in a given
|
|
|
|
* searchpath.
|
|
|
|
*
|
|
|
|
* Keeps a list of #GimpModule's found in a given searchpath.
|
|
|
|
**/
|
|
|
|
|
|
|
|
|
2023-05-21 04:37:33 +08:00
|
|
|
struct _GimpModuleDB
|
2002-10-23 22:55:07 +08:00
|
|
|
{
|
2023-05-21 04:37:33 +08:00
|
|
|
GObject parent_instance;
|
2002-10-20 18:14:17 +08:00
|
|
|
|
2023-05-21 04:37:33 +08:00
|
|
|
GPtrArray *modules;
|
2018-05-06 02:41:02 +08:00
|
|
|
|
2023-05-21 04:37:33 +08:00
|
|
|
gchar *load_inhibit;
|
|
|
|
gboolean verbose;
|
2018-05-06 02:41:02 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2002-10-23 22:55:07 +08:00
|
|
|
static void gimp_module_db_finalize (GObject *object);
|
|
|
|
|
2014-08-04 00:30:02 +08:00
|
|
|
static void gimp_module_db_load_directory (GimpModuleDB *db,
|
|
|
|
GFile *directory);
|
|
|
|
static void gimp_module_db_load_module (GimpModuleDB *db,
|
|
|
|
GFile *file);
|
2001-10-19 01:27:36 +08:00
|
|
|
|
2019-09-13 19:11:23 +08:00
|
|
|
static GimpModule * gimp_module_db_module_find_by_file (GimpModuleDB *db,
|
|
|
|
GFile *file);
|
2001-10-19 01:27:36 +08:00
|
|
|
|
2014-08-03 05:47:10 +08:00
|
|
|
static void gimp_module_db_module_dump_func (gpointer data,
|
2002-10-23 22:55:07 +08:00
|
|
|
gpointer user_data);
|
2014-08-03 05:47:10 +08:00
|
|
|
|
2023-05-21 04:37:33 +08:00
|
|
|
static void gimp_module_db_list_model_iface_init (GListModelInterface *iface);
|
2001-10-19 01:27:36 +08:00
|
|
|
|
|
|
|
|
2023-05-21 04:37:33 +08:00
|
|
|
G_DEFINE_TYPE_WITH_CODE (GimpModuleDB, gimp_module_db, G_TYPE_OBJECT,
|
|
|
|
G_IMPLEMENT_INTERFACE (G_TYPE_LIST_MODEL,
|
|
|
|
gimp_module_db_list_model_iface_init))
|
2002-10-23 22:55:07 +08:00
|
|
|
|
2005-12-21 04:35:23 +08:00
|
|
|
#define parent_class gimp_module_db_parent_class
|
2002-10-23 22:55:07 +08:00
|
|
|
|
2001-10-19 01:27:36 +08:00
|
|
|
|
2002-10-23 22:55:07 +08:00
|
|
|
static void
|
|
|
|
gimp_module_db_class_init (GimpModuleDBClass *klass)
|
|
|
|
{
|
2004-01-24 01:24:44 +08:00
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
2002-10-23 22:55:07 +08:00
|
|
|
|
|
|
|
object_class->finalize = gimp_module_db_finalize;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_module_db_init (GimpModuleDB *db)
|
2001-10-19 01:27:36 +08:00
|
|
|
{
|
2023-05-21 04:37:33 +08:00
|
|
|
db->modules = g_ptr_array_new ();
|
|
|
|
db->load_inhibit = NULL;
|
|
|
|
db->verbose = FALSE;
|
2002-10-23 22:55:07 +08:00
|
|
|
}
|
2001-10-19 01:27:36 +08:00
|
|
|
|
2002-10-23 22:55:07 +08:00
|
|
|
static void
|
|
|
|
gimp_module_db_finalize (GObject *object)
|
|
|
|
{
|
2019-09-13 19:11:23 +08:00
|
|
|
GimpModuleDB *db = GIMP_MODULE_DB (object);
|
2002-10-23 22:55:07 +08:00
|
|
|
|
2023-05-21 04:37:33 +08:00
|
|
|
g_clear_pointer (&db->modules, g_ptr_array_unref);
|
|
|
|
g_clear_pointer (&db->load_inhibit, g_free);
|
2002-10-23 22:55:07 +08:00
|
|
|
|
|
|
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
2001-10-19 01:27:36 +08:00
|
|
|
}
|
|
|
|
|
2023-05-21 04:37:33 +08:00
|
|
|
static GType
|
|
|
|
gimp_module_db_get_item_type (GListModel *list)
|
|
|
|
{
|
|
|
|
return GIMP_TYPE_MODULE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static guint
|
|
|
|
gimp_module_db_get_n_items (GListModel *list)
|
|
|
|
{
|
|
|
|
GimpModuleDB *self = GIMP_MODULE_DB (list);
|
|
|
|
return self->modules->len;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void *
|
|
|
|
gimp_module_db_get_item (GListModel *list,
|
|
|
|
guint index)
|
|
|
|
{
|
|
|
|
GimpModuleDB *self = GIMP_MODULE_DB (list);
|
|
|
|
|
|
|
|
if (index >= self->modules->len)
|
|
|
|
return NULL;
|
|
|
|
return g_object_ref (g_ptr_array_index (self->modules, index));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_module_db_list_model_iface_init (GListModelInterface *iface)
|
|
|
|
{
|
|
|
|
iface->get_item_type = gimp_module_db_get_item_type;
|
|
|
|
iface->get_n_items = gimp_module_db_get_n_items;
|
|
|
|
iface->get_item = gimp_module_db_get_item;
|
|
|
|
}
|
|
|
|
|
2003-01-03 05:34:35 +08:00
|
|
|
/**
|
|
|
|
* gimp_module_db_new:
|
2003-02-07 05:17:12 +08:00
|
|
|
* @verbose: Pass %TRUE to enable debugging output.
|
2003-11-15 20:36:09 +08:00
|
|
|
*
|
2003-01-03 05:34:35 +08:00
|
|
|
* Creates a new #GimpModuleDB instance. The @verbose parameter will be
|
|
|
|
* passed to the created #GimpModule instances using gimp_module_new().
|
2003-11-15 20:36:09 +08:00
|
|
|
*
|
2019-08-03 06:10:14 +08:00
|
|
|
* Returns: The new #GimpModuleDB instance.
|
2003-01-03 05:34:35 +08:00
|
|
|
**/
|
2002-10-23 22:55:07 +08:00
|
|
|
GimpModuleDB *
|
|
|
|
gimp_module_db_new (gboolean verbose)
|
2001-10-19 01:27:36 +08:00
|
|
|
{
|
2002-10-23 22:55:07 +08:00
|
|
|
GimpModuleDB *db;
|
2001-10-19 01:27:36 +08:00
|
|
|
|
2002-10-23 22:55:07 +08:00
|
|
|
db = g_object_new (GIMP_TYPE_MODULE_DB, NULL);
|
2001-10-19 01:27:36 +08:00
|
|
|
|
2023-05-21 04:37:33 +08:00
|
|
|
db->verbose = verbose ? TRUE : FALSE;
|
2001-10-19 01:27:36 +08:00
|
|
|
|
2002-10-23 22:55:07 +08:00
|
|
|
return db;
|
|
|
|
}
|
2001-10-19 01:27:36 +08:00
|
|
|
|
2018-05-06 02:41:02 +08:00
|
|
|
/**
|
|
|
|
* gimp_module_db_set_verbose:
|
|
|
|
* @db: A #GimpModuleDB.
|
|
|
|
* @verbose: the new 'verbose' setting
|
|
|
|
*
|
|
|
|
* Sets the 'verbose' setting of @db.
|
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
**/
|
|
|
|
void
|
|
|
|
gimp_module_db_set_verbose (GimpModuleDB *db,
|
|
|
|
gboolean verbose)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_MODULE_DB (db));
|
|
|
|
|
2023-05-21 04:37:33 +08:00
|
|
|
db->verbose = verbose ? TRUE : FALSE;
|
2018-05-06 02:41:02 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gimp_module_db_get_verbose:
|
|
|
|
* @db: A #GimpModuleDB.
|
|
|
|
*
|
|
|
|
* Returns the 'verbose' setting of @db.
|
|
|
|
*
|
2019-08-03 06:10:14 +08:00
|
|
|
* Returns: the 'verbose' setting.
|
2018-05-06 02:41:02 +08:00
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
**/
|
|
|
|
gboolean
|
|
|
|
gimp_module_db_get_verbose (GimpModuleDB *db)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GIMP_IS_MODULE_DB (db), FALSE);
|
|
|
|
|
2023-05-21 04:37:33 +08:00
|
|
|
return db->verbose;
|
2018-05-06 02:41:02 +08:00
|
|
|
}
|
|
|
|
|
2002-10-23 22:55:07 +08:00
|
|
|
static gboolean
|
2019-09-13 19:11:23 +08:00
|
|
|
is_in_inhibit_list (GFile *file,
|
2002-10-23 22:55:07 +08:00
|
|
|
const gchar *inhibit_list)
|
|
|
|
{
|
2019-09-13 19:11:23 +08:00
|
|
|
gchar *filename;
|
2002-10-23 22:55:07 +08:00
|
|
|
gchar *p;
|
|
|
|
gint pathlen;
|
|
|
|
const gchar *start;
|
|
|
|
const gchar *end;
|
|
|
|
|
|
|
|
if (! inhibit_list || ! strlen (inhibit_list))
|
|
|
|
return FALSE;
|
|
|
|
|
2019-09-13 19:11:23 +08:00
|
|
|
filename = g_file_get_path (file);
|
|
|
|
|
2002-10-23 22:55:07 +08:00
|
|
|
p = strstr (inhibit_list, filename);
|
2019-09-13 19:11:23 +08:00
|
|
|
if (! p)
|
|
|
|
{
|
|
|
|
g_free (filename);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2002-10-23 22:55:07 +08:00
|
|
|
|
|
|
|
/* 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 (filename);
|
|
|
|
|
2019-09-13 19:11:23 +08:00
|
|
|
g_free (filename);
|
|
|
|
|
2002-10-23 22:55:07 +08:00
|
|
|
if ((end - start) == pathlen)
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
return FALSE;
|
2001-10-19 01:27:36 +08:00
|
|
|
}
|
|
|
|
|
2003-01-03 05:34:35 +08:00
|
|
|
/**
|
|
|
|
* gimp_module_db_set_load_inhibit:
|
|
|
|
* @db: A #GimpModuleDB.
|
|
|
|
* @load_inhibit: A #G_SEARCHPATH_SEPARATOR delimited list of module
|
|
|
|
* filenames to exclude from auto-loading.
|
2003-11-15 20:36:09 +08:00
|
|
|
*
|
2003-01-03 05:34:35 +08:00
|
|
|
* Sets the @load_inhibit flag for all #GimpModule's which are kept
|
|
|
|
* by @db (using gimp_module_set_load_inhibit()).
|
|
|
|
**/
|
2001-10-19 01:27:36 +08:00
|
|
|
void
|
2002-10-23 22:55:07 +08:00
|
|
|
gimp_module_db_set_load_inhibit (GimpModuleDB *db,
|
|
|
|
const gchar *load_inhibit)
|
2001-10-19 01:27:36 +08:00
|
|
|
{
|
2023-05-21 04:37:33 +08:00
|
|
|
guint i;
|
2002-10-23 22:55:07 +08:00
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_MODULE_DB (db));
|
|
|
|
|
2023-05-21 04:37:33 +08:00
|
|
|
g_free (db->load_inhibit);
|
2018-05-06 02:41:02 +08:00
|
|
|
|
2023-05-21 04:37:33 +08:00
|
|
|
db->load_inhibit = g_strdup (load_inhibit);
|
2002-10-23 22:55:07 +08:00
|
|
|
|
2023-05-21 04:37:33 +08:00
|
|
|
for (i = 0; i < db->modules->len; i++)
|
2001-10-19 01:27:36 +08:00
|
|
|
{
|
2023-05-21 04:37:33 +08:00
|
|
|
GimpModule *module = g_ptr_array_index (db->modules, i);
|
2019-09-13 19:11:23 +08:00
|
|
|
gboolean inhibit;
|
|
|
|
|
2023-05-21 04:37:33 +08:00
|
|
|
inhibit = is_in_inhibit_list (gimp_module_get_file (module),
|
|
|
|
load_inhibit);
|
2002-10-23 22:55:07 +08:00
|
|
|
|
2019-09-13 19:11:23 +08:00
|
|
|
gimp_module_set_auto_load (module, ! inhibit);
|
2001-10-19 01:27:36 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-01-03 05:34:35 +08:00
|
|
|
/**
|
|
|
|
* gimp_module_db_get_load_inhibit:
|
|
|
|
* @db: A #GimpModuleDB.
|
2003-11-15 20:36:09 +08:00
|
|
|
*
|
2012-09-13 15:14:17 +08:00
|
|
|
* Return the #G_SEARCHPATH_SEPARATOR delimited list of module filenames
|
2003-01-03 05:34:35 +08:00
|
|
|
* which are excluded from auto-loading.
|
2003-11-15 20:36:09 +08:00
|
|
|
*
|
2019-08-03 06:10:14 +08:00
|
|
|
* Returns: the @db's @load_inhibit string.
|
2003-01-03 05:34:35 +08:00
|
|
|
**/
|
2002-10-23 22:55:07 +08:00
|
|
|
const gchar *
|
|
|
|
gimp_module_db_get_load_inhibit (GimpModuleDB *db)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GIMP_IS_MODULE_DB (db), NULL);
|
|
|
|
|
2023-05-21 04:37:33 +08:00
|
|
|
return db->load_inhibit;
|
2002-10-23 22:55:07 +08:00
|
|
|
}
|
|
|
|
|
2003-01-03 05:34:35 +08:00
|
|
|
/**
|
|
|
|
* gimp_module_db_load:
|
|
|
|
* @db: A #GimpModuleDB.
|
|
|
|
* @module_path: A #G_SEARCHPATH_SEPARATOR delimited list of directories
|
|
|
|
* to load modules from.
|
2003-11-15 20:36:09 +08:00
|
|
|
*
|
2014-08-04 05:09:30 +08:00
|
|
|
* Scans the directories contained in @module_path and creates a
|
|
|
|
* #GimpModule instance for every loadable module contained in the
|
|
|
|
* directories.
|
2003-01-03 05:34:35 +08:00
|
|
|
**/
|
2002-10-23 22:55:07 +08:00
|
|
|
void
|
|
|
|
gimp_module_db_load (GimpModuleDB *db,
|
|
|
|
const gchar *module_path)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_MODULE_DB (db));
|
|
|
|
g_return_if_fail (module_path != NULL);
|
|
|
|
|
|
|
|
if (g_module_supported ())
|
2014-08-04 00:30:02 +08:00
|
|
|
{
|
|
|
|
GList *path;
|
|
|
|
GList *list;
|
|
|
|
|
|
|
|
path = gimp_config_path_expand_to_files (module_path, NULL);
|
|
|
|
|
|
|
|
for (list = path; list; list = g_list_next (list))
|
|
|
|
{
|
|
|
|
gimp_module_db_load_directory (db, list->data);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_list_free_full (path, (GDestroyNotify) g_object_unref);
|
|
|
|
}
|
2002-10-23 22:55:07 +08:00
|
|
|
|
2019-09-13 19:11:23 +08:00
|
|
|
if (FALSE)
|
2023-05-21 04:37:33 +08:00
|
|
|
g_ptr_array_foreach (db->modules, gimp_module_db_module_dump_func, NULL);
|
2002-10-23 22:55:07 +08:00
|
|
|
}
|
|
|
|
|
2003-01-03 05:34:35 +08:00
|
|
|
/**
|
|
|
|
* gimp_module_db_refresh:
|
|
|
|
* @db: A #GimpModuleDB.
|
|
|
|
* @module_path: A #G_SEARCHPATH_SEPARATOR delimited list of directories
|
|
|
|
* to load modules from.
|
2003-11-15 20:36:09 +08:00
|
|
|
*
|
2003-01-03 05:34:35 +08:00
|
|
|
* Does the same as gimp_module_db_load(), plus removes all #GimpModule
|
|
|
|
* instances whose modules have been deleted from disk.
|
|
|
|
*
|
|
|
|
* Note that the #GimpModule's will just be removed from the internal
|
|
|
|
* list and not freed as this is not possible with #GTypeModule
|
|
|
|
* instances which actually implement types.
|
|
|
|
**/
|
2001-10-19 01:27:36 +08:00
|
|
|
void
|
2002-10-23 22:55:07 +08:00
|
|
|
gimp_module_db_refresh (GimpModuleDB *db,
|
|
|
|
const gchar *module_path)
|
2001-10-19 01:27:36 +08:00
|
|
|
{
|
2023-05-21 04:37:33 +08:00
|
|
|
guint i;
|
2001-10-19 01:27:36 +08:00
|
|
|
|
2002-10-23 22:55:07 +08:00
|
|
|
g_return_if_fail (GIMP_IS_MODULE_DB (db));
|
|
|
|
g_return_if_fail (module_path != NULL);
|
2001-10-19 01:27:36 +08:00
|
|
|
|
2023-05-21 04:37:33 +08:00
|
|
|
for (i = 0; i < db->modules->len; i++)
|
2019-09-13 19:11:23 +08:00
|
|
|
{
|
2023-05-21 04:37:33 +08:00
|
|
|
GimpModule *module = g_ptr_array_index (db->modules, i);
|
2019-09-13 19:11:23 +08:00
|
|
|
|
|
|
|
if (! gimp_module_is_on_disk (module) &&
|
|
|
|
! gimp_module_is_loaded (module))
|
|
|
|
{
|
2023-05-21 04:37:33 +08:00
|
|
|
g_ptr_array_remove_index (db->modules, i);
|
|
|
|
g_list_model_items_changed (G_LIST_MODEL (db), i, 1, 0);
|
|
|
|
i--;
|
2019-09-13 19:11:23 +08:00
|
|
|
}
|
|
|
|
}
|
2001-10-19 01:27:36 +08:00
|
|
|
|
|
|
|
/* walk filesystem and add new things we find */
|
2014-08-04 00:30:02 +08:00
|
|
|
gimp_module_db_load (db, module_path);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_module_db_load_directory (GimpModuleDB *db,
|
|
|
|
GFile *directory)
|
|
|
|
{
|
|
|
|
GFileEnumerator *enumerator;
|
|
|
|
|
|
|
|
enumerator = g_file_enumerate_children (directory,
|
|
|
|
G_FILE_ATTRIBUTE_STANDARD_NAME ","
|
|
|
|
G_FILE_ATTRIBUTE_STANDARD_IS_HIDDEN ","
|
|
|
|
G_FILE_ATTRIBUTE_STANDARD_TYPE,
|
|
|
|
G_FILE_QUERY_INFO_NONE,
|
|
|
|
NULL, NULL);
|
|
|
|
|
|
|
|
if (enumerator)
|
|
|
|
{
|
|
|
|
GFileInfo *info;
|
|
|
|
|
|
|
|
while ((info = g_file_enumerator_next_file (enumerator, NULL, NULL)))
|
|
|
|
{
|
2023-09-19 20:38:42 +08:00
|
|
|
GFileType file_type = g_file_info_get_attribute_uint32 (info, G_FILE_ATTRIBUTE_STANDARD_TYPE);
|
2014-08-04 00:30:02 +08:00
|
|
|
|
|
|
|
if (file_type == G_FILE_TYPE_REGULAR &&
|
2023-09-19 20:38:42 +08:00
|
|
|
! g_file_info_get_attribute_boolean (info, G_FILE_ATTRIBUTE_STANDARD_IS_HIDDEN))
|
2014-08-04 00:30:02 +08:00
|
|
|
{
|
|
|
|
GFile *child = g_file_enumerator_get_child (enumerator, info);
|
|
|
|
|
|
|
|
gimp_module_db_load_module (db, child);
|
|
|
|
|
|
|
|
g_object_unref (child);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_object_unref (info);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_object_unref (enumerator);
|
|
|
|
}
|
2001-10-19 01:27:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-08-04 00:30:02 +08:00
|
|
|
gimp_module_db_load_module (GimpModuleDB *db,
|
|
|
|
GFile *file)
|
2001-10-19 01:27:36 +08:00
|
|
|
{
|
2019-09-13 19:11:23 +08:00
|
|
|
GimpModule *module;
|
|
|
|
gboolean load_inhibit;
|
2001-10-19 01:27:36 +08:00
|
|
|
|
2014-08-04 02:46:28 +08:00
|
|
|
if (! gimp_file_has_extension (file, "." G_MODULE_SUFFIX))
|
|
|
|
return;
|
2014-08-04 00:30:02 +08:00
|
|
|
|
2001-10-19 01:27:36 +08:00
|
|
|
/* don't load if we already know about it */
|
2019-09-13 19:11:23 +08:00
|
|
|
if (gimp_module_db_module_find_by_file (db, file))
|
|
|
|
return;
|
2002-10-23 22:55:07 +08:00
|
|
|
|
2023-05-21 04:37:33 +08:00
|
|
|
load_inhibit = is_in_inhibit_list (file, db->load_inhibit);
|
2001-10-19 01:27:36 +08:00
|
|
|
|
2019-09-13 19:11:23 +08:00
|
|
|
module = gimp_module_new (file,
|
|
|
|
! load_inhibit,
|
2023-05-21 04:37:33 +08:00
|
|
|
db->verbose);
|
2002-10-23 22:55:07 +08:00
|
|
|
|
2023-05-21 04:37:33 +08:00
|
|
|
g_ptr_array_add (db->modules, module);
|
|
|
|
g_list_model_items_changed (G_LIST_MODEL (db), db->modules->len - 1, 0, 1);
|
2001-10-19 01:27:36 +08:00
|
|
|
}
|
|
|
|
|
2002-10-21 22:15:02 +08:00
|
|
|
static GimpModule *
|
2019-09-13 19:11:23 +08:00
|
|
|
gimp_module_db_module_find_by_file (GimpModuleDB *db,
|
|
|
|
GFile *file)
|
2001-10-19 01:27:36 +08:00
|
|
|
{
|
2023-05-21 04:37:33 +08:00
|
|
|
guint i;
|
2001-10-19 01:27:36 +08:00
|
|
|
|
2023-05-21 04:37:33 +08:00
|
|
|
for (i = 0; i < db->modules->len; i++)
|
2002-10-20 18:14:17 +08:00
|
|
|
{
|
2023-05-21 04:37:33 +08:00
|
|
|
GimpModule *module = g_ptr_array_index (db->modules, i);
|
2001-10-19 01:27:36 +08:00
|
|
|
|
2019-09-13 19:11:23 +08:00
|
|
|
if (g_file_equal (file, gimp_module_get_file (module)))
|
2002-10-21 22:15:02 +08:00
|
|
|
return module;
|
2002-10-20 18:14:17 +08:00
|
|
|
}
|
2001-10-19 01:27:36 +08:00
|
|
|
|
2002-10-20 18:14:17 +08:00
|
|
|
return NULL;
|
2001-10-19 01:27:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-08-03 05:47:10 +08:00
|
|
|
gimp_module_db_module_dump_func (gpointer data,
|
|
|
|
gpointer user_data)
|
2001-10-19 01:27:36 +08:00
|
|
|
{
|
2019-09-13 19:11:23 +08:00
|
|
|
static const gchar * const statenames[] =
|
|
|
|
{
|
|
|
|
N_("Module error"),
|
|
|
|
N_("Loaded"),
|
|
|
|
N_("Load failed"),
|
|
|
|
N_("Not loaded")
|
|
|
|
};
|
|
|
|
|
|
|
|
GimpModule *module = data;
|
|
|
|
const GimpModuleInfo *info = gimp_module_get_info (module);
|
2001-10-19 01:27:36 +08:00
|
|
|
|
2002-10-23 22:55:07 +08:00
|
|
|
g_print ("\n%s: %s\n",
|
2019-09-13 19:11:23 +08:00
|
|
|
gimp_file_get_utf8_name (gimp_module_get_file (module)),
|
|
|
|
gettext (statenames[gimp_module_get_state (module)]));
|
2002-10-20 20:40:30 +08:00
|
|
|
|
2019-09-13 19:11:23 +08:00
|
|
|
#if 0
|
2004-01-24 01:24:44 +08:00
|
|
|
g_print (" module: %p lasterr: %s query: %p register: %p\n",
|
2004-07-30 03:22:32 +08:00
|
|
|
module->module,
|
2004-01-24 01:24:44 +08:00
|
|
|
module->last_module_error ? module->last_module_error : "NONE",
|
2004-07-30 03:22:32 +08:00
|
|
|
module->query_module,
|
|
|
|
module->register_module);
|
2019-09-13 19:11:23 +08:00
|
|
|
#endif
|
2002-10-20 20:40:30 +08:00
|
|
|
|
2019-09-13 19:11:23 +08:00
|
|
|
if (info)
|
2002-10-21 22:15:02 +08:00
|
|
|
{
|
|
|
|
g_print (" purpose: %s\n"
|
|
|
|
" author: %s\n"
|
|
|
|
" version: %s\n"
|
|
|
|
" copyright: %s\n"
|
|
|
|
" date: %s\n",
|
2019-09-13 19:11:23 +08:00
|
|
|
info->purpose ? info->purpose : "NONE",
|
|
|
|
info->author ? info->author : "NONE",
|
|
|
|
info->version ? info->version : "NONE",
|
|
|
|
info->copyright ? info->copyright : "NONE",
|
|
|
|
info->date ? info->date : "NONE");
|
2002-10-21 22:15:02 +08:00
|
|
|
}
|
2001-10-19 01:27:36 +08:00
|
|
|
}
|