{-# LANGUAGE TypeApplications #-}
#if (MIN_VERSION_haskell_gi_overloading(1,0,0) && !defined(__HADDOCK_VERSION__))
#define ENABLE_OVERLOADING
#endif
module GI.Gio.Interfaces.Icon
(
Icon(..) ,
IsIcon ,
toIcon ,
#if defined(ENABLE_OVERLOADING)
ResolveIconMethod ,
#endif
iconDeserialize ,
#if defined(ENABLE_OVERLOADING)
IconEqualMethodInfo ,
#endif
iconEqual ,
#if defined(ENABLE_OVERLOADING)
IconHashMethodInfo ,
#endif
iconHash ,
iconNewForString ,
#if defined(ENABLE_OVERLOADING)
IconSerializeMethodInfo ,
#endif
iconSerialize ,
#if defined(ENABLE_OVERLOADING)
IconToStringMethodInfo ,
#endif
iconToString ,
) 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.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 GI.GObject.Objects.Object as GObject.Object
newtype Icon = Icon (SP.ManagedPtr Icon)
deriving (Icon -> Icon -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Icon -> Icon -> Bool
$c/= :: Icon -> Icon -> Bool
== :: Icon -> Icon -> Bool
$c== :: Icon -> Icon -> Bool
Eq)
instance SP.ManagedPtrNewtype Icon where
toManagedPtr :: Icon -> ManagedPtr Icon
toManagedPtr (Icon ManagedPtr Icon
p) = ManagedPtr Icon
p
foreign import ccall "g_icon_get_type"
c_g_icon_get_type :: IO B.Types.GType
instance B.Types.TypedObject Icon where
glibType :: IO GType
glibType = IO GType
c_g_icon_get_type
instance B.Types.GObject Icon
class (SP.GObject o, O.IsDescendantOf Icon o) => IsIcon o
instance (SP.GObject o, O.IsDescendantOf Icon o) => IsIcon o
instance O.HasParentTypes Icon
type instance O.ParentTypes Icon = '[GObject.Object.Object]
toIcon :: (MIO.MonadIO m, IsIcon o) => o -> m Icon
toIcon :: forall (m :: * -> *) o. (MonadIO m, IsIcon o) => o -> m Icon
toIcon = forall (m :: * -> *) a. MonadIO m => IO a -> m a
MIO.liftIO forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall o o'.
(HasCallStack, ManagedPtrNewtype o, TypedObject o,
ManagedPtrNewtype o', TypedObject o') =>
(ManagedPtr o' -> o') -> o -> IO o'
B.ManagedPtr.unsafeCastTo ManagedPtr Icon -> Icon
Icon
instance B.GValue.IsGValue (Maybe Icon) where
gvalueGType_ :: IO GType
gvalueGType_ = IO GType
c_g_icon_get_type
gvalueSet_ :: Ptr GValue -> Maybe Icon -> IO ()
gvalueSet_ Ptr GValue
gv Maybe Icon
P.Nothing = forall a. GObject a => Ptr GValue -> Ptr a -> IO ()
B.GValue.set_object Ptr GValue
gv (forall a. Ptr a
FP.nullPtr :: FP.Ptr Icon)
gvalueSet_ Ptr GValue
gv (P.Just Icon
obj) = forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
B.ManagedPtr.withManagedPtr Icon
obj (forall a. GObject a => Ptr GValue -> Ptr a -> IO ()
B.GValue.set_object Ptr GValue
gv)
gvalueGet_ :: Ptr GValue -> IO (Maybe Icon)
gvalueGet_ Ptr GValue
gv = do
Ptr Icon
ptr <- forall a. GObject a => Ptr GValue -> IO (Ptr a)
B.GValue.get_object Ptr GValue
gv :: IO (FP.Ptr Icon)
if Ptr Icon
ptr forall a. Eq a => a -> a -> Bool
/= forall a. Ptr a
FP.nullPtr
then forall a. a -> Maybe a
P.Just forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
B.ManagedPtr.newObject ManagedPtr Icon -> Icon
Icon Ptr Icon
ptr
else forall (m :: * -> *) a. Monad m => a -> m a
return forall a. Maybe a
P.Nothing
#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList Icon
type instance O.AttributeList Icon = IconAttributeList
type IconAttributeList = ('[ ] :: [(Symbol, *)])
#endif
#if defined(ENABLE_OVERLOADING)
#endif
#if defined(ENABLE_OVERLOADING)
type family ResolveIconMethod (t :: Symbol) (o :: *) :: * where
ResolveIconMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
ResolveIconMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
ResolveIconMethod "equal" o = IconEqualMethodInfo
ResolveIconMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
ResolveIconMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
ResolveIconMethod "getv" o = GObject.Object.ObjectGetvMethodInfo
ResolveIconMethod "hash" o = IconHashMethodInfo
ResolveIconMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
ResolveIconMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
ResolveIconMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
ResolveIconMethod "ref" o = GObject.Object.ObjectRefMethodInfo
ResolveIconMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
ResolveIconMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
ResolveIconMethod "serialize" o = IconSerializeMethodInfo
ResolveIconMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
ResolveIconMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
ResolveIconMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
ResolveIconMethod "toString" o = IconToStringMethodInfo
ResolveIconMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
ResolveIconMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
ResolveIconMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
ResolveIconMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
ResolveIconMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
ResolveIconMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
ResolveIconMethod "setDataFull" o = GObject.Object.ObjectSetDataFullMethodInfo
ResolveIconMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
ResolveIconMethod l o = O.MethodResolutionFailed l o
instance (info ~ ResolveIconMethod t Icon, O.OverloadedMethod info Icon p) => OL.IsLabel t (Icon -> 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 ~ ResolveIconMethod t Icon, O.OverloadedMethod info Icon p, R.HasField t Icon p) => R.HasField t Icon p where
getField = O.overloadedMethod @info
#endif
instance (info ~ ResolveIconMethod t Icon, O.OverloadedMethodInfo info Icon) => OL.IsLabel t (O.MethodProxy info Icon) where
#if MIN_VERSION_base(4,10,0)
fromLabel = O.MethodProxy
#else
fromLabel _ = O.MethodProxy
#endif
#endif
foreign import ccall "g_icon_equal" g_icon_equal ::
Ptr Icon ->
Ptr Icon ->
IO CInt
iconEqual ::
(B.CallStack.HasCallStack, MonadIO m, IsIcon a, IsIcon b) =>
a
-> Maybe (b)
-> m Bool
iconEqual :: forall (m :: * -> *) a b.
(HasCallStack, MonadIO m, IsIcon a, IsIcon b) =>
a -> Maybe b -> m Bool
iconEqual a
icon1 Maybe b
icon2 = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ do
Ptr Icon
icon1' <- forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
icon1
Ptr Icon
maybeIcon2 <- case Maybe b
icon2 of
Maybe b
Nothing -> forall (m :: * -> *) a. Monad m => a -> m a
return forall a. Ptr a
nullPtr
Just b
jIcon2 -> do
Ptr Icon
jIcon2' <- forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
jIcon2
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Icon
jIcon2'
CInt
result <- Ptr Icon -> Ptr Icon -> IO CInt
g_icon_equal Ptr Icon
icon1' Ptr Icon
maybeIcon2
let result' :: Bool
result' = (forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
icon1
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe b
icon2 forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'
#if defined(ENABLE_OVERLOADING)
data IconEqualMethodInfo
instance (signature ~ (Maybe (b) -> m Bool), MonadIO m, IsIcon a, IsIcon b) => O.OverloadedMethod IconEqualMethodInfo a signature where
overloadedMethod = iconEqual
instance O.OverloadedMethodInfo IconEqualMethodInfo a where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.Gio.Interfaces.Icon.iconEqual",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-gio-2.0.30/docs/GI-Gio-Interfaces-Icon.html#v:iconEqual"
})
#endif
foreign import ccall "g_icon_hash" g_icon_hash ::
Ptr Icon ->
IO Word32
iconHash ::
(B.CallStack.HasCallStack, MonadIO m, IsIcon a) =>
a
-> m Word32
iconHash :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsIcon a) =>
a -> m Word32
iconHash a
icon = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ do
Ptr Icon
icon' <- forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
icon
Word32
result <- Ptr Icon -> IO Word32
g_icon_hash Ptr Icon
icon'
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
icon
forall (m :: * -> *) a. Monad m => a -> m a
return Word32
result
#if defined(ENABLE_OVERLOADING)
data IconHashMethodInfo
instance (signature ~ (m Word32), MonadIO m, IsIcon a) => O.OverloadedMethod IconHashMethodInfo a signature where
overloadedMethod = iconHash
instance O.OverloadedMethodInfo IconHashMethodInfo a where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.Gio.Interfaces.Icon.iconHash",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-gio-2.0.30/docs/GI-Gio-Interfaces-Icon.html#v:iconHash"
})
#endif
foreign import ccall "g_icon_serialize" g_icon_serialize ::
Ptr Icon ->
IO (Ptr GVariant)
iconSerialize ::
(B.CallStack.HasCallStack, MonadIO m, IsIcon a) =>
a
-> m (Maybe GVariant)
iconSerialize :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsIcon a) =>
a -> m (Maybe GVariant)
iconSerialize a
icon = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ do
Ptr Icon
icon' <- forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
icon
Ptr GVariant
result <- Ptr Icon -> IO (Ptr GVariant)
g_icon_serialize Ptr Icon
icon'
Maybe GVariant
maybeResult <- forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull Ptr GVariant
result forall a b. (a -> b) -> a -> b
$ \Ptr GVariant
result' -> do
GVariant
result'' <- Ptr GVariant -> IO GVariant
B.GVariant.wrapGVariantPtr Ptr GVariant
result'
forall (m :: * -> *) a. Monad m => a -> m a
return GVariant
result''
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
icon
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe GVariant
maybeResult
#if defined(ENABLE_OVERLOADING)
data IconSerializeMethodInfo
instance (signature ~ (m (Maybe GVariant)), MonadIO m, IsIcon a) => O.OverloadedMethod IconSerializeMethodInfo a signature where
overloadedMethod = iconSerialize
instance O.OverloadedMethodInfo IconSerializeMethodInfo a where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.Gio.Interfaces.Icon.iconSerialize",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-gio-2.0.30/docs/GI-Gio-Interfaces-Icon.html#v:iconSerialize"
})
#endif
foreign import ccall "g_icon_to_string" g_icon_to_string ::
Ptr Icon ->
IO CString
iconToString ::
(B.CallStack.HasCallStack, MonadIO m, IsIcon a) =>
a
-> m (Maybe T.Text)
iconToString :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsIcon a) =>
a -> m (Maybe Text)
iconToString a
icon = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ do
Ptr Icon
icon' <- forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
icon
CString
result <- Ptr Icon -> IO CString
g_icon_to_string Ptr Icon
icon'
Maybe Text
maybeResult <- forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull CString
result forall a b. (a -> b) -> a -> b
$ \CString
result' -> do
Text
result'' <- HasCallStack => CString -> IO Text
cstringToText CString
result'
forall a. Ptr a -> IO ()
freeMem CString
result'
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result''
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
icon
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe Text
maybeResult
#if defined(ENABLE_OVERLOADING)
data IconToStringMethodInfo
instance (signature ~ (m (Maybe T.Text)), MonadIO m, IsIcon a) => O.OverloadedMethod IconToStringMethodInfo a signature where
overloadedMethod = iconToString
instance O.OverloadedMethodInfo IconToStringMethodInfo a where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.Gio.Interfaces.Icon.iconToString",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-gio-2.0.30/docs/GI-Gio-Interfaces-Icon.html#v:iconToString"
})
#endif
foreign import ccall "g_icon_deserialize" g_icon_deserialize ::
Ptr GVariant ->
IO (Ptr Icon)
iconDeserialize ::
(B.CallStack.HasCallStack, MonadIO m) =>
GVariant
-> m (Maybe Icon)
iconDeserialize :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
GVariant -> m (Maybe Icon)
iconDeserialize GVariant
value = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ do
Ptr GVariant
value' <- forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr GVariant
value
Ptr Icon
result <- Ptr GVariant -> IO (Ptr Icon)
g_icon_deserialize Ptr GVariant
value'
Maybe Icon
maybeResult <- forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull Ptr Icon
result forall a b. (a -> b) -> a -> b
$ \Ptr Icon
result' -> do
Icon
result'' <- (forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
wrapObject ManagedPtr Icon -> Icon
Icon) Ptr Icon
result'
forall (m :: * -> *) a. Monad m => a -> m a
return Icon
result''
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr GVariant
value
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe Icon
maybeResult
#if defined(ENABLE_OVERLOADING)
#endif
foreign import ccall "g_icon_new_for_string" g_icon_new_for_string ::
CString ->
Ptr (Ptr GError) ->
IO (Ptr Icon)
iconNewForString ::
(B.CallStack.HasCallStack, MonadIO m) =>
T.Text
-> m Icon
iconNewForString :: forall (m :: * -> *). (HasCallStack, MonadIO m) => Text -> m Icon
iconNewForString Text
str = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ do
CString
str' <- Text -> IO CString
textToCString Text
str
forall a b. IO a -> IO b -> IO a
onException (do
Ptr Icon
result <- forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError forall a b. (a -> b) -> a -> b
$ CString -> Ptr (Ptr GError) -> IO (Ptr Icon)
g_icon_new_for_string CString
str'
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"iconNewForString" Ptr Icon
result
Icon
result' <- (forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
wrapObject ManagedPtr Icon -> Icon
Icon) Ptr Icon
result
forall a. Ptr a -> IO ()
freeMem CString
str'
forall (m :: * -> *) a. Monad m => a -> m a
return Icon
result'
) (do
forall a. Ptr a -> IO ()
freeMem CString
str'
)
#if defined(ENABLE_OVERLOADING)
#endif
#if defined(ENABLE_OVERLOADING)
type instance O.SignalList Icon = IconSignalList
type IconSignalList = ('[ '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, *)])
#endif