| Copyright | Will Thompson Iñaki García Etxebarria and Jonas Platte | 
|---|---|
| License | LGPL-2.1 | 
| Maintainer | Iñaki García Etxebarria | 
| Safe Haskell | Safe-Inferred | 
| Language | Haskell2010 | 
GI.Gtk.Objects.Picture
Contents
Description
The Picture widget displays a Paintable. Many convenience functions
 are provided to make pictures simple to use. For example, if you want to load
 an image from a file, and then display that, there’s a convenience function
 to do this:
C code
 GtkWidget *widget;
 widget = gtk_picture_new_for_filename ("myfile.png");If the file isn’t loaded successfully, the picture 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
 textureNewFromFile, then create the Picture with
 pictureNewForPaintable.
Sometimes an application will want to avoid depending on external data
 files, such as image files. See the documentation of Resource for details.
 In this case, pictureNewForResource and pictureSetResource
 should be used.
GtkPicture displays an image at its natural size. See Image if you want
 to display a fixed-size image, such as an icon.
Sizing the paintable
You can influence how the paintable is displayed inside the Picture.
 By turning off Picture:keep-aspect-ratio you can allow the paintable
 to get stretched. Picture:can-shrink can be unset to make sure that
 paintables are never made smaller than their ideal size - but be careful
 if you do not know the size of the paintable in use (like when displaying
 user-loaded images). This can easily cause the picture to grow larger than
 the screen. And Widget:halign and Widget:valign can be used to make
 sure the paintable doesn't fill all available space but is instead displayed
 at its original size.
