{- |
Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
License    : LGPL-2.1
Maintainer : Iñaki García Etxebarria (garetxe@gmail.com)

'GI.Gio.Interfaces.Drive.Drive' - this represent a piece of hardware connected to the machine.
It\'s generally only created for removable hardware or hardware with
removable media.

'GI.Gio.Interfaces.Drive.Drive' is a container class for 'GI.Gio.Interfaces.Volume.Volume' objects that stem from
the same piece of media. As such, 'GI.Gio.Interfaces.Drive.Drive' abstracts a drive with
(or without) removable media and provides operations for querying
whether media is available, determining whether media change is
automatically detected and ejecting the media.

If the 'GI.Gio.Interfaces.Drive.Drive' reports that media isn\'t automatically detected, one
can poll for media; typically one should not do this periodically
as a poll for media operation is potententially expensive and may
spin up the drive creating noise.

'GI.Gio.Interfaces.Drive.Drive' supports starting and stopping drives with authentication
support for the former. This can be used to support a diverse set
of use cases including connecting\/disconnecting iSCSI devices,
powering down external disk enclosures and starting\/stopping
multi-disk devices such as RAID devices. Note that the actual
semantics and side-effects of starting\/stopping a 'GI.Gio.Interfaces.Drive.Drive' may vary
according to implementation. To choose the correct verbs in e.g. a
file manager, use 'GI.Gio.Interfaces.Drive.driveGetStartStopType'.

For porting from GnomeVFS note that there is no equivalent of
'GI.Gio.Interfaces.Drive.Drive' in that API.
-}

#define ENABLE_OVERLOADING \
       (!defined(__HADDOCK_VERSION__))

module GI.Gio.Interfaces.Drive
    ( 

-- * Exported types
    Drive(..)                               ,
    noDrive                                 ,
    IsDrive                                 ,
    toDrive                                 ,


 -- * Methods
-- ** canEject #method:canEject#

#if ENABLE_OVERLOADING
    DriveCanEjectMethodInfo                 ,
#endif
    driveCanEject                           ,


-- ** canPollForMedia #method:canPollForMedia#

#if ENABLE_OVERLOADING
    DriveCanPollForMediaMethodInfo          ,
#endif
    driveCanPollForMedia                    ,


-- ** canStart #method:canStart#

#if ENABLE_OVERLOADING
    DriveCanStartMethodInfo                 ,
#endif
    driveCanStart                           ,


-- ** canStartDegraded #method:canStartDegraded#

#if ENABLE_OVERLOADING
    DriveCanStartDegradedMethodInfo         ,
#endif
    driveCanStartDegraded                   ,


-- ** canStop #method:canStop#

#if ENABLE_OVERLOADING
    DriveCanStopMethodInfo                  ,
#endif
    driveCanStop                            ,


-- ** eject #method:eject#

#if ENABLE_OVERLOADING
    DriveEjectMethodInfo                    ,
#endif
    driveEject                              ,


-- ** ejectFinish #method:ejectFinish#

#if ENABLE_OVERLOADING
    DriveEjectFinishMethodInfo              ,
#endif
    driveEjectFinish                        ,


-- ** ejectWithOperation #method:ejectWithOperation#

#if ENABLE_OVERLOADING
    DriveEjectWithOperationMethodInfo       ,
#endif
    driveEjectWithOperation                 ,


-- ** ejectWithOperationFinish #method:ejectWithOperationFinish#

#if ENABLE_OVERLOADING
    DriveEjectWithOperationFinishMethodInfo ,
#endif
    driveEjectWithOperationFinish           ,


-- ** enumerateIdentifiers #method:enumerateIdentifiers#

#if ENABLE_OVERLOADING
    DriveEnumerateIdentifiersMethodInfo     ,
#endif
    driveEnumerateIdentifiers               ,


-- ** getIcon #method:getIcon#

#if ENABLE_OVERLOADING
    DriveGetIconMethodInfo                  ,
#endif
    driveGetIcon                            ,


-- ** getIdentifier #method:getIdentifier#

#if ENABLE_OVERLOADING
    DriveGetIdentifierMethodInfo            ,
#endif
    driveGetIdentifier                      ,


-- ** getName #method:getName#

#if ENABLE_OVERLOADING
    DriveGetNameMethodInfo                  ,
#endif
    driveGetName                            ,


-- ** getSortKey #method:getSortKey#

#if ENABLE_OVERLOADING
    DriveGetSortKeyMethodInfo               ,
#endif
    driveGetSortKey                         ,


-- ** getStartStopType #method:getStartStopType#

#if ENABLE_OVERLOADING
    DriveGetStartStopTypeMethodInfo         ,
#endif
    driveGetStartStopType                   ,


-- ** getSymbolicIcon #method:getSymbolicIcon#

#if ENABLE_OVERLOADING
    DriveGetSymbolicIconMethodInfo          ,
#endif
    driveGetSymbolicIcon                    ,


-- ** getVolumes #method:getVolumes#

#if ENABLE_OVERLOADING
    DriveGetVolumesMethodInfo               ,
#endif
    driveGetVolumes                         ,


-- ** hasMedia #method:hasMedia#

#if ENABLE_OVERLOADING
    DriveHasMediaMethodInfo                 ,
#endif
    driveHasMedia                           ,


-- ** hasVolumes #method:hasVolumes#

#if ENABLE_OVERLOADING
    DriveHasVolumesMethodInfo               ,
#endif
    driveHasVolumes                         ,


-- ** isMediaCheckAutomatic #method:isMediaCheckAutomatic#

#if ENABLE_OVERLOADING
    DriveIsMediaCheckAutomaticMethodInfo    ,
#endif
    driveIsMediaCheckAutomatic              ,


-- ** isMediaRemovable #method:isMediaRemovable#

#if ENABLE_OVERLOADING
    DriveIsMediaRemovableMethodInfo         ,
#endif
    driveIsMediaRemovable                   ,


-- ** isRemovable #method:isRemovable#

#if ENABLE_OVERLOADING
    DriveIsRemovableMethodInfo              ,
#endif
    driveIsRemovable                        ,


-- ** pollForMedia #method:pollForMedia#

#if ENABLE_OVERLOADING
    DrivePollForMediaMethodInfo             ,
#endif
    drivePollForMedia                       ,


-- ** pollForMediaFinish #method:pollForMediaFinish#

#if ENABLE_OVERLOADING
    DrivePollForMediaFinishMethodInfo       ,
#endif
    drivePollForMediaFinish                 ,


-- ** start #method:start#

#if ENABLE_OVERLOADING
    DriveStartMethodInfo                    ,
#endif
    driveStart                              ,


-- ** startFinish #method:startFinish#

#if ENABLE_OVERLOADING
    DriveStartFinishMethodInfo              ,
#endif
    driveStartFinish                        ,


-- ** stop #method:stop#

#if ENABLE_OVERLOADING
    DriveStopMethodInfo                     ,
#endif
    driveStop                               ,


-- ** stopFinish #method:stopFinish#

#if ENABLE_OVERLOADING
    DriveStopFinishMethodInfo               ,
#endif
    driveStopFinish                         ,




 -- * Signals
-- ** changed #signal:changed#

    C_DriveChangedCallback                  ,
    DriveChangedCallback                    ,
#if ENABLE_OVERLOADING
    DriveChangedSignalInfo                  ,
#endif
    afterDriveChanged                       ,
    genClosure_DriveChanged                 ,
    mk_DriveChangedCallback                 ,
    noDriveChangedCallback                  ,
    onDriveChanged                          ,
    wrap_DriveChangedCallback               ,


-- ** disconnected #signal:disconnected#

    C_DriveDisconnectedCallback             ,
    DriveDisconnectedCallback               ,
#if ENABLE_OVERLOADING
    DriveDisconnectedSignalInfo             ,
#endif
    afterDriveDisconnected                  ,
    genClosure_DriveDisconnected            ,
    mk_DriveDisconnectedCallback            ,
    noDriveDisconnectedCallback             ,
    onDriveDisconnected                     ,
    wrap_DriveDisconnectedCallback          ,


-- ** ejectButton #signal:ejectButton#

    C_DriveEjectButtonCallback              ,
    DriveEjectButtonCallback                ,
#if ENABLE_OVERLOADING
    DriveEjectButtonSignalInfo              ,
#endif
    afterDriveEjectButton                   ,
    genClosure_DriveEjectButton             ,
    mk_DriveEjectButtonCallback             ,
    noDriveEjectButtonCallback              ,
    onDriveEjectButton                      ,
    wrap_DriveEjectButtonCallback           ,


-- ** stopButton #signal:stopButton#

    C_DriveStopButtonCallback               ,
    DriveStopButtonCallback                 ,
#if ENABLE_OVERLOADING
    DriveStopButtonSignalInfo               ,
#endif
    afterDriveStopButton                    ,
    genClosure_DriveStopButton              ,
    mk_DriveStopButtonCallback              ,
    noDriveStopButtonCallback               ,
    onDriveStopButton                       ,
    wrap_DriveStopButtonCallback            ,




    ) where

import Data.GI.Base.ShortPrelude
import qualified Data.GI.Base.ShortPrelude as SP
import qualified Data.GI.Base.Overloading as O
import qualified Prelude as P

import qualified Data.GI.Base.Attributes as GI.Attributes
import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GVariant as B.GVariant
import qualified Data.GI.Base.GValue as B.GValue
import qualified Data.GI.Base.GParamSpec as B.GParamSpec
import qualified Data.GI.Base.CallStack as B.CallStack
import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import qualified Foreign.Ptr as FP

