Gly.Loader

g GObject.Object GObject.Object Gly.Loader Gly.Loader GObject.Object->Gly.Loader

Subclasses:

None

Methods

Inherited:

GObject.Object (37)

Structs:

GObject.ObjectClass (5)

class

get_mime_types ()

class

get_mime_types_async (cancellable, callback, *user_data)

class

get_mime_types_finish (result)

class

new (file)

class

new_for_bytes (bytes)

class

new_for_stream (stream)

load ()

load_async (cancellable, callback, *user_data)

load_finish (result)

set_accepted_memory_formats (memory_format_selection)

set_apply_transformations (apply_transformations)

set_sandbox_selector (sandbox_selector)

Virtual Methods

Inherited:

GObject.Object (7)

Properties

Name

Type

Flags

Short Description

apply-transformation

bool

r/w

bytes

GLib.Bytes

r/w/co

cancellable

Gio.Cancellable

r/w

file

Gio.File

r/w/co

memory-format-selection

Gly.MemoryFormatSelection

r/w

sandbox-selector

Gly.SandboxSelector

r/w

stream

Gio.InputStream

r/w/co

Signals

Inherited:

GObject.Object (1)

Fields

Inherited:

GObject.Object (1)

Class Details

class Gly.Loader(**kwargs)
Bases:

GObject.Object

Abstract:

No

Structure:

Gly.LoaderClass

[class`Loader`] prepares loading an image.

The following example shows how to obtain a Gdk.Texture. It uses GlyGtk4 for this.

```c #include <glycin-gtk4.h>

file = Gio.File.new_for_path (“test.png”); loader = Gly.Loader.new (file); image = Gly.Loader.load (loader, None); if (image) { frame = Gly.Image.next_frame (image, None); if (frame) { texture = gly_gtk_frame_get_texture (frame); g_print (“Image height: %d\n”, gdk_texture_get_height (texture)); image_widget = gtk_image_new_from_paintable (GDK_PAINTABLE (texture)); } } ```

New in version 2.0.

classmethod get_mime_types()
Returns:

List of supported MIME types

Return type:

[str]

Returns a list of MIME types currently supported for loading images.

This list is generated from the config on first use of a loader or call of this function and cached afterwards. Hence, the first call can be blocking.

New in version 2.0.

classmethod get_mime_types_async(cancellable, callback, *user_data)
Parameters:

Async variant of [func`Loader`.get_mime_types]

New in version 2.0.

classmethod get_mime_types_finish(result)
Parameters:

result (Gio.AsyncResult) – A GAsyncResult

Raises:

GLib.Error

Returns:

Mime types.

Return type:

[str]

Finishes the [func`Loader`.get_mime_types_async] call.

New in version 2.0.

classmethod new(file)
Parameters:

file (Gio.File) – A file from which to load the image data

Returns:

a new [class`Loader`]

Return type:

Gly.Loader

Creates a new loader for a file.

New in version 2.0.

classmethod new_for_bytes(bytes)
Parameters:

bytes (GLib.Bytes) – Data from which to load the image

Returns:

a new [class`Loader`]

Return type:

Gly.Loader

Creates a new loader for bytes.

New in version 2.0.

classmethod new_for_stream(stream)
Parameters:

stream (Gio.InputStream) – A stream from which to load the image data

Returns:

a new [class`Loader`]

Return type:

Gly.Loader

Creates a new loader for a stream.

New in version 2.0.

load()
Raises:

GLib.Error

Returns:

a new [class`Image`] on success, or NULL with error filled in

Return type:

Gly.Image

Synchronously loads an image and returns an [class`Image`] when successful.

New in version 2.0.

load_async(cancellable, callback, *user_data)
Parameters:

Asynchronous version of [method`Loader`.load].

New in version 2.0.

load_finish(result)
Parameters:

result (Gio.AsyncResult) – A GAsyncResult

Raises:

GLib.Error

Returns:

Loaded image.

Return type:

Gly.Image

Finishes the [method`Loader`.load_async] call.

New in version 2.0.

set_accepted_memory_formats(memory_format_selection)
Parameters:

memory_format_selection (Gly.MemoryFormatSelection) – Accepted memory formats

Sets which memory formats can be returned by the loader

If the memory format doesn’t match one of the selected formats, the format will be transformed into the best suitable format selected.

New in version 2.0.

set_apply_transformations(apply_transformations)
Parameters:

apply_transformations (bool) –

Set whether to apply transformations to texture

When enabled, transformations like image orientation are applied to the texture data.

This option is enabled by default.

New in version 2.0.

set_sandbox_selector(sandbox_selector)
Parameters:

sandbox_selector (Gly.SandboxSelector) – Method by which the sandbox mechanism is selected

Selects which sandbox mechanism should be used. The default without calling this function is [enum`SandboxSelector`]``.AUTO``.

New in version 2.0.

Property Details

Gly.Loader.props.apply_transformation
Name:

apply-transformation

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE

Gly.Loader.props.bytes
Name:

bytes

Type:

GLib.Bytes

Default Value:

None

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

Gly.Loader.props.cancellable
Name:

cancellable

Type:

Gio.Cancellable

Default Value:

None

Flags:

READABLE, WRITABLE

Gly.Loader.props.file
Name:

file

Type:

Gio.File

Default Value:

None

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

Gly.Loader.props.memory_format_selection
Name:

memory-format-selection

Type:

Gly.MemoryFormatSelection

Default Value:

0

Flags:

READABLE, WRITABLE

Gly.Loader.props.sandbox_selector
Name:

sandbox-selector

Type:

Gly.SandboxSelector

Default Value:

Gly.SandboxSelector.AUTO

Flags:

READABLE, WRITABLE

Gly.Loader.props.stream
Name:

stream

Type:

Gio.InputStream

Default Value:

None

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY