It derives from <GtkWidget>.
Displays a <GdkPaintable>.
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:
GtkWidget *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 and image loading
framework such as libglycin, then create the
<GtkPicture> with picture:new-for-paintable.
Sometimes an application will want to avoid depending on external data
files, such as image files. See the documentation of
<GResource> for details. In this case,
picture:new-for-resource and
picture:set-resource should be used.
<GtkPicture> displays an image at its natural
size. See <GtkImage> if you want to display a
fixed-size image, such as an icon.
You can influence how the paintable is displayed inside the
<GtkPicture> by changing picture:content-fit. See
<GtkContentFit> for details. 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.
<GtkPicture> has a single CSS node with the name
picture.
<GtkPicture> uses the
Gtk.AccessibleRole.img role.
The alternative textual description for the picture.
Its value is a string, or #f.
Set it with (set! (picture:alternative-text self) value).
If the <GtkPicture> can be made smaller than the
natural size of its contents.
Its value is a boolean.
Set it with (set! (picture:can-shrink self) value).
How the content should be resized to fit inside the
<GtkPicture>.
Its value is a <GtkContentFit> (or, to set it,
one of its symbols).
Set it with (set! (picture:content-fit self) value).
The <GFile> that is displayed or #f if
none.
Its value is a <GFile>, or #f.
Set it with (set! (picture:file self) value).
If the rendering of the contents is isolated from the rest of the widget tree.
Its value is a boolean.
Set it with (set! (picture:isolate-contents self) value).
Whether the GtkPicture will render its contents trying to preserve the aspect ratio.
Its value is a boolean.
Set it with (set! (picture:keep-aspect-ratio self) value).
The <GdkPaintable> to be displayed by this
<GtkPicture>.
Its value is a <GdkPaintable>, or #f.
Set it with (set! (picture:paintable self) value).
Gets the alternative textual description of the picture.
The returned string will be #f if the picture cannot be described
textually.
Passed: a <GtkPicture>.
Returned: a string, or #f.
the alternative textual description of self.
Returns whether the <GtkPicture> respects its
contents size.
Passed: a <GtkPicture>.
Returned: a boolean.
#t if the picture can be made smaller than its contents
Returns the fit mode for the content of the
<GtkPicture>.
See <GtkContentFit> for details.
Passed: a <GtkPicture>.
Returned: a <GtkContentFit>.
the content fit mode
Gets the <GFile> currently displayed if
self is displaying a file.
If self is not displaying a file, for example when
picture:set-paintable was used, then
#f is returned.
Passed: a <GtkPicture>.
Returned: a <GFile>, or #f.
The <GFile> displayed by self.
Returns whether the contents are isolated.
Passed: a <GtkPicture>.
Returned: a boolean.
True if contents are isolated
Returns whether the <GtkPicture> preserves its
contents aspect ratio.
Passed: a <GtkPicture>.
Returned: a boolean.
#t if the self tries to keep the contents’ aspect ratio
Gets the <GdkPaintable> being displayed by
the <GtkPicture>.
Passed: a <GtkPicture>.
Returned: a <GdkPaintable>, or #f.
the displayed paintable
Creates a new empty <GtkPicture> widget.
Returned: a <GtkWidget>.
a newly created <GtkPicture> widget.
Creates a new <GtkPicture> displaying the given
file.
If the file isn’t found or can’t be loaded, the resulting
<GtkPicture> is empty.
If you need to detect failures to load the file, use an image loading
framework such as libglycin to load the file yourself, then create the
<GtkPicture> from the texture.
Passed, or left out: a <GFile>, or #f.
a <GFile>
Returned: a <GtkWidget>.
a new <GtkPicture>
Creates a new <GtkPicture> displaying the file
filename.
This is a utility function that calls picture:new-for-file. See that function for details.
Passed, or left out: a file name, as a string, or #f.
a filename
Returned: a <GtkWidget>.
a new <GtkPicture>
Creates a new <GtkPicture> displaying
paintable.
The <GtkPicture> will track changes to the
paintable and update its size and contents in response to it.
Passed, or left out: a <GdkPaintable>, or
#f.
Returned: a <GtkWidget>.
a new <GtkPicture>
Creates a new <GtkPicture> displaying
pixbuf.
This is a utility function that calls picture:new-for-paintable, See that function for
details.
The pixbuf must not be modified after passing it to this function.
Passed, or left out: a <GdkPixbuf>, or
#f.
Returned: a <GtkWidget>.
a new <GtkPicture>
Creates a new <GtkPicture> displaying the resource
at resource-path.
This is a utility function that calls picture:new-for-file. See that function for details.
Passed, or left out: a string, or #f.
resource path to play back
Returned: a <GtkWidget>.
a new <GtkPicture>
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
#f.
Passed: a <GtkPicture>.
Passed, or left out: a string, or #f.
a textual description of the contents
If set to #t, then 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
widget:set-size-request.
Also of note is that a similar function for growing does not exist
because the grow behavior can be controlled via widget:set-halign and widget:set-valign.
Passed: a <GtkPicture>.
Passed: a boolean.
if self can be made smaller than its contents
Sets how the content should be resized to fit the
<GtkPicture>.
See <GtkContentFit> for details.
Passed: a <GtkPicture>.
Passed: a <GtkContentFit>, or one of its
symbols.
the content fit mode
Makes self load and display file.
See picture:new-for-file for details.
::: warning Note that this function should not be used with untrusted
data. Use a proper image loading framework such as libglycin, which can
load many image formats into a <GdkTexture>,
and then use image:set-from-paintable.
Passed: a <GtkPicture>.
Passed, or left out: a <GFile>, or #f.
a <GFile>
Makes self load and display the given filename.
This is a utility function that calls picture:set-file.
::: warning Note that this function should not be used with untrusted
data. Use a proper image loading framework such as libglycin, which can
load many image formats into a <GdkTexture>,
and then use image:set-from-paintable.
Passed: a <GtkPicture>.
Passed, or left out: a file name, as a string, or #f.
the filename to play
If set to true, then the contents will be rendered individually.
If set to false they will be able to erase or otherwise mix with the background.
GTK supports finer grained isolation, in rare cases where you need this,
you can use snapshot:push-isolation yourself to achieve this.
By default contents are isolated.
Passed: a <GtkPicture>.
Passed: a boolean.
if contents are rendered separately
If set to #t, 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 #f or if the contents provide no aspect ratio, the
contents will be stretched over the picture’s whole area.
Passed: a <GtkPicture>.
Passed: a boolean.
whether to keep aspect ratio
Makes self display the given paintable.
If paintable is NULL, nothing will be displayed.
See picture:new-for-paintable
for details.
Passed: a <GtkPicture>.
Passed, or left out: a <GdkPaintable>, or
#f.
Sets a <GtkPicture> to show a
<GdkPixbuf>.
See picture:new-for-pixbuf for
details.
This is a utility function that calls picture:set-paintable.
Passed: a <GtkPicture>.
Passed, or left out: a <GdkPixbuf>, or
#f.
Makes self load and display the resource at the given resource-path.
This is a utility function that calls picture:set-file.
Passed: a <GtkPicture>.
Passed, or left out: a string, or #f.
the resource to set