gi-gtk4-4.0.12: Gtk 4.x bindings
CopyrightWill Thompson and Iñaki García Etxebarria
LicenseLGPL-2.1
MaintainerIñaki García Etxebarria
Safe HaskellNone
LanguageHaskell2010

GI.Gtk.Objects.SvgWidget

Description

A widget that renders SVG, with animations and event handling.

GtkSvgWidget uses Svg internally, and should read its documentation to learn about the supported SVG features and extensions.

On top of the GtkSvg rendering, GtkSvgWidget adds event handling. <kbd>Tab</kbd> and <kbd>Shift</kbd>+<kbd>Tab</kbd> keys can be used to move the focus and <kbd>Enter</kbd> and clicks will activate links by emitting the SvgWidget::activate signal.

The tabindex and autofocus attributes can be used to influence what elements act as focus locations, and where focus goes initially.

The styling of the SVG content is following input-related pseudo classes such as :focus, :active, :hover or :visited.

If Widget:hasTooltip is set, then the content of <title> elements will be shown as tooltips.

SVG animations and different <view>s can be triggered by input events as well. The following events are supported: focus, blur, mouseenter, mouseleave, click. See the SVG animation specification for details.

Since: 4.24

Synopsis

Exported types

class (GObject o, IsDescendantOf SvgWidget o) => IsSvgWidget o Source #

Type class for types which can be safely cast to SvgWidget, for instance with toSvgWidget.

Instances

Instances details
(GObject o, IsDescendantOf SvgWidget o) => IsSvgWidget o Source # 
Instance details

Defined in GI.Gtk.Objects.SvgWidget

toSvgWidget :: (MonadIO m, IsSvgWidget o) => o -> m SvgWidget Source #

Cast to SvgWidget, for types for which this is known to be safe. For general casts, use castTo.

Methods

Click to display all available methods, including inherited ones

Expand

Methods

actionSetEnabled, activate, activateAction, activateDefault, addController, addCssClass, addMnemonicLabel, addTickCallback, allocate, announce, bindProperty, bindPropertyFull, childFocus, computeBounds, computeExpand, computePoint, computeTransform, contains, createPangoContext, createPangoLayout, disposeTemplate, dragCheckThreshold, errorBell, forceFloating, freezeNotify, getv, grabFocus, hasCssClass, hasDefault, hasFocus, hasVisibleFocus, hide, inDestruction, initTemplate, insertActionGroup, insertAfter, insertBefore, isAncestor, isDrawable, isFloating, isFocus, isSensitive, isVisible, keynavFailed, listMnemonicLabels, loadFromBytes, map, measure, mnemonicActivate, notify, notifyByPspec, observeChildren, observeControllers, pick, queueAllocate, queueDraw, queueResize, realize, ref, refSink, removeController, removeCssClass, removeMnemonicLabel, removeTickCallback, resetProperty, resetRelation, resetState, runDispose, shouldLayout, show, sizeAllocate, snapshotChild, stealData, stealQdata, thawNotify, translateCoordinates, triggerTooltipQuery, unmap, unparent, unrealize, unref, unsetStateFlags, updateNextAccessibleSibling, updatePlatformState, updateProperty, updateRelation, updateState, watchClosure.

Getters

getAccessibleId, getAccessibleParent, getAccessibleRole, getAllocatedBaseline, getAllocatedHeight, getAllocatedWidth, getAllocation, getAncestor, getAtContext, getBaseline, getBounds, getBuildableId, getCanFocus, getCanTarget, getChildVisible, getClipboard, getColor, getCssClasses, getCssName, getCursor, getData, getDirection, getDisplay, getFirstAccessibleChild, getFirstChild, getFocusChild, getFocusOnClick, getFocusable, getFontMap, getFontOptions, getFrameClock, getHalign, getHasTooltip, getHeight, getHexpand, getHexpandSet, getLastChild, getLayoutManager, getLimitEvents, getMapped, getMarginBottom, getMarginEnd, getMarginStart, getMarginTop, getName, getNative, getNextAccessibleSibling, getNextSibling, getOpacity, getOverflow, getPangoContext, getParent, getPlatformState, getPreferredSize, getPrevSibling, getPrimaryClipboard, getProperty, getQdata, getRealized, getReceivesDefault, getRequestMode, getRoot, getScaleFactor, getSensitive, getSettings, getSize, getSizeRequest, getState, getStateFlags, getStyleContext, getStylesheet, getTemplateChild, getTooltipMarkup, getTooltipText, getValign, getVexpand, getVexpandSet, getVisible, getWidth.