CSS nodes
GtkPicture has a single CSS node with the name picture.
Accessibility
GtkPicture uses the GTK_ACCESSIBLE_ROLE_IMG role.
Synopsis
- newtype Picture = Picture (ManagedPtr Picture)
- class (GObject o, IsDescendantOf Picture o) => IsPicture o
- toPicture :: (MonadIO m, IsPicture o) => o -> m Picture
- pictureGetAlternativeText :: (HasCallStack, MonadIO m, IsPicture a) => a -> m (Maybe Text)
- pictureGetCanShrink :: (HasCallStack, MonadIO m, IsPicture a) => a -> m Bool
- pictureGetFile :: (HasCallStack, MonadIO m, IsPicture a) => a -> m (Maybe File)
- pictureGetKeepAspectRatio :: (HasCallStack, MonadIO m, IsPicture a) => a -> m Bool
- pictureGetPaintable :: (HasCallStack, MonadIO m, IsPicture a) => a -> m (Maybe Paintable)
- pictureNew :: (HasCallStack, MonadIO m) => m Picture
- pictureNewForFile :: (HasCallStack, MonadIO m, IsFile a) => Maybe a -> m Picture
- pictureNewForFilename :: (HasCallStack, MonadIO m) => Maybe [Char] -> m Picture
- pictureNewForPaintable :: (HasCallStack, MonadIO m, IsPaintable a) => Maybe a -> m Picture
- pictureNewForPixbuf :: (HasCallStack, MonadIO m, IsPixbuf a) => Maybe a -> m Picture
- pictureNewForResource :: (HasCallStack, MonadIO m) => Maybe Text -> m Picture
- pictureSetAlternativeText :: (HasCallStack, MonadIO m, IsPicture a) => a -> Maybe Text -> m ()
- pictureSetCanShrink :: (HasCallStack, MonadIO m, IsPicture a) => a -> Bool -> m ()
- pictureSetFile :: (HasCallStack, MonadIO m, IsPicture a, IsFile b) => a -> Maybe b -> m ()
- pictureSetFilename :: (HasCallStack, MonadIO m, IsPicture a) => a -> Maybe Text -> m ()
- pictureSetKeepAspectRatio :: (HasCallStack, MonadIO m, IsPicture a) => a -> Bool -> m ()
- pictureSetPaintable :: (HasCallStack, MonadIO m, IsPicture a, IsPaintable b) => a -> Maybe b -> m ()
- pictureSetPixbuf :: (HasCallStack, MonadIO m, IsPicture a, IsPixbuf b) => a -> Maybe b -> m ()
- pictureSetResource :: (HasCallStack, MonadIO m, IsPicture a) => a -> Maybe Text -> m ()
- clearPictureAlternativeText :: (MonadIO m, IsPicture o) => o -> m ()
- constructPictureAlternativeText :: (IsPicture o, MonadIO m) => Text -> m (GValueConstruct o)
- getPictureAlternativeText :: (MonadIO m, IsPicture o) => o -> m (Maybe Text)
- setPictureAlternativeText :: (MonadIO m, IsPicture o) => o -> Text -> m ()
- constructPictureCanShrink :: (IsPicture o, MonadIO m) => Bool -> m (GValueConstruct o)
- getPictureCanShrink :: (MonadIO m, IsPicture o) => o -> m Bool
- setPictureCanShrink :: (MonadIO m, IsPicture o) => o -> Bool -> m ()
- clearPictureFile :: (MonadIO m, IsPicture o) => o -> m ()
- constructPictureFile :: (IsPicture o, MonadIO m, IsFile a) => a -> m (GValueConstruct o)
- getPictureFile :: (MonadIO m, IsPicture o) => o -> m (Maybe File)
- setPictureFile :: (MonadIO m, IsPicture o, IsFile a) => o -> a -> m ()
- constructPictureKeepAspectRatio :: (IsPicture o, MonadIO m) => Bool -> m (GValueConstruct o)
- getPictureKeepAspectRatio :: (MonadIO m, IsPicture o) => o -> m Bool
- setPictureKeepAspectRatio :: (MonadIO m, IsPicture o) => o -> Bool -> m ()
- clearPicturePaintable :: (MonadIO m, IsPicture o) => o -> m ()
- constructPicturePaintable :: (IsPicture o, MonadIO m, IsPaintable a) => a -> m (GValueConstruct o)
- getPicturePaintable :: (MonadIO m, IsPicture o) => o -> m (Maybe Paintable)
- setPicturePaintable :: (MonadIO m, IsPicture o, IsPaintable a) => o -> a -> m ()
Exported types
Memory-managed wrapper type.
Instances
| Eq Picture Source # | |
| GObject Picture Source # | |
| Defined in GI.Gtk.Objects.Picture | |
| ManagedPtrNewtype Picture Source # | |
| Defined in GI.Gtk.Objects.Picture Methods toManagedPtr :: Picture -> ManagedPtr Picture | |
| TypedObject Picture Source # | |
| Defined in GI.Gtk.Objects.Picture | |
| HasParentTypes Picture Source # | |
| Defined in GI.Gtk.Objects.Picture | |
| IsGValue (Maybe Picture) Source # | Convert  | 
| Defined in GI.Gtk.Objects.Picture Methods gvalueGType_ :: IO GType gvalueSet_ :: Ptr GValue -> Maybe Picture -> IO () gvalueGet_ :: Ptr GValue -> IO (Maybe Picture) | |
| type ParentTypes Picture Source # | |
| Defined in GI.Gtk.Objects.Picture | |
class (GObject o, IsDescendantOf Picture o) => IsPicture o Source #
Instances
| (GObject o, IsDescendantOf Picture o) => IsPicture o Source # | |
| Defined in GI.Gtk.Objects.Picture | |
Methods
Click to display all available methods, including inherited ones
Methods
actionSetEnabled, activate, activateAction, activateDefault, addController, addCssClass, addMnemonicLabel, addTickCallback, allocate, bindProperty, bindPropertyFull, childFocus, computeBounds, computeExpand, computePoint, computeTransform, contains, createPangoContext, createPangoLayout, dragCheckThreshold, errorBell, forceFloating, freezeNotify, getv, grabFocus, hasCssClass, hasDefault, hasFocus, hasVisibleFocus, hide, inDestruction, initTemplate, insertActionGroup, insertAfter, insertBefore, isAncestor, isDrawable, isFloating, isFocus, isSensitive, isVisible, keynavFailed, listMnemonicLabels, 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, updateProperty, updateRelation, updateState, watchClosure.
Getters
getAccessibleRole, getAllocatedBaseline, getAllocatedHeight, getAllocatedWidth, getAllocation, getAlternativeText, getAncestor, getBuildableId, getCanFocus, getCanShrink, getCanTarget, getChildVisible, getClipboard, getCssClasses, getCssName, getCursor, getData, getDirection, getDisplay, getFile, getFirstChild, getFocusChild, getFocusOnClick, getFocusable, getFontMap, getFontOptions, getFrameClock, getHalign, getHasTooltip, getHeight, getHexpand, getHexpandSet, getKeepAspectRatio, getLastChild, getLayoutManager, getMapped, getMarginBottom, getMarginEnd, getMarginStart, getMarginTop, getName, getNative, getNextSibling, getOpacity, getOverflow, getPaintable, getPangoContext, getParent, getPreferredSize, getPrevSibling, getPrimaryClipboard, getProperty, getQdata, getRealized, getReceivesDefault, getRequestMode, getRoot, getScaleFactor, getSensitive, getSettings, getSize, getSizeRequest, getStateFlags, getStyleContext, getTemplateChild, getTooltipMarkup, getTooltipText, getValign, getVexpand, getVexpandSet, getVisible, getWidth.
Setters
setAlternativeText, setCanFocus, setCanShrink, setCanTarget, setChildVisible, setCssClasses, setCursor, setCursorFromName, setData, setDataFull, setDirection, setFile, setFilename, setFocusChild, setFocusOnClick, setFocusable, setFontMap, setFontOptions, setHalign, setHasTooltip, setHexpand, setHexpandSet, setKeepAspectRatio, setLayoutManager, setMarginBottom, setMarginEnd, setMarginStart, setMarginTop, setName, setOpacity, setOverflow, setPaintable, setParent, setPixbuf, setProperty, setReceivesDefault, setResource, setSensitive, setSizeRequest, setStateFlags, setTooltipMarkup, setTooltipText, setValign, setVexpand, setVexpandSet, setVisible.
getAlternativeText
pictureGetAlternativeText Source #
Arguments
| :: (HasCallStack, MonadIO m, IsPicture a) | |
| => a | 
 | 
