Struct gdk_pixbuf::Pixbuf [−][src]
pub struct Pixbuf(_);
Expand description
This is the main structure in the gdk-pixbuf library. It is used to represent images. It contains information about the image’s pixel data, its color space, bits per sample, width and height, and the rowstride (the number of bytes between the start of one row and the start of the next).
Implements
Implementations
Creates a new Pixbuf
structure and allocates a buffer for it. The
buffer has an optimal rowstride. Note that the buffer is not cleared;
you will have to fill it completely yourself.
colorspace
Color space for image
has_alpha
Whether the image should have transparency information
bits_per_sample
Number of bits per color sample
width
Width of image in pixels, must be > 0
height
Height of image in pixels, must be > 0
Returns
A newly-created Pixbuf
with a reference count of 1, or
None
if not enough memory could be allocated for the image buffer.
pub fn from_bytes(
data: &Bytes,
colorspace: Colorspace,
has_alpha: bool,
bits_per_sample: i32,
width: i32,
height: i32,
rowstride: i32
) -> Pixbuf
pub fn from_bytes(
data: &Bytes,
colorspace: Colorspace,
has_alpha: bool,
bits_per_sample: i32,
width: i32,
height: i32,
rowstride: i32
) -> Pixbuf
Creates a new Pixbuf
out of in-memory readonly image data.
Currently only RGB images with 8 bits per sample are supported.
This is the glib::Bytes
variant of gdk_pixbuf_new_from_data()
.
data
Image data in 8-bit/sample packed format inside a glib::Bytes
colorspace
Colorspace for the image data
has_alpha
Whether the data has an opacity channel
bits_per_sample
Number of bits per sample
width
Width of the image in pixels, must be > 0
height
Height of the image in pixels, must be > 0
rowstride
Distance in bytes between row starts
Returns
A newly-created Pixbuf
structure with a reference count of 1.
Creates a new pixbuf by loading an image from an resource.
The file format is detected automatically. If None
is returned, then
error
will be set.
resource_path
the path of the resource file
Returns
A newly-created pixbuf, or None
if any of several error
conditions occurred: the file could not be opened, the image format is
not supported, there was not enough memory to allocate the image buffer,
the stream contained invalid data, or the operation was cancelled.
Creates a new pixbuf by loading an image from an resource.
The file format is detected automatically. If None
is returned, then
error
will be set.
The image will be scaled to fit in the requested size, optionally
preserving the image’s aspect ratio. When preserving the aspect ratio,
a width
of -1 will cause the image to be scaled to the exact given
height, and a height
of -1 will cause the image to be scaled to the
exact given width. When not preserving aspect ratio, a width
or
height
of -1 means to not scale the image at all in that dimension.
The stream is not closed.
resource_path
the path of the resource file
width
The width the image should have or -1 to not constrain the width
height
The height the image should have or -1 to not constrain the height
preserve_aspect_ratio
true
to preserve the image’s aspect ratio
Returns
A newly-created pixbuf, or None
if any of several error
conditions occurred: the file could not be opened, the image format is
not supported, there was not enough memory to allocate the image buffer,
the stream contained invalid data, or the operation was cancelled.
pub fn from_stream<P: IsA<InputStream>, Q: IsA<Cancellable>>(
stream: &P,
cancellable: Option<&Q>
) -> Result<Pixbuf, Error>
pub fn from_stream<P: IsA<InputStream>, Q: IsA<Cancellable>>(
stream: &P,
cancellable: Option<&Q>
) -> Result<Pixbuf, Error>
Creates a new pixbuf by loading an image from an input stream.
The file format is detected automatically. If None
is returned, then
error
will be set. The cancellable
can be used to abort the operation
from another thread. If the operation was cancelled, the error
G_IO_ERROR_CANCELLED
will be returned. Other possible errors are in
the GDK_PIXBUF_ERROR
and G_IO_ERROR
domains.
The stream is not closed.
stream
a gio::InputStream
to load the pixbuf from
cancellable
optional gio::Cancellable
object, None
to ignore
Returns
A newly-created pixbuf, or None
if any of several error
conditions occurred: the file could not be opened, the image format is
not supported, there was not enough memory to allocate the image buffer,
the stream contained invalid data, or the operation was cancelled.
pub fn from_stream_at_scale<P: IsA<InputStream>, Q: IsA<Cancellable>>(
stream: &P,
width: i32,
height: i32,
preserve_aspect_ratio: bool,
cancellable: Option<&Q>
) -> Result<Pixbuf, Error>
pub fn from_stream_at_scale<P: IsA<InputStream>, Q: IsA<Cancellable>>(
stream: &P,
width: i32,
height: i32,
preserve_aspect_ratio: bool,
cancellable: Option<&Q>
) -> Result<Pixbuf, Error>
Creates a new pixbuf by loading an image from an input stream.
The file format is detected automatically. If None
is returned, then
error
will be set. The cancellable
can be used to abort the operation
from another thread. If the operation was cancelled, the error
G_IO_ERROR_CANCELLED
will be returned. Other possible errors are in
the GDK_PIXBUF_ERROR
and G_IO_ERROR
domains.
The image will be scaled to fit in the requested size, optionally preserving the image’s aspect ratio.
When preserving the aspect ratio, a width
of -1 will cause the image to be
scaled to the exact given height, and a height
of -1 will cause the image
to be scaled to the exact given width. If both width
and height
are
given, this function will behave as if the smaller of the two values
is passed as -1.
When not preserving aspect ratio, a width
or height
of -1 means to not
scale the image at all in that dimension.
The stream is not closed.
stream
a gio::InputStream
to load the pixbuf from
width
The width the image should have or -1 to not constrain the width
height
The height the image should have or -1 to not constrain the height
preserve_aspect_ratio
true
to preserve the image’s aspect ratio
cancellable
optional gio::Cancellable
object, None
to ignore
Returns
A newly-created pixbuf, or None
if any of several error
conditions occurred: the file could not be opened, the image format is
not supported, there was not enough memory to allocate the image buffer,
the stream contained invalid data, or the operation was cancelled.
Takes an existing pixbuf and adds an alpha channel to it. If the existing pixbuf already had an alpha channel, the channel values are copied from the original; otherwise, the alpha channel is initialized to 255 (full opacity).
If substitute_color
is true
, then the color specified by (r
, g
, b
) will be
assigned zero opacity. That is, if you pass (255, 255, 255) for the
substitute color, all white pixels will become fully transparent.
substitute_color
Whether to set a color to zero opacity. If this
is false
, then the (r
, g
, b
) arguments will be ignored.
r
Red value to substitute.
g
Green value to substitute.
b
Blue value to substitute.
Returns
A newly-created pixbuf with a reference count of 1.
Takes an existing pixbuf and checks for the presence of an associated “orientation” option, which may be provided by the jpeg loader (which reads the exif orientation tag) or the tiff loader (which reads the tiff orientation tag, and compensates it for the partial transforms performed by libtiff). If an orientation option/tag is present, the appropriate transform will be performed so that the pixbuf is oriented correctly.
Returns
A newly-created pixbuf, None
if
not enough memory could be allocated for it, or a reference to the
input pixbuf (with an increased reference count).
Creates a transformation of the source image self
by scaling by
scale_x
and scale_y
then translating by offset_x
and offset_y
.
This gives an image in the coordinates of the destination pixbuf.
The rectangle (dest_x
, dest_y
, dest_width
, dest_height
)
is then alpha blended onto the corresponding rectangle of the
original destination image.
When the destination rectangle contains parts not in the source image, the data at the edges of the source image is replicated to infinity.
dest
the Pixbuf
into which to render the results
dest_x
the left coordinate for region to render
dest_y
the top coordinate for region to render
dest_width
the width of the region to render
dest_height
the height of the region to render
offset_x
the offset in the X direction (currently rounded to an integer)
offset_y
the offset in the Y direction (currently rounded to an integer)
scale_x
the scale factor in the X direction
scale_y
the scale factor in the Y direction
interp_type
the interpolation type for the transformation.
overall_alpha
overall alpha for source image (0..255)
Creates a transformation of the source image self
by scaling by
scale_x
and scale_y
then translating by offset_x
and offset_y
,
then alpha blends the rectangle (dest_x
,dest_y
, dest_width
,
dest_height
) of the resulting image with a checkboard of the
colors color1
and color2
and renders it onto the destination
image.
If the source image has no alpha channel, and overall_alpha
is 255, a fast
path is used which omits the alpha blending and just performs the scaling.
See composite_color_simple()
for a simpler variant of this
function suitable for many tasks.
dest
the Pixbuf
into which to render the results
dest_x
the left coordinate for region to render
dest_y
the top coordinate for region to render
dest_width
the width of the region to render
dest_height
the height of the region to render
offset_x
the offset in the X direction (currently rounded to an integer)
offset_y
the offset in the Y direction (currently rounded to an integer)
scale_x
the scale factor in the X direction
scale_y
the scale factor in the Y direction
interp_type
the interpolation type for the transformation.
overall_alpha
overall alpha for source image (0..255)
check_x
the X offset for the checkboard (origin of checkboard is at -check_x
, -check_y
)
check_y
the Y offset for the checkboard
check_size
the size of checks in the checkboard (must be a power of two)
color1
the color of check at upper left
color2
the color of the other check
Creates a new Pixbuf
by scaling self
to dest_width
x
dest_height
and alpha blending the result with a checkboard of colors
color1
and color2
.
dest_width
the width of destination image
dest_height
the height of destination image
interp_type
the interpolation type for the transformation.
overall_alpha
overall alpha for source image (0..255)
check_size
the size of checks in the checkboard (must be a power of two)
color1
the color of check at upper left
color2
the color of the other check
Returns
the new Pixbuf
, or None
if not enough memory could be
allocated for it.
Creates a new Pixbuf
with a copy of the information in the specified
self
. Note that this does not copy the options set on the original Pixbuf
,
use copy_options()
for this.
Returns
A newly-created pixbuf with a reference count of 1, or None
if
not enough memory could be allocated.
Copies a rectangular area from self
to dest_pixbuf
. Conversion of
pixbuf formats is done automatically.
If the source rectangle overlaps the destination rectangle on the same pixbuf, it will be overwritten during the copy operation. Therefore, you can not use this function to scroll a pixbuf.
src_x
Source X coordinate within self
.
src_y
Source Y coordinate within self
.
width
Width of the area to copy.
height
Height of the area to copy.
dest_pixbuf
Destination pixbuf.
dest_x
X coordinate within dest_pixbuf
.
dest_y
Y coordinate within dest_pixbuf
.
This is supported on crate feature v2_36
only.
v2_36
only.Copy the key/value pair options attached to a Pixbuf
to another.
This is useful to keep original metadata after having manipulated
a file. However be careful to remove metadata which you’ve already
applied, such as the “orientation” option after rotating the image.
dest_pixbuf
the Pixbuf
to copy options to
Returns
true
on success.
Clears a pixbuf to the given RGBA value, converting the RGBA value into the pixbuf’s pixel format. The alpha will be ignored if the pixbuf doesn’t have an alpha channel.
pixel
RGBA pixel to clear to (0xffffffff is opaque white, 0x00000000 transparent black)
Looks up key
in the list of options that may have been attached to the
self
when it was loaded, or that may have been attached by another
function using set_option()
.
For instance, the ANI loader provides “Title” and “Artist” options. The ICO, XBM, and XPM loaders provide “x_hot” and “y_hot” hot-spot options for cursor definitions. The PNG loader provides the tEXt ancillary chunk key/value pairs as options. Since 2.12, the TIFF and JPEG loaders return an “orientation” option string that corresponds to the embedded TIFF/Exif orientation tag (if present). Since 2.32, the TIFF loader sets the “multipage” option string to “yes” when a multi-page TIFF is loaded. Since 2.32 the JPEG and PNG loaders set “x-dpi” and “y-dpi” if the file contains image density information in dots per inch. Since 2.36.6, the JPEG loader sets the “comment” option with the comment EXIF tag.
key
a nul-terminated string.
Returns
the value associated with key
. This is a nul-terminated
string that should not be freed or None
if key
was not found.
Queries the rowstride of a pixbuf, which is the number of bytes between the start of a row and the start of the next row.
Returns
Distance between row starts.
Creates a new pixbuf which represents a sub-region of self
.
The new pixbuf shares its pixels with the original pixbuf, so
writing to one affects both. The new pixbuf holds a reference to
self
, so self
will not be finalized until the new
pixbuf is finalized.
Note that if self
is read-only, this function will force it
to be mutable.
src_x
X coord in self
src_y
Y coord in self
width
width of region in self
height
height of region in self
Returns
a new pixbuf
Provides a glib::Bytes
buffer containing the raw pixel data; the data
must not be modified. This function allows skipping the implicit
copy that must be made if pixels()
is called on a
read-only pixbuf.
Returns
A new reference to a read-only copy of
the pixel data. Note that for mutable pixbufs, this function will
incur a one-time copy of the pixel data for conversion into the
returned glib::Bytes
.
This is supported on crate feature v2_36
only.
v2_36
only.Modifies saturation and optionally pixelates self
, placing the result in
dest
. self
and dest
may be the same pixbuf with no ill effects. If
saturation
is 1.0 then saturation is not changed. If it’s less than 1.0,
saturation is reduced (the image turns toward grayscale); if greater than
1.0, saturation is increased (the image gets more vivid colors). If pixelate
is true
, then pixels are faded in a checkerboard pattern to create a
pixelated image. self
and dest
must have the same image format, size, and
rowstride.
dest
place to write modified version of self
saturation
saturation factor
pixelate
whether to pixelate
Creates a transformation of the source image self
by scaling by
scale_x
and scale_y
then translating by offset_x
and offset_y
,
then renders the rectangle (dest_x
, dest_y
, dest_width
,
dest_height
) of the resulting image onto the destination image
replacing the previous contents.
Try to use scale_simple()
first, this function is
the industrial-strength power tool you can fall back to if
scale_simple()
isn’t powerful enough.
If the source rectangle overlaps the destination rectangle on the same pixbuf, it will be overwritten during the scaling which results in rendering artifacts.
dest
the Pixbuf
into which to render the results
dest_x
the left coordinate for region to render
dest_y
the top coordinate for region to render
dest_width
the width of the region to render
dest_height
the height of the region to render
offset_x
the offset in the X direction (currently rounded to an integer)
offset_y
the offset in the Y direction (currently rounded to an integer)
scale_x
the scale factor in the X direction
scale_y
the scale factor in the Y direction
interp_type
the interpolation type for the transformation.
pub fn scale_simple(
&self,
dest_width: i32,
dest_height: i32,
interp_type: InterpType
) -> Option<Pixbuf>
pub fn scale_simple(
&self,
dest_width: i32,
dest_height: i32,
interp_type: InterpType
) -> Option<Pixbuf>
Create a new Pixbuf
containing a copy of self
scaled to
dest_width
x dest_height
. Leaves self
unaffected. interp_type
should be InterpType::Nearest
if you want maximum speed (but when
scaling down InterpType::Nearest
is usually unusably ugly). The
default interp_type
should be InterpType::Bilinear
which offers
reasonable quality and speed.
You can scale a sub-portion of self
by creating a sub-pixbuf
pointing into self
; see new_subpixbuf()
.
If dest_width
and dest_height
are equal to the self
width and height, a
copy of self
is returned, avoiding any scaling.
For more complicated scaling/alpha blending see scale()
and composite()
.
dest_width
the width of destination image
dest_height
the height of destination image
interp_type
the interpolation type for the transformation.
Returns
the new Pixbuf
, or None
if not enough memory could be
allocated for it.
pub fn calculate_rowstride(
colorspace: Colorspace,
has_alpha: bool,
bits_per_sample: i32,
width: i32,
height: i32
) -> i32
This is supported on crate feature v2_36_8
only.
pub fn calculate_rowstride(
colorspace: Colorspace,
has_alpha: bool,
bits_per_sample: i32,
width: i32,
height: i32
) -> i32
v2_36_8
only.Calculates the rowstride that an image created with those values would have. This is useful for front-ends and backends that want to sanity check image values without needing to create them.
colorspace
Color space for image
has_alpha
Whether the image should have transparency information
bits_per_sample
Number of bits per color sample
width
Width of image in pixels, must be > 0
height
Height of image in pixels, must be > 0
Returns
the rowstride for the given values, or -1 in case of error.
This is supported on crate feature v2_40
only.
v2_40
only.Initalizes the gdk-pixbuf loader modules referenced by the loaders.cache file present inside that directory.
This is to be used by applications that want to ship certain loaders in a different location from the system ones.
This is needed when the OS or runtime ships a minimal number of loaders so as to reduce the potential attack surface of carefully crafted image files, especially for uncommon file types. Applications that require broader image file types coverage, such as image viewers, would be expected to ship the gdk-pixbuf modules in a separate location, bundled with the application in a separate directory from the OS or runtime- provided modules.
path
Path to directory where the loaders.cache is installed
pub fn from_mut_slice<T: AsMut<[u8]>>(
data: T,
colorspace: Colorspace,
has_alpha: bool,
bits_per_sample: i32,
width: i32,
height: i32,
row_stride: i32
) -> Pixbuf
Creates a Pixbuf
from a type implementing Read
(like File
).
use std::fs::File; use gdk_pixbuf::Pixbuf; let f = File::open("some_file.png").expect("failed to open image"); let pixbuf = Pixbuf::from_read(f).expect("failed to load image");
Creates a new pixbuf by loading an image from a file. The file format is
detected automatically. If None
is returned, then error
will be set.
Possible errors are in the GDK_PIXBUF_ERROR
and G_FILE_ERROR
domains.
filename
Name of file to load, in the GLib file name encoding
Returns
A newly-created pixbuf with a reference count of 1, or None
if
any of several error conditions occurred: the file could not be opened,
there was no loader for the file’s format, there was not enough memory to
allocate the image buffer, or the image file contained invalid data.
Creates a new pixbuf by loading an image from a file.
The file format is detected automatically. If None
is returned, then
error
will be set. Possible errors are in the GDK_PIXBUF_ERROR
and
G_FILE_ERROR
domains.
The image will be scaled to fit in the requested size, preserving
the image’s aspect ratio. Note that the returned pixbuf may be smaller
than width
x height
, if the aspect ratio requires it. To load
and image at the requested size, regardless of aspect ratio, use
from_file_at_scale()
.
filename
Name of file to load, in the GLib file name encoding
width
The width the image should have or -1 to not constrain the width
height
The height the image should have or -1 to not constrain the height
Returns
A newly-created pixbuf with a reference count of 1, or
None
if any of several error conditions occurred: the file could not
be opened, there was no loader for the file’s format, there was not
enough memory to allocate the image buffer, or the image file contained
invalid data.
Creates a new pixbuf by loading an image from a file. The file format is
detected automatically. If None
is returned, then error
will be set.
Possible errors are in the GDK_PIXBUF_ERROR
and G_FILE_ERROR
domains.
The image will be scaled to fit in the requested size, optionally preserving
the image’s aspect ratio.
When preserving the aspect ratio, a width
of -1 will cause the image
to be scaled to the exact given height, and a height
of -1 will cause
the image to be scaled to the exact given width. When not preserving
aspect ratio, a width
or height
of -1 means to not scale the image
at all in that dimension. Negative values for width
and height
are
allowed since 2.8.
filename
Name of file to load, in the GLib file name encoding
width
The width the image should have or -1 to not constrain the width
height
The height the image should have or -1 to not constrain the height
preserve_aspect_ratio
true
to preserve the image’s aspect ratio
Returns
A newly-created pixbuf with a reference count of 1, or None
if any of several error conditions occurred: the file could not be opened,
there was no loader for the file’s format, there was not enough memory to
allocate the image buffer, or the image file contained invalid data.
pub fn from_stream_async<P: IsA<InputStream>, Q: IsA<Cancellable>, R: FnOnce(Result<Pixbuf, Error>) + Send + 'static>(
stream: &P,
cancellable: Option<&Q>,
callback: R
)
pub fn from_stream_async_future<P: IsA<InputStream> + Clone + 'static>(
stream: &P
) -> Pin<Box<dyn Future<Output = Result<Pixbuf, Error>> + 'static>>
pub fn from_stream_at_scale_async<P: IsA<InputStream>, Q: IsA<Cancellable>, R: FnOnce(Result<Pixbuf, Error>) + Send + 'static>(
stream: &P,
width: i32,
height: i32,
preserve_aspect_ratio: bool,
cancellable: Option<&Q>,
callback: R
)
pub fn from_stream_at_scale_async_future<P: IsA<InputStream> + Clone + 'static>(
stream: &P,
width: i32,
height: i32,
preserve_aspect_ratio: bool
) -> Pin<Box<dyn Future<Output = Result<Pixbuf, Error>> + 'static>>
Queries a pointer to the pixel data of a pixbuf.
Returns
A pointer to the pixbuf’s pixel data. Please see the section on [image data][image-data] for information about how the pixel data is stored in memory.
This function will cause an implicit copy of the pixbuf data if the pixbuf was created from read-only data.
Parses an image file far enough to determine its format and size.
filename
The name of the file to identify.
Returns
A PixbufFormat
describing
the image format of the file or None
if the image format wasn’t
recognized. The return value is owned by Pixbuf
and should
not be freed.
width
Return location for the width of the
image, or None
height
Return location for the height of the
image, or None
Asynchronously parses an image file far enough to determine its format and size.
For more details see file_info()
, which is the synchronous
version of this function.
When the operation is finished, callback
will be called in the
main thread. You can then call gdk_pixbuf_get_file_info_finish()
to
get the result of the operation.
filename
The name of the file to identify
cancellable
optional gio::Cancellable
object, None
to ignore
callback
a GAsyncReadyCallback
to call when the file info is available
pub fn file_info_async_future<T: AsRef<Path> + Clone + 'static>(
filename: T
) -> Pin<Box<dyn Future<Output = Result<Option<(PixbufFormat, i32, i32)>, Error>> + 'static>>
Saves pixbuf to a new buffer in format type_
, which is currently “jpeg”,
“tiff”, “png”, “ico” or “bmp”. See gdk_pixbuf_save_to_buffer()
for more details.
type_
name of file format.
option_keys
name of options to set, None
-terminated
option_values
values for named options
Returns
whether an error was set
buffer
location to receive a pointer to the new buffer.
pub fn save_to_streamv<P: IsA<OutputStream>, Q: IsA<Cancellable>>(
&self,
stream: &P,
type_: &str,
options: &[(&str, &str)],
cancellable: Option<&Q>
) -> Result<(), Error>
This is supported on crate feature v2_36
only.
pub fn save_to_streamv<P: IsA<OutputStream>, Q: IsA<Cancellable>>(
&self,
stream: &P,
type_: &str,
options: &[(&str, &str)],
cancellable: Option<&Q>
) -> Result<(), Error>
v2_36
only.Saves self
to an output stream.
Supported file formats are currently “jpeg”, “tiff”, “png”, “ico” or
“bmp”. See gdk_pixbuf_save_to_stream()
for more details.
stream
a gio::OutputStream
to save the pixbuf to
type_
name of file format
option_keys
name of options to set, None
-terminated
option_values
values for named options
cancellable
optional gio::Cancellable
object, None
to ignore
Returns
true
if the pixbuf was saved successfully, false
if an
error was set.
pub fn save_to_streamv_async<P: IsA<OutputStream>, Q: IsA<Cancellable>, R: FnOnce(Result<(), Error>) + Send + 'static>(
&self,
stream: &P,
type_: &str,
options: &[(&str, &str)],
cancellable: Option<&Q>,
callback: R
)
This is supported on crate feature v2_36
only.
pub fn save_to_streamv_async<P: IsA<OutputStream>, Q: IsA<Cancellable>, R: FnOnce(Result<(), Error>) + Send + 'static>(
&self,
stream: &P,
type_: &str,
options: &[(&str, &str)],
cancellable: Option<&Q>,
callback: R
)
v2_36
only.Saves self
to an output stream asynchronously.
For more details see save_to_streamv()
, which is the synchronous
version of this function.
When the operation is finished, callback
will be called in the main thread.
You can then call gdk_pixbuf_save_to_stream_finish()
to get the result of the operation.
stream
a gio::OutputStream
to which to save the pixbuf
type_
name of file format
option_keys
name of options to set, None
-terminated
option_values
values for named options
cancellable
optional gio::Cancellable
object, None
to ignore
callback
a GAsyncReadyCallback
to call when the pixbuf is saved
pub fn save_to_streamv_async_future<P: IsA<OutputStream> + Clone + 'static>(
&self,
stream: &P,
type_: &str,
options: &[(&str, &str)]
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + 'static>>
v2_36
only.Saves pixbuf to a file in type_
, which is currently “jpeg”, “png”, “tiff”, “ico” or “bmp”.
If error
is set, false
will be returned.
See gdk_pixbuf_save () for more details.
filename
name of file to save.
type_
name of file format.
option_keys
name of options to set, None
-terminated
option_values
values for named options
Returns
whether an error was set
Trait Implementations
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
Returns the type identifier of Self
.
Auto Trait Implementations
impl RefUnwindSafe for Pixbuf
impl UnwindSafe for Pixbuf
Blanket Implementations
Mutably borrows from an owned value. Read more
Upcasts an object to a superclass or interface T
. Read more
Upcasts an object to a reference of its superclass or interface T
. Read more
Tries to downcast to a subclass or interface implementor T
. Read more
Tries to downcast to a reference of its subclass or interface implementor T
. Read more
Tries to cast to an object of type T
. This handles upcasting, downcasting
and casting between interface and interface implementors. All checks are performed at
runtime, while downcast
and upcast
will do many checks at compile-time already. Read more
Tries to cast to reference to an object of type T
. This handles upcasting, downcasting
and casting between interface and interface implementors. All checks are performed at
runtime, while downcast
and upcast
will do many checks at compile-time already. Read more
Casts to T
unconditionally. Read more
Casts to &T
unconditionally. Read more
Checks if two icons are equal. Read more
Serializes a Icon
into a glib::Variant
. An equivalent Icon
can be retrieved
back by calling Icon::deserialize()
on the returned value.
As serialization will avoid using raw icon data when possible, it only
makes sense to transfer the glib::Variant
between processes on the same machine,
(as opposed to over the network), and within the same file system namespace. Read more
Loads a loadable icon. For the asynchronous version of this function,
see load_async()
. Read more
pub fn load_async<P, Q>(&self, size: i32, cancellable: Option<&P>, callback: Q) where
P: IsA<Cancellable>,
Q: 'static + FnOnce(Result<(InputStream, GString), Error>) + Send,
pub fn load_async<P, Q>(&self, size: i32, cancellable: Option<&P>, callback: Q) where
P: IsA<Cancellable>,
Q: 'static + FnOnce(Result<(InputStream, GString), Error>) + Send,
Returns true
if the object is an instance of (can be cast to) T
.
pub fn set_properties_from_value(
&self,
property_values: &[(&str, Value)]
) -> Result<(), BoolError>
pub fn set_property<'a, N, V>(
&self,
property_name: N,
value: V
) -> Result<(), BoolError> where
V: ToValue,
N: Into<&'a str>,
pub fn set_property_from_value<'a, N>(
&self,
property_name: N,
value: &Value
) -> Result<(), BoolError> where
N: Into<&'a str>,
Safety Read more
Safety Read more
Safety Read more
Safety Read more
pub fn connect_notify<F>(&self, name: Option<&str>, f: F) -> SignalHandlerId where
F: 'static + Fn(&T, &ParamSpec) + Send + Sync,
pub fn connect_notify_local<F>(
&self,
name: Option<&str>,
f: F
) -> SignalHandlerId where
F: 'static + Fn(&T, &ParamSpec),
pub unsafe fn connect_notify_unsafe<F>(
&self,
name: Option<&str>,
f: F
) -> SignalHandlerId where
F: Fn(&T, &ParamSpec),
pub fn has_property<'a, N>(&self, property_name: N, type_: Option<Type>) -> bool where
N: Into<&'a str>,
pub fn find_property<'a, N>(&self, property_name: N) -> Option<ParamSpec> where
N: Into<&'a str>,
pub fn connect<'a, N, F>(
&self,
signal_name: N,
after: bool,
callback: F
) -> Result<SignalHandlerId, BoolError> where
F: Fn(&[Value]) -> Option<Value> + Send + Sync + 'static,
N: Into<&'a str>,
Same as connect
but takes a SignalId
instead of a signal name.
pub fn connect_local<'a, N, F>(
&self,
signal_name: N,
after: bool,
callback: F
) -> Result<SignalHandlerId, BoolError> where
F: Fn(&[Value]) -> Option<Value> + 'static,
N: Into<&'a str>,
Same as connect_local
but takes a SignalId
instead of a signal name.
pub unsafe fn connect_unsafe<'a, N, F>(
&self,
signal_name: N,
after: bool,
callback: F
) -> Result<SignalHandlerId, BoolError> where
F: Fn(&[Value]) -> Option<Value>,
N: Into<&'a str>,
Same as connect_unsafe
but takes a SignalId
instead of a signal name.
Emit signal by signal id.
Emit signal with details by signal id.
Emit signal by it’s name.
pub fn bind_property<'a, O, N, M>(
&'a self,
source_property: N,
target: &'a O,
target_property: M
) -> BindingBuilder<'a> where
O: ObjectType,
N: Into<&'a str>,
M: Into<&'a str>,
Same as emit
but takes Value
for the arguments.
Same as emit_by_name
but takes Value
for the arguments.
Returns a SendValue
clone of self
.
impl<'a, T, C> FromValueOptional<'a> for T where
C: ValueTypeChecker<Error = ValueTypeMismatchOrNoneError>,
T: FromValue<'a, Checker = C>,