{-# LANGUAGE TypeApplications #-}


-- | Copyright  : Will Thompson and Iñaki García Etxebarria
-- License    : LGPL-2.1
-- Maintainer : Iñaki García Etxebarria
-- 
-- WpEvent describes an event, an event is an entity which can be pushed on to event stack and the event dispatcher is going to pick and dispatch it.

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

module GI.Wp.Structs.Event
    ( 

-- * Exported types
    Event(..)                               ,


 -- * Methods
-- | 
-- 
--  === __Click to display all available methods, including inherited ones__
-- ==== Methods
-- [collectHooks]("GI.Wp.Structs.Event#g:method:collectHooks"), [newHooksIterator]("GI.Wp.Structs.Event#g:method:newHooksIterator"), [ref]("GI.Wp.Structs.Event#g:method:ref"), [stopProcessing]("GI.Wp.Structs.Event#g:method:stopProcessing"), [unref]("GI.Wp.Structs.Event#g:method:unref").
-- 
-- ==== Getters
-- [getCancellable]("GI.Wp.Structs.Event#g:method:getCancellable"), [getData]("GI.Wp.Structs.Event#g:method:getData"), [getName]("GI.Wp.Structs.Event#g:method:getName"), [getPriority]("GI.Wp.Structs.Event#g:method:getPriority"), [getProperties]("GI.Wp.Structs.Event#g:method:getProperties"), [getSource]("GI.Wp.Structs.Event#g:method:getSource"), [getSubject]("GI.Wp.Structs.Event#g:method:getSubject").
-- 
-- ==== Setters
-- [setData]("GI.Wp.Structs.Event#g:method:setData").

#if defined(ENABLE_OVERLOADING)
    ResolveEventMethod                      ,
#endif

-- ** collectHooks #method:collectHooks#

#if defined(ENABLE_OVERLOADING)
    EventCollectHooksMethodInfo             ,
#endif
    eventCollectHooks                       ,


-- ** getCancellable #method:getCancellable#

#if defined(ENABLE_OVERLOADING)
    EventGetCancellableMethodInfo           ,
#endif
    eventGetCancellable                     ,


-- ** getData #method:getData#

#if defined(ENABLE_OVERLOADING)
    EventGetDataMethodInfo                  ,
#endif
    eventGetData                            ,


-- ** getName #method:getName#

#if defined(ENABLE_OVERLOADING)
    EventGetNameMethodInfo                  ,
#endif
    eventGetName                            ,


-- ** getPriority #method:getPriority#

#if defined(ENABLE_OVERLOADING)
    EventGetPriorityMethodInfo              ,
#endif
    eventGetPriority                        ,


-- ** getProperties #method:getProperties#

#if defined(ENABLE_OVERLOADING)
    EventGetPropertiesMethodInfo            ,
#endif
    eventGetProperties                      ,


-- ** getSource #method:getSource#

#if defined(ENABLE_OVERLOADING)
    EventGetSourceMethodInfo                ,
#endif
    eventGetSource                          ,


-- ** getSubject #method:getSubject#

#if defined(ENABLE_OVERLOADING)
    EventGetSubjectMethodInfo               ,
#endif
    eventGetSubject                         ,


-- ** new #method:new#

    eventNew                                ,


-- ** newHooksIterator #method:newHooksIterator#

#if defined(ENABLE_OVERLOADING)
    EventNewHooksIteratorMethodInfo         ,
#endif
    eventNewHooksIterator                   ,


-- ** ref #method:ref#

#if defined(ENABLE_OVERLOADING)
    EventRefMethodInfo                      ,
#endif
    eventRef                                ,


-- ** setData #method:setData#

#if defined(ENABLE_OVERLOADING)
    EventSetDataMethodInfo                  ,
#endif
    eventSetData                            ,


-- ** stopProcessing #method:stopProcessing#

#if defined(ENABLE_OVERLOADING)
    EventStopProcessingMethodInfo           ,
#endif
    eventStopProcessing                     ,


-- ** unref #method:unref#

#if defined(ENABLE_OVERLOADING)
    EventUnrefMethodInfo                    ,
#endif
    eventUnref                              ,




    ) 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.EventDispatcher as Wp.EventDispatcher
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.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 qualified GI.Gio.Objects.Cancellable as Gio.Cancellable
import {-# SOURCE #-} qualified GI.Wp.Objects.EventDispatcher as Wp.EventDispatcher
import {-# SOURCE #-} qualified GI.Wp.Structs.Iterator as Wp.Iterator
import {-# SOURCE #-} qualified GI.Wp.Structs.Properties as Wp.Properties

#endif

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

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

foreign import ccall "wp_event_get_type" c_wp_event_get_type :: 
    IO GType

type instance O.ParentTypes Event = '[]
instance O.HasParentTypes Event

instance B.Types.TypedObject Event where
    glibType = c_wp_event_get_type

instance B.Types.GBoxed Event

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


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

-- method Event::new
-- method type : Constructor
-- Args: [ Arg
--           { argCName = "type"
--           , argType = TBasicType TUTF8
--           , argCType = Just "const gchar*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the type of the event"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "priority"
--           , argType = TBasicType TInt
--           , argCType = Just "gint"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the priority of the event"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "properties"
--           , argType =
--               TInterface Name { namespace = "Wp" , name = "Properties" }
--           , argCType = Just "WpProperties*"
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "properties of the event"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferEverything
--           }
--       , Arg
--           { argCName = "source"
--           , argType =
--               TInterface Name { namespace = "GObject" , name = "Object" }
--           , argCType = Just "GObject*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the source of the event"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "subject"
--           , argType =
--               TInterface Name { namespace = "GObject" , name = "Object" }
--           , argCType = Just "GObject*"
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the object that the event is about"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TInterface Name { namespace = "Wp" , name = "Event" })
-- throws : False
-- Skip return : False

foreign import ccall "wp_event_new" wp_event_new :: 
    CString ->                              -- type : TBasicType TUTF8
    Int32 ->                                -- priority : TBasicType TInt
    Ptr Wp.Properties.Properties ->         -- properties : TInterface (Name {namespace = "Wp", name = "Properties"})
    Ptr GObject.Object.Object ->            -- source : TInterface (Name {namespace = "GObject", name = "Object"})
    Ptr GObject.Object.Object ->            -- subject : TInterface (Name {namespace = "GObject", name = "Object"})
    IO (Ptr Event)

-- | Creates a new event.
eventNew ::
    (B.CallStack.HasCallStack, MonadIO m, GObject.Object.IsObject a, GObject.Object.IsObject b) =>
    T.Text
    -- ^ /@type@/: the type of the event
    -> Int32
    -- ^ /@priority@/: the priority of the event
    -> Maybe (Wp.Properties.Properties)
    -- ^ /@properties@/: properties of the event
    -> a
    -- ^ /@source@/: the source of the event
    -> Maybe (b)
    -- ^ /@subject@/: the object that the event is about
    -> m Event
    -- ^ __Returns:__ the newly constructed event
eventNew type_ priority properties source subject = liftIO $ do
    type_' <- textToCString type_
    maybeProperties <- case properties of
        Nothing -> return FP.nullPtr
        Just jProperties -> do
            jProperties' <- B.ManagedPtr.disownBoxed jProperties
            return jProperties'
    source' <- unsafeManagedPtrCastPtr source
    maybeSubject <- case subject of
        Nothing -> return FP.nullPtr
        Just jSubject -> do
            jSubject' <- unsafeManagedPtrCastPtr jSubject
            return jSubject'
    result <- wp_event_new type_' priority maybeProperties source' maybeSubject
    checkUnexpectedReturnNULL "eventNew" result
    result' <- (wrapBoxed Event) result
    whenJust properties touchManagedPtr
    touchManagedPtr source
    whenJust subject touchManagedPtr
    freeMem type_'
    return result'

#if defined(ENABLE_OVERLOADING)
#endif

-- method Event::collect_hooks
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "event"
--           , argType = TInterface Name { namespace = "Wp" , name = "Event" }
--           , argCType = Just "WpEvent*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the event" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "dispatcher"
--           , 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 (TBasicType TBoolean)
-- throws : False
-- Skip return : False

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

-- | Collects all the hooks registered in the /@dispatcher@/ that run for this /@event@/.
eventCollectHooks ::
    (B.CallStack.HasCallStack, MonadIO m, Wp.EventDispatcher.IsEventDispatcher a) =>
    Event
    -- ^ /@event@/: the event
    -> a
    -- ^ /@dispatcher@/: the event dispatcher
    -> m Bool
    -- ^ __Returns:__ TRUE if at least one hook has been collected, FALSE if no hooks run for this event or an error occurred
eventCollectHooks event dispatcher = liftIO $ do
    event' <- unsafeManagedPtrGetPtr event
    dispatcher' <- unsafeManagedPtrCastPtr dispatcher
    result <- wp_event_collect_hooks event' dispatcher'
    let result' = (/= 0) result
    touchManagedPtr event
    touchManagedPtr dispatcher
    return result'

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

instance O.OverloadedMethodInfo EventCollectHooksMethodInfo Event where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.Wp.Structs.Event.eventCollectHooks",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-wireplumber-0.5.14.2/docs/GI-Wp-Structs-Event.html#v:eventCollectHooks"
        })


#endif

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

foreign import ccall "wp_event_get_cancellable" wp_event_get_cancellable :: 
    Ptr Event ->                            -- self : TInterface (Name {namespace = "Wp", name = "Event"})
    IO (Ptr Gio.Cancellable.Cancellable)

-- | Returns the internal GCancellable that is used to track whether this event has been stopped by 'GI.Wp.Structs.Event.eventStopProcessing'.
eventGetCancellable ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Event
    -- ^ /@self@/: the event
    -> m Gio.Cancellable.Cancellable
    -- ^ __Returns:__ the cancellable
eventGetCancellable self = liftIO $ do
    self' <- unsafeManagedPtrGetPtr self
    result <- wp_event_get_cancellable self'
    checkUnexpectedReturnNULL "eventGetCancellable" result
    result' <- (newObject Gio.Cancellable.Cancellable) result
    touchManagedPtr self
    return result'

#if defined(ENABLE_OVERLOADING)
data EventGetCancellableMethodInfo
instance (signature ~ (m Gio.Cancellable.Cancellable), MonadIO m) => O.OverloadedMethod EventGetCancellableMethodInfo Event signature where
    overloadedMethod = eventGetCancellable

instance O.OverloadedMethodInfo EventGetCancellableMethodInfo Event where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.Wp.Structs.Event.eventGetCancellable",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-wireplumber-0.5.14.2/docs/GI-Wp-Structs-Event.html#v:eventGetCancellable"
        })


#endif

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

foreign import ccall "wp_event_get_data" wp_event_get_data :: 
    Ptr Event ->                            -- self : TInterface (Name {namespace = "Wp", name = "Event"})
    CString ->                              -- key : TBasicType TUTF8
    IO (Ptr GValue)

-- | Gets the data that was previously associated with /@key@/ by 'GI.Wp.Structs.Event.eventSetData'.
eventGetData ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Event
    -- ^ /@self@/: the event
    -> T.Text
    -- ^ /@key@/: the key
    -> m (Maybe GValue)
    -- ^ __Returns:__ the data associated with /@key@/ or 'P.Nothing'
eventGetData self key = liftIO $ do
    self' <- unsafeManagedPtrGetPtr self
    key' <- textToCString key
    result <- wp_event_get_data self' key'
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- B.GValue.newGValueFromPtr result'
        return result''
    touchManagedPtr self
    freeMem key'
    return maybeResult

#if defined(ENABLE_OVERLOADING)
data EventGetDataMethodInfo
instance (signature ~ (T.Text -> m (Maybe GValue)), MonadIO m) => O.OverloadedMethod EventGetDataMethodInfo Event signature where
    overloadedMethod = eventGetData

instance O.OverloadedMethodInfo EventGetDataMethodInfo Event where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.Wp.Structs.Event.eventGetData",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-wireplumber-0.5.14.2/docs/GI-Wp-Structs-Event.html#v:eventGetData"
        })


