Avoid deprecated use of librsvg

This commit is contained in:
Michael Catanzaro 2020-12-04 15:45:16 -06:00
parent ef1fe371bb
commit 48a1ae651a
2 changed files with 11 additions and 16 deletions

View file

@ -67,21 +67,19 @@ public class ChessView : Gtk.DrawingArea
}
catch (Error e)
{
stderr.printf ("Failed to load piece svg: %s\n", e.message);
warning ("Failed to load piece SVG: %s", e.message);
return;
}
c1.save ();
c1.translate (square_size * offset, 0);
c1.scale ((double) square_size / handle.width, (double) square_size / handle.height);
handle.render_cairo (c1);
c1.restore ();
c2.save ();
c2.translate (selected_square_size * offset, 0);
c2.scale ((double) selected_square_size / handle.width, (double) selected_square_size / handle.height);
handle.render_cairo (c2);
c2.restore ();
try
{
handle.render_document (c1, Rsvg.Rectangle () { height = square_size, width = square_size, x = square_size * offset, y = 0 });
handle.render_document (c2, Rsvg.Rectangle () { height = selected_square_size, width = selected_square_size, x = selected_square_size * offset, y = 0 });
}
catch (Error e)
{
warning ("Failed to render piece SVG: %s", e.message);
}
}
private void load_theme (Cairo.Context c)

View file

@ -380,10 +380,7 @@ Copyright © 20152016 Sahil Sareen""";
var s = new Cairo.ImageSurface (Cairo.Format.ARGB32, width, height);
var c = new Cairo.Context (s);
var m = Cairo.Matrix.identity ();
m.scale ((double) width / h.width, (double) height / h.height);
c.set_matrix (m);
h.render_cairo (c);
h.render_document (c, Rsvg.Rectangle () { width = width, height = height, x = 0, y = 0 });
var p = Gdk.pixbuf_get_from_surface (s, 0, 0, width, height);
image.set_from_pixbuf (p);