{-# LINE 1 "Data/GI/Base/GParamSpec.hsc" #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
module Data.GI.Base.GParamSpec
(
wrapGParamSpecPtr
, newGParamSpecFromPtr
, unrefGParamSpec
, disownGParamSpec
, PropertyInfo(..)
, gParamSpecValue
, CStringPropertyInfo(..)
, gParamSpecCString
, CIntPropertyInfo(..)
, gParamSpecCInt
, PropGetSetter(..)
, getGParamSpecGetterSetter
) where
import Foreign.C (CInt(..), CString)
import Foreign.Ptr (Ptr, FunPtr, castPtr, nullPtr)
import Foreign.StablePtr (newStablePtr, deRefStablePtr,
castStablePtrToPtr, castPtrToStablePtr)
import Control.Monad (void)
import Data.Coerce (coerce)
import Data.Maybe (fromMaybe)
import Data.Text (Text)
import Data.GI.Base.ManagedPtr (newManagedPtr', withManagedPtr,
disownManagedPtr,
newObject, withTransient)
import Data.GI.Base.BasicConversions (gflagsToWord, withTextCString)
import Data.GI.Base.BasicTypes (GObject(..), GParamSpec(..),
GType(..), IsGFlag, ManagedPtr)
import Data.GI.Base.GQuark (GQuark(..), gQuarkFromString)
import Data.GI.Base.GType (gtypeStablePtr)
import qualified Data.GI.Base.GValue as GV
import Data.GI.Base.GValue (GValue(..), IsGValue(..), take_stablePtr)
foreign import ccall "g_param_spec_ref_sink" g_param_spec_ref_sink ::
Ptr GParamSpec -> IO (Ptr GParamSpec)
foreign import ccall "g_param_spec_ref" g_param_spec_ref ::
Ptr GParamSpec -> IO (Ptr GParamSpec)
foreign import ccall "g_param_spec_unref" g_param_spec_unref ::
Ptr GParamSpec -> IO ()
foreign import ccall "&g_param_spec_unref" ptr_to_g_param_spec_unref ::
FunPtr (Ptr GParamSpec -> IO ())
wrapGParamSpecPtr :: Ptr GParamSpec -> IO GParamSpec
wrapGParamSpecPtr :: Ptr GParamSpec -> IO GParamSpec
wrapGParamSpecPtr ptr :: Ptr GParamSpec
ptr = do
IO (Ptr GParamSpec) -> IO ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (IO (Ptr GParamSpec) -> IO ()) -> IO (Ptr GParamSpec) -> IO ()
forall a b. (a -> b) -> a -> b
$ Ptr GParamSpec -> IO (Ptr GParamSpec)
g_param_spec_ref_sink Ptr GParamSpec
ptr
ManagedPtr GParamSpec
fPtr <- FinalizerPtr GParamSpec
-> Ptr GParamSpec -> IO (ManagedPtr GParamSpec)
forall a.
HasCallStack =>
FinalizerPtr a -> Ptr a -> IO (ManagedPtr a)
newManagedPtr' FinalizerPtr GParamSpec
ptr_to_g_param_spec_unref Ptr GParamSpec
ptr
GParamSpec -> IO GParamSpec
forall (m :: * -> *) a. Monad m => a -> m a
return (GParamSpec -> IO GParamSpec) -> GParamSpec -> IO GParamSpec
forall a b. (a -> b) -> a -> b
$! ManagedPtr GParamSpec -> GParamSpec
GParamSpec ManagedPtr GParamSpec
fPtr
newGParamSpecFromPtr :: Ptr GParamSpec -> IO GParamSpec
newGParamSpecFromPtr :: Ptr GParamSpec -> IO GParamSpec
newGParamSpecFromPtr ptr :: Ptr GParamSpec
ptr = do
ManagedPtr GParamSpec
fPtr <- Ptr GParamSpec -> IO (Ptr GParamSpec)
g_param_spec_ref Ptr GParamSpec
ptr IO (Ptr GParamSpec)
-> (Ptr GParamSpec -> IO (ManagedPtr GParamSpec))
-> IO (ManagedPtr GParamSpec)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= FinalizerPtr GParamSpec
-> Ptr GParamSpec -> IO (ManagedPtr GParamSpec)
forall a.
HasCallStack =>
FinalizerPtr a -> Ptr a -> IO (ManagedPtr a)
newManagedPtr' FinalizerPtr GParamSpec
ptr_to_g_param_spec_unref
GParamSpec -> IO GParamSpec
forall (m :: * -> *) a. Monad m => a -> m a
return (GParamSpec -> IO GParamSpec) -> GParamSpec -> IO GParamSpec
forall a b. (a -> b) -> a -> b
$! ManagedPtr GParamSpec -> GParamSpec
GParamSpec ManagedPtr GParamSpec
fPtr
unrefGParamSpec :: GParamSpec -> IO ()
unrefGParamSpec :: GParamSpec -> IO ()
unrefGParamSpec ps :: GParamSpec
ps = GParamSpec -> (Ptr GParamSpec -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr GParamSpec
ps Ptr GParamSpec -> IO ()
g_param_spec_unref
disownGParamSpec :: GParamSpec -> IO (Ptr GParamSpec)
disownGParamSpec :: GParamSpec -> IO (Ptr GParamSpec)
disownGParamSpec = GParamSpec -> IO (Ptr GParamSpec)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
disownManagedPtr
data GParamFlag = GParamReadable
| GParamWritable
| GParamConstruct
| GParamConstructOnly
| GParamExplicitNotify
| AnotherGParamFlag Int
deriving (Int -> GParamFlag -> ShowS
[GParamFlag] -> ShowS
GParamFlag -> String
(Int -> GParamFlag -> ShowS)
-> (GParamFlag -> String)
-> ([GParamFlag] -> ShowS)
-> Show GParamFlag
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GParamFlag] -> ShowS
$cshowList :: [GParamFlag] -> ShowS
show :: GParamFlag -> String
$cshow :: GParamFlag -> String
showsPrec :: Int -> GParamFlag -> ShowS
$cshowsPrec :: Int -> GParamFlag -> ShowS
Show, GParamFlag -> GParamFlag -> Bool
(GParamFlag -> GParamFlag -> Bool)
-> (GParamFlag -> GParamFlag -> Bool) -> Eq GParamFlag
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GParamFlag -> GParamFlag -> Bool
$c/= :: GParamFlag -> GParamFlag -> Bool
== :: GParamFlag -> GParamFlag -> Bool
$c== :: GParamFlag -> GParamFlag -> Bool
Eq)
instance Enum GParamFlag where
fromEnum :: GParamFlag -> Int
fromEnum GParamReadable = 1
{-# LINE 105 "Data/GI/Base/GParamSpec.hsc" #-}
fromEnum GParamWritable = 2
{-# LINE 106 "Data/GI/Base/GParamSpec.hsc" #-}
fromEnum GParamConstruct = 4
{-# LINE 107 "Data/GI/Base/GParamSpec.hsc" #-}
fromEnum GParamConstructOnly = 8
{-# LINE 108 "Data/GI/Base/GParamSpec.hsc" #-}
fromEnum GParamExplicitNotify = 1073741824
{-# LINE 109 "Data/GI/Base/GParamSpec.hsc" #-}
fromEnum (AnotherGParamFlag k) = k
toEnum :: Int -> GParamFlag
toEnum (Int
1) = GParamFlag
GParamReadable
{-# LINE 112 "Data/GI/Base/GParamSpec.hsc" #-}
toEnum (2) = GParamWritable
{-# LINE 113 "Data/GI/Base/GParamSpec.hsc" #-}
toEnum (4) = GParamConstruct
{-# LINE 114 "Data/GI/Base/GParamSpec.hsc" #-}
toEnum (8) = GParamConstructOnly
{-# LINE 115 "Data/GI/Base/GParamSpec.hsc" #-}
toEnum (1073741824) = GParamExplicitNotify
{-# LINE 116 "Data/GI/Base/GParamSpec.hsc" #-}
toEnum k = AnotherGParamFlag k
instance Ord GParamFlag where
compare :: GParamFlag -> GParamFlag -> Ordering
compare a :: GParamFlag
a b :: GParamFlag
b = Int -> Int -> Ordering
forall a. Ord a => a -> a -> Ordering
compare (GParamFlag -> Int
forall a. Enum a => a -> Int
fromEnum GParamFlag
a) (GParamFlag -> Int
forall a. Enum a => a -> Int
fromEnum GParamFlag
b)
instance IsGFlag GParamFlag
defaultFlags :: Num a => a
defaultFlags :: a
defaultFlags = [GParamFlag] -> a
forall b a. (Num b, IsGFlag a) => [a] -> b
gflagsToWord [GParamFlag
GParamReadable, GParamFlag
GParamWritable,
GParamFlag
GParamExplicitNotify]
data PropGetSetter o = PropGetSetter
{ PropGetSetter o -> Ptr o -> Ptr GValue -> IO ()
propGetter :: Ptr o -> Ptr GValue -> IO ()
, PropGetSetter o -> Ptr o -> Ptr GValue -> IO ()
propSetter :: Ptr o -> Ptr GValue -> IO ()
}
pspecQuark :: IO (GQuark (PropGetSetter o))
pspecQuark :: IO (GQuark (PropGetSetter o))
pspecQuark = Text -> IO (GQuark (PropGetSetter o))
forall a. Text -> IO (GQuark a)
gQuarkFromString "haskell-gi-get-set"
newtype GObjectConstructor = GObjectConstructor (ManagedPtr GObjectConstructor)
objectFromPtr :: forall a o. GObject o => Ptr a -> IO o
objectFromPtr :: Ptr a -> IO o
objectFromPtr objPtr :: Ptr a
objPtr = (ManagedPtr o -> o) -> Ptr o -> IO o
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
newObject @o @o ((ManagedPtr GObjectConstructor -> GObjectConstructor)
-> ManagedPtr o -> o
forall a b. Coercible a b => a -> b
coerce @_ @(ManagedPtr o -> o) ManagedPtr GObjectConstructor -> GObjectConstructor
GObjectConstructor) (Ptr a -> Ptr o
forall a b. Ptr a -> Ptr b
castPtr Ptr a
objPtr)
wrapGetSet :: forall o a. (GObject o, IsGValue a) =>
(o -> IO a)
-> (o -> a -> IO ())
-> (GValue -> a -> IO ())
-> PropGetSetter o
wrapGetSet :: (o -> IO a)
-> (o -> a -> IO ()) -> (GValue -> a -> IO ()) -> PropGetSetter o
wrapGetSet getter :: o -> IO a
getter setter :: o -> a -> IO ()
setter gvalueSetter :: GValue -> a -> IO ()
gvalueSetter = PropGetSetter :: forall o.
(Ptr o -> Ptr GValue -> IO ())
-> (Ptr o -> Ptr GValue -> IO ()) -> PropGetSetter o
PropGetSetter {
$sel:propGetter:PropGetSetter :: Ptr o -> Ptr GValue -> IO ()
propGetter = \objPtr :: Ptr o
objPtr destPtr :: Ptr GValue
destPtr -> do
a
value <- Ptr o -> IO o
forall a o. GObject o => Ptr a -> IO o
objectFromPtr Ptr o
objPtr IO o -> (o -> IO a) -> IO a
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= o -> IO a
getter
(ManagedPtr GValue -> GValue)
-> Ptr GValue -> (GValue -> IO ()) -> IO ()
forall a b.
(HasCallStack, ManagedPtrNewtype a) =>
(ManagedPtr a -> a) -> Ptr a -> (a -> IO b) -> IO b
withTransient ManagedPtr GValue -> GValue
GValue Ptr GValue
destPtr ((GValue -> IO ()) -> IO ()) -> (GValue -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \dest :: GValue
dest -> GValue -> a -> IO ()
gvalueSetter GValue
dest a
value
, $sel:propSetter:PropGetSetter :: Ptr o -> Ptr GValue -> IO ()
propSetter = \objPtr :: Ptr o
objPtr newGValuePtr :: Ptr GValue
newGValuePtr ->
(ManagedPtr GValue -> GValue)
-> Ptr GValue -> (GValue -> IO ()) -> IO ()
forall a b.
(HasCallStack, ManagedPtrNewtype a) =>
(ManagedPtr a -> a) -> Ptr a -> (a -> IO b) -> IO b
withTransient ManagedPtr GValue -> GValue
GValue Ptr GValue
newGValuePtr ((GValue -> IO ()) -> IO ()) -> (GValue -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \newGValue :: GValue
newGValue -> do
o
obj <- Ptr o -> IO o
forall a o. GObject o => Ptr a -> IO o
objectFromPtr Ptr o
objPtr
a
value <- GValue -> IO a
forall a. IsGValue a => GValue -> IO a
fromGValue GValue
newGValue
o -> a -> IO ()
setter o
obj a
value
}
data PropertyInfo o a = PropertyInfo
{ PropertyInfo o a -> Text
name :: Text
, PropertyInfo o a -> Text
nick :: Text
, PropertyInfo o a -> Text
blurb :: Text
, PropertyInfo o a -> o -> a -> IO ()
setter :: o -> a -> IO ()
, PropertyInfo o a -> o -> IO a
getter :: o -> IO a
, PropertyInfo o a -> Maybe [GParamFlag]
flags :: Maybe [GParamFlag]
}
foreign import ccall g_param_spec_boxed ::
CString -> CString -> CString -> GType -> CInt -> IO (Ptr GParamSpec)
gParamSpecValue :: forall o a. GObject o => PropertyInfo o a -> IO GParamSpec
gParamSpecValue :: PropertyInfo o a -> IO GParamSpec
gParamSpecValue (PropertyInfo {..}) =
Text -> (CString -> IO GParamSpec) -> IO GParamSpec
forall a. Text -> (CString -> IO a) -> IO a
withTextCString Text
name ((CString -> IO GParamSpec) -> IO GParamSpec)
-> (CString -> IO GParamSpec) -> IO GParamSpec
forall a b. (a -> b) -> a -> b
$ \cname :: CString
cname ->
Text -> (CString -> IO GParamSpec) -> IO GParamSpec
forall a. Text -> (CString -> IO a) -> IO a
withTextCString Text
nick ((CString -> IO GParamSpec) -> IO GParamSpec)
-> (CString -> IO GParamSpec) -> IO GParamSpec
forall a b. (a -> b) -> a -> b
$ \cnick :: CString
cnick ->
Text -> (CString -> IO GParamSpec) -> IO GParamSpec
forall a. Text -> (CString -> IO a) -> IO a
withTextCString Text
blurb ((CString -> IO GParamSpec) -> IO GParamSpec)
-> (CString -> IO GParamSpec) -> IO GParamSpec
forall a b. (a -> b) -> a -> b
$ \cblurb :: CString
cblurb -> do
Ptr GParamSpec
pspecPtr <- CString
-> CString -> CString -> GType -> CInt -> IO (Ptr GParamSpec)
g_param_spec_boxed CString
cname CString
cnick CString
cblurb
GType
gtypeStablePtr
(CInt -> ([GParamFlag] -> CInt) -> Maybe [GParamFlag] -> CInt
forall b a. b -> (a -> b) -> Maybe a -> b
maybe CInt
forall a. Num a => a
defaultFlags [GParamFlag] -> CInt
forall b a. (Num b, IsGFlag a) => [a] -> b
gflagsToWord Maybe [GParamFlag]
flags)
GQuark (PropGetSetter o)
quark <- IO (GQuark (PropGetSetter o))
forall o. IO (GQuark (PropGetSetter o))
pspecQuark @o
Ptr GParamSpec
-> GQuark (PropGetSetter o) -> PropGetSetter o -> IO ()
forall a. Ptr GParamSpec -> GQuark a -> a -> IO ()
gParamSpecSetQData Ptr GParamSpec
pspecPtr GQuark (PropGetSetter o)
quark
(PropGetSetter :: forall o.
(Ptr o -> Ptr GValue -> IO ())
-> (Ptr o -> Ptr GValue -> IO ()) -> PropGetSetter o
PropGetSetter { $sel:propGetter:PropGetSetter :: Ptr o -> Ptr GValue -> IO ()
propGetter = Ptr o -> Ptr GValue -> IO ()
getter', $sel:propSetter:PropGetSetter :: Ptr o -> Ptr GValue -> IO ()
propSetter = Ptr o -> Ptr GValue -> IO ()
setter'})
Ptr GParamSpec -> IO GParamSpec
wrapGParamSpecPtr Ptr GParamSpec
pspecPtr
where
getter' :: Ptr o -> Ptr GValue -> IO ()
getter' :: Ptr o -> Ptr GValue -> IO ()
getter' objPtr :: Ptr o
objPtr destPtr :: Ptr GValue
destPtr = do
StablePtr a
stablePtr <- Ptr o -> IO o
forall a o. GObject o => Ptr a -> IO o
objectFromPtr Ptr o
objPtr IO o -> (o -> IO a) -> IO a
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= o -> IO a
getter IO a -> (a -> IO (StablePtr a)) -> IO (StablePtr a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= a -> IO (StablePtr a)
forall a. a -> IO (StablePtr a)
newStablePtr
Ptr GValue -> StablePtr a -> IO ()
forall a. Ptr GValue -> StablePtr a -> IO ()
take_stablePtr Ptr GValue
destPtr StablePtr a
stablePtr
setter' :: Ptr o -> (Ptr GValue) -> IO ()
setter' :: Ptr o -> Ptr GValue -> IO ()
setter' objPtr :: Ptr o
objPtr gvPtr :: Ptr GValue
gvPtr = (ManagedPtr GValue -> GValue)
-> Ptr GValue -> (GValue -> IO ()) -> IO ()
forall a b.
(HasCallStack, ManagedPtrNewtype a) =>
(ManagedPtr a -> a) -> Ptr a -> (a -> IO b) -> IO b
withTransient ManagedPtr GValue -> GValue
GValue Ptr GValue
gvPtr ((GValue -> IO ()) -> IO ()) -> (GValue -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \gv :: GValue
gv -> do
o
obj <- Ptr o -> IO o
forall a o. GObject o => Ptr a -> IO o
objectFromPtr Ptr o
objPtr
a
val <- GValue -> IO (StablePtr a)
forall a. IsGValue a => GValue -> IO a
fromGValue GValue
gv IO (StablePtr a) -> (StablePtr a -> IO a) -> IO a
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= StablePtr a -> IO a
forall a. StablePtr a -> IO a
deRefStablePtr
o -> a -> IO ()
setter o
obj a
val
data CIntPropertyInfo o = CIntPropertyInfo
{ CIntPropertyInfo o -> Text
name :: Text
, CIntPropertyInfo o -> Text
nick :: Text
, CIntPropertyInfo o -> Text
blurb :: Text
, CIntPropertyInfo o -> CInt
defaultValue :: CInt
, CIntPropertyInfo o -> o -> CInt -> IO ()
setter :: o -> CInt -> IO ()
, CIntPropertyInfo o -> o -> IO CInt
getter :: o -> IO CInt
, CIntPropertyInfo o -> Maybe [GParamFlag]
flags :: Maybe [GParamFlag]
, CIntPropertyInfo o -> Maybe CInt
minValue :: Maybe CInt
, CIntPropertyInfo o -> Maybe CInt
maxValue :: Maybe CInt
}
foreign import ccall g_param_spec_int ::
CString -> CString -> CString -> CInt -> CInt -> CInt -> CInt
-> IO (Ptr GParamSpec)
gParamSpecCInt :: GObject o => CIntPropertyInfo o -> IO GParamSpec
gParamSpecCInt :: CIntPropertyInfo o -> IO GParamSpec
gParamSpecCInt (CIntPropertyInfo {..}) =
Text -> (CString -> IO GParamSpec) -> IO GParamSpec
forall a. Text -> (CString -> IO a) -> IO a
withTextCString Text
name ((CString -> IO GParamSpec) -> IO GParamSpec)
-> (CString -> IO GParamSpec) -> IO GParamSpec
forall a b. (a -> b) -> a -> b
$ \cname :: CString
cname ->
Text -> (CString -> IO GParamSpec) -> IO GParamSpec
forall a. Text -> (CString -> IO a) -> IO a
withTextCString Text
nick ((CString -> IO GParamSpec) -> IO GParamSpec)
-> (CString -> IO GParamSpec) -> IO GParamSpec
forall a b. (a -> b) -> a -> b
$ \cnick :: CString
cnick ->
Text -> (CString -> IO GParamSpec) -> IO GParamSpec
forall a. Text -> (CString -> IO a) -> IO a
withTextCString Text
blurb ((CString -> IO GParamSpec) -> IO GParamSpec)
-> (CString -> IO GParamSpec) -> IO GParamSpec
forall a b. (a -> b) -> a -> b
$ \cblurb :: CString
cblurb -> do
Ptr GParamSpec
pspecPtr <- CString
-> CString
-> CString
-> CInt
-> CInt
-> CInt
-> CInt
-> IO (Ptr GParamSpec)
g_param_spec_int CString
cname CString
cnick CString
cblurb
(CInt -> Maybe CInt -> CInt
forall a. a -> Maybe a -> a
fromMaybe CInt
forall a. Bounded a => a
minBound Maybe CInt
minValue)
(CInt -> Maybe CInt -> CInt
forall a. a -> Maybe a -> a
fromMaybe CInt
forall a. Bounded a => a
maxBound Maybe CInt
maxValue)
CInt
defaultValue
(CInt -> ([GParamFlag] -> CInt) -> Maybe [GParamFlag] -> CInt
forall b a. b -> (a -> b) -> Maybe a -> b
maybe CInt
forall a. Num a => a
defaultFlags [GParamFlag] -> CInt
forall b a. (Num b, IsGFlag a) => [a] -> b
gflagsToWord Maybe [GParamFlag]
flags)
GQuark (PropGetSetter o)
quark <- IO (GQuark (PropGetSetter o))
forall o. IO (GQuark (PropGetSetter o))
pspecQuark
Ptr GParamSpec
-> GQuark (PropGetSetter o) -> PropGetSetter o -> IO ()
forall a. Ptr GParamSpec -> GQuark a -> a -> IO ()
gParamSpecSetQData Ptr GParamSpec
pspecPtr GQuark (PropGetSetter o)
quark ((o -> IO CInt)
-> (o -> CInt -> IO ())
-> (GValue -> CInt -> IO ())
-> PropGetSetter o
forall o a.
(GObject o, IsGValue a) =>
(o -> IO a)
-> (o -> a -> IO ()) -> (GValue -> a -> IO ()) -> PropGetSetter o
wrapGetSet o -> IO CInt
getter o -> CInt -> IO ()
setter GValue -> CInt -> IO ()
GV.set_int)
Ptr GParamSpec -> IO GParamSpec
wrapGParamSpecPtr Ptr GParamSpec
pspecPtr
data CStringPropertyInfo o = CStringPropertyInfo
{ CStringPropertyInfo o -> Text
name :: Text
, CStringPropertyInfo o -> Text
nick :: Text
, CStringPropertyInfo o -> Text
blurb :: Text
, CStringPropertyInfo o -> Maybe Text
defaultValue :: Maybe Text
, CStringPropertyInfo o -> Maybe [GParamFlag]
flags :: Maybe [GParamFlag]
, CStringPropertyInfo o -> o -> Maybe Text -> IO ()
setter :: o -> Maybe Text -> IO ()
, CStringPropertyInfo o -> o -> IO (Maybe Text)
getter :: o -> IO (Maybe Text)
}
foreign import ccall g_param_spec_string ::
CString -> CString -> CString -> CString -> CInt -> IO (Ptr GParamSpec)
gParamSpecCString :: GObject o => CStringPropertyInfo o -> IO GParamSpec
gParamSpecCString :: CStringPropertyInfo o -> IO GParamSpec
gParamSpecCString (CStringPropertyInfo {..}) =
Text -> (CString -> IO GParamSpec) -> IO GParamSpec
forall a. Text -> (CString -> IO a) -> IO a
withTextCString Text
name ((CString -> IO GParamSpec) -> IO GParamSpec)
-> (CString -> IO GParamSpec) -> IO GParamSpec
forall a b. (a -> b) -> a -> b
$ \cname :: CString
cname ->
Text -> (CString -> IO GParamSpec) -> IO GParamSpec
forall a. Text -> (CString -> IO a) -> IO a
withTextCString Text
nick ((CString -> IO GParamSpec) -> IO GParamSpec)
-> (CString -> IO GParamSpec) -> IO GParamSpec
forall a b. (a -> b) -> a -> b
$ \cnick :: CString
cnick ->
Text -> (CString -> IO GParamSpec) -> IO GParamSpec
forall a. Text -> (CString -> IO a) -> IO a
withTextCString Text
blurb ((CString -> IO GParamSpec) -> IO GParamSpec)
-> (CString -> IO GParamSpec) -> IO GParamSpec
forall a b. (a -> b) -> a -> b
$ \cblurb :: CString
cblurb -> do
Ptr GParamSpec
pspecPtr <- case Maybe Text
defaultValue of
Nothing -> CString
-> CString -> CString -> CString -> CInt -> IO (Ptr GParamSpec)
g_param_spec_string CString
cname CString
cnick CString
cblurb CString
forall a. Ptr a
nullPtr
(CInt -> ([GParamFlag] -> CInt) -> Maybe [GParamFlag] -> CInt
forall b a. b -> (a -> b) -> Maybe a -> b
maybe CInt
forall a. Num a => a
defaultFlags [GParamFlag] -> CInt
forall b a. (Num b, IsGFlag a) => [a] -> b
gflagsToWord Maybe [GParamFlag]
flags)
Just value :: Text
value ->
Text -> (CString -> IO (Ptr GParamSpec)) -> IO (Ptr GParamSpec)
forall a. Text -> (CString -> IO a) -> IO a
withTextCString Text
value ((CString -> IO (Ptr GParamSpec)) -> IO (Ptr GParamSpec))
-> (CString -> IO (Ptr GParamSpec)) -> IO (Ptr GParamSpec)
forall a b. (a -> b) -> a -> b
$ \cdefault :: CString
cdefault ->
CString
-> CString -> CString -> CString -> CInt -> IO (Ptr GParamSpec)
g_param_spec_string CString
cname CString
cnick CString
cblurb CString
cdefault
(CInt -> ([GParamFlag] -> CInt) -> Maybe [GParamFlag] -> CInt
forall b a. b -> (a -> b) -> Maybe a -> b
maybe CInt
forall a. Num a => a
defaultFlags [GParamFlag] -> CInt
forall b a. (Num b, IsGFlag a) => [a] -> b
gflagsToWord Maybe [GParamFlag]
flags)
GQuark (PropGetSetter o)
quark <- IO (GQuark (PropGetSetter o))
forall o. IO (GQuark (PropGetSetter o))
pspecQuark
Ptr GParamSpec
-> GQuark (PropGetSetter o) -> PropGetSetter o -> IO ()
forall a. Ptr GParamSpec -> GQuark a -> a -> IO ()
gParamSpecSetQData Ptr GParamSpec
pspecPtr GQuark (PropGetSetter o)
quark ((o -> IO (Maybe Text))
-> (o -> Maybe Text -> IO ())
-> (GValue -> Maybe Text -> IO ())
-> PropGetSetter o
forall o a.
(GObject o, IsGValue a) =>
(o -> IO a)
-> (o -> a -> IO ()) -> (GValue -> a -> IO ()) -> PropGetSetter o
wrapGetSet o -> IO (Maybe Text)
getter o -> Maybe Text -> IO ()
setter GValue -> Maybe Text -> IO ()
GV.set_string)
Ptr GParamSpec -> IO GParamSpec
wrapGParamSpecPtr Ptr GParamSpec
pspecPtr
foreign import ccall g_param_spec_set_qdata_full ::
Ptr GParamSpec -> GQuark a -> Ptr b -> FunPtr (Ptr c -> IO ()) -> IO ()
foreign import ccall "&hs_free_stable_ptr" ptr_to_hs_free_stable_ptr ::
FunPtr (Ptr a -> IO ())
gParamSpecSetQData :: Ptr GParamSpec -> GQuark a -> a -> IO ()
gParamSpecSetQData :: Ptr GParamSpec -> GQuark a -> a -> IO ()
gParamSpecSetQData pspecPtr :: Ptr GParamSpec
pspecPtr quark :: GQuark a
quark d :: a
d = do
StablePtr a
ptr <- a -> IO (StablePtr a)
forall a. a -> IO (StablePtr a)
newStablePtr a
d
Ptr GParamSpec
-> GQuark a -> Ptr () -> FunPtr (Ptr Any -> IO ()) -> IO ()
forall a b c.
Ptr GParamSpec
-> GQuark a -> Ptr b -> FunPtr (Ptr c -> IO ()) -> IO ()
g_param_spec_set_qdata_full Ptr GParamSpec
pspecPtr GQuark a
quark
(StablePtr a -> Ptr ()
forall a. StablePtr a -> Ptr ()
castStablePtrToPtr StablePtr a
ptr)
FunPtr (Ptr Any -> IO ())
forall a. FunPtr (Ptr a -> IO ())
ptr_to_hs_free_stable_ptr
foreign import ccall g_param_spec_get_qdata ::
Ptr GParamSpec -> GQuark a -> IO (Ptr b)
gParamSpecGetQData :: Ptr GParamSpec -> GQuark a -> IO (Maybe a)
gParamSpecGetQData :: Ptr GParamSpec -> GQuark a -> IO (Maybe a)
gParamSpecGetQData pspecPtr :: Ptr GParamSpec
pspecPtr quark :: GQuark a
quark = do
Ptr ()
ptr <- Ptr GParamSpec -> GQuark a -> IO (Ptr ())
forall a b. Ptr GParamSpec -> GQuark a -> IO (Ptr b)
g_param_spec_get_qdata Ptr GParamSpec
pspecPtr GQuark a
quark
if Ptr ()
ptr Ptr () -> Ptr () -> Bool
forall a. Eq a => a -> a -> Bool
/= Ptr ()
forall a. Ptr a
nullPtr
then a -> Maybe a
forall a. a -> Maybe a
Just (a -> Maybe a) -> IO a -> IO (Maybe a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> StablePtr a -> IO a
forall a. StablePtr a -> IO a
deRefStablePtr (Ptr () -> StablePtr a
forall a. Ptr () -> StablePtr a
castPtrToStablePtr Ptr ()
ptr)
else Maybe a -> IO (Maybe a)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe a
forall a. Maybe a
Nothing
getGParamSpecGetterSetter :: forall o. Ptr GParamSpec ->
IO (Maybe (PropGetSetter o))
getGParamSpecGetterSetter :: Ptr GParamSpec -> IO (Maybe (PropGetSetter o))
getGParamSpecGetterSetter pspecPtr :: Ptr GParamSpec
pspecPtr = do
GQuark (PropGetSetter o)
quark <- IO (GQuark (PropGetSetter o))
forall o. IO (GQuark (PropGetSetter o))
pspecQuark @o
Ptr GParamSpec
-> GQuark (PropGetSetter o) -> IO (Maybe (PropGetSetter o))
forall a. Ptr GParamSpec -> GQuark a -> IO (Maybe a)
gParamSpecGetQData Ptr GParamSpec
pspecPtr GQuark (PropGetSetter o)
quark