gtk.image
Module for [Image] class
Types 3
The gtk.image.Image widget displays an image.
Various kinds of object can be displayed as an image; most typically, you would load a gdk.texture.Texture from a file, using the convenience function gtk.image.Image.newFromFile, for instance:
GtkWidget *image = gtk_image_new_from_file ("myfile.png");If the file isn’t loaded successfully, the image will contain a “broken image” icon similar to that used in many web browsers.
If you want to handle errors in loading the file yourself, for example by displaying an error message, then load the image with gdk.texture.Texture.newFromFile, then create the gtk.image.Image with gtk.image.Image.newFromPaintable.
Sometimes an application will want to avoid depending on external data files, such as image files. See the documentation of gio.resource.Resource inside GIO, for details. In this case, gtk.image.Image.resource, gtk.image.Image.newFromResource, and gtk.image.Image.setFromResource should be used.
gtk.image.Image displays its image as an icon, with a size that is determined by the application. See gtk.picture.Picture if you want to show an image at is actual size.
CSS nodes
gtk.image.Image has a single CSS node with the name image. The style classes .normal-icons or .large-icons may appear, depending on the gtk.image.Image.iconSize property.
Accessibility
gtk.image.Image uses the gtk.types.AccessibleRole.Img role.
ImageGidBuilder builder() static nothrowGet builder for [gtk.image.Image] Returns: New builder objectvoid file(string propval) @property nothrowSet `file` property. Params: propval = A path to the file to display.gio.icon.Icon gicon() @property nothrowGet `gicon` property. Returns: The [gio.icon.Icon] displayed in the GtkImage.void gicon(gio.icon.Icon propval) @property nothrowSet `gicon` property. Params: propval = The [gio.icon.Icon] displayed in the GtkImage.string iconName() @property nothrowGet `iconName` property. Returns: The name of the icon in the icon theme.void iconName(string propval) @property nothrowSet `iconName` property. Params: propval = The name of the icon in the icon theme.gtk.types.IconSize iconSize() @property nothrowGet `iconSize` property. Returns: The symbolic size to display icons at.void iconSize(gtk.types.IconSize propval) @property nothrowSet `iconSize` property. Params: propval = The symbolic size to display icons at.gdk.paintable.Paintable paintable() @property nothrowGet `paintable` property. Returns: The [gdk.paintable.Paintable] to display.void paintable(gdk.paintable.Paintable propval) @property nothrowSet `paintable` property. Params: propval = The [gdk.paintable.Paintable] to display.int pixelSize() @property nothrowGet `pixelSize` property. Returns: The size in pixels to display icons at.void pixelSize(int propval) @property nothrowSet `pixelSize` property. Params: propval = The size in pixels to display icons at.string resource() @property nothrowGet `resource` property. Returns: A path to a resource file to display.void resource(string propval) @property nothrowSet `resource` property. Params: propval = A path to a resource file to display.gtk.types.ImageType storageType() @property nothrowGet `storageType` property. Returns: The representation being used for image data.bool useFallback() @property nothrowGet `useFallback` property. Returns: Whether the icon displayed in the [gtk.image.Image] will use standard icon names fallback.void useFallback(bool propval) @property nothrowSet `useFallback` property. Params: propval = Whether the icon displayed in the [gtk.image.Image] will use standard icon names fallback.gtk.image.Image newFromFile(string filename) static nothrowCreates a new [gtk.image.Image] displaying the file filename.gtk.image.Image newFromGicon(gio.icon.Icon icon) static nothrowCreates a [gtk.image.Image] displaying an icon from the current icon theme.gtk.image.Image newFromIconName(string iconName = null) static nothrowCreates a [gtk.image.Image] displaying an icon from the current icon theme.gtk.image.Image newFromPaintable(gdk.paintable.Paintable paintable = null) static nothrowCreates a new [gtk.image.Image] displaying paintable.gtk.image.Image newFromPixbuf(gdkpixbuf.pixbuf.Pixbuf pixbuf = null) static nothrowCreates a new [gtk.image.Image] displaying pixbuf.gtk.image.Image newFromResource(string resourcePath) static nothrowCreates a new [gtk.image.Image] displaying the resource file resource_path.gtk.types.IconSize getIconSize() nothrowGets the icon size used by the image when rendering icons. Returns: the image size used by iconsgdk.paintable.Paintable getPaintable() nothrowGets the image [gdk.paintable.Paintable] being displayed by the [gtk.image.Image].int getPixelSize() nothrowGets the pixel size used for named icons. Returns: the pixel size used for named icons.gtk.types.ImageType getStorageType() nothrowGets the type of representation being used by the [gtk.image.Image] to store image data.void setFromPaintable(gdk.paintable.Paintable paintable = null) nothrowSets a [gtk.image.Image] to show a [gdk.paintable.Paintable].void setFromPixbuf(gdkpixbuf.pixbuf.Pixbuf pixbuf = null) nothrowSets a [gtk.image.Image] to show a [gdkpixbuf.pixbuf.Pixbuf].void setFromResource(string resourcePath = null) nothrowSets a [gtk.image.Image] to show a resource.void setIconSize(gtk.types.IconSize iconSize) nothrowSuggests an icon size to the theme for named icons.Fluent builder implementation template for gtk.image.Image
T file(string propval) nothrowSet `file` property. Params: propval = A path to the file to display. Returns: Builder instance for fluent chainingT gicon(gio.icon.Icon propval) nothrowSet `gicon` property. Params: propval = The [gio.icon.Icon] displayed in the GtkImage.T iconName(string propval) nothrowSet `iconName` property. Params: propval = The name of the icon in the icon theme.T iconSize(gtk.types.IconSize propval) nothrowSet `iconSize` property. Params: propval = The symbolic size to display icons at. Returns: Builder instance for fluent chainingT paintable(gdk.paintable.Paintable propval) nothrowSet `paintable` property. Params: propval = The [gdk.paintable.Paintable] to display. Returns: Builder instance for fluent chainingT pixelSize(int propval) nothrowSet `pixelSize` property. Params: propval = The size in pixels to display icons at.T resource(string propval) nothrowSet `resource` property. Params: propval = A path to a resource file to display. Returns: Builder instance for fluent chainingT useFallback(bool propval) nothrowSet `useFallback` property. Params: propval = Whether the icon displayed in the [gtk.image.Image] will use standard icon names fallback.Fluent builder for gtk.image.Image