{- |
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.WebKit2.Objects.ColorChooserRequest
    ( 

-- * Exported types
    ColorChooserRequest(..)                 ,
    ColorChooserRequestK                    ,
    toColorChooserRequest                   ,
    noColorChooserRequest                   ,


 -- * Methods
-- ** colorChooserRequestCancel
    colorChooserRequestCancel               ,


-- ** colorChooserRequestFinish
    colorChooserRequestFinish               ,


-- ** colorChooserRequestGetElementRectangle
    colorChooserRequestGetElementRectangle  ,


-- ** colorChooserRequestGetRgba
    colorChooserRequestGetRgba              ,


-- ** colorChooserRequestSetRgba
    colorChooserRequestSetRgba              ,




 -- * Properties
-- ** Rgba
    ColorChooserRequestRgbaPropertyInfo     ,
    constructColorChooserRequestRgba        ,
    getColorChooserRequestRgba              ,
    setColorChooserRequestRgba              ,




 -- * Signals
-- ** Finished
    ColorChooserRequestFinishedCallback     ,
    ColorChooserRequestFinishedCallbackC    ,
    ColorChooserRequestFinishedSignalInfo   ,
    afterColorChooserRequestFinished        ,
    colorChooserRequestFinishedCallbackWrapper,
    colorChooserRequestFinishedClosure      ,
    mkColorChooserRequestFinishedCallback   ,
    noColorChooserRequestFinishedCallback   ,
    onColorChooserRequestFinished           ,




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

newtype ColorChooserRequest = ColorChooserRequest (ForeignPtr ColorChooserRequest)
foreign import ccall "webkit_color_chooser_request_get_type"
    c_webkit_color_chooser_request_get_type :: IO GType

type instance ParentTypes ColorChooserRequest = ColorChooserRequestParentTypes
type ColorChooserRequestParentTypes = '[GObject.Object]

instance GObject ColorChooserRequest where
    gobjectIsInitiallyUnowned _ = False
    gobjectType _ = c_webkit_color_chooser_request_get_type
    

class GObject o => ColorChooserRequestK o
instance (GObject o, IsDescendantOf ColorChooserRequest o) => ColorChooserRequestK o

toColorChooserRequest :: ColorChooserRequestK o => o -> IO ColorChooserRequest
toColorChooserRequest = unsafeCastTo ColorChooserRequest

noColorChooserRequest :: Maybe ColorChooserRequest
noColorChooserRequest = Nothing

-- signal ColorChooserRequest::finished
type ColorChooserRequestFinishedCallback =
    IO ()

noColorChooserRequestFinishedCallback :: Maybe ColorChooserRequestFinishedCallback
noColorChooserRequestFinishedCallback = Nothing

type ColorChooserRequestFinishedCallbackC =
    Ptr () ->                               -- object
    Ptr () ->                               -- user_data
    IO ()

foreign import ccall "wrapper"
    mkColorChooserRequestFinishedCallback :: ColorChooserRequestFinishedCallbackC -> IO (FunPtr ColorChooserRequestFinishedCallbackC)

colorChooserRequestFinishedClosure :: ColorChooserRequestFinishedCallback -> IO Closure
colorChooserRequestFinishedClosure cb = newCClosure =<< mkColorChooserRequestFinishedCallback wrapped
    where wrapped = colorChooserRequestFinishedCallbackWrapper cb

colorChooserRequestFinishedCallbackWrapper ::
    ColorChooserRequestFinishedCallback ->
    Ptr () ->
    Ptr () ->
    IO ()
colorChooserRequestFinishedCallbackWrapper _cb _ _ = do
    _cb 

onColorChooserRequestFinished :: (GObject a, MonadIO m) => a -> ColorChooserRequestFinishedCallback -> m SignalHandlerId
onColorChooserRequestFinished obj cb = liftIO $ connectColorChooserRequestFinished obj cb SignalConnectBefore
afterColorChooserRequestFinished :: (GObject a, MonadIO m) => a -> ColorChooserRequestFinishedCallback -> m SignalHandlerId
afterColorChooserRequestFinished obj cb = connectColorChooserRequestFinished obj cb SignalConnectAfter

connectColorChooserRequestFinished :: (GObject a, MonadIO m) =>
                                      a -> ColorChooserRequestFinishedCallback -> SignalConnectMode -> m SignalHandlerId
connectColorChooserRequestFinished obj cb after = liftIO $ do
    cb' <- mkColorChooserRequestFinishedCallback (colorChooserRequestFinishedCallbackWrapper cb)
    connectSignalFunPtr obj "finished" cb' after

-- VVV Prop "rgba"
   -- Type: TInterface "Gdk" "RGBA"
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstruct]

getColorChooserRequestRgba :: (MonadIO m, ColorChooserRequestK o) => o -> m Gdk.RGBA
getColorChooserRequestRgba obj = liftIO $ getObjectPropertyBoxed obj "rgba" Gdk.RGBA

setColorChooserRequestRgba :: (MonadIO m, ColorChooserRequestK o) => o -> Gdk.RGBA -> m ()
setColorChooserRequestRgba obj val = liftIO $ setObjectPropertyBoxed obj "rgba" val

constructColorChooserRequestRgba :: Gdk.RGBA -> IO ([Char], GValue)
constructColorChooserRequestRgba val = constructObjectPropertyBoxed "rgba" val

data ColorChooserRequestRgbaPropertyInfo
instance AttrInfo ColorChooserRequestRgbaPropertyInfo where
    type AttrAllowedOps ColorChooserRequestRgbaPropertyInfo = '[ 'AttrSet, 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint ColorChooserRequestRgbaPropertyInfo = (~) Gdk.RGBA
    type AttrBaseTypeConstraint ColorChooserRequestRgbaPropertyInfo = ColorChooserRequestK
    type AttrGetType ColorChooserRequestRgbaPropertyInfo = Gdk.RGBA
    type AttrLabel ColorChooserRequestRgbaPropertyInfo = "ColorChooserRequest::rgba"
    attrGet _ = getColorChooserRequestRgba
    attrSet _ = setColorChooserRequestRgba
    attrConstruct _ = constructColorChooserRequestRgba

type instance AttributeList ColorChooserRequest = ColorChooserRequestAttributeList
type ColorChooserRequestAttributeList = ('[ '("rgba", ColorChooserRequestRgbaPropertyInfo)] :: [(Symbol, *)])

