{-# LANGUAGE TypeApplications #-}
#if !defined(__HADDOCK_VERSION__)
#define ENABLE_OVERLOADING
#endif
module GI.Atk.Interfaces.Image
(
Image(..) ,
IsImage ,
#if defined(ENABLE_OVERLOADING)
ResolveImageMethod ,
#endif
#if defined(ENABLE_OVERLOADING)
ImageGetImageDescriptionMethodInfo ,
#endif
imageGetImageDescription ,
#if defined(ENABLE_OVERLOADING)
ImageGetImageLocaleMethodInfo ,
#endif
imageGetImageLocale ,
#if defined(ENABLE_OVERLOADING)
ImageGetImagePositionMethodInfo ,
#endif
imageGetImagePosition ,
#if defined(ENABLE_OVERLOADING)
ImageGetImageSizeMethodInfo ,
#endif
imageGetImageSize ,
#if defined(ENABLE_OVERLOADING)
ImageSetImageDescriptionMethodInfo ,
#endif
imageSetImageDescription ,
) 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 {-# SOURCE #-} qualified GI.Atk.Enums as Atk.Enums
#else
import {-# SOURCE #-} qualified GI.Atk.Enums as Atk.Enums
#endif
newtype Image = Image (SP.ManagedPtr Image)
deriving (Image -> Image -> Bool
(Image -> Image -> Bool) -> (Image -> Image -> Bool) -> Eq Image
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Image -> Image -> Bool
== :: Image -> Image -> Bool
$c/= :: Image -> Image -> Bool
/= :: Image -> Image -> Bool
Eq)
instance SP.ManagedPtrNewtype Image where
toManagedPtr :: Image -> ManagedPtr Image
toManagedPtr (Image ManagedPtr Image
p) = ManagedPtr Image
p
class (ManagedPtrNewtype o, O.IsDescendantOf Image o) => IsImage o
instance (ManagedPtrNewtype o, O.IsDescendantOf Image o) => IsImage o
instance BoxedPtr Image where
boxedPtrCopy :: Image -> IO Image
boxedPtrCopy = Image -> IO Image
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return
boxedPtrFree :: Image -> IO ()
boxedPtrFree = \Image
_x -> () -> IO ()
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
#if defined(ENABLE_OVERLOADING)
type family ResolveImageMethod (t :: Symbol) (o :: DK.Type) :: DK.Type where
ResolveImageMethod "getImageDescription" o = ImageGetImageDescriptionMethodInfo
ResolveImageMethod "getImageLocale" o = ImageGetImageLocaleMethodInfo
ResolveImageMethod "getImagePosition" o = ImageGetImagePositionMethodInfo
ResolveImageMethod "getImageSize" o = ImageGetImageSizeMethodInfo
ResolveImageMethod "setImageDescription" o = ImageSetImageDescriptionMethodInfo
ResolveImageMethod l o = O.MethodResolutionFailed l o
instance (info ~ ResolveImageMethod t Image, O.OverloadedMethod info Image p) => OL.IsLabel t (Image -> 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 ~ ResolveImageMethod t Image, O.OverloadedMethod info Image p, R.HasField t Image p) => R.HasField t Image p where
getField = O.overloadedMethod @info
#endif
instance (info ~ ResolveImageMethod t Image, O.OverloadedMethodInfo info Image) => OL.IsLabel t (O.MethodProxy info Image) where
#if MIN_VERSION_base(4,10,0)
fromLabel = O.MethodProxy
#else
fromLabel _ = O.MethodProxy
#endif
#endif
foreign import ccall "atk_image_get_image_description" atk_image_get_image_description ::
Ptr Image ->
IO CString
imageGetImageDescription ::
(B.CallStack.HasCallStack, MonadIO m, IsImage a) =>
a
-> m T.Text
imageGetImageDescription :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsImage a) =>
a -> m Text
imageGetImageDescription a
image = IO Text -> m Text
forall a. IO a -> m a
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
image' <- a -> IO (Ptr Image)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
image
result <- atk_image_get_image_description image'
checkUnexpectedReturnNULL "imageGetImageDescription" result
result' <- cstringToText result
touchManagedPtr image
return result'
#if defined(ENABLE_OVERLOADING)
data ImageGetImageDescriptionMethodInfo
instance (signature ~ (m T.Text), MonadIO m, IsImage a) => O.OverloadedMethod ImageGetImageDescriptionMethodInfo a signature where
overloadedMethod = imageGetImageDescription
instance O.OverloadedMethodInfo ImageGetImageDescriptionMethodInfo a where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.Atk.Interfaces.Image.imageGetImageDescription",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-atk-2.0.28/docs/GI-Atk-Interfaces-Image.html#v:imageGetImageDescription"
})
#endif
foreign import ccall "atk_image_get_image_locale" atk_image_get_image_locale ::
Ptr Image ->
IO CString
imageGetImageLocale ::
(B.CallStack.HasCallStack, MonadIO m, IsImage a) =>
a
-> m (Maybe T.Text)
imageGetImageLocale :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsImage a) =>
a -> m (Maybe Text)
imageGetImageLocale a
image = IO (Maybe Text) -> m (Maybe Text)
forall a. IO a -> m a
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
image' <- a -> IO (Ptr Image)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
image
result <- atk_image_get_image_locale image'
maybeResult <- convertIfNonNull result $ \CString
result' -> do
result'' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result'
return result''
touchManagedPtr image
return maybeResult
#if defined(ENABLE_OVERLOADING)
data ImageGetImageLocaleMethodInfo
instance (signature ~ (m (Maybe T.Text)), MonadIO m, IsImage a) => O.OverloadedMethod ImageGetImageLocaleMethodInfo a signature where
overloadedMethod = imageGetImageLocale
instance O.OverloadedMethodInfo ImageGetImageLocaleMethodInfo a where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.Atk.Interfaces.Image.imageGetImageLocale",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-atk-2.0.28/docs/GI-Atk-Interfaces-Image.html#v:imageGetImageLocale"
})
#endif
foreign import ccall "atk_image_get_image_position" atk_image_get_image_position ::
Ptr Image ->
Ptr Int32 ->
Ptr Int32 ->
CUInt ->
IO ()
imageGetImagePosition ::
(B.CallStack.HasCallStack, MonadIO m, IsImage a) =>
a
-> Atk.Enums.CoordType
-> m ((Int32, Int32))
imageGetImagePosition :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsImage a) =>
a -> CoordType -> m (Int32, Int32)
imageGetImagePosition a
image CoordType
coordType = IO (Int32, Int32) -> m (Int32, Int32)
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Int32, Int32) -> m (Int32, Int32))
-> IO (Int32, Int32) -> m (Int32, Int32)
forall a b. (a -> b) -> a -> b
$ do
image' <- a -> IO (Ptr Image)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
image
x <- allocMem :: IO (Ptr Int32)
y <- allocMem :: IO (Ptr Int32)
let coordType' = (Int -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CUInt) -> (CoordType -> Int) -> CoordType -> CUInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CoordType -> Int
forall a. Enum a => a -> Int
fromEnum) CoordType
coordType
atk_image_get_image_position image' x y coordType'
x' <- peek x
y' <- peek y
touchManagedPtr image
freeMem x
freeMem y
return (x', y')
#if defined(ENABLE_OVERLOADING)
data ImageGetImagePositionMethodInfo
instance (signature ~ (Atk.Enums.CoordType -> m ((Int32, Int32))), MonadIO m, IsImage a) => O.OverloadedMethod ImageGetImagePositionMethodInfo a signature where
overloadedMethod = imageGetImagePosition
instance O.OverloadedMethodInfo ImageGetImagePositionMethodInfo a where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.Atk.Interfaces.Image.imageGetImagePosition",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-atk-2.0.28/docs/GI-Atk-Interfaces-Image.html#v:imageGetImagePosition"
})
#endif
foreign import ccall "atk_image_get_image_size" atk_image_get_image_size ::
Ptr Image ->
Ptr Int32 ->
Ptr Int32 ->
IO ()
imageGetImageSize ::
(B.CallStack.HasCallStack, MonadIO m, IsImage a) =>
a
-> m ((Int32, Int32))
imageGetImageSize :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsImage a) =>
a -> m (Int32, Int32)
imageGetImageSize a
image = IO (Int32, Int32) -> m (Int32, Int32)
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Int32, Int32) -> m (Int32, Int32))
-> IO (Int32, Int32) -> m (Int32, Int32)
forall a b. (a -> b) -> a -> b
$ do
image' <- a -> IO (Ptr Image)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
image
width <- allocMem :: IO (Ptr Int32)
height <- allocMem :: IO (Ptr Int32)
atk_image_get_image_size image' width height
width' <- peek width
height' <- peek height
touchManagedPtr image
freeMem width
freeMem height
return (width', height')
#if defined(ENABLE_OVERLOADING)
data ImageGetImageSizeMethodInfo
instance (signature ~ (m ((Int32, Int32))), MonadIO m, IsImage a) => O.OverloadedMethod ImageGetImageSizeMethodInfo a signature where
overloadedMethod = imageGetImageSize
instance O.OverloadedMethodInfo ImageGetImageSizeMethodInfo a where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.Atk.Interfaces.Image.imageGetImageSize",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-atk-2.0.28/docs/GI-Atk-Interfaces-Image.html#v:imageGetImageSize"
})
#endif
foreign import ccall "atk_image_set_image_description" atk_image_set_image_description ::
Ptr Image ->
CString ->
IO CInt
imageSetImageDescription ::
(B.CallStack.HasCallStack, MonadIO m, IsImage a) =>
a
-> T.Text
-> m Bool
imageSetImageDescription :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsImage a) =>
a -> Text -> m Bool
imageSetImageDescription a
image Text
description = 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
image' <- a -> IO (Ptr Image)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
image
description' <- textToCString description
result <- atk_image_set_image_description image' description'
let result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
touchManagedPtr image
freeMem description'
return result'
#if defined(ENABLE_OVERLOADING)
data ImageSetImageDescriptionMethodInfo
instance (signature ~ (T.Text -> m Bool), MonadIO m, IsImage a) => O.OverloadedMethod ImageSetImageDescriptionMethodInfo a signature where
overloadedMethod = imageSetImageDescription
instance O.OverloadedMethodInfo ImageSetImageDescriptionMethodInfo a where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.Atk.Interfaces.Image.imageSetImageDescription",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-atk-2.0.28/docs/GI-Atk-Interfaces-Image.html#v:imageSetImageDescription"
})
#endif
#if defined(ENABLE_OVERLOADING)
type instance O.SignalList Image = ImageSignalList
type ImageSignalList = ('[ ] :: [(Symbol, DK.Type)])
#endif