#endif

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

foreign import ccall "wp_event_get_name" wp_event_get_name :: 
    Ptr Event ->                            -- self : TInterface (Name {namespace = "Wp", name = "Event"})
    IO CString

-- | Gets the name of the event.
eventGetName ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Event
    -- ^ /@self@/: the event
    -> m T.Text
    -- ^ __Returns:__ the event name
eventGetName self = liftIO $ do
    self' <- unsafeManagedPtrGetPtr self
    result <- wp_event_get_name self'
    checkUnexpectedReturnNULL "eventGetName" result
    result' <- cstringToText result
    touchManagedPtr self
    return result'

#if defined(ENABLE_OVERLOADING)
data EventGetNameMethodInfo
instance (signature ~ (m T.Text), MonadIO m) => O.OverloadedMethod EventGetNameMethodInfo Event signature where
    overloadedMethod = eventGetName

instance O.OverloadedMethodInfo EventGetNameMethodInfo Event where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.Wp.Structs.Event.eventGetName",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-wireplumber-0.5.14.2/docs/GI-Wp-Structs-Event.html#v:eventGetName"
        })


#endif

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

foreign import ccall "wp_event_get_priority" wp_event_get_priority :: 
    Ptr Event ->                            -- self : TInterface (Name {namespace = "Wp", name = "Event"})
    IO Int32

