:right-sidebar: True FileLauncher =================================================================== .. currentmodule:: gi.repository.Gtk .. versionadded:: 4.10 .. class:: FileLauncher(**properties: ~typing.Any) :no-contents-entry: Superclasses: :class:`~gi.repository.GObject.Object` A ``GtkFileLauncher`` object collects the arguments that are needed to open a file with an application. Depending on system configuration, user preferences and available APIs, this may or may not show an app chooser dialog or launch the default application right away. The operation is started with the :obj:`~gi.repository.Gtk.FileLauncher.launch` function. To launch uris that don't represent files, use :obj:`~gi.repository.Gtk.UriLauncher`\. Constructors ------------ .. rst-class:: interim-class .. class:: FileLauncher :no-index: .. classmethod:: new(file: ~gi.repository.Gio.File | None = None) -> ~gi.repository.Gtk.FileLauncher Creates a new ``GtkFileLauncher`` object. .. versionadded:: 4.10 :param file: the file to open Methods ------- .. rst-class:: interim-class .. class:: FileLauncher :no-index: .. method:: get_always_ask() -> bool Returns whether to ask the user to choose an app for opening the file. .. versionadded:: 4.12 .. method:: get_file() -> ~gi.repository.Gio.File | None Gets the file that will be opened. .. versionadded:: 4.10 .. method:: get_writable() -> bool Returns whether to make the file writable for the handler. .. versionadded:: 4.14 .. method:: launch(parent: ~gi.repository.Gtk.Window | None = None, cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[~gi.repository.GObject.Object | None, ~gi.repository.Gio.AsyncResult, ~typing.Any], None] | None = None, user_data: ~typing.Any = None) -> None Launch an application to open the file. This may present an app chooser dialog to the user. .. versionadded:: 4.10 :param parent: the parent ``GtkWindow`` :param cancellable: a ``GCancellable`` to cancel the operation :param callback: a callback to call when the operation is complete :param user_data: data to pass to ``callback`` .. method:: launch_finish(result: ~gi.repository.Gio.AsyncResult) -> bool Finishes the :obj:`~gi.repository.Gtk.FileLauncher.launch` call and returns the result. .. versionadded:: 4.10 :param result: a ``GAsyncResult`` .. method:: open_containing_folder(parent: ~gi.repository.Gtk.Window | None = None, cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[~gi.repository.GObject.Object | None, ~gi.repository.Gio.AsyncResult, ~typing.Any], None] | None = None, user_data: ~typing.Any = None) -> None Launch a file manager to show the file in its parent directory. This is only supported native files. It will fail if ``file`` is e.g. a http:// uri. .. versionadded:: 4.10 :param parent: the parent ``GtkWindow`` :param cancellable: a ``GCancellable`` to cancel the operation :param callback: a callback to call when the operation is complete :param user_data: data to pass to ``callback`` .. method:: open_containing_folder_finish(result: ~gi.repository.Gio.AsyncResult) -> bool Finishes the :obj:`~gi.repository.Gtk.FileLauncher.open_containing_folder` call and returns the result. .. versionadded:: 4.10 :param result: a ``GAsyncResult`` .. method:: set_always_ask(always_ask: bool) -> None Sets whether to awlays ask the user to choose an app for opening the file. If ``FALSE``\, the file might be opened with a default app or the previous choice. .. versionadded:: 4.12 :param always_ask: a ``gboolean`` .. method:: set_file(file: ~gi.repository.Gio.File | None = None) -> None Sets the file that will be opened. .. versionadded:: 4.10 :param file: a ``GFile`` .. method:: set_writable(writable: bool) -> None Sets whether to make the file writable for the handler. .. versionadded:: 4.14 :param writable: a ``gboolean`` Properties ---------- .. rst-class:: interim-class .. class:: FileLauncher :no-index: .. attribute:: props.always_ask :type: bool The type of the None singleton. .. versionadded:: 4.12 .. attribute:: props.file :type: ~gi.repository.Gio.File The type of the None singleton. .. versionadded:: 4.10 .. attribute:: props.writable :type: bool The type of the None singleton. .. versionadded:: 4.14