Op 18-07-18 om 02:32 schreef Benjamin Summerton via gtk-app-devel-list:
> How do I use an SVG as an Icon where I can scale it based on the DPI?

As Luca suggested the easiest is to use an icon name and it will handle
it for you. There is possibly another option by using cairo surfaces
which I had to use because I had to render something over the icon. I
have not used it with svg image so the below pseudo code may not work
for you.

svg = rsvg_handle_new_from_file(fname, error)
surface = gdk_window_create_similar_surface(gdkwin, cairo_content,
width, heigth)
ctx = cairo_create(surface)
rsvg_handle_render_cairo(svg, ctx)
image = gtk_image_new_from_surface(surface)

You may need to handle scale changes by listening to changes of the
scale-factor property on the GtkWidget.

~infirit
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Reply via email to