Gnome::Gtk4::Picture

#------------------------------------------------------------------------------- #--[Class Description]---------------------------------------------------------- #-------------------------------------------------------------------------------

=begin rakudoc

Description

The Gnome::Gtk4::Picture widget displays a Gnome::Gdk4::R-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 it, there’s a convenience function to do this:

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 .new-from-file() in class Texture, then create the Gnome::Gtk4::Picture with .new-for-paintable().

Sometimes an application will want to avoid depending on external data files, such as image files. See the documentation of Gnome::Gio::N-Resource for details. In this case, .new-for-resource() and .set-resource() should be used.

Gnome::Gtk4::Picture displays an image at its natural size. See Gnome::Gtk4::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 Gnome::Gtk4::Picture by changing content-fit. See enumeration ContentFit from Gnome::Gtk4::T-enums for details. 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 halign defined in Gnome::Gtk4::Widget and valign defined in Gnome::Gtk4::Widget can be used to make sure the paintable doesn't fill all available space but is instead displayed at its original size.

CSS nodes

Gnome::Gtk4::Picture has a single CSS node with the name picture.

Accessibility

Gnome::Gtk4::Picture uses the GTK_ACCESSIBLE_ROLE_IMG role.

Uml Diagram

=end rakudoc

#------------------------------------------------------------------------------- #--[Class Initialization]------------------------------------------------------- #-------------------------------------------------------------------------------

=begin rakudoc

Class initialization

new

:native-object

Create an object using a native object from an object of the same type found elsewhere. See also Gnome::N::TopLevelSupportClass.

multi method new ( N-Object() :$native-object! )

=end rakudoc

#------------------------------------------------------------------------------- =begin rakudoc

new-picture

Creates a new empty Gnome::Gtk4::Picture widget.

method new-picture ( --> Gnome::Gtk4::Picture )

=end rakudoc

#------------------------------------------------------------------------------- =begin rakudoc

new-for-file

Creates a new Gnome::Gtk4::Picture displaying the given $file.

If the file isn’t found or can’t be loaded, the resulting Gnome::Gtk4::Picture is empty.

If you need to detect failures to load the file, use .new-from-file() in class Texture to load the file yourself, then create the Gnome::Gtk4::Picture from the texture.

method new-for-file ( N-Object() $file --> Gnome::Gtk4::Picture )

=end rakudoc

#------------------------------------------------------------------------------- =begin rakudoc

new-for-filename

Creates a new Gnome::Gtk4::Picture displaying the file $filename.

This is a utility function that calls .new-for-file(). See that function for details.

method new-for-filename ( Str $filename --> Gnome::Gtk4::Picture )
  • $filename; a filename.

=end rakudoc

#------------------------------------------------------------------------------- =begin rakudoc

new-for-paintable

Creates a new Gnome::Gtk4::Picture displaying $paintable.

The Gnome::Gtk4::Picture will track changes to the $paintable and update its size and contents in response to it.

method new-for-paintable ( N-Object() $paintable --> Gnome::Gtk4::Picture )

=end rakudoc

#------------------------------------------------------------------------------- =begin rakudoc

new-for-pixbuf

Note: The native version of this routine is deprecated in gtk4-lib() since version 4.12

Creates a new Gnome::Gtk4::Picture displaying $pixbuf.

This is a utility function that calls .new-for-paintable(), See that function for details.

The pixbuf must not be modified after passing it to this function.

method new-for-pixbuf ( N-Object() $pixbuf --> Gnome::Gtk4::Picture )

=end rakudoc

#------------------------------------------------------------------------------- =begin rakudoc

new-for-resource

Creates a new Gnome::Gtk4::Picture displaying the resource at $resource-path.

This is a utility function that calls .new-for-file(). See that function for details.

method new-for-resource ( Str $resource-path --> Gnome::Gtk4::Picture )
  • $resource-path; resource path to play back.

=end rakudoc

#------------------------------------------------------------------------------- #--[Methods]-------------------------------------------------------------------- #-------------------------------------------------------------------------------

=begin rakudoc

