{- |
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.FileChooserRequest
    ( 

-- * Exported types
    FileChooserRequest(..)                  ,
    FileChooserRequestK                     ,
    toFileChooserRequest                    ,
    noFileChooserRequest                    ,


 -- * Methods
-- ** fileChooserRequestCancel
    fileChooserRequestCancel                ,


-- ** fileChooserRequestGetMimeTypes
    fileChooserRequestGetMimeTypes          ,


-- ** fileChooserRequestGetMimeTypesFilter
    fileChooserRequestGetMimeTypesFilter    ,


-- ** fileChooserRequestGetSelectMultiple
    fileChooserRequestGetSelectMultiple     ,


-- ** fileChooserRequestGetSelectedFiles
    fileChooserRequestGetSelectedFiles      ,


-- ** fileChooserRequestSelectFiles
    fileChooserRequestSelectFiles           ,




 -- * Properties
-- ** Filter
    FileChooserRequestFilterPropertyInfo    ,
    getFileChooserRequestFilter             ,


-- ** MimeTypes
    FileChooserRequestMimeTypesPropertyInfo ,
    getFileChooserRequestMimeTypes          ,


-- ** SelectMultiple
    FileChooserRequestSelectMultiplePropertyInfo,
    getFileChooserRequestSelectMultiple     ,


-- ** SelectedFiles
    FileChooserRequestSelectedFilesPropertyInfo,
    getFileChooserRequestSelectedFiles      ,




    ) 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.Gtk as Gtk

newtype FileChooserRequest = FileChooserRequest (ForeignPtr FileChooserRequest)
foreign import ccall "webkit_file_chooser_request_get_type"
    c_webkit_file_chooser_request_get_type :: IO GType

type instance ParentTypes FileChooserRequest = FileChooserRequestParentTypes
type FileChooserRequestParentTypes = '[GObject.Object]

instance GObject FileChooserRequest where
    gobjectIsInitiallyUnowned _ = False
    gobjectType _ = c_webkit_file_chooser_request_get_type
    

class GObject o => FileChooserRequestK o
instance (GObject o, IsDescendantOf FileChooserRequest o) => FileChooserRequestK o

toFileChooserRequest :: FileChooserRequestK o => o -> IO FileChooserRequest
toFileChooserRequest = unsafeCastTo FileChooserRequest

noFileChooserRequest :: Maybe FileChooserRequest
noFileChooserRequest = Nothing

-- VVV Prop "filter"
   -- Type: TInterface "Gtk" "FileFilter"
   -- Flags: [PropertyReadable]

getFileChooserRequestFilter :: (MonadIO m, FileChooserRequestK o) => o -> m Gtk.FileFilter
getFileChooserRequestFilter obj = liftIO $ getObjectPropertyObject obj "filter" Gtk.FileFilter

data FileChooserRequestFilterPropertyInfo
instance AttrInfo FileChooserRequestFilterPropertyInfo where
    type AttrAllowedOps FileChooserRequestFilterPropertyInfo = '[ 'AttrGet]
    type AttrSetTypeConstraint FileChooserRequestFilterPropertyInfo = (~) ()
    type AttrBaseTypeConstraint FileChooserRequestFilterPropertyInfo = FileChooserRequestK
    type AttrGetType FileChooserRequestFilterPropertyInfo = Gtk.FileFilter
    type AttrLabel FileChooserRequestFilterPropertyInfo = "FileChooserRequest::filter"
    attrGet _ = getFileChooserRequestFilter
    attrSet _ = undefined
    attrConstruct _ = undefined

-- VVV Prop "mime-types"
   -- Type: TCArray True (-1) (-1) (TBasicType TUTF8)
   -- Flags: [PropertyReadable]

getFileChooserRequestMimeTypes :: (MonadIO m, FileChooserRequestK o) => o -> m [T.Text]
getFileChooserRequestMimeTypes obj = liftIO $ getObjectPropertyStringArray obj "mime-types"

