{- |
Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
License    : LGPL-2.1
Maintainer : Iñaki García Etxebarria (garetxe@gmail.com)

'GI.GObject.Objects.Binding.Binding' is the representation of a binding between a property on a
'GI.GObject.Objects.Object.Object' instance (or source) and another property on another 'GI.GObject.Objects.Object.Object'
instance (or target). Whenever the source property changes, the same
value is applied to the target property; for instance, the following
binding:


=== /C code/
>
>  g_object_bind_property (object1, "property-a",
>                          object2, "property-b",
>                          G_BINDING_DEFAULT);


will cause the property named \"property-b\" of /@object2@/ to be updated
every time @/g_object_set()/@ or the specific accessor changes the value of
the property \"property-a\" of /@object1@/.

It is possible to create a bidirectional binding between two properties
of two 'GI.GObject.Objects.Object.Object' instances, so that if either property changes, the
other is updated as well, for instance:


=== /C code/
>
>  g_object_bind_property (object1, "property-a",
>                          object2, "property-b",
>                          G_BINDING_BIDIRECTIONAL);


will keep the two properties in sync.

It is also possible to set a custom transformation function (in both
directions, in case of a bidirectional binding) to apply a custom
transformation from the source value to the target value before
applying it; for instance, the following binding:


=== /C code/
>
>  g_object_bind_property_full (adjustment1, "value",
>                               adjustment2, "value",
>                               G_BINDING_BIDIRECTIONAL,
>                               celsius_to_fahrenheit,
>                               fahrenheit_to_celsius,
>                               NULL, NULL);


will keep the \"value\" property of the two adjustments in sync; the
/@celsiusToFahrenheit@/ function will be called whenever the \"value\"
property of /@adjustment1@/ changes and will transform the current value
of the property before applying it to the \"value\" property of /@adjustment2@/.

Vice versa, the /@fahrenheitToCelsius@/ function will be called whenever
the \"value\" property of /@adjustment2@/ changes, and will transform the
current value of the property before applying it to the \"value\" property
of /@adjustment1@/.

Note that 'GI.GObject.Objects.Binding.Binding' does not resolve cycles by itself; a cycle like

>
>  object1:propertyA -> object2:propertyB
>  object2:propertyB -> object3:propertyC
>  object3:propertyC -> object1:propertyA


might lead to an infinite loop. The loop, in this particular case,
can be avoided if the objects emit the 'GI.GObject.Objects.Object.Object'::@/notify/@ signal only
if the value has effectively been changed. A binding is implemented
using the 'GI.GObject.Objects.Object.Object'::@/notify/@ signal, so it is susceptible to all the
various ways of blocking a signal emission, like 'GI.GObject.Functions.signalStopEmission'
or 'GI.GObject.Functions.signalHandlerBlock'.

A binding will be severed, and the resources it allocates freed, whenever
either one of the 'GI.GObject.Objects.Object.Object' instances it refers to are finalized, or when
the 'GI.GObject.Objects.Binding.Binding' instance loses its last reference.

Bindings for languages with garbage collection can use
'GI.GObject.Objects.Binding.bindingUnbind' to explicitly release a binding between the source
and target properties, instead of relying on the last reference on the
binding, source, and target instances to drop.

'GI.GObject.Objects.Binding.Binding' is available since GObject 2.26
-}

