removed the GError parameter from gimp_vectors_export_string() and
2003-12-21 Sven Neumann <sven@gimp.org> * app/vectors/gimpvectors-export.[ch]: removed the GError parameter from gimp_vectors_export_string() and implemented this function.
This commit is contained in:

committed by
Sven Neumann

parent
fc47cbc059
commit
9630d40834
@ -1,3 +1,8 @@
|
|||||||
|
2003-12-21 Sven Neumann <sven@gimp.org>
|
||||||
|
|
||||||
|
* app/vectors/gimpvectors-export.[ch]: removed the GError parameter
|
||||||
|
from gimp_vectors_export_string() and implemented this function.
|
||||||
|
|
||||||
2003-12-21 Michael Natterer <mitch@gimp.org>
|
2003-12-21 Michael Natterer <mitch@gimp.org>
|
||||||
|
|
||||||
* app/widgets/gimppreviewrendererbrush.c: removed trailing
|
* app/widgets/gimppreviewrendererbrush.c: removed trailing
|
||||||
|
@ -40,10 +40,13 @@
|
|||||||
#include "gimp-intl.h"
|
#include "gimp-intl.h"
|
||||||
|
|
||||||
|
|
||||||
|
static GString * gimp_vectors_export (const GimpImage *image,
|
||||||
|
const GimpVectors *vectors);
|
||||||
|
static void gimp_vectors_export_image_size (const GimpImage *image,
|
||||||
|
GString *str);
|
||||||
static void gimp_vectors_export_path (const GimpVectors *vectors,
|
static void gimp_vectors_export_path (const GimpVectors *vectors,
|
||||||
FILE *file);
|
GString *str);
|
||||||
static gchar * gimp_vectors_export_path_data (const GimpVectors *vectors);
|
static gchar * gimp_vectors_export_path_data (const GimpVectors *vectors);
|
||||||
static gchar * gimp_vectors_export_image_size (const GimpImage *image);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -55,7 +58,8 @@ static gchar * gimp_vectors_export_image_size (const GimpImage *image);
|
|||||||
*
|
*
|
||||||
* Exports one or more vectors to a SVG file.
|
* Exports one or more vectors to a SVG file.
|
||||||
*
|
*
|
||||||
* Return value: %TRUE on success, %FALSE if an error occured
|
* Return value: %TRUE on success,
|
||||||
|
* %FALSE if there was an error writing the file
|
||||||
**/
|
**/
|
||||||
gboolean
|
gboolean
|
||||||
gimp_vectors_export_file (const GimpImage *image,
|
gimp_vectors_export_file (const GimpImage *image,
|
||||||
@ -64,7 +68,7 @@ gimp_vectors_export_file (const GimpImage *image,
|
|||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
FILE *file;
|
FILE *file;
|
||||||
gchar *size;
|
GString *str;
|
||||||
|
|
||||||
g_return_val_if_fail (GIMP_IS_IMAGE (image), FALSE);
|
g_return_val_if_fail (GIMP_IS_IMAGE (image), FALSE);
|
||||||
g_return_val_if_fail (vectors == NULL || GIMP_IS_VECTORS (vectors), FALSE);
|
g_return_val_if_fail (vectors == NULL || GIMP_IS_VECTORS (vectors), FALSE);
|
||||||
@ -79,32 +83,11 @@ gimp_vectors_export_file (const GimpImage *image,
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf (file,
|
str = gimp_vectors_export (image, vectors);
|
||||||
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n"
|
|
||||||
"<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 20010904//EN\"\n"
|
|
||||||
" \"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd\">\n"
|
|
||||||
"<svg xmlns=\"http://www.w3.org/2000/svg\"\n");
|
|
||||||
|
|
||||||
size = gimp_vectors_export_image_size (image);
|
fprintf (file, str->str);
|
||||||
fprintf (file, " %s\n", size);
|
|
||||||
g_free (size);
|
|
||||||
|
|
||||||
fprintf (file, " viewBox=\"0 0 %d %d\">\n",
|
g_string_free (str, TRUE);
|
||||||
image->width, image->height);
|
|
||||||
|
|
||||||
if (vectors)
|
|
||||||
{
|
|
||||||
gimp_vectors_export_path (vectors, file);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
GList *list;
|
|
||||||
|
|
||||||
for (list = GIMP_LIST (image->vectors)->list; list; list = list->next)
|
|
||||||
gimp_vectors_export_path (GIMP_VECTORS (list->data), file);
|
|
||||||
}
|
|
||||||
|
|
||||||
fprintf (file, "</svg>\n");
|
|
||||||
|
|
||||||
if (fclose (file))
|
if (fclose (file))
|
||||||
{
|
{
|
||||||
@ -116,22 +99,66 @@ gimp_vectors_export_file (const GimpImage *image,
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gimp_vectors_export_string:
|
||||||
|
* @image: the #GimpImage from which to export vectors
|
||||||
|
* @vectors: a #GimpVectors object or %NULL to export all vectors in @image
|
||||||
|
*
|
||||||
|
* Exports one or more vectors to a SVG string.
|
||||||
|
*
|
||||||
|
* Return value: a %NUL-terminated string that holds a complete XML document
|
||||||
|
**/
|
||||||
gchar *
|
gchar *
|
||||||
gimp_vectors_export_string (const GimpImage *image,
|
gimp_vectors_export_string (const GimpImage *image,
|
||||||
const GimpVectors *vectors,
|
const GimpVectors *vectors)
|
||||||
GError **error)
|
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (GIMP_IS_IMAGE (image), FALSE);
|
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
|
||||||
g_return_val_if_fail (vectors == NULL || GIMP_IS_VECTORS (vectors), FALSE);
|
g_return_val_if_fail (vectors == NULL || GIMP_IS_VECTORS (vectors), NULL);
|
||||||
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
|
|
||||||
|
|
||||||
g_warning ("gimp_vectors_export_string: unimplemented");
|
return g_string_free (gimp_vectors_export (image, vectors), FALSE);
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static gchar *
|
static GString *
|
||||||
gimp_vectors_export_image_size (const GimpImage *image)
|
gimp_vectors_export (const GimpImage *image,
|
||||||
|
const GimpVectors *vectors)
|
||||||
|
{
|
||||||
|
GString *str = g_string_new (NULL);
|
||||||
|
|
||||||
|
g_string_append_printf (str,
|
||||||
|
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n"
|
||||||
|
"<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 20010904//EN\"\n"
|
||||||
|
" \"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd\">\n"
|
||||||
|
"\n"
|
||||||
|
"<svg xmlns=\"http://www.w3.org/2000/svg\"\n");
|
||||||
|
|
||||||
|
g_string_append (str, " ");
|
||||||
|
gimp_vectors_export_image_size (image, str);
|
||||||
|
g_string_append_c (str, '\n');
|
||||||
|
|
||||||
|
g_string_append_printf (str,
|
||||||
|
" viewBox=\"0 0 %d %d\">\n",
|
||||||
|
image->width, image->height);
|
||||||
|
|
||||||
|
if (vectors)
|
||||||
|
{
|
||||||
|
gimp_vectors_export_path (vectors, str);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GList *list;
|
||||||
|
|
||||||
|
for (list = GIMP_LIST (image->vectors)->list; list; list = list->next)
|
||||||
|
gimp_vectors_export_path (GIMP_VECTORS (list->data), str);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_string_append (str, "</svg>\n");
|
||||||
|
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gimp_vectors_export_image_size (const GimpImage *image,
|
||||||
|
GString *str)
|
||||||
{
|
{
|
||||||
GimpUnit unit;
|
GimpUnit unit;
|
||||||
const gchar *abbrev;
|
const gchar *abbrev;
|
||||||
@ -161,13 +188,14 @@ gimp_vectors_export_image_size (const GimpImage *image)
|
|||||||
g_ascii_formatd (hbuf, sizeof (hbuf),
|
g_ascii_formatd (hbuf, sizeof (hbuf),
|
||||||
"%g", h * _gimp_unit_get_factor (image->gimp, unit));
|
"%g", h * _gimp_unit_get_factor (image->gimp, unit));
|
||||||
|
|
||||||
return g_strdup_printf ("width=\"%s%s\" height=\"%s%s\"",
|
g_string_append_printf (str,
|
||||||
|
"width=\"%s%s\" height=\"%s%s\"",
|
||||||
wbuf, abbrev, hbuf, abbrev);
|
wbuf, abbrev, hbuf, abbrev);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gimp_vectors_export_path (const GimpVectors *vectors,
|
gimp_vectors_export_path (const GimpVectors *vectors,
|
||||||
FILE *file)
|
GString *str)
|
||||||
{
|
{
|
||||||
const gchar *name = gimp_object_get_name (GIMP_OBJECT (vectors));
|
const gchar *name = gimp_object_get_name (GIMP_OBJECT (vectors));
|
||||||
gchar *data = gimp_vectors_export_path_data (vectors);
|
gchar *data = gimp_vectors_export_path_data (vectors);
|
||||||
@ -175,7 +203,7 @@ gimp_vectors_export_path (const GimpVectors *vectors,
|
|||||||
|
|
||||||
esc_name = g_markup_escape_text (name, strlen (name));
|
esc_name = g_markup_escape_text (name, strlen (name));
|
||||||
|
|
||||||
fprintf (file,
|
g_string_append_printf (str,
|
||||||
" <path id=\"%s\"\n"
|
" <path id=\"%s\"\n"
|
||||||
" fill=\"none\" stroke=\"black\" stroke-width=\"1\"\n"
|
" fill=\"none\" stroke=\"black\" stroke-width=\"1\"\n"
|
||||||
" d=\"%s\" />\n",
|
" d=\"%s\" />\n",
|
||||||
|
@ -25,8 +25,7 @@ gboolean gimp_vectors_export_file (const GimpImage *image,
|
|||||||
const gchar *filename,
|
const gchar *filename,
|
||||||
GError **error);
|
GError **error);
|
||||||
gchar * gimp_vectors_export_string (const GimpImage *image,
|
gchar * gimp_vectors_export_string (const GimpImage *image,
|
||||||
const GimpVectors *vectors,
|
const GimpVectors *vectors);
|
||||||
GError **error);
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* __GIMP_VECTORS_IMPORT_H__ */
|
#endif /* __GIMP_VECTORS_IMPORT_H__ */
|
||||||
|
Reference in New Issue
Block a user