:right-sidebar: True Loader =================================================================== .. currentmodule:: gi.repository.Gly .. versionadded:: 2.0 .. class:: Loader(**properties: ~typing.Any) :no-contents-entry: Superclasses: :class:`~gi.repository.GObject.Object` :obj:`~gi.repository.Gly.Loader` prepares loading an image. The following example shows how to obtain a ``Gdk.Texture``\. It uses `GlyGtk4 `__ for this. .. code-block:: c :dedent: #include file = g_file_new_for_path ("test.png"); loader = gly_loader_new (file); image = gly_loader_load (loader, NULL); if (image) { frame = gly_image_next_frame (image, NULL); 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)); } } Constructors ------------ .. rst-class:: interim-class .. class:: Loader :no-index: .. classmethod:: new(file: ~gi.repository.Gio.File) -> ~gi.repository.Gly.Loader Creates a new loader for a file. .. versionadded:: 2.0 :param file: A file from which to load the image data .. classmethod:: new_for_bytes(bytes: ~gi.repository.GLib.Bytes) -> ~gi.repository.Gly.Loader Creates a new loader for bytes. .. versionadded:: 2.0 :param bytes: Data from which to load the image .. classmethod:: new_for_stream(stream: ~gi.repository.Gio.InputStream) -> ~gi.repository.Gly.Loader Creates a new loader for a stream. .. versionadded:: 2.0 :param stream: A stream from which to load the image data Methods ------- .. rst-class:: interim-class .. class:: Loader :no-index: .. classmethod:: get_mime_types() -> list[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. .. versionadded:: 2.0 .. classmethod:: get_mime_types_async() -> list[str] :async: This is the `awaitable `_ version of :meth:`get_mime_types_async`. .. versionadded:: 2.0 .. classmethod:: get_mime_types_async(callback: ~collections.abc.Callable[[~gi.repository.GObject.Object | None, ~gi.repository.Gio.AsyncResult, ~typing.Any], None] | None = None, user_data: ~typing.Any = None) -> None Async variant of :obj:`~gi.repository.Loader.get_mime_types` .. versionadded:: 2.0 :param callback: :param user_data: user data to pass to ``callback`` .. classmethod:: get_mime_types_finish() -> list[str] Finishes the :obj:`~gi.repository.Loader.get_mime_types_async` call. .. versionadded:: 2.0 .. method:: load() -> ~gi.repository.Gly.Image Synchronously loads an image and returns an :obj:`~gi.repository.Gly.Image` when successful. .. versionadded:: 2.0 .. method:: load_async(self) -> ~gi.repository.Gly.Image :async: This is the `awaitable `_ version of :meth:`load_async`. .. versionadded:: 2.0 .. method:: load_async(cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~collections.abc.Callable[[~gi.repository.GObject.Object | None, ~gi.repository.Gio.AsyncResult, ~typing.Any], None] | None = None, user_data: ~typing.Any = None) -> None Asynchronous version of :obj:`~gi.repository.Loader.load`\. .. versionadded:: 2.0 :param cancellable: A :obj:`~gi.repository.Gio.Cancellable` to cancel the operation :param callback: A callback to call when the operation is complete :param user_data: Data to pass to ``callback`` .. method:: load_finish(result: ~gi.repository.Gio.AsyncResult) -> ~gi.repository.Gly.Image Finishes the :obj:`~gi.repository.Loader.load_async` call. .. versionadded:: 2.0 :param result: A ``GAsyncResult`` .. method:: set_accepted_memory_formats(memory_format_selection: ~gi.repository.Gly.MemoryFormatSelection) -> None 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. .. versionadded:: 2.0 :param memory_format_selection: Accepted memory formats .. method:: set_apply_transformations(apply_transformations: bool) -> None 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. .. versionadded:: 2.0 :param apply_transformations: .. method:: set_sandbox_selector(sandbox_selector: ~gi.repository.Gly.SandboxSelector) -> None Selects which sandbox mechanism should be used. The default without calling this function is :obj:`~gi.repository.Gly.SandboxSelector```.AUTO``\. .. versionadded:: 2.0 :param sandbox_selector: Method by which the sandbox mechanism is selected Properties ---------- .. rst-class:: interim-class .. class:: Loader :no-index: .. attribute:: props.apply_transformation :type: bool The type of the None singleton. .. attribute:: props.bytes :type: ~gi.repository.GLib.Bytes The type of the None singleton. .. attribute:: props.cancellable :type: ~gi.repository.Gio.Cancellable The type of the None singleton. .. attribute:: props.file :type: ~gi.repository.Gio.File The type of the None singleton. .. attribute:: props.memory_format_selection :type: ~gi.repository.Gly.MemoryFormatSelection The type of the None singleton. .. attribute:: props.sandbox_selector :type: ~gi.repository.Gly.SandboxSelector The type of the None singleton. .. attribute:: props.stream :type: ~gi.repository.Gio.InputStream The type of the None singleton.