gtk.image

Module for [Image] class

Types 3

The [gtk.image.Image] widget displays an image.

!An example GtkImage

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 property@Gtk.Image:icon-size property.

Accessibility

[gtk.image.Image] uses the [gtk.types.AccessibleRole.Img] role.

Methods
GType _gType() @property
Image self()Returns `this`, for use in `with` statements.
ImageGidBuilder builder()Get builder for [gtk.image.Image] Returns: New builder object
string file() @propertyGet `file` property. Returns: A path to the file to display.
void file(string propval) @propertySet `file` property. Params: propval = A path to the file to display.
gio.icon.Icon gicon() @propertyGet `gicon` property. Returns: The [gio.icon.Icon] displayed in the GtkImage.
void gicon(gio.icon.Icon propval) @propertySet `gicon` property. Params: propval = The [gio.icon.Icon] displayed in the GtkImage.
string iconName() @propertyGet `iconName` property. Returns: The name of the icon in the icon theme.
void iconName(string propval) @propertySet `iconName` property. Params: propval = The name of the icon in the icon theme.
gtk.types.IconSize iconSize() @propertyGet `iconSize` property. Returns: The symbolic size to display icons at.
void iconSize(gtk.types.IconSize propval) @propertySet `iconSize` property. Params: propval = The symbolic size to display icons at.
gdk.paintable.Paintable paintable() @propertyGet `paintable` property. Returns: The [gdk.paintable.Paintable] to display.
void paintable(gdk.paintable.Paintable propval) @propertySet `paintable` property. Params: propval = The [gdk.paintable.Paintable] to display.
int pixelSize() @propertyGet `pixelSize` property. Returns: The size in pixels to display icons at.
void pixelSize(int propval) @propertySet `pixelSize` property. Params: propval = The size in pixels to display icons at.
string resource() @propertyGet `resource` property. Returns: A path to a resource file to display.
void resource(string propval) @propertySet `resource` property. Params: propval = A path to a resource file to display.
gtk.types.ImageType storageType() @propertyGet `storageType` property. Returns: The representation being used for image data.
bool useFallback() @propertyGet `useFallback` property. Returns: Whether the icon displayed in the [gtk.image.Image] will use standard icon names fallback.
void useFallback(bool propval) @propertySet `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)Creates a new [gtk.image.Image] displaying the file filename.
gtk.image.Image newFromGicon(gio.icon.Icon icon)Creates a [gtk.image.Image] displaying an icon from the current icon theme.
gtk.image.Image newFromIconName(string iconName = null)Creates a [gtk.image.Image] displaying an icon from the current icon theme.
gtk.image.Image newFromPaintable(gdk.paintable.Paintable paintable = null)Creates a new [gtk.image.Image] displaying paintable.
gtk.image.Image newFromPixbuf(gdkpixbuf.pixbuf.Pixbuf pixbuf = null)Creates a new [gtk.image.Image] displaying pixbuf.
gtk.image.Image newFromResource(string resourcePath)Creates a new [gtk.image.Image] displaying the resource file resource_path.
void clear()Resets the image to be empty.
gio.icon.Icon getGicon()Gets the [gio.icon.Icon] being displayed by the [gtk.image.Image].
string getIconName()Gets the icon name and size being displayed by the [gtk.image.Image].
gtk.types.IconSize getIconSize()Gets the icon size used by the image when rendering icons. Returns: the image size used by icons
gdk.paintable.Paintable getPaintable()Gets the image [gdk.paintable.Paintable] being displayed by the [gtk.image.Image].
int getPixelSize()Gets the pixel size used for named icons. Returns: the pixel size used for named icons.
gtk.types.ImageType getStorageType()Gets the type of representation being used by the [gtk.image.Image] to store image data.
void setFromFile(string filename = null)Sets a [gtk.image.Image] to show a file.
void setFromGicon(gio.icon.Icon icon)Sets a [gtk.image.Image] to show a [gio.icon.Icon].
void setFromIconName(string iconName = null)Sets a [gtk.image.Image] to show a named icon.
void setFromPaintable(gdk.paintable.Paintable paintable = null)Sets a [gtk.image.Image] to show a [gdk.paintable.Paintable].
void setFromPixbuf(gdkpixbuf.pixbuf.Pixbuf pixbuf = null)Sets a [gtk.image.Image] to show a [gdkpixbuf.pixbuf.Pixbuf].
void setFromResource(string resourcePath = null)Sets a [gtk.image.Image] to show a resource.
void setIconSize(gtk.types.IconSize iconSize)Suggests an icon size to the theme for named icons.
void setPixelSize(int pixelSize)Sets the pixel size to use for named icons.
Constructors
this(void * ptr, Flag!"Take" take)
this()Creates a new empty [gtk.image.Image] widget. Returns: a newly created [gtk.image.Image] widget.
Methods
T file(string propval)Set `file` property. Params: propval = A path to the file to display. Returns: Builder instance for fluent chaining
T gicon(gio.icon.Icon propval)Set `gicon` property. Params: propval = The [gio.icon.Icon] displayed in the GtkImage.
T iconName(string propval)Set `iconName` property. Params: propval = The name of the icon in the icon theme.
T iconSize(gtk.types.IconSize propval)Set `iconSize` property. Params: propval = The symbolic size to display icons at. Returns: Builder instance for fluent chaining
T paintable(gdk.paintable.Paintable propval)Set `paintable` property. Params: propval = The [gdk.paintable.Paintable] to display. Returns: Builder instance for fluent chaining
T pixelSize(int propval)Set `pixelSize` property. Params: propval = The size in pixels to display icons at.
T resource(string propval)Set `resource` property. Params: propval = A path to a resource file to display. Returns: Builder instance for fluent chaining
T useFallback(bool propval)Set `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]

Methods