-- | Gets the priority of the event.
eventGetPriority ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Event
    -- ^ /@self@/: the event
    -> m Int32
    -- ^ __Returns:__ the event priority
eventGetPriority self = liftIO $ do
    self' <- unsafeManagedPtrGetPtr self
    result <- wp_event_get_priority self'
    touchManagedPtr self
    return result

#if defined(ENABLE_OVERLOADING)
data EventGetPriorityMethodInfo
instance (signature ~ (m Int32), MonadIO m) => O.OverloadedMethod EventGetPriorityMethodInfo Event signature where
    overloadedMethod = eventGetPriority

instance O.OverloadedMethodInfo EventGetPriorityMethodInfo Event where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.Wp.Structs.Event.eventGetPriority",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-wireplumber-0.5.14.2/docs/GI-Wp-Structs-Event.html#v:eventGetPriority"
        })


#endif

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

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

-- | Gets the properties of the Event.
eventGetProperties ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Event
    -- ^ /@self@/: the handle
    -> m Wp.Properties.Properties
    -- ^ __Returns:__ the properties of the event
eventGetProperties self = liftIO $ do
    self' <- unsafeManagedPtrGetPtr self
    result <- wp_event_get_properties self'
    checkUnexpectedReturnNULL "eventGetProperties" result
    result' <- (wrapBoxed Wp.Properties.Properties) result
    touchManagedPtr self
    return result'

