{-# LANGUAGE TypeApplications #-}


-- | Copyright  : Will Thompson and Iñaki García Etxebarria
-- License    : LGPL-2.1
-- Maintainer : Iñaki García Etxebarria
-- 
-- The event dispatcher holds all the events and hooks and dispatches them. It orchestras the show on event stack.

#if (MIN_VERSION_haskell_gi_overloading(1,0,0) && !defined(__HADDOCK_VERSION__))
#define ENABLE_OVERLOADING
#endif

module GI.Wp.Objects.EventDispatcher
    ( 

-- * Exported types
    EventDispatcher(..)                     ,
    IsEventDispatcher                       ,
    toEventDispatcher                       ,


 -- * Methods
-- | 
-- 
--  === __Click to display all available methods, including inherited ones__
-- ==== Methods
-- [bindProperty]("GI.GObject.Objects.Object#g:method:bindProperty"), [bindPropertyFull]("GI.GObject.Objects.Object#g:method:bindPropertyFull"), [forceFloating]("GI.GObject.Objects.Object#g:method:forceFloating"), [freezeNotify]("GI.GObject.Objects.Object#g:method:freezeNotify"), [getv]("GI.GObject.Objects.Object#g:method:getv"), [isFloating]("GI.GObject.Objects.Object#g:method:isFloating"), [newHooksForEventTypeIterator]("GI.Wp.Objects.EventDispatcher#g:method:newHooksForEventTypeIterator"), [newHooksIterator]("GI.Wp.Objects.EventDispatcher#g:method:newHooksIterator"), [notify]("GI.GObject.Objects.Object#g:method:notify"), [notifyByPspec]("GI.GObject.Objects.Object#g:method:notifyByPspec"), [pushEvent]("GI.Wp.Objects.EventDispatcher#g:method:pushEvent"), [ref]("GI.GObject.Objects.Object#g:method:ref"), [refSink]("GI.GObject.Objects.Object#g:method:refSink"), [registerHook]("GI.Wp.Objects.EventDispatcher#g:method:registerHook"), [runDispose]("GI.GObject.Objects.Object#g:method:runDispose"), [stealData]("GI.GObject.Objects.Object#g:method:stealData"), [stealQdata]("GI.GObject.Objects.Object#g:method:stealQdata"), [thawNotify]("GI.GObject.Objects.Object#g:method:thawNotify"), [unref]("GI.GObject.Objects.Object#g:method:unref"), [unregisterHook]("GI.Wp.Objects.EventDispatcher#g:method:unregisterHook"), [watchClosure]("GI.GObject.Objects.Object#g:method:watchClosure").
-- 
-- ==== Getters
-- [getData]("GI.GObject.Objects.Object#g:method:getData"), [getProperty]("GI.GObject.Objects.Object#g:method:getProperty"), [getQdata]("GI.GObject.Objects.Object#g:method:getQdata").
-- 
-- ==== Setters
-- [setData]("GI.GObject.Objects.Object#g:method:setData"), [setDataFull]("GI.GObject.Objects.Object#g:method:setDataFull"), [setProperty]("GI.GObject.Objects.Object#g:method:setProperty").

#if defined(ENABLE_OVERLOADING)
    ResolveEventDispatcherMethod            ,
#endif

-- ** getInstance #method:getInstance#

    eventDispatcherGetInstance              ,


-- ** newHooksForEventTypeIterator #method:newHooksForEventTypeIterator#

#if defined(ENABLE_OVERLOADING)
    EventDispatcherNewHooksForEventTypeIteratorMethodInfo,
#endif
    eventDispatcherNewHooksForEventTypeIterator,


-- ** newHooksIterator #method:newHooksIterator#

#if defined(ENABLE_OVERLOADING)
    EventDispatcherNewHooksIteratorMethodInfo,
#endif
    eventDispatcherNewHooksIterator         ,


-- ** pushEvent #method:pushEvent#

#if defined(ENABLE_OVERLOADING)
    EventDispatcherPushEventMethodInfo      ,
#endif
    eventDispatcherPushEvent                ,


-- ** registerHook #method:registerHook#

#if defined(ENABLE_OVERLOADING)
    EventDispatcherRegisterHookMethodInfo   ,
#endif
    eventDispatcherRegisterHook             ,


-- ** unregisterHook #method:unregisterHook#

#if defined(ENABLE_OVERLOADING)
    EventDispatcherUnregisterHookMethodInfo ,
#endif
    eventDispatcherUnregisterHook           ,




    ) where

import Data.GI.Base.ShortPrelude
import qualified Data.GI.Base.ShortPrelude as SP
import qualified Data.GI.Base.Overloading as O
import qualified Prelude as P

import qualified Data.GI.Base.Attributes as GI.Attributes
import qualified Data.GI.Base.BasicTypes as B.Types
import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GArray as B.GArray
import qualified Data.GI.Base.GClosure as B.GClosure
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GHashTable as B.GHT
import qualified Data.GI.Base.GVariant as B.GVariant
import qualified Data.GI.Base.GValue as B.GValue
import qualified Data.GI.Base.GParamSpec as B.GParamSpec
import qualified Data.GI.Base.CallStack as B.CallStack
import qualified Data.GI.Base.Properties as B.Properties
import qualified Data.GI.Base.Signals as B.Signals
import qualified Control.Monad.IO.Class as MIO
import qualified Data.Coerce as Coerce
import qualified Data.Text as T
import qualified Data.Kind as DK
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import qualified Foreign.Ptr as FP
import qualified GHC.OverloadedLabels as OL
import qualified GHC.Records as R
import qualified Data.Word as DW
import qualified Data.Int as DI
import qualified System.Posix.Types as SPT
import qualified Foreign.C.Types as FCT

-- Workaround for https://gitlab.haskell.org/ghc/ghc/-/issues/23392
#if MIN_VERSION_base(4,18,0)
import qualified GI.GLib.Callbacks as GLib.Callbacks
import qualified GI.GLib.Structs.MainContext as GLib.MainContext
import qualified GI.GLib.Structs.Source as GLib.Source
import qualified GI.GObject.Objects.Object as GObject.Object
import qualified GI.Gio.Callbacks as Gio.Callbacks
import qualified GI.Gio.Interfaces.AsyncResult as Gio.AsyncResult
import qualified GI.Gio.Objects.Cancellable as Gio.Cancellable
import qualified GI.Wp.Callbacks as Wp.Callbacks
import {-# SOURCE #-} qualified GI.Wp.Enums as Wp.Enums
import {-# SOURCE #-} qualified GI.Wp.Flags as Wp.Flags
import {-# SOURCE #-} qualified GI.Wp.Objects.Conf as Wp.Conf
import {-# SOURCE #-} qualified GI.Wp.Objects.Core as Wp.Core
import {-# SOURCE #-} qualified GI.Wp.Objects.EventHook as Wp.EventHook
import {-# SOURCE #-} qualified GI.Wp.Objects.Object as Wp.Object
import {-# SOURCE #-} qualified GI.Wp.Objects.ObjectManager as Wp.ObjectManager
import {-# SOURCE #-} qualified GI.Wp.Structs.Event as Wp.Event
import {-# SOURCE #-} qualified GI.Wp.Structs.Iterator as Wp.Iterator
import {-# SOURCE #-} qualified GI.Wp.Structs.IteratorMethods as Wp.IteratorMethods
import {-# SOURCE #-} qualified GI.Wp.Structs.ObjectInterest as Wp.ObjectInterest
import {-# SOURCE #-} qualified GI.Wp.Structs.Properties as Wp.Properties
import {-# SOURCE #-} qualified GI.Wp.Structs.SpaJson as Wp.SpaJson

#else
import qualified GI.GObject.Objects.Object as GObject.Object
import {-# SOURCE #-} qualified GI.Wp.Objects.Core as Wp.Core
import {-# SOURCE #-} qualified GI.Wp.Objects.EventHook as Wp.EventHook
import {-# SOURCE #-} qualified GI.Wp.Structs.Event as Wp.Event
import {-# SOURCE #-} qualified GI.Wp.Structs.Iterator as Wp.Iterator

#endif

-- | Memory-managed wrapper type.
newtype EventDispatcher = EventDispatcher (SP.ManagedPtr EventDispatcher)
    deriving (Eq)

instance SP.ManagedPtrNewtype EventDispatcher where
    toManagedPtr (EventDispatcher p) = p

foreign import ccall "wp_event_dispatcher_get_type"
    c_wp_event_dispatcher_get_type :: IO B.Types.GType

instance B.Types.TypedObject EventDispatcher where
    glibType = c_wp_event_dispatcher_get_type

instance B.Types.GObject EventDispatcher

-- | Type class for types which can be safely cast to t'EventDispatcher', for instance with `toEventDispatcher`.
class (SP.GObject o, O.IsDescendantOf EventDispatcher o) => IsEventDispatcher o
instance (SP.GObject o, O.IsDescendantOf EventDispatcher o) => IsEventDispatcher o

instance O.HasParentTypes EventDispatcher
type instance O.ParentTypes EventDispatcher = '[GObject.Object.Object]

-- | Cast to t'EventDispatcher', for types for which this is known to be safe. For general casts, use 'Data.GI.Base.ManagedPtr.castTo'.
toEventDispatcher :: (MIO.MonadIO m, IsEventDispatcher o) => o -> m EventDispatcher
toEventDispatcher = MIO.liftIO . B.ManagedPtr.unsafeCastTo EventDispatcher

-- | Convert t'EventDispatcher' to and from t'Data.GI.Base.GValue.GValue'. See 'Data.GI.Base.GValue.toGValue' and 'Data.GI.Base.GValue.fromGValue'.
instance B.GValue.IsGValue (Maybe EventDispatcher) where
    gvalueGType_ = c_wp_event_dispatcher_get_type
    gvalueSet_ gv P.Nothing = B.GValue.set_object gv (FP.nullPtr :: FP.Ptr EventDispatcher)
    gvalueSet_ gv (P.Just obj) = B.ManagedPtr.withManagedPtr obj (B.GValue.set_object gv)
    gvalueGet_ gv = do
        ptr <- B.GValue.get_object gv :: IO (FP.Ptr EventDispatcher)
        if ptr /= FP.nullPtr
        then P.Just <$> B.ManagedPtr.newObject EventDispatcher ptr
        else return P.Nothing
        
    

#if defined(ENABLE_OVERLOADING)
type family ResolveEventDispatcherMethod (t :: Symbol) (o :: DK.Type) :: DK.Type where
    ResolveEventDispatcherMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
    ResolveEventDispatcherMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
    ResolveEventDispatcherMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
    ResolveEventDispatcherMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
    ResolveEventDispatcherMethod "getv" o = GObject.Object.ObjectGetvMethodInfo
    ResolveEventDispatcherMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
    ResolveEventDispatcherMethod "newHooksForEventTypeIterator" o = EventDispatcherNewHooksForEventTypeIteratorMethodInfo
    ResolveEventDispatcherMethod "newHooksIterator" o = EventDispatcherNewHooksIteratorMethodInfo
    ResolveEventDispatcherMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
    ResolveEventDispatcherMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
    ResolveEventDispatcherMethod "pushEvent" o = EventDispatcherPushEventMethodInfo
    ResolveEventDispatcherMethod "ref" o = GObject.Object.ObjectRefMethodInfo
    ResolveEventDispatcherMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
    ResolveEventDispatcherMethod "registerHook" o = EventDispatcherRegisterHookMethodInfo
    ResolveEventDispatcherMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
    ResolveEventDispatcherMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
    ResolveEventDispatcherMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
    ResolveEventDispatcherMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
    ResolveEventDispatcherMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
    ResolveEventDispatcherMethod "unregisterHook" o = EventDispatcherUnregisterHookMethodInfo
    ResolveEventDispatcherMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
    ResolveEventDispatcherMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
    ResolveEventDispatcherMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
    ResolveEventDispatcherMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
    ResolveEventDispatcherMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
    ResolveEventDispatcherMethod "setDataFull" o = GObject.Object.ObjectSetDataFullMethodInfo
    ResolveEventDispatcherMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolveEventDispatcherMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveEventDispatcherMethod t EventDispatcher, O.OverloadedMethod info EventDispatcher p) => OL.IsLabel t (EventDispatcher -> p) where
#if MIN_VERSION_base(4,10,0)
    fromLabel = O.overloadedMethod @info
#else
    fromLabel _ = O.overloadedMethod @info
#endif

#if MIN_VERSION_base(4,13,0)
instance (info ~ ResolveEventDispatcherMethod t EventDispatcher, O.OverloadedMethod info EventDispatcher p, R.HasField t EventDispatcher p) => R.HasField t EventDispatcher p where
    getField = O.overloadedMethod @info

#endif

instance (info ~ ResolveEventDispatcherMethod t EventDispatcher, O.OverloadedMethodInfo info EventDispatcher) => OL.IsLabel t (O.MethodProxy info EventDispatcher) where
#if MIN_VERSION_base(4,10,0)
    fromLabel = O.MethodProxy
#else
    fromLabel _ = O.MethodProxy
#endif

#endif

#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList EventDispatcher
type instance O.AttributeList EventDispatcher = EventDispatcherAttributeList
type EventDispatcherAttributeList = ('[ ] :: [(Symbol, DK.Type)])
#endif

#if defined(ENABLE_OVERLOADING)
#endif

#if defined(ENABLE_OVERLOADING)
type instance O.SignalList EventDispatcher = EventDispatcherSignalList
type EventDispatcherSignalList = ('[ '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, DK.Type)])

#endif

-- method EventDispatcher::new_hooks_for_event_type_iterator
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "self"
--           , argType =
--               TInterface Name { namespace = "Wp" , name = "EventDispatcher" }
--           , argCType = Just "WpEventDispatcher*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the event dispatcher"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "event_type"
--           , argType = TBasicType TUTF8
--           , argCType = Just "const gchar*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the event type" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TInterface Name { namespace = "Wp" , name = "Iterator" })
-- throws : False
-- Skip return : False

foreign import ccall "wp_event_dispatcher_new_hooks_for_event_type_iterator" wp_event_dispatcher_new_hooks_for_event_type_iterator :: 
    Ptr EventDispatcher ->                  -- self : TInterface (Name {namespace = "Wp", name = "EventDispatcher"})
    CString ->                              -- event_type : TBasicType TUTF8
    IO (Ptr Wp.Iterator.Iterator)

-- | Returns an iterator to iterate over the registered hooks for a particular event type.
-- 
-- /Since: 0.5.13/
eventDispatcherNewHooksForEventTypeIterator ::
    (B.CallStack.HasCallStack, MonadIO m, IsEventDispatcher a) =>
    a
    -- ^ /@self@/: the event dispatcher
    -> T.Text
    -- ^ /@eventType@/: the event type
    -> m Wp.Iterator.Iterator
    -- ^ __Returns:__ a new iterator
eventDispatcherNewHooksForEventTypeIterator self eventType = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    eventType' <- textToCString eventType
    result <- wp_event_dispatcher_new_hooks_for_event_type_iterator self' eventType'
    checkUnexpectedReturnNULL "eventDispatcherNewHooksForEventTypeIterator" result
    result' <- (wrapBoxed Wp.Iterator.Iterator) result
    touchManagedPtr self
    freeMem eventType'
    return result'

#if defined(ENABLE_OVERLOADING)
data EventDispatcherNewHooksForEventTypeIteratorMethodInfo
instance (signature ~ (T.Text -> m Wp.Iterator.Iterator), MonadIO m, IsEventDispatcher a) => O.OverloadedMethod EventDispatcherNewHooksForEventTypeIteratorMethodInfo a signature where
    overloadedMethod = eventDispatcherNewHooksForEventTypeIterator

instance O.OverloadedMethodInfo EventDispatcherNewHooksForEventTypeIteratorMethodInfo a where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.Wp.Objects.EventDispatcher.eventDispatcherNewHooksForEventTypeIterator",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-wireplumber-0.5.14.2/docs/GI-Wp-Objects-EventDispatcher.html#v:eventDispatcherNewHooksForEventTypeIterator"
        })


#endif

-- method EventDispatcher::new_hooks_iterator
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "self"
--           , argType =
--               TInterface Name { namespace = "Wp" , name = "EventDispatcher" }
--           , argCType = Just "WpEventDispatcher*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the event dispatcher"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TInterface Name { namespace = "Wp" , name = "Iterator" })
-- throws : False
-- Skip return : False

foreign import ccall "wp_event_dispatcher_new_hooks_iterator" wp_event_dispatcher_new_hooks_iterator :: 
    Ptr EventDispatcher ->                  -- self : TInterface (Name {namespace = "Wp", name = "EventDispatcher"})
    IO (Ptr Wp.Iterator.Iterator)

{-# DEPRECATED eventDispatcherNewHooksIterator ["Use wp_event_dispatcher_new_hooks_for_event_type_iterator instead."] #-}
-- | Returns an iterator to iterate over all the registered hooks.
eventDispatcherNewHooksIterator ::
    (B.CallStack.HasCallStack, MonadIO m, IsEventDispatcher a) =>
    a
    -- ^ /@self@/: the event dispatcher
    -> m Wp.Iterator.Iterator
    -- ^ __Returns:__ a new iterator
eventDispatcherNewHooksIterator self = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    result <- wp_event_dispatcher_new_hooks_iterator self'
    checkUnexpectedReturnNULL "eventDispatcherNewHooksIterator" result
    result' <- (wrapBoxed Wp.Iterator.Iterator) result
    touchManagedPtr self
    return result'

#if defined(ENABLE_OVERLOADING)
data EventDispatcherNewHooksIteratorMethodInfo
instance (signature ~ (m Wp.Iterator.Iterator), MonadIO m, IsEventDispatcher a) => O.OverloadedMethod EventDispatcherNewHooksIteratorMethodInfo a signature where
    overloadedMethod = eventDispatcherNewHooksIterator

instance O.OverloadedMethodInfo EventDispatcherNewHooksIteratorMethodInfo a where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.Wp.Objects.EventDispatcher.eventDispatcherNewHooksIterator",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-wireplumber-0.5.14.2/docs/GI-Wp-Objects-EventDispatcher.html#v:eventDispatcherNewHooksIterator"
        })


#endif

-- method EventDispatcher::push_event
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "self"
--           , argType =
--               TInterface Name { namespace = "Wp" , name = "EventDispatcher" }
--           , argCType = Just "WpEventDispatcher*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the dispatcher" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "event"
--           , argType = TInterface Name { namespace = "Wp" , name = "Event" }
--           , argCType = Just "WpEvent*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the new event" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferEverything
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "wp_event_dispatcher_push_event" wp_event_dispatcher_push_event :: 
    Ptr EventDispatcher ->                  -- self : TInterface (Name {namespace = "Wp", name = "EventDispatcher"})
    Ptr Wp.Event.Event ->                   -- event : TInterface (Name {namespace = "Wp", name = "Event"})
    IO ()

-- | Pushes a new event onto the event stack for dispatching only if there are any hooks are available for it.
eventDispatcherPushEvent ::
    (B.CallStack.HasCallStack, MonadIO m, IsEventDispatcher a) =>
    a
    -- ^ /@self@/: the dispatcher
    -> Wp.Event.Event
    -- ^ /@event@/: the new event
    -> m ()
eventDispatcherPushEvent self event = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    event' <- B.ManagedPtr.disownBoxed event
    wp_event_dispatcher_push_event self' event'
    touchManagedPtr self
    touchManagedPtr event
    return ()

#if defined(ENABLE_OVERLOADING)
data EventDispatcherPushEventMethodInfo
instance (signature ~ (Wp.Event.Event -> m ()), MonadIO m, IsEventDispatcher a) => O.OverloadedMethod EventDispatcherPushEventMethodInfo a signature where
    overloadedMethod = eventDispatcherPushEvent

instance O.OverloadedMethodInfo EventDispatcherPushEventMethodInfo a where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.Wp.Objects.EventDispatcher.eventDispatcherPushEvent",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-wireplumber-0.5.14.2/docs/GI-Wp-Objects-EventDispatcher.html#v:eventDispatcherPushEvent"
        })


#endif

-- method EventDispatcher::register_hook
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "self"
--           , argType =
--               TInterface Name { namespace = "Wp" , name = "EventDispatcher" }
--           , argCType = Just "WpEventDispatcher*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the event dispatcher"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "hook"
--           , argType =
--               TInterface Name { namespace = "Wp" , name = "EventHook" }
--           , argCType = Just "WpEventHook*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the hook to register"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "wp_event_dispatcher_register_hook" wp_event_dispatcher_register_hook :: 
    Ptr EventDispatcher ->                  -- self : TInterface (Name {namespace = "Wp", name = "EventDispatcher"})
    Ptr Wp.EventHook.EventHook ->           -- hook : TInterface (Name {namespace = "Wp", name = "EventHook"})
    IO ()

-- | Registers an event hook.
eventDispatcherRegisterHook ::
    (B.CallStack.HasCallStack, MonadIO m, IsEventDispatcher a, Wp.EventHook.IsEventHook b) =>
    a
    -- ^ /@self@/: the event dispatcher
    -> b
    -- ^ /@hook@/: the hook to register
    -> m ()
eventDispatcherRegisterHook self hook = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    hook' <- unsafeManagedPtrCastPtr hook
    wp_event_dispatcher_register_hook self' hook'
    touchManagedPtr self
    touchManagedPtr hook
    return ()

#if defined(ENABLE_OVERLOADING)
data EventDispatcherRegisterHookMethodInfo
instance (signature ~ (b -> m ()), MonadIO m, IsEventDispatcher a, Wp.EventHook.IsEventHook b) => O.OverloadedMethod EventDispatcherRegisterHookMethodInfo a signature where
    overloadedMethod = eventDispatcherRegisterHook

instance O.OverloadedMethodInfo EventDispatcherRegisterHookMethodInfo a where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.Wp.Objects.EventDispatcher.eventDispatcherRegisterHook",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-wireplumber-0.5.14.2/docs/GI-Wp-Objects-EventDispatcher.html#v:eventDispatcherRegisterHook"
        })


#endif

-- method EventDispatcher::unregister_hook
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "self"
--           , argType =
--               TInterface Name { namespace = "Wp" , name = "EventDispatcher" }
--           , argCType = Just "WpEventDispatcher*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the event dispatcher"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "hook"
--           , argType =
--               TInterface Name { namespace = "Wp" , name = "EventHook" }
--           , argCType = Just "WpEventHook*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the hook to unregister"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "wp_event_dispatcher_unregister_hook" wp_event_dispatcher_unregister_hook :: 
    Ptr EventDispatcher ->                  -- self : TInterface (Name {namespace = "Wp", name = "EventDispatcher"})
    Ptr Wp.EventHook.EventHook ->           -- hook : TInterface (Name {namespace = "Wp", name = "EventHook"})
    IO ()

-- | Unregisters an event hook.
eventDispatcherUnregisterHook ::
    (B.CallStack.HasCallStack, MonadIO m, IsEventDispatcher a, Wp.EventHook.IsEventHook b) =>
    a
    -- ^ /@self@/: the event dispatcher
    -> b
    -- ^ /@hook@/: the hook to unregister
    -> m ()
eventDispatcherUnregisterHook self hook = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    hook' <- unsafeManagedPtrCastPtr hook
    wp_event_dispatcher_unregister_hook self' hook'
    touchManagedPtr self
    touchManagedPtr hook
    return ()

#if defined(ENABLE_OVERLOADING)
data EventDispatcherUnregisterHookMethodInfo
instance (signature ~ (b -> m ()), MonadIO m, IsEventDispatcher a, Wp.EventHook.IsEventHook b) => O.OverloadedMethod EventDispatcherUnregisterHookMethodInfo a signature where
    overloadedMethod = eventDispatcherUnregisterHook

instance O.OverloadedMethodInfo EventDispatcherUnregisterHookMethodInfo a where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.Wp.Objects.EventDispatcher.eventDispatcherUnregisterHook",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-wireplumber-0.5.14.2/docs/GI-Wp-Objects-EventDispatcher.html#v:eventDispatcherUnregisterHook"
        })


#endif

-- method EventDispatcher::get_instance
-- method type : MemberFunction
-- Args: [ Arg
--           { argCName = "core"
--           , argType = TInterface Name { namespace = "Wp" , name = "Core" }
--           , argCType = Just "WpCore*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the core" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just
--               (TInterface Name { namespace = "Wp" , name = "EventDispatcher" })
-- throws : False
-- Skip return : False

foreign import ccall "wp_event_dispatcher_get_instance" wp_event_dispatcher_get_instance :: 
    Ptr Wp.Core.Core ->                     -- core : TInterface (Name {namespace = "Wp", name = "Core"})
    IO (Ptr EventDispatcher)

-- | Returns the event dispatcher instance that is associated with the given core.
-- 
-- 
-- This method will also create the instance and register it with the core, if it had not been created before.
eventDispatcherGetInstance ::
    (B.CallStack.HasCallStack, MonadIO m, Wp.Core.IsCore a) =>
    a
    -- ^ /@core@/: the core
    -> m EventDispatcher
    -- ^ __Returns:__ the event dispatcher instance
eventDispatcherGetInstance core = liftIO $ do
    core' <- unsafeManagedPtrCastPtr core
    result <- wp_event_dispatcher_get_instance core'
    checkUnexpectedReturnNULL "eventDispatcherGetInstance" result
    result' <- (wrapObject EventDispatcher) result
    touchManagedPtr core
    return result'

#if defined(ENABLE_OVERLOADING)
#endif


