{- | Copyright : Will Thompson, Iñaki García Etxebarria and Jonas Platte License : LGPL-2.1 Maintainer : Iñaki García Etxebarria (garetxe@gmail.com) -} module GI.Gio.Interfaces.Seekable ( -- * Exported types Seekable(..) , noSeekable , SeekableK , toSeekable , -- * Methods -- ** seekableCanSeek seekableCanSeek , -- ** seekableCanTruncate seekableCanTruncate , -- ** seekableSeek seekableSeek , -- ** seekableTell seekableTell , -- ** seekableTruncate seekableTruncate , ) where import Prelude () import Data.GI.Base.ShortPrelude import qualified Data.Text as T import qualified Data.ByteString.Char8 as B import qualified Data.Map as Map import GI.Gio.Types import GI.Gio.Callbacks import qualified GI.GLib as GLib import qualified GI.GObject as GObject -- interface Seekable newtype Seekable = Seekable (ForeignPtr Seekable) noSeekable :: Maybe Seekable noSeekable = Nothing type instance AttributeList Seekable = SeekableAttributeList type SeekableAttributeList = ('[ ] :: [(Symbol, *)]) type instance SignalList Seekable = SeekableSignalList type SeekableSignalList = ('[ '("notify", GObject.ObjectNotifySignalInfo), '("notify::[property]", GObjectNotifySignalInfo)] :: [(Symbol, *)]) foreign import ccall "g_seekable_get_type" c_g_seekable_get_type :: IO GType type instance ParentTypes Seekable = SeekableParentTypes type SeekableParentTypes = '[GObject.Object] instance GObject Seekable where gobjectIsInitiallyUnowned _ = False gobjectType _ = c_g_seekable_get_type class GObject o => SeekableK o instance (GObject o, IsDescendantOf Seekable o) => SeekableK o toSeekable :: SeekableK o => o -> IO Seekable toSeekable = unsafeCastTo Seekable -- method Seekable::can_seek -- method type : OrdinaryMethod -- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "Seekable", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- Lengths : [] -- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "Seekable", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- returnType : TBasicType TBoolean -- throws : False -- Skip return : False foreign import ccall "g_seekable_can_seek" g_seekable_can_seek :: Ptr Seekable -> -- _obj : TInterface "Gio" "Seekable" IO CInt seekableCanSeek :: (MonadIO m, SeekableK a) => a -> -- _obj m Bool seekableCanSeek _obj = liftIO $ do let _obj' = unsafeManagedPtrCastPtr _obj result <- g_seekable_can_seek _obj' let result' = (/= 0) result touchManagedPtr _obj return result' -- method Seekable::can_truncate -- method type : OrdinaryMethod -- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "Seekable", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- Lengths : [] -- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "Seekable", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- returnType : TBasicType TBoolean -- throws : False -- Skip return : False foreign import ccall "g_seekable_can_truncate" g_seekable_can_truncate :: Ptr Seekable -> -- _obj : TInterface "Gio" "Seekable" IO CInt seekableCanTruncate :: (MonadIO m, SeekableK a) => a -> -- _obj m Bool seekableCanTruncate _obj = liftIO $ do let _obj' = unsafeManagedPtrCastPtr _obj result <- g_seekable_can_truncate _obj' let result' = (/= 0) result touchManagedPtr _obj return result' -- method Seekable::seek -- method type : OrdinaryMethod -- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "Seekable", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "offset", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "type", argType = TInterface "GLib" "SeekType", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "cancellable", argType = TInterface "Gio" "Cancellable", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- Lengths : [] -- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "Seekable", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "offset", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "type", argType = TInterface "GLib" "SeekType", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "cancellable", argType = TInterface "Gio" "Cancellable", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- returnType : TBasicType TBoolean -- throws : True -- Skip return : False foreign import ccall "g_seekable_seek" g_seekable_seek :: Ptr Seekable -> -- _obj : TInterface "Gio" "Seekable" Int64 -> -- offset : TBasicType TInt64 CUInt -> -- type : TInterface "GLib" "SeekType" Ptr Cancellable -> -- cancellable : TInterface "Gio" "Cancellable" Ptr (Ptr GError) -> -- error IO CInt seekableSeek :: (MonadIO m, SeekableK a, CancellableK b) => a -> -- _obj Int64 -> -- offset GLib.SeekType -> -- type Maybe (b) -> -- cancellable m () seekableSeek _obj offset type_ cancellable = liftIO $ do let _obj' = unsafeManagedPtrCastPtr _obj let type_' = (fromIntegral . fromEnum) type_ maybeCancellable <- case cancellable of Nothing -> return nullPtr Just jCancellable -> do let jCancellable' = unsafeManagedPtrCastPtr jCancellable return jCancellable' onException (do _ <- propagateGError $ g_seekable_seek _obj' offset type_' maybeCancellable touchManagedPtr _obj whenJust cancellable touchManagedPtr return () ) (do return () ) -- method Seekable::tell -- method type : OrdinaryMethod -- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "Seekable", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- Lengths : [] -- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "Seekable", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- returnType : TBasicType TInt64 -- throws : False -- Skip return : False foreign import ccall "g_seekable_tell" g_seekable_tell :: Ptr Seekable -> -- _obj : TInterface "Gio" "Seekable" IO Int64 seekableTell :: (MonadIO m, SeekableK a) => a -> -- _obj m Int64 seekableTell _obj = liftIO $ do let _obj' = unsafeManagedPtrCastPtr _obj result <- g_seekable_tell _obj' touchManagedPtr _obj return result -- method Seekable::truncate -- method type : OrdinaryMethod -- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "Seekable", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "offset", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "cancellable", argType = TInterface "Gio" "Cancellable", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- Lengths : [] -- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "Seekable", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "offset", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "cancellable", argType = TInterface "Gio" "Cancellable", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- returnType : TBasicType TBoolean -- throws : True -- Skip return : False foreign import ccall "g_seekable_truncate" g_seekable_truncate :: Ptr Seekable -> -- _obj : TInterface "Gio" "Seekable" Int64 -> -- offset : TBasicType TInt64 Ptr Cancellable -> -- cancellable : TInterface "Gio" "Cancellable" Ptr (Ptr GError) -> -- error IO CInt seekableTruncate :: (MonadIO m, SeekableK a, CancellableK b) => a -> -- _obj Int64 -> -- offset Maybe (b) -> -- cancellable m () seekableTruncate _obj offset cancellable = liftIO $ do let _obj' = unsafeManagedPtrCastPtr _obj maybeCancellable <- case cancellable of Nothing -> return nullPtr Just jCancellable -> do let jCancellable' = unsafeManagedPtrCastPtr jCancellable return jCancellable' onException (do _ <- propagateGError $ g_seekable_truncate _obj' offset maybeCancellable touchManagedPtr _obj whenJust cancellable touchManagedPtr return () ) (do return () )