{-# LINE 2 "./System/GIO/Volumes/Drive.chs" #-}
module System.GIO.Volumes.Drive (
Drive(..),
DriveClass,
DriveStartStopType (..),
DriveStartFlags (..),
driveGetName,
driveGetIcon,
driveHasVolumes,
driveGetVolumes,
driveCanEject,
driveGetStartStopType,
driveCanStart,
driveCanStartDegraded,
driveCanStop,
driveCanPollForMedia,
drivePollForMedia,
driveHasMedia,
driveIsMediaCheckAutomatic,
driveIsMediaRemovable,
driveEjectWithOperation,
driveEjectWithOperationFinish,
driveStart,
driveStartFinish,
driveStopFinish,
driveEnumerateIdentifiers,
driveGetIdentifier,
driveChanged,
driveDisconnected,
driveEjectButton,
driveStopButton,
) where
import Control.Monad
import Data.Maybe (fromMaybe)
import System.GIO.Enums
import System.Glib.Attributes
import System.Glib.FFI
import System.Glib.Flags
import System.Glib.GError
import System.Glib.GList
import System.Glib.GObject
import System.Glib.Properties
import System.Glib.Signals
import System.Glib.UTFString
import System.GIO.Async.AsyncResult
{-# LINE 113 "./System/GIO/Volumes/Drive.chs" #-}
import System.GIO.Signals
{-# LINE 114 "./System/GIO/Volumes/Drive.chs" #-}
import System.GIO.Types
{-# LINE 115 "./System/GIO/Volumes/Drive.chs" #-}
{-# LINE 117 "./System/GIO/Volumes/Drive.chs" #-}
driveGetName :: (DriveClass drive, GlibString string) => drive
-> IO string
driveGetName drive =
(\(Drive arg1) -> withForeignPtr arg1 $ \argPtr1 ->g_drive_get_name argPtr1) (toDrive drive)
>>= readUTFString
driveGetIcon :: DriveClass drive => drive
-> IO Icon
driveGetIcon drive =
wrapNewGObject mkIcon $
(\(Drive arg1) -> withForeignPtr arg1 $ \argPtr1 ->g_drive_get_icon argPtr1) (toDrive drive)
driveHasVolumes :: DriveClass drive => drive
-> IO Bool
driveHasVolumes drive =
liftM toBool $
(\(Drive arg1) -> withForeignPtr arg1 $ \argPtr1 ->g_drive_has_volumes argPtr1) (toDrive drive)
driveGetVolumes :: DriveClass drive => drive
-> IO [Volume]
driveGetVolumes drive = do
glistPtr <- (\(Drive arg1) -> withForeignPtr arg1 $ \argPtr1 ->g_drive_get_volumes argPtr1) (toDrive drive)
volumePtrs <- fromGList glistPtr
mapM (wrapNewGObject mkVolume . return) volumePtrs
driveCanEject :: DriveClass drive => drive
-> IO Bool
driveCanEject drive =
liftM toBool $
(\(Drive arg1) -> withForeignPtr arg1 $ \argPtr1 ->g_drive_can_eject argPtr1) (toDrive drive)
driveGetStartStopType :: DriveClass drive => drive
-> IO DriveStartStopType
driveGetStartStopType drive =
liftM (toEnum . fromIntegral) $
(\(Drive arg1) -> withForeignPtr arg1 $ \argPtr1 ->g_drive_get_start_stop_type argPtr1) (toDrive drive)
driveCanStart :: DriveClass drive => drive
-> IO Bool
driveCanStart drive =
liftM toBool $
(\(Drive arg1) -> withForeignPtr arg1 $ \argPtr1 ->g_drive_can_start argPtr1) (toDrive drive)
driveCanStartDegraded :: DriveClass drive => drive
-> IO Bool
driveCanStartDegraded drive =
liftM toBool $
(\(Drive arg1) -> withForeignPtr arg1 $ \argPtr1 ->g_drive_can_start_degraded argPtr1) (toDrive drive)
driveCanStop :: DriveClass drive => drive
-> IO Bool
driveCanStop drive =
liftM toBool $
(\(Drive arg1) -> withForeignPtr arg1 $ \argPtr1 ->g_drive_can_stop argPtr1) (toDrive drive)
driveCanPollForMedia :: DriveClass drive => drive
-> IO Bool
driveCanPollForMedia drive =
liftM toBool $
(\(Drive arg1) -> withForeignPtr arg1 $ \argPtr1 ->g_drive_can_poll_for_media argPtr1) (toDrive drive)
drivePollForMedia :: DriveClass drive => drive
-> Maybe Cancellable
-> AsyncReadyCallback
-> IO ()
drivePollForMedia drive cancellable callback = do
cCallback <- marshalAsyncReadyCallback callback
(\(Drive arg1) (Cancellable arg2) arg3 arg4 -> withForeignPtr arg1 $ \argPtr1 ->withForeignPtr arg2 $ \argPtr2 ->g_drive_poll_for_media argPtr1 argPtr2 arg3 arg4)
{-# LINE 204 "./System/GIO/Volumes/Drive.chs" #-}
(toDrive drive)
(fromMaybe (Cancellable nullForeignPtr) cancellable)
cCallback
(castFunPtrToPtr cCallback)
drivePollForMediaFinish :: DriveClass drive => drive
-> AsyncResult
-> IO ()
drivePollForMediaFinish drive result =
propagateGError (\gErrorPtr -> do
(\(Drive arg1) (AsyncResult arg2) arg3 -> withForeignPtr arg1 $ \argPtr1 ->withForeignPtr arg2 $ \argPtr2 ->g_drive_poll_for_media_finish argPtr1 argPtr2 arg3)
{-# LINE 218 "./System/GIO/Volumes/Drive.chs" #-}
(toDrive drive)
result
gErrorPtr
return ())
driveHasMedia :: DriveClass drive => drive
-> IO Bool
driveHasMedia drive =
liftM toBool $
(\(Drive arg1) -> withForeignPtr arg1 $ \argPtr1 ->g_drive_has_media argPtr1) (toDrive drive)
driveIsMediaCheckAutomatic :: DriveClass drive => drive
-> IO Bool
driveIsMediaCheckAutomatic drive =
liftM toBool $
(\(Drive arg1) -> withForeignPtr arg1 $ \argPtr1 ->g_drive_is_media_check_automatic argPtr1) (toDrive drive)
driveIsMediaRemovable :: DriveClass drive => drive
-> IO Bool
driveIsMediaRemovable drive =
liftM toBool $
(\(Drive arg1) -> withForeignPtr arg1 $ \argPtr1 ->g_drive_is_media_removable argPtr1) (toDrive drive)
driveEjectWithOperation :: DriveClass drive
=> drive
-> [MountUnmountFlags]
-> Maybe MountOperation
-> Maybe Cancellable
-> AsyncReadyCallback
-> IO ()
driveEjectWithOperation drive flags mountOperation cancellable callback = do
cCallback <- marshalAsyncReadyCallback callback
(\(Drive arg1) arg2 (MountOperation arg3) (Cancellable arg4) arg5 arg6 -> withForeignPtr arg1 $ \argPtr1 ->withForeignPtr arg3 $ \argPtr3 ->withForeignPtr arg4 $ \argPtr4 ->g_drive_eject_with_operation argPtr1 arg2 argPtr3 argPtr4 arg5 arg6)
{-# LINE 258 "./System/GIO/Volumes/Drive.chs" #-}
(toDrive drive)
((fromIntegral . fromFlags) flags)
(fromMaybe (MountOperation nullForeignPtr) mountOperation)
(fromMaybe (Cancellable nullForeignPtr) cancellable)
cCallback
(castFunPtrToPtr cCallback)
driveEjectWithOperationFinish :: DriveClass drive
=> drive
-> AsyncResult
-> IO ()
driveEjectWithOperationFinish drive result =
propagateGError (\gErrorPtr -> do
(\(Drive arg1) (AsyncResult arg2) arg3 -> withForeignPtr arg1 $ \argPtr1 ->withForeignPtr arg2 $ \argPtr2 ->g_drive_eject_with_operation_finish argPtr1 argPtr2 arg3)
{-# LINE 276 "./System/GIO/Volumes/Drive.chs" #-}
(toDrive drive)
result
gErrorPtr
return ())
driveStart :: DriveClass drive
=> drive
-> [DriveStartFlags]
-> Maybe MountOperation
-> Maybe Cancellable
-> AsyncReadyCallback
-> IO ()
driveStart drive flags mountOperation cancellable callback = do
cCallback <- marshalAsyncReadyCallback callback
(\(Drive arg1) arg2 (MountOperation arg3) (Cancellable arg4) arg5 arg6 -> withForeignPtr arg1 $ \argPtr1 ->withForeignPtr arg3 $ \argPtr3 ->withForeignPtr arg4 $ \argPtr4 ->g_drive_start argPtr1 arg2 argPtr3 argPtr4 arg5 arg6)
{-# LINE 295 "./System/GIO/Volumes/Drive.chs" #-}
(toDrive drive)
((fromIntegral . fromFlags) flags)
(fromMaybe (MountOperation nullForeignPtr) mountOperation)
(fromMaybe (Cancellable nullForeignPtr) cancellable)
cCallback
(castFunPtrToPtr cCallback)
driveStartFinish :: DriveClass drive
=> drive
-> AsyncResult
-> IO ()
driveStartFinish drive result =
propagateGError (\gErrorPtr -> do
(\(Drive arg1) (AsyncResult arg2) arg3 -> withForeignPtr arg1 $ \argPtr1 ->withForeignPtr arg2 $ \argPtr2 ->g_drive_start_finish argPtr1 argPtr2 arg3)
{-# LINE 312 "./System/GIO/Volumes/Drive.chs" #-}
(toDrive drive)
result
gErrorPtr
return ())
driveStop :: DriveClass drive
=> drive
-> [MountUnmountFlags]
-> Maybe MountOperation
-> Maybe Cancellable
-> AsyncReadyCallback
-> IO ()
driveStop drive flags mountOperation cancellable callback = do
cCallback <- marshalAsyncReadyCallback callback
(\(Drive arg1) arg2 (MountOperation arg3) (Cancellable arg4) arg5 arg6 -> withForeignPtr arg1 $ \argPtr1 ->withForeignPtr arg3 $ \argPtr3 ->withForeignPtr arg4 $ \argPtr4 ->g_drive_stop argPtr1 arg2 argPtr3 argPtr4 arg5 arg6)
{-# LINE 331 "./System/GIO/Volumes/Drive.chs" #-}
(toDrive drive)
((fromIntegral . fromFlags) flags)
(fromMaybe (MountOperation nullForeignPtr) mountOperation)
(fromMaybe (Cancellable nullForeignPtr) cancellable)
cCallback
(castFunPtrToPtr cCallback)
driveStopFinish :: DriveClass drive
=> drive
-> AsyncResult
-> IO ()
driveStopFinish drive result =
propagateGError (\gErrorPtr -> do
(\(Drive arg1) (AsyncResult arg2) arg3 -> withForeignPtr arg1 $ \argPtr1 ->withForeignPtr arg2 $ \argPtr2 ->g_drive_stop_finish argPtr1 argPtr2 arg3)
{-# LINE 348 "./System/GIO/Volumes/Drive.chs" #-}
(toDrive drive)
result
gErrorPtr
return ())
driveEnumerateIdentifiers :: (DriveClass drive, GlibString string) => drive
-> IO [string]
driveEnumerateIdentifiers drive =
(\(Drive arg1) -> withForeignPtr arg1 $ \argPtr1 ->g_drive_enumerate_identifiers argPtr1) (toDrive drive)
>>= readUTFStringArray0
driveGetIdentifier :: (DriveClass drive, GlibString string) => drive
-> string
-> IO string
driveGetIdentifier drive kind =
withUTFString kind $ \ kindPtr ->
(\(Drive arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->g_drive_get_identifier argPtr1 arg2) (toDrive drive) kindPtr
>>= readUTFString
driveChanged :: DriveClass drive => Signal drive (Drive -> IO ())
driveChanged = Signal (connect_OBJECT__NONE "drive-changed")
driveDisconnected :: DriveClass drive => Signal drive (Drive -> IO ())
driveDisconnected = Signal (connect_OBJECT__NONE "drive-disconnected")
driveEjectButton :: DriveClass drive => Signal drive (Drive -> IO ())
driveEjectButton = Signal (connect_OBJECT__NONE "drive-eject-button")
driveStopButton :: DriveClass drive => Signal drive (Drive -> IO ())
driveStopButton = Signal (connect_OBJECT__NONE "drive-stop-button")
foreign import ccall safe "g_drive_get_name"
g_drive_get_name :: ((Ptr Drive) -> (IO (Ptr CChar)))
foreign import ccall safe "g_drive_get_icon"
g_drive_get_icon :: ((Ptr Drive) -> (IO (Ptr Icon)))
foreign import ccall safe "g_drive_has_volumes"
g_drive_has_volumes :: ((Ptr Drive) -> (IO CInt))
foreign import ccall safe "g_drive_get_volumes"
g_drive_get_volumes :: ((Ptr Drive) -> (IO (Ptr ())))
foreign import ccall safe "g_drive_can_eject"
g_drive_can_eject :: ((Ptr Drive) -> (IO CInt))
foreign import ccall safe "g_drive_get_start_stop_type"
g_drive_get_start_stop_type :: ((Ptr Drive) -> (IO CInt))
foreign import ccall safe "g_drive_can_start"
g_drive_can_start :: ((Ptr Drive) -> (IO CInt))
foreign import ccall safe "g_drive_can_start_degraded"
g_drive_can_start_degraded :: ((Ptr Drive) -> (IO CInt))
foreign import ccall safe "g_drive_can_stop"
g_drive_can_stop :: ((Ptr Drive) -> (IO CInt))
foreign import ccall safe "g_drive_can_poll_for_media"
g_drive_can_poll_for_media :: ((Ptr Drive) -> (IO CInt))
foreign import ccall safe "g_drive_poll_for_media"
g_drive_poll_for_media :: ((Ptr Drive) -> ((Ptr Cancellable) -> ((FunPtr ((Ptr ()) -> ((Ptr AsyncResult) -> ((Ptr ()) -> (IO ()))))) -> ((Ptr ()) -> (IO ())))))
foreign import ccall safe "g_drive_poll_for_media_finish"
g_drive_poll_for_media_finish :: ((Ptr Drive) -> ((Ptr AsyncResult) -> ((Ptr (Ptr ())) -> (IO CInt))))
foreign import ccall safe "g_drive_has_media"
g_drive_has_media :: ((Ptr Drive) -> (IO CInt))
foreign import ccall safe "g_drive_is_media_check_automatic"
g_drive_is_media_check_automatic :: ((Ptr Drive) -> (IO CInt))
foreign import ccall safe "g_drive_is_media_removable"
g_drive_is_media_removable :: ((Ptr Drive) -> (IO CInt))
foreign import ccall safe "g_drive_eject_with_operation"
g_drive_eject_with_operation :: ((Ptr Drive) -> (CInt -> ((Ptr MountOperation) -> ((Ptr Cancellable) -> ((FunPtr ((Ptr ()) -> ((Ptr AsyncResult) -> ((Ptr ()) -> (IO ()))))) -> ((Ptr ()) -> (IO ())))))))
foreign import ccall safe "g_drive_eject_with_operation_finish"
g_drive_eject_with_operation_finish :: ((Ptr Drive) -> ((Ptr AsyncResult) -> ((Ptr (Ptr ())) -> (IO CInt))))
foreign import ccall safe "g_drive_start"
g_drive_start :: ((Ptr Drive) -> (CInt -> ((Ptr MountOperation) -> ((Ptr Cancellable) -> ((FunPtr ((Ptr ()) -> ((Ptr AsyncResult) -> ((Ptr ()) -> (IO ()))))) -> ((Ptr ()) -> (IO ())))))))
foreign import ccall safe "g_drive_start_finish"
g_drive_start_finish :: ((Ptr Drive) -> ((Ptr AsyncResult) -> ((Ptr (Ptr ())) -> (IO CInt))))
foreign import ccall safe "g_drive_stop"
g_drive_stop :: ((Ptr Drive) -> (CInt -> ((Ptr MountOperation) -> ((Ptr Cancellable) -> ((FunPtr ((Ptr ()) -> ((Ptr AsyncResult) -> ((Ptr ()) -> (IO ()))))) -> ((Ptr ()) -> (IO ())))))))
foreign import ccall safe "g_drive_stop_finish"
g_drive_stop_finish :: ((Ptr Drive) -> ((Ptr AsyncResult) -> ((Ptr (Ptr ())) -> (IO CInt))))
foreign import ccall safe "g_drive_enumerate_identifiers"
g_drive_enumerate_identifiers :: ((Ptr Drive) -> (IO (Ptr (Ptr CChar))))
foreign import ccall safe "g_drive_get_identifier"
g_drive_get_identifier :: ((Ptr Drive) -> ((Ptr CChar) -> (IO (Ptr CChar))))