Setters

setAccessibleParent, setCanFocus, setCanTarget, setChildVisible, setCssClasses, setCursor, setCursorFromName, setData, setDataFull, setDirection, setFocusChild, setFocusOnClick, setFocusable, setFontMap, setFontOptions, setHalign, setHasTooltip, setHexpand, setHexpandSet, setLayoutManager, setLimitEvents, setMarginBottom, setMarginEnd, setMarginStart, setMarginTop, setName, setOpacity, setOverflow, setParent, setProperty, setReceivesDefault, setSensitive, setSizeRequest, setState, setStateFlags, setStylesheet, setTooltipMarkup, setTooltipText, setValign, setVexpand, setVexpandSet, setVisible.

getState

svgWidgetGetState Source #

Arguments

:: (HasCallStack, MonadIO m, IsSvgWidget a) 
=> a

self: an SVG widget

-> m Word32

Returns: the state

Gets the current state of the widget.

Since: 4.24

getStylesheet

svgWidgetGetStylesheet Source #

Arguments

:: (HasCallStack, MonadIO m, IsSvgWidget a) 
=> a

self: an SVG widget

-> m (Maybe Bytes)

Returns: a GBytes with the CSS data

Gets the CSS user stylesheet.

Since: 4.24

loadFromBytes

svgWidgetLoadFromBytes Source #

Arguments

:: (HasCallStack, MonadIO m, IsSvgWidget a) 
=> a

self: an SVG widget

-> Bytes

bytes: the data to data

-> m () 

Loads SVG content into an existing SVG widget.

To track errors while loading SVG content, connect to the SvgWidget::error signal.

This clears any previously loaded content.

Since: 4.24

new

svgWidgetNew Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> m SvgWidget

Returns: the new widget

Creates a new, empty GtkSvgWidget.

Since: 4.24

setState

svgWidgetSetState Source #

Arguments

:: (HasCallStack, MonadIO m, IsSvgWidget a) 
=> a

self: an SVG widget

-> Word32

state: the state to set, as a value between 0 and 63

-> m () 

Sets the state of the widget.

The state change will apply transitions that are defined in the SVG. See Svg for details about states and transitions.

Since: 4.24

setStylesheet

svgWidgetSetStylesheet Source #

Arguments

:: (HasCallStack, MonadIO m, IsSvgWidget a) 
=> a

self: an SVG widget

-> Maybe Bytes

bytes: CSS data

-> m () 

Sets a CSS user stylesheet to use.

Note that styles are applied at load time, so this function must be called before loading SVG.

Since: 4.24

Properties

resource

Resource to load SVG data from.

This property is meant for use in ui files.

Since: 4.24

clearSvgWidgetResource :: (MonadIO m, IsSvgWidget o) => o -> m () Source #

Set the value of the “resource” property to Nothing. When overloading is enabled, this is equivalent to

clear #resource

constructSvgWidgetResource :: (IsSvgWidget o, MonadIO m) => Text -> m (GValueConstruct o) Source #

Construct a GValueConstruct with valid value for the “resource” property. This is rarely needed directly, but it is used by new.

getSvgWidgetResource :: (MonadIO m, IsSvgWidget o) => o -> m (Maybe Text) Source #

Get the value of the “resource” property. When overloading is enabled, this is equivalent to

get svgWidget #resource

setSvgWidgetResource :: (MonadIO m, IsSvgWidget o) => o -> Text -> m () Source #

Set the value of the “resource” property. When overloading is enabled, this is equivalent to

