2008-11-04 Sven Neumann <sven@sven> * configure.in: bumped minimum required version of GLib to 2.18.0. * INSTALL: document the updated dependency. * app/core/gimp.[ch]: introduced gimp_message_literal(), a variant of gimp_message() that takes a literal string. * app/errors.[ch]: removed format arguments from gimp_fatal_error() and gimp_terminate() and let them take a literal string instead. * app/tools/gimptool.[ch]: introduced gimp_tool_message_literal(), a variant of gimp_tool_message() that takes a literal string. * app/actions/documents-commands.c * app/actions/drawable-commands.c * app/actions/edit-commands.c * app/actions/error-console-commands.c * app/actions/file-commands.c * app/actions/gradients-commands.c * app/actions/image-commands.c * app/actions/layers-commands.c * app/actions/palettes-commands.c * app/actions/plug-in-commands.c * app/actions/select-commands.c * app/actions/vectors-commands.c * app/config/gimprc.c * app/core/gimp-modules.c * app/core/gimp-parasites.c * app/core/gimp-templates.c * app/core/gimp-units.c * app/core/gimpchannel.c * app/core/gimpcontainer-filter.c * app/core/gimpdrawable-bucket-fill.c * app/core/gimpimage-convert.c * app/core/gimpimage-merge.c * app/core/gimpimage.c * app/core/gimpimagefile.c * app/core/gimplayer-floating-sel.c * app/core/gimplayer.c * app/core/gimpselection.c * app/dialogs/convert-dialog.c * app/dialogs/dialogs.c * app/dialogs/palette-import-dialog.c * app/dialogs/preferences-dialog.c * app/dialogs/quit-dialog.c * app/dialogs/stroke-dialog.c * app/display/gimpdisplayshell-dnd.c * app/file/file-open.c * app/file/file-procedure.c * app/file/file-save.c * app/file/file-utils.c * app/gegl/gimpcurvesconfig.c * app/gegl/gimplevelsconfig.c * app/gui/gui-message.c * app/gui/gui.c * app/gui/session.c * app/paint/gimpbrushcore.c * app/paint/gimpclone.c * app/paint/gimpheal.c * app/paint/gimpperspectiveclone.c * app/paint/gimpsourcecore.c * app/pdb/gimppdb-utils.c * app/pdb/gimpprocedure.c * app/plug-in/gimpplugin-message.c * app/plug-in/gimpplugin.c * app/plug-in/gimppluginmanager-restore.c * app/plug-in/gimppluginprocedure.c * app/text/gimptextlayer.c * app/tools/gimp-tools.c * app/tools/gimpaligntool.c * app/tools/gimpblendtool.c * app/tools/gimpbrightnesscontrasttool.c * app/tools/gimpbucketfilltool.c * app/tools/gimpcolorbalancetool.c * app/tools/gimpcolorpickertool.c * app/tools/gimpcurvestool.c * app/tools/gimpdesaturatetool.c * app/tools/gimpeditselectiontool.c * app/tools/gimpforegroundselecttool.c * app/tools/gimpfreeselecttool.c * app/tools/gimpgegltool.c * app/tools/gimphuesaturationtool.c * app/tools/gimpimagemaptool-settings.c * app/tools/gimpiscissorstool.c * app/tools/gimplevelstool.c * app/tools/gimpmeasuretool.c * app/tools/gimppainttool.c * app/tools/gimpposterizetool.c * app/tools/gimpselectiontool.c * app/tools/gimpsourcetool.c * app/tools/gimpthresholdtool.c * app/tools/gimptransformtool.c * app/tools/gimpvectortool.c * app/widgets/gimpactionview.c * app/widgets/gimpcontrollerlist.c * app/widgets/gimpcontrollers.c * app/widgets/gimpdataeditor.c * app/widgets/gimpdevices.c * app/widgets/gimpdnd-xds.c * app/widgets/gimperrordialog.c * app/widgets/gimphelp.c * app/widgets/gimpitemtreeview.c * app/widgets/gimppdbdialog.c * app/widgets/gimpsettingsbox.c * app/widgets/gimpvectorstreeview.c * app/widgets/gimpwidgets-utils.c * app/xcf/xcf-load.c * tools/pdbgen/pdb/convert.pdb * tools/pdbgen/pdb/edit.pdb * tools/pdbgen/pdb/floating_sel.pdb * tools/pdbgen/pdb/image.pdb: use the _literal variants for g_set_error(), gimp_message() and gimp_tool_message(). * app/pdb/convert-cmds.c * app/pdb/edit-cmds.c * app/pdb/floating-sel-cmds.c * app/pdb/image-cmds.c: regenerated. svn path=/trunk/; revision=27548
236 lines
5.8 KiB
C
236 lines
5.8 KiB
C
/* GIMP - The GNU 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 <glib-object.h>
|
|
|
|
#include "libgimpbase/gimpbase.h"
|
|
#include "libgimpmodule/gimpmodule.h"
|
|
#include "libgimpconfig/gimpconfig.h"
|
|
|
|
#include "core-types.h"
|
|
|
|
#include "config/gimpcoreconfig.h"
|
|
|
|
#include "gimp.h"
|
|
#include "gimp-modules.h"
|
|
|
|
#include "gimp-intl.h"
|
|
|
|
|
|
void
|
|
gimp_modules_init (Gimp *gimp)
|
|
{
|
|
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
|
|
|
if (! gimp->no_interface)
|
|
{
|
|
gimp->module_db = gimp_module_db_new (gimp->be_verbose);
|
|
gimp->write_modulerc = FALSE;
|
|
}
|
|
}
|
|
|
|
void
|
|
gimp_modules_exit (Gimp *gimp)
|
|
{
|
|
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
|
|
|
if (gimp->module_db)
|
|
{
|
|
g_object_unref (gimp->module_db);
|
|
gimp->module_db = NULL;
|
|
}
|
|
}
|
|
|
|
void
|
|
gimp_modules_load (Gimp *gimp)
|
|
{
|
|
gchar *filename;
|
|
gchar *path;
|
|
GScanner *scanner;
|
|
gchar *module_load_inhibit = NULL;
|
|
|
|
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
|
|
|
if (gimp->no_interface)
|
|
return;
|
|
|
|
filename = gimp_personal_rc_file ("modulerc");
|
|
|
|
if (gimp->be_verbose)
|
|
g_print ("Parsing '%s'\n", gimp_filename_to_utf8 (filename));
|
|
|
|
scanner = gimp_scanner_new_file (filename, NULL);
|
|
g_free (filename);
|
|
|
|
if (scanner)
|
|
{
|
|
GTokenType token;
|
|
GError *error = NULL;
|
|
|
|
#define MODULE_LOAD_INHIBIT 1
|
|
|
|
g_scanner_scope_add_symbol (scanner, 0, "module-load-inhibit",
|
|
GINT_TO_POINTER (MODULE_LOAD_INHIBIT));
|
|
|
|
token = G_TOKEN_LEFT_PAREN;
|
|
|
|
while (g_scanner_peek_next_token (scanner) == token)
|
|
{
|
|
token = g_scanner_get_next_token (scanner);
|
|
|
|
switch (token)
|
|
{
|
|
case G_TOKEN_LEFT_PAREN:
|
|
token = G_TOKEN_SYMBOL;
|
|
break;
|
|
|
|
case G_TOKEN_SYMBOL:
|
|
if (scanner->value.v_symbol == GINT_TO_POINTER (MODULE_LOAD_INHIBIT))
|
|
{
|
|
token = G_TOKEN_STRING;
|
|
|
|
if (! gimp_scanner_parse_string_no_validate (scanner,
|
|
&module_load_inhibit))
|
|
goto error;
|
|
}
|
|
token = G_TOKEN_RIGHT_PAREN;
|
|
break;
|
|
|
|
case G_TOKEN_RIGHT_PAREN:
|
|
token = G_TOKEN_LEFT_PAREN;
|
|
break;
|
|
|
|
default: /* do nothing */
|
|
break;
|
|
}
|
|
}
|
|
|
|
#undef MODULE_LOAD_INHIBIT
|
|
|
|
if (token != G_TOKEN_LEFT_PAREN)
|
|
{
|
|
g_scanner_get_next_token (scanner);
|
|
g_scanner_unexp_token (scanner, token, NULL, NULL, NULL,
|
|
_("fatal parse error"), TRUE);
|
|
}
|
|
|
|
error:
|
|
|
|
if (error)
|
|
{
|
|
gimp_message_literal (gimp, NULL, GIMP_MESSAGE_ERROR, error->message);
|
|
g_clear_error (&error);
|
|
}
|
|
|
|
gimp_scanner_destroy (scanner);
|
|
}
|
|
|
|
if (module_load_inhibit)
|
|
{
|
|
gimp_module_db_set_load_inhibit (gimp->module_db, module_load_inhibit);
|
|
g_free (module_load_inhibit);
|
|
}
|
|
|
|
path = gimp_config_path_expand (gimp->config->module_path, TRUE, NULL);
|
|
gimp_module_db_load (gimp->module_db, path);
|
|
g_free (path);
|
|
}
|
|
|
|
static void
|
|
add_to_inhibit_string (gpointer data,
|
|
gpointer user_data)
|
|
{
|
|
GimpModule *module = data;
|
|
GString *str = user_data;
|
|
|
|
if (module->load_inhibit)
|
|
{
|
|
str = g_string_append_c (str, G_SEARCHPATH_SEPARATOR);
|
|
str = g_string_append (str, module->filename);
|
|
}
|
|
}
|
|
|
|
void
|
|
gimp_modules_unload (Gimp *gimp)
|
|
{
|
|
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
|
|
|
if (! gimp->no_interface && gimp->write_modulerc)
|
|
{
|
|
GimpConfigWriter *writer;
|
|
GString *str;
|
|
const gchar *p;
|
|
gchar *filename;
|
|
GError *error = NULL;
|
|
|
|
str = g_string_new (NULL);
|
|
g_list_foreach (gimp->module_db->modules, add_to_inhibit_string, str);
|
|
if (str->len > 0)
|
|
p = str->str + 1;
|
|
else
|
|
p = "";
|
|
|
|
filename = gimp_personal_rc_file ("modulerc");
|
|
|
|
if (gimp->be_verbose)
|
|
g_print ("Writing '%s'\n", gimp_filename_to_utf8 (filename));
|
|
|
|
writer = gimp_config_writer_new_file (filename, TRUE,
|
|
"GIMP modulerc", &error);
|
|
g_free (filename);
|
|
|
|
if (writer)
|
|
{
|
|
gimp_config_writer_open (writer, "module-load-inhibit");
|
|
gimp_config_writer_printf (writer, "\"%s\"", p);
|
|
gimp_config_writer_close (writer);
|
|
|
|
gimp_config_writer_finish (writer, "end of modulerc", &error);
|
|
|
|
gimp->write_modulerc = FALSE;
|
|
}
|
|
|
|
g_string_free (str, TRUE);
|
|
|
|
if (error)
|
|
{
|
|
gimp_message_literal (gimp, NULL, GIMP_MESSAGE_ERROR, error->message);
|
|
g_clear_error (&error);
|
|
}
|
|
}
|
|
}
|
|
|
|
void
|
|
gimp_modules_refresh (Gimp *gimp)
|
|
{
|
|
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
|
|
|
if (! gimp->no_interface)
|
|
{
|
|
gchar *path;
|
|
|
|
path = gimp_config_path_expand (gimp->config->module_path, TRUE, NULL);
|
|
gimp_module_db_refresh (gimp->module_db, path);
|
|
g_free (path);
|
|
}
|
|
}
|