Methods =end rakudoc

#------------------------------------------------------------------------------- =begin rakudoc

get-alternative-text

Gets the alternative textual description of the picture.

The returned string will be undefined if the picture cannot be described textually.

method get-alternative-text (--> Str )

Return value; the alternative textual description of $self..

=end rakudoc

#------------------------------------------------------------------------------- =begin rakudoc

get-can-shrink

Returns whether the Gnome::Gtk4::Picture respects its contents size.

method get-can-shrink (--> Bool )

Return value; True if the picture can be made smaller than its contents.

=end rakudoc

#------------------------------------------------------------------------------- =begin rakudoc

get-content-fit

Returns the fit mode for the content of the Gnome::Gtk4::Picture.

See enumeration ContentFit from Gnome::Gtk4::T-enums for details.

method get-content-fit (--> GtkContentFit )

Return value; the content fit mode.

=end rakudoc

#------------------------------------------------------------------------------- =begin rakudoc

get-file

Gets the Gnome::Gio::R-File currently displayed if $self is displaying a file.

If $self is not displaying a file, for example when .set-paintable() was used, then undefined is returned.

method get-file (--> N-Object )

Return value; The Gnome::Gio::R-File displayed by $self..

=end rakudoc

#------------------------------------------------------------------------------- =begin rakudoc

get-keep-aspect-ratio

Note: The native version of this routine is deprecated in gtk4-lib() since version 4.8

Returns whether the Gnome::Gtk4::Picture preserves its contents aspect ratio.

method get-keep-aspect-ratio (--> Bool )

Return value; True if the self tries to keep the contents' aspect ratio.

=end rakudoc

#------------------------------------------------------------------------------- =begin rakudoc

get-paintable

Gets the Gnome::Gdk4::R-Paintable being displayed by the Gnome::Gtk4::Picture.

method get-paintable (--> N-Object )

Return value; the displayed paintable.

=end rakudoc

#------------------------------------------------------------------------------- =begin rakudoc

set-alternative-text

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 undefined.

method set-alternative-text ( Str $alternative-text )
  • $alternative-text; a textual description of the contents.

=end rakudoc

#------------------------------------------------------------------------------- =begin rakudoc

set-can-shrink

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 .set-size-request() in class Widget.

Also of note is that a similar function for growing does not exist because the grow behavior can be controlled via .set-halign() in class Widget and .set-valign() in class Widget.

method set-can-shrink ( Bool() $can-shrink )
  • $can-shrink; if $self can be made smaller than its contents.

=end rakudoc

#------------------------------------------------------------------------------- =begin rakudoc

set-content-fit

Sets how the content should be resized to fit the Gnome::Gtk4::Picture.

See enumeration ContentFit from Gnome::Gtk4::T-enums for details.

method set-content-fit ( GtkContentFit $content-fit )
  • $content-fit; the content fit mode.

=end rakudoc

#------------------------------------------------------------------------------- =begin rakudoc

set-file

Makes $self load and display $file.

See .new-for-file() for details.

method set-file ( N-Object() $file )

=end rakudoc

#------------------------------------------------------------------------------- =begin rakudoc

set-filename

Makes $self load and display the given $filename.

This is a utility function that calls .set-file().

method set-filename ( Str $filename )
  • $filename; the filename to play.

=end rakudoc

#------------------------------------------------------------------------------- =begin rakudoc

set-keep-aspect-ratio

Note: The native version of this routine is deprecated in gtk4-lib() since version 4.8

If set to True, the $self will render its contents according to their aspect ratio.

That means that empty space may show up at the top/bottom or left/right of $self.

If set to False or if the contents provide no aspect ratio, the contents will be stretched over the picture's whole area.

method set-keep-aspect-ratio ( Bool() $keep-aspect-ratio )
  • $keep-aspect-ratio; whether to keep aspect ratio.

=end rakudoc

#------------------------------------------------------------------------------- =begin rakudoc

set-paintable

Makes $self display the given $paintable.

If $paintable is undefined, nothing will be displayed.

See .new-for-paintable() for details.

