Re: Using SVG for icons (and scaling)



SVG are supported in Gtk (and Glade)

Support for image formats is modularized in form of plugins, you just need
to get the plugin for SVG. In many distros you have to install 'librsvg' to
get the SVG loader.

As for scaling goes, GtkImage can scale images only when using icon-name
source and not from sources like files, resources, stock icons (this can
even be seen in Glade).
There has been some discussion on that: bug 728476
<https://bugzilla.gnome.org/show_bug.cgi?id=728476>

Currently, the solution is to use: gtk_icon_theme_add_resource_path ()
<https://developer.gnome.org/gtk3/stable/GtkIconTheme.html#gtk-icon-theme-add-resource-path>
to augment the system theme with your icons and then use icon-name in
GtkImage to load your SVGs.
Then you can set 'icon-size' property of GtkImage to something you want to
(Menu, Small Toolbar, Large Toolbar, Button, Drag and Drop, Dialog - those
should take DPI in account) or set
'pixel-size' property to set the size you want in pixel.

But I think there is no way to display them when editing in glade

Luca


2018-07-18 4:32 GMT+02:00 Benjamin Summerton via gtk-app-devel-list <
gtk-app-devel-list gnome org>:

I'm currently developing an application (using the Gtk 3.x series).  I've
got some icons I'd like to use (for buttons n' stuff) and they are in SVG
format.

It's pretty trivial to turn these into a PNG, and then into my .glade
file.  But I'm a bit concerned about how much smaller bitmap images will
look on high DPI displays.

I've been trying to search for the information on how to achieve this, but
I haven't found much of anything.  So to summerize:

How do I use an SVG as an Icon where I can scale it based on the DPI?

And if I can't do this in Glade, how would I do this in code?

Thanks,
~Ben
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]