#if defined(ENABLE_OVERLOADING)
data EventGetPropertiesMethodInfo
instance (signature ~ (m Wp.Properties.Properties), MonadIO m) => O.OverloadedMethod EventGetPropertiesMethodInfo Event signature where
    overloadedMethod = eventGetProperties

instance O.OverloadedMethodInfo EventGetPropertiesMethodInfo Event where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.Wp.Structs.Event.eventGetProperties",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-wireplumber-0.5.14.2/docs/GI-Wp-Structs-Event.html#v:eventGetProperties"
        })


#endif

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

foreign import ccall "wp_event_get_source" wp_event_get_source :: 
    Ptr Event ->                            -- self : TInterface (Name {namespace = "Wp", name = "Event"})
    IO (Ptr GObject.Object.Object)

-- | Gets the Source Object of the Event.
eventGetSource ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Event
    -- ^ /@self@/: the handle
    -> m GObject.Object.Object
    -- ^ __Returns:__ the source of the event
eventGetSource self = liftIO $ do
    self' <- unsafeManagedPtrGetPtr self
    result <- wp_event_get_source self'
    checkUnexpectedReturnNULL "eventGetSource" result
    result' <- (wrapObject GObject.Object.Object) result
    touchManagedPtr self
    return result'

#if defined(ENABLE_OVERLOADING)
data EventGetSourceMethodInfo
instance (signature ~ (m GObject.Object.Object), MonadIO m) => O.OverloadedMethod EventGetSourceMethodInfo Event signature where
    overloadedMethod = eventGetSource

instance O.OverloadedMethodInfo EventGetSourceMethodInfo Event where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.Wp.Structs.Event.eventGetSource",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-wireplumber-0.5.14.2/docs/GI-Wp-Structs-Event.html#v:eventGetSource"
        })


#endif

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

foreign import ccall "wp_event_get_subject" wp_event_get_subject :: 
    Ptr Event ->                            -- self : TInterface (Name {namespace = "Wp", name = "Event"})
    IO (Ptr GObject.Object.Object)

-- | Gets the Subject Object of the Event.
eventGetSubject ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Event
    -- ^ /@self@/: the handle
    -> m GObject.Object.Object
    -- ^ __Returns:__ the subject of the event
eventGetSubject self = liftIO $ do
    self' <- unsafeManagedPtrGetPtr self
    result <- wp_event_get_subject self'
    checkUnexpectedReturnNULL "eventGetSubject" result
    result' <- (wrapObject GObject.Object.Object) result
    touchManagedPtr self
    return result'

#if defined(ENABLE_OVERLOADING)
data EventGetSubjectMethodInfo
instance (signature ~ (m GObject.Object.Object), MonadIO m) => O.OverloadedMethod EventGetSubjectMethodInfo Event signature where
    overloadedMethod = eventGetSubject