import qualified GI.GObject.Objects.Object as GObject.Object
import qualified GI.Gio.Callbacks as Gio.Callbacks
import {-# SOURCE #-} qualified GI.Gio.Enums as Gio.Enums
import {-# SOURCE #-} qualified GI.Gio.Flags as Gio.Flags
import {-# SOURCE #-} qualified GI.Gio.Interfaces.AsyncResult as Gio.AsyncResult
import {-# SOURCE #-} qualified GI.Gio.Interfaces.Icon as Gio.Icon
import {-# SOURCE #-} qualified GI.Gio.Interfaces.Volume as Gio.Volume
import {-# SOURCE #-} qualified GI.Gio.Objects.Cancellable as Gio.Cancellable
import {-# SOURCE #-} qualified GI.Gio.Objects.MountOperation as Gio.MountOperation

-- interface Drive 
-- | Memory-managed wrapper type.
newtype Drive = Drive (ManagedPtr Drive)
-- | A convenience alias for `Nothing` :: `Maybe` `Drive`.
noDrive :: Maybe Drive
noDrive :: Maybe Drive
noDrive = Maybe Drive
forall a. Maybe a
Nothing

-- signal Drive::changed
{- |
Emitted when the drive\'s state has changed.
-}
type DriveChangedCallback =
    IO ()

-- | A convenience synonym for @`Nothing` :: `Maybe` `DriveChangedCallback`@.
noDriveChangedCallback :: Maybe DriveChangedCallback
noDriveChangedCallback :: Maybe DriveChangedCallback
noDriveChangedCallback = Maybe DriveChangedCallback
forall a. Maybe a
Nothing

-- | Type for the callback on the (unwrapped) C side.
type C_DriveChangedCallback =
    Ptr () ->                               -- object
    Ptr () ->                               -- user_data
    IO ()

-- | Generate a function pointer callable from C code, from a `C_DriveChangedCallback`.
foreign import ccall "wrapper"
    mk_DriveChangedCallback :: C_DriveChangedCallback -> IO (FunPtr C_DriveChangedCallback)

-- | Wrap the callback into a `Closure`.
genClosure_DriveChanged :: DriveChangedCallback -> IO Closure
genClosure_DriveChanged :: DriveChangedCallback -> IO Closure
genClosure_DriveChanged cb :: DriveChangedCallback
cb = do
    let cb' :: C_DriveChangedCallback
cb' = DriveChangedCallback -> C_DriveChangedCallback
wrap_DriveChangedCallback DriveChangedCallback
cb
    C_DriveChangedCallback -> IO (FunPtr C_DriveChangedCallback)
mk_DriveChangedCallback C_DriveChangedCallback
cb' IO (FunPtr C_DriveChangedCallback)
-> (FunPtr C_DriveChangedCallback -> IO Closure) -> IO Closure
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= FunPtr C_DriveChangedCallback -> IO Closure
forall a. FunPtr a -> IO Closure
newCClosure


-- | Wrap a `DriveChangedCallback` into a `C_DriveChangedCallback`.
wrap_DriveChangedCallback ::
    DriveChangedCallback ->
    C_DriveChangedCallback
wrap_DriveChangedCallback :: DriveChangedCallback -> C_DriveChangedCallback
wrap_DriveChangedCallback _cb :: DriveChangedCallback
_cb _ _ = do
    DriveChangedCallback
_cb 


{- |
Connect a signal handler for the “@changed@” signal, to be run before the default handler.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Signals.on' drive #changed callback
@
-}
onDriveChanged :: (IsDrive a, MonadIO m) => a -> DriveChangedCallback -> m SignalHandlerId
onDriveChanged :: a -> DriveChangedCallback -> m SignalHandlerId
onDriveChanged obj :: a
obj cb :: DriveChangedCallback
cb = IO SignalHandlerId -> m SignalHandlerId
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO SignalHandlerId -> m SignalHandlerId)
-> IO SignalHandlerId -> m SignalHandlerId
forall a b. (a -> b) -> a -> b
$ do
    let cb' :: C_DriveChangedCallback
cb' = DriveChangedCallback -> C_DriveChangedCallback
wrap_DriveChangedCallback DriveChangedCallback
cb
    FunPtr C_DriveChangedCallback
cb'' <- C_DriveChangedCallback -> IO (FunPtr C_DriveChangedCallback)
mk_DriveChangedCallback C_DriveChangedCallback
cb'
    a
-> String
-> FunPtr C_DriveChangedCallback
-> SignalConnectMode
-> IO SignalHandlerId
forall o a.
GObject o =>
o -> String -> FunPtr a -> SignalConnectMode -> IO SignalHandlerId
connectSignalFunPtr a
obj "changed" FunPtr C_DriveChangedCallback
cb'' SignalConnectMode
SignalConnectBefore

{- |
Connect a signal handler for the “@changed@” signal, to be run after the default handler.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Signals.after' drive #changed callback
@
-}
afterDriveChanged :: (IsDrive a, MonadIO m) => a -> DriveChangedCallback -> m SignalHandlerId
afterDriveChanged :: a -> DriveChangedCallback -> m SignalHandlerId
afterDriveChanged obj :: a
obj cb :: DriveChangedCallback
cb = IO SignalHandlerId -> m SignalHandlerId
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO SignalHandlerId -> m SignalHandlerId)
-> IO SignalHandlerId -> m SignalHandlerId
forall a b. (a -> b) -> a -> b
$ do
    let cb' :: C_DriveChangedCallback
cb' = DriveChangedCallback -> C_DriveChangedCallback
wrap_DriveChangedCallback DriveChangedCallback
cb
    FunPtr C_DriveChangedCallback
cb'' <- C_DriveChangedCallback -> IO (FunPtr C_DriveChangedCallback)
mk_DriveChangedCallback C_DriveChangedCallback
cb'
    a
-> String
-> FunPtr C_DriveChangedCallback
-> SignalConnectMode
-> IO SignalHandlerId
forall o a.
GObject o =>
o -> String -> FunPtr a -> SignalConnectMode -> IO SignalHandlerId
connectSignalFunPtr a
obj "changed" FunPtr C_DriveChangedCallback
cb'' SignalConnectMode
SignalConnectAfter


-- signal Drive::disconnected
{- |
This signal is emitted when the 'GI.Gio.Interfaces.Drive.Drive' have been
disconnected. If the recipient is holding references to the
object they should release them so the object can be
finalized.
-}
type DriveDisconnectedCallback =
    IO ()

-- | A convenience synonym for @`Nothing` :: `Maybe` `DriveDisconnectedCallback`@.
noDriveDisconnectedCallback :: Maybe DriveDisconnectedCallback
noDriveDisconnectedCallback :: Maybe DriveChangedCallback
noDriveDisconnectedCallback = Maybe DriveChangedCallback
forall a. Maybe a
Nothing

-- | Type for the callback on the (unwrapped) C side.
type C_DriveDisconnectedCallback =
    Ptr () ->                               -- object
    Ptr () ->                               -- user_data
    IO ()

-- | Generate a function pointer callable from C code, from a `C_DriveDisconnectedCallback`.
foreign import ccall "wrapper"
    mk_DriveDisconnectedCallback :: C_DriveDisconnectedCallback -> IO (FunPtr C_DriveDisconnectedCallback)

-- | Wrap the callback into a `Closure`.
genClosure_DriveDisconnected :: DriveDisconnectedCallback -> IO Closure
genClosure_DriveDisconnected :: DriveChangedCallback -> IO Closure
genClosure_DriveDisconnected cb :: DriveChangedCallback
cb = do
    let cb' :: C_DriveChangedCallback
cb' = DriveChangedCallback -> C_DriveChangedCallback
wrap_DriveDisconnectedCallback DriveChangedCallback
cb
    C_DriveChangedCallback -> IO (FunPtr C_DriveChangedCallback)
mk_DriveDisconnectedCallback C_DriveChangedCallback
cb' IO (FunPtr C_DriveChangedCallback)
-> (FunPtr C_DriveChangedCallback -> IO Closure) -> IO Closure
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= FunPtr C_DriveChangedCallback -> IO Closure
forall a. FunPtr a -> IO Closure
newCClosure


-- | Wrap a `DriveDisconnectedCallback` into a `C_DriveDisconnectedCallback`.
wrap_DriveDisconnectedCallback ::
    DriveDisconnectedCallback ->
    C_DriveDisconnectedCallback
wrap_DriveDisconnectedCallback :: DriveChangedCallback -> C_DriveChangedCallback
wrap_DriveDisconnectedCallback _cb :: DriveChangedCallback
_cb _ _ = do
    DriveChangedCallback
_cb 


{- |
Connect a signal handler for the “@disconnected@” signal, to be run before the default handler.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Signals.on' drive #disconnected callback
@
-}
onDriveDisconnected :: (IsDrive a, MonadIO m) => a -> DriveDisconnectedCallback -> m SignalHandlerId
onDriveDisconnected :: a -> DriveChangedCallback -> m SignalHandlerId
onDriveDisconnected obj :: a
obj cb :: DriveChangedCallback
cb = IO SignalHandlerId -> m SignalHandlerId
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO SignalHandlerId -> m SignalHandlerId)
-> IO SignalHandlerId -> m SignalHandlerId
forall a b. (a -> b) -> a -> b
$ do
    let cb' :: C_DriveChangedCallback
cb' = DriveChangedCallback -> C_DriveChangedCallback
wrap_DriveDisconnectedCallback DriveChangedCallback
cb
    FunPtr C_DriveChangedCallback
cb'' <- C_DriveChangedCallback -> IO (FunPtr C_DriveChangedCallback)
mk_DriveDisconnectedCallback C_DriveChangedCallback
cb'
    a
-> String
-> FunPtr C_DriveChangedCallback
-> SignalConnectMode
-> IO SignalHandlerId
forall o a.
GObject o =>
o -> String -> FunPtr a -> SignalConnectMode -> IO SignalHandlerId
connectSignalFunPtr a
obj "disconnected" FunPtr C_DriveChangedCallback
cb'' SignalConnectMode
SignalConnectBefore

{- |
Connect a signal handler for the “@disconnected@” signal, to be run after the default handler.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Signals.after' drive #disconnected callback
@
-}
afterDriveDisconnected :: (IsDrive a, MonadIO m) => a -> DriveDisconnectedCallback -> m SignalHandlerId
afterDriveDisconnected :: a -> DriveChangedCallback -> m SignalHandlerId
afterDriveDisconnected obj :: a
obj cb :: DriveChangedCallback
cb = IO SignalHandlerId -> m SignalHandlerId
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO SignalHandlerId -> m SignalHandlerId)
-> IO SignalHandlerId -> m SignalHandlerId
forall a b. (a -> b) -> a -> b
$ do
    let cb' :: C_DriveChangedCallback
cb' = DriveChangedCallback -> C_DriveChangedCallback
wrap_DriveDisconnectedCallback DriveChangedCallback
cb
    FunPtr C_DriveChangedCallback
cb'' <- C_DriveChangedCallback -> IO (FunPtr C_DriveChangedCallback)
mk_DriveDisconnectedCallback C_DriveChangedCallback
cb'
    a
-> String
-> FunPtr C_DriveChangedCallback
-> SignalConnectMode
-> IO SignalHandlerId
forall o a.
GObject o =>
o -> String -> FunPtr a -> SignalConnectMode -> IO SignalHandlerId
connectSignalFunPtr a
obj "disconnected" FunPtr C_DriveChangedCallback
cb'' SignalConnectMode
SignalConnectAfter


-- signal Drive::eject-button
{- |
Emitted when the physical eject button (if any) of a drive has
been pressed.
-}
type DriveEjectButtonCallback =
    IO ()

-- | A convenience synonym for @`Nothing` :: `Maybe` `DriveEjectButtonCallback`@.
noDriveEjectButtonCallback :: Maybe DriveEjectButtonCallback
noDriveEjectButtonCallback :: Maybe DriveChangedCallback
noDriveEjectButtonCallback = Maybe DriveChangedCallback
forall a. Maybe a
Nothing

-- | Type for the callback on the (unwrapped) C side.
type C_DriveEjectButtonCallback =
    Ptr () ->                               -- object
    Ptr () ->                               -- user_data
    IO ()

-- | Generate a function pointer callable from C code, from a `C_DriveEjectButtonCallback`.
foreign import ccall "wrapper"
    mk_DriveEjectButtonCallback :: C_DriveEjectButtonCallback -> IO (FunPtr C_DriveEjectButtonCallback)

-- | Wrap the callback into a `Closure`.
genClosure_DriveEjectButton :: DriveEjectButtonCallback -> IO Closure
genClosure_DriveEjectButton :: DriveChangedCallback -> IO Closure
genClosure_DriveEjectButton cb :: DriveChangedCallback
cb = do
    let cb' :: C_DriveChangedCallback
cb' = DriveChangedCallback -> C_DriveChangedCallback
wrap_DriveEjectButtonCallback DriveChangedCallback
cb
    C_DriveChangedCallback -> IO (FunPtr C_DriveChangedCallback)
mk_DriveEjectButtonCallback C_DriveChangedCallback
cb' IO (FunPtr C_DriveChangedCallback)
-> (FunPtr C_DriveChangedCallback -> IO Closure) -> IO Closure
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= FunPtr C_DriveChangedCallback -> IO Closure
forall a. FunPtr a -> IO Closure
newCClosure


-- | Wrap a `DriveEjectButtonCallback` into a `C_DriveEjectButtonCallback`.
wrap_DriveEjectButtonCallback ::
    DriveEjectButtonCallback ->
    C_DriveEjectButtonCallback
wrap_DriveEjectButtonCallback :: DriveChangedCallback -> C_DriveChangedCallback
wrap_DriveEjectButtonCallback _cb :: DriveChangedCallback
_cb _ _ = do
    DriveChangedCallback
_cb 


{- |
Connect a signal handler for the “@eject-button@” signal, to be run before the default handler.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Signals.on' drive #ejectButton callback
@
-}
onDriveEjectButton :: (IsDrive a, MonadIO m) => a -> DriveEjectButtonCallback -> m SignalHandlerId
onDriveEjectButton :: a -> DriveChangedCallback -> m SignalHandlerId
onDriveEjectButton obj :: a
obj cb :: DriveChangedCallback
cb = IO SignalHandlerId -> m SignalHandlerId
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO SignalHandlerId -> m SignalHandlerId)
-> IO SignalHandlerId -> m SignalHandlerId
forall a b. (a -> b) -> a -> b
$ do
    let cb' :: C_DriveChangedCallback
cb' = DriveChangedCallback -> C_DriveChangedCallback
wrap_DriveEjectButtonCallback DriveChangedCallback
cb
    FunPtr C_DriveChangedCallback
cb'' <- C_DriveChangedCallback -> IO (FunPtr C_DriveChangedCallback)
mk_DriveEjectButtonCallback C_DriveChangedCallback
cb'
    a
-> String
-> FunPtr C_DriveChangedCallback
-> SignalConnectMode
-> IO SignalHandlerId
forall o a.
GObject o =>
o -> String -> FunPtr a -> SignalConnectMode -> IO SignalHandlerId
connectSignalFunPtr a
obj "eject-button" FunPtr C_DriveChangedCallback
cb'' SignalConnectMode
SignalConnectBefore

{- |
Connect a signal handler for the “@eject-button@” signal, to be run after the default handler.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Signals.after' drive #ejectButton callback
@
-}
afterDriveEjectButton :: (IsDrive a, MonadIO m) => a -> DriveEjectButtonCallback -> m SignalHandlerId
afterDriveEjectButton :: a -> DriveChangedCallback -> m SignalHandlerId
afterDriveEjectButton obj :: a
obj cb :: DriveChangedCallback
cb = IO SignalHandlerId -> m SignalHandlerId
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO SignalHandlerId -> m SignalHandlerId)
-> IO SignalHandlerId -> m SignalHandlerId
forall a b. (a -> b) -> a -> b
$ do
    let cb' :: C_DriveChangedCallback
cb' = DriveChangedCallback -> C_DriveChangedCallback
wrap_DriveEjectButtonCallback DriveChangedCallback
cb
    FunPtr C_DriveChangedCallback
cb'' <- C_DriveChangedCallback -> IO (FunPtr C_DriveChangedCallback)
mk_DriveEjectButtonCallback C_DriveChangedCallback
cb'
    a
-> String
-> FunPtr C_DriveChangedCallback
-> SignalConnectMode
-> IO SignalHandlerId
forall o a.
GObject o =>
o -> String -> FunPtr a -> SignalConnectMode -> IO SignalHandlerId
connectSignalFunPtr a
obj "eject-button" FunPtr C_DriveChangedCallback
cb'' SignalConnectMode
SignalConnectAfter


-- signal Drive::stop-button
{- |
Emitted when the physical stop button (if any) of a drive has
been pressed.

/Since: 2.22/
-}
type DriveStopButtonCallback =
    IO ()

-- | A convenience synonym for @`Nothing` :: `Maybe` `DriveStopButtonCallback`@.
noDriveStopButtonCallback :: Maybe DriveStopButtonCallback
noDriveStopButtonCallback :: Maybe DriveChangedCallback
noDriveStopButtonCallback = Maybe DriveChangedCallback
forall a. Maybe a
Nothing

-- | Type for the callback on the (unwrapped) C side.
type C_DriveStopButtonCallback =
    Ptr () ->                               -- object
    Ptr () ->                               -- user_data
    IO ()

-- | Generate a function pointer callable from C code, from a `C_DriveStopButtonCallback`.
foreign import ccall "wrapper"
    mk_DriveStopButtonCallback :: C_DriveStopButtonCallback -> IO (FunPtr C_DriveStopButtonCallback)

-- | Wrap the callback into a `Closure`.
genClosure_DriveStopButton :: DriveStopButtonCallback -> IO Closure
genClosure_DriveStopButton :: DriveChangedCallback -> IO Closure
genClosure_DriveStopButton cb :: DriveChangedCallback
cb = do
    let cb' :: C_DriveChangedCallback
cb' = DriveChangedCallback -> C_DriveChangedCallback
wrap_DriveStopButtonCallback DriveChangedCallback
cb
    C_DriveChangedCallback -> IO (FunPtr C_DriveChangedCallback)
mk_DriveStopButtonCallback C_DriveChangedCallback
cb' IO (FunPtr C_DriveChangedCallback)
-> (FunPtr C_DriveChangedCallback -> IO Closure) -> IO Closure
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= FunPtr C_DriveChangedCallback -> IO Closure
forall a. FunPtr a -> IO Closure
newCClosure


-- | Wrap a `DriveStopButtonCallback` into a `C_DriveStopButtonCallback`.
wrap_DriveStopButtonCallback ::
    DriveStopButtonCallback ->
    C_DriveStopButtonCallback
wrap_DriveStopButtonCallback :: DriveChangedCallback -> C_DriveChangedCallback
wrap_DriveStopButtonCallback _cb :: DriveChangedCallback
_cb _ _ = do
    DriveChangedCallback
_cb 


{- |
Connect a signal handler for the “@stop-button@” signal, to be run before the default handler.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Signals.on' drive #stopButton callback
@
-}
onDriveStopButton :: (IsDrive a, MonadIO m) => a -> DriveStopButtonCallback -> m SignalHandlerId
onDriveStopButton :: a -> DriveChangedCallback -> m SignalHandlerId
onDriveStopButton obj :: a
obj cb :: DriveChangedCallback
cb = IO SignalHandlerId -> m SignalHandlerId
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO SignalHandlerId -> m SignalHandlerId)
-> IO SignalHandlerId -> m SignalHandlerId
forall a b. (a -> b) -> a -> b
$ do
    let cb' :: C_DriveChangedCallback
cb' = DriveChangedCallback -> C_DriveChangedCallback
wrap_DriveStopButtonCallback DriveChangedCallback
cb
    FunPtr C_DriveChangedCallback
cb'' <- C_DriveChangedCallback -> IO (FunPtr C_DriveChangedCallback)
mk_DriveStopButtonCallback C_DriveChangedCallback
cb'
    a
-> String
-> FunPtr C_DriveChangedCallback
-> SignalConnectMode
-> IO SignalHandlerId
forall o a.
GObject o =>
o -> String -> FunPtr a -> SignalConnectMode -> IO SignalHandlerId
connectSignalFunPtr a
obj "stop-button" FunPtr C_DriveChangedCallback
cb'' SignalConnectMode
SignalConnectBefore

{- |
Connect a signal handler for the “@stop-button@” signal, to be run after the default handler.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Signals.after' drive #stopButton callback
@
-}
afterDriveStopButton :: (IsDrive a, MonadIO m) => a -> DriveStopButtonCallback -> m SignalHandlerId
afterDriveStopButton :: a -> DriveChangedCallback -> m SignalHandlerId
afterDriveStopButton obj :: a
obj cb :: DriveChangedCallback
cb = IO SignalHandlerId -> m SignalHandlerId
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO SignalHandlerId -> m SignalHandlerId)
-> IO SignalHandlerId -> m SignalHandlerId
forall a b. (a -> b) -> a -> b
$ do
    let cb' :: C_DriveChangedCallback
cb' = DriveChangedCallback -> C_DriveChangedCallback
wrap_DriveStopButtonCallback DriveChangedCallback
cb
    FunPtr C_DriveChangedCallback
