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

All the fields in the GObject structure are private
to the 'GI.GObject.Objects.Object.Object' implementation and should never be accessed directly.
-}

module GI.GObject.Objects.Object
    ( 

-- * Exported types
    Object(..)                              ,
    IsObject                                ,
    toObject                                ,
    noObject                                ,


 -- * Methods
-- ** Unsupported methods #method:Unsupported methods#
    ObjectInterfaceListPropertiesMethodInfo ,


-- ** bindProperty #method:bindProperty#
    ObjectBindPropertyMethodInfo            ,
    objectBindProperty                      ,


-- ** bindPropertyFull #method:bindPropertyFull#
    ObjectBindPropertyFullMethodInfo        ,
    objectBindPropertyFull                  ,


-- ** compatControl #method:compatControl#
    objectCompatControl                     ,


-- ** forceFloating #method:forceFloating#
    ObjectForceFloatingMethodInfo           ,
    objectForceFloating                     ,


-- ** freezeNotify #method:freezeNotify#
    ObjectFreezeNotifyMethodInfo            ,
    objectFreezeNotify                      ,


-- ** getData #method:getData#
    ObjectGetDataMethodInfo                 ,
    objectGetData                           ,


-- ** getProperty #method:getProperty#
    ObjectGetPropertyMethodInfo             ,
    objectGetProperty                       ,


-- ** getQdata #method:getQdata#
    ObjectGetQdataMethodInfo                ,
    objectGetQdata                          ,


-- ** interfaceFindProperty #method:interfaceFindProperty#
    objectInterfaceFindProperty             ,


-- ** interfaceInstallProperty #method:interfaceInstallProperty#
    objectInterfaceInstallProperty          ,


-- ** isFloating #method:isFloating#
    ObjectIsFloatingMethodInfo              ,
    objectIsFloating                        ,


-- ** new #method:new#
    objectNew                               ,


-- ** notify #method:notify#
    ObjectNotifyMethodInfo                  ,
    objectNotify                            ,


-- ** notifyByPspec #method:notifyByPspec#
    ObjectNotifyByPspecMethodInfo           ,
    objectNotifyByPspec                     ,


-- ** ref #method:ref#
    ObjectRefMethodInfo                     ,
    objectRef                               ,


-- ** refSink #method:refSink#
    ObjectRefSinkMethodInfo                 ,
    objectRefSink                           ,


-- ** replaceData #method:replaceData#
    ObjectReplaceDataMethodInfo             ,
    objectReplaceData                       ,


-- ** replaceQdata #method:replaceQdata#
    ObjectReplaceQdataMethodInfo            ,
    objectReplaceQdata                      ,


-- ** runDispose #method:runDispose#
    ObjectRunDisposeMethodInfo              ,
    objectRunDispose                        ,


-- ** setData #method:setData#
    ObjectSetDataMethodInfo                 ,
    objectSetData                           ,


-- ** setProperty #method:setProperty#
    ObjectSetPropertyMethodInfo             ,
    objectSetProperty                       ,


-- ** stealData #method:stealData#
    ObjectStealDataMethodInfo               ,
    objectStealData                         ,


-- ** stealQdata #method:stealQdata#
    ObjectStealQdataMethodInfo              ,
    objectStealQdata                        ,


-- ** thawNotify #method:thawNotify#
    ObjectThawNotifyMethodInfo              ,
    objectThawNotify                        ,


-- ** unref #method:unref#
    ObjectUnrefMethodInfo                   ,
    objectUnref                             ,


-- ** watchClosure #method:watchClosure#
    ObjectWatchClosureMethodInfo            ,
    objectWatchClosure                      ,




 -- * Signals
-- ** notify #signal:notify#
    C_ObjectNotifyCallback                  ,
    ObjectNotifyCallback                    ,
    ObjectNotifySignalInfo                  ,
    afterObjectNotify                       ,
    genClosure_ObjectNotify                 ,
    mk_ObjectNotifyCallback                 ,
    noObjectNotifyCallback                  ,
    onObjectNotify                          ,
    wrap_ObjectNotifyCallback               ,




    ) 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 qualified GI.GLib.Callbacks as GLib.Callbacks