data ColorChooserRequestFinishedSignalInfo
instance SignalInfo ColorChooserRequestFinishedSignalInfo where
    type HaskellCallbackType ColorChooserRequestFinishedSignalInfo = ColorChooserRequestFinishedCallback
    connectSignal _ = connectColorChooserRequestFinished

type instance SignalList ColorChooserRequest = ColorChooserRequestSignalList
type ColorChooserRequestSignalList = ('[ '("finished", ColorChooserRequestFinishedSignalInfo), '("notify", GObject.ObjectNotifySignalInfo), '("notify::[property]", GObjectNotifySignalInfo)] :: [(Symbol, *)])

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

foreign import ccall "webkit_color_chooser_request_cancel" webkit_color_chooser_request_cancel :: 
    Ptr ColorChooserRequest ->              -- _obj : TInterface "WebKit2" "ColorChooserRequest"
    IO ()


colorChooserRequestCancel ::
    (MonadIO m, ColorChooserRequestK a) =>
    a ->                                    -- _obj
    m ()
colorChooserRequestCancel _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    webkit_color_chooser_request_cancel _obj'
    touchManagedPtr _obj
    return ()

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

foreign import ccall "webkit_color_chooser_request_finish" webkit_color_chooser_request_finish :: 
    Ptr ColorChooserRequest ->              -- _obj : TInterface "WebKit2" "ColorChooserRequest"
    IO ()


colorChooserRequestFinish ::
    (MonadIO m, ColorChooserRequestK a) =>
    a ->                                    -- _obj
    m ()
colorChooserRequestFinish _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    webkit_color_chooser_request_finish _obj'
    touchManagedPtr _obj
    return ()

-- method ColorChooserRequest::get_element_rectangle
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "WebKit2" "ColorChooserRequest", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "rect", argType = TInterface "Gdk" "Rectangle", direction = DirectionOut, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "WebKit2" "ColorChooserRequest", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False

foreign import ccall "webkit_color_chooser_request_get_element_rectangle" webkit_color_chooser_request_get_element_rectangle :: 
    Ptr ColorChooserRequest ->              -- _obj : TInterface "WebKit2" "ColorChooserRequest"
    Ptr Gdk.Rectangle ->                    -- rect : TInterface "Gdk" "Rectangle"
    IO ()


colorChooserRequestGetElementRectangle ::
    (MonadIO m, ColorChooserRequestK a) =>
    a ->                                    -- _obj
    m (Gdk.Rectangle)
colorChooserRequestGetElementRectangle _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    rect <- callocBoxedBytes 16 :: IO (Ptr Gdk.Rectangle)
    webkit_color_chooser_request_get_element_rectangle _obj' rect
    rect' <- (wrapBoxed Gdk.Rectangle) rect
    touchManagedPtr _obj
    return rect'

-- method ColorChooserRequest::get_rgba
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "WebKit2" "ColorChooserRequest", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "rgba", argType = TInterface "Gdk" "RGBA", direction = DirectionOut, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "WebKit2" "ColorChooserRequest", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False

foreign import ccall "webkit_color_chooser_request_get_rgba" webkit_color_chooser_request_get_rgba :: 
    Ptr ColorChooserRequest ->              -- _obj : TInterface "WebKit2" "ColorChooserRequest"
    Ptr Gdk.RGBA ->                         -- rgba : TInterface "Gdk" "RGBA"
    IO ()


colorChooserRequestGetRgba ::
    (MonadIO m, ColorChooserRequestK a) =>
    a ->                                    -- _obj
    m (Gdk.RGBA)
colorChooserRequestGetRgba _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    rgba <- callocBoxedBytes 32 :: IO (Ptr Gdk.RGBA)
    webkit_color_chooser_request_get_rgba _obj' rgba
    rgba' <- (wrapBoxed Gdk.RGBA) rgba
    touchManagedPtr _obj
    return rgba'

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

foreign import ccall "webkit_color_chooser_request_set_rgba" webkit_color_chooser_request_set_rgba :: 
    Ptr ColorChooserRequest ->              -- _obj : TInterface "WebKit2" "ColorChooserRequest"
    Ptr Gdk.RGBA ->                         -- rgba : TInterface "Gdk" "RGBA"
    IO ()


colorChooserRequestSetRgba ::
    (MonadIO m, ColorChooserRequestK a) =>
    a ->                                    -- _obj
    Gdk.RGBA ->                             -- rgba
    m ()
colorChooserRequestSetRgba _obj rgba = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    let rgba' = unsafeManagedPtrGetPtr rgba
    webkit_color_chooser_request_set_rgba _obj' rgba'
    touchManagedPtr _obj
    touchManagedPtr rgba
    return ()