Re: Using SVG for icons (and scaling)

2018-07-18 Thread infirit via gtk-app-devel-list
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


Re: Using SVG for icons (and scaling)

2018-07-18 Thread Luca Bacci via gtk-app-devel-list
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


Currently, the solution is to use: 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
>
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Using SVG for icons (and scaling)

2018-07-18 Thread Benjamin Summerton via gtk-app-devel-list
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