gio.mount_mixin
Module for [Mount] interface mixin
Templates 2
The [gio.mount.Mount] interface represents user-visible mounts. Note, when
porting from GnomeVFS, [gio.mount.Mount] is the moralequivalent of GnomeVFSVolume.
[gio.mount.Mount] 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. Might or might not be related to a volume object.
Unmounting a [gio.mount.Mount] instance is an asynchronous operation. For more information about asynchronous operations, see [gio.async_result.AsyncResult] and [gio.task.Task]. To unmount a [gio.mount.Mount] instance, first call [gio.mount.Mount.unmountWithOperation] with (at least) the [gio.mount.Mount] instance and a [gio.types.AsyncReadyCallback]. The callback will be fired when the operation has resolved (either with success or failure), and a [gio.async_result.AsyncResult] structure will be passed to the callback. That callback should then call [gio.mount.Mount.unmountWithOperationFinish] with the [gio.mount.Mount] and the [gio.async_result.AsyncResult] data to see if the operation was completed successfully. If an error is present when [gio.mount.Mount.unmountWithOperationFinish] is called, then it will be filled with any error information.
Checks if mount can be ejected.
Returns
Checks if mount can be unmounted.
Returns
Ejects a mount. This is an asynchronous operation, and is finished by calling [gio.mount.Mount.ejectFinish] with the mount and #GAsyncResult data returned in the callback.
Parameters
flags | flags affecting the unmount if required for eject |
cancellable | optional #GCancellable object, null to ignore. |
callback | a #GAsyncReadyCallback, or null. |
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 | a #GAsyncResult. |
Returns
Throws
Deprecated
Ejects a mount. This is an asynchronous operation, and is finished by calling [gio.mount.Mount.ejectWithOperationFinish] with the mount and #GAsyncResult data returned in the callback.
Parameters
flags | flags affecting the unmount if required for eject |
mountOperation | a #GMountOperation or null to avoid user interaction. |
cancellable | optional #GCancellable object, null to ignore. |
callback | a #GAsyncReadyCallback, or null. |
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 | a #GAsyncResult. |
Returns
Throws
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).
Returns
The returned object should be unreffed with [gobject.object.ObjectWrap.unref] when no longer needed.
Gets the drive for the mount.
This is a convenience method for getting the #GVolume and then using that object to get the #GDrive.
Returns
associated with a volume or a drive. The returned object should be unreffed with [gobject.object.ObjectWrap.unref] when no longer needed.
Gets the icon for mount.
Returns
The returned object should be unreffed with [gobject.object.ObjectWrap.unref] when no longer needed.
Gets the name of mount.
Returns
The returned string should be freed with [glib.global.gfree] when no longer needed.
Gets the root directory on mount.
Returns
The returned object should be unreffed with [gobject.object.ObjectWrap.unref] when no longer needed.
Gets the sort key for mount, if any.
Returns
Gets the symbolic icon for mount.
Returns
The returned object should be unreffed with [gobject.object.ObjectWrap.unref] when no longer needed.
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 null if there is no UUID available.
Returns
can be computed. The returned string should be freed with [glib.global.gfree] when no longer needed.
Gets the volume for the mount.
Returns
associated with a volume. The returned object should be unreffed with [gobject.object.ObjectWrap.unref] when no longer needed.
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-infospecification for more on x-content types.
This is an asynchronous operation (see [gio.mount.Mount.guessContentTypeSync] for the synchronous version), and is finished by calling [gio.mount.Mount.guessContentTypeFinish] with the mount and #GAsyncResult data returned in the callback.
Parameters
forceRescan | Whether to force a rescan of the content. Otherwise a cached result will be used if available |
cancellable | optional #GCancellable object, null to ignore |
callback | a #GAsyncReadyCallback |
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 [gio.types.IOErrorEnum.NotSupported] if the mount does not support content guessing.
Parameters
result | a #GAsyncResult |
Returns
Caller should free this array with [glib.global.strfreev] when done with it.
Throws
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-infospecification for more on x-content types.
This is a synchronous operation and as such may block doing IO; see [gio.mount.Mount.guessContentType] for the asynchronous version.
Parameters
forceRescan | Whether to force a rescan of the content. Otherwise a cached result will be used if available |
cancellable | optional #GCancellable object, null to ignore |
Returns
Caller should free this array with [glib.global.strfreev] when done with it.
Throws
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 #GMount 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 #GVolumeMonitor implementation would create two #GVolume 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 #GVolumeMonitor implementation would create two #GMount 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 #GVolume is set.
Returns
Remounts a mount. This is an asynchronous operation, and is finished by calling [gio.mount.Mount.remountFinish] 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 operation |
mountOperation | a #GMountOperation or null to avoid user interaction. |
cancellable | optional #GCancellable object, null to ignore. |
callback | a #GAsyncReadyCallback, or null. |
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 | a #GAsyncResult. |
Returns
Throws
Increments the shadow count on mount. Usually used by #GVolumeMonitor implementations when creating a shadow mount for mount, see [gio.mount.Mount.isShadowed] for more information. The caller will need to emit the #GMount::changed signal on mount manually.
Unmounts a mount. This is an asynchronous operation, and is finished by calling [gio.mount.Mount.unmountFinish] with the mount and #GAsyncResult data returned in the callback.
Parameters
flags | flags affecting the operation |
cancellable | optional #GCancellable object, null to ignore. |
callback | a #GAsyncReadyCallback, or null. |
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 | a #GAsyncResult. |
Returns
Throws
Deprecated
Unmounts a mount. This is an asynchronous operation, and is finished by calling [gio.mount.Mount.unmountWithOperationFinish] with the mount and #GAsyncResult data returned in the callback.
Parameters
flags | flags affecting the operation |
mountOperation | a #GMountOperation or null to avoid user interaction. |
cancellable | optional #GCancellable object, null to ignore. |
callback | a #GAsyncReadyCallback, or null. |
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 | a #GAsyncResult. |
Returns
Throws
Decrements the shadow count on mount. Usually used by #GVolumeMonitor implementations when destroying a shadow mount for mount, see [gio.mount.Mount.isShadowed] for more information. The caller will need to emit the #GMount::changed signal on mount manually.
Connect to Changed signal.
Emitted when the mount has been changed.
Parameters
callback | signal callback delegate or function to connect void callback(gio.mount.Mount mount) mount the instance the signal is connected to (optional) |
after | Yes.After to execute callback after default handler, No.After to execute before (default) |
Returns
Connect to PreUnmount signal.
This signal may be emitted when the #GMount is about to be unmounted.
This signal depends on the backend and is only emitted if GIO was used to unmount.
Parameters
callback | signal callback delegate or function to connect void callback(gio.mount.Mount mount) mount the instance the signal is connected to (optional) |
after | Yes.After to execute callback after default handler, No.After to execute before (default) |
Returns
Connect to Unmounted signal.
This signal is emitted when the #GMount have been unmounted. If the recipient is holding references to the object they should release them so the object can be finalized.
Parameters
callback | signal callback delegate or function to connect void callback(gio.mount.Mount mount) mount the instance the signal is connected to (optional) |
after | Yes.After to execute callback after default handler, No.After to execute before (default) |