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
Nested ClassesModifier and TypeClassDescriptionstatic classVolumeMonitor.Builder<B extends VolumeMonitor.Builder<B>>Inner class implementing a builder pattern to construct a GObject with properties.static interfaceFunctional interface declaration of theDriveChangedCallbackcallback.static interfaceFunctional interface declaration of theDriveConnectedCallbackcallback.static interfaceFunctional interface declaration of theDriveDisconnectedCallbackcallback.static interfaceFunctional interface declaration of theDriveEjectButtonCallbackcallback.static interfaceFunctional interface declaration of theDriveStopButtonCallbackcallback.static interfaceFunctional interface declaration of theMountAddedCallbackcallback.static interfaceFunctional interface declaration of theMountChangedCallbackcallback.static interfaceFunctional interface declaration of theMountPreUnmountCallbackcallback.static interfaceFunctional interface declaration of theMountRemovedCallbackcallback.static interfaceFunctional interface declaration of theVolumeAddedCallbackcallback.static interfaceFunctional interface declaration of theVolumeChangedCallbackcallback.static classstatic interfaceFunctional interface declaration of theVolumeRemovedCallbackcallback.Nested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback, GObject.ObjectClass -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new VolumeMonitor.VolumeMonitor(MemorySegment address) Create a VolumeMonitor proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionstatic VolumeadoptOrphanMount(Mount mount) Deprecated.protected VolumeMonitorasParent()Returns this instance as if it were its parent type.static VolumeMonitor.Builder<? extends VolumeMonitor.Builder> builder()AVolumeMonitor.Builderobject constructs aVolumeMonitorwith the specified properties.protected voiddriveChanged(Drive drive) protected voiddriveConnected(Drive drive) protected voiddriveDisconnected(Drive drive) protected voiddriveEjectButton(Drive drive) protected voiddriveStopButton(Drive drive) voidemitDriveChanged(@Nullable Drive drive) Emits the "drive-changed" signal.voidemitDriveConnected(@Nullable Drive drive) Emits the "drive-connected" signal.voidemitDriveDisconnected(@Nullable Drive drive) Emits the "drive-disconnected" signal.voidemitDriveEjectButton(@Nullable Drive drive) Emits the "drive-eject-button" signal.voidemitDriveStopButton(@Nullable Drive drive) Emits the "drive-stop-button" signal.voidemitMountAdded(@Nullable Mount mount) Emits the "mount-added" signal.voidemitMountChanged(@Nullable Mount mount) Emits the "mount-changed" signal.voidemitMountPreUnmount(@Nullable Mount mount) Emits the "mount-pre-unmount" signal.voidemitMountRemoved(@Nullable Mount mount) Emits the "mount-removed" signal.voidemitVolumeAdded(@Nullable Volume volume) Emits the "volume-added" signal.voidemitVolumeChanged(@Nullable Volume volume) Emits the "volume-changed" signal.voidemitVolumeRemoved(@Nullable Volume volume) Emits the "volume-removed" signal.static VolumeMonitorget()Gets the volume monitor used by gio.Gets a list of drives connected to the system.static MemoryLayoutThe memory layout of the native struct.@Nullable MountgetMountForUuid(String uuid) Finds aGMountobject by its UUID (see g_mount_get_uuid())Gets a list of the mounts on the system.static @Nullable TypegetType()Get the GType of the VolumeMonitor class@Nullable VolumegetVolumeForUuid(String uuid) Finds aGVolumeobject by its UUID (see g_volume_get_uuid())Gets a list of the volumes on the system.protected voidmountAdded(Mount mount) protected voidmountChanged(Mount mount) protected voidmountPreUnmount(Mount mount) protected voidmountRemoved(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 voidvolumeAdded(Volume volume) protected voidvolumeChanged(Volume volume) protected voidvolumeRemoved(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, 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, withPropertiesMethods inherited from class org.gnome.gobject.TypeInstance
callParent, callParent, cast, getPrivate, readGClass, writeGClassMethods inherited from class org.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
-
VolumeMonitor
public VolumeMonitor()Creates a new VolumeMonitor.
-
-
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 Javasuperkeyword, 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,GVolumeMonitorimplementations 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 anyGVolumeMonitorimplementation when a newGMountobject is created that is not associated with aGVolumeobject. It must be called just before emitting themountAddedsignal.If the return value is not
null, the caller must associate the returnedGVolumeobject 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
mountand return it in its g_volume_get_mount() implemented. Also, the implementor must listen for the "unmounted" signal onmountand 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
GMountobject that needs to be associated with theGVolumeobject that represents the volume.The other is for implementing a
GVolumeMonitorwhose sole purpose is to returnGVolumeobjects representing entries in the users "favorite servers" list or similar.- Parameters:
mount- aGMountobject to find a parent for- Returns:
- the
GVolumeobject that is the parent formountornullif no wants to adopt theGMount.
-
get
Gets the volume monitor used by gio.- Returns:
- a reference to the
GVolumeMonitorused by gio. Call g_object_unref() when done with it, after disconnecting any signal handlers.
-
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
- Since:
- 2.18
- 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
- Since:
- 2.22
- 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.Builderobject constructs aVolumeMonitorwith the specified properties. Use the variousset...()methods to set properties, and finish construction withVolumeMonitor.Builder.build().- Returns:
- the builder object
-
GVolumeMonitorimplementations should instead create shadow mounts with the URI of the mount they intend to adopt.