    {-# LANGUAGE TypeApplications #-}

    -- | Copyright  : Will Thompson and Iñaki García Etxebarria
    -- License    : LGPL-2.1
    -- Maintainer : Iñaki García Etxebarria
    --
    -- Provides context information for a context menu event.
    --
    -- /Since: 0.76/

    #if !defined(__HADDOCK_VERSION__)
    #define ENABLE_OVERLOADING
    #endif

    module GI.Vte.Structs.EventContext
        (

    -- * Exported types
        EventContext(..)                        ,

     -- * Methods
    -- |
    --
    --  === __Click to display all available methods, including inherited ones__
    -- ==== Methods
    -- /None/.
    --
    -- ==== Getters
    -- [getEvent]("GI.Vte.Structs.EventContext#g:method:getEvent").
    --
    -- ==== Setters
    -- /None/.

    #if defined(ENABLE_OVERLOADING)
        ResolveEventContextMethod               ,
    #endif

    -- ** getEvent #method:getEvent#

    #if defined(ENABLE_OVERLOADING)
        EventContextGetEventMethodInfo          ,
    #endif
        eventContextGetEvent                    ,

        ) 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 GI.Gdk.Unions.Event as Gdk.Event

    -- | Memory-managed wrapper type.
    newtype EventContext = EventContext (SP.ManagedPtr EventContext)
        deriving (EventContext -> EventContext -> Bool
    (EventContext -> EventContext -> Bool)
    -> (EventContext -> EventContext -> Bool) -> Eq EventContext
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: EventContext -> EventContext -> Bool
    == :: EventContext -> EventContext -> Bool
    $c/= :: EventContext -> EventContext -> Bool
    /= :: EventContext -> EventContext -> Bool
    Eq)

    instance SP.ManagedPtrNewtype EventContext where
        toManagedPtr :: EventContext -> ManagedPtr EventContext
    toManagedPtr (EventContext ManagedPtr EventContext
    p) = ManagedPtr EventContext
    p

    -- XXX Wrapping a foreign struct/union with no known destructor or size, leak?
    instance BoxedPtr EventContext where
        boxedPtrCopy :: EventContext -> IO EventContext
    boxedPtrCopy = EventContext -> IO EventContext
    forall a. a -> IO a
    forall (m :: * -> *) a. Monad m => a -> m a
    return
        boxedPtrFree :: EventContext -> IO ()
    boxedPtrFree = \EventContext
    _x -> () -> IO ()
    forall a. a -> IO a
    forall (m :: * -> *) a. Monad m => a -> m a
    return ()

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

    -- method EventContext::get_event
    -- method type : OrdinaryMethod
    -- Args: [ Arg
    --           { argCName = "context"
    --           , argType =
    --               TInterface Name { namespace = "Vte" , name = "EventContext" }
    --           , direction = DirectionIn
    --           , mayBeNull = False
    --           , argDoc =
    --               Documentation
    --                 { rawDocText = Just "the #VteEventContext"
    --                 , sinceVersion = Nothing
    --                 }
    --           , argScope = ScopeTypeInvalid
    --           , argClosure = -1
    --           , argDestroy = -1
    --           , argCallerAllocates = False
    --           , argCallbackUserData = False
    --           , transfer = TransferNothing
    --           }
    --       ]
    -- Lengths: []
    -- returnType: Just (TInterface Name { namespace = "Gdk" , name = "Event" })
    -- throws : False
    -- Skip return : False

    foreign import ccall "vte_event_context_get_event" vte_event_context_get_event ::
        Ptr EventContext ->                     -- context : TInterface (Name {namespace = "Vte", name = "EventContext"})
        IO (Ptr Gdk.Event.Event)

    -- | /No description available in the introspection data./
    --
    -- /Since: 0.76/
    eventContextGetEvent ::
        (B.CallStack.HasCallStack, MonadIO m) =>
        EventContext
        -- ^ /@context@/: the t'GI.Vte.Structs.EventContext.EventContext'
        -> m Gdk.Event.Event
        -- ^ __Returns:__ the t'GI.Gdk.Unions.Event.Event' that triggered the event, or 'P.Nothing' if it was not
        --   triggered by an event
    eventContextGetEvent :: forall (m :: * -> *).
    (HasCallStack, MonadIO m) =>
    EventContext -> m Event
    eventContextGetEvent EventContext
    context = IO Event -> m Event
    forall a. IO a -> m a
    forall (m :: * -> *) a. MonadIO m => IO a -> m a
    liftIO (IO Event -> m Event) -> IO Event -> m Event
    forall a b. (a -> b) -> a -> b
    $ do
        Ptr EventContext
    context' <- EventContext -> IO (Ptr EventContext)
    forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
    unsafeManagedPtrGetPtr EventContext
    context
        Ptr Event
    result <- Ptr EventContext -> IO (Ptr Event)
    vte_event_context_get_event Ptr EventContext
    context'
        Text -> Ptr Event -> IO ()
    forall a. HasCallStack => Text -> Ptr a -> IO ()
    checkUnexpectedReturnNULL Text
    "eventContextGetEvent" Ptr Event
    result
        Event
    result' <- ((ManagedPtr Event -> Event) -> Ptr Event -> IO Event
    forall a.
    (HasCallStack, GBoxed a) =>
    (ManagedPtr a -> a) -> Ptr a -> IO a
    newBoxed ManagedPtr Event -> Event
    Gdk.Event.Event) Ptr Event
    result
        EventContext -> IO ()
    forall a. ManagedPtrNewtype a => a -> IO ()
    touchManagedPtr EventContext
    context
        Event -> IO Event
    forall a. a -> IO a
    forall (m :: * -> *) a. Monad m => a -> m a
    return Event
    result'

    #if defined(ENABLE_OVERLOADING)
    data EventContextGetEventMethodInfo
    instance (signature ~ (m Gdk.Event.Event), MonadIO m) => O.OverloadedMethod EventContextGetEventMethodInfo EventContext signature where
        overloadedMethod = eventContextGetEvent

    instance O.OverloadedMethodInfo EventContextGetEventMethodInfo EventContext where
        overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
            O.resolvedSymbolName = "GI.Vte.Structs.EventContext.eventContextGetEvent",
            O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-vte-2.91.31/docs/GI-Vte-Structs-EventContext.html#v:eventContextGetEvent"
            })

    #endif

    #if defined(ENABLE_OVERLOADING)
    type family ResolveEventContextMethod (t :: Symbol) (o :: DK.Type) :: DK.Type where
        ResolveEventContextMethod "getEvent" o = EventContextGetEventMethodInfo
        ResolveEventContextMethod l o = O.MethodResolutionFailed l o

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

    #endif

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

    #endif