app/vectors: formatting

This commit is contained in:
Sven Neumann 2010-10-13 21:52:10 +02:00
parent 8cf6695a50
commit 4236990351
1 changed files with 36 additions and 26 deletions

View File

@ -334,10 +334,10 @@ gimp_vectors_import (GimpImage *image,
SvgPath *path = paths->data; SvgPath *path = paths->data;
GList *list; GList *list;
if (!merge || !vectors) if (! merge || ! vectors)
{ {
vectors = gimp_vectors_new (image, vectors = gimp_vectors_new (image,
((merge || !path->id) ? ((merge || ! path->id) ?
_("Imported Path") : path->id)); _("Imported Path") : path->id));
gimp_image_add_vectors (image, vectors, gimp_image_add_vectors (image, vectors,
parent, position, TRUE); parent, position, TRUE);
@ -353,7 +353,7 @@ gimp_vectors_import (GimpImage *image,
for (list = path->strokes; list; list = list->next) for (list = path->strokes; list; list = list->next)
gimp_vectors_stroke_add (vectors, GIMP_STROKE (list->data)); gimp_vectors_stroke_add (vectors, GIMP_STROKE (list->data));
if (!merge) if (! merge)
gimp_vectors_thaw (vectors); gimp_vectors_thaw (vectors);
g_list_free (path->strokes); g_list_free (path->strokes);
@ -597,7 +597,7 @@ svg_handler_group_start (SvgHandler *handler,
{ {
while (*names) while (*names)
{ {
if (strcmp (*names, "transform") == 0 && !handler->transform) if (strcmp (*names, "transform") == 0 && ! handler->transform)
{ {
GimpMatrix3 matrix; GimpMatrix3 matrix;
@ -639,17 +639,17 @@ svg_handler_path_start (SvgHandler *handler,
switch (*names[0]) switch (*names[0])
{ {
case 'i': case 'i':
if (strcmp (*names, "id") == 0 && !path->id) if (strcmp (*names, "id") == 0 && ! path->id)
path->id = g_strdup (*values); path->id = g_strdup (*values);
break; break;
case 'd': case 'd':
if (strcmp (*names, "d") == 0 && !path->strokes) if (strcmp (*names, "d") == 0 && ! path->strokes)
path->strokes = parse_path_data (*values); path->strokes = parse_path_data (*values);
break; break;
case 't': case 't':
if (strcmp (*names, "transform") == 0 && !handler->transform) if (strcmp (*names, "transform") == 0 && ! handler->transform)
{ {
GimpMatrix3 matrix; GimpMatrix3 matrix;
@ -691,7 +691,7 @@ svg_handler_rect_start (SvgHandler *handler,
switch (*names[0]) switch (*names[0])
{ {
case 'i': case 'i':
if (strcmp (*names, "id") == 0 && !path->id) if (strcmp (*names, "id") == 0 && ! path->id)
path->id = g_strdup (*values); path->id = g_strdup (*values);
break; break;
@ -723,7 +723,7 @@ svg_handler_rect_start (SvgHandler *handler,
break; break;
case 't': case 't':
if (strcmp (*names, "transform") == 0 && !handler->transform) if (strcmp (*names, "transform") == 0 && ! handler->transform)
{ {
GimpMatrix3 matrix; GimpMatrix3 matrix;
@ -837,7 +837,7 @@ svg_handler_ellipse_start (SvgHandler *handler,
switch (*names[0]) switch (*names[0])
{ {
case 'i': case 'i':
if (strcmp (*names, "id") == 0 && !path->id) if (strcmp (*names, "id") == 0 && ! path->id)
path->id = g_strdup (*values); path->id = g_strdup (*values);
break; break;
@ -865,7 +865,7 @@ svg_handler_ellipse_start (SvgHandler *handler,
break; break;
case 't': case 't':
if (strcmp (*names, "transform") == 0 && !handler->transform) if (strcmp (*names, "transform") == 0 && ! handler->transform)
{ {
GimpMatrix3 matrix; GimpMatrix3 matrix;
@ -910,7 +910,7 @@ svg_handler_line_start (SvgHandler *handler,
switch (*names[0]) switch (*names[0])
{ {
case 'i': case 'i':
if (strcmp (*names, "id") == 0 && !path->id) if (strcmp (*names, "id") == 0 && ! path->id)
path->id = g_strdup (*values); path->id = g_strdup (*values);
break; break;
@ -929,7 +929,7 @@ svg_handler_line_start (SvgHandler *handler,
break; break;
case 't': case 't':
if (strcmp (*names, "transform") == 0 && !handler->transform) if (strcmp (*names, "transform") == 0 && ! handler->transform)
{ {
GimpMatrix3 matrix; GimpMatrix3 matrix;
@ -967,12 +967,12 @@ svg_handler_poly_start (SvgHandler *handler,
switch (*names[0]) switch (*names[0])
{ {
case 'i': case 'i':
if (strcmp (*names, "id") == 0 && !path->id) if (strcmp (*names, "id") == 0 && ! path->id)
path->id = g_strdup (*values); path->id = g_strdup (*values);
break; break;
case 'p': case 'p':
if (strcmp (*names, "points") == 0 && !points) if (strcmp (*names, "points") == 0 && ! points)
{ {
const gchar *p = *values; const gchar *p = *values;
const gchar *m = NULL; const gchar *m = NULL;
@ -997,7 +997,7 @@ svg_handler_poly_start (SvgHandler *handler,
if (*p) if (*p)
n++; n++;
while (*p && !g_ascii_isspace (*p) && *p != ',') while (*p && ! g_ascii_isspace (*p) && *p != ',')
p++; p++;
} }
@ -1018,7 +1018,7 @@ svg_handler_poly_start (SvgHandler *handler,
break; break;
case 't': case 't':
if (strcmp (*names, "transform") == 0 && !handler->transform) if (strcmp (*names, "transform") == 0 && ! handler->transform)
{ {
GimpMatrix3 matrix; GimpMatrix3 matrix;
@ -1273,7 +1273,7 @@ parse_svg_transform (const gchar *value,
/* OK, have parsed keyword and args, now calculate the transform matrix */ /* OK, have parsed keyword and args, now calculate the transform matrix */
if (!strcmp (keyword, "matrix")) if (strcmp (keyword, "matrix") == 0)
{ {
if (n_args != 6) if (n_args != 6)
return FALSE; return FALSE;
@ -1283,7 +1283,7 @@ parse_svg_transform (const gchar *value,
args[2], args[3], args[2], args[3],
args[4], args[5]); args[4], args[5]);
} }
else if (!strcmp (keyword, "translate")) else if (strcmp (keyword, "translate") == 0)
{ {
if (n_args == 1) if (n_args == 1)
args[1] = 0.0; args[1] = 0.0;
@ -1292,7 +1292,7 @@ parse_svg_transform (const gchar *value,
gimp_matrix3_translate (&trafo, args[0], args[1]); gimp_matrix3_translate (&trafo, args[0], args[1]);
} }
else if (!strcmp (keyword, "scale")) else if (strcmp (keyword, "scale") == 0)
{ {
if (n_args == 1) if (n_args == 1)
args[1] = args[0]; args[1] = args[0];
@ -1301,7 +1301,7 @@ parse_svg_transform (const gchar *value,
gimp_matrix3_scale (&trafo, args[0], args[1]); gimp_matrix3_scale (&trafo, args[0], args[1]);
} }
else if (!strcmp (keyword, "rotate")) else if (strcmp (keyword, "rotate") == 0)
{ {
if (n_args == 1) if (n_args == 1)
{ {
@ -1316,14 +1316,14 @@ parse_svg_transform (const gchar *value,
else else
return FALSE; return FALSE;
} }
else if (!strcmp (keyword, "skewX")) else if (strcmp (keyword, "skewX") == 0)
{ {
if (n_args != 1) if (n_args != 1)
return FALSE; return FALSE;
gimp_matrix3_xshear (&trafo, tan (gimp_deg_to_rad (args[0]))); gimp_matrix3_xshear (&trafo, tan (gimp_deg_to_rad (args[0])));
} }
else if (!strcmp (keyword, "skewY")) else if (strcmp (keyword, "skewY") == 0)
{ {
if (n_args != 1) if (n_args != 1)
return FALSE; return FALSE;
@ -1393,6 +1393,7 @@ parse_path_data (const gchar *data)
for (i = 0; ; i++) for (i = 0; ; i++)
{ {
c = data[i]; c = data[i];
if (c >= '0' && c <= '9') if (c >= '0' && c <= '9')
{ {
/* digit */ /* digit */
@ -1422,11 +1423,12 @@ parse_path_data (const gchar *data)
} }
else if (c == '.') else if (c == '.')
{ {
if (!in_num) if (! in_num)
{ {
in_num = TRUE; in_num = TRUE;
val = 0; val = 0;
} }
in_frac = TRUE; in_frac = TRUE;
frac = 1; frac = 1;
} }
@ -1446,6 +1448,7 @@ parse_path_data (const gchar *data)
/* end of number */ /* end of number */
val *= sign * pow (10, exp_sign * exp); val *= sign * pow (10, exp_sign * exp);
if (ctx.rel) if (ctx.rel)
{ {
/* Handle relative coordinates. This switch statement attempts /* Handle relative coordinates. This switch statement attempts
@ -1475,10 +1478,12 @@ parse_path_data (const gchar *data)
else if (ctx.param == 6) else if (ctx.param == 6)
val += ctx.cpy; val += ctx.cpy;
break; break;
case 'h': case 'h':
/* rule: x-relative */ /* rule: x-relative */
val += ctx.cpx; val += ctx.cpx;
break; break;
case 'v': case 'v':
/* rule: y-relative */ /* rule: y-relative */
val += ctx.cpy; val += ctx.cpy;
@ -1492,8 +1497,10 @@ parse_path_data (const gchar *data)
} }
if (c == '\0') if (c == '\0')
break; {
else if ((c == '+' || c == '-') && !exp_wait_sign) break;
}
else if ((c == '+' || c == '-') && ! exp_wait_sign)
{ {
sign = c == '+' ? 1 : -1; sign = c == '+' ? 1 : -1;
val = 0; val = 0;
@ -1508,6 +1515,7 @@ parse_path_data (const gchar *data)
{ {
if (ctx.param) if (ctx.param)
parse_path_do_cmd (&ctx, TRUE); parse_path_do_cmd (&ctx, TRUE);
if (ctx.stroke) if (ctx.stroke)
gimp_stroke_close (ctx.stroke); gimp_stroke_close (ctx.stroke);
} }
@ -1515,6 +1523,7 @@ parse_path_data (const gchar *data)
{ {
if (ctx.param) if (ctx.param)
parse_path_do_cmd (&ctx, TRUE); parse_path_do_cmd (&ctx, TRUE);
ctx.cmd = c + 'a' - 'A'; ctx.cmd = c + 'a' - 'A';
ctx.rel = FALSE; ctx.rel = FALSE;
} }
@ -1522,6 +1531,7 @@ parse_path_data (const gchar *data)
{ {
if (ctx.param) if (ctx.param)
parse_path_do_cmd (&ctx, TRUE); parse_path_do_cmd (&ctx, TRUE);
ctx.cmd = c; ctx.cmd = c;
ctx.rel = TRUE; ctx.rel = TRUE;
} }