{-# LANGUAGE TypeApplications #-}
#if (MIN_VERSION_haskell_gi_overloading(1,0,0) && !defined(__HADDOCK_VERSION__))
#define ENABLE_OVERLOADING
#endif
module GI.Gio.Interfaces.Seekable
(
Seekable(..) ,
noSeekable ,
IsSeekable ,
toSeekable ,
#if defined(ENABLE_OVERLOADING)
ResolveSeekableMethod ,
#endif
#if defined(ENABLE_OVERLOADING)
SeekableCanSeekMethodInfo ,
#endif
seekableCanSeek ,
#if defined(ENABLE_OVERLOADING)
SeekableCanTruncateMethodInfo ,
#endif
seekableCanTruncate ,
#if defined(ENABLE_OVERLOADING)
SeekableSeekMethodInfo ,
#endif
seekableSeek ,
#if defined(ENABLE_OVERLOADING)
SeekableTellMethodInfo ,
#endif
seekableTell ,
#if defined(ENABLE_OVERLOADING)
SeekableTruncateMethodInfo ,
#endif
seekableTruncate ,
) 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.GClosure as B.GClosure
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.GI.Base.Properties as B.Properties
import qualified Data.GI.Base.Signals as B.Signals
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 GHC.OverloadedLabels as OL
import qualified GI.GLib.Enums as GLib.Enums
import qualified GI.GObject.Objects.Object as GObject.Object
import {-# SOURCE #-} qualified GI.Gio.Objects.Cancellable as Gio.Cancellable
newtype Seekable = Seekable (ManagedPtr Seekable)
deriving (Seekable -> Seekable -> Bool
(Seekable -> Seekable -> Bool)
-> (Seekable -> Seekable -> Bool) -> Eq Seekable
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Seekable -> Seekable -> Bool
$c/= :: Seekable -> Seekable -> Bool
== :: Seekable -> Seekable -> Bool
$c== :: Seekable -> Seekable -> Bool
Eq)
noSeekable :: Maybe Seekable
noSeekable :: Maybe Seekable
noSeekable = Maybe Seekable
forall a. Maybe a
Nothing
#if defined(ENABLE_OVERLOADING)
type instance O.SignalList Seekable = SeekableSignalList
type SeekableSignalList = ('[ '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, *)])
#endif
foreign import ccall "g_seekable_get_type"
c_g_seekable_get_type :: IO GType
instance GObject Seekable where
gobjectType :: IO GType
gobjectType = IO GType
c_g_seekable_get_type
instance B.GValue.IsGValue Seekable where
toGValue :: Seekable -> IO GValue
toGValue o :: Seekable
o = do
GType
gtype <- IO GType
c_g_seekable_get_type
Seekable -> (Ptr Seekable -> IO GValue) -> IO GValue
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
B.ManagedPtr.withManagedPtr Seekable
o (GType
-> (GValue -> Ptr Seekable -> IO ()) -> Ptr Seekable -> IO GValue
forall a. GType -> (GValue -> a -> IO ()) -> a -> IO GValue
B.GValue.buildGValue GType
gtype GValue -> Ptr Seekable -> IO ()
forall a. GObject a => GValue -> Ptr a -> IO ()
B.GValue.set_object)
fromGValue :: GValue -> IO Seekable
fromGValue gv :: GValue
gv = do
Ptr Seekable
ptr <- GValue -> IO (Ptr Seekable)
forall b. GObject b => GValue -> IO (Ptr b)
B.GValue.get_object GValue
gv :: IO (Ptr Seekable)
(ManagedPtr Seekable -> Seekable) -> Ptr Seekable -> IO Seekable
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
B.ManagedPtr.newObject ManagedPtr Seekable -> Seekable
Seekable Ptr Seekable
ptr
class (GObject o, O.IsDescendantOf Seekable o) => IsSeekable o
instance (GObject o, O.IsDescendantOf Seekable o) => IsSeekable o
instance O.HasParentTypes Seekable
type instance O.ParentTypes Seekable = '[GObject.Object.Object]
toSeekable :: (MonadIO m, IsSeekable o) => o -> m Seekable
toSeekable :: o -> m Seekable
toSeekable = IO Seekable -> m Seekable
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Seekable -> m Seekable)
-> (o -> IO Seekable) -> o -> m Seekable
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ManagedPtr Seekable -> Seekable) -> o -> IO Seekable
forall o o'.
(HasCallStack, GObject o, GObject o') =>
(ManagedPtr o' -> o') -> o -> IO o'
unsafeCastTo ManagedPtr Seekable -> Seekable
Seekable
#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList Seekable
type instance O.AttributeList Seekable = SeekableAttributeList
type SeekableAttributeList = ('[ ] :: [(Symbol, *)])
#endif
#if defined(ENABLE_OVERLOADING)
#endif
#if defined(ENABLE_OVERLOADING)
type family ResolveSeekableMethod (t :: Symbol) (o :: *) :: * where
ResolveSeekableMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
ResolveSeekableMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
ResolveSeekableMethod "canSeek" o = SeekableCanSeekMethodInfo
ResolveSeekableMethod "canTruncate" o = SeekableCanTruncateMethodInfo
ResolveSeekableMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
ResolveSeekableMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
ResolveSeekableMethod "getv" o = GObject.Object.ObjectGetvMethodInfo
ResolveSeekableMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
ResolveSeekableMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
ResolveSeekableMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
ResolveSeekableMethod "ref" o = GObject.Object.ObjectRefMethodInfo
ResolveSeekableMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
ResolveSeekableMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
ResolveSeekableMethod "seek" o = SeekableSeekMethodInfo
ResolveSeekableMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
ResolveSeekableMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
ResolveSeekableMethod "tell" o = SeekableTellMethodInfo
ResolveSeekableMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
ResolveSeekableMethod "truncate" o = SeekableTruncateMethodInfo
ResolveSeekableMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
ResolveSeekableMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
ResolveSeekableMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
ResolveSeekableMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
ResolveSeekableMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
ResolveSeekableMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
ResolveSeekableMethod "setDataFull" o = GObject.Object.ObjectSetDataFullMethodInfo
ResolveSeekableMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
ResolveSeekableMethod l o = O.MethodResolutionFailed l o
instance (info ~ ResolveSeekableMethod t Seekable, O.MethodInfo info Seekable p) => OL.IsLabel t (Seekable -> p) where
#if MIN_VERSION_base(4,10,0)
fromLabel = O.overloadedMethod @info
#else
fromLabel _ = O.overloadedMethod @info
#endif
#endif
foreign import ccall "g_seekable_can_seek" g_seekable_can_seek ::
Ptr Seekable ->
IO CInt
seekableCanSeek ::
(B.CallStack.HasCallStack, MonadIO m, IsSeekable a) =>
a
-> m Bool
seekableCanSeek :: a -> m Bool
seekableCanSeek seekable :: a
seekable = 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 Seekable
seekable' <- a -> IO (Ptr Seekable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
seekable
CInt
result <- Ptr Seekable -> IO CInt
g_seekable_can_seek Ptr Seekable
seekable'
let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
seekable
Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'
#if defined(ENABLE_OVERLOADING)
data SeekableCanSeekMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsSeekable a) => O.MethodInfo SeekableCanSeekMethodInfo a signature where
overloadedMethod = seekableCanSeek
#endif
foreign import ccall "g_seekable_can_truncate" g_seekable_can_truncate ::
Ptr Seekable ->
IO CInt
seekableCanTruncate ::
(B.CallStack.HasCallStack, MonadIO m, IsSeekable a) =>
a
-> m Bool
seekableCanTruncate :: a -> m Bool
seekableCanTruncate seekable :: a
seekable = 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 Seekable
seekable' <- a -> IO (Ptr Seekable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
seekable
CInt
result <- Ptr Seekable -> IO CInt
g_seekable_can_truncate Ptr Seekable
seekable'
let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
seekable
Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'
#if defined(ENABLE_OVERLOADING)
data SeekableCanTruncateMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsSeekable a) => O.MethodInfo SeekableCanTruncateMethodInfo a signature where
overloadedMethod = seekableCanTruncate
#endif
foreign import ccall "g_seekable_seek" g_seekable_seek ::
Ptr Seekable ->
Int64 ->
CUInt ->
Ptr Gio.Cancellable.Cancellable ->
Ptr (Ptr GError) ->
IO CInt
seekableSeek ::
(B.CallStack.HasCallStack, MonadIO m, IsSeekable a, Gio.Cancellable.IsCancellable b) =>
a
-> Int64
-> GLib.Enums.SeekType
-> Maybe (b)
-> m ()
seekableSeek :: a -> Int64 -> SeekType -> Maybe b -> m ()
seekableSeek seekable :: a
seekable offset :: Int64
offset type_ :: SeekType
type_ cancellable :: Maybe b
cancellable = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
Ptr Seekable
seekable' <- a -> IO (Ptr Seekable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
seekable
let type_' :: CUInt
type_' = (Int -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CUInt) -> (SeekType -> Int) -> SeekType -> CUInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SeekType -> Int
forall a. Enum a => a -> Int
fromEnum) SeekType
type_
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'
IO () -> IO () -> IO ()
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 Seekable
-> Int64 -> CUInt -> Ptr Cancellable -> Ptr (Ptr GError) -> IO CInt
g_seekable_seek Ptr Seekable
seekable' Int64
offset CUInt
type_' Ptr Cancellable
maybeCancellable
a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
seekable
Maybe b -> (b -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe b
cancellable b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
) (do
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
)
#if defined(ENABLE_OVERLOADING)
data SeekableSeekMethodInfo
instance (signature ~ (Int64 -> GLib.Enums.SeekType -> Maybe (b) -> m ()), MonadIO m, IsSeekable a, Gio.Cancellable.IsCancellable b) => O.MethodInfo SeekableSeekMethodInfo a signature where
overloadedMethod = seekableSeek
#endif
foreign import ccall "g_seekable_tell" g_seekable_tell ::
Ptr Seekable ->
IO Int64
seekableTell ::
(B.CallStack.HasCallStack, MonadIO m, IsSeekable a) =>
a
-> m Int64
seekableTell :: a -> m Int64
seekableTell seekable :: a
seekable = IO Int64 -> m Int64
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Int64 -> m Int64) -> IO Int64 -> m Int64
forall a b. (a -> b) -> a -> b
$ do
Ptr Seekable
seekable' <- a -> IO (Ptr Seekable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
seekable
Int64
result <- Ptr Seekable -> IO Int64
g_seekable_tell Ptr Seekable
seekable'
a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
seekable
Int64 -> IO Int64
forall (m :: * -> *) a. Monad m => a -> m a
return Int64
result
#if defined(ENABLE_OVERLOADING)
data SeekableTellMethodInfo
instance (signature ~ (m Int64), MonadIO m, IsSeekable a) => O.MethodInfo SeekableTellMethodInfo a signature where
overloadedMethod = seekableTell
#endif
foreign import ccall "g_seekable_truncate" g_seekable_truncate ::
Ptr Seekable ->
Int64 ->
Ptr Gio.Cancellable.Cancellable ->
Ptr (Ptr GError) ->
IO CInt
seekableTruncate ::
(B.CallStack.HasCallStack, MonadIO m, IsSeekable a, Gio.Cancellable.IsCancellable b) =>
a
-> Int64
-> Maybe (b)
-> m ()
seekableTruncate :: a -> Int64 -> Maybe b -> m ()
seekableTruncate seekable :: a
seekable offset :: Int64
offset cancellable :: Maybe b
cancellable = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
Ptr Seekable
seekable' <- a -> IO (Ptr Seekable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
seekable
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'
IO () -> IO () -> IO ()
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 Seekable
-> Int64 -> Ptr Cancellable -> Ptr (Ptr GError) -> IO CInt
g_seekable_truncate Ptr Seekable
seekable' Int64
offset Ptr Cancellable
maybeCancellable
a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
seekable
Maybe b -> (b -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe b
cancellable b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
) (do
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
)
#if defined(ENABLE_OVERLOADING)
data SeekableTruncateMethodInfo
instance (signature ~ (Int64 -> Maybe (b) -> m ()), MonadIO m, IsSeekable a, Gio.Cancellable.IsCancellable b) => O.MethodInfo SeekableTruncateMethodInfo a signature where
overloadedMethod = seekableTruncate
#endif