14
14
* by GIMP but it is also supposed to be able to extract paths and
15
15
* shapes from foreign SVG documents.
17
* This program is free software; you can redistribute it and/or modify
17
* This program is free software: you can redistribute it and/or modify
18
18
* it under the terms of the GNU General Public License as published by
19
* the Free Software Foundation; either version 2 of the License, or
19
* the Free Software Foundation; either version 3 of the License, or
20
20
* (at your option) any later version.
22
22
* This program is distributed in the hope that it will be useful,
25
25
* GNU General Public License for more details.
27
27
* You should have received a copy of the GNU General Public License
28
* along with this program; if not, write to the Free Software
29
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
28
* along with this program. If not, see <http://www.gnu.org/licenses/>.
32
31
#include "config.h"
198
199
const gchar *filename,
202
204
GList **ret_vectors,
205
207
g_return_val_if_fail (GIMP_IS_IMAGE (image), FALSE);
206
208
g_return_val_if_fail (filename != NULL, FALSE);
209
g_return_val_if_fail (parent == NULL ||
210
parent == GIMP_IMAGE_ACTIVE_PARENT ||
211
GIMP_IS_VECTORS (parent), FALSE);
212
g_return_val_if_fail (parent == NULL ||
213
parent == GIMP_IMAGE_ACTIVE_PARENT ||
214
gimp_item_is_attached (GIMP_ITEM (parent)), FALSE);
215
g_return_val_if_fail (parent == NULL ||
216
parent == GIMP_IMAGE_ACTIVE_PARENT ||
217
gimp_item_get_image (GIMP_ITEM (parent)) == image,
219
g_return_val_if_fail (parent == NULL ||
220
parent == GIMP_IMAGE_ACTIVE_PARENT ||
221
gimp_viewable_get_children (GIMP_VIEWABLE (parent)),
207
223
g_return_val_if_fail (ret_vectors == NULL || *ret_vectors == NULL, FALSE);
208
224
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
210
return gimp_vectors_import (image, filename, NULL, 0, merge, scale, position,
226
return gimp_vectors_import (image, filename, NULL, 0, merge, scale,
211
228
ret_vectors, error);
234
252
GList **ret_vectors,
237
255
g_return_val_if_fail (GIMP_IS_IMAGE (image), FALSE);
238
256
g_return_val_if_fail (buffer != NULL || len == 0, FALSE);
257
g_return_val_if_fail (parent == NULL ||
258
parent == GIMP_IMAGE_ACTIVE_PARENT ||
259
GIMP_IS_VECTORS (parent), FALSE);
260
g_return_val_if_fail (parent == NULL ||
261
parent == GIMP_IMAGE_ACTIVE_PARENT ||
262
gimp_item_is_attached (GIMP_ITEM (parent)), FALSE);
263
g_return_val_if_fail (parent == NULL ||
264
parent == GIMP_IMAGE_ACTIVE_PARENT ||
265
gimp_item_get_image (GIMP_ITEM (parent)) == image,
267
g_return_val_if_fail (parent == NULL ||
268
parent == GIMP_IMAGE_ACTIVE_PARENT ||
269
gimp_viewable_get_children (GIMP_VIEWABLE (parent)),
239
271
g_return_val_if_fail (ret_vectors == NULL || *ret_vectors == NULL, FALSE);
240
272
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
242
return gimp_vectors_import (image, NULL, buffer, len, merge, scale, position,
274
return gimp_vectors_import (image, NULL, buffer, len, merge, scale,
243
276
ret_vectors, error);
300
334
SvgPath *path = paths->data;
303
if (!merge || !vectors)
337
if (! merge || ! vectors)
305
339
vectors = gimp_vectors_new (image,
306
((merge || !path->id) ?
340
((merge || ! path->id) ?
307
341
_("Imported Path") : path->id));
308
gimp_image_add_vectors (image, vectors, position);
342
gimp_image_add_vectors (image, vectors,
343
parent, position, TRUE);
309
344
gimp_vectors_freeze (vectors);
318
353
for (list = path->strokes; list; list = list->next)
319
354
gimp_vectors_stroke_add (vectors, GIMP_STROKE (list->data));
322
357
gimp_vectors_thaw (vectors);
324
g_list_free (path->strokes);
359
g_list_free_full (path->strokes, g_object_unref);
325
360
path->strokes = NULL;
336
g_set_error (error, 0, 0, _("No paths found in '%s'"),
371
g_set_error (error, GIMP_ERROR, GIMP_FAILED,
372
_("No paths found in '%s'"),
337
373
gimp_filename_to_utf8 (filename));
339
g_set_error (error, 0, 0, _("No paths found in the buffer"));
375
g_set_error_literal (error, GIMP_ERROR, GIMP_FAILED,
376
_("No paths found in the buffer"));
602
639
switch (*names[0])
605
if (strcmp (*names, "id") == 0 && !path->id)
642
if (strcmp (*names, "id") == 0 && ! path->id)
606
643
path->id = g_strdup (*values);
610
if (strcmp (*names, "d") == 0 && !path->strokes)
647
if (strcmp (*names, "d") == 0 && ! path->strokes)
611
648
path->strokes = parse_path_data (*values);
615
if (strcmp (*names, "transform") == 0 && !handler->transform)
652
if (strcmp (*names, "transform") == 0 && ! handler->transform)
617
654
GimpMatrix3 matrix;
930
967
switch (*names[0])
933
if (strcmp (*names, "id") == 0 && !path->id)
970
if (strcmp (*names, "id") == 0 && ! path->id)
934
971
path->id = g_strdup (*values);
938
if (strcmp (*names, "points") == 0 && !points)
975
if (strcmp (*names, "points") == 0 && ! points)
940
977
const gchar *p = *values;
941
978
const gchar *m = NULL;
1236
1274
/* OK, have parsed keyword and args, now calculate the transform matrix */
1238
if (!strcmp (keyword, "matrix"))
1276
if (strcmp (keyword, "matrix") == 0)
1240
1278
if (n_args != 6)
1255
1293
gimp_matrix3_translate (&trafo, args[0], args[1]);
1257
else if (!strcmp (keyword, "scale"))
1295
else if (strcmp (keyword, "scale") == 0)
1259
1297
if (n_args == 1)
1260
1298
args[1] = args[0];
1264
1302
gimp_matrix3_scale (&trafo, args[0], args[1]);
1266
else if (!strcmp (keyword, "rotate"))
1304
else if (strcmp (keyword, "rotate") == 0)
1268
1306
if (n_args == 1)
1281
else if (!strcmp (keyword, "skewX"))
1319
else if (strcmp (keyword, "skewX") == 0)
1283
1321
if (n_args != 1)
1286
1324
gimp_matrix3_xshear (&trafo, tan (gimp_deg_to_rad (args[0])));
1288
else if (!strcmp (keyword, "skewY"))
1326
else if (strcmp (keyword, "skewY") == 0)
1290
1328
if (n_args != 1)