| -> m (Maybe Text) | Returns: the alternative textual description
     of  | 
Gets the alternative textual description of the picture or returns Nothing if
 the picture cannot be described textually.
getCanShrink
Arguments
| :: (HasCallStack, MonadIO m, IsPicture a) | |
| => a | 
 | 
| -> m Bool | Returns:  | 
Gets the value set via pictureSetCanShrink.
getFile
Arguments
| :: (HasCallStack, MonadIO m, IsPicture a) | |
| => a | 
 | 
| -> m (Maybe File) | Returns: The  | 
Gets the File currently displayed if self is displaying a file.
 If self is not displaying a file, for example when pictureSetPaintable
 was used, then Nothing is returned.
getKeepAspectRatio
pictureGetKeepAspectRatio Source #
Arguments
| :: (HasCallStack, MonadIO m, IsPicture a) | |
| => a | 
 | 
| -> m Bool | Returns:  | 
Gets the value set via pictureSetKeepAspectRatio.
getPaintable
new
Arguments
| :: (HasCallStack, MonadIO m) | |
| => m Picture | Returns: a newly created  | 
Creates a new empty Picture widget.
newForFile
Arguments
| :: (HasCallStack, MonadIO m, IsFile a) | |
| => Maybe a | 
 | 
| -> m Picture | Returns: a new  | 
Creates a new Picture displaying the given file. If the file
 isn’t found or can’t be loaded, the resulting Picture be empty.
If you need to detect failures to load the file, use
 textureNewFromFile to load the file yourself, then create
 the Picture from the texture.
