[Commits] [SCM] claws branch, master, updated. 4.2.0-20-g897e3cd03

mones at claws-mail.org mones at claws-mail.org
Thu Dec 28 12:10:16 UTC 2023


The branch, master has been updated
       via  897e3cd0382e242c2dbb2dd08c68ffdadd2a7db1 (commit)
      from  46746a17a630396aff1aeee108c657dc45234ca2 (commit)

Summary of changes:
 src/stock_pixmap.c | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)


- Log -----------------------------------------------------------------
commit 897e3cd0382e242c2dbb2dd08c68ffdadd2a7db1
Author: Ricardo Mones <ricardo at mones.org>
Date:   Thu Dec 28 13:09:12 2023 +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

diff --git a/src/stock_pixmap.c b/src/stock_pixmap.c
index 99303ffc3..4b7d019e6 100644
--- 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 */

-----------------------------------------------------------------------


hooks/post-receive
-- 
Claws Mail


More information about the Commits mailing list