{- |
Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
License    : LGPL-2.1
Maintainer : Iñaki García Etxebarria (garetxe@gmail.com)
-}

module GI.Atk.Objects.Socket
    ( 

-- * Exported types
    Socket(..)                              ,
    SocketK                                 ,
    toSocket                                ,
    noSocket                                ,


 -- * Methods
-- ** socketEmbed
    socketEmbed                             ,


-- ** socketIsOccupied
    socketIsOccupied                        ,


-- ** socketNew
    socketNew                               ,




    ) where

import Prelude ()
import Data.GI.Base.ShortPrelude

import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map

import GI.Atk.Types
import GI.Atk.Callbacks
import qualified GI.GObject as GObject

newtype Socket = Socket (ForeignPtr Socket)
foreign import ccall "atk_socket_get_type"
    c_atk_socket_get_type :: IO GType

type instance ParentTypes Socket = SocketParentTypes
type SocketParentTypes = '[Object, GObject.Object, Component]

instance GObject Socket where
    gobjectIsInitiallyUnowned _ = False
    gobjectType _ = c_atk_socket_get_type
    

class GObject o => SocketK o
instance (GObject o, IsDescendantOf Socket o) => SocketK o

toSocket :: SocketK o => o -> IO Socket
toSocket = unsafeCastTo Socket

noSocket :: Maybe Socket
noSocket = Nothing

type instance AttributeList Socket = SocketAttributeList
type SocketAttributeList = ('[ '("accessible-component-layer", ObjectAccessibleComponentLayerPropertyInfo), '("accessible-component-mdi-zorder", ObjectAccessibleComponentMdiZorderPropertyInfo), '("accessible-description", ObjectAccessibleDescriptionPropertyInfo), '("accessible-hypertext-nlinks", ObjectAccessibleHypertextNlinksPropertyInfo), '("accessible-name", ObjectAccessibleNamePropertyInfo), '("accessible-parent", ObjectAccessibleParentPropertyInfo), '("accessible-role", ObjectAccessibleRolePropertyInfo), '("accessible-table-caption", ObjectAccessibleTableCaptionPropertyInfo), '("accessible-table-caption-object", ObjectAccessibleTableCaptionObjectPropertyInfo), '("accessible-table-column-description", ObjectAccessibleTableColumnDescriptionPropertyInfo), '("accessible-table-column-header", ObjectAccessibleTableColumnHeaderPropertyInfo), '("accessible-table-row-description", ObjectAccessibleTableRowDescriptionPropertyInfo), '("accessible-table-row-header", ObjectAccessibleTableRowHeaderPropertyInfo), '("accessible-table-summary", ObjectAccessibleTableSummaryPropertyInfo), '("accessible-value", ObjectAccessibleValuePropertyInfo)] :: [(Symbol, *)])

type instance SignalList Socket = SocketSignalList
type SocketSignalList = ('[ '("active-descendant-changed", ObjectActiveDescendantChangedSignalInfo), '("bounds-changed", ComponentBoundsChangedSignalInfo), '("children-changed", ObjectChildrenChangedSignalInfo), '("focus-event", ObjectFocusEventSignalInfo), '("notify", GObject.ObjectNotifySignalInfo), '("property-change", ObjectPropertyChangeSignalInfo), '("state-change", ObjectStateChangeSignalInfo), '("visible-data-changed", ObjectVisibleDataChangedSignalInfo), '("notify::[property]", GObjectNotifySignalInfo)] :: [(Symbol, *)])

-- method Socket::new
-- method type : Constructor
-- Args : []
-- Lengths : []
-- hInArgs : []
-- returnType : TInterface "Atk" "Socket"
-- throws : False
-- Skip return : False

foreign import ccall "atk_socket_new" atk_socket_new :: 
    IO (Ptr Socket)


socketNew ::
    (MonadIO m) =>
    m Socket
socketNew  = liftIO $ do
    result <- atk_socket_new
    checkUnexpectedReturnNULL "atk_socket_new" result
    result' <- (wrapObject Socket) result
    return result'

-- method Socket::embed
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Atk" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "plug_id", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Atk" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "plug_id", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False

foreign import ccall "atk_socket_embed" atk_socket_embed :: 
    Ptr Socket ->                           -- _obj : TInterface "Atk" "Socket"
    CString ->                              -- plug_id : TBasicType TUTF8
    IO ()


socketEmbed ::
    (MonadIO m, SocketK a) =>
    a ->                                    -- _obj
    T.Text ->                               -- plug_id
    m ()
socketEmbed _obj plug_id = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    plug_id' <- textToCString plug_id
    atk_socket_embed _obj' plug_id'
    touchManagedPtr _obj
    freeMem plug_id'
    return ()

-- method Socket::is_occupied
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Atk" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Atk" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TBoolean
-- throws : False
-- Skip return : False

foreign import ccall "atk_socket_is_occupied" atk_socket_is_occupied :: 
    Ptr Socket ->                           -- _obj : TInterface "Atk" "Socket"
    IO CInt


socketIsOccupied ::
    (MonadIO m, SocketK a) =>
    a ->                                    -- _obj
    m Bool
socketIsOccupied _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- atk_socket_is_occupied _obj'
    let result' = (/= 0) result
    touchManagedPtr _obj
    return result'