{-# LANGUAGE TypeApplications #-}


-- | Copyright  : Will Thompson and Iñaki García Etxebarria
-- License    : LGPL-2.1
-- Maintainer : Iñaki García Etxebarria
-- 
-- An event hook that declares interest in specific events. This subclass implements the WpEventHook.@/runs_for_event()/@ vmethod and returns TRUE from that method if the given event has properties that match one of the declared interests.

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

module GI.Wp.Objects.InterestEventHook
    ( 

-- * Exported types
    InterestEventHook(..)                   ,
    IsInterestEventHook                     ,
    toInterestEventHook                     ,


 -- * Methods
-- | 
-- 
--  === __Click to display all available methods, including inherited ones__
-- ==== Methods
-- [addInterestFull]("GI.Wp.Objects.InterestEventHook#g:method:addInterestFull"), [bindProperty]("GI.GObject.Objects.Object#g:method:bindProperty"), [bindPropertyFull]("GI.GObject.Objects.Object#g:method:bindPropertyFull"), [finish]("GI.Wp.Objects.EventHook#g:method:finish"), [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"), [notify]("GI.GObject.Objects.Object#g:method:notify"), [notifyByPspec]("GI.GObject.Objects.Object#g:method:notifyByPspec"), [ref]("GI.GObject.Objects.Object#g:method:ref"), [refSink]("GI.GObject.Objects.Object#g:method:refSink"), [run]("GI.Wp.Objects.EventHook#g:method:run"), [runDispose]("GI.GObject.Objects.Object#g:method:runDispose"), [runsForEvent]("GI.Wp.Objects.EventHook#g:method:runsForEvent"), [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"), [watchClosure]("GI.GObject.Objects.Object#g:method:watchClosure").
-- 
-- ==== Getters
-- [getData]("GI.GObject.Objects.Object#g:method:getData"), [getMatchingEventTypes]("GI.Wp.Objects.EventHook#g:method:getMatchingEventTypes"), [getName]("GI.Wp.Objects.EventHook#g:method:getName"), [getProperty]("GI.GObject.Objects.Object#g:method:getProperty"), [getQdata]("GI.GObject.Objects.Object#g:method:getQdata"), [getRunsAfterHooks]("GI.Wp.Objects.EventHook#g:method:getRunsAfterHooks"), [getRunsBeforeHooks]("GI.Wp.Objects.EventHook#g:method:getRunsBeforeHooks").
-- 
-- ==== 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)
    ResolveInterestEventHookMethod          ,
#endif

-- ** addInterestFull #method:addInterestFull#

#if defined(ENABLE_OVERLOADING)
    InterestEventHookAddInterestFullMethodInfo,
#endif
    interestEventHookAddInterestFull        ,




    ) 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.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.EventHook as Wp.EventHook
import {-# SOURCE #-} qualified GI.Wp.Structs.ObjectInterest as Wp.ObjectInterest

#endif

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

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

foreign import ccall "wp_interest_event_hook_get_type"
    c_wp_interest_event_hook_get_type :: IO B.Types.GType

instance B.Types.TypedObject InterestEventHook where
    glibType = c_wp_interest_event_hook_get_type

instance B.Types.GObject InterestEventHook

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

instance O.HasParentTypes InterestEventHook
type instance O.ParentTypes InterestEventHook = '[Wp.EventHook.EventHook, GObject.Object.Object]

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

-- | Convert t'InterestEventHook' 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 InterestEventHook) where
    gvalueGType_ = c_wp_interest_event_hook_get_type
    gvalueSet_ gv P.Nothing = B.GValue.set_object gv (FP.nullPtr :: FP.Ptr InterestEventHook)
    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 InterestEventHook)
        if ptr /= FP.nullPtr
        then P.Just <$> B.ManagedPtr.newObject InterestEventHook ptr
        else return P.Nothing
        
    