set svgWidget [ #resource := value ]

state

The current state of the renderer.

This can be a number between 0 and 63.

Since: 4.24

constructSvgWidgetState :: (IsSvgWidget o, MonadIO m) => Word32 -> m (GValueConstruct o) Source #

Construct a GValueConstruct with valid value for the “state” property. This is rarely needed directly, but it is used by new.

getSvgWidgetState :: (MonadIO m, IsSvgWidget o) => o -> m Word32 Source #

Get the value of the “state” property. When overloading is enabled, this is equivalent to

get svgWidget #state

setSvgWidgetState :: (MonadIO m, IsSvgWidget o) => o -> Word32 -> m () Source #

Set the value of the “state” property. When overloading is enabled, this is equivalent to

set svgWidget [ #state := value ]

stylesheet

A CSS stylesheet to apply to the SVG.

Since: 4.24

clearSvgWidgetStylesheet :: (MonadIO m, IsSvgWidget o) => o -> m () Source #

Set the value of the “stylesheet” property to Nothing. When overloading is enabled, this is equivalent to

clear #stylesheet

constructSvgWidgetStylesheet :: (IsSvgWidget o, MonadIO m) => Bytes -> m (GValueConstruct o) Source #

Construct a GValueConstruct with valid value for the “stylesheet” property. This is rarely needed directly, but it is used by new.

getSvgWidgetStylesheet :: (MonadIO m, IsSvgWidget o) => o -> m (Maybe Bytes) Source #

Get the value of the “stylesheet” property. When overloading is enabled, this is equivalent to

get svgWidget #stylesheet

setSvgWidgetStylesheet :: (MonadIO m, IsSvgWidget o) => o -> Bytes -> m () Source #

Set the value of the “stylesheet” property. When overloading is enabled, this is equivalent to

set svgWidget [ #stylesheet := value ]

Signals

activate

type SvgWidgetActivateCallback Source #

Arguments

 = Maybe Text

id: the ID of the element

-> Maybe Text

href: the href, if the element is a link

-> IO () 

Emitted when a link or other element is activated.

Activating elements can be achieved by clicking or by hitting <kbd>Enter</kbd> while the element has focus.

Since: 4.24

afterSvgWidgetActivate :: (IsSvgWidget a, MonadIO m) => a -> ((?self :: a) => SvgWidgetActivateCallback) -> m SignalHandlerId Source #

Connect a signal handler for the activate signal, to be run after the default handler. When overloading is enabled, this is equivalent to

after svgWidget #activate callback

By default the object invoking the signal is not passed to the callback. If you need to access it, you can use the implit ?self parameter. Note that this requires activating the ImplicitParams GHC extension.

onSvgWidgetActivate :: (IsSvgWidget a, MonadIO m) => a -> ((?self :: a) => SvgWidgetActivateCallback) -> m SignalHandlerId Source #

Connect a signal handler for the activate signal, to be run before the default handler. When overloading is enabled, this is equivalent to

on svgWidget #activate callback

error

type SvgWidgetErrorCallback Source #

Arguments

 = GError

error: the error

-> IO () 

Signals that an error occurred.

Errors can occur both during parsing and during rendering.

The expected error values are in the [errorgtk.SvgError] enumeration, context information about the location of parsing errors can be obtained with the various gtk_svg_error functions.

Parsing errors are never fatal, so the parsing will resume after the error. Errors may however cause parts of the given data or even all of it to not be parsed at all. So it is a useful idea to check that the parsing succeeds by connecting to this signal.

::: note This signal is emitted in the middle of parsing or rendering, and if you handle it, you must be careful. Logging the errors you receive is fine, but modifying the widget hierarchy or changing the paintable state definitively isn't.

If in doubt, defer to an idle.

Since: 4.24

afterSvgWidgetError :: (IsSvgWidget a, MonadIO m) => a -> ((?self :: a) => SvgWidgetErrorCallback) -> m SignalHandlerId Source #

Connect a signal handler for the error signal, to be run after the default handler. When overloading is enabled, this is equivalent to

after svgWidget #error callback

By default the object invoking the signal is not passed to the callback. If you need to access it, you can use the implit ?self parameter. Note that this requires activating the ImplicitParams GHC extension.

onSvgWidgetError :: (IsSvgWidget a, MonadIO m) => a -> ((?self :: a) => SvgWidgetErrorCallback) -> m SignalHandlerId Source #

Connect a signal handler for the error signal, to be run before the default handler. When overloading is enabled, this is equivalent to

on svgWidget #error callback