data FileChooserRequestMimeTypesPropertyInfo
instance AttrInfo FileChooserRequestMimeTypesPropertyInfo where
    type AttrAllowedOps FileChooserRequestMimeTypesPropertyInfo = '[ 'AttrGet]
    type AttrSetTypeConstraint FileChooserRequestMimeTypesPropertyInfo = (~) ()
    type AttrBaseTypeConstraint FileChooserRequestMimeTypesPropertyInfo = FileChooserRequestK
    type AttrGetType FileChooserRequestMimeTypesPropertyInfo = [T.Text]
    type AttrLabel FileChooserRequestMimeTypesPropertyInfo = "FileChooserRequest::mime-types"
    attrGet _ = getFileChooserRequestMimeTypes
    attrSet _ = undefined
    attrConstruct _ = undefined

-- VVV Prop "select-multiple"
   -- Type: TBasicType TBoolean
   -- Flags: [PropertyReadable]

getFileChooserRequestSelectMultiple :: (MonadIO m, FileChooserRequestK o) => o -> m Bool
getFileChooserRequestSelectMultiple obj = liftIO $ getObjectPropertyBool obj "select-multiple"

data FileChooserRequestSelectMultiplePropertyInfo
instance AttrInfo FileChooserRequestSelectMultiplePropertyInfo where
    type AttrAllowedOps FileChooserRequestSelectMultiplePropertyInfo = '[ 'AttrGet]
    type AttrSetTypeConstraint FileChooserRequestSelectMultiplePropertyInfo = (~) ()
    type AttrBaseTypeConstraint FileChooserRequestSelectMultiplePropertyInfo = FileChooserRequestK
    type AttrGetType FileChooserRequestSelectMultiplePropertyInfo = Bool
    type AttrLabel FileChooserRequestSelectMultiplePropertyInfo = "FileChooserRequest::select-multiple"
    attrGet _ = getFileChooserRequestSelectMultiple
    attrSet _ = undefined
    attrConstruct _ = undefined

-- VVV Prop "selected-files"
   -- Type: TCArray True (-1) (-1) (TBasicType TUTF8)
   -- Flags: [PropertyReadable]

getFileChooserRequestSelectedFiles :: (MonadIO m, FileChooserRequestK o) => o -> m [T.Text]
getFileChooserRequestSelectedFiles obj = liftIO $ getObjectPropertyStringArray obj "selected-files"

data FileChooserRequestSelectedFilesPropertyInfo
instance AttrInfo FileChooserRequestSelectedFilesPropertyInfo where
    type AttrAllowedOps FileChooserRequestSelectedFilesPropertyInfo = '[ 'AttrGet]
    type AttrSetTypeConstraint FileChooserRequestSelectedFilesPropertyInfo = (~) ()
    type AttrBaseTypeConstraint FileChooserRequestSelectedFilesPropertyInfo = FileChooserRequestK
    type AttrGetType FileChooserRequestSelectedFilesPropertyInfo = [T.Text]
    type AttrLabel FileChooserRequestSelectedFilesPropertyInfo = "FileChooserRequest::selected-files"
    attrGet _ = getFileChooserRequestSelectedFiles
    attrSet _ = undefined
    attrConstruct _ = undefined

