Class VolumeMonitor
- All Implemented Interfaces:
Proxy
- Direct Known Subclasses:
NativeVolumeMonitor
GVolumeMonitor
is for listing the user interesting devices and volumes
on the computer. In other words, what a file selector or file manager
would show in a sidebar.
GVolumeMonitor
is not
thread-default-context aware (see
MainContext.pushThreadDefault()
), and so should not be used
other than from the main thread, with no thread-default-context active.
In order to receive updates about volumes and mounts monitored through GVFS, a main loop must be running.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
VolumeMonitor.Builder<B extends VolumeMonitor.Builder<B>>
Inner class implementing a builder pattern to construct a GObject with properties.static interface
Functional interface declaration of theDriveChangedCallback
callback.static interface
Functional interface declaration of theDriveConnectedCallback
callback.static interface
Functional interface declaration of theDriveDisconnectedCallback
callback.static interface
Functional interface declaration of theDriveEjectButtonCallback
callback.static interface
Functional interface declaration of theDriveStopButtonCallback
callback.static interface
Functional interface declaration of theMountAddedCallback
callback.static interface
Functional interface declaration of theMountChangedCallback
callback.static interface
Functional interface declaration of theMountPreUnmountCallback
callback.static interface
Functional interface declaration of theMountRemovedCallback
callback.static interface
Functional interface declaration of theVolumeAddedCallback
callback.static interface
Functional interface declaration of theVolumeChangedCallback
callback.static class
static interface
Functional interface declaration of theVolumeRemovedCallback
callback.Nested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback, GObject.ObjectClass
-
Constructor Summary
ConstructorDescriptionVolumeMonitor
(MemorySegment address) Create a VolumeMonitor proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionstatic Volume
adoptOrphanMount
(Mount mount) Deprecated.protected VolumeMonitor
asParent()
Returns this instance as if it were its parent type.static VolumeMonitor.Builder
<? extends VolumeMonitor.Builder> builder()
AVolumeMonitor.Builder
object constructs aVolumeMonitor
with the specified properties.protected void
driveChanged
(Drive drive) protected void
driveConnected
(Drive drive) protected void
driveDisconnected
(Drive drive) protected void
driveEjectButton
(Drive drive) protected void
driveStopButton
(Drive drive) void
emitDriveChanged
(Drive drive) Emits the "drive-changed" signal.void
emitDriveConnected
(Drive drive) Emits the "drive-connected" signal.void
emitDriveDisconnected
(Drive drive) Emits the "drive-disconnected" signal.void
emitDriveEjectButton
(Drive drive) Emits the "drive-eject-button" signal.void
emitDriveStopButton
(Drive drive) Emits the "drive-stop-button" signal.void
emitMountAdded
(Mount mount) Emits the "mount-added" signal.void
emitMountChanged
(Mount mount) Emits the "mount-changed" signal.void
emitMountPreUnmount
(Mount mount) Emits the "mount-pre-unmount" signal.void
emitMountRemoved
(Mount mount) Emits the "mount-removed" signal.void
emitVolumeAdded
(Volume volume) Emits the "volume-added" signal.void
emitVolumeChanged
(Volume volume) Emits the "volume-changed" signal.void
emitVolumeRemoved
(Volume volume) Emits the "volume-removed" signal.static VolumeMonitor
get()
Gets the volume monitor used by gio.Gets a list of drives connected to the system.static MemoryLayout
The memory layout of the native struct.getMountForUuid
(String uuid) Finds aGMount
object by its UUID (see g_mount_get_uuid())Gets a list of the mounts on the system.static Type
getType()
Get the GType of the VolumeMonitor classgetVolumeForUuid
(String uuid) Finds aGVolume
object by its UUID (see g_volume_get_uuid())Gets a list of the volumes on the system.protected void
mountAdded
(Mount mount) protected void
mountChanged
(Mount mount) protected void
mountPreUnmount
(Mount mount) protected void
mountRemoved
(Mount mount) Emitted when a drive changes.Emitted when a drive is connected to the system.Emitted when a drive is disconnected from the system.Emitted when the eject button is pressed ondrive
.Emitted when the stop button is pressed ondrive
.Emitted when a mount is added.Emitted when a mount changes.May be emitted when a mount is about to be removed.Emitted when a mount is removed.Emitted when a mountable volume is added to the system.Emitted when mountable volume is changed.Emitted when a mountable volume is removed from the system.protected void
volumeAdded
(Volume volume) protected void
volumeChanged
(Volume volume) protected void
volumeRemoved
(Volume volume) Methods inherited from class org.gnome.gobject.GObject
addToggleRef, addWeakPointer, bindProperty, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, compatControl, connect, connect, connect, constructed, disconnect, dispatchPropertiesChanged, dispose, dupData, dupQdata, emit, emitNotify, finalize_, forceFloating, freezeNotify, get, getData, getProperty, getProperty, getProperty, getQdata, getv, interfaceFindProperty, interfaceInstallProperty, interfaceListProperties, isFloating, newInstance, newInstance, newInstance, newInstance, newv, notify_, notify_, notifyByPspec, onNotify, ref, refSink, removeToggleRef, removeWeakPointer, replaceData, replaceQdata, runDispose, set, setData, setDataFull, setProperty, setProperty, setProperty, setQdata, setQdataFull, setv, stealData, stealQdata, takeRef, thawNotify, unref, watchClosure, weakRef, weakUnref, withProperties
Methods inherited from class org.gnome.gobject.TypeInstance
callParent, callParent, getPrivate, readGClass, writeGClass
Methods inherited from class io.github.jwharm.javagi.base.ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
VolumeMonitor
Create a VolumeMonitor proxy instance for the provided memory address.- Parameters:
address
- the memory address of the native object
-
-
Method Details
-
getType
-
getMemoryLayout
The memory layout of the native struct.- Returns:
- the memory layout
-
asParent
Returns this instance as if it were its parent type. This is mostly synonymous to the Javasuper
keyword, but will set the native typeclass function pointers to the parent type. When overriding a native virtual method in Java, "chaining up" withsuper.methodName()
doesn't work, because it invokes the overridden function pointer again. To chain up, callasParent().methodName()
. This will call the native function pointer of this virtual method in the typeclass of the parent type. -
adoptOrphanMount
Deprecated.Instead of using this function,GVolumeMonitor
implementations should instead create shadow mounts with the URI of the mount they intend to adopt. See the proxy volume monitor in gvfs for an example of this. Also see g_mount_is_shadowed(), g_mount_shadow() and g_mount_unshadow() functions.This function should be called by anyGVolumeMonitor
implementation when a newGMount
object is created that is not associated with aGVolume
object. It must be called just before emitting themountAdded
signal.If the return value is not
null
, the caller must associate the returnedGVolume
object with theGMount
. This involves returning it in its g_mount_get_volume() implementation. The caller must also listen for the "removed" signal on the returned object and give up its reference when handling that signalSimilarly, if implementing g_volume_monitor_adopt_orphan_mount(), the implementor must take a reference to
mount
and return it in its g_volume_get_mount() implemented. Also, the implementor must listen for the "unmounted" signal onmount
and give up its reference upon handling that signal.There are two main use cases for this function.
One is when implementing a user space file system driver that reads blocks of a block device that is already represented by the native volume monitor (for example a CD Audio file system driver). Such a driver will generate its own
GMount
object that needs to be associated with theGVolume
object that represents the volume.The other is for implementing a
GVolumeMonitor
whose sole purpose is to returnGVolume
objects representing entries in the users "favorite servers" list or similar.- Parameters:
mount
- aGMount
object to find a parent for- Returns:
- the
GVolume
object that is the parent formount
ornull
if no wants to adopt theGMount
.
-
get
Gets the volume monitor used by gio.- Returns:
- a reference to the
GVolumeMonitor
used by gio. Call g_object_unref() when done with it.
-
getConnectedDrives
-
getMountForUuid
-
getMounts
-
getVolumeForUuid
-
getVolumes
-
driveChanged
-
driveConnected
-
driveDisconnected
-
driveEjectButton
-
driveStopButton
-
mountAdded
-
mountChanged
-
mountPreUnmount
-
mountRemoved
-
volumeAdded
-
volumeChanged
-
volumeRemoved
-
onDriveChanged
public SignalConnection<VolumeMonitor.DriveChangedCallback> onDriveChanged(VolumeMonitor.DriveChangedCallback handler) Emitted when a drive changes.- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitDriveChanged
Emits the "drive-changed" signal. SeeonDriveChanged(org.gnome.gio.VolumeMonitor.DriveChangedCallback)
. -
onDriveConnected
public SignalConnection<VolumeMonitor.DriveConnectedCallback> onDriveConnected(VolumeMonitor.DriveConnectedCallback handler) Emitted when a drive is connected to the system.- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitDriveConnected
Emits the "drive-connected" signal. SeeonDriveConnected(org.gnome.gio.VolumeMonitor.DriveConnectedCallback)
. -
onDriveDisconnected
public SignalConnection<VolumeMonitor.DriveDisconnectedCallback> onDriveDisconnected(VolumeMonitor.DriveDisconnectedCallback handler) Emitted when a drive is disconnected from the system.- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitDriveDisconnected
Emits the "drive-disconnected" signal. SeeonDriveDisconnected(org.gnome.gio.VolumeMonitor.DriveDisconnectedCallback)
. -
onDriveEjectButton
public SignalConnection<VolumeMonitor.DriveEjectButtonCallback> onDriveEjectButton(VolumeMonitor.DriveEjectButtonCallback handler) Emitted when the eject button is pressed ondrive
.- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitDriveEjectButton
Emits the "drive-eject-button" signal. SeeonDriveEjectButton(org.gnome.gio.VolumeMonitor.DriveEjectButtonCallback)
. -
onDriveStopButton
public SignalConnection<VolumeMonitor.DriveStopButtonCallback> onDriveStopButton(VolumeMonitor.DriveStopButtonCallback handler) Emitted when the stop button is pressed ondrive
.- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitDriveStopButton
Emits the "drive-stop-button" signal. SeeonDriveStopButton(org.gnome.gio.VolumeMonitor.DriveStopButtonCallback)
. -
onMountAdded
public SignalConnection<VolumeMonitor.MountAddedCallback> onMountAdded(VolumeMonitor.MountAddedCallback handler) Emitted when a mount is added.- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitMountAdded
Emits the "mount-added" signal. SeeonMountAdded(org.gnome.gio.VolumeMonitor.MountAddedCallback)
. -
onMountChanged
public SignalConnection<VolumeMonitor.MountChangedCallback> onMountChanged(VolumeMonitor.MountChangedCallback handler) Emitted when a mount changes.- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitMountChanged
Emits the "mount-changed" signal. SeeonMountChanged(org.gnome.gio.VolumeMonitor.MountChangedCallback)
. -
onMountPreUnmount
public SignalConnection<VolumeMonitor.MountPreUnmountCallback> onMountPreUnmount(VolumeMonitor.MountPreUnmountCallback handler) May be emitted when a mount is about to be removed.This signal depends on the backend and is only emitted if GIO was used to unmount.
- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitMountPreUnmount
Emits the "mount-pre-unmount" signal. SeeonMountPreUnmount(org.gnome.gio.VolumeMonitor.MountPreUnmountCallback)
. -
onMountRemoved
public SignalConnection<VolumeMonitor.MountRemovedCallback> onMountRemoved(VolumeMonitor.MountRemovedCallback handler) Emitted when a mount is removed.- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitMountRemoved
Emits the "mount-removed" signal. SeeonMountRemoved(org.gnome.gio.VolumeMonitor.MountRemovedCallback)
. -
onVolumeAdded
public SignalConnection<VolumeMonitor.VolumeAddedCallback> onVolumeAdded(VolumeMonitor.VolumeAddedCallback handler) Emitted when a mountable volume is added to the system.- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitVolumeAdded
Emits the "volume-added" signal. SeeonVolumeAdded(org.gnome.gio.VolumeMonitor.VolumeAddedCallback)
. -
onVolumeChanged
public SignalConnection<VolumeMonitor.VolumeChangedCallback> onVolumeChanged(VolumeMonitor.VolumeChangedCallback handler) Emitted when mountable volume is changed.- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitVolumeChanged
Emits the "volume-changed" signal. SeeonVolumeChanged(org.gnome.gio.VolumeMonitor.VolumeChangedCallback)
. -
onVolumeRemoved
public SignalConnection<VolumeMonitor.VolumeRemovedCallback> onVolumeRemoved(VolumeMonitor.VolumeRemovedCallback handler) Emitted when a mountable volume is removed from the system.- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitVolumeRemoved
Emits the "volume-removed" signal. SeeonVolumeRemoved(org.gnome.gio.VolumeMonitor.VolumeRemovedCallback)
. -
builder
AVolumeMonitor.Builder
object constructs aVolumeMonitor
with the specified properties. Use the variousset...()
methods to set properties, and finish construction withVolumeMonitor.Builder.build()
.
-
GVolumeMonitor
implementations should instead create shadow mounts with the URI of the mount they intend to adopt.