Commit b3e58673 authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann

don't insert an extra line-break after a serialized property.

2003-02-26  Sven Neumann  <sven@gimp.org>

	* app/config/gimpconfig-serialize.c (gimp_config_serialize_properties):
	don't insert an extra line-break after a serialized property.

	* app/config/gimpconfig-serialize.c
	* app/config/gimpconfig-dump.c
	* app/gui/tips-parser.c: use g_string_truncate (str, 0) instead of
	assigning an empty string.

	* app/tools/gimptextoptions.c: override the serialize and
	deserialize methods of the GimpConfig interface and save/restore
	the associated GimpText object instead of GimpTextOptions.

	* app/tools/tool_options.c (gimp_tool_options_build_filename):
	don't append ".default" if no extension is given.
parent 9d25aa53
2003-02-26 Sven Neumann <sven@gimp.org>
* app/config/gimpconfig-serialize.c (gimp_config_serialize_properties):
don't insert an extra line-break after a serialized property.
* app/config/gimpconfig-serialize.c
* app/config/gimpconfig-dump.c
* app/gui/tips-parser.c: use g_string_truncate (str, 0) instead of
assigning an empty string.
* app/tools/gimptextoptions.c: override the serialize and
deserialize methods of the GimpConfig interface and save/restore
the associated GimpText object instead of GimpTextOptions.
* app/tools/tool_options.c (gimp_tool_options_build_filename):
don't append ".default" if no extension is given.
2003-02-26 Sven Neumann <sven@gimp.org>
* app/display/gimpdisplayshell-callbacks.c: removed debugging output.
......@@ -183,7 +183,7 @@ dump_gimprc_system (GObject *rc,
if (! (prop_spec->flags & GIMP_PARAM_SERIALIZE))
continue;
g_string_assign (str, "");
g_string_truncate (str, 0);
comment = dump_describe_param (prop_spec);
if (comment)
......
......@@ -92,10 +92,7 @@ gimp_config_serialize_properties (GObject *object,
return FALSE;
}
if (indent_level == 0)
g_string_assign (str, "\n");
else
g_string_assign (str, "");
g_string_truncate (str, 0);
}
g_free (property_specs);
......@@ -157,7 +154,7 @@ gimp_config_serialize_changed_properties (GObject *new,
if (property_written)
g_string_assign (str, "\n");
else
g_string_assign (str, "");
g_string_truncate (str, 0);
gimp_config_string_indent (str, indent_level);
......
......@@ -180,17 +180,24 @@ gimp_tool_options_build_filename (GimpToolOptions *tool_options,
gchar *basename;
gchar *filename;
if (! extension)
extension = "default";
basename = g_strconcat (GIMP_OBJECT (tool_options->tool_info)->name,
".", extension, NULL);
filename = g_build_filename (gimp_directory (),
"tool-options", basename,
NULL);
g_free (basename);
if (extension)
{
basename = g_strconcat (GIMP_OBJECT (tool_options->tool_info)->name,
".", extension, NULL);
filename = g_build_filename (gimp_directory (),
"tool-options",
basename,
NULL);
g_free (basename);
}
else
{
filename = g_build_filename (gimp_directory (),
"tool-options",
GIMP_OBJECT (tool_options->tool_info)->name,
NULL);
}
return filename;
}
......
......@@ -309,7 +309,7 @@ tips_parser_end_element (GMarkupParseContext *context,
if (parser->markup_depth == 0)
{
tips_parser_set_by_locale (parser, &parser->current_tip->welcome);
g_string_assign (parser->value, "");
g_string_truncate (parser->value, 0);
parser->state = TIPS_IN_TIP;
}
else
......@@ -320,7 +320,7 @@ tips_parser_end_element (GMarkupParseContext *context,
if (parser->markup_depth == 0)
{
tips_parser_set_by_locale (parser, &parser->current_tip->thetip);
g_string_assign (parser->value, "");
g_string_truncate (parser->value, 0);
parser->state = TIPS_IN_TIP;
}
else
......
......@@ -309,7 +309,7 @@ tips_parser_end_element (GMarkupParseContext *context,
if (parser->markup_depth == 0)
{
tips_parser_set_by_locale (parser, &parser->current_tip->welcome);
g_string_assign (parser->value, "");
g_string_truncate (parser->value, 0);
parser->state = TIPS_IN_TIP;
}
else
......@@ -320,7 +320,7 @@ tips_parser_end_element (GMarkupParseContext *context,
if (parser->markup_depth == 0)
{
tips_parser_set_by_locale (parser, &parser->current_tip->thetip);
g_string_assign (parser->value, "");
g_string_truncate (parser->value, 0);
parser->state = TIPS_IN_TIP;
}
else
......
......@@ -26,6 +26,8 @@
#include "tools-types.h"
#include "config/gimpconfig.h"
#include "config/gimpconfig-deserialize.h"
#include "config/gimpconfig-serialize.h"
#include "core/gimptoolinfo.h"
......@@ -42,10 +44,20 @@
#include "libgimp/gimpintl.h"
static void gimp_text_options_init (GimpTextOptions *options);
static void gimp_text_options_class_init (GimpTextOptionsClass *options_class);
static void gimp_text_options_init (GimpTextOptions *options);
static void gimp_text_options_class_init (GimpTextOptionsClass *options_class);
static void gimp_text_options_config_iface_init (GimpConfigInterface *config_iface);
static void gimp_text_options_reset (GimpToolOptions *tool_options);
static void gimp_text_options_reset (GimpToolOptions *tool_options);
static gboolean gimp_text_options_serialize (GObject *object,
gint fd,
gint indent_level,
gpointer data);
static gboolean gimp_text_options_deserialize (GObject *object,
GScanner *scanner,
gint nest_level,
gpointer data);
static GimpToolOptionsClass *parent_class = NULL;
......@@ -70,10 +82,20 @@ gimp_text_options_get_type (void)
0, /* n_preallocs */
(GInstanceInitFunc) gimp_text_options_init,
};
static const GInterfaceInfo config_iface_info =
{
(GInterfaceInitFunc) gimp_text_options_config_iface_init,
NULL, /* iface_finalize */
NULL /* iface_data */
};
type = g_type_register_static (GIMP_TYPE_TOOL_OPTIONS,
"GimpTextOptions",
&info, 0);
g_type_add_interface_static (type,
GIMP_TYPE_CONFIG_INTERFACE,
&config_iface_info);
}
return type;
......@@ -93,6 +115,13 @@ gimp_text_options_class_init (GimpTextOptionsClass *klass)
options_class->reset = gimp_text_options_reset;
}
static void
gimp_text_options_config_iface_init (GimpConfigInterface *config_iface)
{
config_iface->serialize = gimp_text_options_serialize;
config_iface->deserialize = gimp_text_options_deserialize;
}
static void
gimp_text_options_init (GimpTextOptions *options)
{
......@@ -105,6 +134,30 @@ gimp_text_options_init (GimpTextOptions *options)
options->buffer = gimp_prop_text_buffer_new (text, "text", -1);
}
static gboolean
gimp_text_options_serialize (GObject *object,
gint fd,
gint indent_level,
gpointer data)
{
GimpTextOptions *options = GIMP_TEXT_OPTIONS (object);
return gimp_config_serialize_properties (G_OBJECT (options->text),
fd, indent_level);
}
static gboolean
gimp_text_options_deserialize (GObject *object,
GScanner *scanner,
gint nest_level,
gpointer data)
{
GimpTextOptions *options = GIMP_TEXT_OPTIONS (object);
return gimp_config_deserialize_properties (G_OBJECT (options->text),
scanner, nest_level, FALSE);
}
static void
gimp_text_options_reset (GimpToolOptions *tool_options)
{
......
......@@ -180,17 +180,24 @@ gimp_tool_options_build_filename (GimpToolOptions *tool_options,
gchar *basename;
gchar *filename;
if (! extension)
extension = "default";
basename = g_strconcat (GIMP_OBJECT (tool_options->tool_info)->name,
".", extension, NULL);
filename = g_build_filename (gimp_directory (),
"tool-options", basename,
NULL);
g_free (basename);
if (extension)
{
basename = g_strconcat (GIMP_OBJECT (tool_options->tool_info)->name,
".", extension, NULL);
filename = g_build_filename (gimp_directory (),
"tool-options",
basename,
NULL);
g_free (basename);
}
else
{
filename = g_build_filename (gimp_directory (),
"tool-options",
GIMP_OBJECT (tool_options->tool_info)->name,
NULL);
}
return filename;
}
......
......@@ -92,10 +92,7 @@ gimp_config_serialize_properties (GObject *object,
return FALSE;
}
if (indent_level == 0)
g_string_assign (str, "\n");
else
g_string_assign (str, "");
g_string_truncate (str, 0);
}
g_free (property_specs);
......@@ -157,7 +154,7 @@ gimp_config_serialize_changed_properties (GObject *new,
if (property_written)
g_string_assign (str, "\n");
else
g_string_assign (str, "");
g_string_truncate (str, 0);
gimp_config_string_indent (str, indent_level);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment