    {-# LINE 1 "Data/GI/Base/GParamSpec.hsc" #-}
    {-# LANGUAGE DuplicateRecordFields #-}
    {-# LANGUAGE RecordWildCards #-}
    {-# LANGUAGE RankNTypes #-}
    {-# LANGUAGE OverloadedStrings #-}
    {-# LANGUAGE ScopedTypeVariables #-}
    {-# LANGUAGE TypeApplications #-}

    -- | Management of `GParamSpec`s.
    module Data.GI.Base.GParamSpec
      ( -- * Memory management
        wrapGParamSpecPtr
      , newGParamSpecFromPtr
      , unrefGParamSpec
      , disownGParamSpec

      -- * GParamSpec building
      , PropertyInfo(..)
      , gParamSpecValue
      , CStringPropertyInfo(..)
      , gParamSpecCString
      , CIntPropertyInfo(..)
      , gParamSpecCInt
      , GBooleanPropertyInfo(..)
      , gParamSpecGBoolean
      , GParamFlag(..)

      -- * Get\/Set
      , 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.Int
    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 ())

    -- | Take ownership of a ParamSpec passed in 'Ptr'.
    wrapGParamSpecPtr :: Ptr GParamSpec -> IO GParamSpec
    wrapGParamSpecPtr :: Ptr GParamSpec -> IO GParamSpec
    wrapGParamSpecPtr 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
      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
      return $! GParamSpec fPtr

    -- | Construct a Haskell wrapper for the given 'GParamSpec', without
    -- assuming ownership.
    newGParamSpecFromPtr :: Ptr GParamSpec -> IO GParamSpec
    newGParamSpecFromPtr :: Ptr GParamSpec -> IO GParamSpec
    newGParamSpecFromPtr Ptr GParamSpec
    ptr = do
      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 a b. IO a -> (a -> IO b) -> IO b
    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
      return $! GParamSpec fPtr

    -- | Remove a reference to the given 'GParamSpec'.
    unrefGParamSpec :: GParamSpec -> IO ()
    unrefGParamSpec :: GParamSpec -> IO ()
    unrefGParamSpec 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

    -- | Disown a `GParamSpec`, i.e. do not longer unref the associated
    -- foreign `GParamSpec` when the Haskell `GParamSpec` gets garbage
    -- collected.
    disownGParamSpec :: GParamSpec -> IO (Ptr GParamSpec)
    disownGParamSpec :: GParamSpec -> IO (Ptr GParamSpec)
    disownGParamSpec = GParamSpec -> IO (Ptr GParamSpec)
    forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
    disownManagedPtr

    {- | Flags controlling the behaviour of the the parameters. -}
    data GParamFlag = GParamReadable
                     {- ^ the parameter is readable -}
                     | GParamWritable
                     {- ^ the parameter is writable -}
                     | GParamConstruct
                     {- ^ the parameter will be set upon object construction -}
                     | GParamConstructOnly
                     {- ^ the parameter can only be set upon object construction -}
                     | GParamExplicitNotify
                     {- ^ calls to 'GI.GObject.Objects.Object.objectSetProperty' for this
    property will not automatically result in a \"notify\" signal being
    emitted: the implementation must call
    'GI.GObject.Objects.Object.objectNotify' themselves in case the
    property actually changes. -}
                     | AnotherGParamFlag Int
                     -- ^ Catch-all for unknown values
                     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
    $cshowsPrec :: Int -> GParamFlag -> ShowS
    showsPrec :: Int -> GParamFlag -> ShowS
    $cshow :: GParamFlag -> String
    show :: GParamFlag -> String
    $cshowList :: [GParamFlag] -> ShowS
    showList :: [GParamFlag] -> ShowS
    Show, GParamFlag -> GParamFlag -> Bool
    (GParamFlag -> GParamFlag -> Bool)
    -> (GParamFlag -> GParamFlag -> Bool) -> Eq GParamFlag
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: GParamFlag -> GParamFlag -> Bool
    == :: GParamFlag -> GParamFlag -> Bool
    $c/= :: GParamFlag -> GParamFlag -> Bool
    /= :: GParamFlag -> GParamFlag -> Bool
    Eq)

    instance Enum GParamFlag where
        fromEnum :: GParamFlag -> Int
    fromEnum GParamFlag
    GParamReadable = Int
    1
    {-# LINE 109 "Data/GI/Base/GParamSpec.hsc" #-}
        fromEnum GParamWritable = 2
    {-# LINE 110 "Data/GI/Base/GParamSpec.hsc" #-}
        fromEnum GParamConstruct = 4
    {-# LINE 111 "Data/GI/Base/GParamSpec.hsc" #-}
        fromEnum GParamConstructOnly = 8
    {-# LINE 112 "Data/GI/Base/GParamSpec.hsc" #-}
        fromEnum GParamExplicitNotify = 1073741824
    {-# LINE 113 "Data/GI/Base/GParamSpec.hsc" #-}
        fromEnum (AnotherGParamFlag k) = k

        toEnum :: Int -> GParamFlag
    toEnum (Int
    1) = GParamFlag
    GParamReadable
    {-# LINE 116 "Data/GI/Base/GParamSpec.hsc" #-}
        toEnum (2) = GParamWritable
    {-# LINE 117 "Data/GI/Base/GParamSpec.hsc" #-}
        toEnum (4) = GParamConstruct
    {-# LINE 118 "Data/GI/Base/GParamSpec.hsc" #-}
        toEnum (8) = GParamConstructOnly
    {-# LINE 119 "Data/GI/Base/GParamSpec.hsc" #-}
        toEnum (1073741824) = GParamExplicitNotify
    {-# LINE 120 "Data/GI/Base/GParamSpec.hsc" #-}
        toEnum k = AnotherGParamFlag k

    instance Ord GParamFlag where
        compare :: GParamFlag -> GParamFlag -> Ordering
    compare GParamFlag
    a 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

    -- | Default set of flags when constructing properties.
    defaultFlags :: Num a => a
    defaultFlags :: forall a. Num a => a
    defaultFlags = [GParamFlag] -> a
    forall b a. (Num b, IsGFlag a) => [a] -> b
    gflagsToWord [GParamFlag
    GParamReadable, GParamFlag
    GParamWritable,
                                 GParamFlag
    GParamExplicitNotify]

    -- | Low-level getter and setter for the property.
    data PropGetSetter o = PropGetSetter
      { forall o. PropGetSetter o -> Ptr o -> Ptr GValue -> IO ()
    propGetter :: Ptr o -> Ptr GValue -> IO ()
      , forall o. PropGetSetter o -> Ptr o -> Ptr GValue -> IO ()
    propSetter :: Ptr o -> Ptr GValue -> IO ()
      }

    -- | The `GQuark` pointing to the setter and getter of the property.
    pspecQuark :: IO (GQuark (PropGetSetter o))
    pspecQuark :: forall o. IO (GQuark (PropGetSetter o))
    pspecQuark = Text -> IO (GQuark (PropGetSetter o))
    forall a. Text -> IO (GQuark a)
    gQuarkFromString Text
    "haskell-gi-get-set"

    -- | The basic constructor for a GObject. They are all isomorphic.
    newtype GObjectConstructor = GObjectConstructor (ManagedPtr GObjectConstructor)

    -- | Construct a copy of the object from the given pointer.
    objectFromPtr :: forall a o. GObject o => Ptr a -> IO o
    objectFromPtr :: forall a o. GObject o => Ptr a -> IO o
    objectFromPtr Ptr a
    objPtr = forall a b.
    (HasCallStack, GObject a, GObject b) =>
    (ManagedPtr a -> a) -> Ptr b -> IO a
    newObject @o @o (forall a b. Coercible a b => a -> b
    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)

    -- | Wrap a Haskell getter/setter into a lower level one.
    wrapGetSet :: forall o a. (GObject o, IsGValue a) =>
                  (o -> IO a)       -- ^ Haskell side getter
               -> (o -> a -> IO ()) -- ^ Haskell side setter
               -> (Ptr GValue -> a -> IO ()) -- ^ Setter for the `GValue`
               -> PropGetSetter o
    wrapGetSet :: forall o a.
    (GObject o, IsGValue a) =>
    (o -> IO a)
    -> (o -> a -> IO ())
    -> (Ptr GValue -> a -> IO ())
    -> PropGetSetter o
    wrapGetSet o -> IO a
    getter o -> a -> IO ()
    setter Ptr GValue -> a -> IO ()
    gvalueSetter = PropGetSetter {
      propGetter :: Ptr o -> Ptr GValue -> IO ()
    propGetter = \Ptr o
    objPtr Ptr GValue
    destPtr -> do
          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 a b. IO a -> (a -> IO b) -> IO b
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= o -> IO a
    getter
          gvalueSetter destPtr value
      , propSetter :: Ptr o -> Ptr GValue -> IO ()
    propSetter = \Ptr o
    objPtr Ptr GValue
    newGValuePtr ->
          Ptr GValue -> (GValue -> IO ()) -> IO ()
    forall a b.
    (HasCallStack, ManagedPtrNewtype a) =>
    Ptr a -> (a -> IO b) -> IO b
    withTransient Ptr GValue
    newGValuePtr ((GValue -> IO ()) -> IO ()) -> (GValue -> IO ()) -> IO ()
    forall a b. (a -> b) -> a -> b
    $ \GValue
    newGValue -> do
            obj <- Ptr o -> IO o
    forall a o. GObject o => Ptr a -> IO o
    objectFromPtr Ptr o
    objPtr
            value <- GV.fromGValue newGValue
            setter obj value
      }

    -- | Information on a property encoding a Haskell value. Note that
    -- from the C side this property will appear as an opaque pointer. Use
    -- the specialized constructors below for creating properties
    -- meaningful from the C side.
    --
    -- A property name consists of segments consisting of ASCII letters
    -- and digits, separated by either the \'-\' or \'_\' character. The
    -- first character of a property name must be a letter. Names which
    -- violate these rules lead to undefined behaviour.
    --
    -- When creating and looking up a property, either separator can be
    -- used, but they cannot be mixed. Using \'-\' is considerably more
    -- efficient and in fact required when using property names as detail
    -- strings for signals.
    --
    -- Beyond the name, properties have two more descriptive strings
    -- associated with them, the @nick@, which should be suitable for use
    -- as a label for the property in a property editor, and the @blurb@,
    -- which should be a somewhat longer description, suitable for e.g. a
    -- tooltip. The @nick@ and @blurb@ should ideally be localized.
    data PropertyInfo o a = PropertyInfo
      { forall o a. PropertyInfo o a -> Text
    name    :: Text              -- ^ Identifier for the property.
      , forall o a. PropertyInfo o a -> Text
    nick    :: Text              -- ^ Identifier for display to the user.
      , forall o a. PropertyInfo o a -> Text
    blurb   :: Text              -- ^ Description of the property.
      , forall o a. PropertyInfo o a -> o -> a -> IO ()
    setter :: o -> a -> IO ()    -- ^ Handler invoked when the
                                     -- property is being set.
      , forall o a. PropertyInfo o a -> o -> IO a
    getter :: o -> IO a          -- ^ Handler that returns the current
                                     -- value of the property.
      , forall o a. PropertyInfo o a -> Maybe [GParamFlag]
    flags   :: Maybe [GParamFlag] -- ^ Set of flags, or `Nothing` for
                                     -- the default set of flags.
      }

    foreign import ccall g_param_spec_boxed ::
      CString -> CString -> CString -> GType -> CInt -> IO (Ptr GParamSpec)

    -- | Create a `GParamSpec` for a Haskell value.
    gParamSpecValue :: forall o a. GObject o => PropertyInfo o a -> IO GParamSpec
    gParamSpecValue :: forall o a. GObject o => PropertyInfo o a -> IO GParamSpec
    gParamSpecValue (PropertyInfo {Maybe [GParamFlag]
    Text
    o -> IO a
    o -> a -> IO ()
    name :: forall o a. PropertyInfo o a -> Text
    nick :: forall o a. PropertyInfo o a -> Text
    blurb :: forall o a. PropertyInfo o a -> Text
    setter :: forall o a. PropertyInfo o a -> o -> a -> IO ()
    getter :: forall o a. PropertyInfo o a -> o -> IO a
    flags :: forall o a. PropertyInfo o a -> Maybe [GParamFlag]
    name :: Text
    nick :: Text
    blurb :: Text
    setter :: o -> a -> IO ()
    getter :: o -> IO a
    flags :: Maybe [GParamFlag]
    ..}) =
      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
    $ \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
    $ \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
    $ \CString
    cblurb -> do
            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)
            quark <- pspecQuark @o
            gParamSpecSetQData pspecPtr quark
              (PropGetSetter { propGetter = getter', propSetter = setter'})
            wrapGParamSpecPtr pspecPtr
      where
        getter' :: Ptr o -> Ptr GValue -> IO ()
        getter' :: Ptr o -> Ptr GValue -> IO ()
    getter' Ptr o
    objPtr Ptr GValue
    destPtr = do
          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 a b. IO a -> (a -> IO b) -> IO b
    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 a b. IO a -> (a -> IO b) -> IO b
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= a -> IO (StablePtr a)
    forall a. a -> IO (StablePtr a)
    newStablePtr
          take_stablePtr destPtr stablePtr

        setter' :: Ptr o -> (Ptr GValue) -> IO ()
        setter' :: Ptr o -> Ptr GValue -> IO ()
    setter' Ptr o
    objPtr Ptr GValue
    gvPtr = Ptr GValue -> (GValue -> IO ()) -> IO ()
    forall a b.
    (HasCallStack, ManagedPtrNewtype a) =>
    Ptr a -> (a -> IO b) -> IO b
    withTransient Ptr GValue
    gvPtr ((GValue -> IO ()) -> IO ()) -> (GValue -> IO ()) -> IO ()
    forall a b. (a -> b) -> a -> b
    $ \GValue
    gv -> do
          obj <- Ptr o -> IO o
    forall a o. GObject o => Ptr a -> IO o
    objectFromPtr Ptr o
    objPtr
          val <- GV.fromGValue gv >>= deRefStablePtr
          setter obj val

    -- | Information on a property of type `CInt` to be registered. A
    -- property name consists of segments consisting of ASCII letters and
    -- digits, separated by either the \'-\' or \'_\' character. The first
    -- character of a property name must be a letter. Names which violate
    -- these rules lead to undefined behaviour.
    --
    -- When creating and looking up a property, either separator can be
    -- used, but they cannot be mixed. Using \'-\' is considerably more
    -- efficient and in fact required when using property names as detail
    -- strings for signals.
    --
    -- Beyond the name, properties have two more descriptive strings
    -- associated with them, the @nick@, which should be suitable for use
    -- as a label for the property in a property editor, and the @blurb@,
    -- which should be a somewhat longer description, suitable for e.g. a
    -- tooltip. The @nick@ and @blurb@ should ideally be localized.
    data CIntPropertyInfo o = CIntPropertyInfo
      { forall o. CIntPropertyInfo o -> Text
    name    :: Text              -- ^ Identifier for the property.
      , forall o. CIntPropertyInfo o -> Text
    nick    :: Text              -- ^ Identifier for display to the user.
      , forall o. CIntPropertyInfo o -> Text
    blurb   :: Text              -- ^ Description of the property.
      , forall o. CIntPropertyInfo o -> CInt
    defaultValue :: CInt         -- ^ Default value.
      , forall o. CIntPropertyInfo o -> o -> CInt -> IO ()
    setter :: o -> CInt -> IO () -- ^ Handler invoked when the
                                     -- property is being set.
      , forall o. CIntPropertyInfo o -> o -> IO CInt
    getter :: o -> IO CInt       -- ^ Handler that returns the current
                                     -- value of the property.
      , forall o. CIntPropertyInfo o -> Maybe [GParamFlag]
    flags   :: Maybe [GParamFlag] -- ^ Set of flags, or `Nothing` for
                                     -- the default set of flags.
      , forall o. CIntPropertyInfo o -> Maybe CInt
    minValue :: Maybe CInt       -- ^ Minimum value, or `Nothing`,
                                     -- which would be replaced by
                                     -- @MININT@.
      , forall o. CIntPropertyInfo o -> Maybe CInt
    maxValue :: Maybe CInt       -- ^ Maximum value, or `Nothing`,
                                     -- which would be replaced by
                                     -- @MAXINT@.
      }

    foreign import ccall g_param_spec_int ::
       CString -> CString -> CString -> CInt -> CInt -> CInt -> CInt
            -> IO (Ptr GParamSpec)

    -- | Create a `GParamSpec` for an integer param.
    gParamSpecCInt :: GObject o => CIntPropertyInfo o -> IO GParamSpec
    gParamSpecCInt :: forall o. GObject o => CIntPropertyInfo o -> IO GParamSpec
    gParamSpecCInt (CIntPropertyInfo {Maybe [GParamFlag]
    Maybe CInt
    CInt
    Text
    o -> IO CInt
    o -> CInt -> IO ()
    name :: forall o. CIntPropertyInfo o -> Text
    nick :: forall o. CIntPropertyInfo o -> Text
    blurb :: forall o. CIntPropertyInfo o -> Text
    defaultValue :: forall o. CIntPropertyInfo o -> CInt
    setter :: forall o. CIntPropertyInfo o -> o -> CInt -> IO ()
    getter :: forall o. CIntPropertyInfo o -> o -> IO CInt
    flags :: forall o. CIntPropertyInfo o -> Maybe [GParamFlag]
    minValue :: forall o. CIntPropertyInfo o -> Maybe CInt
    maxValue :: forall o. CIntPropertyInfo o -> Maybe CInt
    name :: Text
    nick :: Text
    blurb :: Text
    defaultValue :: CInt
    setter :: o -> CInt -> IO ()
    getter :: o -> IO CInt
    flags :: Maybe [GParamFlag]
    minValue :: Maybe CInt
    maxValue :: Maybe CInt
    ..}) =
      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
    $ \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
    $ \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
    $ \CString
    cblurb -> do
            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)
            quark <- pspecQuark
            gParamSpecSetQData pspecPtr quark (wrapGetSet getter setter gvalueSet_)
            wrapGParamSpecPtr pspecPtr

    -- | Information on a property of type `Text` to be registered. A
    -- property name consists of segments consisting of ASCII letters and
    -- digits, separated by either the \'-\' or \'_\' character. The first
    -- character of a property name must be a letter. Names which violate
    -- these rules lead to undefined behaviour.
    --
    -- When creating and looking up a property, either separator can be
    -- used, but they cannot be mixed. Using \'-\' is considerably more
    -- efficient and in fact required when using property names as detail
    -- strings for signals.
    --
    -- Beyond the name, properties have two more descriptive strings
    -- associated with them, the @nick@, which should be suitable for use
    -- as a label for the property in a property editor, and the @blurb@,
    -- which should be a somewhat longer description, suitable for e.g. a
    -- tooltip. The @nick@ and @blurb@ should ideally be localized.
    data CStringPropertyInfo o = CStringPropertyInfo
      { forall o. CStringPropertyInfo o -> Text
    name   :: Text
      , forall o. CStringPropertyInfo o -> Text
    nick   :: Text
      , forall o. CStringPropertyInfo o -> Text
    blurb  :: Text
      , forall o. CStringPropertyInfo o -> Maybe Text
    defaultValue :: Maybe Text
      , forall o. CStringPropertyInfo o -> Maybe [GParamFlag]
    flags  :: Maybe [GParamFlag]
      , forall o. CStringPropertyInfo o -> o -> Maybe Text -> IO ()
    setter :: o -> Maybe Text -> IO ()
      , forall o. 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)

    -- | Create a `GParamSpec` for a string param.
    gParamSpecCString :: GObject o => CStringPropertyInfo o -> IO GParamSpec
    gParamSpecCString :: forall o. GObject o => CStringPropertyInfo o -> IO GParamSpec
    gParamSpecCString (CStringPropertyInfo {Maybe [GParamFlag]
    Maybe Text
    Text
    o -> IO (Maybe Text)
    o -> Maybe Text -> IO ()
    name :: forall o. CStringPropertyInfo o -> Text
    nick :: forall o. CStringPropertyInfo o -> Text
    blurb :: forall o. CStringPropertyInfo o -> Text
    defaultValue :: forall o. CStringPropertyInfo o -> Maybe Text
    flags :: forall o. CStringPropertyInfo o -> Maybe [GParamFlag]
    setter :: forall o. CStringPropertyInfo o -> o -> Maybe Text -> IO ()
    getter :: forall o. CStringPropertyInfo o -> o -> IO (Maybe Text)
    name :: Text
    nick :: Text
    blurb :: Text
    defaultValue :: Maybe Text
    flags :: Maybe [GParamFlag]
    setter :: o -> Maybe Text -> IO ()
    getter :: o -> IO (Maybe Text)
    ..}) =
      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
    $ \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
    $ \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
    $ \CString
    cblurb -> do
            pspecPtr <- case Maybe Text
    defaultValue of
              Maybe Text
    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 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
    $ \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)
            quark <- pspecQuark
            gParamSpecSetQData pspecPtr quark (wrapGetSet getter setter gvalueSet_)
            wrapGParamSpecPtr pspecPtr

    -- | Information on a property of type `type gboolean` to be registered. A
    -- property name consists of segments consisting of ASCII letters and
    -- digits, separated by either the \'-\' or \'_\' character. The first
    -- character of a property name must be a letter. Names which violate
    -- these rules lead to undefined behaviour.
    --
    -- When creating and looking up a property, either separator can be
    -- used, but they cannot be mixed. Using \'-\' is considerably more
    -- efficient and in fact required when using property names as detail
    -- strings for signals.
    --
    -- Beyond the name, properties have two more descriptive strings
    -- associated with them, the @nick@, which should be suitable for use
    -- as a label for the property in a property editor, and the @blurb@,
    -- which should be a somewhat longer description, suitable for e.g. a
    -- tooltip. The @nick@ and @blurb@ should ideally be localized.
    data GBooleanPropertyInfo o = GBooleanPropertyInfo
      { forall o. GBooleanPropertyInfo o -> Text
    name   :: Text
      , forall o. GBooleanPropertyInfo o -> Text
    nick   :: Text
      , forall o. GBooleanPropertyInfo o -> Text
    blurb  :: Text
      , forall o. GBooleanPropertyInfo o -> Bool
    defaultValue :: Bool
      , forall o. GBooleanPropertyInfo o -> Maybe [GParamFlag]
    flags  :: Maybe [GParamFlag]
      , forall o. GBooleanPropertyInfo o -> o -> Bool -> IO ()
    setter :: o -> Bool -> IO ()
      , forall o. GBooleanPropertyInfo o -> o -> IO Bool
    getter :: o -> IO (Bool)
      }

    foreign import ccall g_param_spec_boolean ::
      CString -> CString -> CString -> Int32 -> CInt -> IO (Ptr GParamSpec)
    {-# LINE 354 "Data/GI/Base/GParamSpec.hsc" #-}

    -- | Create a `GParamSpec` for a bool param.
    gParamSpecGBoolean :: GObject o => GBooleanPropertyInfo o -> IO GParamSpec
    gParamSpecGBoolean :: forall o. GObject o => GBooleanPropertyInfo o -> IO GParamSpec
    gParamSpecGBoolean (GBooleanPropertyInfo {Bool
    Maybe [GParamFlag]
    Text
    o -> IO Bool
    o -> Bool -> IO ()
    name :: forall o. GBooleanPropertyInfo o -> Text
    nick :: forall o. GBooleanPropertyInfo o -> Text
    blurb :: forall o. GBooleanPropertyInfo o -> Text
    defaultValue :: forall o. GBooleanPropertyInfo o -> Bool
    flags :: forall o. GBooleanPropertyInfo o -> Maybe [GParamFlag]
    setter :: forall o. GBooleanPropertyInfo o -> o -> Bool -> IO ()
    getter :: forall o. GBooleanPropertyInfo o -> o -> IO Bool
    name :: Text
    nick :: Text
    blurb :: Text
    defaultValue :: Bool
    flags :: Maybe [GParamFlag]
    setter :: o -> Bool -> IO ()
    getter :: o -> IO Bool
    ..}) =
      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
    $ \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
    $ \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
    $ \CString
    cblurb -> do
            pspecPtr <- CString
    -> CString -> CString -> Int32 -> CInt -> IO (Ptr GParamSpec)
    g_param_spec_boolean CString
    cname CString
    cnick CString
    cblurb
                            ((Int -> Int32
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral (Int -> Int32) -> (Bool -> Int) -> Bool -> Int32
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Bool -> Int
    forall a. Enum a => a -> Int
    fromEnum) Bool
    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)
            quark <- pspecQuark
            gParamSpecSetQData pspecPtr quark (wrapGetSet getter setter gvalueSet_)
            wrapGParamSpecPtr 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 ())

    -- | Set the given user data on the `GParamSpec`.
    gParamSpecSetQData :: Ptr GParamSpec -> GQuark a -> a -> IO ()
    gParamSpecSetQData :: forall a. Ptr GParamSpec -> GQuark a -> a -> IO ()
    gParamSpecSetQData Ptr GParamSpec
    pspecPtr GQuark a
    quark a
    d = do
      ptr <- a -> IO (StablePtr a)
    forall a. a -> IO (StablePtr a)
    newStablePtr a
    d
      g_param_spec_set_qdata_full pspecPtr quark
                                  (castStablePtrToPtr ptr)
                                  ptr_to_hs_free_stable_ptr

    foreign import ccall g_param_spec_get_qdata ::
      Ptr GParamSpec -> GQuark a -> IO (Ptr b)

    -- | Get the user data for the given `GQuark` on the `GParamSpec`.
    gParamSpecGetQData :: Ptr GParamSpec -> GQuark a -> IO (Maybe a)
    gParamSpecGetQData :: forall a. Ptr GParamSpec -> GQuark a -> IO (Maybe a)
    gParamSpecGetQData Ptr GParamSpec
    pspecPtr GQuark a
    quark = do
      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 /= nullPtr
        then Just <$> deRefStablePtr (castPtrToStablePtr ptr)
        else return Nothing

    -- | Attempt to get the Haskell setter and getter for the given
    -- `GParamSpec`. This will only be possible if the `GParamSpec` was
    -- created with one of the functions above, if this is not the case
    -- the function will return `Nothing`.
    getGParamSpecGetterSetter :: forall o. Ptr GParamSpec ->
                                  IO (Maybe (PropGetSetter o))
    getGParamSpecGetterSetter :: forall o. Ptr GParamSpec -> IO (Maybe (PropGetSetter o))
    getGParamSpecGetterSetter Ptr GParamSpec
    pspecPtr = do
      quark <- forall o. IO (GQuark (PropGetSetter o))
    pspecQuark @o
      gParamSpecGetQData pspecPtr quark