newForFilename
pictureNewForFilename Source #
Arguments
| :: (HasCallStack, MonadIO m) | |
| => Maybe [Char] | 
 | 
| -> m Picture | Returns: a new  | 
Creates a new Picture displaying the file filename.
This is a utility function that calls pictureNewForFile.
 See that function for details.
newForPaintable
pictureNewForPaintable Source #
Arguments
| :: (HasCallStack, MonadIO m, IsPaintable a) | |
| => Maybe a | |
| -> m Picture | Returns: a new  | 
newForPixbuf
Arguments
| :: (HasCallStack, MonadIO m, IsPixbuf a) | |
| => Maybe a | |
| -> m Picture | Returns: a new  | 
Creates a new Picture displaying pixbuf.
This is a utility function that calls pictureNewForPaintable,
 See that function for details.
The pixbuf must not be modified after passing it to this function.
newForResource
pictureNewForResource Source #
Arguments
| :: (HasCallStack, MonadIO m) | |
| => Maybe Text | 
 | 
| -> m Picture | Returns: a new  | 
Creates a new Picture displaying the resource at resourcePath.
This is a utility function that calls pictureNewForFile.
 See that function for details.
setAlternativeText
pictureSetAlternativeText Source #
Arguments
| :: (HasCallStack, MonadIO m, IsPicture a) | |
| => a | 
 | 
| -> Maybe Text | 
 | 
| -> m () | 
Sets an alternative textual description for the picture contents. It is equivalent to the "alt" attribute for images on websites.
This text will be made available to accessibility tools.
If the picture cannot be described textually, set this property to Nothing.
setCanShrink
Arguments
| :: (HasCallStack, MonadIO m, IsPicture a) | |
| => a | 
 | 
| -> Bool | 
 | 
| -> m () | 
If set to True, the self can be made smaller than its contents.
 The contents will then be scaled down when rendering.
If you want to still force a minimum size manually, consider using
 widgetSetSizeRequest.
Also of note is that a similar function for growing does not exist
 because the grow behavior can be controlled via
 widgetSetHalign and widgetSetValign.
setFile
Arguments
| :: (HasCallStack, MonadIO m, IsPicture a, IsFile b) | |
| => a | 
 | 
| -> Maybe b | 
 | 
| -> m () | 
Makes self load and display file.
See pictureNewForFile for details.
setFilename
Arguments
| :: (HasCallStack, MonadIO m, IsPicture a) | |
| => a | 
 | 
| -> Maybe Text | 
 | 
| -> m () | 
Makes self load and display the given filename.
This is a utility function that calls pictureSetFile.
setKeepAspectRatio
pictureSetKeepAspectRatio Source #
Arguments
| :: (HasCallStack, MonadIO m, IsPicture a) | |
| => a | 
 | 
| -> Bool | 
 | 
| -> m () | 
setPaintable
Arguments
| :: (HasCallStack, MonadIO m, IsPicture a, IsPaintable b) | |
| => a | 
 | 
| -> Maybe b | |
| -> m () | 
Makes self display the given paintable. If paintable is Nothing,
 nothing will be displayed.
See pictureNewForPaintable for details.
setPixbuf
Arguments
| :: (HasCallStack, MonadIO m, IsPicture a, IsPixbuf b) | |
| => a | 
 | 
| -> Maybe b | |
| -> m () | 
See pictureNewForPixbuf for details.
This is a utility function that calls pictureSetPaintable,
setResource
Arguments
| :: (HasCallStack, MonadIO m, IsPicture a) | |
| => a | 
 | 
| -> Maybe Text | 
 | 
| -> m () | 
Makes self load and display the resource at the given
 resourcePath.
This is a utility function that calls pictureSetFile,
Properties
alternativeText
The alternative textual description for the picture.
clearPictureAlternativeText :: (MonadIO m, IsPicture o) => o -> m () Source #
Set the value of the “alternative-text” property to Nothing.
 When overloading is enabled, this is equivalent to