module GI.GObject.Objects.Binding
    ( 

-- * Exported types
    Binding(..)                             ,
    IsBinding                               ,
    toBinding                               ,
    noBinding                               ,


 -- * Methods
-- ** getFlags #method:getFlags#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    BindingGetFlagsMethodInfo               ,
#endif
    bindingGetFlags                         ,


-- ** getSource #method:getSource#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    BindingGetSourceMethodInfo              ,
#endif
    bindingGetSource                        ,


-- ** getSourceProperty #method:getSourceProperty#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    BindingGetSourcePropertyMethodInfo      ,
#endif
    bindingGetSourceProperty                ,


-- ** getTarget #method:getTarget#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    BindingGetTargetMethodInfo              ,
#endif
    bindingGetTarget                        ,


-- ** getTargetProperty #method:getTargetProperty#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    BindingGetTargetPropertyMethodInfo      ,
#endif
    bindingGetTargetProperty                ,


-- ** unbind #method:unbind#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    BindingUnbindMethodInfo                 ,
#endif
    bindingUnbind                           ,




 -- * Properties
-- ** flags #attr:flags#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    BindingFlagsPropertyInfo                ,
#endif
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    bindingFlags                            ,
#endif
    constructBindingFlags                   ,
    getBindingFlags                         ,


-- ** source #attr:source#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    BindingSourcePropertyInfo               ,
#endif
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    bindingSource                           ,
#endif
    constructBindingSource                  ,
    getBindingSource                        ,


-- ** sourceProperty #attr:sourceProperty#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    BindingSourcePropertyPropertyInfo       ,
#endif
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    bindingSourceProperty                   ,
#endif
    constructBindingSourceProperty          ,
    getBindingSourceProperty                ,


-- ** target #attr:target#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    BindingTargetPropertyInfo               ,
#endif
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    bindingTarget                           ,
#endif
    constructBindingTarget                  ,
    getBindingTarget                        ,


-- ** targetProperty #attr:targetProperty#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    BindingTargetPropertyPropertyInfo       ,
#endif
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    bindingTargetProperty                   ,
#endif
    constructBindingTargetProperty          ,
    getBindingTargetProperty                ,




    ) 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.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GVariant as B.GVariant
import qualified Data.GI.Base.GParamSpec as B.GParamSpec
import qualified Data.GI.Base.CallStack as B.CallStack
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 {-# SOURCE #-} qualified GI.GObject.Flags as GObject.Flags
import {-# SOURCE #-} qualified GI.GObject.Objects.Object as GObject.Object

newtype Binding = Binding (ManagedPtr Binding)
foreign import ccall "g_binding_get_type"
    c_g_binding_get_type :: IO GType

instance GObject Binding where
    gobjectType _ = c_g_binding_get_type
    

class GObject o => IsBinding o
#if MIN_VERSION_base(4,9,0)
instance {-# OVERLAPPABLE #-} (GObject a, O.UnknownAncestorError Binding a) =>
    IsBinding a
#endif
instance IsBinding Binding
instance GObject.Object.IsObject Binding

toBinding :: (MonadIO m, IsBinding o) => o -> m Binding
toBinding = liftIO . unsafeCastTo Binding

noBinding :: Maybe Binding
noBinding = Nothing

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
type family ResolveBindingMethod (t :: Symbol) (o :: *) :: * where
    ResolveBindingMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
    ResolveBindingMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
    ResolveBindingMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
    ResolveBindingMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
    ResolveBindingMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
    ResolveBindingMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
    ResolveBindingMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
    ResolveBindingMethod "ref" o = GObject.Object.ObjectRefMethodInfo
    ResolveBindingMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
    ResolveBindingMethod "replaceData" o = GObject.Object.ObjectReplaceDataMethodInfo
    ResolveBindingMethod "replaceQdata" o = GObject.Object.ObjectReplaceQdataMethodInfo
    ResolveBindingMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
    ResolveBindingMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
    ResolveBindingMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
    ResolveBindingMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
    ResolveBindingMethod "unbind" o = BindingUnbindMethodInfo
    ResolveBindingMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
    ResolveBindingMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
    ResolveBindingMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
    ResolveBindingMethod "getFlags" o = BindingGetFlagsMethodInfo
    ResolveBindingMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
    ResolveBindingMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
    ResolveBindingMethod "getSource" o = BindingGetSourceMethodInfo
    ResolveBindingMethod "getSourceProperty" o = BindingGetSourcePropertyMethodInfo
    ResolveBindingMethod "getTarget" o = BindingGetTargetMethodInfo
    ResolveBindingMethod "getTargetProperty" o = BindingGetTargetPropertyMethodInfo
    ResolveBindingMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
    ResolveBindingMethod "setDataFull" o = GObject.Object.ObjectSetDataFullMethodInfo
    ResolveBindingMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolveBindingMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveBindingMethod t Binding, O.MethodInfo info Binding p) => O.IsLabelProxy t (Binding -> p) where
    fromLabelProxy _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)

#if MIN_VERSION_base(4,9,0)
instance (info ~ ResolveBindingMethod t Binding, O.MethodInfo info Binding p) => O.IsLabel t (Binding -> p) where
#if MIN_VERSION_base(4,10,0)
    fromLabel = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#else
    fromLabel _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#endif
#endif

#endif

-- VVV Prop "flags"
   -- Type: TInterface (Name {namespace = "GObject", name = "BindingFlags"})
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly]
   -- Nullable: (Just False,Nothing)

