Basics

Guides

API Reference

Menu

Basics

Guides

API Reference

class: ImageMeta

[560:14] static extends: object

Generated metadata helpers for Image class surfaces.

Methods

  • properties ()

    Returns property metadata for Image.

    • @r A list.

class: Image

[33:7] extends: object

Displays an image. An example GtkImage Various kinds of object can be displayed as an image; most typically, you would load a GdkTexture from a file, using the convenience function [ctor@Gtk.Image.new_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 an image loading framework such as libglycin, then create the GtkImage with [ctor@Gtk.Image.new_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, [property@Gtk.Image:resource], [ctor@Gtk.Image.new_from_resource], and [method@Gtk.Image.set_from_resource] should be used. GtkImage displays its image as an icon, with a size that is determined by the application. See [class@Gtk.Picture] 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 [property@Gtk.Image:icon-size] property. ## Accessibility GtkImage uses the [enum@Gtk.AccessibleRole.img] role.

Members

  • handleObj
  • lib
  • retainedCallbacks
  • signalHandlerNames
  • signalSetterHandlers

Methods

  • Image ()

    Creates a new empty GtkImage widget.

  • toNativeHandle (Source)

    Normalizes a constructor argument into a raw pointer carrier. Accepts a raw NativeHandle, a raw NativeBuffer returned from fn.call(...), another generated wrapper exposing handle(), or null. Returns null when the argument carries no pointer.

    • @p Source is the raw handle, raw buffer, wrapper, or null.
    • @r A raw pointer carrier or null when no pointer is present.
  • getLib ()

    Returns the opened native library for this generated wrapper.

    • @r The opened native library.
  • handle ()

    Returns the wrapped NativeHandle.

    • @r The wrapped NativeHandle.
  • isNull ()

    Returns true when the wrapped handle is null.

    • @r A bool.
  • describe ()

    Returns a small string for debugging generated wrappers.

    • @r A string.
  • asWidget ()

    Wraps this handle as Widget.

    • @r A Widget object.
  • asAccessible ()

    Wraps this handle as Accessible.

    • @r A Accessible object.
  • asBuildable ()

    Wraps this handle as Buildable.

    • @r A Buildable object.
  • asConstraintTarget ()

    Wraps this handle as ConstraintTarget.

    • @r A ConstraintTarget object.
  • getProperty (string Name)

    Reads one generated property by name.

  • setProperty (string Name, Value)

    Writes one generated property by name.

  • setFile (string Value)

    A path to the file to display.

    • @p Value is the new property value.
    • @r None.
  • setGicon (object Value)

    The GIcon displayed in the GtkImage. For themed icons, If the icon theme is changed, the image will be updated automatically.

    • @p Value is the new property value.
    • @r None.
  • setIconname (string Value)

    The name of the icon in the icon theme. If the icon theme is changed, the image will be updated automatically.

    • @p Value is the new property value.
    • @r None.
  • setIconsize (string Value)

    The symbolic size to display icons at.

    • @p Value is the new property value.
    • @r None.
  • setPaintable (object Value)

    The GdkPaintable to display.

    • @p Value is the new property value.
    • @r None.
  • setPixelsize (int Value)

    The size in pixels to display icons at. If set to a value != -1, this property overrides the [property@Gtk.Image:icon-size] property for images of type GTK_IMAGE_ICON_NAME.

    • @p Value is the new property value.
    • @r None.
  • setResource (string Value)

    A path to a resource file to display.

    • @p Value is the new property value.
    • @r None.
  • setUsefallback (bool Value)

    Whether the icon displayed in the GtkImage will use standard icon names fallback. The value of this property is only relevant for images of type %GTK_IMAGE_ICON_NAME and %GTK_IMAGE_GICON.

    • @p Value is the new property value.
    • @r None.
  • clear ()

    Resets the image to be empty.

    • @r None.
  • get_gicon ()

    Gets the GIcon being displayed by the GtkImage. The storage type of the image must be %GTK_IMAGE_EMPTY or %GTK_IMAGE_GICON (see [method@Gtk.Image.get_storage_type]). The caller of this function does not own a reference to the returned GIcon.

  • get_icon_name ()

    Gets the icon name and size being displayed by the GtkImage. The storage type of the image must be %GTK_IMAGE_EMPTY or %GTK_IMAGE_ICON_NAME (see [method@Gtk.Image.get_storage_type]). The returned string is owned by the GtkImage and should not be freed.

  • get_icon_size ()

    Gets the icon size used by the @image when rendering icons.

  • get_paintable ()

    Gets the image GdkPaintable being displayed by the GtkImage. The storage type of the image must be %GTK_IMAGE_EMPTY or %GTK_IMAGE_PAINTABLE (see [method@Gtk.Image.get_storage_type]). The caller of this function does not own a reference to the returned paintable.

  • get_pixel_size ()

    Gets the pixel size used for named icons.

  • get_storage_type ()

    Gets the type of representation being used by the GtkImage to store image data. If the GtkImage has no image data, the return value will be %GTK_IMAGE_EMPTY.

  • set_from_file (string filename)

    Sets a GtkImage to show a file. See [ctor@Gtk.Image.new_from_file] for details. ::: warning Note that this function should not be used with untrusted data. Use a proper image loading framework such as libglycin, which can load many image formats into a GdkTexture, and then use [method@Gtk.Image.set_from_paintable].

    • @p filename is a filename.
    • @r None.
  • set_from_gicon (object icon)

    Sets a GtkImage to show a GIcon. See [ctor@Gtk.Image.new_from_gicon] for details.

    • @p icon is an icon.
    • @r None.
  • set_from_icon_name (string icon_name)

    Sets a GtkImage to show a named icon. See [ctor@Gtk.Image.new_from_icon_name] for details.

    • @p icon_name is an icon name.
    • @r None.
  • set_from_paintable (object paintable)

    Sets a GtkImage to show a GdkPaintable. See [ctor@Gtk.Image.new_from_paintable] for details.

    • @p paintable is a GdkPaintable.
    • @r None.
  • set_from_pixbuf (object pixbuf)

    Sets a GtkImage to show a GdkPixbuf. See [ctor@Gtk.Image.new_from_pixbuf] for details. Note: This is a helper for [method@Gtk.Image.set_from_paintable], and you can't get back the exact pixbuf once this is called, only a paintable.

    • @p pixbuf is a GdkPixbuf or NULL.
    • @r None.
  • set_from_resource (string resource_path)

    Sets a GtkImage to show a resource. See [ctor@Gtk.Image.new_from_resource] for details.

    • @p resource_path is a resource path.
    • @r None.
  • set_icon_size (string icon_size)

    Suggests an icon size to the theme for named icons.

    • @p icon_size is the new icon size.
    • @r None.
  • set_pixel_size (int pixel_size)

    Sets the pixel size to use for named icons. If the pixel size is set to a value != -1, it is used instead of the icon size set by [method@Gtk.Image.set_icon_size].

    • @p pixel_size is the new pixel size.
    • @r None.

class: ImageCtors

[446:14] static extends: object

Alternate constructors for Image. Usage: ImageCtors.<name>(...). The primary constructor lives directly on Image.

Methods

  • newFromFile (string filename)

    Creates a new GtkImage displaying the file @filename. If the file isn’t found or can’t be loaded, the resulting GtkImage will display a “broken image” icon. This function never returns %NULL, it always returns a valid GtkImage widget. If you need to detect failures to load the file, use an image loading framework such as libglycin to load the file yourself, then create the GtkImage from the texture. The storage type (see [method@Gtk.Image.get_storage_type]) of the returned image is not defined, it will be whatever is appropriate for displaying the file.

    • @p filename is a filename.
    • @r A new Image.
  • newFromGicon (object icon)

    Creates a GtkImage displaying an icon from the current icon theme. If the icon name isn’t known, a “broken image” icon will be displayed instead. If the current icon theme is changed, the icon will be updated appropriately.

    • @p icon is an icon.
    • @r A new Image.
  • newFromIconName (string icon_name)

    Creates a GtkImage displaying an icon from the current icon theme. If the icon name isn’t known, a “broken image” icon will be displayed instead. If the current icon theme is changed, the icon will be updated appropriately.

    • @p icon_name is an icon name.
    • @r A new Image.
  • newFromPaintable (object paintable)

    Creates a new GtkImage displaying @paintable. The GtkImage does not assume a reference to the paintable; you still need to unref it if you own references. GtkImage will add its own reference rather than adopting yours. The GtkImage will track changes to the @paintable and update its size and contents in response to it. Note that paintables are still subject to the icon size that is set on the image. If you want to display a paintable at its intrinsic size, use [class@Gtk.Picture] instead. If @paintable is a [iface@Gtk.SymbolicPaintable], then it will be recolored with the symbolic palette from the theme.

    • @p paintable is a GdkPaintable.
    • @r A new Image.
  • newFromPixbuf (object pixbuf)

    Creates a new GtkImage displaying @pixbuf. The GtkImage does not assume a reference to the pixbuf; you still need to unref it if you own references. GtkImage will add its own reference rather than adopting yours. This is a helper for [ctor@Gtk.Image.new_from_paintable], and you can't get back the exact pixbuf once this is called, only a texture. Note that this function just creates an GtkImage from the pixbuf. The GtkImage created will not react to state changes. Should you want that, you should use [ctor@Gtk.Image.new_from_icon_name].

    • @p pixbuf is a GdkPixbuf.
    • @r A new Image.
  • newFromResource (string resource_path)

    Creates a new GtkImage displaying the resource file @resource_path. If the file isn’t found or can’t be loaded, the resulting GtkImage will display a “broken image” icon. This function never returns %NULL, it always returns a valid GtkImage widget. If you need to detect failures to load the file, use an image loading framework such as libglycin to load the file yourself, then create the GtkImage from the texture. The storage type (see [method@Gtk.Image.get_storage_type]) of the returned image is not defined, it will be whatever is appropriate for displaying the file.

    • @p resource_path is a resource path.
    • @r A new Image.