开发者

GTK: how to get width and height of GTK_ICON_SIZE_BUTTON etc?

I need to add my own images into GTK Icon Theme, so i need to somehow figure the size in pixels GTK uses to display icons of different predefined sizes: GTK_ICON_SIZE_BUTTON, GTK_ICON_SIZE_MENU, GTK_ICON_SIZE_DIALOG etc. GTK manual states that sizes are available as value of gtk-icon-sizes property of GtkSettings object. I have executed foll开发者_运维问答owing code on latest ubuntu:

#!/usr/bin/env python
import gtk; print(gtk.settings_get_default().get_property('gtk-icon-sizes'))

But the output is very short:

'panel-menu=22,22;gtk-button=16,16'

Where can i find rest of the sizes, for example for GTK_ICON_SIZE_DIALOG or GTK_ICON_SIZE_LARGE_TOOLBAR?


GTK resizes the icons to whatever size they need to be. According to the Icon Theme Specification, you should make at least one 48x48 icon, and optionally a scalable SVG icon. That is enough to be able to display any of those sizes.

The Tango Icon Theme Guidelines recommend some supplementary sizes that you can make, in order to minimize how often the icon has to be resized internally by GTK.


Just add your images to the icon list with gtk_icon_theme_add_builtin_icon, and then use them as named icons.

An example in Vala:

Gdk.Pixbuf pixbuf;
pixbuf = new Gdk.Pixbuf.from_file_at_size(Path.build_filename(AutovalaPluginConstants.DATADIR,"valaplugin","application.svg"),-1,-1);
Gtk.IconTheme.add_builtin_icon("autovala-plugin-executable",-1,pixbuf);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