ImageProtocol
public protocol ImageProtocol : WidgetProtocol
The GtkImage
widget displays an image.
Various kinds of object can be displayed as an image; most typically,
you would load a GdkTexture
from a file, using the convenience function
[ctorGtk.Image.new_from_file
], 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
[ctorGdk.Texture.new_from_file
], then create the GtkImage
with
[ctorGtk.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, [propertyGtk.Image:resource
],
[ctorGtk.Image.new_from_resource
], and [methodGtk.Image.set_from_resource
]
should be used.
GtkImage
displays its image as an icon, with a size that is determined
by the application. See [classGtk.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
[propertyGtk.Image:icon-size
] property.
Accessibility
GtkImage
uses the GTK_ACCESSIBLE_ROLE_IMG
role.
The ImageProtocol
protocol exposes the methods and properties of an underlying GtkImage
instance.
The default implementation of these can be found in the protocol extension below.
For a concrete class that implements these methods and properties, see Image
.
Alternatively, use ImageRef
as a lighweight, unowned
reference if you already have an instance you just want to use.
-
Untyped pointer to the underlying
GtkImage
instance.Declaration
Swift
var ptr: UnsafeMutableRawPointer! { get }
-
image_ptr
Default implementationTyped pointer to the underlying
GtkImage
instance.Default Implementation
Return the stored, untyped pointer as a typed pointer to the
GtkImage
instance.Declaration
Swift
var image_ptr: UnsafeMutablePointer<GtkImage>! { get }
-
Required Initialiser for types conforming to
ImageProtocol
Declaration
Swift
init(raw: UnsafeMutableRawPointer)
-
bind(property:
Extension methodto: _: flags: transformFrom: transformTo: ) Bind a
ImagePropertyName
source property to a given target object.Declaration
Swift
@discardableResult @inlinable func bind<Q, T>(property source_property: ImagePropertyName, to target: T, _ target_property: Q, flags f: BindingFlags = .default, transformFrom transform_from: @escaping GLibObject.ValueTransformer = { $0.transform(destValue: $1) }, transformTo transform_to: @escaping GLibObject.ValueTransformer = { $0.transform(destValue: $1) }) -> BindingRef! where Q : PropertyNameProtocol, T : ObjectProtocol
Parameters
source_property
the source property to bind
target
the target object to bind to
target_property
the target property to bind to
flags
the flags to pass to the
Binding
transform_from
ValueTransformer
to use for forward transformationtransform_to
ValueTransformer
to use for backwards transformationReturn Value
binding reference or
nil
in case of an error -
get(property:
Extension method) Get the value of a Image property
Declaration
Swift
@inlinable func get(property: ImagePropertyName) -> GLibObject.Value
Parameters
property
the property to get the value for
Return Value
the value of the named property
-
set(property:
Extension methodvalue: ) Set the value of a Image property. Note that this will only have an effect on properties that are writable and not construct-only!
Declaration
Swift
@inlinable func set(property: ImagePropertyName, value v: GLibObject.Value)
Parameters
property
the property to get the value for
Return Value
the value of the named property
-
clear()
Extension methodResets the image to be empty.
Declaration
Swift
@inlinable func clear()
-
getGicon()
Extension methodGets the
GIcon
being displayed by theGtkImage
.The storage type of the image must be
GTK_IMAGE_EMPTY
orGTK_IMAGE_GICON
(see [methodGtk.Image.get_storage_type
]). The caller of this function does not own a reference to the returnedGIcon
.Declaration
Swift
@inlinable func getGicon() -> GIO.IconRef!
-
getIconName()
Extension methodGets the icon name and size being displayed by the
GtkImage
.The storage type of the image must be
GTK_IMAGE_EMPTY
orGTK_IMAGE_ICON_NAME
(see [methodGtk.Image.get_storage_type
]). The returned string is owned by theGtkImage
and should not be freed.Declaration
Swift
@inlinable func getIconName() -> String!
-
getIconSize()
Extension methodGets the icon size used by the
image
when rendering icons.Declaration
Swift
@inlinable func getIconSize() -> GtkIconSize
-
getPaintable()
Extension methodGets the image
GdkPaintable
being displayed by theGtkImage
.The storage type of the image must be
GTK_IMAGE_EMPTY
orGTK_IMAGE_PAINTABLE
(see [methodGtk.Image.get_storage_type
]). The caller of this function does not own a reference to the returned paintable.Declaration
Swift
@inlinable func getPaintable() -> Gdk.PaintableRef!
-
getPixelSize()
Extension methodGets the pixel size used for named icons.
Declaration
Swift
@inlinable func getPixelSize() -> Int
-
getStorageType()
Extension methodGets the type of representation being used by the
GtkImage
to store image data.If the
GtkImage
has no image data, the return value will beGTK_IMAGE_EMPTY
.Declaration
Swift
@inlinable func getStorageType() -> GtkImageType
-
setFromFile(filename:
Extension method) Sets a
GtkImage
to show a file.See [ctor
Gtk.Image.new_from_file
] for details.Declaration
Swift
@inlinable func setFromFile(filename: UnsafePointer<CChar>? = nil)
-
setFromGicon(icon:
Extension method) Sets a
GtkImage
to show aGIcon
.See [ctor
Gtk.Image.new_from_gicon
] for details.Declaration
Swift
@inlinable func setFromGicon<IconT>(icon: IconT) where IconT : IconProtocol
-
setFrom(iconName:
Extension method) Sets a
GtkImage
to show a named icon.See [ctor
Gtk.Image.new_from_icon_name
] for details.Declaration
Swift
@inlinable func setFrom(iconName: UnsafePointer<CChar>? = nil)
-
setFrom(paintable:
Extension method) Sets a
GtkImage
to show aGdkPaintable
.See [ctor
Gtk.Image.new_from_paintable
] for details.Declaration
Swift
@inlinable func setFrom(paintable: Gdk.PaintableRef? = nil)
-
setFrom(paintable:
Extension method) Sets a
GtkImage
to show aGdkPaintable
.See [ctor
Gtk.Image.new_from_paintable
] for details.Declaration
Swift
@inlinable func setFrom<PaintableT>(paintable: PaintableT?) where PaintableT : PaintableProtocol
-
setFrom(pixbuf:
Extension method) Sets a
GtkImage
to show aGdkPixbuf
.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.Declaration
Swift
@inlinable func setFrom(pixbuf: PixbufRef? = nil)
-
setFrom(pixbuf:
Extension method) Sets a
GtkImage
to show aGdkPixbuf
.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.Declaration
Swift
@inlinable func setFrom<PixbufT>(pixbuf: PixbufT?) where PixbufT : PixbufProtocol
-
setFromResource(resourcePath:
Extension method) Sets a
GtkImage
to show a resource.See [ctor
Gtk.Image.new_from_resource
] for details.Declaration
Swift
@inlinable func setFromResource(resourcePath: UnsafePointer<CChar>? = nil)
-
set(iconSize:
Extension method) Suggests an icon size to the theme for named icons.
Declaration
Swift
@inlinable func set(iconSize: GtkIconSize)
-
set(pixelSize:
Extension method) 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_from_icon_name
].Declaration
Swift
@inlinable func set(pixelSize: Int)
-
gicon
Extension methodThe
GIcon
displayed in the GtkImage.For themed icons, If the icon theme is changed, the image will be updated automatically.
Declaration
Swift
@inlinable var gicon: GIO.IconRef! { get }
-
iconName
Extension methodGets the icon name and size being displayed by the
GtkImage
.The storage type of the image must be
GTK_IMAGE_EMPTY
orGTK_IMAGE_ICON_NAME
(see [methodGtk.Image.get_storage_type
]). The returned string is owned by theGtkImage
and should not be freed.Declaration
Swift
@inlinable var iconName: String! { get }
-
iconSize
Extension methodGets the icon size used by the
image
when rendering icons.Declaration
Swift
@inlinable var iconSize: GtkIconSize { get nonmutating set }
-
paintable
Extension methodThe
GdkPaintable
to display.Declaration
Swift
@inlinable var paintable: Gdk.PaintableRef! { get }
-
pixelSize
Extension methodGets the pixel size used for named icons.
Declaration
Swift
@inlinable var pixelSize: Int { get nonmutating set }
-
storageType
Extension methodGets the type of representation being used by the
GtkImage
to store image data.If the
GtkImage
has no image data, the return value will beGTK_IMAGE_EMPTY
.Declaration
Swift
@inlinable var storageType: GtkImageType { get }