instance O.OverloadedMethodInfo EventGetSubjectMethodInfo Event where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.Wp.Structs.Event.eventGetSubject",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-wireplumber-0.5.14.2/docs/GI-Wp-Structs-Event.html#v:eventGetSubject"
        })


#endif

-- method Event::new_hooks_iterator
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "event"
--           , argType = TInterface Name { namespace = "Wp" , name = "Event" }
--           , argCType = Just "WpEvent*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the event" , 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_new_hooks_iterator" wp_event_new_hooks_iterator :: 
    Ptr Event ->                            -- event : TInterface (Name {namespace = "Wp", name = "Event"})
    IO (Ptr Wp.Iterator.Iterator)

-- | Returns an iterator that iterates over all the hooks that were collected by 'GI.Wp.Structs.Event.eventCollectHooks'.
eventNewHooksIterator ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Event
    -- ^ /@event@/: the event
    -> m Wp.Iterator.Iterator
    -- ^ __Returns:__ the new iterator
eventNewHooksIterator event = liftIO $ do
    event' <- unsafeManagedPtrGetPtr event
    result <- wp_event_new_hooks_iterator event'
    checkUnexpectedReturnNULL "eventNewHooksIterator" result
    result' <- (wrapBoxed Wp.Iterator.Iterator) result
    touchManagedPtr event
    return result'

#if defined(ENABLE_OVERLOADING)
data EventNewHooksIteratorMethodInfo
instance (signature ~ (m Wp.Iterator.Iterator), MonadIO m) => O.OverloadedMethod EventNewHooksIteratorMethodInfo Event signature where
    overloadedMethod = eventNewHooksIterator

instance O.OverloadedMethodInfo EventNewHooksIteratorMethodInfo Event where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.Wp.Structs.Event.eventNewHooksIterator",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-wireplumber-0.5.14.2/docs/GI-Wp-Structs-Event.html#v:eventNewHooksIterator"
        })


#endif

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

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

-- | Increases the reference count of an event.
eventRef ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Event
    -- ^ /@self@/: the event
    -> m Event
    -- ^ __Returns:__ /@self@/ with an additional reference count on it
eventRef self = liftIO $ do
    self' <- unsafeManagedPtrGetPtr self
    result <- wp_event_ref self'
    checkUnexpectedReturnNULL "eventRef" result
    result' <- (wrapBoxed Event) result
    touchManagedPtr self
    return result'

#if defined(ENABLE_OVERLOADING)
data EventRefMethodInfo
instance (signature ~ (m Event), MonadIO m) => O.OverloadedMethod EventRefMethodInfo Event signature where
    overloadedMethod = eventRef

instance O.OverloadedMethodInfo EventRefMethodInfo Event where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.Wp.Structs.Event.eventRef",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-wireplumber-0.5.14.2/docs/GI-Wp-Structs-Event.html#v:eventRef"
        })


#endif

-- method Event::set_data
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "self"
--           , argType = TInterface Name { namespace = "Wp" , name = "Event" }
--           , argCType = Just "WpEvent*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the event" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "key"
--           , argType = TBasicType TUTF8
--           , argCType = Just "const gchar*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the key to associate @data with"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "data"
--           , argType = TGValue
--           , argCType = Just "const GValue*"
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "the data element, or %NULL to remove any previous data associated with this @key"
--                 , 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_set_data" wp_event_set_data :: 
    Ptr Event ->                            -- self : TInterface (Name {namespace = "Wp", name = "Event"})
    CString ->                              -- key : TBasicType TUTF8
    Ptr GValue ->                           -- data : TGValue
    IO ()

-- | Stores /@data@/ on the event, associated with the specified /@key@/.
-- 
-- 
-- This can be used to exchange arbitrary data between hooks that run for this event.
eventSetData ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Event
    -- ^ /@self@/: the event
    -> T.Text
    -- ^ /@key@/: the key to associate /@data@/ with
    -> Maybe (GValue)
    -- ^ /@data@/: the data element, or 'P.Nothing' to remove any previous data associated with this /@key@/
    -> m ()
eventSetData self key data_ = liftIO $ do
    self' <- unsafeManagedPtrGetPtr self
    key' <- textToCString key
    maybeData_ <- case data_ of
        Nothing -> return FP.nullPtr
        Just jData_ -> do
            jData_' <- unsafeManagedPtrGetPtr jData_
            return jData_'
    wp_event_set_data self' key' maybeData_
    touchManagedPtr self
    whenJust data_ touchManagedPtr
    freeMem key'
    return ()

