diff --git a/app/path/gimppath-export.c b/app/path/gimppath-export.c
index 09e6941d95..d3c77116f0 100644
--- a/app/path/gimppath-export.c
+++ b/app/path/gimppath-export.c
@@ -215,21 +215,27 @@ gimp_path_export_path (GimpPath *path,
GString *str,
gint path_id)
{
- gchar *name;
- gchar *data = gimp_path_export_path_data (path);
+ const gchar *name = gimp_object_get_name (path);
+ gchar *data = gimp_path_export_path_data (path);
+ gchar *id;
+ gchar *esc_name;
/* SVG specification states the id attribute must not contain whitespace.
* Rather than filter user names, we'll just define a generic,
* auto-incrementing id. */
- name = g_strdup_printf ("path%d", path_id);
+ id = g_strdup_printf ("path%d", path_id);
+ esc_name = g_markup_escape_text (name, strlen (name));
g_string_append_printf (str,
" \n",
- name, data);
+ " d=\"%s\">\n"
+ "
%s\n"
+ " \n",
+ id, data, esc_name);
- g_free (name);
+ g_free (id);
+ g_free (esc_name);
g_free (data);
}
diff --git a/app/path/gimppath-import.c b/app/path/gimppath-import.c
index 202c2d9ab5..8565218f33 100644
--- a/app/path/gimppath-import.c
+++ b/app/path/gimppath-import.c
@@ -134,6 +134,11 @@ static void svg_parser_start_element (GMarkupParseContext *context,
const gchar **attribute_values,
gpointer user_data,
GError **error);
+static void svg_parser_text (GMarkupParseContext *context,
+ const gchar *text,
+ gsize text_len,
+ gpointer user_data,
+ GError **error);
static void svg_parser_end_element (GMarkupParseContext *context,
const gchar *element_name,
gpointer user_data,
@@ -143,7 +148,7 @@ static const GMarkupParser markup_parser =
{
svg_parser_start_element,
svg_parser_end_element,
- NULL, /* characters */
+ svg_parser_text,
NULL, /* passthrough */
NULL /* error */
};
@@ -190,7 +195,8 @@ static const SvgHandler svg_handlers[] =
{ "ellipse", svg_handler_ellipse_start, NULL },
{ "line", svg_handler_line_start, NULL },
{ "polyline", svg_handler_poly_start, NULL },
- { "polygon", svg_handler_poly_start, NULL }
+ { "polygon", svg_handler_poly_start, NULL },
+ { "title", NULL, NULL }
};
@@ -480,6 +486,50 @@ svg_parser_start_element (GMarkupParseContext *context,
handler->start (handler, attribute_names, attribute_values, parser);
}
+static void
+svg_parser_text (GMarkupParseContext *context,
+ const gchar *text,
+ gsize text_len,
+ gpointer user_data,
+ GError **error)
+{
+ SvgParser *parser = user_data;
+ SvgHandler *handler;
+
+ handler = g_queue_pop_head (parser->stack);
+
+ if (handler &&
+ handler->name &&
+ strcmp (handler->name, "title") == 0)
+ {
+ gchar *title = g_markup_escape_text (text, text_len);
+ SvgHandler *prior_handler;
+ GList *paths;
+
+ prior_handler = g_queue_pop_head (parser->stack);
+
+ /* Replace path ID with title name if imported */
+ if (prior_handler && prior_handler->paths)
+ {
+ for (paths = prior_handler->paths; paths; paths = paths->next)
+ {
+ SvgPath *svg_path = paths->data;
+
+ if (svg_path->id)
+ g_free (svg_path->id);
+
+ svg_path->id = g_strdup (title);
+ }
+ g_list_free (paths);
+ }
+
+ g_queue_push_head (parser->stack, prior_handler);
+ g_free (title);
+ }
+ g_queue_push_head (parser->stack, handler);
+}
+
+
static void
svg_parser_end_element (GMarkupParseContext *context,
const gchar *element_name,
@@ -1761,7 +1811,7 @@ parse_number (ParsePathContext *ctx,
if (c >= '0' && c <= '9')
{
fraction *= 0.1;
- value += fraction * (c - '0');
+ value += fraction * (c - '0');
}
else if (c == 'e' || c == 'E')
{