/* grrobot - Ricochet Robot using GTK+ and Xr
*
- * Copyright © 2003 Carl Worth
+ * Copyright © 2003 Carl Worth
*
* Permission to use, copy, modify, distribute, and sell this software
* and its documentation for any purpose is hereby granted without
static rr_status_t
_grr_icon_init (grr_icon_t *icon, char *name)
{
- svg_cairo_status_t status;
char *file, *buf;
int buflen;
+ GError *error = NULL;
icon->surface = NULL;
icon->surface_width = 0;
icon->surface_height = 0;
- status = svg_cairo_create (&icon->svg_cairo);
- if (status)
- return RR_STATUS_NO_MEMORY;
-
file = _grr_icon_find_file (name);
-
if (file) {
- status = svg_cairo_parse (icon->svg_cairo, file);
- if (status == SVG_CAIRO_STATUS_SUCCESS) {
- free (file);
- return RR_STATUS_SUCCESS;
- }
- fprintf (stderr, "Error parsing SVG icon: %s\n", file);
- free (file);
- }
-
- _grr_icon_find_buffer (name, &buf, &buflen);
- status = svg_cairo_parse_buffer (icon->svg_cairo, buf, buflen);
- if (status) {
- fprintf (stderr, "Error parsing built-in SVG icon for: %s\n", name);
- return RR_STATUS_PARSE_ERROR;
+ icon->rsvg = rsvg_handle_new_from_file(file, &error);
+ if (!icon->rsvg) {
+ fprintf (stderr, "Error parsing SVG icon: %s\n", file);
+ return RR_STATUS_PARSE_ERROR;
+ }
+ } else {
+ _grr_icon_find_buffer (name, &buf, &buflen);
+ icon->rsvg = rsvg_handle_new_from_data(buf, buflen, &error);
+ if (!icon->rsvg) {
+ fprintf (stderr, "Error parsing built-in SVG icon for: %s\n", name);
+ return RR_STATUS_PARSE_ERROR;
+ }
}
return RR_STATUS_SUCCESS;
}
void
grr_icon_draw (grr_icon_t *icon, cairo_t *xrs)
{
- svg_cairo_status_t status;
-
- status = svg_cairo_render (icon->svg_cairo, xrs);
+ rsvg_handle_render_cairo(icon->rsvg, xrs);
+#if 0
if (status) {
fprintf (stderr, "svg_cairo_render error\n");
return;
}
+#endif
}
void
icon->surface_width = width;
icon->surface_height = height;
icon->surface = cairo_surface_create_similar (cairo_get_target (xrs),
- CAIRO_FORMAT_ARGB32,
+ CAIRO_CONTENT_COLOR_ALPHA,
width, height);
}