cb'' <- C_DriveChangedCallback -> IO (FunPtr C_DriveChangedCallback)
mk_DriveStopButtonCallback C_DriveChangedCallback
cb'
    a
-> String
-> FunPtr C_DriveChangedCallback
-> SignalConnectMode
-> IO SignalHandlerId
forall o a.
GObject o =>
o -> String -> FunPtr a -> SignalConnectMode -> IO SignalHandlerId
connectSignalFunPtr a
obj "stop-button" FunPtr C_DriveChangedCallback
cb'' SignalConnectMode
SignalConnectAfter


#if ENABLE_OVERLOADING
data DriveChangedSignalInfo
instance SignalInfo DriveChangedSignalInfo where
    type HaskellCallbackType DriveChangedSignalInfo = DriveChangedCallback
    connectSignal _ obj cb connectMode = do
        let cb' = wrap_DriveChangedCallback cb
        cb'' <- mk_DriveChangedCallback cb'
        connectSignalFunPtr obj "changed" cb'' connectMode

data DriveDisconnectedSignalInfo
instance SignalInfo DriveDisconnectedSignalInfo where
    type HaskellCallbackType DriveDisconnectedSignalInfo = DriveDisconnectedCallback
    connectSignal _ obj cb connectMode = do
        let cb' = wrap_DriveDisconnectedCallback cb
        cb'' <- mk_DriveDisconnectedCallback cb'
        connectSignalFunPtr obj "disconnected" cb'' connectMode

data DriveEjectButtonSignalInfo
instance SignalInfo DriveEjectButtonSignalInfo where
    type HaskellCallbackType DriveEjectButtonSignalInfo = DriveEjectButtonCallback
    connectSignal _ obj cb connectMode = do
        let cb' = wrap_DriveEjectButtonCallback cb
        cb'' <- mk_DriveEjectButtonCallback cb'
        connectSignalFunPtr obj "eject-button" cb'' connectMode

data DriveStopButtonSignalInfo
instance SignalInfo DriveStopButtonSignalInfo where
    type HaskellCallbackType DriveStopButtonSignalInfo = DriveStopButtonCallback
    connectSignal _ obj cb connectMode = do
        let cb' = wrap_DriveStopButtonCallback cb
        cb'' <- mk_DriveStopButtonCallback cb'
        connectSignalFunPtr obj "stop-button" cb'' connectMode

type instance O.SignalList Drive = DriveSignalList
type DriveSignalList = ('[ '("changed", DriveChangedSignalInfo), '("disconnected", DriveDisconnectedSignalInfo), '("ejectButton", DriveEjectButtonSignalInfo), '("notify", GObject.Object.ObjectNotifySignalInfo), '("stopButton", DriveStopButtonSignalInfo)] :: [(Symbol, *)])

#endif

foreign import ccall "g_drive_get_type"
    c_g_drive_get_type :: IO GType

instance GObject Drive where
    gobjectType :: Drive -> IO GType
gobjectType _ = IO GType
c_g_drive_get_type
    

-- | Type class for types which can be safely cast to `Drive`, for instance with `toDrive`.
class GObject o => IsDrive o
#if MIN_VERSION_base(4,9,0)
instance {-# OVERLAPPABLE #-} (GObject a, O.UnknownAncestorError Drive a) =>
    IsDrive a
#endif
instance IsDrive Drive
instance GObject.Object.IsObject Drive

-- | Cast to `Drive`, for types for which this is known to be safe. For general casts, use `Data.GI.Base.ManagedPtr.castTo`.
toDrive :: (MonadIO m, IsDrive o) => o -> m Drive
toDrive :: o -> m Drive
toDrive = IO Drive -> m Drive
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Drive -> m Drive) -> (o -> IO Drive) -> o -> m Drive
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ManagedPtr Drive -> Drive) -> o -> IO Drive
forall o o'.
(HasCallStack, GObject o, GObject o') =>
(ManagedPtr o' -> o') -> o -> IO o'
unsafeCastTo ManagedPtr Drive -> Drive
Drive

#if ENABLE_OVERLOADING
instance O.HasAttributeList Drive
type instance O.AttributeList Drive = DriveAttributeList
type DriveAttributeList = ('[ ] :: [(Symbol, *)])
#endif

#if ENABLE_OVERLOADING
#endif

#if ENABLE_OVERLOADING
type family ResolveDriveMethod (t :: Symbol) (o :: *) :: * where
    ResolveDriveMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
    ResolveDriveMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
    ResolveDriveMethod "canEject" o = DriveCanEjectMethodInfo
    ResolveDriveMethod "canPollForMedia" o = DriveCanPollForMediaMethodInfo
    ResolveDriveMethod "canStart" o = DriveCanStartMethodInfo
    ResolveDriveMethod "canStartDegraded" o = DriveCanStartDegradedMethodInfo
    ResolveDriveMethod "canStop" o = DriveCanStopMethodInfo
    ResolveDriveMethod "eject" o = DriveEjectMethodInfo
    ResolveDriveMethod "ejectFinish" o = DriveEjectFinishMethodInfo
    ResolveDriveMethod "ejectWithOperation" o = DriveEjectWithOperationMethodInfo
    ResolveDriveMethod "ejectWithOperationFinish" o = DriveEjectWithOperationFinishMethodInfo
    ResolveDriveMethod "enumerateIdentifiers" o = DriveEnumerateIdentifiersMethodInfo
    ResolveDriveMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
    ResolveDriveMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
    ResolveDriveMethod "getv" o = GObject.Object.ObjectGetvMethodInfo
    ResolveDriveMethod "hasMedia" o = DriveHasMediaMethodInfo
    ResolveDriveMethod "hasVolumes" o = DriveHasVolumesMethodInfo
    ResolveDriveMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
    ResolveDriveMethod "isMediaCheckAutomatic" o = DriveIsMediaCheckAutomaticMethodInfo
    ResolveDriveMethod "isMediaRemovable" o = DriveIsMediaRemovableMethodInfo
    ResolveDriveMethod "isRemovable" o = DriveIsRemovableMethodInfo
    ResolveDriveMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
    ResolveDriveMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
    ResolveDriveMethod "pollForMedia" o = DrivePollForMediaMethodInfo
    ResolveDriveMethod "pollForMediaFinish" o = DrivePollForMediaFinishMethodInfo
    ResolveDriveMethod "ref" o = GObject.Object.ObjectRefMethodInfo
    ResolveDriveMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
    ResolveDriveMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
    ResolveDriveMethod "start" o = DriveStartMethodInfo
    ResolveDriveMethod "startFinish" o = DriveStartFinishMethodInfo
    ResolveDriveMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
    ResolveDriveMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
    ResolveDriveMethod "stop" o = DriveStopMethodInfo
    ResolveDriveMethod "stopFinish" o = DriveStopFinishMethodInfo
    ResolveDriveMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
    ResolveDriveMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
    ResolveDriveMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
    ResolveDriveMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
    ResolveDriveMethod "getIcon" o = DriveGetIconMethodInfo
    ResolveDriveMethod "getIdentifier" o = DriveGetIdentifierMethodInfo
    ResolveDriveMethod "getName" o = DriveGetNameMethodInfo
    ResolveDriveMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
    ResolveDriveMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
    ResolveDriveMethod "getSortKey" o = DriveGetSortKeyMethodInfo
    ResolveDriveMethod "getStartStopType" o = DriveGetStartStopTypeMethodInfo
    ResolveDriveMethod "getSymbolicIcon" o = DriveGetSymbolicIconMethodInfo
    ResolveDriveMethod "getVolumes" o = DriveGetVolumesMethodInfo
    ResolveDriveMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
    ResolveDriveMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolveDriveMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveDriveMethod t Drive, O.MethodInfo info Drive p) => O.IsLabelProxy t (Drive -> p) where
    fromLabelProxy _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)

#if MIN_VERSION_base(4,9,0)
instance (info ~ ResolveDriveMethod t Drive, O.MethodInfo info Drive p) => O.IsLabel t (Drive -> p) where
#if MIN_VERSION_base(4,10,0)
    fromLabel = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#else
    fromLabel _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#endif
#endif

#endif