import {-# SOURCE #-} qualified GI.GObject.Flags as GObject.Flags
import {-# SOURCE #-} qualified GI.GObject.Objects.Binding as GObject.Binding
import {-# SOURCE #-} qualified GI.GObject.Structs.Parameter as GObject.Parameter
import {-# SOURCE #-} qualified GI.GObject.Structs.TypeInterface as GObject.TypeInterface

newtype Object = Object (ManagedPtr Object)
foreign import ccall "g_object_get_type"
    c_g_object_get_type :: IO GType

instance GObject Object where
    gobjectType _ = c_g_object_get_type
    

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

toObject :: IsObject o => o -> IO Object
toObject = unsafeCastTo Object

noObject :: Maybe Object
noObject = Nothing

type family ResolveObjectMethod (t :: Symbol) (o :: *) :: * where
    ResolveObjectMethod "bindProperty" o = ObjectBindPropertyMethodInfo
    ResolveObjectMethod "bindPropertyFull" o = ObjectBindPropertyFullMethodInfo
    ResolveObjectMethod "forceFloating" o = ObjectForceFloatingMethodInfo
    ResolveObjectMethod "freezeNotify" o = ObjectFreezeNotifyMethodInfo
    ResolveObjectMethod "isFloating" o = ObjectIsFloatingMethodInfo
    ResolveObjectMethod "notify" o = ObjectNotifyMethodInfo
    ResolveObjectMethod "notifyByPspec" o = ObjectNotifyByPspecMethodInfo
    ResolveObjectMethod "ref" o = ObjectRefMethodInfo
    ResolveObjectMethod "refSink" o = ObjectRefSinkMethodInfo
    ResolveObjectMethod "replaceData" o = ObjectReplaceDataMethodInfo
    ResolveObjectMethod "replaceQdata" o = ObjectReplaceQdataMethodInfo
    ResolveObjectMethod "runDispose" o = ObjectRunDisposeMethodInfo
    ResolveObjectMethod "stealData" o = ObjectStealDataMethodInfo
    ResolveObjectMethod "stealQdata" o = ObjectStealQdataMethodInfo
    ResolveObjectMethod "thawNotify" o = ObjectThawNotifyMethodInfo
    ResolveObjectMethod "unref" o = ObjectUnrefMethodInfo
    ResolveObjectMethod "watchClosure" o = ObjectWatchClosureMethodInfo
    ResolveObjectMethod "getData" o = ObjectGetDataMethodInfo
    ResolveObjectMethod "getProperty" o = ObjectGetPropertyMethodInfo
    ResolveObjectMethod "getQdata" o = ObjectGetQdataMethodInfo
    ResolveObjectMethod "setData" o = ObjectSetDataMethodInfo
    ResolveObjectMethod "setProperty" o = ObjectSetPropertyMethodInfo
    ResolveObjectMethod l o = O.MethodResolutionFailed l o

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

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

-- signal Object::notify
type ObjectNotifyCallback =
    GParamSpec ->
    IO ()

noObjectNotifyCallback :: Maybe ObjectNotifyCallback
noObjectNotifyCallback = Nothing

type C_ObjectNotifyCallback =
    Ptr () ->                               -- object
    Ptr GParamSpec ->
    Ptr () ->                               -- user_data
    IO ()

foreign import ccall "wrapper"
    mk_ObjectNotifyCallback :: C_ObjectNotifyCallback -> IO (FunPtr C_ObjectNotifyCallback)

genClosure_ObjectNotify :: ObjectNotifyCallback -> IO Closure
genClosure_ObjectNotify cb = do
    let cb' = wrap_ObjectNotifyCallback cb
    mk_ObjectNotifyCallback cb' >>= newCClosure


wrap_ObjectNotifyCallback ::
    ObjectNotifyCallback ->
    Ptr () ->
    Ptr GParamSpec ->
    Ptr () ->
    IO ()
wrap_ObjectNotifyCallback _cb _ pspec _ = do
    pspec' <- newGParamSpecFromPtr pspec
    _cb  pspec'


onObjectNotify :: (GObject a, MonadIO m) => a -> ObjectNotifyCallback -> m SignalHandlerId
onObjectNotify obj cb = liftIO $ connectObjectNotify obj cb SignalConnectBefore
afterObjectNotify :: (GObject a, MonadIO m) => a -> ObjectNotifyCallback -> m SignalHandlerId
afterObjectNotify obj cb = connectObjectNotify obj cb SignalConnectAfter

connectObjectNotify :: (GObject a, MonadIO m) =>
                       a -> ObjectNotifyCallback -> SignalConnectMode -> m SignalHandlerId
connectObjectNotify obj cb after = liftIO $ do
    let cb' = wrap_ObjectNotifyCallback cb
    cb'' <- mk_ObjectNotifyCallback cb'
    connectSignalFunPtr obj "notify" cb'' after

instance O.HasAttributeList Object
type instance O.AttributeList Object = ObjectAttributeList
type ObjectAttributeList = ('[ ] :: [(Symbol, *)])

data ObjectNotifySignalInfo
instance SignalInfo ObjectNotifySignalInfo where
    type HaskellCallbackType ObjectNotifySignalInfo = ObjectNotifyCallback
    connectSignal _ = connectObjectNotify

type instance O.SignalList Object = ObjectSignalList
type ObjectSignalList = ('[ '("notify", ObjectNotifySignalInfo)] :: [(Symbol, *)])

-- method Object::new
-- method type : Constructor
-- Args : [Arg {argCName = "object_type", argType = TBasicType TGType, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the type id of the #GObject subtype to instantiate", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "n_parameters", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the length of the @parameters array", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "parameters", argType = TCArray False (-1) 1 (TInterface (Name {namespace = "GObject", name = "Parameter"})), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "an array of #GParameter", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : [Arg {argCName = "n_parameters", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the length of the @parameters array", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- returnType : Just (TInterface (Name {namespace = "GObject", name = "Object"}))
-- throws : False
-- Skip return : False

foreign import ccall "g_object_newv" g_object_newv :: 
    CGType ->                               -- object_type : TBasicType TGType
    Word32 ->                               -- n_parameters : TBasicType TUInt
    Ptr GObject.Parameter.Parameter ->      -- parameters : TCArray False (-1) 1 (TInterface (Name {namespace = "GObject", name = "Parameter"}))
    IO (Ptr Object)

{- |
Creates a new instance of a 'GI.GObject.Objects.Object.Object' subtype and sets its properties.

Construction parameters (see @/G_PARAM_CONSTRUCT/@, @/G_PARAM_CONSTRUCT_ONLY/@)
which are not explicitly specified are set to their default values.
-}
objectNew ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    GType
    {- ^ /@objectType@/: the type id of the 'GI.GObject.Objects.Object.Object' subtype to instantiate -}
    -> [GObject.Parameter.Parameter]
    {- ^ /@parameters@/: an array of 'GI.GObject.Structs.Parameter.Parameter' -}
    -> m Object
    {- ^ __Returns:__ a new instance of
/@objectType@/ -}
objectNew objectType parameters = liftIO $ do
    let nParameters = fromIntegral $ length parameters
    let objectType' = gtypeToCGType objectType
    parameters' <- mapM unsafeManagedPtrGetPtr parameters
    parameters'' <- packBlockArray 32 parameters'
    result <- g_object_newv objectType' nParameters parameters''
    checkUnexpectedReturnNULL "objectNew" result
    result' <- (wrapObject Object) result
    mapM_ touchManagedPtr parameters
    freeMem parameters''
    return result'

-- method Object::bind_property
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "source", argType = TInterface (Name {namespace = "GObject", name = "Object"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the source #GObject", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "source_property", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the property on @source to bind", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "target", argType = TInterface (Name {namespace = "GObject", name = "Object"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the target #GObject", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "target_property", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the property on @target to bind", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "flags", argType = TInterface (Name {namespace = "GObject", name = "BindingFlags"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "flags to pass to #GBinding", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "GObject", name = "Binding"}))
-- throws : False
-- Skip return : False

foreign import ccall "g_object_bind_property" g_object_bind_property :: 
    Ptr Object ->                           -- source : TInterface (Name {namespace = "GObject", name = "Object"})
    CString ->                              -- source_property : TBasicType TUTF8
    Ptr Object ->                           -- target : TInterface (Name {namespace = "GObject", name = "Object"})
    CString ->                              -- target_property : TBasicType TUTF8
    CUInt ->                                -- flags : TInterface (Name {namespace = "GObject", name = "BindingFlags"})
    IO (Ptr GObject.Binding.Binding)

{- |
Creates a binding between /@sourceProperty@/ on /@source@/ and /@targetProperty@/
on /@target@/. Whenever the /@sourceProperty@/ is changed the /@targetProperty@/ is
updated using the same value. For instance:

>
>  g_object_bind_property (action, "active", widget, "sensitive", 0);


Will result in the \"sensitive\" property of the widget 'GI.GObject.Objects.Object.Object' instance to be
updated with the same value of the \"active\" property of the action 'GI.GObject.Objects.Object.Object'
instance.

If /@flags@/ contains 'GI.GObject.Flags.BindingFlagsBidirectional' then the binding will be mutual:
if /@targetProperty@/ on /@target@/ changes then the /@sourceProperty@/ on /@source@/
will be updated as well.

The binding will automatically be removed when either the /@source@/ or the
/@target@/ instances are finalized. To remove the binding without affecting the
/@source@/ and the /@target@/ you can just call 'GI.GObject.Objects.Object.objectUnref' on the returned
'GI.GObject.Objects.Binding.Binding' instance.

A 'GI.GObject.Objects.Object.Object' can have multiple bindings.

@since 2.26
-}
objectBindProperty ::
    (B.CallStack.HasCallStack, MonadIO m, IsObject a, IsObject b) =>
    a
    {- ^ /@source@/: the source 'GI.GObject.Objects.Object.Object' -}
    -> T.Text
    {- ^ /@sourceProperty@/: the property on /@source@/ to bind -}
    -> b
    {- ^ /@target@/: the target 'GI.GObject.Objects.Object.Object' -}
    -> T.Text
    {- ^ /@targetProperty@/: the property on /@target@/ to bind -}
    -> [GObject.Flags.BindingFlags]
    {- ^ /@flags@/: flags to pass to 'GI.GObject.Objects.Binding.Binding' -}
    -> m GObject.Binding.Binding
    {- ^ __Returns:__ the 'GI.GObject.Objects.Binding.Binding' instance representing the
    binding between the two 'GI.GObject.Objects.Object.Object' instances. The binding is released
    whenever the 'GI.GObject.Objects.Binding.Binding' reference count reaches zero. -}
objectBindProperty source sourceProperty target targetProperty flags = liftIO $ do
    source' <- unsafeManagedPtrCastPtr source
    sourceProperty' <- textToCString sourceProperty
    target' <- unsafeManagedPtrCastPtr target
    targetProperty' <- textToCString targetProperty
    let flags' = gflagsToWord flags
    result <- g_object_bind_property source' sourceProperty' target' targetProperty' flags'
    checkUnexpectedReturnNULL "objectBindProperty" result
    result' <- (newObject GObject.Binding.Binding) result
    touchManagedPtr source
    touchManagedPtr target
    freeMem sourceProperty'
    freeMem targetProperty'
    return result'

data ObjectBindPropertyMethodInfo
instance (signature ~ (T.Text -> b -> T.Text -> [GObject.Flags.BindingFlags] -> m GObject.Binding.Binding), MonadIO m, IsObject a, IsObject b) => O.MethodInfo ObjectBindPropertyMethodInfo a signature where
    overloadedMethod _ = objectBindProperty

-- method Object::bind_property_full
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "source", argType = TInterface (Name {namespace = "GObject", name = "Object"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the source #GObject", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "source_property", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the property on @source to bind", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "target", argType = TInterface (Name {namespace = "GObject", name = "Object"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the target #GObject", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "target_property", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the property on @target to bind", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "flags", argType = TInterface (Name {namespace = "GObject", name = "BindingFlags"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "flags to pass to #GBinding", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "transform_to", argType = TInterface (Name {namespace = "GObject", name = "Closure"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GClosure wrapping the transformation function\n    from the @source to the @target, or %NULL to use the default", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "transform_from", argType = TInterface (Name {namespace = "GObject", name = "Closure"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GClosure wrapping the transformation function\n    from the @target to the @source, or %NULL to use the default", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "GObject", name = "Binding"}))
-- throws : False
-- Skip return : False

foreign import ccall "g_object_bind_property_with_closures" g_object_bind_property_with_closures :: 
    Ptr Object ->                           -- source : TInterface (Name {namespace = "GObject", name = "Object"})
    CString ->                              -- source_property : TBasicType TUTF8
    Ptr Object ->                           -- target : TInterface (Name {namespace = "GObject", name = "Object"})
    CString ->                              -- target_property : TBasicType TUTF8
    CUInt ->                                -- flags : TInterface (Name {namespace = "GObject", name = "BindingFlags"})
    Ptr Closure ->                          -- transform_to : TInterface (Name {namespace = "GObject", name = "Closure"})
    Ptr Closure ->                          -- transform_from : TInterface (Name {namespace = "GObject", name = "Closure"})
    IO (Ptr GObject.Binding.Binding)

{- |
Creates a binding between /@sourceProperty@/ on /@source@/ and /@targetProperty@/
on /@target@/, allowing you to set the transformation functions to be used by
the binding.

This function is the language bindings friendly version of
@/g_object_bind_property_full()/@, using @/GClosures/@ instead of
function pointers.

@since 2.26
-}
objectBindPropertyFull ::
    (B.CallStack.HasCallStack, MonadIO m, IsObject a, IsObject b) =>
    a
    {- ^ /@source@/: the source 'GI.GObject.Objects.Object.Object' -}
    -> T.Text
    {- ^ /@sourceProperty@/: the property on /@source@/ to bind -}
    -> b
    {- ^ /@target@/: the target 'GI.GObject.Objects.Object.Object' -}
    -> T.Text
    {- ^ /@targetProperty@/: the property on /@target@/ to bind -}
    -> [GObject.Flags.BindingFlags]
    {- ^ /@flags@/: flags to pass to 'GI.GObject.Objects.Binding.Binding' -}
    -> Closure
    {- ^ /@transformTo@/: a 'GI.GObject.Structs.Closure.Closure' wrapping the transformation function
    from the /@source@/ to the /@target@/, or 'Nothing' to use the default -}
    -> Closure
    {- ^ /@transformFrom@/: a 'GI.GObject.Structs.Closure.Closure' wrapping the transformation function
    from the /@target@/ to the /@source@/, or 'Nothing' to use the default -}
    -> m GObject.Binding.Binding
    {- ^ __Returns:__ the 'GI.GObject.Objects.Binding.Binding' instance representing the
    binding between the two 'GI.GObject.Objects.Object.Object' instances. The binding is released
    whenever the 'GI.GObject.Objects.Binding.Binding' reference count reaches zero. -}
objectBindPropertyFull source sourceProperty target targetProperty flags transformTo transformFrom = liftIO $ do
    source' <- unsafeManagedPtrCastPtr source
    sourceProperty' <- textToCString sourceProperty
    target' <- unsafeManagedPtrCastPtr target
    targetProperty' <- textToCString targetProperty
    let flags' = gflagsToWord flags
    transformTo' <- unsafeManagedPtrGetPtr transformTo
    transformFrom' <- unsafeManagedPtrGetPtr transformFrom
    result <- g_object_bind_property_with_closures source' sourceProperty' target' targetProperty' flags' transformTo' transformFrom'
    checkUnexpectedReturnNULL "objectBindPropertyFull" result
    result' <- (newObject GObject.Binding.Binding) result
    touchManagedPtr source
    touchManagedPtr target
    touchManagedPtr transformTo
    touchManagedPtr transformFrom
    freeMem sourceProperty'
    freeMem targetProperty'
    return result'

data ObjectBindPropertyFullMethodInfo
instance (signature ~ (T.Text -> b -> T.Text -> [GObject.Flags.BindingFlags] -> Closure -> Closure -> m GObject.Binding.Binding), MonadIO m, IsObject a, IsObject b) => O.MethodInfo ObjectBindPropertyFullMethodInfo a signature where
    overloadedMethod _ = objectBindPropertyFull

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

foreign import ccall "g_object_force_floating" g_object_force_floating :: 
    Ptr Object ->                           -- object : TInterface (Name {namespace = "GObject", name = "Object"})
    IO ()

{- |
This function is intended for 'GI.GObject.Objects.Object.Object' implementations to re-enforce
a [floating][floating-ref] object reference. Doing this is seldom
required: all @/GInitiallyUnowneds/@ are created with a floating reference
which usually just needs to be sunken by calling 'GI.GObject.Objects.Object.objectRefSink'.

@since 2.10
-}
objectForceFloating ::
    (B.CallStack.HasCallStack, MonadIO m, IsObject a) =>
    a
    {- ^ /@object@/: a 'GI.GObject.Objects.Object.Object' -}
    -> m ()
objectForceFloating object = liftIO $ do
    object' <- unsafeManagedPtrCastPtr object
    g_object_force_floating object'
    touchManagedPtr object
    return ()

data ObjectForceFloatingMethodInfo
instance (signature ~ (m ()), MonadIO m, IsObject a) => O.MethodInfo ObjectForceFloatingMethodInfo a signature where
    overloadedMethod _ = objectForceFloating

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

foreign import ccall "g_object_freeze_notify" g_object_freeze_notify :: 
    Ptr Object ->                           -- object : TInterface (Name {namespace = "GObject", name = "Object"})
    IO ()

{- |
Increases the freeze count on /@object@/. If the freeze count is
non-zero, the emission of \"notify\" signals on /@object@/ is
stopped. The signals are queued until the freeze count is decreased
to zero. Duplicate notifications are squashed so that at most one
'GI.GObject.Objects.Object.Object'::@/notify/@ signal is emitted for each property modified while the
object is frozen.

This is necessary for accessors that modify multiple properties to prevent
premature notification while the object is still being modified.
-}
objectFreezeNotify ::
    (B.CallStack.HasCallStack, MonadIO m, IsObject a) =>
    a
    {- ^ /@object@/: a 'GI.GObject.Objects.Object.Object' -}
    -> m ()
objectFreezeNotify object = liftIO $ do
    object' <- unsafeManagedPtrCastPtr object
    g_object_freeze_notify object'
    touchManagedPtr object
    return ()

data ObjectFreezeNotifyMethodInfo
instance (signature ~ (m ()), MonadIO m, IsObject a) => O.MethodInfo ObjectFreezeNotifyMethodInfo a signature where
    overloadedMethod _ = objectFreezeNotify

-- method Object::get_data
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "object", argType = TInterface (Name {namespace = "GObject", name = "Object"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "#GObject containing the associations", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "key", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "name of the key for that association", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TPtr)
-- throws : False
-- Skip return : False

foreign import ccall "g_object_get_data" g_object_get_data :: 
    Ptr Object ->                           -- object : TInterface (Name {namespace = "GObject", name = "Object"})
    CString ->                              -- key : TBasicType TUTF8
    IO (Ptr ())

{- |
Gets a named field from the objects table of associations (see 'GI.GObject.Objects.Object.objectSetData').
-}
objectGetData ::
    (B.CallStack.HasCallStack, MonadIO m, IsObject a) =>
    a
    {- ^ /@object@/: 'GI.GObject.Objects.Object.Object' containing the associations -}
    -> T.Text
    {- ^ /@key@/: name of the key for that association -}
    -> m (Ptr ())
    {- ^ __Returns:__ the data if found, or 'Nothing' if no such data exists. -}
objectGetData object key = liftIO $ do
    object' <- unsafeManagedPtrCastPtr object
    key' <- textToCString key
    result <- g_object_get_data object' key'
    touchManagedPtr object
    freeMem key'
    return result

data ObjectGetDataMethodInfo
instance (signature ~ (T.Text -> m (Ptr ())), MonadIO m, IsObject a) => O.MethodInfo ObjectGetDataMethodInfo a signature where
    overloadedMethod _ = objectGetData

-- method Object::get_property
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "object", argType = TInterface (Name {namespace = "GObject", name = "Object"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GObject", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "property_name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the name of the property to get", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "value", argType = TInterface (Name {namespace = "GObject", name = "Value"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "return location for the property value", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_object_get_property" g_object_get_property :: 
    Ptr Object ->                           -- object : TInterface (Name {namespace = "GObject", name = "Object"})
    CString ->                              -- property_name : TBasicType TUTF8
    Ptr GValue ->                           -- value : TInterface (Name {namespace = "GObject", name = "Value"})
    IO ()

{- |
Gets a property of an object. /@value@/ must have been initialized to the
expected type of the property (or a type to which the expected type can be
transformed) using 'GI.GObject.Structs.Value.valueInit'.

In general, a copy is made of the property contents and the caller is
responsible for freeing the memory by calling 'GI.GObject.Structs.Value.valueUnset'.

Note that 'GI.GObject.Objects.Object.objectGetProperty' is really intended for language
bindings, @/g_object_get()/@ is much more convenient for C programming.
-}
objectGetProperty ::
    (B.CallStack.HasCallStack, MonadIO m, IsObject a) =>
    a
    {- ^ /@object@/: a 'GI.GObject.Objects.Object.Object' -}
    -> T.Text
    {- ^ /@propertyName@/: the name of the property to get -}
    -> GValue
    {- ^ /@value@/: return location for the property value -}
    -> m ()
objectGetProperty object propertyName value = liftIO $ do
    object' <- unsafeManagedPtrCastPtr object
    propertyName' <- textToCString propertyName
    value' <- unsafeManagedPtrGetPtr value
    g_object_get_property object' propertyName' value'
    touchManagedPtr object
    touchManagedPtr value
    freeMem propertyName'
    return ()

data ObjectGetPropertyMethodInfo
instance (signature ~ (T.Text -> GValue -> m ()), MonadIO m, IsObject a) => O.MethodInfo ObjectGetPropertyMethodInfo a signature where
    overloadedMethod _ = objectGetProperty

-- method Object::get_qdata
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "object", argType = TInterface (Name {namespace = "GObject", name = "Object"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "The GObject to get a stored user data pointer from", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "quark", argType = TBasicType TUInt32, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A #GQuark, naming the user data pointer", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TPtr)
-- throws : False
-- Skip return : False

foreign import ccall "g_object_get_qdata" g_object_get_qdata :: 
    Ptr Object ->                           -- object : TInterface (Name {namespace = "GObject", name = "Object"})
    Word32 ->                               -- quark : TBasicType TUInt32
    IO (Ptr ())

{- |
This function gets back user data pointers stored via
@/g_object_set_qdata()/@.
-}
objectGetQdata ::
    (B.CallStack.HasCallStack, MonadIO m, IsObject a) =>
    a
    {- ^ /@object@/: The GObject to get a stored user data pointer from -}
    -> Word32
    {- ^ /@quark@/: A @/GQuark/@, naming the user data pointer -}
    -> m (Ptr ())
    {- ^ __Returns:__ The user data pointer set, or 'Nothing' -}
objectGetQdata object quark = liftIO $ do
    object' <- unsafeManagedPtrCastPtr object
    result <- g_object_get_qdata object' quark
    touchManagedPtr object
    return result

data ObjectGetQdataMethodInfo
instance (signature ~ (Word32 -> m (Ptr ())), MonadIO m, IsObject a) => O.MethodInfo ObjectGetQdataMethodInfo a signature where
    overloadedMethod _ = objectGetQdata

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

foreign import ccall "g_object_is_floating" g_object_is_floating :: 
    Ptr Object ->                           -- object : TInterface (Name {namespace = "GObject", name = "Object"})
    IO CInt

{- |
Checks whether /@object@/ has a [floating][floating-ref] reference.

@since 2.10
-}
objectIsFloating ::
    (B.CallStack.HasCallStack, MonadIO m, IsObject a) =>
    a
    {- ^ /@object@/: a 'GI.GObject.Objects.Object.Object' -}
    -> m Bool
    {- ^ __Returns:__ 'True' if /@object@/ has a floating reference -}
objectIsFloating object = liftIO $ do
    object' <- unsafeManagedPtrCastPtr object
    result <- g_object_is_floating object'
    let result' = (/= 0) result
    touchManagedPtr object
    return result'

data ObjectIsFloatingMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsObject a) => O.MethodInfo ObjectIsFloatingMethodInfo a signature where
    overloadedMethod _ = objectIsFloating

-- method Object::notify
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "object", argType = TInterface (Name {namespace = "GObject", name = "Object"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GObject", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "property_name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the name of a property installed on the class of @object.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_object_notify" g_object_notify :: 
    Ptr Object ->                           -- object : TInterface (Name {namespace = "GObject", name = "Object"})
    CString ->                              -- property_name : TBasicType TUTF8
    IO ()

{- |
Emits a \"notify\" signal for the property /@propertyName@/ on /@object@/.

When possible, eg. when signaling a property change from within the class
that registered the property, you should use 'GI.GObject.Objects.Object.objectNotifyByPspec'
instead.

Note that emission of the notify signal may be blocked with
'GI.GObject.Objects.Object.objectFreezeNotify'. In this case, the signal emissions are queued
and will be emitted (in reverse order) when 'GI.GObject.Objects.Object.objectThawNotify' is
called.
-}
objectNotify ::
    (B.CallStack.HasCallStack, MonadIO m, IsObject a) =>
    a
    {- ^ /@object@/: a 'GI.GObject.Objects.Object.Object' -}
    -> T.Text
    {- ^ /@propertyName@/: the name of a property installed on the class of /@object@/. -}
    -> m ()
objectNotify object propertyName = liftIO $ do
    object' <- unsafeManagedPtrCastPtr object
    propertyName' <- textToCString propertyName
    g_object_notify object' propertyName'
    touchManagedPtr object
    freeMem propertyName'
    return ()

data ObjectNotifyMethodInfo
instance (signature ~ (T.Text -> m ()), MonadIO m, IsObject a) => O.MethodInfo ObjectNotifyMethodInfo a signature where
    overloadedMethod _ = objectNotify

-- method Object::notify_by_pspec
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "object", argType = TInterface (Name {namespace = "GObject", name = "Object"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GObject", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "pspec", argType = TParamSpec, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GParamSpec of a property installed on the class of @object.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_object_notify_by_pspec" g_object_notify_by_pspec :: 
    Ptr Object ->                           -- object : TInterface (Name {namespace = "GObject", name = "Object"})
    Ptr GParamSpec ->                       -- pspec : TParamSpec
    IO ()

{- |
Emits a \"notify\" signal for the property specified by /@pspec@/ on /@object@/.

This function omits the property name lookup, hence it is faster than
'GI.GObject.Objects.Object.objectNotify'.

One way to avoid using 'GI.GObject.Objects.Object.objectNotify' from within the
class that registered the properties, and using 'GI.GObject.Objects.Object.objectNotifyByPspec'
instead, is to store the GParamSpec used with
'GI.GObject.Structs.ObjectClass.objectClassInstallProperty' inside a static array, e.g.:


=== /C code/
>
>  enum
>  {
>    PROP_0,
>    PROP_FOO,
>    PROP_LAST
>  };
>
>  static GParamSpec *properties[PROP_LAST];
>
>  static void
>  my_object_class_init (MyObjectClass *klass)
>  {
>    properties[PROP_FOO] = g_param_spec_int ("foo", "Foo", "The foo",
>                                             0, 100,
>                                             50,
>                                             G_PARAM_READWRITE);
>    g_object_class_install_property (gobject_class,
>                                     PROP_FOO,
>                                     properties[PROP_FOO]);
>  }


and then notify a change on the \"foo\" property with:


=== /C code/
>
>  g_object_notify_by_pspec (self, properties[PROP_FOO]);

@since 2.26
-}
objectNotifyByPspec ::
    (B.CallStack.HasCallStack, MonadIO m, IsObject a) =>
    a
    {- ^ /@object@/: a 'GI.GObject.Objects.Object.Object' -}
    -> GParamSpec
    {- ^ /@pspec@/: the 'GI.GObject.Objects.ParamSpec.ParamSpec' of a property installed on the class of /@object@/. -}
    -> m ()
objectNotifyByPspec object pspec = liftIO $ do
    object' <- unsafeManagedPtrCastPtr object
    pspec' <- unsafeManagedPtrGetPtr pspec
    g_object_notify_by_pspec object' pspec'
    touchManagedPtr object
    touchManagedPtr pspec
    return ()

data ObjectNotifyByPspecMethodInfo
instance (signature ~ (GParamSpec -> m ()), MonadIO m, IsObject a) => O.MethodInfo ObjectNotifyByPspecMethodInfo a signature where
    overloadedMethod _ = objectNotifyByPspec

-- method Object::ref
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "object", argType = TInterface (Name {namespace = "GObject", name = "Object"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GObject", 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_object_ref" g_object_ref :: 
    Ptr Object ->                           -- object : TInterface (Name {namespace = "GObject", name = "Object"})
    IO (Ptr Object)

{- |
Increases the reference count of /@object@/.
-}
objectRef ::
    (B.CallStack.HasCallStack, MonadIO m, IsObject a) =>
    a
    {- ^ /@object@/: a 'GI.GObject.Objects.Object.Object' -}
    -> m Object
    {- ^ __Returns:__ the same /@object@/ -}
objectRef object = liftIO $ do
    object' <- unsafeManagedPtrCastPtr object
    result <- g_object_ref object'
    checkUnexpectedReturnNULL "objectRef" result
    result' <- (newObject Object) result
    touchManagedPtr object
    return result'

data ObjectRefMethodInfo
instance (signature ~ (m Object), MonadIO m, IsObject a) => O.MethodInfo ObjectRefMethodInfo a signature where
    overloadedMethod _ = objectRef

-- method Object::ref_sink
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "object", argType = TInterface (Name {namespace = "GObject", name = "Object"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GObject", 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_object_ref_sink" g_object_ref_sink :: 
    Ptr Object ->                           -- object : TInterface (Name {namespace = "GObject", name = "Object"})
    IO (Ptr Object)

{- |
Increase the reference count of /@object@/, and possibly remove the
[floating][floating-ref] reference, if /@object@/ has a floating reference.

In other words, if the object is floating, then this call \"assumes
ownership\" of the floating reference, converting it to a normal
reference by clearing the floating flag while leaving the reference
count unchanged.  If the object is not floating, then this call
adds a new normal reference increasing the reference count by one.

@since 2.10
-}
objectRefSink ::
    (B.CallStack.HasCallStack, MonadIO m, IsObject a) =>
    a
    {- ^ /@object@/: a 'GI.GObject.Objects.Object.Object' -}
    -> m Object
    {- ^ __Returns:__ /@object@/ -}
objectRefSink object = liftIO $ do
    object' <- unsafeManagedPtrCastPtr object
    result <- g_object_ref_sink object'
    checkUnexpectedReturnNULL "objectRefSink" result
    result' <- (newObject Object) result
    touchManagedPtr object
    return result'

data ObjectRefSinkMethodInfo
instance (signature ~ (m Object), MonadIO m, IsObject a) => O.MethodInfo ObjectRefSinkMethodInfo a signature where
    overloadedMethod _ = objectRefSink

-- method Object::replace_data
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "object", argType = TInterface (Name {namespace = "GObject", name = "Object"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GObject to store user data on", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "key", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a string, naming the user data pointer", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "oldval", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the old value to compare against", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "newval", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the new value", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "destroy", argType = TInterface (Name {namespace = "GLib", name = "DestroyNotify"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a destroy notify for the new value", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "old_destroy", argType = TInterface (Name {namespace = "GLib", name = "DestroyNotify"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "destroy notify for the existing value", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "g_object_replace_data" g_object_replace_data :: 
    Ptr Object ->                           -- object : TInterface (Name {namespace = "GObject", name = "Object"})
    CString ->                              -- key : TBasicType TUTF8
    Ptr () ->                               -- oldval : TBasicType TPtr
    Ptr () ->                               -- newval : TBasicType TPtr
    FunPtr GLib.Callbacks.C_DestroyNotify -> -- destroy : TInterface (Name {namespace = "GLib", name = "DestroyNotify"})
    FunPtr GLib.Callbacks.C_DestroyNotify -> -- old_destroy : TInterface (Name {namespace = "GLib", name = "DestroyNotify"})
    IO CInt

{- |
Compares the user data for the key /@key@/ on /@object@/ with
/@oldval@/, and if they are the same, replaces /@oldval@/ with
/@newval@/.

This is like a typical atomic compare-and-exchange
operation, for user data on an object.

If the previous value was replaced then ownership of the
old value (/@oldval@/) is passed to the caller, including
the registered destroy notify for it (passed out in /@oldDestroy@/).
Its up to the caller to free this as he wishes, which may
or may not include using /@oldDestroy@/ as sometimes replacement
should not destroy the object in the normal way.

@since 2.34
-}
objectReplaceData ::
    (B.CallStack.HasCallStack, MonadIO m, IsObject a) =>
    a
    {- ^ /@object@/: the 'GI.GObject.Objects.Object.Object' to store user data on -}
    -> T.Text
    {- ^ /@key@/: a string, naming the user data pointer -}
    -> Ptr ()
    {- ^ /@oldval@/: the old value to compare against -}
    -> Ptr ()
    {- ^ /@newval@/: the new value -}
    -> Maybe (GLib.Callbacks.DestroyNotify)
    {- ^ /@destroy@/: a destroy notify for the new value -}
    -> Maybe (GLib.Callbacks.DestroyNotify)
    {- ^ /@oldDestroy@/: destroy notify for the existing value -}
    -> m Bool
    {- ^ __Returns:__ 'True' if the existing value for /@key@/ was replaced
 by /@newval@/, 'False' otherwise. -}
objectReplaceData object key oldval newval destroy oldDestroy = liftIO $ do
    object' <- unsafeManagedPtrCastPtr object
    key' <- textToCString key
    ptrdestroy <- callocMem :: IO (Ptr (FunPtr GLib.Callbacks.C_DestroyNotify))
    maybeDestroy <- case destroy of
        Nothing -> return (castPtrToFunPtr nullPtr)
        Just jDestroy -> do
            jDestroy' <- GLib.Callbacks.mk_DestroyNotify (GLib.Callbacks.wrap_DestroyNotify (Just ptrdestroy) jDestroy)
            poke ptrdestroy jDestroy'
            return jDestroy'
    ptroldDestroy <- callocMem :: IO (Ptr (FunPtr GLib.Callbacks.C_DestroyNotify))
    maybeOldDestroy <- case oldDestroy of
        Nothing -> return (castPtrToFunPtr nullPtr)
        Just jOldDestroy -> do
            jOldDestroy' <- GLib.Callbacks.mk_DestroyNotify (GLib.Callbacks.wrap_DestroyNotify (Just ptroldDestroy) jOldDestroy)
            poke ptroldDestroy jOldDestroy'
            return jOldDestroy'
    result <- g_object_replace_data object' key' oldval newval maybeDestroy maybeOldDestroy
    let result' = (/= 0) result
    touchManagedPtr object
    freeMem key'
    return result'

data ObjectReplaceDataMethodInfo
instance (signature ~ (T.Text -> Ptr () -> Ptr () -> Maybe (GLib.Callbacks.DestroyNotify) -> Maybe (GLib.Callbacks.DestroyNotify) -> m Bool), MonadIO m, IsObject a) => O.MethodInfo ObjectReplaceDataMethodInfo a signature where
    overloadedMethod _ = objectReplaceData

-- method Object::replace_qdata
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "object", argType = TInterface (Name {namespace = "GObject", name = "Object"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GObject to store user data on", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "quark", argType = TBasicType TUInt32, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GQuark, naming the user data pointer", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "oldval", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the old value to compare against", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "newval", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the new value", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "destroy", argType = TInterface (Name {namespace = "GLib", name = "DestroyNotify"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a destroy notify for the new value", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "old_destroy", argType = TInterface (Name {namespace = "GLib", name = "DestroyNotify"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "destroy notify for the existing value", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "g_object_replace_qdata" g_object_replace_qdata :: 
    Ptr Object ->                           -- object : TInterface (Name {namespace = "GObject", name = "Object"})
    Word32 ->                               -- quark : TBasicType TUInt32
    Ptr () ->                               -- oldval : TBasicType TPtr
    Ptr () ->                               -- newval : TBasicType TPtr
    FunPtr GLib.Callbacks.C_DestroyNotify -> -- destroy : TInterface (Name {namespace = "GLib", name = "DestroyNotify"})
    FunPtr GLib.Callbacks.C_DestroyNotify -> -- old_destroy : TInterface (Name {namespace = "GLib", name = "DestroyNotify"})
    IO CInt

{- |
Compares the user data for the key /@quark@/ on /@object@/ with
/@oldval@/, and if they are the same, replaces /@oldval@/ with
/@newval@/.

This is like a typical atomic compare-and-exchange
operation, for user data on an object.

If the previous value was replaced then ownership of the
old value (/@oldval@/) is passed to the caller, including
the registered destroy notify for it (passed out in /@oldDestroy@/).
Its up to the caller to free this as he wishes, which may
or may not include using /@oldDestroy@/ as sometimes replacement
should not destroy the object in the normal way.

@since 2.34
-}
objectReplaceQdata ::
    (B.CallStack.HasCallStack, MonadIO m, IsObject a) =>
    a
    {- ^ /@object@/: the 'GI.GObject.Objects.Object.Object' to store user data on -}
    -> Word32
    {- ^ /@quark@/: a @/GQuark/@, naming the user data pointer -}
    -> Ptr ()
    {- ^ /@oldval@/: the old value to compare against -}
    -> Ptr ()
    {- ^ /@newval@/: the new value -}
    -> Maybe (GLib.Callbacks.DestroyNotify)
    {- ^ /@destroy@/: a destroy notify for the new value -}
    -> Maybe (GLib.Callbacks.DestroyNotify)
    {- ^ /@oldDestroy@/: destroy notify for the existing value -}
    -> m Bool
    {- ^ __Returns:__ 'True' if the existing value for /@quark@/ was replaced
 by /@newval@/, 'False' otherwise. -}
objectReplaceQdata object quark oldval newval destroy oldDestroy = liftIO $ do
    object' <- unsafeManagedPtrCastPtr object
    ptrdestroy <- callocMem :: IO (Ptr (FunPtr GLib.Callbacks.C_DestroyNotify))
    maybeDestroy <- case destroy of
        Nothing -> return (castPtrToFunPtr nullPtr)
        Just jDestroy -> do
            jDestroy' <- GLib.Callbacks.mk_DestroyNotify (GLib.Callbacks.wrap_DestroyNotify (Just ptrdestroy) jDestroy)
            poke ptrdestroy jDestroy'
            return jDestroy'
    ptroldDestroy <- callocMem :: IO (Ptr (FunPtr GLib.Callbacks.C_DestroyNotify))
    maybeOldDestroy <- case oldDestroy of
        Nothing -> return (castPtrToFunPtr nullPtr)
        Just jOldDestroy -> do
            jOldDestroy' <- GLib.Callbacks.mk_DestroyNotify (GLib.Callbacks.wrap_DestroyNotify (Just ptroldDestroy) jOldDestroy)
            poke ptroldDestroy jOldDestroy'
            return jOldDestroy'
    result <- g_object_replace_qdata object' quark oldval newval maybeDestroy maybeOldDestroy
    let result' = (/= 0) result
    touchManagedPtr object
    return result'

data ObjectReplaceQdataMethodInfo
instance (signature ~ (Word32 -> Ptr () -> Ptr () -> Maybe (GLib.Callbacks.DestroyNotify) -> Maybe (GLib.Callbacks.DestroyNotify) -> m Bool), MonadIO m, IsObject a) => O.MethodInfo ObjectReplaceQdataMethodInfo a signature where
    overloadedMethod _ = objectReplaceQdata

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

foreign import ccall "g_object_run_dispose" g_object_run_dispose :: 
    Ptr Object ->                           -- object : TInterface (Name {namespace = "GObject", name = "Object"})
    IO ()

{- |
Releases all references to other objects. This can be used to break
reference cycles.

This function should only be called from object system implementations.
-}
objectRunDispose ::
    (B.CallStack.HasCallStack, MonadIO m, IsObject a) =>
    a
    {- ^ /@object@/: a 'GI.GObject.Objects.Object.Object' -}
    -> m ()
objectRunDispose object = liftIO $ do
    object' <- unsafeManagedPtrCastPtr object
    g_object_run_dispose object'
    touchManagedPtr object
    return ()

data ObjectRunDisposeMethodInfo
instance (signature ~ (m ()), MonadIO m, IsObject a) => O.MethodInfo ObjectRunDisposeMethodInfo a signature where
    overloadedMethod _ = objectRunDispose

-- method Object::set_data
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "object", argType = TInterface (Name {namespace = "GObject", name = "Object"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "#GObject containing the associations.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "key", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "name of the key", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "data to associate with that key", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_object_set_data" g_object_set_data :: 
    Ptr Object ->                           -- object : TInterface (Name {namespace = "GObject", name = "Object"})
    CString ->                              -- key : TBasicType TUTF8
    Ptr () ->                               -- data : TBasicType TPtr
    IO ()

{- |
Each object carries around a table of associations from
strings to pointers.  This function lets you set an association.

If the object already had an association with that name,
the old association will be destroyed.
-}
objectSetData ::
    (B.CallStack.HasCallStack, MonadIO m, IsObject a) =>
    a
    {- ^ /@object@/: 'GI.GObject.Objects.Object.Object' containing the associations. -}
    -> T.Text
    {- ^ /@key@/: name of the key -}
    -> Ptr ()
    {- ^ /@data@/: data to associate with that key -}
    -> m ()
objectSetData object key data_ = liftIO $ do
    object' <- unsafeManagedPtrCastPtr object
    key' <- textToCString key
    g_object_set_data object' key' data_
    touchManagedPtr object
    freeMem key'
    return ()

data ObjectSetDataMethodInfo
instance (signature ~ (T.Text -> Ptr () -> m ()), MonadIO m, IsObject a) => O.MethodInfo ObjectSetDataMethodInfo a signature where
    overloadedMethod _ = objectSetData

-- method Object::set_property
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "object", argType = TInterface (Name {namespace = "GObject", name = "Object"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GObject", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "property_name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the name of the property to set", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "value", argType = TInterface (Name {namespace = "GObject", name = "Value"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the value", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_object_set_property" g_object_set_property :: 
    Ptr Object ->                           -- object : TInterface (Name {namespace = "GObject", name = "Object"})
    CString ->                              -- property_name : TBasicType TUTF8
    Ptr GValue ->                           -- value : TInterface (Name {namespace = "GObject", name = "Value"})
    IO ()

{- |
Sets a property on an object.
-}
objectSetProperty ::
    (B.CallStack.HasCallStack, MonadIO m, IsObject a) =>
    a
    {- ^ /@object@/: a 'GI.GObject.Objects.Object.Object' -}
    -> T.Text
    {- ^ /@propertyName@/: the name of the property to set -}
    -> GValue
    {- ^ /@value@/: the value -}
    -> m ()
objectSetProperty object propertyName value = liftIO $ do
    object' <- unsafeManagedPtrCastPtr object
    propertyName' <- textToCString propertyName
    value' <- unsafeManagedPtrGetPtr value
    g_object_set_property object' propertyName' value'
    touchManagedPtr object
    touchManagedPtr value
    freeMem propertyName'
    return ()

data ObjectSetPropertyMethodInfo
instance (signature ~ (T.Text -> GValue -> m ()), MonadIO m, IsObject a) => O.MethodInfo ObjectSetPropertyMethodInfo a signature where
    overloadedMethod _ = objectSetProperty

-- method Object::steal_data
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "object", argType = TInterface (Name {namespace = "GObject", name = "Object"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "#GObject containing the associations", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "key", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "name of the key", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TPtr)
-- throws : False
-- Skip return : False

foreign import ccall "g_object_steal_data" g_object_steal_data :: 
    Ptr Object ->                           -- object : TInterface (Name {namespace = "GObject", name = "Object"})
    CString ->                              -- key : TBasicType TUTF8
    IO (Ptr ())

{- |
Remove a specified datum from the object\'s data associations,
without invoking the association\'s destroy handler.
-}
objectStealData ::
    (B.CallStack.HasCallStack, MonadIO m, IsObject a) =>
    a
    {- ^ /@object@/: 'GI.GObject.Objects.Object.Object' containing the associations -}
    -> T.Text
    {- ^ /@key@/: name of the key -}
    -> m (Ptr ())
    {- ^ __Returns:__ the data if found, or 'Nothing' if no such data exists. -}
objectStealData object key = liftIO $ do
    object' <- unsafeManagedPtrCastPtr object
    key' <- textToCString key
    result <- g_object_steal_data object' key'
    touchManagedPtr object
    freeMem key'
    return result

data ObjectStealDataMethodInfo
instance (signature ~ (T.Text -> m (Ptr ())), MonadIO m, IsObject a) => O.MethodInfo ObjectStealDataMethodInfo a signature where
    overloadedMethod _ = objectStealData

-- method Object::steal_qdata
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "object", argType = TInterface (Name {namespace = "GObject", name = "Object"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "The GObject to get a stored user data pointer from", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "quark", argType = TBasicType TUInt32, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A #GQuark, naming the user data pointer", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TPtr)
-- throws : False
-- Skip return : False

foreign import ccall "g_object_steal_qdata" g_object_steal_qdata :: 
    Ptr Object ->                           -- object : TInterface (Name {namespace = "GObject", name = "Object"})
    Word32 ->                               -- quark : TBasicType TUInt32
    IO (Ptr ())

{- |
This function gets back user data pointers stored via
@/g_object_set_qdata()/@ and removes the /@data@/ from object
without invoking its @/destroy()/@ function (if any was
set).
Usually, calling this function is only required to update
user data pointers with a destroy notifier, for example:

=== /C code/
>
>void
>object_add_to_user_list (GObject     *object,
>                         const gchar *new_string)
>{
>  // the quark, naming the object data
>  GQuark quark_string_list = g_quark_from_static_string ("my-string-list");
>  // retrive the old string list
>  GList *list = g_object_steal_qdata (object, quark_string_list);
>
>  // prepend new string
>  list = g_list_prepend (list, g_strdup (new_string));
>  // this changed 'list', so we need to set it again
>  g_object_set_qdata_full (object, quark_string_list, list, free_string_list);
>}
>static void
>free_string_list (gpointer data)
>{
>  GList *node, *list = data;
>
>  for (node = list; node; node = node->next)
>    g_free (node->data);
>  g_list_free (list);
>}

Using 'GI.GObject.Objects.Object.objectGetQdata' in the above example, instead of
'GI.GObject.Objects.Object.objectStealQdata' would have left the destroy function set,
and thus the partial string list would have been freed upon
@/g_object_set_qdata_full()/@.
-}
objectStealQdata ::
    (B.CallStack.HasCallStack, MonadIO m, IsObject a) =>
    a
    {- ^ /@object@/: The GObject to get a stored user data pointer from -}
    -> Word32
    {- ^ /@quark@/: A @/GQuark/@, naming the user data pointer -}
    -> m (Ptr ())
    {- ^ __Returns:__ The user data pointer set, or 'Nothing' -}
objectStealQdata object quark = liftIO $ do
    object' <- unsafeManagedPtrCastPtr object
    result <- g_object_steal_qdata object' quark
    touchManagedPtr object
    return result

data ObjectStealQdataMethodInfo
instance (signature ~ (Word32 -> m (Ptr ())), MonadIO m, IsObject a) => O.MethodInfo ObjectStealQdataMethodInfo a signature where
    overloadedMethod _ = objectStealQdata

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

foreign import ccall "g_object_thaw_notify" g_object_thaw_notify :: 
    Ptr Object ->                           -- object : TInterface (Name {namespace = "GObject", name = "Object"})
    IO ()

{- |
Reverts the effect of a previous call to
'GI.GObject.Objects.Object.objectFreezeNotify'. The freeze count is decreased on /@object@/
and when it reaches zero, queued \"notify\" signals are emitted.

Duplicate notifications for each property are squashed so that at most one
'GI.GObject.Objects.Object.Object'::@/notify/@ signal is emitted for each property, in the reverse order
in which they have been queued.

It is an error to call this function when the freeze count is zero.
-}
objectThawNotify ::
    (B.CallStack.HasCallStack, MonadIO m, IsObject a) =>
    a
    {- ^ /@object@/: a 'GI.GObject.Objects.Object.Object' -}
    -> m ()
objectThawNotify object = liftIO $ do
    object' <- unsafeManagedPtrCastPtr object
    g_object_thaw_notify object'
    touchManagedPtr object
    return ()

data ObjectThawNotifyMethodInfo
instance (signature ~ (m ()), MonadIO m, IsObject a) => O.MethodInfo ObjectThawNotifyMethodInfo a signature where
    overloadedMethod _ = objectThawNotify

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

foreign import ccall "g_object_unref" g_object_unref :: 
    Ptr Object ->                           -- object : TInterface (Name {namespace = "GObject", name = "Object"})
    IO ()

{- |
Decreases the reference count of /@object@/. When its reference count
drops to 0, the object is finalized (i.e. its memory is freed).

If the pointer to the 'GI.GObject.Objects.Object.Object' may be reused in future (for example, if it is
an instance variable of another object), it is recommended to clear the
pointer to 'Nothing' rather than retain a dangling pointer to a potentially
invalid 'GI.GObject.Objects.Object.Object' instance. Use @/g_clear_object()/@ for this.
-}
objectUnref ::
    (B.CallStack.HasCallStack, MonadIO m, IsObject a) =>
    a
    {- ^ /@object@/: a 'GI.GObject.Objects.Object.Object' -}
    -> m ()
objectUnref object = liftIO $ do
    object' <- unsafeManagedPtrCastPtr object
    g_object_unref object'
    touchManagedPtr object
    return ()

data ObjectUnrefMethodInfo
instance (signature ~ (m ()), MonadIO m, IsObject a) => O.MethodInfo ObjectUnrefMethodInfo a signature where
    overloadedMethod _ = objectUnref

-- method Object::watch_closure
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "object", argType = TInterface (Name {namespace = "GObject", name = "Object"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "GObject restricting lifetime of @closure", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "closure", argType = TInterface (Name {namespace = "GObject", name = "Closure"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "GClosure to watch", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_object_watch_closure" g_object_watch_closure :: 
    Ptr Object ->                           -- object : TInterface (Name {namespace = "GObject", name = "Object"})
    Ptr Closure ->                          -- closure : TInterface (Name {namespace = "GObject", name = "Closure"})
    IO ()

{- |
This function essentially limits the life time of the /@closure@/ to
the life time of the object. That is, when the object is finalized,
the /@closure@/ is invalidated by calling 'GI.GObject.Structs.Closure.closureInvalidate' on
it, in order to prevent invocations of the closure with a finalized
(nonexisting) object. Also, 'GI.GObject.Objects.Object.objectRef' and 'GI.GObject.Objects.Object.objectUnref' are
added as marshal guards to the /@closure@/, to ensure that an extra
reference count is held on /@object@/ during invocation of the
/@closure@/.  Usually, this function will be called on closures that
use this /@object@/ as closure data.
-}
objectWatchClosure ::
    (B.CallStack.HasCallStack, MonadIO m, IsObject a) =>
    a
    {- ^ /@object@/: GObject restricting lifetime of /@closure@/ -}
    -> Closure
    {- ^ /@closure@/: GClosure to watch -}
    -> m ()
objectWatchClosure object closure = liftIO $ do
    object' <- unsafeManagedPtrCastPtr object
    closure' <- unsafeManagedPtrGetPtr closure
    g_object_watch_closure object' closure'
    touchManagedPtr object
    touchManagedPtr closure
    return ()

data ObjectWatchClosureMethodInfo
instance (signature ~ (Closure -> m ()), MonadIO m, IsObject a) => O.MethodInfo ObjectWatchClosureMethodInfo a signature where
    overloadedMethod _ = objectWatchClosure

-- method Object::compat_control
-- method type : MemberFunction
-- Args : [Arg {argCName = "what", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUInt64)
-- throws : False
-- Skip return : False

foreign import ccall "g_object_compat_control" g_object_compat_control :: 
    Word64 ->                               -- what : TBasicType TUInt64
    Ptr () ->                               -- data : TBasicType TPtr
    IO Word64

{- |
/No description available in the introspection data./
-}
objectCompatControl ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Word64
    -> Ptr ()
    -> m Word64
objectCompatControl what data_ = liftIO $ do
    result <- g_object_compat_control what data_
    return result

-- method Object::interface_find_property
-- method type : MemberFunction
-- Args : [Arg {argCName = "g_iface", argType = TInterface (Name {namespace = "GObject", name = "TypeInterface"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "any interface vtable for the\n interface, or the default vtable for the interface", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "property_name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "name of a property to lookup.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just TParamSpec
-- throws : False
-- Skip return : False

foreign import ccall "g_object_interface_find_property" g_object_interface_find_property :: 
    Ptr GObject.TypeInterface.TypeInterface -> -- g_iface : TInterface (Name {namespace = "GObject", name = "TypeInterface"})
    CString ->                              -- property_name : TBasicType TUTF8
    IO (Ptr GParamSpec)

{- |
Find the 'GI.GObject.Objects.ParamSpec.ParamSpec' with the given name for an
interface. Generally, the interface vtable passed in as /@gIface@/
will be the default vtable from 'GI.GObject.Functions.typeDefaultInterfaceRef', or,
if you know the interface has already been loaded,
'GI.GObject.Functions.typeDefaultInterfacePeek'.

@since 2.4
-}
objectInterfaceFindProperty ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    GObject.TypeInterface.TypeInterface
    {- ^ /@gIface@/: any interface vtable for the
 interface, or the default vtable for the interface -}
    -> T.Text
    {- ^ /@propertyName@/: name of a property to lookup. -}
    -> m GParamSpec
    {- ^ __Returns:__ the 'GI.GObject.Objects.ParamSpec.ParamSpec' for the property of the
         interface with the name /@propertyName@/, or 'Nothing' if no
         such property exists. -}
objectInterfaceFindProperty gIface propertyName = liftIO $ do
    gIface' <- unsafeManagedPtrGetPtr gIface
    propertyName' <- textToCString propertyName
    result <- g_object_interface_find_property gIface' propertyName'
    checkUnexpectedReturnNULL "objectInterfaceFindProperty" result
    result' <- newGParamSpecFromPtr result
    touchManagedPtr gIface
    freeMem propertyName'
    return result'

-- method Object::interface_install_property
-- method type : MemberFunction
-- Args : [Arg {argCName = "g_iface", argType = TInterface (Name {namespace = "GObject", name = "TypeInterface"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "any interface vtable for the\n   interface, or the default\n vtable for the interface.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "pspec", argType = TParamSpec, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GParamSpec for the new property", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_object_interface_install_property" g_object_interface_install_property :: 
    Ptr GObject.TypeInterface.TypeInterface -> -- g_iface : TInterface (Name {namespace = "GObject", name = "TypeInterface"})
    Ptr GParamSpec ->                       -- pspec : TParamSpec
    IO ()

{- |
Add a property to an interface; this is only useful for interfaces
that are added to GObject-derived types. Adding a property to an
interface forces all objects classes with that interface to have a
compatible property. The compatible property could be a newly
created 'GI.GObject.Objects.ParamSpec.ParamSpec', but normally
'GI.GObject.Structs.ObjectClass.objectClassOverrideProperty' will be used so that the object
class only needs to provide an implementation and inherits the
property description, default value, bounds, and so forth from the
interface property.

This function is meant to be called from the interface\'s default
vtable initialization function (the /@classInit@/ member of
'GI.GObject.Structs.TypeInfo.TypeInfo'.) It must not be called after after /@classInit@/ has
been called for any object types implementing this interface.

@since 2.4
-}
objectInterfaceInstallProperty ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    GObject.TypeInterface.TypeInterface
    {- ^ /@gIface@/: any interface vtable for the
   interface, or the default
 vtable for the interface. -}
    -> GParamSpec
    {- ^ /@pspec@/: the 'GI.GObject.Objects.ParamSpec.ParamSpec' for the new property -}
    -> m ()
objectInterfaceInstallProperty gIface pspec = liftIO $ do
    gIface' <- unsafeManagedPtrGetPtr gIface
    pspec' <- unsafeManagedPtrGetPtr pspec
    g_object_interface_install_property gIface' pspec'
    touchManagedPtr gIface
    touchManagedPtr pspec
    return ()

-- XXX Could not generate method Object::interface_list_properties
-- Error was : Not implemented: "unpackCArray : Don't know how to unpack C Array of type TParamSpec"
-- XXX: Dummy instance, since code generation failed.
-- Please file a bug at http://github.com/haskell-gi/haskell-gi.
data ObjectInterfaceListPropertiesMethodInfo
instance (p ~ (), o ~ O.MethodResolutionFailed "interfaceListProperties" Object) => O.MethodInfo ObjectInterfaceListPropertiesMethodInfo o p where
    overloadedMethod _ = undefined