{-# LANGUAGE TypeApplications #-}
#if (MIN_VERSION_haskell_gi_overloading(1,0,0) && !defined(__HADDOCK_VERSION__))
#define ENABLE_OVERLOADING
#endif
module GI.Gio.Interfaces.Seekable
(
Seekable(..) ,
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.BasicTypes as B.Types
import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GArray as B.GArray
import qualified Data.GI.Base.GClosure as B.GClosure
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GHashTable as B.GHT
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 Control.Monad.IO.Class as MIO
import qualified Data.Coerce as Coerce
import qualified Data.Text as T
import qualified Data.Kind as DK
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 GHC.Records as R
import qualified Data.Word as DW
import qualified Data.Int as DI
import qualified System.Posix.Types as SPT
import qualified Foreign.C.Types as FCT
#if MIN_VERSION_base(4,18,0)
import qualified GI.GLib.Callbacks as GLib.Callbacks
import qualified GI.GLib.Enums as GLib.Enums
import qualified GI.GLib.Structs.PollFD as GLib.PollFD
import qualified GI.GLib.Structs.Source as GLib.Source
import qualified GI.GObject.Callbacks as GObject.Callbacks
import qualified GI.GObject.Objects.Object as GObject.Object
import {-# SOURCE #-} qualified GI.Gio.Objects.Cancellable as Gio.Cancellable
#else
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
#endif
newtype Seekable = Seekable (SP.ManagedPtr Seekable)
deriving (Seekable -> Seekable -> Bool
(Seekable -> Seekable -> Bool)
-> (Seekable -> Seekable -> Bool) -> Eq Seekable
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Seekable -> Seekable -> Bool
== :: Seekable -> Seekable -> Bool
$c/= :: Seekable -> Seekable -> Bool
/= :: Seekable -> Seekable -> Bool
Eq)
instance SP.ManagedPtrNewtype Seekable where
toManagedPtr :: Seekable -> ManagedPtr Seekable
toManagedPtr (Seekable ManagedPtr Seekable
p) = ManagedPtr Seekable
p
foreign import ccall "g_seekable_get_type"
c_g_seekable_get_type :: IO B.Types.GType
instance B.Types.TypedObject Seekable where
glibType :: IO GType
glibType = IO GType
c_g_seekable_get_type
instance B.Types.GObject Seekable
class (SP.GObject o, O.IsDescendantOf Seekable o) => IsSeekable o
instance (SP.GObject o, O.IsDescendantOf Seekable o) => IsSeekable o
instance O.HasParentTypes Seekable
type instance O.ParentTypes Seekable = '[GObject.Object.Object]
toSeekable :: (MIO.MonadIO m, IsSeekable o) => o -> m Seekable
toSeekable :: forall (m :: * -> *) o.
(MonadIO m, IsSeekable o) =>
o -> m Seekable
toSeekable = IO Seekable -> m Seekable
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
MIO.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, ManagedPtrNewtype o, TypedObject o,
ManagedPtrNewtype o', TypedObject o') =>
(ManagedPtr o' -> o') -> o -> IO o'
B.ManagedPtr.unsafeCastTo ManagedPtr Seekable -> Seekable
Seekable
instance B.GValue.IsGValue (Maybe Seekable) where
gvalueGType_ :: IO GType
gvalueGType_ = IO GType
c_g_seekable_get_type
gvalueSet_ :: Ptr GValue -> Maybe Seekable -> IO ()
gvalueSet_ Ptr GValue
gv Maybe Seekable
P.Nothing = Ptr GValue -> Ptr Seekable -> IO ()
forall a. GObject a => Ptr GValue -> Ptr a -> IO ()
B.GValue.set_object Ptr GValue
gv (Ptr Seekable
forall a. Ptr a
FP.nullPtr :: FP.Ptr Seekable)
gvalueSet_ Ptr GValue
gv (P.Just Seekable
obj) = Seekable -> (Ptr Seekable -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
B.ManagedPtr.withManagedPtr Seekable
obj (Ptr GValue -> Ptr Seekable -> IO ()
forall a. GObject a => Ptr GValue -> Ptr a -> IO ()
B.GValue.set_object Ptr GValue
gv)
gvalueGet_ :: Ptr GValue -> IO (Maybe Seekable)
gvalueGet_ Ptr GValue
gv = do
ptr <- Ptr GValue -> IO (Ptr Seekable)
forall a. GObject a => Ptr GValue -> IO (Ptr a)
B.GValue.get_object Ptr GValue
gv :: IO (FP.Ptr Seekable)
if ptr /= FP.nullPtr
then P.Just <$> B.ManagedPtr.newObject Seekable ptr
else return P.Nothing
#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList Seekable
type instance O.AttributeList Seekable = SeekableAttributeList
type SeekableAttributeList = ('[ ] :: [(Symbol, DK.Type)])
#endif
#if defined(ENABLE_OVERLOADING)
#endif
#if defined(ENABLE_OVERLOADING)
type family ResolveSeekableMethod (t :: Symbol) (o :: DK.Type) :: DK.Type 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.OverloadedMethod 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
#if MIN_VERSION_base(4,13,0)
instance (info ~ ResolveSeekableMethod t Seekable, O.OverloadedMethod info Seekable p, R.HasField t Seekable p) => R.HasField t Seekable p where
getField = O.overloadedMethod @info
#endif
instance (info ~ ResolveSeekableMethod t Seekable, O.OverloadedMethodInfo info Seekable) => OL.IsLabel t (O.MethodProxy info Seekable) where
#if MIN_VERSION_base(4,10,0)
fromLabel = O.MethodProxy
#else
fromLabel _ = O.MethodProxy
#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 :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsSeekable a) =>
a -> m Bool
seekableCanSeek a
seekable = IO Bool -> m Bool
forall a. IO a -> m a
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
seekable' <- a -> IO (Ptr Seekable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
seekable
result <- g_seekable_can_seek seekable'
let result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
touchManagedPtr seekable
return result'
#if defined(ENABLE_OVERLOADING)
data SeekableCanSeekMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsSeekable a) => O.OverloadedMethod SeekableCanSeekMethodInfo a signature where
overloadedMethod = seekableCanSeek
instance O.OverloadedMethodInfo SeekableCanSeekMethodInfo a where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.Gio.Interfaces.Seekable.seekableCanSeek",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-gio-2.0.35/docs/GI-Gio-Interfaces-Seekable.html#v: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 :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsSeekable a) =>
a -> m Bool
seekableCanTruncate a
seekable = IO Bool -> m Bool
forall a. IO a -> m a
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
seekable' <- a -> IO (Ptr Seekable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
seekable
result <- g_seekable_can_truncate seekable'
let result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
touchManagedPtr seekable
return result'
#if defined(ENABLE_OVERLOADING)
data SeekableCanTruncateMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsSeekable a) => O.OverloadedMethod SeekableCanTruncateMethodInfo a signature where
overloadedMethod = seekableCanTruncate
instance O.OverloadedMethodInfo SeekableCanTruncateMethodInfo a where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.Gio.Interfaces.Seekable.seekableCanTruncate",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-gio-2.0.35/docs/GI-Gio-Interfaces-Seekable.html#v: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 :: forall (m :: * -> *) a b.
(HasCallStack, MonadIO m, IsSeekable a, IsCancellable b) =>
a -> Int64 -> SeekType -> Maybe b -> m ()
seekableSeek a
seekable Int64
offset SeekType
type_ Maybe b
cancellable = IO () -> m ()
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
seekable' <- a -> IO (Ptr Seekable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
seekable
let 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_
maybeCancellable <- case cancellable of
Maybe b
Nothing -> Ptr Cancellable -> IO (Ptr Cancellable)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
forall a. Ptr a
FP.nullPtr
Just b
jCancellable -> do
jCancellable' <- b -> IO (Ptr Cancellable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
jCancellable
return jCancellable'
onException (do
_ <- propagateGError $ g_seekable_seek seekable' offset type_' maybeCancellable
touchManagedPtr seekable
whenJust cancellable touchManagedPtr
return ()
) (do
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.OverloadedMethod SeekableSeekMethodInfo a signature where
overloadedMethod = seekableSeek
instance O.OverloadedMethodInfo SeekableSeekMethodInfo a where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.Gio.Interfaces.Seekable.seekableSeek",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-gio-2.0.35/docs/GI-Gio-Interfaces-Seekable.html#v: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 :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsSeekable a) =>
a -> m Int64
seekableTell a
seekable = IO Int64 -> m Int64
forall a. IO a -> m a
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
seekable' <- a -> IO (Ptr Seekable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
seekable
result <- g_seekable_tell seekable'
touchManagedPtr seekable
return result
#if defined(ENABLE_OVERLOADING)
data SeekableTellMethodInfo
instance (signature ~ (m Int64), MonadIO m, IsSeekable a) => O.OverloadedMethod SeekableTellMethodInfo a signature where
overloadedMethod = seekableTell
instance O.OverloadedMethodInfo SeekableTellMethodInfo a where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.Gio.Interfaces.Seekable.seekableTell",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-gio-2.0.35/docs/GI-Gio-Interfaces-Seekable.html#v: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 :: forall (m :: * -> *) a b.
(HasCallStack, MonadIO m, IsSeekable a, IsCancellable b) =>
a -> Int64 -> Maybe b -> m ()
seekableTruncate a
seekable Int64
offset Maybe b
cancellable = IO () -> m ()
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
seekable' <- a -> IO (Ptr Seekable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
seekable
maybeCancellable <- case cancellable of
Maybe b
Nothing -> Ptr Cancellable -> IO (Ptr Cancellable)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
forall a. Ptr a
FP.nullPtr
Just b
jCancellable -> do
jCancellable' <- b -> IO (Ptr Cancellable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
jCancellable
return jCancellable'
onException (do
_ <- propagateGError $ g_seekable_truncate seekable' offset maybeCancellable
touchManagedPtr seekable
whenJust cancellable touchManagedPtr
return ()
) (do
return ()
)
#if defined(ENABLE_OVERLOADING)
data SeekableTruncateMethodInfo
instance (signature ~ (Int64 -> Maybe (b) -> m ()), MonadIO m, IsSeekable a, Gio.Cancellable.IsCancellable b) => O.OverloadedMethod SeekableTruncateMethodInfo a signature where
overloadedMethod = seekableTruncate
instance O.OverloadedMethodInfo SeekableTruncateMethodInfo a where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.Gio.Interfaces.Seekable.seekableTruncate",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-gio-2.0.35/docs/GI-Gio-Interfaces-Seekable.html#v:seekableTruncate"
})
#endif
#if defined(ENABLE_OVERLOADING)
type instance O.SignalList Seekable = SeekableSignalList
type SeekableSignalList = ('[ '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, DK.Type)])
#endif