{- |
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.Gdk.Objects.DragContext
    ( 

-- * Exported types
    DragContext(..)                         ,
    DragContextK                            ,
    toDragContext                           ,
    noDragContext                           ,


 -- * Methods
-- ** dragContextGetActions
    dragContextGetActions                   ,


-- ** dragContextGetDestWindow
    dragContextGetDestWindow                ,


-- ** dragContextGetDevice
    dragContextGetDevice                    ,


-- ** dragContextGetProtocol
    dragContextGetProtocol                  ,


-- ** dragContextGetSelectedAction
    dragContextGetSelectedAction            ,


-- ** dragContextGetSourceWindow
    dragContextGetSourceWindow              ,


-- ** dragContextGetSuggestedAction
    dragContextGetSuggestedAction           ,


-- ** dragContextListTargets
    dragContextListTargets                  ,


-- ** dragContextSetDevice
    dragContextSetDevice                    ,




    ) 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.Gdk.Types
import GI.Gdk.Callbacks
import qualified GI.GObject as GObject

newtype DragContext = DragContext (ForeignPtr DragContext)
foreign import ccall "gdk_drag_context_get_type"
    c_gdk_drag_context_get_type :: IO GType

type instance ParentTypes DragContext = DragContextParentTypes
type DragContextParentTypes = '[GObject.Object]

instance GObject DragContext where
    gobjectIsInitiallyUnowned _ = False
    gobjectType _ = c_gdk_drag_context_get_type
    

class GObject o => DragContextK o
instance (GObject o, IsDescendantOf DragContext o) => DragContextK o

toDragContext :: DragContextK o => o -> IO DragContext
toDragContext = unsafeCastTo DragContext

noDragContext :: Maybe DragContext
noDragContext = Nothing

type instance AttributeList DragContext = DragContextAttributeList
type DragContextAttributeList = ('[ ] :: [(Symbol, *)])

type instance SignalList DragContext = DragContextSignalList
type DragContextSignalList = ('[ '("notify", GObject.ObjectNotifySignalInfo), '("notify::[property]", GObjectNotifySignalInfo)] :: [(Symbol, *)])

-- method DragContext::get_actions
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gdk" "DragContext", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gdk" "DragContext", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "Gdk" "DragAction"
-- throws : False
-- Skip return : False

foreign import ccall "gdk_drag_context_get_actions" gdk_drag_context_get_actions :: 
    Ptr DragContext ->                      -- _obj : TInterface "Gdk" "DragContext"
    IO CUInt


dragContextGetActions ::
    (MonadIO m, DragContextK a) =>
    a ->                                    -- _obj
    m [DragAction]
dragContextGetActions _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- gdk_drag_context_get_actions _obj'
    let result' = wordToGFlags result
    touchManagedPtr _obj
    return result'

-- method DragContext::get_dest_window
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gdk" "DragContext", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gdk" "DragContext", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "Gdk" "Window"
-- throws : False
-- Skip return : False

foreign import ccall "gdk_drag_context_get_dest_window" gdk_drag_context_get_dest_window :: 
    Ptr DragContext ->                      -- _obj : TInterface "Gdk" "DragContext"
    IO (Ptr Window)


dragContextGetDestWindow ::
    (MonadIO m, DragContextK a) =>
    a ->                                    -- _obj
    m Window
dragContextGetDestWindow _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- gdk_drag_context_get_dest_window _obj'
    checkUnexpectedReturnNULL "gdk_drag_context_get_dest_window" result
    result' <- (newObject Window) result
    touchManagedPtr _obj
    return result'

-- method DragContext::get_device
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gdk" "DragContext", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gdk" "DragContext", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "Gdk" "Device"
-- throws : False
-- Skip return : False

foreign import ccall "gdk_drag_context_get_device" gdk_drag_context_get_device :: 
    Ptr DragContext ->                      -- _obj : TInterface "Gdk" "DragContext"
    IO (Ptr Device)


dragContextGetDevice ::
    (MonadIO m, DragContextK a) =>
    a ->                                    -- _obj
    m Device
dragContextGetDevice _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- gdk_drag_context_get_device _obj'
    checkUnexpectedReturnNULL "gdk_drag_context_get_device" result
    result' <- (newObject Device) result
    touchManagedPtr _obj
    return result'

-- method DragContext::get_protocol
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gdk" "DragContext", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gdk" "DragContext", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "Gdk" "DragProtocol"
-- throws : False
-- Skip return : False

foreign import ccall "gdk_drag_context_get_protocol" gdk_drag_context_get_protocol :: 
    Ptr DragContext ->                      -- _obj : TInterface "Gdk" "DragContext"
    IO CUInt


dragContextGetProtocol ::
    (MonadIO m, DragContextK a) =>
    a ->                                    -- _obj
    m DragProtocol
dragContextGetProtocol _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- gdk_drag_context_get_protocol _obj'
    let result' = (toEnum . fromIntegral) result
    touchManagedPtr _obj
    return result'

-- method DragContext::get_selected_action
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gdk" "DragContext", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gdk" "DragContext", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "Gdk" "DragAction"
-- throws : False
-- Skip return : False

foreign import ccall "gdk_drag_context_get_selected_action" gdk_drag_context_get_selected_action :: 
    Ptr DragContext ->                      -- _obj : TInterface "Gdk" "DragContext"
    IO CUInt


dragContextGetSelectedAction ::
    (MonadIO m, DragContextK a) =>
    a ->                                    -- _obj
    m [DragAction]
dragContextGetSelectedAction _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- gdk_drag_context_get_selected_action _obj'
    let result' = wordToGFlags result
    touchManagedPtr _obj
    return result'

-- method DragContext::get_source_window
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gdk" "DragContext", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gdk" "DragContext", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "Gdk" "Window"
-- throws : False
-- Skip return : False

foreign import ccall "gdk_drag_context_get_source_window" gdk_drag_context_get_source_window :: 
    Ptr DragContext ->                      -- _obj : TInterface "Gdk" "DragContext"
    IO (Ptr Window)


dragContextGetSourceWindow ::
    (MonadIO m, DragContextK a) =>
    a ->                                    -- _obj
    m Window
dragContextGetSourceWindow _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- gdk_drag_context_get_source_window _obj'
    checkUnexpectedReturnNULL "gdk_drag_context_get_source_window" result
    result' <- (newObject Window) result
    touchManagedPtr _obj
    return result'

-- method DragContext::get_suggested_action
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gdk" "DragContext", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gdk" "DragContext", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "Gdk" "DragAction"
-- throws : False
-- Skip return : False

foreign import ccall "gdk_drag_context_get_suggested_action" gdk_drag_context_get_suggested_action :: 
    Ptr DragContext ->                      -- _obj : TInterface "Gdk" "DragContext"
    IO CUInt


dragContextGetSuggestedAction ::
    (MonadIO m, DragContextK a) =>
    a ->                                    -- _obj
    m [DragAction]
dragContextGetSuggestedAction _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- gdk_drag_context_get_suggested_action _obj'
    let result' = wordToGFlags result
    touchManagedPtr _obj
    return result'

-- method DragContext::list_targets
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gdk" "DragContext", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gdk" "DragContext", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TGList (TInterface "Gdk" "Atom")
-- throws : False
-- Skip return : False

foreign import ccall "gdk_drag_context_list_targets" gdk_drag_context_list_targets :: 
    Ptr DragContext ->                      -- _obj : TInterface "Gdk" "DragContext"
    IO (Ptr (GList (Ptr Atom)))


dragContextListTargets ::
    (MonadIO m, DragContextK a) =>
    a ->                                    -- _obj
    m [Atom]
dragContextListTargets _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- gdk_drag_context_list_targets _obj'
    checkUnexpectedReturnNULL "gdk_drag_context_list_targets" result
    -- XXX Wrapping a foreign struct/union with no known destructor, leak?
    result' <- unpackGList result
    result'' <- mapM (\x -> Atom <$> newForeignPtr_ x) result'
    touchManagedPtr _obj
    return result''

-- method DragContext::set_device
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gdk" "DragContext", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "device", argType = TInterface "Gdk" "Device", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gdk" "DragContext", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "device", argType = TInterface "Gdk" "Device", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False

foreign import ccall "gdk_drag_context_set_device" gdk_drag_context_set_device :: 
    Ptr DragContext ->                      -- _obj : TInterface "Gdk" "DragContext"
    Ptr Device ->                           -- device : TInterface "Gdk" "Device"
    IO ()


dragContextSetDevice ::
    (MonadIO m, DragContextK a, DeviceK b) =>
    a ->                                    -- _obj
    b ->                                    -- device
    m ()
dragContextSetDevice _obj device = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    let device' = unsafeManagedPtrCastPtr device
    gdk_drag_context_set_device _obj' device'
    touchManagedPtr _obj
    touchManagedPtr device
    return ()