getBindingFlags :: (MonadIO m, IsBinding o) => o -> m [GObject.Flags.BindingFlags]
getBindingFlags obj = liftIO $ getObjectPropertyFlags obj "flags"

constructBindingFlags :: (IsBinding o) => [GObject.Flags.BindingFlags] -> IO (GValueConstruct o)
constructBindingFlags val = constructObjectPropertyFlags "flags" val

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data BindingFlagsPropertyInfo
instance AttrInfo BindingFlagsPropertyInfo where
    type AttrAllowedOps BindingFlagsPropertyInfo = '[ 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint BindingFlagsPropertyInfo = (~) [GObject.Flags.BindingFlags]
    type AttrBaseTypeConstraint BindingFlagsPropertyInfo = IsBinding
    type AttrGetType BindingFlagsPropertyInfo = [GObject.Flags.BindingFlags]
    type AttrLabel BindingFlagsPropertyInfo = "flags"
    type AttrOrigin BindingFlagsPropertyInfo = Binding
    attrGet _ = getBindingFlags
    attrSet _ = undefined
    attrConstruct _ = constructBindingFlags
    attrClear _ = undefined
#endif

-- VVV Prop "source"
   -- Type: TInterface (Name {namespace = "GObject", name = "Object"})
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly]
   -- Nullable: (Just False,Nothing)

getBindingSource :: (MonadIO m, IsBinding o) => o -> m GObject.Object.Object
getBindingSource obj = liftIO $ checkUnexpectedNothing "getBindingSource" $ getObjectPropertyObject obj "source" GObject.Object.Object

constructBindingSource :: (IsBinding o, GObject.Object.IsObject a) => a -> IO (GValueConstruct o)
constructBindingSource val = constructObjectPropertyObject "source" (Just val)

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data BindingSourcePropertyInfo
instance AttrInfo BindingSourcePropertyInfo where
    type AttrAllowedOps BindingSourcePropertyInfo = '[ 'AttrConstruct, 'AttrGet, 'AttrClear]
    type AttrSetTypeConstraint BindingSourcePropertyInfo = GObject.Object.IsObject
    type AttrBaseTypeConstraint BindingSourcePropertyInfo = IsBinding
    type AttrGetType BindingSourcePropertyInfo = GObject.Object.Object
    type AttrLabel BindingSourcePropertyInfo = "source"
    type AttrOrigin BindingSourcePropertyInfo = Binding
    attrGet _ = getBindingSource
    attrSet _ = undefined
    attrConstruct _ = constructBindingSource
    attrClear _ = undefined
#endif

-- VVV Prop "source-property"
   -- Type: TBasicType TUTF8
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly]
   -- Nullable: (Just False,Nothing)

getBindingSourceProperty :: (MonadIO m, IsBinding o) => o -> m T.Text
getBindingSourceProperty obj = liftIO $ checkUnexpectedNothing "getBindingSourceProperty" $ getObjectPropertyString obj "source-property"

constructBindingSourceProperty :: (IsBinding o) => T.Text -> IO (GValueConstruct o)
constructBindingSourceProperty val = constructObjectPropertyString "source-property" (Just val)

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data BindingSourcePropertyPropertyInfo
instance AttrInfo BindingSourcePropertyPropertyInfo where
    type AttrAllowedOps BindingSourcePropertyPropertyInfo = '[ 'AttrConstruct, 'AttrGet, 'AttrClear]
    type AttrSetTypeConstraint BindingSourcePropertyPropertyInfo = (~) T.Text
    type AttrBaseTypeConstraint BindingSourcePropertyPropertyInfo = IsBinding
    type AttrGetType BindingSourcePropertyPropertyInfo = T.Text
    type AttrLabel BindingSourcePropertyPropertyInfo = "source-property"
    type AttrOrigin BindingSourcePropertyPropertyInfo = Binding
    attrGet _ = getBindingSourceProperty
    attrSet _ = undefined
    attrConstruct _ = constructBindingSourceProperty
    attrClear _ = undefined
