removed function gimp_config_serialize_comment()...
2003-10-12 Sven Neumann <sven@gimp.org> * app/config/gimpconfig-serialize.[ch]: removed function gimp_config_serialize_comment()... * app/config/gimpconfig-utils.[ch]: removed function gimp_config_string_indent()... * app/config/gimpconfigwriter.[ch]: ... and implement both here. Added a comment mode to GimpConfigWriter. * app/config/gimpconfig-dump.c: handle GimpConfig properties. * doc/gimprc-1.3.5.in * etc/gimprc: regenerated by gimpconfig-dump.
This commit is contained in:
parent
7b7b3c3f0c
commit
4ea392ef3b
17 changed files with 447 additions and 332 deletions
27
ChangeLog
27
ChangeLog
|
|
@ -1,3 +1,19 @@
|
|||
2003-10-12 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* app/config/gimpconfig-serialize.[ch]: removed function
|
||||
gimp_config_serialize_comment()...
|
||||
|
||||
* app/config/gimpconfig-utils.[ch]: removed function
|
||||
gimp_config_string_indent()...
|
||||
|
||||
* app/config/gimpconfigwriter.[ch]: ... and implement both here.
|
||||
Added a comment mode to GimpConfigWriter.
|
||||
|
||||
* app/config/gimpconfig-dump.c: handle GimpConfig properties.
|
||||
|
||||
* doc/gimprc-1.3.5.in
|
||||
* etc/gimprc: regenerated by gimpconfig-dump.
|
||||
|
||||
2003-10-11 Helvetix Victorinox <helvetix@gimp.org>
|
||||
|
||||
* app/composite/gimp-composite.h
|
||||
|
|
@ -7,7 +23,8 @@
|
|||
|
||||
* app/composite/gimp-composite.c
|
||||
* app/composite/gimp-composite-generic.c
|
||||
* app/composite/gimp-composite-regression.c: Added gtk-doc templates for functions.
|
||||
* app/composite/gimp-composite-regression.c: Added gtk-doc
|
||||
templates for functions.
|
||||
|
||||
* app/composite/make-install.py: migrated to new (trimmer) code and
|
||||
removed dead code. Some beautification for generated code.
|
||||
|
|
@ -23,10 +40,12 @@
|
|||
* app/composite/gimp-composite-{mmx,sse,sse2,3dnow,altivec,vis}-{install,test}.c:
|
||||
Regenerated
|
||||
|
||||
* app/composite/test-composite.c: Deprecated, removed. All tests are automatically
|
||||
generated and the code is in app/composite/gimp-composite-{mmx,sse,sse2,3dnow,altivec,vis}-test.c:
|
||||
* app/composite/test-composite.c: Deprecated, removed. All tests
|
||||
are automatically generated and the code is in
|
||||
app/composite/gimp-composite-{mmx,sse,sse2,3dnow,altivec,vis}-test.c:
|
||||
|
||||
* app/composite/Makefile.am: removed unused references to test-composite.c
|
||||
* app/composite/Makefile.am: removed unused references to
|
||||
test-composite.c
|
||||
|
||||
2003-10-11 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
|
|
|
|||
|
|
@ -195,13 +195,14 @@ dump_gimprc_system (GimpConfig *rc,
|
|||
{
|
||||
gimp_config_writer_comment (writer, comment);
|
||||
g_free (comment);
|
||||
|
||||
write (fd, "#\n", 2);
|
||||
}
|
||||
|
||||
write (fd, "# ", 2);
|
||||
gimp_config_writer_comment_mode (writer, TRUE);
|
||||
gimp_config_writer_linefeed (writer);
|
||||
|
||||
gimp_config_serialize_property (rc, prop_spec, writer);
|
||||
|
||||
gimp_config_writer_comment_mode (writer, FALSE);
|
||||
gimp_config_writer_linefeed (writer);
|
||||
}
|
||||
|
||||
|
|
@ -448,6 +449,10 @@ dump_describe_param (GParamSpec *param_spec)
|
|||
"The unit can be one inches, millimeters, points or picas plus "
|
||||
"those in your user units database.";
|
||||
}
|
||||
else if (g_type_is_a (type, GIMP_TYPE_CONFIG))
|
||||
{
|
||||
values = "This is a parameter list.";
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (G_TYPE_FUNDAMENTAL (type))
|
||||
|
|
|
|||
|
|
@ -500,51 +500,6 @@ gimp_config_serialize_unknown_tokens (GimpConfig *config,
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
#define LINE_LENGTH 75
|
||||
|
||||
/**
|
||||
* gimp_config_serialize_comment:
|
||||
* @str: a #GString.
|
||||
* @comment: the comment to serialize (ASCII only)
|
||||
*
|
||||
* Appends the @comment to @str and inserts linebreaks and hash-marks to
|
||||
* format it as a comment. Note that this function does not handle non-ASCII
|
||||
* characters.
|
||||
**/
|
||||
void
|
||||
gimp_config_serialize_comment (GString *str,
|
||||
const gchar *comment)
|
||||
{
|
||||
const gchar *s;
|
||||
gint i, len, space;
|
||||
|
||||
len = strlen (comment);
|
||||
|
||||
while (len > 0)
|
||||
{
|
||||
for (s = comment, i = 0, space = 0;
|
||||
*s != '\n' && (i <= LINE_LENGTH || space == 0) && i < len;
|
||||
s++, i++)
|
||||
{
|
||||
if (g_ascii_isspace (*s))
|
||||
space = i;
|
||||
}
|
||||
|
||||
if (i > LINE_LENGTH && space && *s != '\n')
|
||||
i = space;
|
||||
|
||||
g_string_append_len (str, "# ", 2);
|
||||
g_string_append_len (str, comment, i);
|
||||
g_string_append_c (str, '\n');
|
||||
|
||||
i++;
|
||||
|
||||
comment += i;
|
||||
len -= i;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
serialize_unknown_token (const gchar *key,
|
||||
const gchar *value,
|
||||
|
|
|
|||
|
|
@ -30,18 +30,16 @@ gboolean gimp_config_serialize_changed_properties (GimpConfig *config,
|
|||
gboolean gimp_config_serialize_properties_diff (GimpConfig *config,
|
||||
GimpConfig *compare,
|
||||
GimpConfigWriter *writer);
|
||||
|
||||
gboolean gimp_config_serialize_unknown_tokens (GimpConfig *config,
|
||||
GimpConfigWriter *writer);
|
||||
|
||||
gboolean gimp_config_serialize_property (GimpConfig *config,
|
||||
GParamSpec *param_spec,
|
||||
GimpConfigWriter *writer);
|
||||
|
||||
gboolean gimp_config_serialize_value (const GValue *value,
|
||||
GString *str,
|
||||
gboolean escaped);
|
||||
void gimp_config_serialize_comment (GString *str,
|
||||
const gchar *comment);
|
||||
|
||||
|
||||
#endif /* __GIMP_CONFIG_SERIALIZE_H__ */
|
||||
|
|
|
|||
|
|
@ -424,19 +424,6 @@ gimp_config_string_append_escaped (GString *string,
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
gimp_config_string_indent (GString *string,
|
||||
gint indent_level)
|
||||
{
|
||||
gint i;
|
||||
|
||||
g_return_if_fail (string != NULL);
|
||||
g_return_if_fail (indent_level >= 0);
|
||||
|
||||
for (i = 0; i < indent_level; i++)
|
||||
g_string_append_len (string, " ", 4);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* GimpConfig path utilities
|
||||
|
|
|
|||
|
|
@ -31,16 +31,12 @@ void gimp_config_disconnect (GObject *src,
|
|||
GList * gimp_config_diff (GimpConfig *a,
|
||||
GimpConfig *b,
|
||||
GParamFlags flags);
|
||||
|
||||
void gimp_config_copy_properties (GimpConfig *src,
|
||||
GimpConfig *dest);
|
||||
|
||||
void gimp_config_reset_properties (GimpConfig *config);
|
||||
|
||||
void gimp_config_string_append_escaped (GString *string,
|
||||
const gchar *val);
|
||||
void gimp_config_string_indent (GString *string,
|
||||
gint indent_level);
|
||||
|
||||
gchar * gimp_config_build_data_path (const gchar *name);
|
||||
gchar * gimp_config_build_plug_in_path (const gchar *name);
|
||||
|
|
|
|||
|
|
@ -54,15 +54,32 @@ struct _GimpConfigWriter
|
|||
gchar *tmpname;
|
||||
GError *error;
|
||||
GString *buffer;
|
||||
gboolean comment;
|
||||
gint depth;
|
||||
gint marker;
|
||||
};
|
||||
|
||||
|
||||
static gboolean gimp_config_writer_close_file (GimpConfigWriter *writer,
|
||||
GError **error);
|
||||
static inline void gimp_config_writer_flush (GimpConfigWriter *writer);
|
||||
static inline void gimp_config_writer_newline (GimpConfigWriter *writer);
|
||||
static gboolean gimp_config_writer_close_file (GimpConfigWriter *writer,
|
||||
GError **error);
|
||||
|
||||
|
||||
/**
|
||||
* gimp_config_writer_new_file:
|
||||
* @filename: a filename
|
||||
* @atomic: if %TRUE the file is written atomically
|
||||
* @header: text to include as comment at the top of the file
|
||||
* @error: return location for errors
|
||||
*
|
||||
* Creates a new #GimpConfigWriter and sets it up to write to
|
||||
* @filename. If @atomic is %TRUE, a temporary file is used to avoid
|
||||
* possible race conditions. The temporary file is then moved to
|
||||
* @filename when the writer is closed.
|
||||
*
|
||||
* Return value: a new #GimpConfigWriter or %NULL in case of an error
|
||||
**/
|
||||
GimpConfigWriter *
|
||||
gimp_config_writer_new_file (const gchar *filename,
|
||||
gboolean atomic,
|
||||
|
|
@ -79,13 +96,13 @@ gimp_config_writer_new_file (const gchar *filename,
|
|||
if (atomic)
|
||||
{
|
||||
tmpname = g_strconcat (filename, "XXXXXX", NULL);
|
||||
|
||||
|
||||
fd = g_mkstemp (tmpname);
|
||||
|
||||
if (fd == -1)
|
||||
{
|
||||
g_set_error (error,
|
||||
GIMP_CONFIG_ERROR, GIMP_CONFIG_ERROR_WRITE,
|
||||
g_set_error (error,
|
||||
GIMP_CONFIG_ERROR, GIMP_CONFIG_ERROR_WRITE,
|
||||
_("Failed to create temporary file for '%s': %s"),
|
||||
filename, g_strerror (errno));
|
||||
g_free (tmpname);
|
||||
|
|
@ -98,8 +115,8 @@ gimp_config_writer_new_file (const gchar *filename,
|
|||
|
||||
if (fd == -1)
|
||||
{
|
||||
g_set_error (error,
|
||||
GIMP_CONFIG_ERROR, GIMP_CONFIG_ERROR_WRITE,
|
||||
g_set_error (error,
|
||||
GIMP_CONFIG_ERROR, GIMP_CONFIG_ERROR_WRITE,
|
||||
_("Failed to open '%s' for writing: %s"),
|
||||
filename, g_strerror (errno));
|
||||
return NULL;
|
||||
|
|
@ -151,6 +168,24 @@ gimp_config_writer_new_string (GString *string)
|
|||
return writer;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_config_writer_comment_mode (GimpConfigWriter *writer,
|
||||
gboolean enable)
|
||||
{
|
||||
g_return_if_fail (writer != NULL);
|
||||
|
||||
if (writer->error)
|
||||
return;
|
||||
|
||||
enable = (enable ? TRUE : FALSE);
|
||||
|
||||
if (enable)
|
||||
g_string_append_len (writer->buffer, "# ", 2);
|
||||
|
||||
writer->comment = enable;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
gimp_config_writer_open (GimpConfigWriter *writer,
|
||||
const gchar *name)
|
||||
|
|
@ -165,10 +200,7 @@ gimp_config_writer_open (GimpConfigWriter *writer,
|
|||
writer->marker = writer->buffer->len;
|
||||
|
||||
if (writer->depth > 0)
|
||||
{
|
||||
g_string_append_c (writer->buffer, '\n');
|
||||
gimp_config_string_indent (writer->buffer, writer->depth);
|
||||
}
|
||||
gimp_config_writer_newline (writer);
|
||||
|
||||
writer->depth++;
|
||||
|
||||
|
|
@ -265,14 +297,7 @@ gimp_config_writer_close (GimpConfigWriter *writer)
|
|||
g_string_append_c (writer->buffer, '\n');
|
||||
|
||||
if (writer->fd)
|
||||
{
|
||||
if (write (writer->fd, writer->buffer->str, writer->buffer->len) < 0)
|
||||
g_set_error (&writer->error,
|
||||
GIMP_CONFIG_ERROR, GIMP_CONFIG_ERROR_WRITE,
|
||||
g_strerror (errno));
|
||||
|
||||
g_string_truncate (writer->buffer, 0);
|
||||
}
|
||||
gimp_config_writer_flush (writer);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -325,11 +350,11 @@ void
|
|||
gimp_config_writer_linefeed (GimpConfigWriter *writer)
|
||||
{
|
||||
g_return_if_fail (writer != NULL);
|
||||
|
||||
|
||||
if (writer->error)
|
||||
return;
|
||||
|
||||
if (writer->buffer->len == 0)
|
||||
if (writer->buffer->len == 0 && !writer->comment)
|
||||
{
|
||||
if (write (writer->fd, "\n", 1) < 0)
|
||||
g_set_error (&writer->error,
|
||||
|
|
@ -338,18 +363,30 @@ gimp_config_writer_linefeed (GimpConfigWriter *writer)
|
|||
}
|
||||
else
|
||||
{
|
||||
g_string_append_c (writer->buffer, '\n');
|
||||
gimp_config_string_indent (writer->buffer, writer->depth);
|
||||
gimp_config_writer_newline (writer);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_config_writer_comment:
|
||||
* @writer: a #GimpConfigWriter
|
||||
* @comment: the comment to write (ASCII only)
|
||||
*
|
||||
* Appends the @comment to @str and inserts linebreaks and hash-marks to
|
||||
* format it as a comment. Note that this function does not handle non-ASCII
|
||||
* characters.
|
||||
**/
|
||||
void
|
||||
gimp_config_writer_comment (GimpConfigWriter *writer,
|
||||
const gchar *comment)
|
||||
{
|
||||
const gchar *s;
|
||||
gint i, len, space;
|
||||
|
||||
#define LINE_LENGTH 75
|
||||
|
||||
g_return_if_fail (writer != NULL);
|
||||
g_return_if_fail (writer->depth == 0);
|
||||
g_return_if_fail (writer->buffer->len == 0);
|
||||
|
||||
if (writer->error)
|
||||
return;
|
||||
|
|
@ -357,16 +394,66 @@ gimp_config_writer_comment (GimpConfigWriter *writer,
|
|||
if (!comment)
|
||||
return;
|
||||
|
||||
gimp_config_serialize_comment (writer->buffer, comment);
|
||||
len = strlen (comment);
|
||||
|
||||
if (! writer->comment)
|
||||
g_string_append_len (writer->buffer, "# ", 2);
|
||||
|
||||
while (len > 0)
|
||||
{
|
||||
for (s = comment, i = 0, space = 0;
|
||||
*s != '\n' && (i <= LINE_LENGTH || space == 0) && i < len;
|
||||
s++, i++)
|
||||
{
|
||||
if (g_ascii_isspace (*s))
|
||||
space = i;
|
||||
}
|
||||
|
||||
if (i > LINE_LENGTH && space && *s != '\n')
|
||||
i = space;
|
||||
|
||||
g_string_append_len (writer->buffer, comment, i);
|
||||
g_string_append_len (writer->buffer, "\n# ", 3);
|
||||
|
||||
i++;
|
||||
|
||||
comment += i;
|
||||
len -= i;
|
||||
}
|
||||
|
||||
g_string_truncate (writer->buffer, writer->buffer->len - 2);
|
||||
|
||||
if (writer->depth == 0)
|
||||
gimp_config_writer_flush (writer);
|
||||
|
||||
#undef LINE_LENGTH
|
||||
}
|
||||
|
||||
static inline void
|
||||
gimp_config_writer_flush (GimpConfigWriter *writer)
|
||||
{
|
||||
if (write (writer->fd, writer->buffer->str, writer->buffer->len) < 0)
|
||||
g_set_error (&writer->error,
|
||||
GIMP_CONFIG_ERROR, GIMP_CONFIG_ERROR_WRITE,
|
||||
g_strerror (errno));
|
||||
|
||||
|
||||
g_string_truncate (writer->buffer, 0);
|
||||
}
|
||||
|
||||
static inline void
|
||||
gimp_config_writer_newline (GimpConfigWriter *writer)
|
||||
{
|
||||
gint i;
|
||||
|
||||
g_string_append_c (writer->buffer, '\n');
|
||||
|
||||
if (writer->comment)
|
||||
g_string_append_len (writer->buffer, "# ", 2);
|
||||
|
||||
for (i = 0; i < writer->depth; i++)
|
||||
g_string_append_len (writer->buffer, " ", 4);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_config_writer_close_file (GimpConfigWriter *writer,
|
||||
GError **error)
|
||||
|
|
@ -426,11 +513,11 @@ gimp_config_writer_close_file (GimpConfigWriter *writer,
|
|||
|
||||
if (rename (writer->tmpname, writer->filename) == -1)
|
||||
{
|
||||
g_set_error (error,
|
||||
g_set_error (error,
|
||||
GIMP_CONFIG_ERROR, GIMP_CONFIG_ERROR_WRITE,
|
||||
_("Failed to create file '%s': %s"),
|
||||
writer->filename, g_strerror (errno));
|
||||
|
||||
|
||||
unlink (writer->tmpname);
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,33 +23,35 @@
|
|||
#define __GIMP_CONFIG_WRITER_H__
|
||||
|
||||
|
||||
GimpConfigWriter * gimp_config_writer_new_file (const gchar *filename,
|
||||
gboolean atomic,
|
||||
const gchar *header,
|
||||
GError **error);
|
||||
GimpConfigWriter * gimp_config_writer_new_fd (gint fd);
|
||||
GimpConfigWriter * gimp_config_writer_new_string (GString *string);
|
||||
GimpConfigWriter * gimp_config_writer_new_file (const gchar *filename,
|
||||
gboolean atomic,
|
||||
const gchar *header,
|
||||
GError **error);
|
||||
GimpConfigWriter * gimp_config_writer_new_fd (gint fd);
|
||||
GimpConfigWriter * gimp_config_writer_new_string (GString *string);
|
||||
|
||||
void gimp_config_writer_open (GimpConfigWriter *writer,
|
||||
const gchar *name);
|
||||
void gimp_config_writer_print (GimpConfigWriter *writer,
|
||||
const gchar *string,
|
||||
gint len);
|
||||
void gimp_config_writer_printf (GimpConfigWriter *writer,
|
||||
const gchar *format,
|
||||
...);
|
||||
void gimp_config_writer_string (GimpConfigWriter *writer,
|
||||
const gchar *string);
|
||||
void gimp_config_writer_revert (GimpConfigWriter *writer);
|
||||
void gimp_config_writer_close (GimpConfigWriter *writer);
|
||||
void gimp_config_writer_open (GimpConfigWriter *writer,
|
||||
const gchar *name);
|
||||
void gimp_config_writer_comment_mode (GimpConfigWriter *writer,
|
||||
gboolean enable);
|
||||
|
||||
void gimp_config_writer_linefeed (GimpConfigWriter *writer);
|
||||
void gimp_config_writer_comment (GimpConfigWriter *writer,
|
||||
const gchar *comment);
|
||||
void gimp_config_writer_print (GimpConfigWriter *writer,
|
||||
const gchar *string,
|
||||
gint len);
|
||||
void gimp_config_writer_printf (GimpConfigWriter *writer,
|
||||
const gchar *format,
|
||||
...);
|
||||
void gimp_config_writer_string (GimpConfigWriter *writer,
|
||||
const gchar *string);
|
||||
void gimp_config_writer_comment (GimpConfigWriter *writer,
|
||||
const gchar *comment);void gimp_config_writer_linefeed (GimpConfigWriter *writer);
|
||||
|
||||
gboolean gimp_config_writer_finish (GimpConfigWriter *writer,
|
||||
const gchar *footer,
|
||||
GError **error);
|
||||
|
||||
void gimp_config_writer_revert (GimpConfigWriter *writer);
|
||||
void gimp_config_writer_close (GimpConfigWriter *writer);
|
||||
gboolean gimp_config_writer_finish (GimpConfigWriter *writer,
|
||||
const gchar *footer,
|
||||
GError **error);
|
||||
|
||||
|
||||
#endif /* __GIMP_CONFIG_WRITER_H__ */
|
||||
|
|
|
|||
|
|
@ -156,6 +156,20 @@ palette path. This is a string value.
|
|||
Specify a default gradient. The gradient is searched for in the specified
|
||||
gradient path. This is a string value.
|
||||
|
||||
.TP
|
||||
(default-grid
|
||||
(xspacing 10.000000)
|
||||
(yspacing 10.000000)
|
||||
(spacing-unit inches)
|
||||
(xoffset 0.000000)
|
||||
(yoffset 0.000000)
|
||||
(offset-unit inches)
|
||||
(fgcolor (color-rgba 0.000000 0.000000 0.000000 1.000000))
|
||||
(bgcolor (color-rgba 1.000000 1.000000 1.000000 1.000000))
|
||||
(style intersections))
|
||||
|
||||
Specify a default image grid. This is a parameter list.
|
||||
|
||||
.TP
|
||||
(default-font "Sans")
|
||||
|
||||
|
|
|
|||
|
|
@ -156,6 +156,20 @@ palette path. This is a string value.
|
|||
Specify a default gradient. The gradient is searched for in the specified
|
||||
gradient path. This is a string value.
|
||||
|
||||
.TP
|
||||
(default-grid
|
||||
(xspacing 10.000000)
|
||||
(yspacing 10.000000)
|
||||
(spacing-unit inches)
|
||||
(xoffset 0.000000)
|
||||
(yoffset 0.000000)
|
||||
(offset-unit inches)
|
||||
(fgcolor (color-rgba 0.000000 0.000000 0.000000 1.000000))
|
||||
(bgcolor (color-rgba 1.000000 1.000000 1.000000 1.000000))
|
||||
(style intersections))
|
||||
|
||||
Specify a default image grid. This is a parameter list.
|
||||
|
||||
.TP
|
||||
(default-font "Sans")
|
||||
|
||||
|
|
|
|||
195
etc/gimprc
195
etc/gimprc
|
|
@ -16,7 +16,7 @@
|
|||
# course of running the GIMP. Most files will disappear when the GIMP exits,
|
||||
# but some files are likely to remain, so it is best if this directory not be
|
||||
# one that is shared by other users. This is a single folder.
|
||||
#
|
||||
#
|
||||
# (temp-path "${gimp_dir}/tmp")
|
||||
|
||||
# Sets the swap file location. The gimp uses a tile based memory allocation
|
||||
|
|
@ -26,19 +26,19 @@
|
|||
# swap file is created on a directory that is mounted over NFS. For these
|
||||
# reasons, it may be desirable to put your swap file in "/tmp". This is a
|
||||
# single folder.
|
||||
#
|
||||
#
|
||||
# (swap-path "${gimp_dir}")
|
||||
|
||||
# There is always a tradeoff between memory usage and speed. In most cases,
|
||||
# the GIMP opts for speed over memory. However, if memory is a big issue,
|
||||
# try to enable this setting. Possible values are yes and no.
|
||||
#
|
||||
#
|
||||
# (stingy-memory-use no)
|
||||
|
||||
# On multiprocessor machines, if GIMP has been compiled with --enable-mp this
|
||||
# sets how many processors GIMP should use simultaneously. This is an
|
||||
# integer value.
|
||||
#
|
||||
#
|
||||
# (num-processors 1)
|
||||
|
||||
# The tile cache is used to make sure the GIMP doesn't thrash tiles between
|
||||
|
|
@ -49,127 +49,140 @@
|
|||
# GIMP interpret the size as being specified in bytes, kilobytes, megabytes
|
||||
# or gigabytes. If no suffix is specified the size defaults to being
|
||||
# specified in kilobytes.
|
||||
#
|
||||
#
|
||||
# (tile-cache-size 64M)
|
||||
|
||||
# Sets the level of interpolation used for scaling and other transformations.
|
||||
# Possible values are none, linear and cubic.
|
||||
#
|
||||
#
|
||||
# (interpolation-type linear)
|
||||
|
||||
# Sets the plug-in search path. This is a colon-separated list of folders to
|
||||
# search.
|
||||
#
|
||||
#
|
||||
# (plug-in-path "${gimp_dir}/plug-ins:${gimp_plug_in_dir}/plug-ins")
|
||||
|
||||
# Sets the module search path. This is a colon-separated list of folders to
|
||||
# search.
|
||||
#
|
||||
#
|
||||
# (module-path "${gimp_dir}/modules:${gimp_plug_in_dir}/modules")
|
||||
|
||||
# Sets the environ search path. This is a colon-separated list of folders to
|
||||
# search.
|
||||
#
|
||||
#
|
||||
# (environ-path "${gimp_dir}/environ:${gimp_plug_in_dir}/environ")
|
||||
|
||||
# Sets the brush search path. This is a colon-separated list of folders to
|
||||
# search.
|
||||
#
|
||||
#
|
||||
# (brush-path "${gimp_dir}/brushes:${gimp_data_dir}/brushes")
|
||||
|
||||
# Sets the pattern search path. This is a colon-separated list of folders to
|
||||
# search.
|
||||
#
|
||||
#
|
||||
# (pattern-path "${gimp_dir}/patterns:${gimp_data_dir}/patterns")
|
||||
|
||||
# Sets the palette search path. This is a colon-separated list of folders to
|
||||
# search.
|
||||
#
|
||||
#
|
||||
# (palette-path "${gimp_dir}/palettes:${gimp_data_dir}/palettes")
|
||||
|
||||
# Sets the gradient search path. This is a colon-separated list of folders
|
||||
# to search.
|
||||
#
|
||||
#
|
||||
# (gradient-path "${gimp_dir}/gradients:${gimp_data_dir}/gradients")
|
||||
|
||||
# Where to look for fonts. This is a colon-separated list of folders to
|
||||
# search.
|
||||
#
|
||||
#
|
||||
# (font-path "${gimp_dir}/fonts:${gimp_data_dir}/fonts")
|
||||
|
||||
# Specify a default brush. The brush is searched for in the specified brush
|
||||
# path. This is a string value.
|
||||
#
|
||||
#
|
||||
# (default-brush "Circle (11)")
|
||||
|
||||
# Specify a default pattern. The pattern is searched for in the specified
|
||||
# pattern path. This is a string value.
|
||||
#
|
||||
#
|
||||
# (default-pattern "Pine")
|
||||
|
||||
# Specify a default palette. The palette is searched for in the specified
|
||||
# palette path. This is a string value.
|
||||
#
|
||||
#
|
||||
# (default-palette "Default")
|
||||
|
||||
# Specify a default gradient. The gradient is searched for in the specified
|
||||
# gradient path. This is a string value.
|
||||
#
|
||||
#
|
||||
# (default-gradient "FG to BG (RGB)")
|
||||
|
||||
# Specify a default image grid. This is a parameter list.
|
||||
#
|
||||
# (default-grid
|
||||
# (xspacing 10.000000)
|
||||
# (yspacing 10.000000)
|
||||
# (spacing-unit inches)
|
||||
# (xoffset 0.000000)
|
||||
# (yoffset 0.000000)
|
||||
# (offset-unit inches)
|
||||
# (fgcolor (color-rgba 0.000000 0.000000 0.000000 1.000000))
|
||||
# (bgcolor (color-rgba 1.000000 1.000000 1.000000 1.000000))
|
||||
# (style intersections))
|
||||
|
||||
# Specify a default font. The font is searched for in the fontconfig font
|
||||
# path. This is a string value.
|
||||
#
|
||||
#
|
||||
# (default-font "Sans")
|
||||
|
||||
# Sets the default comment. This is a string value.
|
||||
#
|
||||
#
|
||||
# (default-comment "Created with The GIMP")
|
||||
|
||||
# Sets the default image type in the "File/New" dialog. Possible values are
|
||||
# rgb, gray and indexed.
|
||||
#
|
||||
#
|
||||
# (default-image-type rgb)
|
||||
|
||||
# Sets the default image width in the "File/New" dialog. This is an integer
|
||||
# value.
|
||||
#
|
||||
#
|
||||
# (default-image-width 256)
|
||||
|
||||
# Sets the default image height in the "File/New" dialog. This is an integer
|
||||
# value.
|
||||
#
|
||||
#
|
||||
# (default-image-height 256)
|
||||
|
||||
# Sets the default unit for new images and for the "File/New" dialog. This
|
||||
# units will be used for coordinate display when not in dot-for-dot mode.
|
||||
# The unit can be one inches, millimeters, points or picas plus those in your
|
||||
# user units database.
|
||||
#
|
||||
#
|
||||
# (default-unit inches)
|
||||
|
||||
# Sets the default horizontal resolution for new images and for the
|
||||
# "File/New" dialog. This value is always in dpi (dots per inch). This is a
|
||||
# float value.
|
||||
#
|
||||
#
|
||||
# (default-xresolution 72.000000)
|
||||
|
||||
# Sets the default vertical resolution for new images and for the "File/New"
|
||||
# dialog. This value is always in dpi (dots per inch). This is a float
|
||||
# value.
|
||||
#
|
||||
#
|
||||
# (default-yresolution 72.000000)
|
||||
|
||||
# Sets the units for the display of the default resolution in the "File/New"
|
||||
# dialog. The unit can be one inches, millimeters, points or picas plus
|
||||
# those in your user units database.
|
||||
#
|
||||
#
|
||||
# (default-resolution-unit inches)
|
||||
|
||||
# Sets the minimal number of operations that can be undone. More undo levels
|
||||
# are kept available until the undo-size limit is reached. This is an
|
||||
# integer value.
|
||||
#
|
||||
#
|
||||
# (undo-levels 5)
|
||||
|
||||
# Sets an upper limit to the memory that is used per image to keep operations
|
||||
|
|
@ -177,76 +190,76 @@
|
|||
# or 'G' which makes GIMP interpret the size as being specified in bytes,
|
||||
# kilobytes, megabytes or gigabytes. If no suffix is specified the size
|
||||
# defaults to being specified in kilobytes.
|
||||
#
|
||||
#
|
||||
# (undo-size 1024k)
|
||||
|
||||
# Sets the pluginrc search path. This is a single filename.
|
||||
#
|
||||
#
|
||||
# (pluginrc-path "${gimp_dir}/pluginrc")
|
||||
|
||||
# Sets whether GIMP should create previews of layers and channels. Previews
|
||||
# in the layers and channels dialog are nice to have but they can slow things
|
||||
# down when working with large images. Possible values are yes and no.
|
||||
#
|
||||
#
|
||||
# (layer-previews yes)
|
||||
|
||||
# Sets the default preview size for layers and channels. Possible values are
|
||||
# tiny, extra-small, small, medium, large, extra-large, huge, enormous and
|
||||
# gigantic.
|
||||
#
|
||||
#
|
||||
# (layer-preview-size medium)
|
||||
|
||||
# Sets the size of the thumbnail saved with each image. Note that GIMP can
|
||||
# not save thumbnails if layer previews are disabled. Possible values are
|
||||
# none, normal and large.
|
||||
#
|
||||
#
|
||||
# (thumbnail-size normal)
|
||||
|
||||
# This setting is ignored. This is a float value.
|
||||
#
|
||||
#
|
||||
# (gamma-correction 1.000000)
|
||||
|
||||
# Install a private colormap; might be useful on pseudocolor visuals.
|
||||
# Possible values are yes and no.
|
||||
#
|
||||
#
|
||||
# (install-colormap no)
|
||||
|
||||
# Generally only a concern for 8-bit displays, this sets the minimum number
|
||||
# of system colors allocated for the GIMP. This is an integer value.
|
||||
#
|
||||
#
|
||||
# (min-colors 144)
|
||||
|
||||
# Speed of marching ants in the selection outline. This value is in
|
||||
# milliseconds (less time indicates faster marching). This is an integer
|
||||
# value.
|
||||
#
|
||||
#
|
||||
# (marching-ants-speed 300)
|
||||
|
||||
# Specify that marching ants for selected regions will be drawn with colormap
|
||||
# cycling as opposed to be drawn as animated lines. This color cycling
|
||||
# option works only with 8-bit displays. Possible values are yes and no.
|
||||
#
|
||||
#
|
||||
# (colormap-cycling no)
|
||||
|
||||
# When enabled, the image window will automatically resize itself, when
|
||||
# zooming into and out of images. Possible values are yes and no.
|
||||
#
|
||||
#
|
||||
# (resize-windows-on-zoom no)
|
||||
|
||||
# When enabled, the image window will automatically resize itself, whenever
|
||||
# the physical image size changes. Possible values are yes and no.
|
||||
#
|
||||
#
|
||||
# (resize-windows-on-resize no)
|
||||
|
||||
# When enabled, this will ensure that each pixel of an image gets mapped to a
|
||||
# pixel on the screen. Possible values are yes and no.
|
||||
#
|
||||
#
|
||||
# (default-dot-for-dot yes)
|
||||
|
||||
# When enabled, this will ensure that the full image is visible after a file
|
||||
# is opened, otherwise it will be displayed with a scale of 1:1. Possible
|
||||
# values are yes and no.
|
||||
#
|
||||
#
|
||||
# (initial-zoom-to-fit yes)
|
||||
|
||||
# When enabled, the X server is queried for the mouse's current position on
|
||||
|
|
@ -254,23 +267,23 @@
|
|||
# painting with large brushes should be more accurate, but it may be slower.
|
||||
# Perversely, on some X servers enabling this option results in faster
|
||||
# painting. Possible values are yes and no.
|
||||
#
|
||||
#
|
||||
# (perfect-mouse no)
|
||||
|
||||
# Sets the mode of cursor the GIMP will use. Possible values are tool-icon,
|
||||
# tool-crosshair and crosshair.
|
||||
#
|
||||
#
|
||||
# (cursor-mode tool-icon)
|
||||
|
||||
# Context-dependent cursors are cool. They are enabled by default. However,
|
||||
# they require overhead that you may want to do without. Possible values are
|
||||
# yes and no.
|
||||
#
|
||||
#
|
||||
# (cursor-updating yes)
|
||||
|
||||
# When enabled, all paint tools will show a preview of the current brush's
|
||||
# outline. Possible values are yes and no.
|
||||
#
|
||||
#
|
||||
# (show-brush-outline yes)
|
||||
|
||||
# Sets the text to appear in image window titles. This is a format string;
|
||||
|
|
@ -297,7 +310,7 @@
|
|||
# %u unit symbol
|
||||
# %U unit abbreviation
|
||||
#
|
||||
#
|
||||
#
|
||||
# (image-title-format "%f-%p.%i (%t)")
|
||||
|
||||
# Sets the text to appear in image window status bars. This is a format
|
||||
|
|
@ -325,114 +338,114 @@
|
|||
# %u unit symbol
|
||||
# %U unit abbreviation
|
||||
#
|
||||
#
|
||||
#
|
||||
# (image-status-format "%f-%p.%i (%t)")
|
||||
|
||||
# Ask for confirmation before closing an image without saving. Possible
|
||||
# values are yes and no.
|
||||
#
|
||||
#
|
||||
# (confirm-on-close yes)
|
||||
|
||||
# Sets the monitor's horizontal resolution, in dots per inch. If set to 0,
|
||||
# forces the X server to be queried for both horizontal and vertical
|
||||
# resolution information. This is a float value.
|
||||
#
|
||||
#
|
||||
# (monitor-xresolution 72.000000)
|
||||
|
||||
# Sets the monitor's vertical resolution, in dots per inch. If set to 0,
|
||||
# forces the X server to be queried for both horizontal and vertical
|
||||
# resolution information. This is a float value.
|
||||
#
|
||||
#
|
||||
# (monitor-yresolution 72.000000)
|
||||
|
||||
# When enabled, the GIMP will use the monitor resolution from the windowing
|
||||
# system. Possible values are yes and no.
|
||||
#
|
||||
#
|
||||
# (monitor-resolution-from-windowing-system yes)
|
||||
|
||||
# Sets the size of the navigation preview available in the lower right corner
|
||||
# of the image window. Possible values are tiny, extra-small, small, medium,
|
||||
# large, extra-large, huge, enormous and gigantic.
|
||||
#
|
||||
#
|
||||
# (navigation-preview-size medium)
|
||||
|
||||
# When enabled, the menubar is visible by default. This can also be toggled
|
||||
# with the "View->Show Menubar" command. Possible values are yes and no.
|
||||
#
|
||||
#
|
||||
# (show-menubar yes)
|
||||
|
||||
# When enabled, the rulers are visible by default. This can also be toggled
|
||||
# with the "View->Show Rulers" command. Possible values are yes and no.
|
||||
#
|
||||
#
|
||||
# (show-rulers yes)
|
||||
|
||||
# When enabled, the scrollbars are visible by default. This can also be
|
||||
# toggled with the "View->Show Scrollbars" command. Possible values are yes
|
||||
# and no.
|
||||
#
|
||||
#
|
||||
# (show-scrollbars yes)
|
||||
|
||||
# When enabled, the statusbar is visible by default. This can also be toggled
|
||||
# with the "View->Show Statusbar" command. Possible values are yes and no.
|
||||
#
|
||||
#
|
||||
# (show-statusbar yes)
|
||||
|
||||
# Specifies how the area around the image should be drawn. Possible values
|
||||
# are default, light-check, dark-check and custom.
|
||||
#
|
||||
#
|
||||
# (canvas-padding-mode default)
|
||||
|
||||
# Sets the canvas padding color used if the padding mode is set to custom
|
||||
# color. The color is specified in the form (color-rgba red green blue
|
||||
# alpha) with channel values as floats between 0.0 and 1.0.
|
||||
#
|
||||
#
|
||||
# (canvas-padding-color (color-rgba 1.000000 1.000000 1.000000 1.000000))
|
||||
|
||||
# When enabled, the menubar is visible by default in fullscreen mode. This
|
||||
# can also be toggled with the "View->Show Menubar" command. Possible values
|
||||
# are yes and no.
|
||||
#
|
||||
#
|
||||
# (fullscreen-show-menubar no)
|
||||
|
||||
# When enabled, the rulers are visible by default in fullscreen mode. This
|
||||
# can also be toggled with the "View->Show Rulers" command. Possible values
|
||||
# are yes and no.
|
||||
#
|
||||
#
|
||||
# (fullscreen-show-rulers no)
|
||||
|
||||
# When enabled, the scrollbars are visible by default in fullscreen mode.
|
||||
# This can also be toggled with the "View->Show Scrollbars" command.
|
||||
# Possible values are yes and no.
|
||||
#
|
||||
#
|
||||
# (fullscreen-show-scrollbars no)
|
||||
|
||||
# When enabled, the statusbar is visible by default in fullscreen mode. This
|
||||
# can also be toggled with the "View->Show Statusbar" command. Possible
|
||||
# values are yes and no.
|
||||
#
|
||||
#
|
||||
# (fullscreen-show-statusbar no)
|
||||
|
||||
# Specifies how the area around the image should be drawn when in fullscreen
|
||||
# mode. Possible values are default, light-check, dark-check and custom.
|
||||
#
|
||||
#
|
||||
# (fullscreen-canvas-padding-mode custom)
|
||||
|
||||
# Sets the canvas padding color used when in fullscreen mode and the padding
|
||||
# mode is set to custom color. The color is specified in the form
|
||||
# (color-rgba red green blue alpha) with channel values as floats between 0.0
|
||||
# and 1.0.
|
||||
#
|
||||
#
|
||||
# (fullscreen-canvas-padding-color (color-rgba 0.000000 0.000000 0.000000 1.000000))
|
||||
|
||||
# Sets the size of the checkerboard used to display transparency. Possible
|
||||
# values are small-checks, medium-checks and large-checks.
|
||||
#
|
||||
#
|
||||
# (transparency-size medium-checks)
|
||||
|
||||
# Sets the manner in which transparency is displayed in images. Possible
|
||||
# values are light-checks, gray-checks, dark-checks, white-only, gray-only
|
||||
# and black-only.
|
||||
#
|
||||
#
|
||||
# (transparency-type gray-checks)
|
||||
|
||||
# Tools such as fuzzy-select and bucket fill find regions based on a
|
||||
|
|
@ -440,65 +453,65 @@
|
|||
# and progresses in all directions until the difference of pixel intensity
|
||||
# from the original is greater than a specified threshold. This value
|
||||
# represents the default threshold. This is an integer value.
|
||||
#
|
||||
#
|
||||
# (default-threshold 15)
|
||||
|
||||
# When enabled, the GIMP will use a different info window per image view.
|
||||
# Possible values are yes and no.
|
||||
#
|
||||
#
|
||||
# (info-window-per-display no)
|
||||
|
||||
# When enabled, the GIMP will not save if the image is unchanged since
|
||||
# opening it. Possible values are yes and no.
|
||||
#
|
||||
#
|
||||
# (trust-dirty-flag no)
|
||||
|
||||
# Remember the current tool, pattern, color, and brush across GIMP sessions.
|
||||
# Possible values are yes and no.
|
||||
#
|
||||
#
|
||||
# (save-device-status no)
|
||||
|
||||
# Save the positions and sizes of the main dialogs when the GIMP exits.
|
||||
# Possible values are yes and no.
|
||||
#
|
||||
#
|
||||
# (save-session-info yes)
|
||||
|
||||
# Let GIMP try to restore your last saved session on each startup. Possible
|
||||
# values are yes and no.
|
||||
#
|
||||
#
|
||||
# (restore-session yes)
|
||||
|
||||
# Enable to display a handy GIMP tip on startup. Possible values are yes and
|
||||
# no.
|
||||
#
|
||||
#
|
||||
# (show-tips yes)
|
||||
|
||||
# Enable to display tooltips. Possible values are yes and no.
|
||||
#
|
||||
#
|
||||
# (show-tool-tips yes)
|
||||
|
||||
# When enabled, menus can be torn off. Possible values are yes and no.
|
||||
#
|
||||
#
|
||||
# (tearoff-menus yes)
|
||||
|
||||
# When enabled, you can change keyboard shortcuts for menu items on the fly.
|
||||
# Possible values are yes and no.
|
||||
#
|
||||
#
|
||||
# (can-change-accels no)
|
||||
|
||||
# Save changed keyboard shortcuts when the GIMP exits. Possible values are
|
||||
# yes and no.
|
||||
#
|
||||
#
|
||||
# (save-accels yes)
|
||||
|
||||
# Restore saved keyboard shortcuts on each GIMP startup. Possible values are
|
||||
# yes and no.
|
||||
#
|
||||
#
|
||||
# (restore-accels yes)
|
||||
|
||||
# How many recently opened image filenames to keep on the File menu. This is
|
||||
# an integer value.
|
||||
#
|
||||
#
|
||||
# (last-opened-size 10)
|
||||
|
||||
# GIMP will warn the user if an attempt is made to create an image that would
|
||||
|
|
@ -506,26 +519,26 @@
|
|||
# contain a suffix of 'B', 'K', 'M' or 'G' which makes GIMP interpret the
|
||||
# size as being specified in bytes, kilobytes, megabytes or gigabytes. If no
|
||||
# suffix is specified the size defaults to being specified in kilobytes.
|
||||
#
|
||||
#
|
||||
# (max-new-image-size 64M)
|
||||
|
||||
# Sets the theme search path. This is a colon-separated list of folders to
|
||||
# search.
|
||||
#
|
||||
#
|
||||
# (theme-path "${gimp_dir}/themes:${gimp_data_dir}/themes")
|
||||
|
||||
# The name of the theme to use. This is a string value.
|
||||
#
|
||||
#
|
||||
# (theme "Default")
|
||||
|
||||
# When enabled, pressing F1 will open the help browser. Possible values are
|
||||
# yes and no.
|
||||
#
|
||||
#
|
||||
# (use-help yes)
|
||||
|
||||
# Sets the browser used by the help system. Possible values are gimp and
|
||||
# webbrowser.
|
||||
#
|
||||
#
|
||||
# (help-browser gimp)
|
||||
|
||||
# Sets the external web browser to be used. This can be an absolute path or
|
||||
|
|
@ -533,31 +546,31 @@
|
|||
# contains '%s' it will be replaced with the URL, else the URL will be
|
||||
# appended to the command with a space separating the two. This is a single
|
||||
# filename.
|
||||
#
|
||||
#
|
||||
# (web-browser "mozilla \"%s\"")
|
||||
|
||||
# Where to search for fractals used by the Fractal Explorer plug-in. This is
|
||||
# a colon-separated list of folders to search.
|
||||
#
|
||||
#
|
||||
# (fractalexplorer-path "${gimp_dir}/fractalexplorer:${gimp_data_dir}/fractalexplorer")
|
||||
|
||||
# Where to search for Gfig figures used by the Gfig plug-in. This is a
|
||||
# colon-separated list of folders to search.
|
||||
#
|
||||
#
|
||||
# (gfig-path "${gimp_dir}/gfig:${gimp_data_dir}/gfig")
|
||||
|
||||
# Where to search for gflares used by the GFlare plug-in. This is a
|
||||
# colon-separated list of folders to search.
|
||||
#
|
||||
#
|
||||
# (gflare-path "${gimp_dir}/gflare:${gimp_data_dir}/gflare")
|
||||
|
||||
# Where to search for data used by the Gimpressionist plug-in. This is a
|
||||
# colon-separated list of folders to search.
|
||||
#
|
||||
#
|
||||
# (gimpressionist-path "${gimp_dir}/gimpressionist:${gimp_data_dir}/gimpressionist")
|
||||
|
||||
# This path will be searched for scripts when the Script-Fu plug-in is run.
|
||||
# This is a colon-separated list of folders to search.
|
||||
#
|
||||
#
|
||||
# (script-fu-path "${gimp_dir}/scripts:${gimp_data_dir}/scripts")
|
||||
|
||||
|
|
|
|||
|
|
@ -500,51 +500,6 @@ gimp_config_serialize_unknown_tokens (GimpConfig *config,
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
#define LINE_LENGTH 75
|
||||
|
||||
/**
|
||||
* gimp_config_serialize_comment:
|
||||
* @str: a #GString.
|
||||
* @comment: the comment to serialize (ASCII only)
|
||||
*
|
||||
* Appends the @comment to @str and inserts linebreaks and hash-marks to
|
||||
* format it as a comment. Note that this function does not handle non-ASCII
|
||||
* characters.
|
||||
**/
|
||||
void
|
||||
gimp_config_serialize_comment (GString *str,
|
||||
const gchar *comment)
|
||||
{
|
||||
const gchar *s;
|
||||
gint i, len, space;
|
||||
|
||||
len = strlen (comment);
|
||||
|
||||
while (len > 0)
|
||||
{
|
||||
for (s = comment, i = 0, space = 0;
|
||||
*s != '\n' && (i <= LINE_LENGTH || space == 0) && i < len;
|
||||
s++, i++)
|
||||
{
|
||||
if (g_ascii_isspace (*s))
|
||||
space = i;
|
||||
}
|
||||
|
||||
if (i > LINE_LENGTH && space && *s != '\n')
|
||||
i = space;
|
||||
|
||||
g_string_append_len (str, "# ", 2);
|
||||
g_string_append_len (str, comment, i);
|
||||
g_string_append_c (str, '\n');
|
||||
|
||||
i++;
|
||||
|
||||
comment += i;
|
||||
len -= i;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
serialize_unknown_token (const gchar *key,
|
||||
const gchar *value,
|
||||
|
|
|
|||
|
|
@ -30,18 +30,16 @@ gboolean gimp_config_serialize_changed_properties (GimpConfig *config,
|
|||
gboolean gimp_config_serialize_properties_diff (GimpConfig *config,
|
||||
GimpConfig *compare,
|
||||
GimpConfigWriter *writer);
|
||||
|
||||
gboolean gimp_config_serialize_unknown_tokens (GimpConfig *config,
|
||||
GimpConfigWriter *writer);
|
||||
|
||||
gboolean gimp_config_serialize_property (GimpConfig *config,
|
||||
GParamSpec *param_spec,
|
||||
GimpConfigWriter *writer);
|
||||
|
||||
gboolean gimp_config_serialize_value (const GValue *value,
|
||||
GString *str,
|
||||
gboolean escaped);
|
||||
void gimp_config_serialize_comment (GString *str,
|
||||
const gchar *comment);
|
||||
|
||||
|
||||
#endif /* __GIMP_CONFIG_SERIALIZE_H__ */
|
||||
|
|
|
|||
|
|
@ -424,19 +424,6 @@ gimp_config_string_append_escaped (GString *string,
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
gimp_config_string_indent (GString *string,
|
||||
gint indent_level)
|
||||
{
|
||||
gint i;
|
||||
|
||||
g_return_if_fail (string != NULL);
|
||||
g_return_if_fail (indent_level >= 0);
|
||||
|
||||
for (i = 0; i < indent_level; i++)
|
||||
g_string_append_len (string, " ", 4);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* GimpConfig path utilities
|
||||
|
|
|
|||
|
|
@ -31,16 +31,12 @@ void gimp_config_disconnect (GObject *src,
|
|||
GList * gimp_config_diff (GimpConfig *a,
|
||||
GimpConfig *b,
|
||||
GParamFlags flags);
|
||||
|
||||
void gimp_config_copy_properties (GimpConfig *src,
|
||||
GimpConfig *dest);
|
||||
|
||||
void gimp_config_reset_properties (GimpConfig *config);
|
||||
|
||||
void gimp_config_string_append_escaped (GString *string,
|
||||
const gchar *val);
|
||||
void gimp_config_string_indent (GString *string,
|
||||
gint indent_level);
|
||||
|
||||
gchar * gimp_config_build_data_path (const gchar *name);
|
||||
gchar * gimp_config_build_plug_in_path (const gchar *name);
|
||||
|
|
|
|||
|
|
@ -54,15 +54,32 @@ struct _GimpConfigWriter
|
|||
gchar *tmpname;
|
||||
GError *error;
|
||||
GString *buffer;
|
||||
gboolean comment;
|
||||
gint depth;
|
||||
gint marker;
|
||||
};
|
||||
|
||||
|
||||
static gboolean gimp_config_writer_close_file (GimpConfigWriter *writer,
|
||||
GError **error);
|
||||
static inline void gimp_config_writer_flush (GimpConfigWriter *writer);
|
||||
static inline void gimp_config_writer_newline (GimpConfigWriter *writer);
|
||||
static gboolean gimp_config_writer_close_file (GimpConfigWriter *writer,
|
||||
GError **error);
|
||||
|
||||
|
||||
/**
|
||||
* gimp_config_writer_new_file:
|
||||
* @filename: a filename
|
||||
* @atomic: if %TRUE the file is written atomically
|
||||
* @header: text to include as comment at the top of the file
|
||||
* @error: return location for errors
|
||||
*
|
||||
* Creates a new #GimpConfigWriter and sets it up to write to
|
||||
* @filename. If @atomic is %TRUE, a temporary file is used to avoid
|
||||
* possible race conditions. The temporary file is then moved to
|
||||
* @filename when the writer is closed.
|
||||
*
|
||||
* Return value: a new #GimpConfigWriter or %NULL in case of an error
|
||||
**/
|
||||
GimpConfigWriter *
|
||||
gimp_config_writer_new_file (const gchar *filename,
|
||||
gboolean atomic,
|
||||
|
|
@ -79,13 +96,13 @@ gimp_config_writer_new_file (const gchar *filename,
|
|||
if (atomic)
|
||||
{
|
||||
tmpname = g_strconcat (filename, "XXXXXX", NULL);
|
||||
|
||||
|
||||
fd = g_mkstemp (tmpname);
|
||||
|
||||
if (fd == -1)
|
||||
{
|
||||
g_set_error (error,
|
||||
GIMP_CONFIG_ERROR, GIMP_CONFIG_ERROR_WRITE,
|
||||
g_set_error (error,
|
||||
GIMP_CONFIG_ERROR, GIMP_CONFIG_ERROR_WRITE,
|
||||
_("Failed to create temporary file for '%s': %s"),
|
||||
filename, g_strerror (errno));
|
||||
g_free (tmpname);
|
||||
|
|
@ -98,8 +115,8 @@ gimp_config_writer_new_file (const gchar *filename,
|
|||
|
||||
if (fd == -1)
|
||||
{
|
||||
g_set_error (error,
|
||||
GIMP_CONFIG_ERROR, GIMP_CONFIG_ERROR_WRITE,
|
||||
g_set_error (error,
|
||||
GIMP_CONFIG_ERROR, GIMP_CONFIG_ERROR_WRITE,
|
||||
_("Failed to open '%s' for writing: %s"),
|
||||
filename, g_strerror (errno));
|
||||
return NULL;
|
||||
|
|
@ -151,6 +168,24 @@ gimp_config_writer_new_string (GString *string)
|
|||
return writer;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_config_writer_comment_mode (GimpConfigWriter *writer,
|
||||
gboolean enable)
|
||||
{
|
||||
g_return_if_fail (writer != NULL);
|
||||
|
||||
if (writer->error)
|
||||
return;
|
||||
|
||||
enable = (enable ? TRUE : FALSE);
|
||||
|
||||
if (enable)
|
||||
g_string_append_len (writer->buffer, "# ", 2);
|
||||
|
||||
writer->comment = enable;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
gimp_config_writer_open (GimpConfigWriter *writer,
|
||||
const gchar *name)
|
||||
|
|
@ -165,10 +200,7 @@ gimp_config_writer_open (GimpConfigWriter *writer,
|
|||
writer->marker = writer->buffer->len;
|
||||
|
||||
if (writer->depth > 0)
|
||||
{
|
||||
g_string_append_c (writer->buffer, '\n');
|
||||
gimp_config_string_indent (writer->buffer, writer->depth);
|
||||
}
|
||||
gimp_config_writer_newline (writer);
|
||||
|
||||
writer->depth++;
|
||||
|
||||
|
|
@ -265,14 +297,7 @@ gimp_config_writer_close (GimpConfigWriter *writer)
|
|||
g_string_append_c (writer->buffer, '\n');
|
||||
|
||||
if (writer->fd)
|
||||
{
|
||||
if (write (writer->fd, writer->buffer->str, writer->buffer->len) < 0)
|
||||
g_set_error (&writer->error,
|
||||
GIMP_CONFIG_ERROR, GIMP_CONFIG_ERROR_WRITE,
|
||||
g_strerror (errno));
|
||||
|
||||
g_string_truncate (writer->buffer, 0);
|
||||
}
|
||||
gimp_config_writer_flush (writer);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -325,11 +350,11 @@ void
|
|||
gimp_config_writer_linefeed (GimpConfigWriter *writer)
|
||||
{
|
||||
g_return_if_fail (writer != NULL);
|
||||
|
||||
|
||||
if (writer->error)
|
||||
return;
|
||||
|
||||
if (writer->buffer->len == 0)
|
||||
if (writer->buffer->len == 0 && !writer->comment)
|
||||
{
|
||||
if (write (writer->fd, "\n", 1) < 0)
|
||||
g_set_error (&writer->error,
|
||||
|
|
@ -338,18 +363,30 @@ gimp_config_writer_linefeed (GimpConfigWriter *writer)
|
|||
}
|
||||
else
|
||||
{
|
||||
g_string_append_c (writer->buffer, '\n');
|
||||
gimp_config_string_indent (writer->buffer, writer->depth);
|
||||
gimp_config_writer_newline (writer);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_config_writer_comment:
|
||||
* @writer: a #GimpConfigWriter
|
||||
* @comment: the comment to write (ASCII only)
|
||||
*
|
||||
* Appends the @comment to @str and inserts linebreaks and hash-marks to
|
||||
* format it as a comment. Note that this function does not handle non-ASCII
|
||||
* characters.
|
||||
**/
|
||||
void
|
||||
gimp_config_writer_comment (GimpConfigWriter *writer,
|
||||
const gchar *comment)
|
||||
{
|
||||
const gchar *s;
|
||||
gint i, len, space;
|
||||
|
||||
#define LINE_LENGTH 75
|
||||
|
||||
g_return_if_fail (writer != NULL);
|
||||
g_return_if_fail (writer->depth == 0);
|
||||
g_return_if_fail (writer->buffer->len == 0);
|
||||
|
||||
if (writer->error)
|
||||
return;
|
||||
|
|
@ -357,16 +394,66 @@ gimp_config_writer_comment (GimpConfigWriter *writer,
|
|||
if (!comment)
|
||||
return;
|
||||
|
||||
gimp_config_serialize_comment (writer->buffer, comment);
|
||||
len = strlen (comment);
|
||||
|
||||
if (! writer->comment)
|
||||
g_string_append_len (writer->buffer, "# ", 2);
|
||||
|
||||
while (len > 0)
|
||||
{
|
||||
for (s = comment, i = 0, space = 0;
|
||||
*s != '\n' && (i <= LINE_LENGTH || space == 0) && i < len;
|
||||
s++, i++)
|
||||
{
|
||||
if (g_ascii_isspace (*s))
|
||||
space = i;
|
||||
}
|
||||
|
||||
if (i > LINE_LENGTH && space && *s != '\n')
|
||||
i = space;
|
||||
|
||||
g_string_append_len (writer->buffer, comment, i);
|
||||
g_string_append_len (writer->buffer, "\n# ", 3);
|
||||
|
||||
i++;
|
||||
|
||||
comment += i;
|
||||
len -= i;
|
||||
}
|
||||
|
||||
g_string_truncate (writer->buffer, writer->buffer->len - 2);
|
||||
|
||||
if (writer->depth == 0)
|
||||
gimp_config_writer_flush (writer);
|
||||
|
||||
#undef LINE_LENGTH
|
||||
}
|
||||
|
||||
static inline void
|
||||
gimp_config_writer_flush (GimpConfigWriter *writer)
|
||||
{
|
||||
if (write (writer->fd, writer->buffer->str, writer->buffer->len) < 0)
|
||||
g_set_error (&writer->error,
|
||||
GIMP_CONFIG_ERROR, GIMP_CONFIG_ERROR_WRITE,
|
||||
g_strerror (errno));
|
||||
|
||||
|
||||
g_string_truncate (writer->buffer, 0);
|
||||
}
|
||||
|
||||
static inline void
|
||||
gimp_config_writer_newline (GimpConfigWriter *writer)
|
||||
{
|
||||
gint i;
|
||||
|
||||
g_string_append_c (writer->buffer, '\n');
|
||||
|
||||
if (writer->comment)
|
||||
g_string_append_len (writer->buffer, "# ", 2);
|
||||
|
||||
for (i = 0; i < writer->depth; i++)
|
||||
g_string_append_len (writer->buffer, " ", 4);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_config_writer_close_file (GimpConfigWriter *writer,
|
||||
GError **error)
|
||||
|
|
@ -426,11 +513,11 @@ gimp_config_writer_close_file (GimpConfigWriter *writer,
|
|||
|
||||
if (rename (writer->tmpname, writer->filename) == -1)
|
||||
{
|
||||
g_set_error (error,
|
||||
g_set_error (error,
|
||||
GIMP_CONFIG_ERROR, GIMP_CONFIG_ERROR_WRITE,
|
||||
_("Failed to create file '%s': %s"),
|
||||
writer->filename, g_strerror (errno));
|
||||
|
||||
|
||||
unlink (writer->tmpname);
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,33 +23,35 @@
|
|||
#define __GIMP_CONFIG_WRITER_H__
|
||||
|
||||
|
||||
GimpConfigWriter * gimp_config_writer_new_file (const gchar *filename,
|
||||
gboolean atomic,
|
||||
const gchar *header,
|
||||
GError **error);
|
||||
GimpConfigWriter * gimp_config_writer_new_fd (gint fd);
|
||||
GimpConfigWriter * gimp_config_writer_new_string (GString *string);
|
||||
GimpConfigWriter * gimp_config_writer_new_file (const gchar *filename,
|
||||
gboolean atomic,
|
||||
const gchar *header,
|
||||
GError **error);
|
||||
GimpConfigWriter * gimp_config_writer_new_fd (gint fd);
|
||||
GimpConfigWriter * gimp_config_writer_new_string (GString *string);
|
||||
|
||||
void gimp_config_writer_open (GimpConfigWriter *writer,
|
||||
const gchar *name);
|
||||
void gimp_config_writer_print (GimpConfigWriter *writer,
|
||||
const gchar *string,
|
||||
gint len);
|
||||
void gimp_config_writer_printf (GimpConfigWriter *writer,
|
||||
const gchar *format,
|
||||
...);
|
||||
void gimp_config_writer_string (GimpConfigWriter *writer,
|
||||
const gchar *string);
|
||||
void gimp_config_writer_revert (GimpConfigWriter *writer);
|
||||
void gimp_config_writer_close (GimpConfigWriter *writer);
|
||||
void gimp_config_writer_open (GimpConfigWriter *writer,
|
||||
const gchar *name);
|
||||
void gimp_config_writer_comment_mode (GimpConfigWriter *writer,
|
||||
gboolean enable);
|
||||
|
||||
void gimp_config_writer_linefeed (GimpConfigWriter *writer);
|
||||
void gimp_config_writer_comment (GimpConfigWriter *writer,
|
||||
const gchar *comment);
|
||||
void gimp_config_writer_print (GimpConfigWriter *writer,
|
||||
const gchar *string,
|
||||
gint len);
|
||||
void gimp_config_writer_printf (GimpConfigWriter *writer,
|
||||
const gchar *format,
|
||||
...);
|
||||
void gimp_config_writer_string (GimpConfigWriter *writer,
|
||||
const gchar *string);
|
||||
void gimp_config_writer_comment (GimpConfigWriter *writer,
|
||||
const gchar *comment);void gimp_config_writer_linefeed (GimpConfigWriter *writer);
|
||||
|
||||
gboolean gimp_config_writer_finish (GimpConfigWriter *writer,
|
||||
const gchar *footer,
|
||||
GError **error);
|
||||
|
||||
void gimp_config_writer_revert (GimpConfigWriter *writer);
|
||||
void gimp_config_writer_close (GimpConfigWriter *writer);
|
||||
gboolean gimp_config_writer_finish (GimpConfigWriter *writer,
|
||||
const gchar *footer,
|
||||
GError **error);
|
||||
|
||||
|
||||
#endif /* __GIMP_CONFIG_WRITER_H__ */
|
||||
|
|
|
|||
Loading…
Reference in a new issue