| Copyright | Will Thompson and Iñaki García Etxebarria |
|---|---|
| License | LGPL-2.1 |
| Maintainer | Iñaki García Etxebarria |
| Safe Haskell | None |
| Language | Haskell2010 |
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
- newtype SvgWidget = SvgWidget (ManagedPtr SvgWidget)
- class (GObject o, IsDescendantOf SvgWidget o) => IsSvgWidget o
- toSvgWidget :: (MonadIO m, IsSvgWidget o) => o -> m SvgWidget
- svgWidgetGetState :: (HasCallStack, MonadIO m, IsSvgWidget a) => a -> m Word32
- svgWidgetGetStylesheet :: (HasCallStack, MonadIO m, IsSvgWidget a) => a -> m (Maybe Bytes)
- svgWidgetLoadFromBytes :: (HasCallStack, MonadIO m, IsSvgWidget a) => a -> Bytes -> m ()
- svgWidgetNew :: (HasCallStack, MonadIO m) => m SvgWidget
- svgWidgetSetState :: (HasCallStack, MonadIO m, IsSvgWidget a) => a -> Word32 -> m ()
- svgWidgetSetStylesheet :: (HasCallStack, MonadIO m, IsSvgWidget a) => a -> Maybe Bytes -> m ()
- clearSvgWidgetResource :: (MonadIO m, IsSvgWidget o) => o -> m ()
- constructSvgWidgetResource :: (IsSvgWidget o, MonadIO m) => Text -> m (GValueConstruct o)
- getSvgWidgetResource :: (MonadIO m, IsSvgWidget o) => o -> m (Maybe Text)
- setSvgWidgetResource :: (MonadIO m, IsSvgWidget o) => o -> Text -> m ()
- constructSvgWidgetState :: (IsSvgWidget o, MonadIO m) => Word32 -> m (GValueConstruct o)
- getSvgWidgetState :: (MonadIO m, IsSvgWidget o) => o -> m Word32
- setSvgWidgetState :: (MonadIO m, IsSvgWidget o) => o -> Word32 -> m ()
- clearSvgWidgetStylesheet :: (MonadIO m, IsSvgWidget o) => o -> m ()
- constructSvgWidgetStylesheet :: (IsSvgWidget o, MonadIO m) => Bytes -> m (GValueConstruct o)
- getSvgWidgetStylesheet :: (MonadIO m, IsSvgWidget o) => o -> m (Maybe Bytes)
- setSvgWidgetStylesheet :: (MonadIO m, IsSvgWidget o) => o -> Bytes -> m ()
- type SvgWidgetActivateCallback = Maybe Text -> Maybe Text -> IO ()
- afterSvgWidgetActivate :: (IsSvgWidget a, MonadIO m) => a -> ((?self :: a) => SvgWidgetActivateCallback) -> m SignalHandlerId
- onSvgWidgetActivate :: (IsSvgWidget a, MonadIO m) => a -> ((?self :: a) => SvgWidgetActivateCallback) -> m SignalHandlerId
- type SvgWidgetErrorCallback = GError -> IO ()
- afterSvgWidgetError :: (IsSvgWidget a, MonadIO m) => a -> ((?self :: a) => SvgWidgetErrorCallback) -> m SignalHandlerId
- onSvgWidgetError :: (IsSvgWidget a, MonadIO m) => a -> ((?self :: a) => SvgWidgetErrorCallback) -> m SignalHandlerId
Exported types
Memory-managed wrapper type.
Constructors
| SvgWidget (ManagedPtr SvgWidget) |
Instances
| Eq SvgWidget Source # | |
| GObject SvgWidget Source # | |
Defined in GI.Gtk.Objects.SvgWidget | |
| ManagedPtrNewtype SvgWidget Source # | |
Defined in GI.Gtk.Objects.SvgWidget Methods | |
| TypedObject SvgWidget Source # | |
| HasParentTypes SvgWidget Source # | |
Defined in GI.Gtk.Objects.SvgWidget | |
| IsGValue (Maybe SvgWidget) Source # | Convert |
| type ParentTypes SvgWidget Source # | |
Defined in GI.Gtk.Objects.SvgWidget | |
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
| (GObject o, IsDescendantOf SvgWidget o) => IsSvgWidget o Source # | |
Defined in GI.Gtk.Objects.SvgWidget | |
toSvgWidget :: (MonadIO m, IsSvgWidget o) => o -> m SvgWidget Source #
Methods
Click to display all available methods, including inherited ones
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
Arguments
| :: (HasCallStack, MonadIO m, IsSvgWidget a) | |
| => a |
|
| -> 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 |
|
| -> m (Maybe Bytes) | Returns: a |
Gets the CSS user stylesheet.
Since: 4.24
loadFromBytes
svgWidgetLoadFromBytes Source #
Arguments
| :: (HasCallStack, MonadIO m, IsSvgWidget a) | |
| => a |
|
| -> Bytes |
|
| -> 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
Arguments
| :: (HasCallStack, MonadIO m) | |
| => m SvgWidget | Returns: the new widget |
Creates a new, empty GtkSvgWidget.
Since: 4.24
setState
Arguments
| :: (HasCallStack, MonadIO m, IsSvgWidget a) | |
| => a |
|
| -> Word32 |
|
| -> 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 |
|
| -> Maybe Bytes |
|
| -> 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
setsvgWidget [ #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
setsvgWidget [ #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
setsvgWidget [ #stylesheet:=value ]
Signals
activate
type SvgWidgetActivateCallback Source #
Arguments
| = Maybe Text |
|
| -> Maybe Text |
|
| -> 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 #
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