#if defined(ENABLE_OVERLOADING)
data EventSetDataMethodInfo
instance (signature ~ (T.Text -> Maybe (GValue) -> m ()), MonadIO m) => O.OverloadedMethod EventSetDataMethodInfo Event signature where
    overloadedMethod = eventSetData

instance O.OverloadedMethodInfo EventSetDataMethodInfo Event where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.Wp.Structs.Event.eventSetData",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-wireplumber-0.5.14.2/docs/GI-Wp-Structs-Event.html#v:eventSetData"
        })


#endif

-- method Event::stop_processing
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "self"
--           , argType = TInterface Name { namespace = "Wp" , name = "Event" }
--           , argCType = Just "WpEvent*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the event" , 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_stop_processing" wp_event_stop_processing :: 
    Ptr Event ->                            -- self : TInterface (Name {namespace = "Wp", name = "Event"})
    IO ()

-- | Stops processing of this event; any further hooks will not be executed from this moment onwards and the event will be discarded from the stack.
eventStopProcessing ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Event
    -- ^ /@self@/: the event
    -> m ()
eventStopProcessing self = liftIO $ do
    self' <- unsafeManagedPtrGetPtr self
    wp_event_stop_processing self'
    touchManagedPtr self
    return ()

#if defined(ENABLE_OVERLOADING)
data EventStopProcessingMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.OverloadedMethod EventStopProcessingMethodInfo Event signature where
    overloadedMethod = eventStopProcessing

instance O.OverloadedMethodInfo EventStopProcessingMethodInfo Event where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.Wp.Structs.Event.eventStopProcessing",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-wireplumber-0.5.14.2/docs/GI-Wp-Structs-Event.html#v:eventStopProcessing"
        })


#endif

-- method Event::unref
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "self"
--           , argType = TInterface Name { namespace = "Wp" , name = "Event" }
--           , argCType = Just "WpEvent*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the 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_unref" wp_event_unref :: 
    Ptr Event ->                            -- self : TInterface (Name {namespace = "Wp", name = "Event"})
    IO ()

-- | Decreases the reference count of an event, destroying it when the reference count reaches zero.
eventUnref ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Event
    -- ^ /@self@/: the event
    -> m ()
eventUnref self = liftIO $ do
    self' <- B.ManagedPtr.disownBoxed self
    wp_event_unref self'
    touchManagedPtr self
    return ()

#if defined(ENABLE_OVERLOADING)
data EventUnrefMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.OverloadedMethod EventUnrefMethodInfo Event signature where
    overloadedMethod = eventUnref

instance O.OverloadedMethodInfo EventUnrefMethodInfo Event where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.Wp.Structs.Event.eventUnref",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-wireplumber-0.5.14.2/docs/GI-Wp-Structs-Event.html#v:eventUnref"
        })


#endif

#if defined(ENABLE_OVERLOADING)
type family ResolveEventMethod (t :: Symbol) (o :: DK.Type) :: DK.Type where
    ResolveEventMethod "collectHooks" o = EventCollectHooksMethodInfo
    ResolveEventMethod "newHooksIterator" o = EventNewHooksIteratorMethodInfo
    ResolveEventMethod "ref" o = EventRefMethodInfo
    ResolveEventMethod "stopProcessing" o = EventStopProcessingMethodInfo
    ResolveEventMethod "unref" o = EventUnrefMethodInfo
    ResolveEventMethod "getCancellable" o = EventGetCancellableMethodInfo
    ResolveEventMethod "getData" o = EventGetDataMethodInfo
    ResolveEventMethod "getName" o = EventGetNameMethodInfo
    ResolveEventMethod "getPriority" o = EventGetPriorityMethodInfo
    ResolveEventMethod "getProperties" o = EventGetPropertiesMethodInfo
    ResolveEventMethod "getSource" o = EventGetSourceMethodInfo
    ResolveEventMethod "getSubject" o = EventGetSubjectMethodInfo
    ResolveEventMethod "setData" o = EventSetDataMethodInfo
    ResolveEventMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveEventMethod t Event, O.OverloadedMethod info Event p) => OL.IsLabel t (Event -> 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 ~ ResolveEventMethod t Event, O.OverloadedMethod info Event p, R.HasField t Event p) => R.HasField t Event p where
    getField = O.overloadedMethod @info

#endif

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

#endif


