mirror of
https://gitlab.gnome.org/GNOME/gimp.git
synced 2025-07-03 17:33:25 +00:00
app/config/gimpcoreconfig.[ch] removed "module-load-inhibit" property
2003-09-02 Michael Natterer <mitch@gimp.org> * app/config/gimpcoreconfig.[ch] * app/config/gimprc-blurbs.h: removed "module-load-inhibit" property since the GimpModuleDB stores this value. * app/config/gimpconfigwriter.[ch] (gimp_config_writer_new): renamed parameter "gboolean safe" to "gboolean atomic". * app/core/gimpmodules.c: ported modulerc parsing/writing to GimpScanner and GimpConfigWriter (apparently it was forgotten during gimprc cleanup). Makes keeping modules from being loaded work again. Reported by Michael Schumacher on #gimp.
This commit is contained in:
parent
f1b283bdde
commit
73b1ed03c6
10 changed files with 214 additions and 60 deletions
14
ChangeLog
14
ChangeLog
|
@ -1,3 +1,17 @@
|
|||
2003-09-02 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/config/gimpcoreconfig.[ch]
|
||||
* app/config/gimprc-blurbs.h: removed "module-load-inhibit"
|
||||
property since the GimpModuleDB stores this value.
|
||||
|
||||
* app/config/gimpconfigwriter.[ch] (gimp_config_writer_new):
|
||||
renamed parameter "gboolean safe" to "gboolean atomic".
|
||||
|
||||
* app/core/gimpmodules.c: ported modulerc parsing/writing to
|
||||
GimpScanner and GimpConfigWriter (apparently it was forgotten
|
||||
during gimprc cleanup). Makes keeping modules from being loaded
|
||||
work again. Reported by Michael Schumacher on #gimp.
|
||||
|
||||
2003-09-02 Simon Budig <simon@gimp.org>
|
||||
|
||||
* app/vectors/gimpstroke.c: duplicate the closed property too.
|
||||
|
|
|
@ -65,7 +65,7 @@ static gboolean gimp_config_writer_close_file (GimpConfigWriter *writer,
|
|||
|
||||
GimpConfigWriter *
|
||||
gimp_config_writer_new_file (const gchar *filename,
|
||||
gboolean safe,
|
||||
gboolean atomic,
|
||||
const gchar *header,
|
||||
GError **error)
|
||||
{
|
||||
|
@ -76,7 +76,7 @@ gimp_config_writer_new_file (const gchar *filename,
|
|||
g_return_val_if_fail (filename != NULL, NULL);
|
||||
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
|
||||
|
||||
if (safe)
|
||||
if (atomic)
|
||||
{
|
||||
tmpname = g_strconcat (filename, "XXXXXX", NULL);
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
|
||||
GimpConfigWriter * gimp_config_writer_new_file (const gchar *filename,
|
||||
gboolean safe,
|
||||
gboolean atomic,
|
||||
const gchar *header,
|
||||
GError **error);
|
||||
GimpConfigWriter * gimp_config_writer_new_fd (gint fd);
|
||||
|
|
|
@ -84,7 +84,6 @@ enum
|
|||
PROP_UNDO_LEVELS,
|
||||
PROP_UNDO_SIZE,
|
||||
PROP_PLUGINRC_PATH,
|
||||
PROP_MODULE_LOAD_INHIBIT,
|
||||
PROP_LAYER_PREVIEWS,
|
||||
PROP_LAYER_PREVIEW_SIZE,
|
||||
PROP_THUMBNAIL_SIZE,
|
||||
|
@ -257,11 +256,6 @@ gimp_core_config_class_init (GimpCoreConfigClass *klass)
|
|||
GIMP_PARAM_PATH_FILE,
|
||||
"${gimp_dir}" G_DIR_SEPARATOR_S "pluginrc",
|
||||
GIMP_PARAM_RESTART);
|
||||
GIMP_CONFIG_INSTALL_PROP_STRING (object_class, PROP_MODULE_LOAD_INHIBIT,
|
||||
"module-load-inhibit",
|
||||
MODULE_LOAD_INHIBIT_BLURB,
|
||||
NULL,
|
||||
0);
|
||||
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_LAYER_PREVIEWS,
|
||||
"layer-previews", LAYER_PREVIEWS_BLURB,
|
||||
TRUE,
|
||||
|
@ -313,7 +307,6 @@ gimp_core_config_finalize (GObject *object)
|
|||
g_free (core_config->default_font);
|
||||
g_free (core_config->default_comment);
|
||||
g_free (core_config->plug_in_rc_path);
|
||||
g_free (core_config->module_load_inhibit);
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||
}
|
||||
|
@ -420,10 +413,6 @@ gimp_core_config_set_property (GObject *object,
|
|||
g_free (core_config->plug_in_rc_path);
|
||||
core_config->plug_in_rc_path = g_value_dup_string (value);
|
||||
break;
|
||||
case PROP_MODULE_LOAD_INHIBIT:
|
||||
g_free (core_config->module_load_inhibit);
|
||||
core_config->module_load_inhibit = g_value_dup_string (value);
|
||||
break;
|
||||
case PROP_LAYER_PREVIEWS:
|
||||
core_config->layer_previews = g_value_get_boolean (value);
|
||||
break;
|
||||
|
@ -536,9 +525,6 @@ gimp_core_config_get_property (GObject *object,
|
|||
case PROP_PLUGINRC_PATH:
|
||||
g_value_set_string (value, core_config->plug_in_rc_path);
|
||||
break;
|
||||
case PROP_MODULE_LOAD_INHIBIT:
|
||||
g_value_set_string (value, core_config->module_load_inhibit);
|
||||
break;
|
||||
case PROP_LAYER_PREVIEWS:
|
||||
g_value_set_boolean (value, core_config->layer_previews);
|
||||
break;
|
||||
|
|
|
@ -65,7 +65,6 @@ struct _GimpCoreConfig
|
|||
gint levels_of_undo;
|
||||
gulong undo_size;
|
||||
gchar *plug_in_rc_path;
|
||||
gchar *module_load_inhibit;
|
||||
gboolean layer_previews;
|
||||
GimpPreviewSize layer_preview_size;
|
||||
GimpThumbnailSize thumbnail_size;
|
||||
|
|
|
@ -176,9 +176,6 @@ N_("Generally only a concern for 8-bit displays, this sets the minimum " \
|
|||
#define MODULE_PATH_BLURB \
|
||||
"Sets the module search path."
|
||||
|
||||
#define MODULE_LOAD_INHIBIT_BLURB \
|
||||
"To inhibit loading of a module, add its name here."
|
||||
|
||||
#define MONITOR_RES_FROM_GDK_BLURB \
|
||||
"When enabled, the GIMP will use the monitor resolution from the " \
|
||||
"windowing system."
|
||||
|
|
|
@ -36,11 +36,12 @@
|
|||
|
||||
#include "core-types.h"
|
||||
|
||||
#include "config/gimpcoreconfig.h"
|
||||
#include "config/gimpconfig-path.h"
|
||||
#include "config/gimpconfigwriter.h"
|
||||
#include "config/gimpcoreconfig.h"
|
||||
#include "config/gimpscanner.h"
|
||||
|
||||
#include "gimp.h"
|
||||
#include "gimplist.h"
|
||||
#include "gimpmodules.h"
|
||||
|
||||
#include "gimp-intl.h"
|
||||
|
@ -70,15 +71,85 @@ gimp_modules_exit (Gimp *gimp)
|
|||
void
|
||||
gimp_modules_load (Gimp *gimp)
|
||||
{
|
||||
gchar *filename;
|
||||
gchar *path;
|
||||
GScanner *scanner;
|
||||
GTokenType token;
|
||||
gchar *module_load_inhibit = NULL;
|
||||
GError *error = NULL;
|
||||
|
||||
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
||||
|
||||
#if 0
|
||||
gchar *filename = gimp_personal_rc_file ("modulerc");
|
||||
gimprc_parse_file (filename);
|
||||
filename = gimp_personal_rc_file ("modulerc");
|
||||
scanner = gimp_scanner_new_file (filename, &error);
|
||||
g_free (filename);
|
||||
#endif
|
||||
|
||||
gimp_modules_refresh (gimp);
|
||||
#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)
|
||||
{
|
||||
g_message (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
|
||||
|
@ -102,10 +173,11 @@ gimp_modules_unload (Gimp *gimp)
|
|||
|
||||
if (gimp->write_modulerc)
|
||||
{
|
||||
GString *str;
|
||||
gchar *p;
|
||||
gchar *filename;
|
||||
FILE *fp;
|
||||
GimpConfigWriter *writer;
|
||||
GString *str;
|
||||
gchar *p;
|
||||
gchar *filename;
|
||||
GError *error = NULL;
|
||||
|
||||
str = g_string_new (NULL);
|
||||
g_list_foreach (gimp->module_db->modules, add_to_inhibit_string, str);
|
||||
|
@ -115,18 +187,28 @@ gimp_modules_unload (Gimp *gimp)
|
|||
p = "";
|
||||
|
||||
filename = gimp_personal_rc_file ("modulerc");
|
||||
fp = fopen (filename, "wt");
|
||||
writer = gimp_config_writer_new_file (filename, TRUE,
|
||||
"GIMP modulerc", &error);
|
||||
g_free (filename);
|
||||
|
||||
if (fp)
|
||||
if (writer)
|
||||
{
|
||||
fprintf (fp, "(module-load-inhibit \"%s\")\n", p);
|
||||
fclose (fp);
|
||||
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)
|
||||
{
|
||||
g_message (error->message);
|
||||
g_clear_error (&error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -137,9 +219,6 @@ gimp_modules_refresh (Gimp *gimp)
|
|||
|
||||
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
||||
|
||||
gimp_module_db_set_load_inhibit (gimp->module_db,
|
||||
gimp->config->module_load_inhibit);
|
||||
|
||||
path = gimp_config_path_expand (gimp->config->module_path, TRUE, NULL);
|
||||
gimp_module_db_refresh (gimp->module_db, path);
|
||||
g_free (path);
|
||||
|
|
|
@ -36,11 +36,12 @@
|
|||
|
||||
#include "core-types.h"
|
||||
|
||||
#include "config/gimpcoreconfig.h"
|
||||
#include "config/gimpconfig-path.h"
|
||||
#include "config/gimpconfigwriter.h"
|
||||
#include "config/gimpcoreconfig.h"
|
||||
#include "config/gimpscanner.h"
|
||||
|
||||
#include "gimp.h"
|
||||
#include "gimplist.h"
|
||||
#include "gimpmodules.h"
|
||||
|
||||
#include "gimp-intl.h"
|
||||
|
@ -70,15 +71,85 @@ gimp_modules_exit (Gimp *gimp)
|
|||
void
|
||||
gimp_modules_load (Gimp *gimp)
|
||||
{
|
||||
gchar *filename;
|
||||
gchar *path;
|
||||
GScanner *scanner;
|
||||
GTokenType token;
|
||||
gchar *module_load_inhibit = NULL;
|
||||
GError *error = NULL;
|
||||
|
||||
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
||||
|
||||
#if 0
|
||||
gchar *filename = gimp_personal_rc_file ("modulerc");
|
||||
gimprc_parse_file (filename);
|
||||
filename = gimp_personal_rc_file ("modulerc");
|
||||
scanner = gimp_scanner_new_file (filename, &error);
|
||||
g_free (filename);
|
||||
#endif
|
||||
|
||||
gimp_modules_refresh (gimp);
|
||||
#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)
|
||||
{
|
||||
g_message (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
|
||||
|
@ -102,10 +173,11 @@ gimp_modules_unload (Gimp *gimp)
|
|||
|
||||
if (gimp->write_modulerc)
|
||||
{
|
||||
GString *str;
|
||||
gchar *p;
|
||||
gchar *filename;
|
||||
FILE *fp;
|
||||
GimpConfigWriter *writer;
|
||||
GString *str;
|
||||
gchar *p;
|
||||
gchar *filename;
|
||||
GError *error = NULL;
|
||||
|
||||
str = g_string_new (NULL);
|
||||
g_list_foreach (gimp->module_db->modules, add_to_inhibit_string, str);
|
||||
|
@ -115,18 +187,28 @@ gimp_modules_unload (Gimp *gimp)
|
|||
p = "";
|
||||
|
||||
filename = gimp_personal_rc_file ("modulerc");
|
||||
fp = fopen (filename, "wt");
|
||||
writer = gimp_config_writer_new_file (filename, TRUE,
|
||||
"GIMP modulerc", &error);
|
||||
g_free (filename);
|
||||
|
||||
if (fp)
|
||||
if (writer)
|
||||
{
|
||||
fprintf (fp, "(module-load-inhibit \"%s\")\n", p);
|
||||
fclose (fp);
|
||||
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)
|
||||
{
|
||||
g_message (error->message);
|
||||
g_clear_error (&error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -137,9 +219,6 @@ gimp_modules_refresh (Gimp *gimp)
|
|||
|
||||
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
||||
|
||||
gimp_module_db_set_load_inhibit (gimp->module_db,
|
||||
gimp->config->module_load_inhibit);
|
||||
|
||||
path = gimp_config_path_expand (gimp->config->module_path, TRUE, NULL);
|
||||
gimp_module_db_refresh (gimp->module_db, path);
|
||||
g_free (path);
|
||||
|
|
|
@ -65,7 +65,7 @@ static gboolean gimp_config_writer_close_file (GimpConfigWriter *writer,
|
|||
|
||||
GimpConfigWriter *
|
||||
gimp_config_writer_new_file (const gchar *filename,
|
||||
gboolean safe,
|
||||
gboolean atomic,
|
||||
const gchar *header,
|
||||
GError **error)
|
||||
{
|
||||
|
@ -76,7 +76,7 @@ gimp_config_writer_new_file (const gchar *filename,
|
|||
g_return_val_if_fail (filename != NULL, NULL);
|
||||
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
|
||||
|
||||
if (safe)
|
||||
if (atomic)
|
||||
{
|
||||
tmpname = g_strconcat (filename, "XXXXXX", NULL);
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
|
||||
GimpConfigWriter * gimp_config_writer_new_file (const gchar *filename,
|
||||
gboolean safe,
|
||||
gboolean atomic,
|
||||
const gchar *header,
|
||||
GError **error);
|
||||
GimpConfigWriter * gimp_config_writer_new_fd (gint fd);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue