{-# LANGUAGE TypeApplications #-}


-- | Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
-- License    : LGPL-2.1
-- Maintainer : Iñaki García Etxebarria
-- 
-- See t'GI.Atk.Objects.Socket.Socket'

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

module GI.Atk.Objects.Plug
    ( 

-- * Exported types
    Plug(..)                                ,
    IsPlug                                  ,
    toPlug                                  ,
    noPlug                                  ,


 -- * Methods
-- ** Overloaded methods #method:Overloaded methods#

#if defined(ENABLE_OVERLOADING)
    ResolvePlugMethod                       ,
#endif


-- ** getId #method:getId#

#if defined(ENABLE_OVERLOADING)
    PlugGetIdMethodInfo                     ,
#endif
    plugGetId                               ,


-- ** new #method:new#

    plugNew                                 ,




    ) where

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

import qualified Data.GI.Base.Attributes as GI.Attributes
import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GClosure as B.GClosure
import qualified Data.GI.Base.GError as B.GError
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 Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import qualified Foreign.Ptr as FP
import qualified GHC.OverloadedLabels as OL

import {-# SOURCE #-} qualified GI.Atk.Interfaces.Component as Atk.Component
import {-# SOURCE #-} qualified GI.Atk.Objects.Object as Atk.Object
import qualified GI.GObject.Objects.Object as GObject.Object

-- | Memory-managed wrapper type.
newtype Plug = Plug (ManagedPtr Plug)
    deriving (Plug -> Plug -> Bool
(Plug -> Plug -> Bool) -> (Plug -> Plug -> Bool) -> Eq Plug
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Plug -> Plug -> Bool
$c/= :: Plug -> Plug -> Bool
== :: Plug -> Plug -> Bool
$c== :: Plug -> Plug -> Bool
Eq)
foreign import ccall "atk_plug_get_type"
    c_atk_plug_get_type :: IO GType

instance GObject Plug where
    gobjectType :: IO GType
gobjectType = IO GType
c_atk_plug_get_type
    

-- | Convert 'Plug' to and from 'Data.GI.Base.GValue.GValue' with 'Data.GI.Base.GValue.toGValue' and 'Data.GI.Base.GValue.fromGValue'.
instance B.GValue.IsGValue Plug where
    toGValue :: Plug -> IO GValue
toGValue o :: Plug
o = do
        GType
gtype <- IO GType
c_atk_plug_get_type
        Plug -> (Ptr Plug -> IO GValue) -> IO GValue
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
B.ManagedPtr.withManagedPtr Plug
o (GType -> (GValue -> Ptr Plug -> IO ()) -> Ptr Plug -> IO GValue
forall a. GType -> (GValue -> a -> IO ()) -> a -> IO GValue
B.GValue.buildGValue GType
gtype GValue -> Ptr Plug -> IO ()
forall a. GObject a => GValue -> Ptr a -> IO ()
B.GValue.set_object)
        
    fromGValue :: GValue -> IO Plug
fromGValue gv :: GValue
gv = do
        Ptr Plug
ptr <- GValue -> IO (Ptr Plug)
forall b. GObject b => GValue -> IO (Ptr b)
B.GValue.get_object GValue
gv :: IO (Ptr Plug)
        (ManagedPtr Plug -> Plug) -> Ptr Plug -> IO Plug
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
B.ManagedPtr.newObject ManagedPtr Plug -> Plug
Plug Ptr Plug
ptr
        
    

-- | Type class for types which can be safely cast to `Plug`, for instance with `toPlug`.
class (GObject o, O.IsDescendantOf Plug o) => IsPlug o
instance (GObject o, O.IsDescendantOf Plug o) => IsPlug o

instance O.HasParentTypes Plug
type instance O.ParentTypes Plug = '[Atk.Object.Object, GObject.Object.Object, Atk.Component.Component]

-- | Cast to `Plug`, for types for which this is known to be safe. For general casts, use `Data.GI.Base.ManagedPtr.castTo`.
toPlug :: (MonadIO m, IsPlug o) => o -> m Plug
toPlug :: o -> m Plug
toPlug = IO Plug -> m Plug
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Plug -> m Plug) -> (o -> IO Plug) -> o -> m Plug
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ManagedPtr Plug -> Plug) -> o -> IO Plug
forall o o'.
(HasCallStack, GObject o, GObject o') =>
(ManagedPtr o' -> o') -> o -> IO o'
unsafeCastTo ManagedPtr Plug -> Plug
Plug

-- | A convenience alias for `Nothing` :: `Maybe` `Plug`.
noPlug :: Maybe Plug
noPlug :: Maybe Plug
noPlug = Maybe Plug
forall a. Maybe a
Nothing

#if defined(ENABLE_OVERLOADING)
type family ResolvePlugMethod (t :: Symbol) (o :: *) :: * where
    ResolvePlugMethod "addRelationship" o = Atk.Object.ObjectAddRelationshipMethodInfo
    ResolvePlugMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
    ResolvePlugMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
    ResolvePlugMethod "contains" o = Atk.Component.ComponentContainsMethodInfo
    ResolvePlugMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
    ResolvePlugMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
    ResolvePlugMethod "getv" o = GObject.Object.ObjectGetvMethodInfo
    ResolvePlugMethod "grabFocus" o = Atk.Component.ComponentGrabFocusMethodInfo
    ResolvePlugMethod "initialize" o = Atk.Object.ObjectInitializeMethodInfo
    ResolvePlugMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
    ResolvePlugMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
    ResolvePlugMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
    ResolvePlugMethod "notifyStateChange" o = Atk.Object.ObjectNotifyStateChangeMethodInfo
    ResolvePlugMethod "peekParent" o = Atk.Object.ObjectPeekParentMethodInfo
    ResolvePlugMethod "ref" o = GObject.Object.ObjectRefMethodInfo
    ResolvePlugMethod "refAccessibleAtPoint" o = Atk.Component.ComponentRefAccessibleAtPointMethodInfo
    ResolvePlugMethod "refAccessibleChild" o = Atk.Object.ObjectRefAccessibleChildMethodInfo
    ResolvePlugMethod "refRelationSet" o = Atk.Object.ObjectRefRelationSetMethodInfo
    ResolvePlugMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
    ResolvePlugMethod "refStateSet" o = Atk.Object.ObjectRefStateSetMethodInfo
    ResolvePlugMethod "removeFocusHandler" o = Atk.Component.ComponentRemoveFocusHandlerMethodInfo
    ResolvePlugMethod "removePropertyChangeHandler" o = Atk.Object.ObjectRemovePropertyChangeHandlerMethodInfo
    ResolvePlugMethod "removeRelationship" o = Atk.Object.ObjectRemoveRelationshipMethodInfo
    ResolvePlugMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
    ResolvePlugMethod "scrollTo" o = Atk.Component.ComponentScrollToMethodInfo
    ResolvePlugMethod "scrollToPoint" o = Atk.Component.ComponentScrollToPointMethodInfo
    ResolvePlugMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
    ResolvePlugMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
    ResolvePlugMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
    ResolvePlugMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
    ResolvePlugMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
    ResolvePlugMethod "getAlpha" o = Atk.Component.ComponentGetAlphaMethodInfo
    ResolvePlugMethod "getAttributes" o = Atk.Object.ObjectGetAttributesMethodInfo
    ResolvePlugMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
    ResolvePlugMethod "getDescription" o = Atk.Object.ObjectGetDescriptionMethodInfo
    ResolvePlugMethod "getExtents" o = Atk.Component.ComponentGetExtentsMethodInfo
    ResolvePlugMethod "getId" o = PlugGetIdMethodInfo
    ResolvePlugMethod "getIndexInParent" o = Atk.Object.ObjectGetIndexInParentMethodInfo
    ResolvePlugMethod "getLayer" o = Atk.Object.ObjectGetLayerMethodInfo
    ResolvePlugMethod "getMdiZorder" o = Atk.Object.ObjectGetMdiZorderMethodInfo
    ResolvePlugMethod "getNAccessibleChildren" o = Atk.Object.ObjectGetNAccessibleChildrenMethodInfo
    ResolvePlugMethod "getName" o = Atk.Object.ObjectGetNameMethodInfo
    ResolvePlugMethod "getObjectLocale" o = Atk.Object.ObjectGetObjectLocaleMethodInfo
    ResolvePlugMethod "getParent" o = Atk.Object.ObjectGetParentMethodInfo
    ResolvePlugMethod "getPosition" o = Atk.Component.ComponentGetPositionMethodInfo
    ResolvePlugMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
    ResolvePlugMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
    ResolvePlugMethod "getRole" o = Atk.Object.ObjectGetRoleMethodInfo
    ResolvePlugMethod "getSize" o = Atk.Component.ComponentGetSizeMethodInfo
    ResolvePlugMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
    ResolvePlugMethod "setDataFull" o = GObject.Object.ObjectSetDataFullMethodInfo
    ResolvePlugMethod "setDescription" o = Atk.Object.ObjectSetDescriptionMethodInfo
    ResolvePlugMethod "setExtents" o = Atk.Component.ComponentSetExtentsMethodInfo
    ResolvePlugMethod "setName" o = Atk.Object.ObjectSetNameMethodInfo
    ResolvePlugMethod "setParent" o = Atk.Object.ObjectSetParentMethodInfo
    ResolvePlugMethod "setPosition" o = Atk.Component.ComponentSetPositionMethodInfo
    ResolvePlugMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolvePlugMethod "setRole" o = Atk.Object.ObjectSetRoleMethodInfo
    ResolvePlugMethod "setSize" o = Atk.Component.ComponentSetSizeMethodInfo
    ResolvePlugMethod l o = O.MethodResolutionFailed l o

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

#endif

#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList Plug
type instance O.AttributeList Plug = PlugAttributeList
type PlugAttributeList = ('[ '("accessibleComponentLayer", Atk.Object.ObjectAccessibleComponentLayerPropertyInfo), '("accessibleComponentMdiZorder", Atk.Object.ObjectAccessibleComponentMdiZorderPropertyInfo), '("accessibleDescription", Atk.Object.ObjectAccessibleDescriptionPropertyInfo), '("accessibleHypertextNlinks", Atk.Object.ObjectAccessibleHypertextNlinksPropertyInfo), '("accessibleName", Atk.Object.ObjectAccessibleNamePropertyInfo), '("accessibleParent", Atk.Object.ObjectAccessibleParentPropertyInfo), '("accessibleRole", Atk.Object.ObjectAccessibleRolePropertyInfo), '("accessibleTableCaption", Atk.Object.ObjectAccessibleTableCaptionPropertyInfo), '("accessibleTableCaptionObject", Atk.Object.ObjectAccessibleTableCaptionObjectPropertyInfo), '("accessibleTableColumnDescription", Atk.Object.ObjectAccessibleTableColumnDescriptionPropertyInfo), '("accessibleTableColumnHeader", Atk.Object.ObjectAccessibleTableColumnHeaderPropertyInfo), '("accessibleTableRowDescription", Atk.Object.ObjectAccessibleTableRowDescriptionPropertyInfo), '("accessibleTableRowHeader", Atk.Object.ObjectAccessibleTableRowHeaderPropertyInfo), '("accessibleTableSummary", Atk.Object.ObjectAccessibleTableSummaryPropertyInfo), '("accessibleValue", Atk.Object.ObjectAccessibleValuePropertyInfo)] :: [(Symbol, *)])
#endif

#if defined(ENABLE_OVERLOADING)
#endif

#if defined(ENABLE_OVERLOADING)
type instance O.SignalList Plug = PlugSignalList
type PlugSignalList = ('[ '("activeDescendantChanged", Atk.Object.ObjectActiveDescendantChangedSignalInfo), '("boundsChanged", Atk.Component.ComponentBoundsChangedSignalInfo), '("childrenChanged", Atk.Object.ObjectChildrenChangedSignalInfo), '("focusEvent", Atk.Object.ObjectFocusEventSignalInfo), '("notify", GObject.Object.ObjectNotifySignalInfo), '("propertyChange", Atk.Object.ObjectPropertyChangeSignalInfo), '("stateChange", Atk.Object.ObjectStateChangeSignalInfo), '("visibleDataChanged", Atk.Object.ObjectVisibleDataChangedSignalInfo)] :: [(Symbol, *)])

#endif

-- method Plug::new
-- method type : Constructor
-- Args: []
-- Lengths: []
-- returnType: Just (TInterface Name { namespace = "Atk" , name = "Plug" })
-- throws : False
-- Skip return : False

foreign import ccall "atk_plug_new" atk_plug_new :: 
    IO (Ptr Plug)

-- | /No description available in the introspection data./
plugNew ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m Plug
plugNew :: m Plug
plugNew  = IO Plug -> m Plug
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Plug -> m Plug) -> IO Plug -> m Plug
forall a b. (a -> b) -> a -> b
$ do
    Ptr Plug
result <- IO (Ptr Plug)
atk_plug_new
    Text -> Ptr Plug -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "plugNew" Ptr Plug
result
    Plug
result' <- ((ManagedPtr Plug -> Plug) -> Ptr Plug -> IO Plug
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
wrapObject ManagedPtr Plug -> Plug
Plug) Ptr Plug
result
    Plug -> IO Plug
