talons

Fork of Claws Mail https://www.claws-mail
Log | Files | Refs | README | LICENSE

commit 897e3cd0382e242c2dbb2dd08c68ffdadd2a7db1
parent 46746a17a630396aff1aeee108c657dc45234ca2
Author: Ricardo Mones <ricardo@mones.org>
Date:   Thu, 28 Dec 2023 13:09:12 +0100

Don't use deprecated calls with modern SVG library

Removes the following warnings:
• stock_pixmap.c:545:9: warning: ‘rsvg_handle_get_dimensions’ is
  deprecated: Use 'rsvg_handle_get_intrinsic_size_in_pixels' instead
• stock_pixmap.c:554:9: warning: ‘rsvg_handle_render_cairo’ is deprecated:
  Use 'rsvg_handle_render_document' instead
• stock_pixmap.c:675:17: warning: ‘rsvg_handle_get_dimensions’ is
  deprecated: Use 'rsvg_handle_get_intrinsic_size_in_pixels' instead

Diffstat:
Msrc/stock_pixmap.c | 29+++++++++++++++++++++++++++++
1 file changed, 29 insertions(+), 0 deletions(-)

diff --git a/src/stock_pixmap.c b/src/stock_pixmap.c @@ -538,6 +538,26 @@ GtkWidget *stock_pixmap_widget(StockPixmap icon) */ void render_scaled_proportionally(RsvgHandle *handle, cairo_t *cr, int width, int height) { +#if LIBRSVG_CHECK_VERSION(2, 46, 0) + if (cairo_status(cr) == CAIRO_STATUS_SUCCESS) { + const RsvgRectangle viewport = { + .x = 0, + .y = 0, + .width = width, + .height = height, + }; + GError *err = NULL; + + cairo_rectangle(cr, 0, 0, width, height); + cairo_clip(cr); + + rsvg_handle_render_document(handle, cr, &viewport, &err); + if (err != NULL) { + g_warning("unable to render SVG document (%d): %s", err->code, err->message); + g_error_free(err); + } + } +#else RsvgDimensionData dimensions; double x_factor, y_factor; double scale_factor; @@ -552,6 +572,7 @@ void render_scaled_proportionally(RsvgHandle *handle, cairo_t *cr, int width, in cairo_scale(cr, scale_factor, scale_factor); rsvg_handle_render_cairo(handle, cr); +#endif } /* @@ -670,11 +691,19 @@ GdkPixbuf *pixbuf_from_svg_like_icon(char *filename, GError **error, StockPixmap height = (int) floor(factor * height); } } else { /* render using SVG size */ +#if LIBRSVG_CHECK_VERSION(2, 46, 0) + double svg_width, svg_height; + + rsvg_handle_get_intrinsic_size_in_pixels(handle, &svg_width, &svg_height); + width = (int) svg_width; + height = (int) svg_height; +#else RsvgDimensionData dimension; rsvg_handle_get_dimensions (handle, &dimension); width = dimension.width; height = dimension.height; +#endif } /* create drawing context */