type instance AttributeList FileChooserRequest = FileChooserRequestAttributeList
type FileChooserRequestAttributeList = ('[ '("filter", FileChooserRequestFilterPropertyInfo), '("mime-types", FileChooserRequestMimeTypesPropertyInfo), '("select-multiple", FileChooserRequestSelectMultiplePropertyInfo), '("selected-files", FileChooserRequestSelectedFilesPropertyInfo)] :: [(Symbol, *)])

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

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

foreign import ccall "webkit_file_chooser_request_cancel" webkit_file_chooser_request_cancel :: 
    Ptr FileChooserRequest ->               -- _obj : TInterface "WebKit2" "FileChooserRequest"
    IO ()


fileChooserRequestCancel ::
    (MonadIO m, FileChooserRequestK a) =>
    a ->                                    -- _obj
    m ()
fileChooserRequestCancel _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    webkit_file_chooser_request_cancel _obj'
    touchManagedPtr _obj
    return ()

-- method FileChooserRequest::get_mime_types
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "WebKit2" "FileChooserRequest", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "WebKit2" "FileChooserRequest", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TCArray True (-1) (-1) (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "webkit_file_chooser_request_get_mime_types" webkit_file_chooser_request_get_mime_types :: 
    Ptr FileChooserRequest ->               -- _obj : TInterface "WebKit2" "FileChooserRequest"
    IO (Ptr CString)


fileChooserRequestGetMimeTypes ::
    (MonadIO m, FileChooserRequestK a) =>
    a ->                                    -- _obj
    m [T.Text]
fileChooserRequestGetMimeTypes _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- webkit_file_chooser_request_get_mime_types _obj'
    checkUnexpectedReturnNULL "webkit_file_chooser_request_get_mime_types" result
    result' <- unpackZeroTerminatedUTF8CArray result
    touchManagedPtr _obj
    return result'

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

foreign import ccall "webkit_file_chooser_request_get_mime_types_filter" webkit_file_chooser_request_get_mime_types_filter :: 
    Ptr FileChooserRequest ->               -- _obj : TInterface "WebKit2" "FileChooserRequest"
    IO (Ptr Gtk.FileFilter)


fileChooserRequestGetMimeTypesFilter ::
    (MonadIO m, FileChooserRequestK a) =>
    a ->                                    -- _obj
    m Gtk.FileFilter
fileChooserRequestGetMimeTypesFilter _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- webkit_file_chooser_request_get_mime_types_filter _obj'
    checkUnexpectedReturnNULL "webkit_file_chooser_request_get_mime_types_filter" result
    result' <- (newObject Gtk.FileFilter) result
    touchManagedPtr _obj
    return result'

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

foreign import ccall "webkit_file_chooser_request_get_select_multiple" webkit_file_chooser_request_get_select_multiple :: 
    Ptr FileChooserRequest ->               -- _obj : TInterface "WebKit2" "FileChooserRequest"
    IO CInt


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

-- method FileChooserRequest::get_selected_files
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "WebKit2" "FileChooserRequest", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "WebKit2" "FileChooserRequest", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TCArray True (-1) (-1) (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "webkit_file_chooser_request_get_selected_files" webkit_file_chooser_request_get_selected_files :: 
    Ptr FileChooserRequest ->               -- _obj : TInterface "WebKit2" "FileChooserRequest"
    IO (Ptr CString)


fileChooserRequestGetSelectedFiles ::
    (MonadIO m, FileChooserRequestK a) =>
    a ->                                    -- _obj
    m [T.Text]
fileChooserRequestGetSelectedFiles _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- webkit_file_chooser_request_get_selected_files _obj'
    checkUnexpectedReturnNULL "webkit_file_chooser_request_get_selected_files" result
    result' <- unpackZeroTerminatedUTF8CArray result
    touchManagedPtr _obj
    return result'

-- method FileChooserRequest::select_files
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "WebKit2" "FileChooserRequest", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "files", argType = TCArray True (-1) (-1) (TBasicType TUTF8), direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "WebKit2" "FileChooserRequest", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "files", argType = TCArray True (-1) (-1) (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 "webkit_file_chooser_request_select_files" webkit_file_chooser_request_select_files :: 
    Ptr FileChooserRequest ->               -- _obj : TInterface "WebKit2" "FileChooserRequest"
    Ptr CString ->                          -- files : TCArray True (-1) (-1) (TBasicType TUTF8)
    IO ()


fileChooserRequestSelectFiles ::
    (MonadIO m, FileChooserRequestK a) =>
    a ->                                    -- _obj
    [T.Text] ->                             -- files
    m ()
fileChooserRequestSelectFiles _obj files = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    files' <- packZeroTerminatedUTF8CArray files
    webkit_file_chooser_request_select_files _obj' files'
    touchManagedPtr _obj
    mapZeroTerminatedCArray freeMem files'
    freeMem files'
    return ()