forall (m :: * -> *) a. Monad m => a -> m a
return Plug
result'

#if defined(ENABLE_OVERLOADING)
#endif

-- method Plug::get_id
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "plug"
--           , argType = TInterface Name { namespace = "Atk" , name = "Plug" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "an #AtkPlug" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "atk_plug_get_id" atk_plug_get_id :: 
    Ptr Plug ->                             -- plug : TInterface (Name {namespace = "Atk", name = "Plug"})
    IO CString

-- | Gets the unique ID of an t'GI.Atk.Objects.Plug.Plug' object, which can be used to
-- embed inside of an t'GI.Atk.Objects.Socket.Socket' using 'GI.Atk.Objects.Socket.socketEmbed'.
-- 
-- Internally, this calls a class function that should be registered
-- by the IPC layer (usually at-spi2-atk). The implementor of an
-- t'GI.Atk.Objects.Plug.Plug' object should call this function (after atk-bridge is
-- loaded) and pass the value to the process implementing the
-- t'GI.Atk.Objects.Socket.Socket', so it could embed the plug.
-- 
-- /Since: 1.30/
plugGetId ::
    (B.CallStack.HasCallStack, MonadIO m, IsPlug a) =>
    a
    -- ^ /@plug@/: an t'GI.Atk.Objects.Plug.Plug'
    -> m T.Text
    -- ^ __Returns:__ the unique ID for the plug
plugGetId :: a -> m Text
plugGetId plug :: a
plug = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    Ptr Plug
plug' <- a -> IO (Ptr Plug)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
plug
    CString
result <- Ptr Plug -> IO CString
atk_plug_get_id Ptr Plug
plug'
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "plugGetId" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
plug
    Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result'

#if defined(ENABLE_OVERLOADING)
data PlugGetIdMethodInfo
instance (signature ~ (m T.Text), MonadIO m, IsPlug a) => O.MethodInfo PlugGetIdMethodInfo a signature where
    overloadedMethod = plugGetId

#endif