Gio.Mount¶
interface
The GMount interface represents a user-visible mount, such as a mounted
file system.
GMount is a ‘mounted’ filesystem that you can access. Mounted is in
quotes because it’s not the same as a UNIX mount, it might be a GVFS
mount, but you can still access the files on it if you use GIO.
A GMount might be associated with a Volume (such as a USB flash
drive) which hosts it.
Unmounting a GMount instance is an asynchronous operation. For
more information about asynchronous operations, see AsyncResult
and Task. To unmount a GMount instance, first call
Mount.unmount_with_operation with (at least) the GMount
instance and a AsyncReadyCallback. The callback will be fired
when the operation has resolved (either with success or failure), and a
AsyncResult structure will be passed to the callback. That
callback should then call Mount.unmount_with_operation_finish
with the GMount and the AsyncResult data to see if the
operation was completed successfully. If an error is present when
Mount.unmount_with_operation_finish is called, then it will be
filled with any error information.
Note, when porting from GnomeVFS, GMount is the
moral equivalent of GnomeVFSVolume.
Methods¶
can_eject¶
Checks if mount can be ejected.
can_unmount¶
Checks if mount can be unmounted.
eject¶
def eject(self, flags: MountUnmountFlags | int, cancellable: Cancellable | None = ..., callback: Callable[[Mount | None, AsyncResult], None] | None = ...) -> None
:::warning Deprecated since 2.22 This API is deprecated. :::
Ejects a mount. This is an asynchronous operation, and is
finished by calling Mount.eject_finish with the mount
and AsyncResult data returned in the callback.
Parameters:
flags— flags affecting the unmount if required for ejectcancellable— optionalCancellableobject,Noneto ignore.callback— aGAsyncReadyCallback, orNone.
eject_finish¶
:::warning Deprecated since 2.22 This API is deprecated. :::
Finishes ejecting a mount. If any errors occurred during the operation,
error will be set to contain the errors and False will be returned.
Parameters:
result— aAsyncResult.
eject_with_operation¶
def eject_with_operation(self, flags: MountUnmountFlags | int, mount_operation: MountOperation | None = ..., cancellable: Cancellable | None = ..., callback: Callable[[Mount | None, AsyncResult], None] | None = ...) -> None
Ejects a mount. This is an asynchronous operation, and is
finished by calling Mount.eject_with_operation_finish with the mount
and AsyncResult data returned in the callback.
Parameters:
flags— flags affecting the unmount if required for ejectmount_operation— aMountOperationorNoneto avoid user interaction.cancellable— optionalCancellableobject,Noneto ignore.callback— aGAsyncReadyCallback, orNone.
eject_with_operation_finish¶
Finishes ejecting a mount. If any errors occurred during the operation,
error will be set to contain the errors and False will be returned.
Parameters:
result— aAsyncResult.
get_default_location¶
Gets the default location of mount. The default location of the given
mount is a path that reflects the main entry point for the user (e.g.
the home directory, or the root of the volume).
get_drive¶
Gets the drive for the mount.
This is a convenience method for getting the Volume and then
using that object to get the Drive.
get_icon¶
Gets the icon for mount.
get_name¶
Gets the name of mount.
get_root¶
Gets the root directory on mount.
get_sort_key¶
Gets the sort key for mount, if any.
get_symbolic_icon¶
Gets the symbolic icon for mount.
get_uuid¶
Gets the UUID for the mount. The reference is typically based on
the file system UUID for the mount in question and should be
considered an opaque string. Returns None if there is no UUID
available.
get_volume¶
Gets the volume for the mount.
guess_content_type¶
def guess_content_type(self, force_rescan: bool, cancellable: Cancellable | None = ..., callback: Callable[[Mount | None, AsyncResult], None] | None = ...) -> None
Tries to guess the type of content stored on mount. Returns one or
more textual identifiers of well-known content types (typically
prefixed with "x-content/"), e.g. x-content/image-dcf for camera
memory cards. See the
shared-mime-info
specification for more on x-content types.
This is an asynchronous operation (see
Mount.guess_content_type_sync for the synchronous version), and
is finished by calling Mount.guess_content_type_finish with the
mount and AsyncResult data returned in the callback.
Parameters:
force_rescan— Whether to force a rescan of the content. Otherwise a cached result will be used if availablecancellable— optionalCancellableobject,Noneto ignorecallback— aGAsyncReadyCallback
guess_content_type_finish¶
Finishes guessing content types of mount. If any errors occurred
during the operation, error will be set to contain the errors and
False will be returned. In particular, you may get an
IOErrorEnum.NOT_SUPPORTED if the mount does not support content
guessing.
Parameters:
result— aAsyncResult
guess_content_type_sync¶
def guess_content_type_sync(self, force_rescan: bool, cancellable: Cancellable | None = ...) -> list[str]
Tries to guess the type of content stored on mount. Returns one or
more textual identifiers of well-known content types (typically
prefixed with "x-content/"), e.g. x-content/image-dcf for camera
memory cards. See the
shared-mime-info
specification for more on x-content types.
This is a synchronous operation and as such may block doing IO;
see Mount.guess_content_type for the asynchronous version.
Parameters:
force_rescan— Whether to force a rescan of the content. Otherwise a cached result will be used if availablecancellable— optionalCancellableobject,Noneto ignore
is_shadowed¶
Determines if mount is shadowed. Applications or libraries should
avoid displaying mount in the user interface if it is shadowed.
A mount is said to be shadowed if there exists one or more user
visible objects (currently Mount objects) with a root that is
inside the root of mount.
One application of shadow mounts is when exposing a single file
system that is used to address several logical volumes. In this
situation, a VolumeMonitor implementation would create two
Volume objects (for example, one for the camera functionality of
the device and one for a SD card reader on the device) with
activation URIs gphoto2://[usb:001,002]/store1/
and gphoto2://[usb:001,002]/store2/. When the
underlying mount (with root
gphoto2://[usb:001,002]/) is mounted, said
VolumeMonitor implementation would create two Mount objects
(each with their root matching the corresponding volume activation
root) that would shadow the original mount.
The proxy monitor in GVfs 2.26 and later, automatically creates and
manage shadow mounts (and shadows the underlying mount) if the
activation root on a Volume is set.
remount¶
def remount(self, flags: MountMountFlags | int, mount_operation: MountOperation | None = ..., cancellable: Cancellable | None = ..., callback: Callable[[Mount | None, AsyncResult], None] | None = ...) -> None
Remounts a mount. This is an asynchronous operation, and is
finished by calling Mount.remount_finish with the mount
and GAsyncResults data returned in the callback.
Remounting is useful when some setting affecting the operation of the volume has been changed, as these may need a remount to take affect. While this is semantically equivalent with unmounting and then remounting not all backends might need to actually be unmounted.
Parameters:
flags— flags affecting the operationmount_operation— aMountOperationorNoneto avoid user interaction.cancellable— optionalCancellableobject,Noneto ignore.callback— aGAsyncReadyCallback, orNone.
remount_finish¶
Finishes remounting a mount. If any errors occurred during the operation,
error will be set to contain the errors and False will be returned.
Parameters:
result— aAsyncResult.
shadow¶
Increments the shadow count on mount. Usually used by
VolumeMonitor implementations when creating a shadow mount for
mount, see Mount.is_shadowed for more information. The caller
will need to emit the Mount::changed signal on mount manually.
unmount¶
def unmount(self, flags: MountUnmountFlags | int, cancellable: Cancellable | None = ..., callback: Callable[[Mount | None, AsyncResult], None] | None = ...) -> None
:::warning Deprecated since 2.22 This API is deprecated. :::
Unmounts a mount. This is an asynchronous operation, and is
finished by calling Mount.unmount_finish with the mount
and AsyncResult data returned in the callback.
Parameters:
flags— flags affecting the operationcancellable— optionalCancellableobject,Noneto ignore.callback— aGAsyncReadyCallback, orNone.
unmount_finish¶
:::warning Deprecated since 2.22 This API is deprecated. :::
Finishes unmounting a mount. If any errors occurred during the operation,
error will be set to contain the errors and False will be returned.
Parameters:
result— aAsyncResult.
unmount_with_operation¶
def unmount_with_operation(self, flags: MountUnmountFlags | int, mount_operation: MountOperation | None = ..., cancellable: Cancellable | None = ..., callback: Callable[[Mount | None, AsyncResult], None] | None = ...) -> None
Unmounts a mount. This is an asynchronous operation, and is
finished by calling Mount.unmount_with_operation_finish with the mount
and AsyncResult data returned in the callback.
Parameters:
flags— flags affecting the operationmount_operation— aMountOperationorNoneto avoid user interaction.cancellable— optionalCancellableobject,Noneto ignore.callback— aGAsyncReadyCallback, orNone.
unmount_with_operation_finish¶
Finishes unmounting a mount. If any errors occurred during the operation,
error will be set to contain the errors and False will be returned.
Parameters:
result— aAsyncResult.
unshadow¶
Decrements the shadow count on mount. Usually used by
VolumeMonitor implementations when destroying a shadow mount for
mount, see Mount.is_shadowed for more information. The caller
will need to emit the Mount::changed signal on mount manually.
Virtual methods¶
do_can_eject¶
Checks if mount can be ejected.
do_can_unmount¶
Checks if mount can be unmounted.
do_changed¶
Changed signal that is emitted when the mount's state has changed.
do_eject¶
def do_eject(self, flags: MountUnmountFlags | int, cancellable: Cancellable | None = ..., callback: Callable[[Mount | None, AsyncResult], None] | None = ...) -> None
:::warning Deprecated since 2.22 This API is deprecated. :::
Ejects a mount. This is an asynchronous operation, and is
finished by calling Mount.eject_finish with the mount
and AsyncResult data returned in the callback.
Parameters:
flags— flags affecting the unmount if required for ejectcancellable— optionalCancellableobject,Noneto ignore.callback— aGAsyncReadyCallback, orNone.
do_eject_finish¶
:::warning Deprecated since 2.22 This API is deprecated. :::
Finishes ejecting a mount. If any errors occurred during the operation,
error will be set to contain the errors and False will be returned.
Parameters:
result— aAsyncResult.
do_eject_with_operation¶
def do_eject_with_operation(self, flags: MountUnmountFlags | int, mount_operation: MountOperation | None = ..., cancellable: Cancellable | None = ..., callback: Callable[[Mount | None, AsyncResult], None] | None = ...) -> None
Ejects a mount. This is an asynchronous operation, and is
finished by calling Mount.eject_with_operation_finish with the mount
and AsyncResult data returned in the callback.
Parameters:
flags— flags affecting the unmount if required for ejectmount_operation— aMountOperationorNoneto avoid user interaction.cancellable— optionalCancellableobject,Noneto ignore.callback— aGAsyncReadyCallback, orNone.
do_eject_with_operation_finish¶
Finishes ejecting a mount. If any errors occurred during the operation,
error will be set to contain the errors and False will be returned.
Parameters:
result— aAsyncResult.
do_get_default_location¶
Gets the default location of mount. The default location of the given
mount is a path that reflects the main entry point for the user (e.g.
the home directory, or the root of the volume).
do_get_drive¶
Gets the drive for the mount.
This is a convenience method for getting the Volume and then
using that object to get the Drive.
do_get_icon¶
Gets the icon for mount.
do_get_name¶
Gets the name of mount.
do_get_root¶
Gets the root directory on mount.
do_get_sort_key¶
Gets the sort key for mount, if any.
do_get_symbolic_icon¶
Gets the symbolic icon for mount.
do_get_uuid¶
Gets the UUID for the mount. The reference is typically based on
the file system UUID for the mount in question and should be
considered an opaque string. Returns None if there is no UUID
available.
do_get_volume¶
Gets the volume for the mount.
do_guess_content_type¶
def do_guess_content_type(self, force_rescan: bool, cancellable: Cancellable | None = ..., callback: Callable[[Mount | None, AsyncResult], None] | None = ...) -> None
Tries to guess the type of content stored on mount. Returns one or
more textual identifiers of well-known content types (typically
prefixed with "x-content/"), e.g. x-content/image-dcf for camera
memory cards. See the
shared-mime-info
specification for more on x-content types.
This is an asynchronous operation (see
Mount.guess_content_type_sync for the synchronous version), and
is finished by calling Mount.guess_content_type_finish with the
mount and AsyncResult data returned in the callback.
Parameters:
force_rescan— Whether to force a rescan of the content. Otherwise a cached result will be used if availablecancellable— optionalCancellableobject,Noneto ignorecallback— aGAsyncReadyCallback
do_guess_content_type_finish¶
Finishes guessing content types of mount. If any errors occurred
during the operation, error will be set to contain the errors and
False will be returned. In particular, you may get an
IOErrorEnum.NOT_SUPPORTED if the mount does not support content
guessing.
Parameters:
result— aAsyncResult
do_guess_content_type_sync¶
def do_guess_content_type_sync(self, force_rescan: bool, cancellable: Cancellable | None = ...) -> list[str]
Tries to guess the type of content stored on mount. Returns one or
more textual identifiers of well-known content types (typically
prefixed with "x-content/"), e.g. x-content/image-dcf for camera
memory cards. See the
shared-mime-info
specification for more on x-content types.
This is a synchronous operation and as such may block doing IO;
see Mount.guess_content_type for the asynchronous version.
Parameters:
force_rescan— Whether to force a rescan of the content. Otherwise a cached result will be used if availablecancellable— optionalCancellableobject,Noneto ignore
do_pre_unmount¶
The ::pre-unmount signal that is emitted when the Mount will soon be emitted. If the recipient is somehow holding the mount open by keeping an open file on it it should close the file.
do_remount¶
def do_remount(self, flags: MountMountFlags | int, mount_operation: MountOperation | None = ..., cancellable: Cancellable | None = ..., callback: Callable[[Mount | None, AsyncResult], None] | None = ...) -> None
Remounts a mount. This is an asynchronous operation, and is
finished by calling Mount.remount_finish with the mount
and GAsyncResults data returned in the callback.
Remounting is useful when some setting affecting the operation of the volume has been changed, as these may need a remount to take affect. While this is semantically equivalent with unmounting and then remounting not all backends might need to actually be unmounted.
Parameters:
flags— flags affecting the operationmount_operation— aMountOperationorNoneto avoid user interaction.cancellable— optionalCancellableobject,Noneto ignore.callback— aGAsyncReadyCallback, orNone.
do_remount_finish¶
Finishes remounting a mount. If any errors occurred during the operation,
error will be set to contain the errors and False will be returned.
Parameters:
result— aAsyncResult.
do_unmount¶
def do_unmount(self, flags: MountUnmountFlags | int, cancellable: Cancellable | None = ..., callback: Callable[[Mount | None, AsyncResult], None] | None = ...) -> None
:::warning Deprecated since 2.22 This API is deprecated. :::
Unmounts a mount. This is an asynchronous operation, and is
finished by calling Mount.unmount_finish with the mount
and AsyncResult data returned in the callback.
Parameters:
flags— flags affecting the operationcancellable— optionalCancellableobject,Noneto ignore.callback— aGAsyncReadyCallback, orNone.
do_unmount_finish¶
:::warning Deprecated since 2.22 This API is deprecated. :::
Finishes unmounting a mount. If any errors occurred during the operation,
error will be set to contain the errors and False will be returned.
Parameters:
result— aAsyncResult.
do_unmount_with_operation¶
def do_unmount_with_operation(self, flags: MountUnmountFlags | int, mount_operation: MountOperation | None = ..., cancellable: Cancellable | None = ..., callback: Callable[[Mount | None, AsyncResult], None] | None = ...) -> None
Unmounts a mount. This is an asynchronous operation, and is
finished by calling Mount.unmount_with_operation_finish with the mount
and AsyncResult data returned in the callback.
Parameters:
flags— flags affecting the operationmount_operation— aMountOperationorNoneto avoid user interaction.cancellable— optionalCancellableobject,Noneto ignore.callback— aGAsyncReadyCallback, orNone.
do_unmount_with_operation_finish¶
Finishes unmounting a mount. If any errors occurred during the operation,
error will be set to contain the errors and False will be returned.
Parameters:
result— aAsyncResult.
do_unmounted¶
The unmounted signal that is emitted when the Mount have been unmounted. If the recipient is holding references to the object they should release them so the object can be finalized.
Signals¶
changed¶
Emitted when the mount has been changed.
pre-unmount¶
This signal may be emitted when the Mount is about to be
unmounted.
This signal depends on the backend and is only emitted if GIO was used to unmount.
unmounted¶
This signal is emitted when the Mount have been
unmounted. If the recipient is holding references to the
object they should release them so the object can be
finalized.