Commit 4ea392ef authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann

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.
parent 7b7b3c3f
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);
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_linefeed (GimpConfigWriter *writer);
void gimp_config_writer_comment (GimpConfigWriter *writer,
const gchar *comment);
gboolean gimp_config_writer_finish (GimpConfigWriter *writer,
const gchar *footer,
GError **error);
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_comment_mode (GimpConfigWriter *writer,
gboolean enable);
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);
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")
......
......@@ -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)