#if defined(ENABLE_OVERLOADING)
type family ResolveInterestEventHookMethod (t :: Symbol) (o :: DK.Type) :: DK.Type where
    ResolveInterestEventHookMethod "addInterestFull" o = InterestEventHookAddInterestFullMethodInfo
    ResolveInterestEventHookMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
    ResolveInterestEventHookMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
    ResolveInterestEventHookMethod "finish" o = Wp.EventHook.EventHookFinishMethodInfo
    ResolveInterestEventHookMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
    ResolveInterestEventHookMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
    ResolveInterestEventHookMethod "getv" o = GObject.Object.ObjectGetvMethodInfo
    ResolveInterestEventHookMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
    ResolveInterestEventHookMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
    ResolveInterestEventHookMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
    ResolveInterestEventHookMethod "ref" o = GObject.Object.ObjectRefMethodInfo
    ResolveInterestEventHookMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
    ResolveInterestEventHookMethod "run" o = Wp.EventHook.EventHookRunMethodInfo
    ResolveInterestEventHookMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
    ResolveInterestEventHookMethod "runsForEvent" o = Wp.EventHook.EventHookRunsForEventMethodInfo
    ResolveInterestEventHookMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
    ResolveInterestEventHookMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
    ResolveInterestEventHookMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
    ResolveInterestEventHookMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
    ResolveInterestEventHookMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
    ResolveInterestEventHookMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
    ResolveInterestEventHookMethod "getMatchingEventTypes" o = Wp.EventHook.EventHookGetMatchingEventTypesMethodInfo
    ResolveInterestEventHookMethod "getName" o = Wp.EventHook.EventHookGetNameMethodInfo
    ResolveInterestEventHookMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
    ResolveInterestEventHookMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
    ResolveInterestEventHookMethod "getRunsAfterHooks" o = Wp.EventHook.EventHookGetRunsAfterHooksMethodInfo
    ResolveInterestEventHookMethod "getRunsBeforeHooks" o = Wp.EventHook.EventHookGetRunsBeforeHooksMethodInfo
    ResolveInterestEventHookMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
    ResolveInterestEventHookMethod "setDataFull" o = GObject.Object.ObjectSetDataFullMethodInfo
    ResolveInterestEventHookMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolveInterestEventHookMethod l o = O.MethodResolutionFailed l o

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

#endif

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

#endif

#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList InterestEventHook
type instance O.AttributeList InterestEventHook = InterestEventHookAttributeList
type InterestEventHookAttributeList = ('[ '("dispatcher", Wp.EventHook.EventHookDispatcherPropertyInfo), '("name", Wp.EventHook.EventHookNamePropertyInfo), '("runsAfterHooks", Wp.EventHook.EventHookRunsAfterHooksPropertyInfo), '("runsBeforeHooks", Wp.EventHook.EventHookRunsBeforeHooksPropertyInfo)] :: [(Symbol, DK.Type)])
#endif

#if defined(ENABLE_OVERLOADING)
#endif

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

#endif

-- method InterestEventHook::add_interest_full
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "self"
--           , argType =
--               TInterface Name { namespace = "Wp" , name = "InterestEventHook" }
--           , argCType = Just "WpInterestEventHook*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the event hook" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "interest"
--           , argType =
--               TInterface Name { namespace = "Wp" , name = "ObjectInterest" }
--           , argCType = Just "WpObjectInterest*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the event interest" , 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_interest_event_hook_add_interest_full" wp_interest_event_hook_add_interest_full :: 
    Ptr InterestEventHook ->                -- self : TInterface (Name {namespace = "Wp", name = "InterestEventHook"})
    Ptr Wp.ObjectInterest.ObjectInterest -> -- interest : TInterface (Name {namespace = "Wp", name = "ObjectInterest"})
    IO ()

-- | Declares interest on events. The interest must be constructed to match WP_TYPE_EVENT objects and it is going to be matched against the WpEvent\'s properties.
interestEventHookAddInterestFull ::
    (B.CallStack.HasCallStack, MonadIO m, IsInterestEventHook a) =>
    a
    -- ^ /@self@/: the event hook
    -> Wp.ObjectInterest.ObjectInterest
    -- ^ /@interest@/: the event interest
    -> m ()
interestEventHookAddInterestFull self interest = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    interest' <- B.ManagedPtr.disownBoxed interest
    wp_interest_event_hook_add_interest_full self' interest'
    touchManagedPtr self
    touchManagedPtr interest
    return ()

#if defined(ENABLE_OVERLOADING)
data InterestEventHookAddInterestFullMethodInfo
instance (signature ~ (Wp.ObjectInterest.ObjectInterest -> m ()), MonadIO m, IsInterestEventHook a) => O.OverloadedMethod InterestEventHookAddInterestFullMethodInfo a signature where
    overloadedMethod = interestEventHookAddInterestFull

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


#endif