clear #alternativeText
constructPictureAlternativeText :: (IsPicture o, MonadIO m) => Text -> m (GValueConstruct o) Source #
Construct a GValueConstruct with valid value for the “alternative-text” property. This is rarely needed directly, but it is used by new.
getPictureAlternativeText :: (MonadIO m, IsPicture o) => o -> m (Maybe Text) Source #
Get the value of the “alternative-text” property.
 When overloading is enabled, this is equivalent to
get picture #alternativeText
setPictureAlternativeText :: (MonadIO m, IsPicture o) => o -> Text -> m () Source #
Set the value of the “alternative-text” property.
 When overloading is enabled, this is equivalent to
setpicture [ #alternativeText:=value ]
canShrink
If the Picture can be made smaller than the self it contains.
constructPictureCanShrink :: (IsPicture o, MonadIO m) => Bool -> m (GValueConstruct o) Source #
Construct a GValueConstruct with valid value for the “can-shrink” property. This is rarely needed directly, but it is used by new.
getPictureCanShrink :: (MonadIO m, IsPicture o) => o -> m Bool Source #
Get the value of the “can-shrink” property.
 When overloading is enabled, this is equivalent to
get picture #canShrink
setPictureCanShrink :: (MonadIO m, IsPicture o) => o -> Bool -> m () Source #
Set the value of the “can-shrink” property.
 When overloading is enabled, this is equivalent to
setpicture [ #canShrink:=value ]
file
clearPictureFile :: (MonadIO m, IsPicture o) => o -> m () Source #
Set the value of the “file” property to Nothing.
 When overloading is enabled, this is equivalent to
clear #file
constructPictureFile :: (IsPicture o, MonadIO m, IsFile a) => a -> m (GValueConstruct o) Source #
Construct a GValueConstruct with valid value for the “file” property. This is rarely needed directly, but it is used by new.
getPictureFile :: (MonadIO m, IsPicture o) => o -> m (Maybe File) Source #
Get the value of the “file” property.
 When overloading is enabled, this is equivalent to
get picture #file
setPictureFile :: (MonadIO m, IsPicture o, IsFile a) => o -> a -> m () Source #
Set the value of the “file” property.
 When overloading is enabled, this is equivalent to
setpicture [ #file:=value ]
keepAspectRatio
Whether the GtkPicture will render its contents trying to preserve the aspect ratio of the contents.
constructPictureKeepAspectRatio :: (IsPicture o, MonadIO m) => Bool -> m (GValueConstruct o) Source #
Construct a GValueConstruct with valid value for the “keep-aspect-ratio” property. This is rarely needed directly, but it is used by new.
getPictureKeepAspectRatio :: (MonadIO m, IsPicture o) => o -> m Bool Source #
Get the value of the “keep-aspect-ratio” property.
 When overloading is enabled, this is equivalent to
get picture #keepAspectRatio
setPictureKeepAspectRatio :: (MonadIO m, IsPicture o) => o -> Bool -> m () Source #
Set the value of the “keep-aspect-ratio” property.
 When overloading is enabled, this is equivalent to
setpicture [ #keepAspectRatio:=value ]
paintable
clearPicturePaintable :: (MonadIO m, IsPicture o) => o -> m () Source #
Set the value of the “paintable” property to Nothing.
 When overloading is enabled, this is equivalent to
clear #paintable
constructPicturePaintable :: (IsPicture o, MonadIO m, IsPaintable a) => a -> m (GValueConstruct o) Source #
Construct a GValueConstruct with valid value for the “paintable” property. This is rarely needed directly, but it is used by new.
getPicturePaintable :: (MonadIO m, IsPicture o) => o -> m (Maybe Paintable) Source #
Get the value of the “paintable” property.
 When overloading is enabled, this is equivalent to
get picture #paintable
setPicturePaintable :: (MonadIO m, IsPicture o, IsPaintable a) => o -> a -> m () Source #
Set the value of the “paintable” property.
 When overloading is enabled, this is equivalent to
setpicture [ #paintable:=value ]