method set-paintable ( N-Object() $paintable )

=end rakudoc

#------------------------------------------------------------------------------- =begin rakudoc

set-pixbuf

Note: The native version of this routine is deprecated in gtk4-lib() since version 4.12

Sets a Gnome::Gtk4::Picture to show a Gnome::GdkPixbuf::Pixbuf.

See .new-for-pixbuf() for details.

This is a utility function that calls .set-paintable().

method set-pixbuf ( N-Object() $pixbuf )

=end rakudoc

#------------------------------------------------------------------------------- =begin rakudoc

set-resource

Makes $self load and display the resource at the given $resource-path.

This is a utility function that calls .set-file().

method set-resource ( Str $resource-path )
  • $resource-path; the resource to set.

=end rakudoc

Gnome::Gtk4 v0.2.10

Modules for package Gnome::Gtk4:api<2>. The language binding to GNOME’s user interface toolkit version 4

Authors

    License

    Artistic-2.0

    Dependencies

    CairoXMLXML::XPathGnome::Gio:api<2>Gnome::Gsk4:api<2>Gnome::Gdk4:api<2>Gnome::Graphene:api<2>Gnome::Pango:api<2>Gnome::GObject:api<2>Gnome::Glib:api<2>Gnome::N:api<2>

    Test Dependencies

    Provides

    • Gnome::Gtk4::AboutDialog
    • Gnome::Gtk4::ActionBar
    • Gnome::Gtk4::ActivateAction
    • Gnome::Gtk4::Adjustment
    • Gnome::Gtk4::AlertDialog
    • Gnome::Gtk4::AlternativeTrigger
    • Gnome::Gtk4::AnyFilter
    • Gnome::Gtk4::AppChooserButton
    • Gnome::Gtk4::AppChooserDialog
    • Gnome::Gtk4::AppChooserWidget
    • Gnome::Gtk4::Application
    • Gnome::Gtk4::ApplicationWindow
    • Gnome::Gtk4::AspectFrame
    • Gnome::Gtk4::Assistant
    • Gnome::Gtk4::AssistantPage
    • Gnome::Gtk4::BinLayout
    • Gnome::Gtk4::BoolFilter
    • Gnome::Gtk4::Box
    • Gnome::Gtk4::BoxLayout
    • Gnome::Gtk4::Builder
    • Gnome::Gtk4::BuilderListItemFactory
    • Gnome::Gtk4::Button
    • Gnome::Gtk4::Calendar
    • Gnome::Gtk4::CallbackAction
    • Gnome::Gtk4::CellArea
    • Gnome::Gtk4::CellAreaBox
    • Gnome::Gtk4::CellRenderer
    • Gnome::Gtk4::CellRendererAccel
    • Gnome::Gtk4::CellRendererCombo
    • Gnome::Gtk4::CellRendererPixbuf
    • Gnome::Gtk4::CellRendererProgress
    • Gnome::Gtk4::CellRendererSpin
    • Gnome::Gtk4::CellRendererSpinner
    • Gnome::Gtk4::CellRendererText
    • Gnome::Gtk4::CellRendererToggle
    • Gnome::Gtk4::CellView
    • Gnome::Gtk4::CenterBox
    • Gnome::Gtk4::CenterLayout
    • Gnome::Gtk4::CheckButton
    • Gnome::Gtk4::ColorButton
    • Gnome::Gtk4::ColorChooserDialog
    • Gnome::Gtk4::ColorChooserWidget
    • Gnome::Gtk4::ColumnView
    • Gnome::Gtk4::ComboBox
    • Gnome::Gtk4::ComboBoxText
    • Gnome::Gtk4::Constraint
    • Gnome::Gtk4::ConstraintLayout
    • Gnome::Gtk4::ConstraintLayoutChild
    • Gnome::Gtk4::CssProvider
    • Gnome::Gtk4::CustomLayout
    • Gnome::Gtk4::Dialog
    • Gnome::Gtk4::DragIcon
    • Gnome::Gtk4::DragSource
    • Gnome::Gtk4::DrawingArea
    • Gnome::Gtk4::DropControllerMotion
    • Gnome::Gtk4::DropDown
    • Gnome::Gtk4::DropTarget
    • Gnome::Gtk4::DropTargetAsync
    • Gnome::Gtk4::EditableLabel
    • Gnome::Gtk4::EmojiChooser
    • Gnome::Gtk4::Entry
    • Gnome::Gtk4::EntryBuffer
    • Gnome::Gtk4::EntryCompletion
    • Gnome::Gtk4::EventController
    • Gnome::Gtk4::EveryFilter
    • Gnome::Gtk4::Expander
    • Gnome::Gtk4::Expression
    • Gnome::Gtk4::FileChooserDialog
    • Gnome::Gtk4::FileChooserWidget
    • Gnome::Gtk4::FileFilter
    • Gnome::Gtk4::Filter
    • Gnome::Gtk4::Fixed
    • Gnome::Gtk4::FixedLayout
    • Gnome::Gtk4::FixedLayoutChild
    • Gnome::Gtk4::FlowBox
    • Gnome::Gtk4::FlowBoxChild
    • Gnome::Gtk4::FontButton
    • Gnome::Gtk4::FontChooserDialog
    • Gnome::Gtk4::FontChooserWidget
    • Gnome::Gtk4::Frame
    • Gnome::Gtk4::GLArea
    • Gnome::Gtk4::Gesture
    • Gnome::Gtk4::GestureClick
    • Gnome::Gtk4::GestureDrag
    • Gnome::Gtk4::GestureLongPress
    • Gnome::Gtk4::GesturePan
    • Gnome::Gtk4::GestureRotate
    • Gnome::Gtk4::GestureSingle
    • Gnome::Gtk4::GestureStylus
    • Gnome::Gtk4::GestureSwipe
    • Gnome::Gtk4::GestureZoom
    • Gnome::Gtk4::Grid
    • Gnome::Gtk4::GridLayout
    • Gnome::Gtk4::GridLayoutChild
    • Gnome::Gtk4::GridView
    • Gnome::Gtk4::HeaderBar
    • Gnome::Gtk4::IconPaintable
    • Gnome::Gtk4::IconTheme
    • Gnome::Gtk4::IconView
    • Gnome::Gtk4::Image
    • Gnome::Gtk4::InfoBar
    • Gnome::Gtk4::KeyvalTrigger
    • Gnome::Gtk4::Label
    • Gnome::Gtk4::LayoutChild
    • Gnome::Gtk4::LayoutManager
    • Gnome::Gtk4::LevelBar
    • Gnome::Gtk4::LinkButton
    • Gnome::Gtk4::ListBase
    • Gnome::Gtk4::ListBox
    • Gnome::Gtk4::ListBoxRow
    • Gnome::Gtk4::ListItem
    • Gnome::Gtk4::ListItemFactory
    • Gnome::Gtk4::ListStore
    • Gnome::Gtk4::ListView
    • Gnome::Gtk4::LockButton
    • Gnome::Gtk4::MediaControls
    • Gnome::Gtk4::MenuButton
    • Gnome::Gtk4::MessageDialog
    • Gnome::Gtk4::MnemonicAction
    • Gnome::Gtk4::MnemonicTrigger
    • Gnome::Gtk4::MultiFilter
    • Gnome::Gtk4::MultiSelection
    • Gnome::Gtk4::MultiSorter
    • Gnome::Gtk4::N-AccessibleList
    • Gnome::Gtk4::N-Bitset
    • Gnome::Gtk4::N-BitsetIter
    • Gnome::Gtk4::N-Border
    • Gnome::Gtk4::N-CssSection
    • Gnome::Gtk4::N-Requisition
    • Gnome::Gtk4::N-ScrollInfo
    • Gnome::Gtk4::N-TextIter
    • Gnome::Gtk4::N-TreeIter
    • Gnome::Gtk4::N-TreePath
    • Gnome::Gtk4::N-TreeRowReference
    • Gnome::Gtk4::NamedAction
    • Gnome::Gtk4::NeverTrigger
    • Gnome::Gtk4::NoSelection
    • Gnome::Gtk4::Notebook
    • Gnome::Gtk4::NotebookPage
    • Gnome::Gtk4::NothingAction
    • Gnome::Gtk4::NumericSorter
    • Gnome::Gtk4::Overlay
    • Gnome::Gtk4::OverlayLayout
    • Gnome::Gtk4::OverlayLayoutChild
    • Gnome::Gtk4::PageSetupUnixDialog
    • Gnome::Gtk4::Paned
    • Gnome::Gtk4::PasswordEntry
    • Gnome::Gtk4::Picture
    • Gnome::Gtk4::Popover
    • Gnome::Gtk4::PopoverMenu
    • Gnome::Gtk4::PopoverMenuBar
    • Gnome::Gtk4::PrintOperation
    • Gnome::Gtk4::PrintUnixDialog
    • Gnome::Gtk4::ProgressBar
    • Gnome::Gtk4::R-Accessible
    • Gnome::Gtk4::R-Actionable
    • Gnome::Gtk4::R-AppChooser
    • Gnome::Gtk4::R-Buildable
    • Gnome::Gtk4::R-BuilderScope
    • Gnome::Gtk4::R-CellEditable
    • Gnome::Gtk4::R-CellLayout
    • Gnome::Gtk4::R-ColorChooser
    • Gnome::Gtk4::R-ConstraintTarget
    • Gnome::Gtk4::R-Editable
    • Gnome::Gtk4::R-FileChooser
    • Gnome::Gtk4::R-FontChooser
    • Gnome::Gtk4::R-Native
    • Gnome::Gtk4::R-Orientable
    • Gnome::Gtk4::R-PrintOperationPreview
    • Gnome::Gtk4::R-Root
    • Gnome::Gtk4::R-Scrollable
    • Gnome::Gtk4::R-SelectionModel
    • Gnome::Gtk4::R-ShortcutManager
    • Gnome::Gtk4::R-StyleProvider
    • Gnome::Gtk4::R-SymbolicPaintable
    • Gnome::Gtk4::R-TreeDragDest
    • Gnome::Gtk4::R-TreeDragSource
    • Gnome::Gtk4::R-TreeModel
    • Gnome::Gtk4::R-TreeSortable
    • Gnome::Gtk4::Range
    • Gnome::Gtk4::Revealer
    • Gnome::Gtk4::Scale
    • Gnome::Gtk4::ScaleButton
    • Gnome::Gtk4::Scrollbar
    • Gnome::Gtk4::ScrolledWindow
    • Gnome::Gtk4::SearchBar
    • Gnome::Gtk4::SearchEntry
    • Gnome::Gtk4::Separator
    • Gnome::Gtk4::Shortcut
    • Gnome::Gtk4::ShortcutAction
    • Gnome::Gtk4::ShortcutController
    • Gnome::Gtk4::ShortcutLabel
    • Gnome::Gtk4::ShortcutTrigger
    • Gnome::Gtk4::ShortcutsGroup
    • Gnome::Gtk4::ShortcutsSection
    • Gnome::Gtk4::ShortcutsShortcut
    • Gnome::Gtk4::ShortcutsWindow
    • Gnome::Gtk4::SignalAction
    • Gnome::Gtk4::SignalListItemFactory
    • Gnome::Gtk4::SingleSelection
    • Gnome::Gtk4::Snapshot
    • Gnome::Gtk4::Sorter
    • Gnome::Gtk4::SpinButton
    • Gnome::Gtk4::Spinner
    • Gnome::Gtk4::Stack
    • Gnome::Gtk4::StackPage
    • Gnome::Gtk4::StackSidebar
    • Gnome::Gtk4::StackSwitcher
    • Gnome::Gtk4::Statusbar
    • Gnome::Gtk4::StringFilter
    • Gnome::Gtk4::StringList
    • Gnome::Gtk4::StringObject
    • Gnome::Gtk4::StringSorter
    • Gnome::Gtk4::StyleContext
    • Gnome::Gtk4::Switch
    • Gnome::Gtk4::T-aboutdialog
    • Gnome::Gtk4::T-accessible
    • Gnome::Gtk4::T-activateaction
    • Gnome::Gtk4::T-application
    • Gnome::Gtk4::T-assistant
    • Gnome::Gtk4::T-bitset
    • Gnome::Gtk4::T-border
    • Gnome::Gtk4::T-builder
    • Gnome::Gtk4::T-builderscope
    • Gnome::Gtk4::T-cellrenderer
    • Gnome::Gtk4::T-cellrendereraccel
    • Gnome::Gtk4::T-csssection
    • Gnome::Gtk4::T-dialog
    • Gnome::Gtk4::T-editable
    • Gnome::Gtk4::T-entry
    • Gnome::Gtk4::T-enums
    • Gnome::Gtk4::T-expression
    • Gnome::Gtk4::T-filechooser
    • Gnome::Gtk4::T-filter
    • Gnome::Gtk4::T-fontchooser
    • Gnome::Gtk4::T-iconpaintable
    • Gnome::Gtk4::T-icontheme
    • Gnome::Gtk4::T-iconview
    • Gnome::Gtk4::T-image
    • Gnome::Gtk4::T-levelbar
    • Gnome::Gtk4::T-messagedialog
    • Gnome::Gtk4::T-native
    • Gnome::Gtk4::T-notebook
    • Gnome::Gtk4::T-popovermenu
    • Gnome::Gtk4::T-printoperation
    • Gnome::Gtk4::T-revealer
    • Gnome::Gtk4::T-scrolledwindow
    • Gnome::Gtk4::T-shortcutaction
    • Gnome::Gtk4::T-shortcutsshortcut
    • Gnome::Gtk4::T-show
    • Gnome::Gtk4::T-sorter
    • Gnome::Gtk4::T-spinbutton
    • Gnome::Gtk4::T-stack
    • Gnome::Gtk4::T-stringfilter
    • Gnome::Gtk4::T-stylecontext
    • Gnome::Gtk4::T-styleprovider
    • Gnome::Gtk4::T-textiter
    • Gnome::Gtk4::T-textview
    • Gnome::Gtk4::T-treednd
    • Gnome::Gtk4::T-treedragdest
    • Gnome::Gtk4::T-treemodel
    • Gnome::Gtk4::T-treesortable
    • Gnome::Gtk4::T-treeview
    • Gnome::Gtk4::T-treeviewcolumn
    • Gnome::Gtk4::T-types
    • Gnome::Gtk4::T-widget
    • Gnome::Gtk4::Text
    • Gnome::Gtk4::TextBuffer
    • Gnome::Gtk4::TextChildAnchor
    • Gnome::Gtk4::TextMark
    • Gnome::Gtk4::TextTag
    • Gnome::Gtk4::TextTagTable
    • Gnome::Gtk4::TextView
    • Gnome::Gtk4::ToggleButton
    • Gnome::Gtk4::Tooltip
    • Gnome::Gtk4::TreeExpander
    • Gnome::Gtk4::TreeListModel
    • Gnome::Gtk4::TreeListRow
    • Gnome::Gtk4::TreeListRowSorter
    • Gnome::Gtk4::TreeModelSort
    • Gnome::Gtk4::TreeSelection
    • Gnome::Gtk4::TreeStore
    • Gnome::Gtk4::TreeView
    • Gnome::Gtk4::TreeViewColumn
    • Gnome::Gtk4::Video
    • Gnome::Gtk4::Viewport
    • Gnome::Gtk4::VolumeButton
    • Gnome::Gtk4::Widget
    • Gnome::Gtk4::WidgetPaintable
    • Gnome::Gtk4::Window
    • Gnome::Gtk4::WindowControls
    • Gnome::Gtk4::WindowHandle

    Documentation

    The Camelia image is copyright 2009 by Larry Wall. "Raku" is a trademark of the Yet Another Society. All rights reserved.

    Built with Podlite — the markup and publishing tools behind this site.