-- method Drive::can_eject
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "drive", argType = TInterface (Name {namespace = "Gio", name = "Drive"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GDrive.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "g_drive_can_eject" g_drive_can_eject :: 
    Ptr Drive ->                            -- drive : TInterface (Name {namespace = "Gio", name = "Drive"})
    IO CInt

{- |
Checks if a drive can be ejected.
-}
driveCanEject ::
    (B.CallStack.HasCallStack, MonadIO m, IsDrive a) =>
    a
    {- ^ /@drive@/: a 'GI.Gio.Interfaces.Drive.Drive'. -}
    -> m Bool
    {- ^ __Returns:__ 'True' if the /@drive@/ can be ejected, 'False' otherwise. -}
driveCanEject :: a -> m Bool
driveCanEject drive :: a
drive = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    Ptr Drive
drive' <- a -> IO (Ptr Drive)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
drive
    CInt
result <- Ptr Drive -> IO CInt
g_drive_can_eject Ptr Drive
drive'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    a -> DriveChangedCallback
forall a. ManagedPtrNewtype a => a -> DriveChangedCallback
touchManagedPtr a
drive
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'

#if ENABLE_OVERLOADING
data DriveCanEjectMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsDrive a) => O.MethodInfo DriveCanEjectMethodInfo a signature where
    overloadedMethod _ = driveCanEject

#endif

-- method Drive::can_poll_for_media
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "drive", argType = TInterface (Name {namespace = "Gio", name = "Drive"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GDrive.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "g_drive_can_poll_for_media" g_drive_can_poll_for_media :: 
    Ptr Drive ->                            -- drive : TInterface (Name {namespace = "Gio", name = "Drive"})
    IO CInt

{- |
Checks if a drive can be polled for media changes.
-}
driveCanPollForMedia ::
    (B.CallStack.HasCallStack, MonadIO m, IsDrive a) =>
    a
    {- ^ /@drive@/: a 'GI.Gio.Interfaces.Drive.Drive'. -}
    -> m Bool
    {- ^ __Returns:__ 'True' if the /@drive@/ can be polled for media changes,
    'False' otherwise. -}
driveCanPollForMedia :: a -> m Bool
driveCanPollForMedia drive :: a
drive = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    Ptr Drive
drive' <- a -> IO (Ptr Drive)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
drive
    CInt
result <- Ptr Drive -> IO CInt
g_drive_can_poll_for_media Ptr Drive
drive'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    a -> DriveChangedCallback
forall a. ManagedPtrNewtype a => a -> DriveChangedCallback
touchManagedPtr a
drive
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'

#if ENABLE_OVERLOADING
data DriveCanPollForMediaMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsDrive a) => O.MethodInfo DriveCanPollForMediaMethodInfo a signature where
    overloadedMethod _ = driveCanPollForMedia

#endif

-- method Drive::can_start
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "drive", argType = TInterface (Name {namespace = "Gio", name = "Drive"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GDrive.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "g_drive_can_start" g_drive_can_start :: 
    Ptr Drive ->                            -- drive : TInterface (Name {namespace = "Gio", name = "Drive"})
    IO CInt

{- |
Checks if a drive can be started.

/Since: 2.22/
-}
driveCanStart ::
    (B.CallStack.HasCallStack, MonadIO m, IsDrive a) =>
    a
    {- ^ /@drive@/: a 'GI.Gio.Interfaces.Drive.Drive'. -}
    -> m Bool
    {- ^ __Returns:__ 'True' if the /@drive@/ can be started, 'False' otherwise. -}
driveCanStart :: a -> m Bool
driveCanStart drive :: a
drive = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    Ptr Drive
drive' <- a -> IO (Ptr Drive)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
drive
    CInt
result <- Ptr Drive -> IO CInt
g_drive_can_start Ptr Drive
drive'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    a -> DriveChangedCallback
forall a. ManagedPtrNewtype a => a -> DriveChangedCallback
touchManagedPtr a
drive
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'

#if ENABLE_OVERLOADING
data DriveCanStartMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsDrive a) => O.MethodInfo DriveCanStartMethodInfo a signature where
    overloadedMethod _ = driveCanStart

#endif

-- method Drive::can_start_degraded
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "drive", argType = TInterface (Name {namespace = "Gio", name = "Drive"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GDrive.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "g_drive_can_start_degraded" g_drive_can_start_degraded :: 
    Ptr Drive ->                            -- drive : TInterface (Name {namespace = "Gio", name = "Drive"})
    IO CInt

{- |
Checks if a drive can be started degraded.

/Since: 2.22/
-}
driveCanStartDegraded ::
    (B.CallStack.HasCallStack, MonadIO m, IsDrive a) =>
    a
    {- ^ /@drive@/: a 'GI.Gio.Interfaces.Drive.Drive'. -}
    -> m Bool
    {- ^ __Returns:__ 'True' if the /@drive@/ can be started degraded, 'False' otherwise. -}
driveCanStartDegraded :: a -> m Bool
driveCanStartDegraded drive :: a
drive = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    Ptr Drive
drive' <- a -> IO (Ptr Drive)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
drive
    CInt
result <- Ptr Drive -> IO CInt
g_drive_can_start_degraded Ptr Drive
drive'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    a -> DriveChangedCallback
forall a. ManagedPtrNewtype a => a -> DriveChangedCallback
touchManagedPtr a
drive
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'

#if ENABLE_OVERLOADING
data DriveCanStartDegradedMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsDrive a) => O.MethodInfo DriveCanStartDegradedMethodInfo a signature where
    overloadedMethod _ = driveCanStartDegraded

#endif

-- method Drive::can_stop
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "drive", argType = TInterface (Name {namespace = "Gio", name = "Drive"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GDrive.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "g_drive_can_stop" g_drive_can_stop :: 
    Ptr Drive ->                            -- drive : TInterface (Name {namespace = "Gio", name = "Drive"})
    IO CInt

{- |
Checks if a drive can be stopped.

/Since: 2.22/
-}
driveCanStop ::
    (B.CallStack.HasCallStack, MonadIO m, IsDrive a) =>
    a
    {- ^ /@drive@/: a 'GI.Gio.Interfaces.Drive.Drive'. -}
    -> m Bool
    {- ^ __Returns:__ 'True' if the /@drive@/ can be stopped, 'False' otherwise. -}
driveCanStop :: a -> m Bool
driveCanStop drive :: a
drive = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    Ptr Drive
drive' <- a -> IO (Ptr Drive)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
drive
    CInt
result <- Ptr Drive -> IO CInt
g_drive_can_stop Ptr Drive
drive'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    a -> DriveChangedCallback
forall a. ManagedPtrNewtype a => a -> DriveChangedCallback
touchManagedPtr a
drive
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'

#if ENABLE_OVERLOADING
data DriveCanStopMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsDrive a) => O.MethodInfo DriveCanStopMethodInfo a signature where
    overloadedMethod _ = driveCanStop

#endif

-- method Drive::eject
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "drive", argType = TInterface (Name {namespace = "Gio", name = "Drive"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GDrive.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "flags", argType = TInterface (Name {namespace = "Gio", name = "MountUnmountFlags"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "flags affecting the unmount if required for eject", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "optional #GCancellable object, %NULL to ignore.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "callback", argType = TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GAsyncReadyCallback, or %NULL.", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = 4, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "user data to pass to @callback", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_drive_eject" g_drive_eject :: 
    Ptr Drive ->                            -- drive : TInterface (Name {namespace = "Gio", name = "Drive"})
    CUInt ->                                -- flags : TInterface (Name {namespace = "Gio", name = "MountUnmountFlags"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    FunPtr Gio.Callbacks.C_AsyncReadyCallback -> -- callback : TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"})
    Ptr () ->                               -- user_data : TBasicType TPtr
    IO ()

{-# DEPRECATED driveEject ["(Since version 2.22)","Use 'GI.Gio.Interfaces.Drive.driveEjectWithOperation' instead."] #-}
{- |
Asynchronously ejects a drive.

When the operation is finished, /@callback@/ will be called.
You can then call 'GI.Gio.Interfaces.Drive.driveEjectFinish' to obtain the
result of the operation.
-}
driveEject ::
    (B.CallStack.HasCallStack, MonadIO m, IsDrive a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@drive@/: a 'GI.Gio.Interfaces.Drive.Drive'. -}
    -> [Gio.Flags.MountUnmountFlags]
    {- ^ /@flags@/: flags affecting the unmount if required for eject -}
    -> Maybe (b)
    {- ^ /@cancellable@/: optional 'GI.Gio.Objects.Cancellable.Cancellable' object, 'Nothing' to ignore. -}
    -> Maybe (Gio.Callbacks.AsyncReadyCallback)
    {- ^ /@callback@/: a 'GI.Gio.Callbacks.AsyncReadyCallback', or 'Nothing'. -}
    -> m ()
driveEject :: a
-> [MountUnmountFlags]
-> Maybe b
-> Maybe AsyncReadyCallback
-> m ()
driveEject drive :: a
drive flags :: [MountUnmountFlags]
flags cancellable :: Maybe b
cancellable callback :: Maybe AsyncReadyCallback
callback = DriveChangedCallback -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (DriveChangedCallback -> m ()) -> DriveChangedCallback -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr Drive
drive' <- a -> IO (Ptr Drive)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
drive
    let flags' :: CUInt
flags' = [MountUnmountFlags] -> CUInt
forall b a. (Num b, IsGFlag a) => [a] -> b
gflagsToWord [MountUnmountFlags]
flags
    Ptr Cancellable
maybeCancellable <- case Maybe b
cancellable of
        Nothing -> Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
forall a. Ptr a
nullPtr
        Just jCancellable :: b
jCancellable -> do
            Ptr Cancellable
jCancellable' <- b -> IO (Ptr Cancellable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
jCancellable
            Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
jCancellable'
    FunPtr C_AsyncReadyCallback
maybeCallback <- case Maybe AsyncReadyCallback
callback of
        Nothing -> FunPtr C_AsyncReadyCallback -> IO (FunPtr C_AsyncReadyCallback)
forall (m :: * -> *) a. Monad m => a -> m a
return (Ptr Any -> FunPtr C_AsyncReadyCallback
forall a b. Ptr a -> FunPtr b
castPtrToFunPtr Ptr Any
forall a. Ptr a
nullPtr)
        Just jCallback :: AsyncReadyCallback
jCallback -> do
            Ptr (FunPtr C_AsyncReadyCallback)
ptrcallback <- IO (Ptr (FunPtr C_AsyncReadyCallback))
forall a. Storable a => IO (Ptr a)
callocMem :: IO (Ptr (FunPtr Gio.Callbacks.C_AsyncReadyCallback))
            FunPtr C_AsyncReadyCallback
jCallback' <- C_AsyncReadyCallback -> IO (FunPtr C_AsyncReadyCallback)
Gio.Callbacks.mk_AsyncReadyCallback (Maybe (Ptr (FunPtr C_AsyncReadyCallback))
-> AsyncReadyCallback_WithClosures -> C_AsyncReadyCallback
Gio.Callbacks.wrap_AsyncReadyCallback (Ptr (FunPtr C_AsyncReadyCallback)
-> Maybe (Ptr (FunPtr C_AsyncReadyCallback))
forall a. a -> Maybe a
Just Ptr (FunPtr C_AsyncReadyCallback)
ptrcallback) (AsyncReadyCallback -> AsyncReadyCallback_WithClosures
Gio.Callbacks.drop_closures_AsyncReadyCallback AsyncReadyCallback
jCallback))
            Ptr (FunPtr C_AsyncReadyCallback)
-> FunPtr C_AsyncReadyCallback -> DriveChangedCallback
forall a. Storable a => Ptr a -> a -> DriveChangedCallback
poke Ptr (FunPtr C_AsyncReadyCallback)
ptrcallback FunPtr C_AsyncReadyCallback
jCallback'
            FunPtr C_AsyncReadyCallback -> IO (FunPtr C_AsyncReadyCallback)
forall (m :: * -> *) a. Monad m => a -> m a
return FunPtr C_AsyncReadyCallback
jCallback'
    let userData :: Ptr a
userData = Ptr a
forall a. Ptr a
nullPtr
    Ptr Drive
-> CUInt
-> Ptr Cancellable
-> FunPtr C_AsyncReadyCallback
-> Ptr ()
-> DriveChangedCallback
g_drive_eject Ptr Drive
drive' CUInt
flags' Ptr Cancellable
maybeCancellable FunPtr C_AsyncReadyCallback
maybeCallback Ptr ()
forall a. Ptr a
userData
    a -> DriveChangedCallback
forall a. ManagedPtrNewtype a => a -> DriveChangedCallback
touchManagedPtr a
drive
    Maybe b -> (b -> DriveChangedCallback) -> DriveChangedCallback
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe b
cancellable b -> DriveChangedCallback
forall a. ManagedPtrNewtype a => a -> DriveChangedCallback
touchManagedPtr
    () -> DriveChangedCallback
forall (m :: * -> *) a. Monad m => a -> m a
return ()

#if ENABLE_OVERLOADING
data DriveEjectMethodInfo
instance (signature ~ ([Gio.Flags.MountUnmountFlags] -> Maybe (b) -> Maybe (Gio.Callbacks.AsyncReadyCallback) -> m ()), MonadIO m, IsDrive a, Gio.Cancellable.IsCancellable b) => O.MethodInfo DriveEjectMethodInfo a signature where
    overloadedMethod _ = driveEject

#endif

-- method Drive::eject_finish
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "drive", argType = TInterface (Name {namespace = "Gio", name = "Drive"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GDrive.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "result", argType = TInterface (Name {namespace = "Gio", name = "AsyncResult"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GAsyncResult.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "g_drive_eject_finish" g_drive_eject_finish :: 
    Ptr Drive ->                            -- drive : TInterface (Name {namespace = "Gio", name = "Drive"})
    Ptr Gio.AsyncResult.AsyncResult ->      -- result : TInterface (Name {namespace = "Gio", name = "AsyncResult"})
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{-# DEPRECATED driveEjectFinish ["(Since version 2.22)","Use 'GI.Gio.Interfaces.Drive.driveEjectWithOperationFinish' instead."] #-}
{- |
Finishes ejecting a drive.
-}
driveEjectFinish ::
    (B.CallStack.HasCallStack, MonadIO m, IsDrive a, Gio.AsyncResult.IsAsyncResult b) =>
    a
    {- ^ /@drive@/: a 'GI.Gio.Interfaces.Drive.Drive'. -}
    -> b
    {- ^ /@result@/: a 'GI.Gio.Interfaces.AsyncResult.AsyncResult'. -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
driveEjectFinish :: a -> b -> m ()
driveEjectFinish drive :: a
drive result_ :: b
result_ = DriveChangedCallback -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (DriveChangedCallback -> m ()) -> DriveChangedCallback -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr Drive
drive' <- a -> IO (Ptr Drive)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
drive
    Ptr AsyncResult
result_' <- b -> IO (Ptr AsyncResult)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
result_
    DriveChangedCallback
-> DriveChangedCallback -> DriveChangedCallback
forall a b. IO a -> IO b -> IO a
onException (do
        CInt
_ <- (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CInt) -> IO CInt)
-> (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ Ptr Drive -> Ptr AsyncResult -> Ptr (Ptr GError) -> IO CInt
g_drive_eject_finish Ptr Drive
drive' Ptr AsyncResult
result_'
        a -> DriveChangedCallback
forall a. ManagedPtrNewtype a => a -> DriveChangedCallback
touchManagedPtr a
drive
        b -> DriveChangedCallback
forall a. ManagedPtrNewtype a => a -> DriveChangedCallback
touchManagedPtr b
result_
        () -> DriveChangedCallback
forall (m :: * -> *) a. Monad m => a -> m a
return ()
     ) (do
        () -> DriveChangedCallback
forall (m :: * -> *) a. Monad m => a -> m a
return ()
     )

#if ENABLE_OVERLOADING
data DriveEjectFinishMethodInfo
instance (signature ~ (b -> m ()), MonadIO m, IsDrive a, Gio.AsyncResult.IsAsyncResult b) => O.MethodInfo DriveEjectFinishMethodInfo a signature where
    overloadedMethod _ = driveEjectFinish

#endif

-- method Drive::eject_with_operation
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "drive", argType = TInterface (Name {namespace = "Gio", name = "Drive"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GDrive.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "flags", argType = TInterface (Name {namespace = "Gio", name = "MountUnmountFlags"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "flags affecting the unmount if required for eject", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "mount_operation", argType = TInterface (Name {namespace = "Gio", name = "MountOperation"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GMountOperation or %NULL to avoid\n    user interaction.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "optional #GCancellable object, %NULL to ignore.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "callback", argType = TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GAsyncReadyCallback, or %NULL.", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = 5, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "user data passed to @callback.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_drive_eject_with_operation" g_drive_eject_with_operation :: 
    Ptr Drive ->                            -- drive : TInterface (Name {namespace = "Gio", name = "Drive"})
    CUInt ->                                -- flags : TInterface (Name {namespace = "Gio", name = "MountUnmountFlags"})
    Ptr Gio.MountOperation.MountOperation -> -- mount_operation : TInterface (Name {namespace = "Gio", name = "MountOperation"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    FunPtr Gio.Callbacks.C_AsyncReadyCallback -> -- callback : TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"})
    Ptr () ->                               -- user_data : TBasicType TPtr
    IO ()

{- |
Ejects a drive. This is an asynchronous operation, and is
finished by calling 'GI.Gio.Interfaces.Drive.driveEjectWithOperationFinish' with the /@drive@/
and 'GI.Gio.Interfaces.AsyncResult.AsyncResult' data returned in the /@callback@/.

/Since: 2.22/
-}
driveEjectWithOperation ::
    (B.CallStack.HasCallStack, MonadIO m, IsDrive a, Gio.MountOperation.IsMountOperation b, Gio.Cancellable.IsCancellable c) =>
    a
    {- ^ /@drive@/: a 'GI.Gio.Interfaces.Drive.Drive'. -}
    -> [Gio.Flags.MountUnmountFlags]
    {- ^ /@flags@/: flags affecting the unmount if required for eject -}
    -> Maybe (b)
    {- ^ /@mountOperation@/: a 'GI.Gio.Objects.MountOperation.MountOperation' or 'Nothing' to avoid
    user interaction. -}
    -> Maybe (c)
    {- ^ /@cancellable@/: optional 'GI.Gio.Objects.Cancellable.Cancellable' object, 'Nothing' to ignore. -}
    -> Maybe (Gio.Callbacks.AsyncReadyCallback)
    {- ^ /@callback@/: a 'GI.Gio.Callbacks.AsyncReadyCallback', or 'Nothing'. -}
    -> m ()
driveEjectWithOperation :: a
-> [MountUnmountFlags]
-> Maybe b
-> Maybe c
-> Maybe AsyncReadyCallback
-> m ()
driveEjectWithOperation drive :: a
drive flags :: [MountUnmountFlags]
flags mountOperation :: Maybe b
mountOperation cancellable :: Maybe c
cancellable callback :: Maybe AsyncReadyCallback
callback = DriveChangedCallback -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (DriveChangedCallback -> m ()) -> DriveChangedCallback -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr Drive
drive' <- a -> IO (Ptr Drive)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
drive
    let flags' :: CUInt
flags' = [MountUnmountFlags] -> CUInt
forall b a. (Num b, IsGFlag a) => [a] -> b
gflagsToWord [MountUnmountFlags]
flags
    Ptr MountOperation
maybeMountOperation <- case Maybe b
mountOperation of
        Nothing -> Ptr MountOperation -> IO (Ptr MountOperation)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr MountOperation
forall a. Ptr a
nullPtr
        Just jMountOperation :: b
jMountOperation -> do
            Ptr MountOperation
jMountOperation' <- b -> IO (Ptr MountOperation)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
jMountOperation
            Ptr MountOperation -> IO (Ptr MountOperation)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr MountOperation
jMountOperation'
    Ptr Cancellable
maybeCancellable <- case Maybe c
cancellable of
        Nothing -> Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
forall a. Ptr a
nullPtr
        Just jCancellable :: c
jCancellable -> do
            Ptr Cancellable
jCancellable' <- c -> IO (Ptr Cancellable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr c
jCancellable
            Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
jCancellable'
    FunPtr C_AsyncReadyCallback
maybeCallback <- case Maybe AsyncReadyCallback
callback of
        Nothing -> FunPtr C_AsyncReadyCallback -> IO (FunPtr C_AsyncReadyCallback)
forall (m :: * -> *) a. Monad m => a -> m a
return (Ptr Any -> FunPtr C_AsyncReadyCallback
forall a b. Ptr a -> FunPtr b
castPtrToFunPtr Ptr Any
forall a. Ptr a
nullPtr)
        Just jCallback :: AsyncReadyCallback
jCallback -> do
            Ptr (FunPtr C_AsyncReadyCallback)
ptrcallback <- IO (Ptr (FunPtr C_AsyncReadyCallback))
forall a. Storable a => IO (Ptr a)
callocMem :: IO (Ptr (FunPtr Gio.Callbacks.C_AsyncReadyCallback))
            FunPtr C_AsyncReadyCallback
jCallback' <- C_AsyncReadyCallback -> IO (FunPtr C_AsyncReadyCallback)
Gio.Callbacks.mk_AsyncReadyCallback (Maybe (Ptr (FunPtr C_AsyncReadyCallback))
-> AsyncReadyCallback_WithClosures -> C_AsyncReadyCallback
Gio.Callbacks.wrap_AsyncReadyCallback (Ptr (FunPtr C_AsyncReadyCallback)
-> Maybe (Ptr (FunPtr C_AsyncReadyCallback))
forall a. a -> Maybe a
Just Ptr (FunPtr C_AsyncReadyCallback)
ptrcallback) (AsyncReadyCallback -> AsyncReadyCallback_WithClosures
Gio.Callbacks.drop_closures_AsyncReadyCallback AsyncReadyCallback
jCallback))
            Ptr (FunPtr C_AsyncReadyCallback)
-> FunPtr C_AsyncReadyCallback -> DriveChangedCallback
forall a. Storable a => Ptr a -> a -> DriveChangedCallback
poke Ptr (FunPtr C_AsyncReadyCallback)
ptrcallback FunPtr C_AsyncReadyCallback
jCallback'
            FunPtr C_AsyncReadyCallback -> IO (FunPtr C_AsyncReadyCallback)
forall (m :: * -> *) a. Monad m => a -> m a
return FunPtr C_AsyncReadyCallback
jCallback'
    let userData :: Ptr a
userData = Ptr a
forall a. Ptr a
nullPtr
    Ptr Drive
-> CUInt
-> Ptr MountOperation
-> Ptr Cancellable
-> FunPtr C_AsyncReadyCallback
-> Ptr ()
-> DriveChangedCallback
g_drive_eject_with_operation Ptr Drive
drive' CUInt
flags' Ptr MountOperation
maybeMountOperation Ptr Cancellable
maybeCancellable FunPtr C_AsyncReadyCallback
maybeCallback Ptr ()
forall a. Ptr a
userData
    a -> DriveChangedCallback
forall a. ManagedPtrNewtype a => a -> DriveChangedCallback
touchManagedPtr a
drive
    Maybe b -> (b -> DriveChangedCallback) -> DriveChangedCallback
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe b
mountOperation b -> DriveChangedCallback
forall a. ManagedPtrNewtype a => a -> DriveChangedCallback
touchManagedPtr
    Maybe c -> (c -> DriveChangedCallback) -> DriveChangedCallback
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe c
cancellable c -> DriveChangedCallback
forall a. ManagedPtrNewtype a => a -> DriveChangedCallback
touchManagedPtr
    () -> DriveChangedCallback
forall (m :: * -> *) a. Monad m => a -> m a
return ()

#if ENABLE_OVERLOADING
data DriveEjectWithOperationMethodInfo
instance (signature ~ ([Gio.Flags.MountUnmountFlags] -> Maybe (b) -> Maybe (c) -> Maybe (Gio.Callbacks.AsyncReadyCallback) -> m ()), MonadIO m, IsDrive a, Gio.MountOperation.IsMountOperation b, Gio.Cancellable.IsCancellable c) => O.MethodInfo DriveEjectWithOperationMethodInfo a signature where
    overloadedMethod _ = driveEjectWithOperation

#endif

-- method Drive::eject_with_operation_finish
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "drive", argType = TInterface (Name {namespace = "Gio", name = "Drive"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GDrive.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "result", argType = TInterface (Name {namespace = "Gio", name = "AsyncResult"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GAsyncResult.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "g_drive_eject_with_operation_finish" g_drive_eject_with_operation_finish :: 
    Ptr Drive ->                            -- drive : TInterface (Name {namespace = "Gio", name = "Drive"})
    Ptr Gio.AsyncResult.AsyncResult ->      -- result : TInterface (Name {namespace = "Gio", name = "AsyncResult"})
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
Finishes ejecting a drive. If any errors occurred during the operation,
/@error@/ will be set to contain the errors and 'False' will be returned.

/Since: 2.22/
-}
driveEjectWithOperationFinish ::
    (B.CallStack.HasCallStack, MonadIO m, IsDrive a, Gio.AsyncResult.IsAsyncResult b) =>
    a
    {- ^ /@drive@/: a 'GI.Gio.Interfaces.Drive.Drive'. -}
    -> b
    {- ^ /@result@/: a 'GI.Gio.Interfaces.AsyncResult.AsyncResult'. -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
driveEjectWithOperationFinish :: a -> b -> m ()
driveEjectWithOperationFinish drive :: a
drive result_ :: b
result_ = DriveChangedCallback -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (DriveChangedCallback -> m ()) -> DriveChangedCallback -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr Drive
drive' <- a -> IO (Ptr Drive)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
drive
    Ptr AsyncResult
result_' <- b -> IO (Ptr AsyncResult)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
result_
    DriveChangedCallback
-> DriveChangedCallback -> DriveChangedCallback
forall a b. IO a -> IO b -> IO a
onException (do
        CInt
_ <- (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CInt) -> IO CInt)
-> (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ Ptr Drive -> Ptr AsyncResult -> Ptr (Ptr GError) -> IO CInt
g_drive_eject_with_operation_finish Ptr Drive
drive' Ptr AsyncResult
result_'
        a -> DriveChangedCallback
forall a. ManagedPtrNewtype a => a -> DriveChangedCallback
touchManagedPtr a
drive
        b -> DriveChangedCallback
forall a. ManagedPtrNewtype a => a -> DriveChangedCallback
touchManagedPtr b
result_
        () -> DriveChangedCallback
forall (m :: * -> *) a. Monad m => a -> m a
return ()
     ) (do
        () -> DriveChangedCallback
forall (m :: * -> *) a. Monad m => a -> m a
return ()
     )

#if ENABLE_OVERLOADING
data DriveEjectWithOperationFinishMethodInfo
instance (signature ~ (b -> m ()), MonadIO m, IsDrive a, Gio.AsyncResult.IsAsyncResult b) => O.MethodInfo DriveEjectWithOperationFinishMethodInfo a signature where
    overloadedMethod _ = driveEjectWithOperationFinish

#endif

-- method Drive::enumerate_identifiers
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "drive", argType = TInterface (Name {namespace = "Gio", name = "Drive"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GDrive", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TCArray True (-1) (-1) (TBasicType TUTF8))
-- throws : False
-- Skip return : False

foreign import ccall "g_drive_enumerate_identifiers" g_drive_enumerate_identifiers :: 
    Ptr Drive ->                            -- drive : TInterface (Name {namespace = "Gio", name = "Drive"})
    IO (Ptr CString)

{- |
Gets the kinds of identifiers that /@drive@/ has.
Use 'GI.Gio.Interfaces.Drive.driveGetIdentifier' to obtain the identifiers
themselves.
-}
driveEnumerateIdentifiers ::
    (B.CallStack.HasCallStack, MonadIO m, IsDrive a) =>
    a
    {- ^ /@drive@/: a 'GI.Gio.Interfaces.Drive.Drive' -}
    -> m [T.Text]
    {- ^ __Returns:__ a 'Nothing'-terminated
    array of strings containing kinds of identifiers. Use 'GI.GLib.Functions.strfreev'
    to free. -}
driveEnumerateIdentifiers :: a -> m [Text]
driveEnumerateIdentifiers drive :: a
drive = IO [Text] -> m [Text]
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO [Text] -> m [Text]) -> IO [Text] -> m [Text]
forall a b. (a -> b) -> a -> b
$ do
    Ptr Drive
drive' <- a -> IO (Ptr Drive)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
drive
    Ptr CString
result <- Ptr Drive -> IO (Ptr CString)
g_drive_enumerate_identifiers Ptr Drive
drive'
    Text -> Ptr CString -> DriveChangedCallback
forall a. HasCallStack => Text -> Ptr a -> DriveChangedCallback
checkUnexpectedReturnNULL "driveEnumerateIdentifiers" Ptr CString
result
    [Text]
result' <- HasCallStack => Ptr CString -> IO [Text]
Ptr CString -> IO [Text]
unpackZeroTerminatedUTF8CArray Ptr CString
result
    (CString -> DriveChangedCallback)
-> Ptr CString -> DriveChangedCallback
forall a b. (Ptr a -> IO b) -> Ptr (Ptr a) -> DriveChangedCallback
mapZeroTerminatedCArray CString -> DriveChangedCallback
forall a. Ptr a -> DriveChangedCallback
freeMem Ptr CString
result
    Ptr CString -> DriveChangedCallback
forall a. Ptr a -> DriveChangedCallback
freeMem Ptr CString
result
    a -> DriveChangedCallback
forall a. ManagedPtrNewtype a => a -> DriveChangedCallback
touchManagedPtr a
drive
    [Text] -> IO [Text]
forall (m :: * -> *) a. Monad m => a -> m a
return [Text]
result'

#if ENABLE_OVERLOADING
data DriveEnumerateIdentifiersMethodInfo
instance (signature ~ (m [T.Text]), MonadIO m, IsDrive a) => O.MethodInfo DriveEnumerateIdentifiersMethodInfo a signature where
    overloadedMethod _ = driveEnumerateIdentifiers

#endif

-- method Drive::get_icon
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "drive", argType = TInterface (Name {namespace = "Gio", name = "Drive"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GDrive.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gio", name = "Icon"}))
-- throws : False
-- Skip return : False

foreign import ccall "g_drive_get_icon" g_drive_get_icon :: 
    Ptr Drive ->                            -- drive : TInterface (Name {namespace = "Gio", name = "Drive"})
    IO (Ptr Gio.Icon.Icon)

{- |
Gets the icon for /@drive@/.
-}
driveGetIcon ::
    (B.CallStack.HasCallStack, MonadIO m, IsDrive a) =>
    a
    {- ^ /@drive@/: a 'GI.Gio.Interfaces.Drive.Drive'. -}
    -> m Gio.Icon.Icon
    {- ^ __Returns:__ 'GI.Gio.Interfaces.Icon.Icon' for the /@drive@/.
   Free the returned object with 'GI.GObject.Objects.Object.objectUnref'. -}
driveGetIcon :: a -> m Icon
driveGetIcon drive :: a
drive = IO Icon -> m Icon
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Icon -> m Icon) -> IO Icon -> m Icon
forall a b. (a -> b) -> a -> b
$ do
    Ptr Drive
drive' <- a -> IO (Ptr Drive)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
drive
    Ptr Icon
result <- Ptr Drive -> IO (Ptr Icon)
g_drive_get_icon Ptr Drive
drive'
    Text -> Ptr Icon -> DriveChangedCallback
forall a. HasCallStack => Text -> Ptr a -> DriveChangedCallback
checkUnexpectedReturnNULL "driveGetIcon" Ptr Icon
result
    Icon
result' <- ((ManagedPtr Icon -> Icon) -> Ptr Icon -> IO Icon
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
wrapObject ManagedPtr Icon -> Icon
Gio.Icon.Icon) Ptr Icon
result
    a -> DriveChangedCallback
forall a. ManagedPtrNewtype a => a -> DriveChangedCallback
touchManagedPtr a
drive
    Icon -> IO Icon
forall (m :: * -> *) a. Monad m => a -> m a
return Icon
result'

#if ENABLE_OVERLOADING
data DriveGetIconMethodInfo
instance (signature ~ (m Gio.Icon.Icon), MonadIO m, IsDrive a) => O.MethodInfo DriveGetIconMethodInfo a signature where
    overloadedMethod _ = driveGetIcon

#endif

-- method Drive::get_identifier
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "drive", argType = TInterface (Name {namespace = "Gio", name = "Drive"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GDrive", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "kind", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the kind of identifier to return", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "g_drive_get_identifier" g_drive_get_identifier :: 
    Ptr Drive ->                            -- drive : TInterface (Name {namespace = "Gio", name = "Drive"})
    CString ->                              -- kind : TBasicType TUTF8
    IO CString

{- |
Gets the identifier of the given kind for /@drive@/. The only
identifier currently available is
'GI.Gio.Constants.DRIVE_IDENTIFIER_KIND_UNIX_DEVICE'.
-}
driveGetIdentifier ::
    (B.CallStack.HasCallStack, MonadIO m, IsDrive a) =>
    a
    {- ^ /@drive@/: a 'GI.Gio.Interfaces.Drive.Drive' -}
    -> T.Text
    {- ^ /@kind@/: the kind of identifier to return -}
    -> m (Maybe T.Text)
    {- ^ __Returns:__ a newly allocated string containing the
    requested identifier, or 'Nothing' if the 'GI.Gio.Interfaces.Drive.Drive'
    doesn\'t have this kind of identifier. -}
driveGetIdentifier :: a -> Text -> m (Maybe Text)
driveGetIdentifier drive :: a
drive kind :: Text
kind = IO (Maybe Text) -> m (Maybe Text)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe Text) -> m (Maybe Text))
-> IO (Maybe Text) -> m (Maybe Text)
forall a b. (a -> b) -> a -> b
$ do
    Ptr Drive
drive' <- a -> IO (Ptr Drive)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
drive
    CString
kind' <- Text -> IO CString
textToCString Text
kind
    CString
result <- Ptr Drive -> CString -> IO CString
g_drive_get_identifier Ptr Drive
drive' CString
kind'
    Maybe Text
maybeResult <- CString -> (CString -> IO Text) -> IO (Maybe Text)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull CString
result ((CString -> IO Text) -> IO (Maybe Text))
-> (CString -> IO Text) -> IO (Maybe Text)
forall a b. (a -> b) -> a -> b
$ \result' :: CString
result' -> do
        Text
result'' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result'
        CString -> DriveChangedCallback
forall a. Ptr a -> DriveChangedCallback
freeMem CString
result'
        Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result''
    a -> DriveChangedCallback
forall a. ManagedPtrNewtype a => a -> DriveChangedCallback
touchManagedPtr a
drive
    CString -> DriveChangedCallback
forall a. Ptr a -> DriveChangedCallback
freeMem CString
kind'
    Maybe Text -> IO (Maybe Text)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe Text
maybeResult

#if ENABLE_OVERLOADING
data DriveGetIdentifierMethodInfo
instance (signature ~ (T.Text -> m (Maybe T.Text)), MonadIO m, IsDrive a) => O.MethodInfo DriveGetIdentifierMethodInfo a signature where
    overloadedMethod _ = driveGetIdentifier

#endif

-- method Drive::get_name
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "drive", argType = TInterface (Name {namespace = "Gio", name = "Drive"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GDrive.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "g_drive_get_name" g_drive_get_name :: 
    Ptr Drive ->                            -- drive : TInterface (Name {namespace = "Gio", name = "Drive"})
    IO CString

{- |
Gets the name of /@drive@/.
-}
driveGetName ::
    (B.CallStack.HasCallStack, MonadIO m, IsDrive a) =>
    a
    {- ^ /@drive@/: a 'GI.Gio.Interfaces.Drive.Drive'. -}
    -> m T.Text
    {- ^ __Returns:__ a string containing /@drive@/\'s name. The returned
    string should be freed when no longer needed. -}
driveGetName :: a -> m Text
driveGetName drive :: a
drive = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    Ptr Drive
drive' <- a -> IO (Ptr Drive)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
drive
    CString
result <- Ptr Drive -> IO CString
g_drive_get_name Ptr Drive
drive'
    Text -> CString -> DriveChangedCallback
forall a. HasCallStack => Text -> Ptr a -> DriveChangedCallback
checkUnexpectedReturnNULL "driveGetName" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    CString -> DriveChangedCallback
forall a. Ptr a -> DriveChangedCallback
freeMem CString
result
    a -> DriveChangedCallback
forall a. ManagedPtrNewtype a => a -> DriveChangedCallback
touchManagedPtr a
drive
    Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result'

#if ENABLE_OVERLOADING
data DriveGetNameMethodInfo
instance (signature ~ (m T.Text), MonadIO m, IsDrive a) => O.MethodInfo DriveGetNameMethodInfo a signature where
    overloadedMethod _ = driveGetName

#endif

-- method Drive::get_sort_key
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "drive", argType = TInterface (Name {namespace = "Gio", name = "Drive"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A #GDrive.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "g_drive_get_sort_key" g_drive_get_sort_key :: 
    Ptr Drive ->                            -- drive : TInterface (Name {namespace = "Gio", name = "Drive"})
    IO CString

{- |
Gets the sort key for /@drive@/, if any.

/Since: 2.32/
-}
driveGetSortKey ::
    (B.CallStack.HasCallStack, MonadIO m, IsDrive a) =>
    a
    {- ^ /@drive@/: A 'GI.Gio.Interfaces.Drive.Drive'. -}
    -> m (Maybe T.Text)
    {- ^ __Returns:__ Sorting key for /@drive@/ or 'Nothing' if no such key is available. -}
driveGetSortKey :: a -> m (Maybe Text)
driveGetSortKey drive :: a
drive = IO (Maybe Text) -> m (Maybe Text)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe Text) -> m (Maybe Text))
-> IO (Maybe Text) -> m (Maybe Text)
forall a b. (a -> b) -> a -> b
$ do
    Ptr Drive
drive' <- a -> IO (Ptr Drive)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
drive
    CString
result <- Ptr Drive -> IO CString
g_drive_get_sort_key Ptr Drive
drive'
    Maybe Text
maybeResult <- CString -> (CString -> IO Text) -> IO (Maybe Text)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull CString
result ((CString -> IO Text) -> IO (Maybe Text))
-> (CString -> IO Text) -> IO (Maybe Text)
forall a b. (a -> b) -> a -> b
$ \result' :: CString
result' -> do
        Text
result'' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result'
        Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result''
    a -> DriveChangedCallback
forall a. ManagedPtrNewtype a => a -> DriveChangedCallback
touchManagedPtr a
drive
    Maybe Text -> IO (Maybe Text)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe Text
maybeResult

#if ENABLE_OVERLOADING
data DriveGetSortKeyMethodInfo
instance (signature ~ (m (Maybe T.Text)), MonadIO m, IsDrive a) => O.MethodInfo DriveGetSortKeyMethodInfo a signature where
    overloadedMethod _ = driveGetSortKey

#endif

-- method Drive::get_start_stop_type
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "drive", argType = TInterface (Name {namespace = "Gio", name = "Drive"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GDrive.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gio", name = "DriveStartStopType"}))
-- throws : False
-- Skip return : False

foreign import ccall "g_drive_get_start_stop_type" g_drive_get_start_stop_type :: 
    Ptr Drive ->                            -- drive : TInterface (Name {namespace = "Gio", name = "Drive"})
    IO CUInt

{- |
Gets a hint about how a drive can be started\/stopped.

/Since: 2.22/
-}
driveGetStartStopType ::
    (B.CallStack.HasCallStack, MonadIO m, IsDrive a) =>
    a
    {- ^ /@drive@/: a 'GI.Gio.Interfaces.Drive.Drive'. -}
    -> m Gio.Enums.DriveStartStopType
    {- ^ __Returns:__ A value from the 'GI.Gio.Enums.DriveStartStopType' enumeration. -}
driveGetStartStopType :: a -> m DriveStartStopType
driveGetStartStopType drive :: a
drive = IO DriveStartStopType -> m DriveStartStopType
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO DriveStartStopType -> m DriveStartStopType)
-> IO DriveStartStopType -> m DriveStartStopType
forall a b. (a -> b) -> a -> b
$ do
    Ptr Drive
drive' <- a -> IO (Ptr Drive)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
drive
    CUInt
result <- Ptr Drive -> IO CUInt
g_drive_get_start_stop_type Ptr Drive
drive'
    let result' :: DriveStartStopType
result' = (Int -> DriveStartStopType
forall a. Enum a => Int -> a
toEnum (Int -> DriveStartStopType)
-> (CUInt -> Int) -> CUInt -> DriveStartStopType
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CUInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral) CUInt
result
    a -> DriveChangedCallback
forall a. ManagedPtrNewtype a => a -> DriveChangedCallback
touchManagedPtr a
drive
    DriveStartStopType -> IO DriveStartStopType
forall (m :: * -> *) a. Monad m => a -> m a
return DriveStartStopType
result'

#if ENABLE_OVERLOADING
data DriveGetStartStopTypeMethodInfo
instance (signature ~ (m Gio.Enums.DriveStartStopType), MonadIO m, IsDrive a) => O.MethodInfo DriveGetStartStopTypeMethodInfo a signature where
    overloadedMethod _ = driveGetStartStopType

#endif

-- method Drive::get_symbolic_icon
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "drive", argType = TInterface (Name {namespace = "Gio", name = "Drive"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GDrive.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gio", name = "Icon"}))
-- throws : False
-- Skip return : False

foreign import ccall "g_drive_get_symbolic_icon" g_drive_get_symbolic_icon :: 
    Ptr Drive ->                            -- drive : TInterface (Name {namespace = "Gio", name = "Drive"})
    IO (Ptr Gio.Icon.Icon)

{- |
Gets the icon for /@drive@/.

/Since: 2.34/
-}
driveGetSymbolicIcon ::
    (B.CallStack.HasCallStack, MonadIO m, IsDrive a) =>
    a
    {- ^ /@drive@/: a 'GI.Gio.Interfaces.Drive.Drive'. -}
    -> m Gio.Icon.Icon
    {- ^ __Returns:__ symbolic 'GI.Gio.Interfaces.Icon.Icon' for the /@drive@/.
   Free the returned object with 'GI.GObject.Objects.Object.objectUnref'. -}
driveGetSymbolicIcon :: a -> m Icon
driveGetSymbolicIcon drive :: a
drive = IO Icon -> m Icon
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Icon -> m Icon) -> IO Icon -> m Icon
forall a b. (a -> b) -> a -> b
$ do
    Ptr Drive
drive' <- a -> IO (Ptr Drive)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
drive
    Ptr Icon
result <- Ptr Drive -> IO (Ptr Icon)
g_drive_get_symbolic_icon Ptr Drive
drive'
    Text -> Ptr Icon -> DriveChangedCallback
forall a. HasCallStack => Text -> Ptr a -> DriveChangedCallback
checkUnexpectedReturnNULL "driveGetSymbolicIcon" Ptr Icon
result
    Icon
result' <- ((ManagedPtr Icon -> Icon) -> Ptr Icon -> IO Icon
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
wrapObject ManagedPtr Icon -> Icon
Gio.Icon.Icon) Ptr Icon
result
    a -> DriveChangedCallback
forall a. ManagedPtrNewtype a => a -> DriveChangedCallback
touchManagedPtr a
drive
    Icon -> IO Icon
forall (m :: * -> *) a. Monad m => a -> m a
return Icon
result'

#if ENABLE_OVERLOADING
data DriveGetSymbolicIconMethodInfo
instance (signature ~ (m Gio.Icon.Icon), MonadIO m, IsDrive a) => O.MethodInfo DriveGetSymbolicIconMethodInfo a signature where
    overloadedMethod _ = driveGetSymbolicIcon

#endif

-- method Drive::get_volumes
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "drive", argType = TInterface (Name {namespace = "Gio", name = "Drive"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GDrive.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TGList (TInterface (Name {namespace = "Gio", name = "Volume"})))
-- throws : False
-- Skip return : False

foreign import ccall "g_drive_get_volumes" g_drive_get_volumes :: 
    Ptr Drive ->                            -- drive : TInterface (Name {namespace = "Gio", name = "Drive"})
    IO (Ptr (GList (Ptr Gio.Volume.Volume)))

{- |
Get a list of mountable volumes for /@drive@/.

The returned list should be freed with @/g_list_free()/@, after
its elements have been unreffed with 'GI.GObject.Objects.Object.objectUnref'.
-}
driveGetVolumes ::
    (B.CallStack.HasCallStack, MonadIO m, IsDrive a) =>
    a
    {- ^ /@drive@/: a 'GI.Gio.Interfaces.Drive.Drive'. -}
    -> m [Gio.Volume.Volume]
    {- ^ __Returns:__ 'GI.GLib.Structs.List.List' containing any 'GI.Gio.Interfaces.Volume.Volume' objects on the given /@drive@/. -}
driveGetVolumes :: a -> m [Volume]
driveGetVolumes drive :: a
drive = IO [Volume] -> m [Volume]
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO [Volume] -> m [Volume]) -> IO [Volume] -> m [Volume]
forall a b. (a -> b) -> a -> b
$ do
    Ptr Drive
drive' <- a -> IO (Ptr Drive)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
drive
    Ptr (GList (Ptr Volume))
result <- Ptr Drive -> IO (Ptr (GList (Ptr Volume)))
g_drive_get_volumes Ptr Drive
drive'
    [Ptr Volume]
result' <- Ptr (GList (Ptr Volume)) -> IO [Ptr Volume]
forall a. Ptr (GList (Ptr a)) -> IO [Ptr a]
unpackGList Ptr (GList (Ptr Volume))
result
    [Volume]
result'' <- (Ptr Volume -> IO Volume) -> [Ptr Volume] -> IO [Volume]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM ((ManagedPtr Volume -> Volume) -> Ptr Volume -> IO Volume
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
wrapObject ManagedPtr Volume -> Volume
Gio.Volume.Volume) [Ptr Volume]
result'
    Ptr (GList (Ptr Volume)) -> DriveChangedCallback
forall a. Ptr (GList a) -> DriveChangedCallback
g_list_free Ptr (GList (Ptr Volume))
result
    a -> DriveChangedCallback
forall a. ManagedPtrNewtype a => a -> DriveChangedCallback
touchManagedPtr a
drive
    [Volume] -> IO [Volume]
forall (m :: * -> *) a. Monad m => a -> m a
return [Volume]
result''

#if ENABLE_OVERLOADING
data DriveGetVolumesMethodInfo
instance (signature ~ (m [Gio.Volume.Volume]), MonadIO m, IsDrive a) => O.MethodInfo DriveGetVolumesMethodInfo a signature where
    overloadedMethod _ = driveGetVolumes

#endif

-- method Drive::has_media
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "drive", argType = TInterface (Name {namespace = "Gio", name = "Drive"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GDrive.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "g_drive_has_media" g_drive_has_media :: 
    Ptr Drive ->                            -- drive : TInterface (Name {namespace = "Gio", name = "Drive"})
    IO CInt

{- |
Checks if the /@drive@/ has media. Note that the OS may not be polling
the drive for media changes; see 'GI.Gio.Interfaces.Drive.driveIsMediaCheckAutomatic'
for more details.
-}
driveHasMedia ::
    (B.CallStack.HasCallStack, MonadIO m, IsDrive a) =>
    a
    {- ^ /@drive@/: a 'GI.Gio.Interfaces.Drive.Drive'. -}
    -> m Bool
    {- ^ __Returns:__ 'True' if /@drive@/ has media, 'False' otherwise. -}
driveHasMedia :: a -> m Bool
driveHasMedia drive :: a
drive = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    Ptr Drive
drive' <- a -> IO (Ptr Drive)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
drive
    CInt
result <- Ptr Drive -> IO CInt
g_drive_has_media Ptr Drive
drive'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    a -> DriveChangedCallback
forall a. ManagedPtrNewtype a => a -> DriveChangedCallback
touchManagedPtr a
drive
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'

#if ENABLE_OVERLOADING
data DriveHasMediaMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsDrive a) => O.MethodInfo DriveHasMediaMethodInfo a signature where
    overloadedMethod _ = driveHasMedia

#endif

-- method Drive::has_volumes
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "drive", argType = TInterface (Name {namespace = "Gio", name = "Drive"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GDrive.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "g_drive_has_volumes" g_drive_has_volumes :: 
    Ptr Drive ->                            -- drive : TInterface (Name {namespace = "Gio", name = "Drive"})
    IO CInt

{- |
Check if /@drive@/ has any mountable volumes.
-}
driveHasVolumes ::
    (B.CallStack.HasCallStack, MonadIO m, IsDrive a) =>
    a
    {- ^ /@drive@/: a 'GI.Gio.Interfaces.Drive.Drive'. -}
    -> m Bool
    {- ^ __Returns:__ 'True' if the /@drive@/ contains volumes, 'False' otherwise. -}
driveHasVolumes :: a -> m Bool
driveHasVolumes drive :: a
drive = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    Ptr Drive
drive' <- a -> IO (Ptr Drive)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
drive
    CInt
result <- Ptr Drive -> IO CInt
g_drive_has_volumes Ptr Drive
drive'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    a -> DriveChangedCallback
forall a. ManagedPtrNewtype a => a -> DriveChangedCallback
touchManagedPtr a
drive
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'

#if ENABLE_OVERLOADING
data DriveHasVolumesMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsDrive a) => O.MethodInfo DriveHasVolumesMethodInfo a signature where
    overloadedMethod _ = driveHasVolumes

#endif

-- method Drive::is_media_check_automatic
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "drive", argType = TInterface (Name {namespace = "Gio", name = "Drive"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GDrive.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "g_drive_is_media_check_automatic" g_drive_is_media_check_automatic :: 
    Ptr Drive ->                            -- drive : TInterface (Name {namespace = "Gio", name = "Drive"})
    IO CInt

{- |
Checks if /@drive@/ is capabable of automatically detecting media changes.
-}
driveIsMediaCheckAutomatic ::
    (B.CallStack.HasCallStack, MonadIO m, IsDrive a) =>
    a
    {- ^ /@drive@/: a 'GI.Gio.Interfaces.Drive.Drive'. -}
    -> m Bool
    {- ^ __Returns:__ 'True' if the /@drive@/ is capabable of automatically detecting
    media changes, 'False' otherwise. -}
driveIsMediaCheckAutomatic :: a -> m Bool
driveIsMediaCheckAutomatic drive :: a
drive = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    Ptr Drive
drive' <- a -> IO (Ptr Drive)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
drive
    CInt
result <- Ptr Drive -> IO CInt
g_drive_is_media_check_automatic Ptr Drive
drive'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    a -> DriveChangedCallback
forall a. ManagedPtrNewtype a => a -> DriveChangedCallback
touchManagedPtr a
drive
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'

#if ENABLE_OVERLOADING
data DriveIsMediaCheckAutomaticMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsDrive a) => O.MethodInfo DriveIsMediaCheckAutomaticMethodInfo a signature where
    overloadedMethod _ = driveIsMediaCheckAutomatic

#endif

-- method Drive::is_media_removable
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "drive", argType = TInterface (Name {namespace = "Gio", name = "Drive"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GDrive.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "g_drive_is_media_removable" g_drive_is_media_removable :: 
    Ptr Drive ->                            -- drive : TInterface (Name {namespace = "Gio", name = "Drive"})
    IO CInt

{- |
Checks if the /@drive@/ supports removable media.
-}
driveIsMediaRemovable ::
    (B.CallStack.HasCallStack, MonadIO m, IsDrive a) =>
    a
    {- ^ /@drive@/: a 'GI.Gio.Interfaces.Drive.Drive'. -}
    -> m Bool
    {- ^ __Returns:__ 'True' if /@drive@/ supports removable media, 'False' otherwise. -}
driveIsMediaRemovable :: a -> m Bool
driveIsMediaRemovable drive :: a
drive = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    Ptr Drive
drive' <- a -> IO (Ptr Drive)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
drive
    CInt
result <- Ptr Drive -> IO CInt
g_drive_is_media_removable Ptr Drive
drive'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    a -> DriveChangedCallback
forall a. ManagedPtrNewtype a => a -> DriveChangedCallback
touchManagedPtr a
drive
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'

#if ENABLE_OVERLOADING
data DriveIsMediaRemovableMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsDrive a) => O.MethodInfo DriveIsMediaRemovableMethodInfo a signature where
    overloadedMethod _ = driveIsMediaRemovable

#endif

-- method Drive::is_removable
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "drive", argType = TInterface (Name {namespace = "Gio", name = "Drive"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GDrive.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "g_drive_is_removable" g_drive_is_removable :: 
    Ptr Drive ->                            -- drive : TInterface (Name {namespace = "Gio", name = "Drive"})
    IO CInt

{- |
Checks if the 'GI.Gio.Interfaces.Drive.Drive' and\/or its media is considered removable by the user.
See 'GI.Gio.Interfaces.Drive.driveIsMediaRemovable'.

/Since: 2.50/
-}
driveIsRemovable ::
    (B.CallStack.HasCallStack, MonadIO m, IsDrive a) =>
    a
    {- ^ /@drive@/: a 'GI.Gio.Interfaces.Drive.Drive'. -}
    -> m Bool
    {- ^ __Returns:__ 'True' if /@drive@/ and\/or its media is considered removable, 'False' otherwise. -}
driveIsRemovable :: a -> m Bool
driveIsRemovable drive :: a
drive = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    Ptr Drive
drive' <- a -> IO (Ptr Drive)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
drive
    CInt
result <- Ptr Drive -> IO CInt
g_drive_is_removable Ptr Drive
drive'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    a -> DriveChangedCallback
forall a. ManagedPtrNewtype a => a -> DriveChangedCallback
touchManagedPtr a
drive
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'

#if ENABLE_OVERLOADING
data DriveIsRemovableMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsDrive a) => O.MethodInfo DriveIsRemovableMethodInfo a signature where
    overloadedMethod _ = driveIsRemovable

#endif

-- method Drive::poll_for_media
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "drive", argType = TInterface (Name {namespace = "Gio", name = "Drive"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GDrive.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "optional #GCancellable object, %NULL to ignore.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "callback", argType = TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GAsyncReadyCallback, or %NULL.", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = 3, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "user data to pass to @callback", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_drive_poll_for_media" g_drive_poll_for_media :: 
    Ptr Drive ->                            -- drive : TInterface (Name {namespace = "Gio", name = "Drive"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    FunPtr Gio.Callbacks.C_AsyncReadyCallback -> -- callback : TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"})
    Ptr () ->                               -- user_data : TBasicType TPtr
    IO ()

{- |
Asynchronously polls /@drive@/ to see if media has been inserted or removed.

When the operation is finished, /@callback@/ will be called.
You can then call 'GI.Gio.Interfaces.Drive.drivePollForMediaFinish' to obtain the
result of the operation.
-}
drivePollForMedia ::
    (B.CallStack.HasCallStack, MonadIO m, IsDrive a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@drive@/: a 'GI.Gio.Interfaces.Drive.Drive'. -}
    -> Maybe (b)
    {- ^ /@cancellable@/: optional 'GI.Gio.Objects.Cancellable.Cancellable' object, 'Nothing' to ignore. -}
    -> Maybe (Gio.Callbacks.AsyncReadyCallback)
    {- ^ /@callback@/: a 'GI.Gio.Callbacks.AsyncReadyCallback', or 'Nothing'. -}
    -> m ()
drivePollForMedia :: a -> Maybe b -> Maybe AsyncReadyCallback -> m ()
drivePollForMedia drive :: a
drive cancellable :: Maybe b
cancellable callback :: Maybe AsyncReadyCallback
callback = DriveChangedCallback -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (DriveChangedCallback -> m ()) -> DriveChangedCallback -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr Drive
drive' <- a -> IO (Ptr Drive)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
drive
    Ptr Cancellable
maybeCancellable <- case Maybe b
cancellable of
        Nothing -> Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
forall a. Ptr a
nullPtr
        Just jCancellable :: b
jCancellable -> do
            Ptr Cancellable
jCancellable' <- b -> IO (Ptr Cancellable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
jCancellable
            Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
jCancellable'
    FunPtr C_AsyncReadyCallback
maybeCallback <- case Maybe AsyncReadyCallback
callback of
        Nothing -> FunPtr C_AsyncReadyCallback -> IO (FunPtr C_AsyncReadyCallback)
forall (m :: * -> *) a. Monad m => a -> m a
return (Ptr Any -> FunPtr C_AsyncReadyCallback
forall a b. Ptr a -> FunPtr b
castPtrToFunPtr Ptr Any
forall a. Ptr a
nullPtr)
        Just jCallback :: AsyncReadyCallback
jCallback -> do
            Ptr (FunPtr C_AsyncReadyCallback)
ptrcallback <- IO (Ptr (FunPtr C_AsyncReadyCallback))
forall a. Storable a => IO (Ptr a)
callocMem :: IO (Ptr (FunPtr Gio.Callbacks.C_AsyncReadyCallback))
            FunPtr C_AsyncReadyCallback
jCallback' <- C_AsyncReadyCallback -> IO (FunPtr C_AsyncReadyCallback)
Gio.Callbacks.mk_AsyncReadyCallback (Maybe (Ptr (FunPtr C_AsyncReadyCallback))
-> AsyncReadyCallback_WithClosures -> C_AsyncReadyCallback
Gio.Callbacks.wrap_AsyncReadyCallback (Ptr (FunPtr C_AsyncReadyCallback)
-> Maybe (Ptr (FunPtr C_AsyncReadyCallback))
forall a. a -> Maybe a
Just Ptr (FunPtr C_AsyncReadyCallback)
ptrcallback) (AsyncReadyCallback -> AsyncReadyCallback_WithClosures
Gio.Callbacks.drop_closures_AsyncReadyCallback AsyncReadyCallback
jCallback))
            Ptr (FunPtr C_AsyncReadyCallback)
-> FunPtr C_AsyncReadyCallback -> DriveChangedCallback
forall a. Storable a => Ptr a -> a -> DriveChangedCallback
poke Ptr (FunPtr C_AsyncReadyCallback)
ptrcallback FunPtr C_AsyncReadyCallback
jCallback'
            FunPtr C_AsyncReadyCallback -> IO (FunPtr C_AsyncReadyCallback)
forall (m :: * -> *) a. Monad m => a -> m a
return FunPtr C_AsyncReadyCallback
jCallback'
    let userData :: Ptr a
userData = Ptr a
forall a. Ptr a
nullPtr
    Ptr Drive
-> Ptr Cancellable
-> FunPtr C_AsyncReadyCallback
-> Ptr ()
-> DriveChangedCallback
g_drive_poll_for_media Ptr Drive
drive' Ptr Cancellable
maybeCancellable FunPtr C_AsyncReadyCallback
maybeCallback Ptr ()
forall a. Ptr a
userData
    a -> DriveChangedCallback
forall a. ManagedPtrNewtype a => a -> DriveChangedCallback
touchManagedPtr a
drive
    Maybe b -> (b -> DriveChangedCallback) -> DriveChangedCallback
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe b
cancellable b -> DriveChangedCallback
forall a. ManagedPtrNewtype a => a -> DriveChangedCallback
touchManagedPtr
    () -> DriveChangedCallback
forall (m :: * -> *) a. Monad m => a -> m a
return ()

#if ENABLE_OVERLOADING
data DrivePollForMediaMethodInfo
instance (signature ~ (Maybe (b) -> Maybe (Gio.Callbacks.AsyncReadyCallback) -> m ()), MonadIO m, IsDrive a, Gio.Cancellable.IsCancellable b) => O.MethodInfo DrivePollForMediaMethodInfo a signature where
    overloadedMethod _ = drivePollForMedia

#endif

-- method Drive::poll_for_media_finish
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "drive", argType = TInterface (Name {namespace = "Gio", name = "Drive"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GDrive.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "result", argType = TInterface (Name {namespace = "Gio", name = "AsyncResult"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GAsyncResult.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "g_drive_poll_for_media_finish" g_drive_poll_for_media_finish :: 
    Ptr Drive ->                            -- drive : TInterface (Name {namespace = "Gio", name = "Drive"})
    Ptr Gio.AsyncResult.AsyncResult ->      -- result : TInterface (Name {namespace = "Gio", name = "AsyncResult"})
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
Finishes an operation started with 'GI.Gio.Interfaces.Drive.drivePollForMedia' on a drive.
-}
drivePollForMediaFinish ::
    (B.CallStack.HasCallStack, MonadIO m, IsDrive a, Gio.AsyncResult.IsAsyncResult b) =>
    a
    {- ^ /@drive@/: a 'GI.Gio.Interfaces.Drive.Drive'. -}
    -> b
    {- ^ /@result@/: a 'GI.Gio.Interfaces.AsyncResult.AsyncResult'. -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
drivePollForMediaFinish :: a -> b -> m ()
drivePollForMediaFinish drive :: a
drive result_ :: b
result_ = DriveChangedCallback -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (DriveChangedCallback -> m ()) -> DriveChangedCallback -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr Drive
drive' <- a -> IO (Ptr Drive)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
drive
    Ptr AsyncResult
result_' <- b -> IO (Ptr AsyncResult)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
result_
    DriveChangedCallback
-> DriveChangedCallback -> DriveChangedCallback
forall a b. IO a -> IO b -> IO a
onException (do
        CInt
_ <- (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CInt) -> IO CInt)
-> (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ Ptr Drive -> Ptr AsyncResult -> Ptr (Ptr GError) -> IO CInt
g_drive_poll_for_media_finish Ptr Drive
drive' Ptr AsyncResult
result_'
        a -> DriveChangedCallback
forall a. ManagedPtrNewtype a => a -> DriveChangedCallback
touchManagedPtr a
drive
        b -> DriveChangedCallback
forall a. ManagedPtrNewtype a => a -> DriveChangedCallback
touchManagedPtr b
result_
        () -> DriveChangedCallback
forall (m :: * -> *) a. Monad m => a -> m a
return ()
     ) (do
        () -> DriveChangedCallback
forall (m :: * -> *) a. Monad m => a -> m a
return ()
     )

#if ENABLE_OVERLOADING
data DrivePollForMediaFinishMethodInfo
instance (signature ~ (b -> m ()), MonadIO m, IsDrive a, Gio.AsyncResult.IsAsyncResult b) => O.MethodInfo DrivePollForMediaFinishMethodInfo a signature where
    overloadedMethod _ = drivePollForMediaFinish

#endif

-- method Drive::start
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "drive", argType = TInterface (Name {namespace = "Gio", name = "Drive"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GDrive.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "flags", argType = TInterface (Name {namespace = "Gio", name = "DriveStartFlags"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "flags affecting the start operation.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "mount_operation", argType = TInterface (Name {namespace = "Gio", name = "MountOperation"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GMountOperation or %NULL to avoid\n    user interaction.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "optional #GCancellable object, %NULL to ignore.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "callback", argType = TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GAsyncReadyCallback, or %NULL.", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = 5, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "user data to pass to @callback", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_drive_start" g_drive_start :: 
    Ptr Drive ->                            -- drive : TInterface (Name {namespace = "Gio", name = "Drive"})
    CUInt ->                                -- flags : TInterface (Name {namespace = "Gio", name = "DriveStartFlags"})
    Ptr Gio.MountOperation.MountOperation -> -- mount_operation : TInterface (Name {namespace = "Gio", name = "MountOperation"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    FunPtr Gio.Callbacks.C_AsyncReadyCallback -> -- callback : TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"})
    Ptr () ->                               -- user_data : TBasicType TPtr
    IO ()

{- |
Asynchronously starts a drive.

When the operation is finished, /@callback@/ will be called.
You can then call 'GI.Gio.Interfaces.Drive.driveStartFinish' to obtain the
result of the operation.

/Since: 2.22/
-}
driveStart ::
    (B.CallStack.HasCallStack, MonadIO m, IsDrive a, Gio.MountOperation.IsMountOperation b, Gio.Cancellable.IsCancellable c) =>
    a
    {- ^ /@drive@/: a 'GI.Gio.Interfaces.Drive.Drive'. -}
    -> [Gio.Flags.DriveStartFlags]
    {- ^ /@flags@/: flags affecting the start operation. -}
    -> Maybe (b)
    {- ^ /@mountOperation@/: a 'GI.Gio.Objects.MountOperation.MountOperation' or 'Nothing' to avoid
    user interaction. -}
    -> Maybe (c)
    {- ^ /@cancellable@/: optional 'GI.Gio.Objects.Cancellable.Cancellable' object, 'Nothing' to ignore. -}
    -> Maybe (Gio.Callbacks.AsyncReadyCallback)
    {- ^ /@callback@/: a 'GI.Gio.Callbacks.AsyncReadyCallback', or 'Nothing'. -}
    -> m ()
driveStart :: a
-> [DriveStartFlags]
-> Maybe b
-> Maybe c
-> Maybe AsyncReadyCallback
-> m ()
driveStart drive :: a
drive flags :: [DriveStartFlags]
flags mountOperation :: Maybe b
mountOperation cancellable :: Maybe c
cancellable callback :: Maybe AsyncReadyCallback
callback = DriveChangedCallback -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (DriveChangedCallback -> m ()) -> DriveChangedCallback -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr Drive
drive' <- a -> IO (Ptr Drive)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
drive
    let flags' :: CUInt
flags' = [DriveStartFlags] -> CUInt
forall b a. (Num b, IsGFlag a) => [a] -> b
gflagsToWord [DriveStartFlags]
flags
    Ptr MountOperation
maybeMountOperation <- case Maybe b
mountOperation of
        Nothing -> Ptr MountOperation -> IO (Ptr MountOperation)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr MountOperation
forall a. Ptr a
nullPtr
        Just jMountOperation :: b
jMountOperation -> do
            Ptr MountOperation
jMountOperation' <- b -> IO (Ptr MountOperation)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
jMountOperation
            Ptr MountOperation -> IO (Ptr MountOperation)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr MountOperation
jMountOperation'
    Ptr Cancellable
maybeCancellable <- case Maybe c
cancellable of
        Nothing -> Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
forall a. Ptr a
nullPtr
        Just jCancellable :: c
jCancellable -> do
            Ptr Cancellable
jCancellable' <- c -> IO (Ptr Cancellable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr c
jCancellable
            Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
jCancellable'
    FunPtr C_AsyncReadyCallback
maybeCallback <- case Maybe AsyncReadyCallback
callback of
        Nothing -> FunPtr C_AsyncReadyCallback -> IO (FunPtr C_AsyncReadyCallback)
forall (m :: * -> *) a. Monad m => a -> m a
return (Ptr Any -> FunPtr C_AsyncReadyCallback
forall a b. Ptr a -> FunPtr b
castPtrToFunPtr Ptr Any
forall a. Ptr a
nullPtr)
        Just jCallback :: AsyncReadyCallback
jCallback -> do
            Ptr (FunPtr C_AsyncReadyCallback)
ptrcallback <- IO (Ptr (FunPtr C_AsyncReadyCallback))
forall a. Storable a => IO (Ptr a)
callocMem :: IO (Ptr (FunPtr Gio.Callbacks.C_AsyncReadyCallback))
            FunPtr C_AsyncReadyCallback
jCallback' <- C_AsyncReadyCallback -> IO (FunPtr C_AsyncReadyCallback)
Gio.Callbacks.mk_AsyncReadyCallback (Maybe (Ptr (FunPtr C_AsyncReadyCallback))
-> AsyncReadyCallback_WithClosures -> C_AsyncReadyCallback
Gio.Callbacks.wrap_AsyncReadyCallback (Ptr (FunPtr C_AsyncReadyCallback)
-> Maybe (Ptr (FunPtr C_AsyncReadyCallback))
forall a. a -> Maybe a
Just Ptr (FunPtr C_AsyncReadyCallback)
ptrcallback) (AsyncReadyCallback -> AsyncReadyCallback_WithClosures
Gio.Callbacks.drop_closures_AsyncReadyCallback AsyncReadyCallback
jCallback))
            Ptr (FunPtr C_AsyncReadyCallback)
-> FunPtr C_AsyncReadyCallback -> DriveChangedCallback
forall a. Storable a => Ptr a -> a -> DriveChangedCallback
poke Ptr (FunPtr C_AsyncReadyCallback)
ptrcallback FunPtr C_AsyncReadyCallback
jCallback'
            FunPtr C_AsyncReadyCallback -> IO (FunPtr C_AsyncReadyCallback)
forall (m :: * -> *) a. Monad m => a -> m a
return FunPtr C_AsyncReadyCallback
jCallback'
    let userData :: Ptr a
userData = Ptr a
forall a. Ptr a
nullPtr
    Ptr Drive
-> CUInt
-> Ptr MountOperation
-> Ptr Cancellable
-> FunPtr C_AsyncReadyCallback
-> Ptr ()
-> DriveChangedCallback
g_drive_start Ptr Drive
drive' CUInt
flags' Ptr MountOperation
maybeMountOperation Ptr Cancellable
maybeCancellable FunPtr C_AsyncReadyCallback
maybeCallback Ptr ()
forall a. Ptr a
userData
    a -> DriveChangedCallback
forall a. ManagedPtrNewtype a => a -> DriveChangedCallback
touchManagedPtr a
drive
    Maybe b -> (b -> DriveChangedCallback) -> DriveChangedCallback
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe b
mountOperation b -> DriveChangedCallback
forall a. ManagedPtrNewtype a => a -> DriveChangedCallback
touchManagedPtr
    Maybe c -> (c -> DriveChangedCallback) -> DriveChangedCallback
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe c
cancellable c -> DriveChangedCallback
forall a. ManagedPtrNewtype a => a -> DriveChangedCallback
touchManagedPtr
    () -> DriveChangedCallback
forall (m :: * -> *) a. Monad m => a -> m a
return ()

#if ENABLE_OVERLOADING
data DriveStartMethodInfo
instance (signature ~ ([Gio.Flags.DriveStartFlags] -> Maybe (b) -> Maybe (c) -> Maybe (Gio.Callbacks.AsyncReadyCallback) -> m ()), MonadIO m, IsDrive a, Gio.MountOperation.IsMountOperation b, Gio.Cancellable.IsCancellable c) => O.MethodInfo DriveStartMethodInfo a signature where
    overloadedMethod _ = driveStart

#endif

-- method Drive::start_finish
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "drive", argType = TInterface (Name {namespace = "Gio", name = "Drive"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GDrive.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "result", argType = TInterface (Name {namespace = "Gio", name = "AsyncResult"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GAsyncResult.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "g_drive_start_finish" g_drive_start_finish :: 
    Ptr Drive ->                            -- drive : TInterface (Name {namespace = "Gio", name = "Drive"})
    Ptr Gio.AsyncResult.AsyncResult ->      -- result : TInterface (Name {namespace = "Gio", name = "AsyncResult"})
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
Finishes starting a drive.

/Since: 2.22/
-}
driveStartFinish ::
    (B.CallStack.HasCallStack, MonadIO m, IsDrive a, Gio.AsyncResult.IsAsyncResult b) =>
    a
    {- ^ /@drive@/: a 'GI.Gio.Interfaces.Drive.Drive'. -}
    -> b
    {- ^ /@result@/: a 'GI.Gio.Interfaces.AsyncResult.AsyncResult'. -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
driveStartFinish :: a -> b -> m ()
driveStartFinish drive :: a
drive result_ :: b
result_ = DriveChangedCallback -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (DriveChangedCallback -> m ()) -> DriveChangedCallback -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr Drive
drive' <- a -> IO (Ptr Drive)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
drive
    Ptr AsyncResult
result_' <- b -> IO (Ptr AsyncResult)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
result_
    DriveChangedCallback
-> DriveChangedCallback -> DriveChangedCallback
forall a b. IO a -> IO b -> IO a
onException (do
        CInt
_ <- (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CInt) -> IO CInt)
-> (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ Ptr Drive -> Ptr AsyncResult -> Ptr (Ptr GError) -> IO CInt
g_drive_start_finish Ptr Drive
drive' Ptr AsyncResult
result_'
        a -> DriveChangedCallback
forall a. ManagedPtrNewtype a => a -> DriveChangedCallback
touchManagedPtr a
drive
        b -> DriveChangedCallback
forall a. ManagedPtrNewtype a => a -> DriveChangedCallback
touchManagedPtr b
result_
        () -> DriveChangedCallback
forall (m :: * -> *) a. Monad m => a -> m a
return ()
     ) (do
        () -> DriveChangedCallback
forall (m :: * -> *) a. Monad m => a -> m a
return ()
     )

#if ENABLE_OVERLOADING
data DriveStartFinishMethodInfo
instance (signature ~ (b -> m ()), MonadIO m, IsDrive a, Gio.AsyncResult.IsAsyncResult b) => O.MethodInfo DriveStartFinishMethodInfo a signature where
    overloadedMethod _ = driveStartFinish

#endif

-- method Drive::stop
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "drive", argType = TInterface (Name {namespace = "Gio", name = "Drive"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GDrive.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "flags", argType = TInterface (Name {namespace = "Gio", name = "MountUnmountFlags"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "flags affecting the unmount if required for stopping.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "mount_operation", argType = TInterface (Name {namespace = "Gio", name = "MountOperation"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GMountOperation or %NULL to avoid\n    user interaction.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "optional #GCancellable object, %NULL to ignore.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "callback", argType = TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GAsyncReadyCallback, or %NULL.", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = 5, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "user data to pass to @callback", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_drive_stop" g_drive_stop :: 
    Ptr Drive ->                            -- drive : TInterface (Name {namespace = "Gio", name = "Drive"})
    CUInt ->                                -- flags : TInterface (Name {namespace = "Gio", name = "MountUnmountFlags"})
    Ptr Gio.MountOperation.MountOperation -> -- mount_operation : TInterface (Name {namespace = "Gio", name = "MountOperation"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    FunPtr Gio.Callbacks.C_AsyncReadyCallback -> -- callback : TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"})
    Ptr () ->                               -- user_data : TBasicType TPtr
    IO ()

{- |
Asynchronously stops a drive.

When the operation is finished, /@callback@/ will be called.
You can then call 'GI.Gio.Interfaces.Drive.driveStopFinish' to obtain the
result of the operation.

/Since: 2.22/
-}
driveStop ::
    (B.CallStack.HasCallStack, MonadIO m, IsDrive a, Gio.MountOperation.IsMountOperation b, Gio.Cancellable.IsCancellable c) =>
    a
    {- ^ /@drive@/: a 'GI.Gio.Interfaces.Drive.Drive'. -}
    -> [Gio.Flags.MountUnmountFlags]
    {- ^ /@flags@/: flags affecting the unmount if required for stopping. -}
    -> Maybe (b)
    {- ^ /@mountOperation@/: a 'GI.Gio.Objects.MountOperation.MountOperation' or 'Nothing' to avoid
    user interaction. -}
    -> Maybe (c)
    {- ^ /@cancellable@/: optional 'GI.Gio.Objects.Cancellable.Cancellable' object, 'Nothing' to ignore. -}
    -> Maybe (Gio.Callbacks.AsyncReadyCallback)
    {- ^ /@callback@/: a 'GI.Gio.Callbacks.AsyncReadyCallback', or 'Nothing'. -}
    -> m ()
driveStop :: a
-> [MountUnmountFlags]
-> Maybe b
-> Maybe c
-> Maybe AsyncReadyCallback
-> m ()
driveStop drive :: a
drive flags :: [MountUnmountFlags]
flags mountOperation :: Maybe b
mountOperation cancellable :: Maybe c
cancellable callback :: Maybe AsyncReadyCallback
callback = DriveChangedCallback -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (DriveChangedCallback -> m ()) -> DriveChangedCallback -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr Drive
drive' <- a -> IO (Ptr Drive)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
drive
    let flags' :: CUInt
flags' = [MountUnmountFlags] -> CUInt
forall b a. (Num b, IsGFlag a) => [a] -> b
gflagsToWord [MountUnmountFlags]
flags
    Ptr MountOperation
maybeMountOperation <- case Maybe b
mountOperation of
        Nothing -> Ptr MountOperation -> IO (Ptr MountOperation)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr MountOperation
forall a. Ptr a
nullPtr
        Just jMountOperation :: b
jMountOperation -> do
            Ptr MountOperation
jMountOperation' <- b -> IO (Ptr MountOperation)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
jMountOperation
            Ptr MountOperation -> IO (Ptr MountOperation)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr MountOperation
jMountOperation'
    Ptr Cancellable
maybeCancellable <- case Maybe c
cancellable of
        Nothing -> Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
forall a. Ptr a
nullPtr
        Just jCancellable :: c
jCancellable -> do
            Ptr Cancellable
jCancellable' <- c -> IO (Ptr Cancellable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr c
jCancellable
            Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
jCancellable'
    FunPtr C_AsyncReadyCallback
maybeCallback <- case Maybe AsyncReadyCallback
callback of
        Nothing -> FunPtr C_AsyncReadyCallback -> IO (FunPtr C_AsyncReadyCallback)
forall (m :: * -> *) a. Monad m => a -> m a
return (Ptr Any -> FunPtr C_AsyncReadyCallback
forall a b. Ptr a -> FunPtr b
castPtrToFunPtr Ptr Any
forall a. Ptr a
nullPtr)
        Just jCallback :: AsyncReadyCallback
jCallback -> do
            Ptr (FunPtr C_AsyncReadyCallback)
ptrcallback <- IO (Ptr (FunPtr C_AsyncReadyCallback))
forall a. Storable a => IO (Ptr a)
callocMem :: IO (Ptr (FunPtr Gio.Callbacks.C_AsyncReadyCallback))
            FunPtr C_AsyncReadyCallback
jCallback' <- C_AsyncReadyCallback -> IO (FunPtr C_AsyncReadyCallback)
Gio.Callbacks.mk_AsyncReadyCallback (Maybe (Ptr (FunPtr C_AsyncReadyCallback))
-> AsyncReadyCallback_WithClosures -> C_AsyncReadyCallback
Gio.Callbacks.wrap_AsyncReadyCallback (Ptr (FunPtr C_AsyncReadyCallback)
-> Maybe (Ptr (FunPtr C_AsyncReadyCallback))
forall a. a -> Maybe a
Just Ptr (FunPtr C_AsyncReadyCallback)
ptrcallback) (AsyncReadyCallback -> AsyncReadyCallback_WithClosures
Gio.Callbacks.drop_closures_AsyncReadyCallback AsyncReadyCallback
jCallback))
            Ptr (FunPtr C_AsyncReadyCallback)
-> FunPtr C_AsyncReadyCallback -> DriveChangedCallback
forall a. Storable a => Ptr a -> a -> DriveChangedCallback
poke Ptr (FunPtr C_AsyncReadyCallback)
ptrcallback FunPtr C_AsyncReadyCallback
jCallback'
            FunPtr C_AsyncReadyCallback -> IO (FunPtr C_AsyncReadyCallback)
forall (m :: * -> *) a. Monad m => a -> m a
return FunPtr C_AsyncReadyCallback
jCallback'
    let userData :: Ptr a
userData = Ptr a
forall a. Ptr a
nullPtr
    Ptr Drive
-> CUInt
-> Ptr MountOperation
-> Ptr Cancellable
-> FunPtr C_AsyncReadyCallback
-> Ptr ()
-> DriveChangedCallback
g_drive_stop Ptr Drive
drive' CUInt
flags' Ptr MountOperation
maybeMountOperation Ptr Cancellable
maybeCancellable FunPtr C_AsyncReadyCallback
maybeCallback Ptr ()
forall a. Ptr a
userData
    a -> DriveChangedCallback
forall a. ManagedPtrNewtype a => a -> DriveChangedCallback
touchManagedPtr a
drive
    Maybe b -> (b -> DriveChangedCallback) -> DriveChangedCallback
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe b
mountOperation b -> DriveChangedCallback
forall a. ManagedPtrNewtype a => a -> DriveChangedCallback
touchManagedPtr
    Maybe c -> (c -> DriveChangedCallback) -> DriveChangedCallback
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe c
cancellable c -> DriveChangedCallback
forall a. ManagedPtrNewtype a => a -> DriveChangedCallback
touchManagedPtr
    () -> DriveChangedCallback
forall (m :: * -> *) a. Monad m => a -> m a
return ()

#if ENABLE_OVERLOADING
data DriveStopMethodInfo
instance (signature ~ ([Gio.Flags.MountUnmountFlags] -> Maybe (b) -> Maybe (c) -> Maybe (Gio.Callbacks.AsyncReadyCallback) -> m ()), MonadIO m, IsDrive a, Gio.MountOperation.IsMountOperation b, Gio.Cancellable.IsCancellable c) => O.MethodInfo DriveStopMethodInfo a signature where
    overloadedMethod _ = driveStop

#endif

-- method Drive::stop_finish
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "drive", argType = TInterface (Name {namespace = "Gio", name = "Drive"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GDrive.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "result", argType = TInterface (Name {namespace = "Gio", name = "AsyncResult"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GAsyncResult.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "g_drive_stop_finish" g_drive_stop_finish :: 
    Ptr Drive ->                            -- drive : TInterface (Name {namespace = "Gio", name = "Drive"})
    Ptr Gio.AsyncResult.AsyncResult ->      -- result : TInterface (Name {namespace = "Gio", name = "AsyncResult"})
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
Finishes stopping a drive.

/Since: 2.22/
-}
driveStopFinish ::
    (B.CallStack.HasCallStack, MonadIO m, IsDrive a, Gio.AsyncResult.IsAsyncResult b) =>
    a
    {- ^ /@drive@/: a 'GI.Gio.Interfaces.Drive.Drive'. -}
    -> b
    {- ^ /@result@/: a 'GI.Gio.Interfaces.AsyncResult.AsyncResult'. -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
driveStopFinish :: a -> b -> m ()
driveStopFinish drive :: a
drive result_ :: b
result_ = DriveChangedCallback -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (DriveChangedCallback -> m ()) -> DriveChangedCallback -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr Drive
drive' <- a -> IO (Ptr Drive)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
drive
    Ptr AsyncResult
result_' <- b -> IO (Ptr AsyncResult)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
result_
    DriveChangedCallback
-> DriveChangedCallback -> DriveChangedCallback
forall a b. IO a -> IO b -> IO a
onException (do
        CInt
_ <- (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CInt) -> IO CInt)
-> (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ Ptr Drive -> Ptr AsyncResult -> Ptr (Ptr GError) -> IO CInt
g_drive_stop_finish Ptr Drive
drive' Ptr AsyncResult
result_'
        a -> DriveChangedCallback
forall a. ManagedPtrNewtype a => a -> DriveChangedCallback
touchManagedPtr a
drive
        b -> DriveChangedCallback
forall a. ManagedPtrNewtype a => a -> DriveChangedCallback
touchManagedPtr b
result_
        () -> DriveChangedCallback
forall (m :: * -> *) a. Monad m => a -> m a
return ()
     ) (do
        () -> DriveChangedCallback
forall (m :: * -> *) a. Monad m => a -> m a
return ()
     )

#if ENABLE_OVERLOADING
data DriveStopFinishMethodInfo
instance (signature ~ (b -> m ()), MonadIO m, IsDrive a, Gio.AsyncResult.IsAsyncResult b) => O.MethodInfo DriveStopFinishMethodInfo a signature where
    overloadedMethod _ = driveStopFinish

#endif