Image


Object Hierarchy:

Gtk.Image Gtk.Image Gtk.Image Gtk.Widget Gtk.Widget Gtk.Widget->Gtk.Image GLib.InitiallyUnowned GLib.InitiallyUnowned GLib.InitiallyUnowned->Gtk.Widget GLib.Object GLib.Object GLib.Object->GLib.InitiallyUnowned Gtk.Accessible Gtk.Accessible Gtk.Accessible->Gtk.Image Gtk.Accessible->Gtk.Widget Gtk.Buildable Gtk.Buildable Gtk.Buildable->Gtk.Image Gtk.Buildable->Gtk.Widget Gtk.ConstraintTarget Gtk.ConstraintTarget Gtk.ConstraintTarget->Gtk.Image Gtk.ConstraintTarget->Gtk.Widget

Description:

[ CCode ( type_id = "gtk_image_get_type ()" ) ]
public class Image : Widget, Accessible, Buildable, ConstraintTarget

The `GtkImage` widget displays an image.

![An example GtkImage](image.png)

Various kinds of object can be displayed as an image; most typically, you would load a `GdkTexture` from a file, using the convenience function [[email protected]_from_file], for instance:

```c 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 [ [email protected]_from_file], then create the `GtkImage` with [[email protected]_from_paintable].

Sometimes an application will want to avoid depending on external data files, such as image files. See the documentation of `GResource` inside GIO, for details. In this case, [[email protected]:resource], [[email protected]_from_resource], and [ [email protected]_from_resource] should be used.

`GtkImage` displays its image as an icon, with a size that is determined by the application. See [[email protected]] if you want to show an image at is actual size.

CSS nodes

`GtkImage` has a single CSS node with the name `image`. The style classes `.normal-icons` or `.large-icons` may appear, depending on the [[email protected]:icon-size] property.

Accessibility

`GtkImage` uses the `GTK_ACCESSIBLE_ROLE_IMG` role.


Namespace: Gtk
Package: gtk4

Content:

Properties:

Creation methods:

Methods:

Inherited Members:

All known members inherited from class Gtk.Widget
All known members inherited from class GLib.Object



2022 vala-language.org