Package ch.bailu.gtk.gtk
Class Image
- All Implemented Interfaces:
PointerInterface
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
[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
[ctor@Gdk.Texture.new_from_file], 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 `GTK_ACCESSIBLE_ROLE_IMG` role.
![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
[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
[ctor@Gdk.Texture.new_from_file], 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 `GTK_ACCESSIBLE_ROLE_IMG` role.
-
Nested Class Summary
Nested classes/interfaces inherited from class ch.bailu.gtk.gtk.Widget
Widget.OnDestroy, Widget.OnDestroyNotify, Widget.OnDirectionChanged, Widget.OnHide, Widget.OnKeynavFailed, Widget.OnMap, Widget.OnMnemonicActivate, Widget.OnMoveFocus, Widget.OnQueryTooltip, Widget.OnRealize, Widget.OnShow, Widget.OnStateFlagsChanged, Widget.OnTickCallback, Widget.OnUnmap, Widget.OnUnrealize
Nested classes/interfaces inherited from class ch.bailu.gtk.gobject.Object
Object.OnBindingTransformFunc, Object.OnDuplicateFunc, Object.OnNotify, Object.OnToggleNotify, Object.OnWeakNotify
-
Field Summary
Fields inherited from class ch.bailu.gtk.gtk.Widget
SIGNAL_ON_DESTROY, SIGNAL_ON_DIRECTION_CHANGED, SIGNAL_ON_HIDE, SIGNAL_ON_KEYNAV_FAILED, SIGNAL_ON_MAP, SIGNAL_ON_MNEMONIC_ACTIVATE, SIGNAL_ON_MOVE_FOCUS, SIGNAL_ON_QUERY_TOOLTIP, SIGNAL_ON_REALIZE, SIGNAL_ON_SHOW, SIGNAL_ON_STATE_FLAGS_CHANGED, SIGNAL_ON_UNMAP, SIGNAL_ON_UNREALIZE
Fields inherited from class ch.bailu.gtk.gobject.Object
SIGNAL_ON_NOTIFY
-
Constructor Summary
ConstructorDescriptionImage()
Creates a new empty `GtkImage` widget.Image
(PointerContainer pointer) -
Method Summary
Modifier and TypeMethodDescriptionImplements interfaceAccessible
.Implements interfaceBuildable
.Implements interfaceConstraintTarget
.void
clear()
Resets the image to be empty.static ClassHandler
getGicon()
Gets the `GIcon` being displayed by the `GtkImage`.Gets the icon name and size being displayed by the `GtkImage`.int
Gets the icon size used by the @image when rendering icons.static int
Gets the image `GdkPaintable` being displayed by the `GtkImage`.static long
static TypeSystem.TypeSize
int
Gets the pixel size used for named icons.int
Gets the type of representation being used by the `GtkImage`
to store image data.static long
static TypeSystem.TypeSize
static Image
newFromFileImage
(Str filename) Creates a new `GtkImage` displaying the file @filename.static Image
newFromFileImage
(String filename) Creates a new `GtkImage` displaying the file @filename.static Image
newFromGiconImage
(Icon icon) Creates a `GtkImage` displaying an icon from the current icon theme.static Image
newFromIconNameImage
(Str icon_name) Creates a `GtkImage` displaying an icon from the current icon theme.static Image
newFromIconNameImage
(String icon_name) Creates a `GtkImage` displaying an icon from the current icon theme.static Image
newFromPaintableImage
(Paintable paintable) Creates a new `GtkImage` displaying @paintable.static Image
newFromPixbufImage
(Pixbuf pixbuf) Creates a new `GtkImage` displaying @pixbuf.static Image
newFromResourceImage
(Str resource_path) Creates a new `GtkImage` displaying the resource file @resource_path.static Image
newFromResourceImage
(String resource_path) Creates a new `GtkImage` displaying the resource file @resource_path.void
setFromFile
(Str filename) Sets a `GtkImage` to show a file.void
setFromFile
(String filename) Sets a `GtkImage` to show a file.void
setFromGicon
(Icon icon) Sets a `GtkImage` to show a `GIcon`.void
setFromIconName
(Str icon_name) Sets a `GtkImage` to show a named icon.void
setFromIconName
(String icon_name) Sets a `GtkImage` to show a named icon.void
setFromPaintable
(Paintable paintable) Sets a `GtkImage` to show a `GdkPaintable`.void
setFromPixbuf
(Pixbuf pixbuf) Sets a `GtkImage` to show a `GdkPixbuf`.void
setFromResource
(Str resource_path) Sets a `GtkImage` to show a resource.void
setFromResource
(String resource_path) Sets a `GtkImage` to show a resource.void
setIconSize
(int icon_size) Suggests an icon size to the theme for named icons.void
setPixelSize
(int pixel_size) Sets the pixel size to use for named icons.Methods inherited from class ch.bailu.gtk.gtk.Widget
actionSetEnabled, actionSetEnabled, activate, activateAction, activateAction, activateActionVariant, activateActionVariant, activateDefault, addController, addCssClass, addCssClass, addMnemonicLabel, addTickCallback, allocate, childFocus, computeBounds, computeExpand, computePoint, computeTransform, contains, createPangoContext, createPangoLayout, createPangoLayout, disposeTemplate, dragCheckThreshold, errorBell, getAllocatedBaseline, getAllocatedHeight, getAllocatedWidth, getAllocation, getAncestor, getCanFocus, getCanTarget, getChildVisible, getClipboard, getCssClasses, getCssName, getCursor, getDefaultDirection, getDirection, getDisplay, getFirstChild, getFocusable, getFocusChild, getFocusOnClick, getFontMap, getFontOptions, getFrameClock, getHalign, getHasTooltip, getHeight, getHexpand, getHexpandSet, getLastChild, getLayoutManager, getMapped, getMarginBottom, getMarginEnd, getMarginStart, getMarginTop, getName, getNative, getNextSibling, getOpacity, getOverflow, getPangoContext, getParent, getPreferredSize, getPrevSibling, getPrimaryClipboard, getRealized, getReceivesDefault, getRequestMode, getRoot, getScaleFactor, getSensitive, getSettings, getSize, getSizeRequest, getStateFlags, getStyleContext, getTemplateChild, getTemplateChild, getTooltipMarkup, getTooltipText, getValign, getVexpand, getVexpandSet, getVisible, getWidth, grabFocus, hasCssClass, hasCssClass, hasDefault, hasFocus, hasVisibleFocus, hide, inDestruction, initTemplate, insertActionGroup, insertActionGroup, insertAfter, insertBefore, isAncestor, isDrawable, isFocus, isSensitive, isVisible, keynavFailed, listMnemonicLabels, map, measure, mnemonicActivate, observeChildren, observeControllers, onDestroy, onDirectionChanged, onHide, onKeynavFailed, onMap, onMnemonicActivate, onMoveFocus, onQueryTooltip, onRealize, onShow, onStateFlagsChanged, onUnmap, onUnrealize, pick, queueAllocate, queueDraw, queueResize, realize, removeController, removeCssClass, removeCssClass, removeMnemonicLabel, removeTickCallback, setCanFocus, setCanTarget, setChildVisible, setCssClasses, setCursor, setCursorFromName, setCursorFromName, setDefaultDirection, setDirection, setFocusable, setFocusChild, setFocusOnClick, setFontMap, setFontOptions, setHalign, setHasTooltip, setHexpand, setHexpandSet, setLayoutManager, setMarginBottom, setMarginEnd, setMarginStart, setMarginTop, setName, setName, setOpacity, setOverflow, setParent, setReceivesDefault, setSensitive, setSizeRequest, setStateFlags, setTooltipMarkup, setTooltipMarkup, setTooltipText, setTooltipText, setValign, setVexpand, setVexpandSet, setVisible, shouldLayout, show, sizeAllocate, snapshotChild, triggerTooltipQuery, unmap, unparent, unrealize, unsetStateFlags
Methods inherited from class ch.bailu.gtk.gobject.Object
addToggleRef, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, compatControl, connect, connect, disconnect, disconnect, dupData, dupData, dupQdata, forceFloating, freezeNotify, get, get, getData, getData, getProperty, getProperty, getQdata, interfaceFindProperty, interfaceInstallProperty, isFloating, notify, notify, notifyByPspec, onNotify, ref, refSink, removeToggleRef, replaceData, replaceData, replaceQdata, runDispose, set, set, setData, setData, setDataFull, setDataFull, setProperty, setProperty, setQdata, setQdataFull, stealData, stealData, stealQdata, takeRef, thawNotify, unref, watchClosure, weakRef, weakUnref
Methods inherited from class ch.bailu.gtk.type.Pointer
asCPointer, cast, connectSignal, disconnectSignals, disconnectSignals, equals, hashCode, throwIfNull, throwNullPointerException, toString, unregisterCallbacks, unregisterCallbacks
Methods inherited from class ch.bailu.gtk.type.Type
asCPointer, asCPointer, asCPointerNotNull, asJnaPointer, asJnaPointer, asPointer, asPointer, cast, cast, throwIfNull
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface ch.bailu.gtk.type.PointerInterface
asCPointerNotNull, asJnaPointer, asPointer, isNotNull, isNull
-
Constructor Details
-
Image
-
Image
public Image()Creates a new empty `GtkImage` widget.
-
-
Method Details
-
getClassHandler
-
newFromFileImage
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
[ctor@Gdk.Texture.new_from_file] 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.- Parameters:
filename
- a filename- Returns:
- a new `GtkImage`
-
newFromFileImage
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
[ctor@Gdk.Texture.new_from_file] 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.- Parameters:
filename
- a filename- Returns:
- a new `GtkImage`
-
newFromGiconImage
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.- Parameters:
icon
- an icon- Returns:
- a new `GtkImage` displaying the themed icon
-
newFromIconNameImage
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.- Parameters:
icon_name
- an icon name- Returns:
- a new `GtkImage` displaying the themed icon
-
newFromIconNameImage
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.- Parameters:
icon_name
- an icon name- Returns:
- a new `GtkImage` displaying the themed icon
-
newFromPaintableImage
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.- Parameters:
paintable
- a `GdkPaintable`- Returns:
- a new `GtkImage`
-
newFromPixbufImage
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].- Parameters:
pixbuf
- a `GdkPixbuf`- Returns:
- a new `GtkImage`
-
newFromResourceImage
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
[ctor@GdkPixbuf.Pixbuf.new_from_file] to load the file yourself,
then create the `GtkImage` from the pixbuf.
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.- Parameters:
resource_path
- a resource path- Returns:
- a new `GtkImage`
-
newFromResourceImage
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
[ctor@GdkPixbuf.Pixbuf.new_from_file] to load the file yourself,
then create the `GtkImage` from the pixbuf.
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.- Parameters:
resource_path
- a resource path- Returns:
- a new `GtkImage`
-
clear
public void clear()Resets the image to be empty. -
getGicon
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`.- Returns:
- a `GIcon`
-
getIconName
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.- Returns:
- the icon name
-
getIconSize
public int getIconSize()Gets the icon size used by the @image when rendering icons.- Returns:
- the image size used by icons
-
getPaintable
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.- Returns:
- the displayed paintable
-
getPixelSize
public int getPixelSize()Gets the pixel size used for named icons.- Returns:
- the pixel size used for named icons.
-
getStorageType
public int getStorageType()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.- Returns:
- image representation being used
-
setFromFile
Sets a `GtkImage` to show a file.
See [ctor@Gtk.Image.new_from_file] for details.- Parameters:
filename
- a filename
-
setFromFile
Sets a `GtkImage` to show a file.
See [ctor@Gtk.Image.new_from_file] for details.- Parameters:
filename
- a filename
-
setFromGicon
Sets a `GtkImage` to show a `GIcon`.
See [ctor@Gtk.Image.new_from_gicon] for details.- Parameters:
icon
- an icon
-
setFromIconName
Sets a `GtkImage` to show a named icon.
See [ctor@Gtk.Image.new_from_icon_name] for details.- Parameters:
icon_name
- an icon name
-
setFromIconName
Sets a `GtkImage` to show a named icon.
See [ctor@Gtk.Image.new_from_icon_name] for details.- Parameters:
icon_name
- an icon name
-
setFromPaintable
Sets a `GtkImage` to show a `GdkPaintable`.
See [ctor@Gtk.Image.new_from_paintable] for details.- Parameters:
paintable
- a `GdkPaintable`
-
setFromPixbuf
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.- Parameters:
pixbuf
- a `GdkPixbuf` or `NULL`
-
setFromResource
Sets a `GtkImage` to show a resource.
See [ctor@Gtk.Image.new_from_resource] for details.- Parameters:
resource_path
- a resource path
-
setFromResource
Sets a `GtkImage` to show a resource.
See [ctor@Gtk.Image.new_from_resource] for details.- Parameters:
resource_path
- a resource path
-
setIconSize
public void setIconSize(int icon_size) Suggests an icon size to the theme for named icons.- Parameters:
icon_size
- the new icon size
-
setPixelSize
public void setPixelSize(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_from_icon_name].- Parameters:
pixel_size
- the new pixel size
-
asAccessible
Implements interfaceAccessible
. Call this to get access to interface functions.- Overrides:
asAccessible
in classWidget
- Returns:
Accessible
-
asBuildable
Implements interfaceBuildable
. Call this to get access to interface functions.- Overrides:
asBuildable
in classWidget
- Returns:
Buildable
-
asConstraintTarget
Implements interfaceConstraintTarget
. Call this to get access to interface functions.- Overrides:
asConstraintTarget
in classWidget
- Returns:
ConstraintTarget
-
getTypeID
public static long getTypeID() -
getParentTypeID
public static long getParentTypeID() -
getTypeSize
-
getParentTypeSize
-
getInstanceSize
public static int getInstanceSize()
-