#endif

-- VVV Prop "target"
   -- Type: TInterface (Name {namespace = "GObject", name = "Object"})
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly]
   -- Nullable: (Just False,Nothing)

getBindingTarget :: (MonadIO m, IsBinding o) => o -> m GObject.Object.Object
getBindingTarget obj = liftIO $ checkUnexpectedNothing "getBindingTarget" $ getObjectPropertyObject obj "target" GObject.Object.Object

constructBindingTarget :: (IsBinding o, GObject.Object.IsObject a) => a -> IO (GValueConstruct o)
constructBindingTarget val = constructObjectPropertyObject "target" (Just val)

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data BindingTargetPropertyInfo
instance AttrInfo BindingTargetPropertyInfo where
    type AttrAllowedOps BindingTargetPropertyInfo = '[ 'AttrConstruct, 'AttrGet, 'AttrClear]
    type AttrSetTypeConstraint BindingTargetPropertyInfo = GObject.Object.IsObject
    type AttrBaseTypeConstraint BindingTargetPropertyInfo = IsBinding
    type AttrGetType BindingTargetPropertyInfo = GObject.Object.Object
    type AttrLabel BindingTargetPropertyInfo = "target"
    type AttrOrigin BindingTargetPropertyInfo = Binding
    attrGet _ = getBindingTarget
    attrSet _ = undefined
    attrConstruct _ = constructBindingTarget
    attrClear _ = undefined
#endif

-- VVV Prop "target-property"
   -- Type: TBasicType TUTF8
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly]
   -- Nullable: (Just False,Nothing)

getBindingTargetProperty :: (MonadIO m, IsBinding o) => o -> m T.Text
getBindingTargetProperty obj = liftIO $ checkUnexpectedNothing "getBindingTargetProperty" $ getObjectPropertyString obj "target-property"

constructBindingTargetProperty :: (IsBinding o) => T.Text -> IO (GValueConstruct o)
constructBindingTargetProperty val = constructObjectPropertyString "target-property" (Just val)

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data BindingTargetPropertyPropertyInfo
instance AttrInfo BindingTargetPropertyPropertyInfo where
    type AttrAllowedOps BindingTargetPropertyPropertyInfo = '[ 'AttrConstruct, 'AttrGet, 'AttrClear]
    type AttrSetTypeConstraint BindingTargetPropertyPropertyInfo = (~) T.Text
    type AttrBaseTypeConstraint BindingTargetPropertyPropertyInfo = IsBinding
    type AttrGetType BindingTargetPropertyPropertyInfo = T.Text
    type AttrLabel BindingTargetPropertyPropertyInfo = "target-property"
    type AttrOrigin BindingTargetPropertyPropertyInfo = Binding
    attrGet _ = getBindingTargetProperty
    attrSet _ = undefined
    attrConstruct _ = constructBindingTargetProperty
    attrClear _ = undefined
#endif

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
instance O.HasAttributeList Binding
type instance O.AttributeList Binding = BindingAttributeList
type BindingAttributeList = ('[ '("flags", BindingFlagsPropertyInfo), '("source", BindingSourcePropertyInfo), '("sourceProperty", BindingSourcePropertyPropertyInfo), '("target", BindingTargetPropertyInfo), '("targetProperty", BindingTargetPropertyPropertyInfo)] :: [(Symbol, *)])
#endif

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
bindingFlags :: AttrLabelProxy "flags"
bindingFlags = AttrLabelProxy

bindingSource :: AttrLabelProxy "source"
bindingSource = AttrLabelProxy

bindingSourceProperty :: AttrLabelProxy "sourceProperty"
bindingSourceProperty = AttrLabelProxy

bindingTarget :: AttrLabelProxy "target"
bindingTarget = AttrLabelProxy

bindingTargetProperty :: AttrLabelProxy "targetProperty"
bindingTargetProperty = AttrLabelProxy

#endif

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
type instance O.SignalList Binding = BindingSignalList
type BindingSignalList = ('[ '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, *)])

#endif

-- method Binding::get_flags
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "binding", argType = TInterface (Name {namespace = "GObject", name = "Binding"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GBinding", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "GObject", name = "BindingFlags"}))
-- throws : False
-- Skip return : False

foreign import ccall "g_binding_get_flags" g_binding_get_flags :: 
    Ptr Binding ->                          -- binding : TInterface (Name {namespace = "GObject", name = "Binding"})
    IO CUInt

{- |
Retrieves the flags passed when constructing the 'GI.GObject.Objects.Binding.Binding'.

@since 2.26
-}
bindingGetFlags ::
    (B.CallStack.HasCallStack, MonadIO m, IsBinding a) =>
    a
    {- ^ /@binding@/: a 'GI.GObject.Objects.Binding.Binding' -}
    -> m [GObject.Flags.BindingFlags]
    {- ^ __Returns:__ the 'GI.GObject.Flags.BindingFlags' used by the 'GI.GObject.Objects.Binding.Binding' -}
bindingGetFlags binding = liftIO $ do
    binding' <- unsafeManagedPtrCastPtr binding
    result <- g_binding_get_flags binding'
    let result' = wordToGFlags result
    touchManagedPtr binding
    return result'

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data BindingGetFlagsMethodInfo
instance (signature ~ (m [GObject.Flags.BindingFlags]), MonadIO m, IsBinding a) => O.MethodInfo BindingGetFlagsMethodInfo a signature where
    overloadedMethod _ = bindingGetFlags

#endif

-- method Binding::get_source
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "binding", argType = TInterface (Name {namespace = "GObject", name = "Binding"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GBinding", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "GObject", name = "Object"}))
-- throws : False
-- Skip return : False

foreign import ccall "g_binding_get_source" g_binding_get_source :: 
    Ptr Binding ->                          -- binding : TInterface (Name {namespace = "GObject", name = "Binding"})
    IO (Ptr GObject.Object.Object)

{- |
Retrieves the 'GI.GObject.Objects.Object.Object' instance used as the source of the binding.

@since 2.26
-}
bindingGetSource ::
    (B.CallStack.HasCallStack, MonadIO m, IsBinding a) =>
    a
    {- ^ /@binding@/: a 'GI.GObject.Objects.Binding.Binding' -}
    -> m GObject.Object.Object
    {- ^ __Returns:__ the source 'GI.GObject.Objects.Object.Object' -}
bindingGetSource binding = liftIO $ do
    binding' <- unsafeManagedPtrCastPtr binding
    result <- g_binding_get_source binding'
    checkUnexpectedReturnNULL "bindingGetSource" result
    result' <- (newObject GObject.Object.Object) result
    touchManagedPtr binding
    return result'

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data BindingGetSourceMethodInfo
instance (signature ~ (m GObject.Object.Object), MonadIO m, IsBinding a) => O.MethodInfo BindingGetSourceMethodInfo a signature where
    overloadedMethod _ = bindingGetSource

#endif

-- method Binding::get_source_property
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "binding", argType = TInterface (Name {namespace = "GObject", name = "Binding"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GBinding", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "g_binding_get_source_property" g_binding_get_source_property :: 
    Ptr Binding ->                          -- binding : TInterface (Name {namespace = "GObject", name = "Binding"})
    IO CString

{- |
Retrieves the name of the property of 'GI.GObject.Objects.Binding.Binding':@/source/@ used as the source
of the binding.

@since 2.26
-}
bindingGetSourceProperty ::
    (B.CallStack.HasCallStack, MonadIO m, IsBinding a) =>
    a
    {- ^ /@binding@/: a 'GI.GObject.Objects.Binding.Binding' -}
    -> m T.Text
    {- ^ __Returns:__ the name of the source property -}
bindingGetSourceProperty binding = liftIO $ do
    binding' <- unsafeManagedPtrCastPtr binding
    result <- g_binding_get_source_property binding'
    checkUnexpectedReturnNULL "bindingGetSourceProperty" result
    result' <- cstringToText result
    touchManagedPtr binding
    return result'

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data BindingGetSourcePropertyMethodInfo
instance (signature ~ (m T.Text), MonadIO m, IsBinding a) => O.MethodInfo BindingGetSourcePropertyMethodInfo a signature where
    overloadedMethod _ = bindingGetSourceProperty

#endif

-- method Binding::get_target
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "binding", argType = TInterface (Name {namespace = "GObject", name = "Binding"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GBinding", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "GObject", name = "Object"}))
-- throws : False
-- Skip return : False

foreign import ccall "g_binding_get_target" g_binding_get_target :: 
    Ptr Binding ->                          -- binding : TInterface (Name {namespace = "GObject", name = "Binding"})
    IO (Ptr GObject.Object.Object)

{- |
Retrieves the 'GI.GObject.Objects.Object.Object' instance used as the target of the binding.

@since 2.26
-}
bindingGetTarget ::
    (B.CallStack.HasCallStack, MonadIO m, IsBinding a) =>
    a
    {- ^ /@binding@/: a 'GI.GObject.Objects.Binding.Binding' -}
    -> m GObject.Object.Object
    {- ^ __Returns:__ the target 'GI.GObject.Objects.Object.Object' -}
bindingGetTarget binding = liftIO $ do
    binding' <- unsafeManagedPtrCastPtr binding
    result <- g_binding_get_target binding'
    checkUnexpectedReturnNULL "bindingGetTarget" result
    result' <- (newObject GObject.Object.Object) result
    touchManagedPtr binding
    return result'

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data BindingGetTargetMethodInfo
instance (signature ~ (m GObject.Object.Object), MonadIO m, IsBinding a) => O.MethodInfo BindingGetTargetMethodInfo a signature where
    overloadedMethod _ = bindingGetTarget

#endif

-- method Binding::get_target_property
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "binding", argType = TInterface (Name {namespace = "GObject", name = "Binding"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GBinding", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "g_binding_get_target_property" g_binding_get_target_property :: 
    Ptr Binding ->                          -- binding : TInterface (Name {namespace = "GObject", name = "Binding"})
    IO CString

{- |
Retrieves the name of the property of 'GI.GObject.Objects.Binding.Binding':@/target/@ used as the target
of the binding.

@since 2.26
-}
bindingGetTargetProperty ::
    (B.CallStack.HasCallStack, MonadIO m, IsBinding a) =>
    a
    {- ^ /@binding@/: a 'GI.GObject.Objects.Binding.Binding' -}
    -> m T.Text
    {- ^ __Returns:__ the name of the target property -}
bindingGetTargetProperty binding = liftIO $ do
    binding' <- unsafeManagedPtrCastPtr binding
    result <- g_binding_get_target_property binding'
    checkUnexpectedReturnNULL "bindingGetTargetProperty" result
    result' <- cstringToText result
    touchManagedPtr binding
    return result'

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data BindingGetTargetPropertyMethodInfo
instance (signature ~ (m T.Text), MonadIO m, IsBinding a) => O.MethodInfo BindingGetTargetPropertyMethodInfo a signature where
    overloadedMethod _ = bindingGetTargetProperty

#endif

-- method Binding::unbind
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "binding", argType = TInterface (Name {namespace = "GObject", name = "Binding"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GBinding", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_binding_unbind" g_binding_unbind :: 
    Ptr Binding ->                          -- binding : TInterface (Name {namespace = "GObject", name = "Binding"})
    IO ()

{- |
Explicitly releases the binding between the source and the target
property expressed by /@binding@/.

This function will release the reference that is being held on
the /@binding@/ instance; if you want to hold on to the 'GI.GObject.Objects.Binding.Binding' instance
after calling 'GI.GObject.Objects.Binding.bindingUnbind', you will need to hold a reference
to it.

@since 2.38
-}
bindingUnbind ::
    (B.CallStack.HasCallStack, MonadIO m, IsBinding a) =>
    a
    {- ^ /@binding@/: a 'GI.GObject.Objects.Binding.Binding' -}
    -> m ()
bindingUnbind binding = liftIO $ do
    binding' <- unsafeManagedPtrCastPtr binding
    g_binding_unbind binding'
    touchManagedPtr binding
    return ()

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data BindingUnbindMethodInfo
instance (signature ~ (m ()), MonadIO m, IsBinding a) => O.MethodInfo BindingUnbindMethodInfo a signature where
    overloadedMethod _ = bindingUnbind

#endif