{- |
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(..)                  ,
    IsFileChooserRequest                    ,
    toFileChooserRequest                    ,
    noFileChooserRequest                    ,


 -- * Methods
-- ** cancel #method:cancel#
    FileChooserRequestCancelMethodInfo      ,
    fileChooserRequestCancel                ,


-- ** getMimeTypes #method:getMimeTypes#
    FileChooserRequestGetMimeTypesMethodInfo,
    fileChooserRequestGetMimeTypes          ,


-- ** getMimeTypesFilter #method:getMimeTypesFilter#
    FileChooserRequestGetMimeTypesFilterMethodInfo,
    fileChooserRequestGetMimeTypesFilter    ,


-- ** getSelectMultiple #method:getSelectMultiple#
    FileChooserRequestGetSelectMultipleMethodInfo,
    fileChooserRequestGetSelectMultiple     ,


-- ** getSelectedFiles #method:getSelectedFiles#
    FileChooserRequestGetSelectedFilesMethodInfo,
    fileChooserRequestGetSelectedFiles      ,


-- ** selectFiles #method:selectFiles#
    FileChooserRequestSelectFilesMethodInfo ,
    fileChooserRequestSelectFiles           ,




 -- * Properties
-- ** filter #attr:filter#
    FileChooserRequestFilterPropertyInfo    ,
    fileChooserRequestFilter                ,
    getFileChooserRequestFilter             ,


-- ** mimeTypes #attr:mimeTypes#
    FileChooserRequestMimeTypesPropertyInfo ,
    fileChooserRequestMimeTypes             ,
    getFileChooserRequestMimeTypes          ,


-- ** selectMultiple #attr:selectMultiple#
    FileChooserRequestSelectMultiplePropertyInfo,
    fileChooserRequestSelectMultiple        ,
    getFileChooserRequestSelectMultiple     ,


-- ** selectedFiles #attr:selectedFiles#
    FileChooserRequestSelectedFilesPropertyInfo,
    fileChooserRequestSelectedFiles         ,
    getFileChooserRequestSelectedFiles      ,




    ) 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.GError as B.GError
import qualified Data.GI.Base.GVariant as B.GVariant
import qualified Data.GI.Base.GParamSpec as B.GParamSpec
import qualified Data.GI.Base.CallStack as B.CallStack
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 GI.GObject.Objects.Object as GObject.Object
import qualified GI.Gtk.Objects.FileFilter as Gtk.FileFilter

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

instance GObject FileChooserRequest where
    gobjectType _ = c_webkit_file_chooser_request_get_type
    

class GObject o => IsFileChooserRequest o
#if MIN_VERSION_base(4,9,0)
instance {-# OVERLAPPABLE #-} (GObject a, O.UnknownAncestorError FileChooserRequest a) =>
    IsFileChooserRequest a
#endif
instance IsFileChooserRequest FileChooserRequest
instance GObject.Object.IsObject FileChooserRequest

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

noFileChooserRequest :: Maybe FileChooserRequest
noFileChooserRequest = Nothing

type family ResolveFileChooserRequestMethod (t :: Symbol) (o :: *) :: * where
    ResolveFileChooserRequestMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
    ResolveFileChooserRequestMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
    ResolveFileChooserRequestMethod "cancel" o = FileChooserRequestCancelMethodInfo
    ResolveFileChooserRequestMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
    ResolveFileChooserRequestMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
    ResolveFileChooserRequestMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
    ResolveFileChooserRequestMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
    ResolveFileChooserRequestMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
    ResolveFileChooserRequestMethod "ref" o = GObject.Object.ObjectRefMethodInfo
    ResolveFileChooserRequestMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
    ResolveFileChooserRequestMethod "replaceData" o = GObject.Object.ObjectReplaceDataMethodInfo
    ResolveFileChooserRequestMethod "replaceQdata" o = GObject.Object.ObjectReplaceQdataMethodInfo
    ResolveFileChooserRequestMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
    ResolveFileChooserRequestMethod "selectFiles" o = FileChooserRequestSelectFilesMethodInfo
    ResolveFileChooserRequestMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
    ResolveFileChooserRequestMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
    ResolveFileChooserRequestMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
    ResolveFileChooserRequestMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
    ResolveFileChooserRequestMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
    ResolveFileChooserRequestMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
    ResolveFileChooserRequestMethod "getMimeTypes" o = FileChooserRequestGetMimeTypesMethodInfo
    ResolveFileChooserRequestMethod "getMimeTypesFilter" o = FileChooserRequestGetMimeTypesFilterMethodInfo
    ResolveFileChooserRequestMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
    ResolveFileChooserRequestMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
    ResolveFileChooserRequestMethod "getSelectMultiple" o = FileChooserRequestGetSelectMultipleMethodInfo
    ResolveFileChooserRequestMethod "getSelectedFiles" o = FileChooserRequestGetSelectedFilesMethodInfo
    ResolveFileChooserRequestMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
    ResolveFileChooserRequestMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolveFileChooserRequestMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveFileChooserRequestMethod t FileChooserRequest, O.MethodInfo info FileChooserRequest p) => O.IsLabelProxy t (FileChooserRequest -> p) where
    fromLabelProxy _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)

#if MIN_VERSION_base(4,9,0)
instance (info ~ ResolveFileChooserRequestMethod t FileChooserRequest, O.MethodInfo info FileChooserRequest p) => O.IsLabel t (FileChooserRequest -> p) where
    fromLabel _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#endif

-- VVV Prop "filter"
   -- Type: TInterface (Name {namespace = "Gtk", name = "FileFilter"})
   -- Flags: [PropertyReadable]
   -- Nullable: (Nothing,Nothing)

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

data FileChooserRequestFilterPropertyInfo
instance AttrInfo FileChooserRequestFilterPropertyInfo where
    type AttrAllowedOps FileChooserRequestFilterPropertyInfo = '[ 'AttrGet, 'AttrClear]
    type AttrSetTypeConstraint FileChooserRequestFilterPropertyInfo = (~) ()
    type AttrBaseTypeConstraint FileChooserRequestFilterPropertyInfo = IsFileChooserRequest
    type AttrGetType FileChooserRequestFilterPropertyInfo = (Maybe Gtk.FileFilter.FileFilter)
    type AttrLabel FileChooserRequestFilterPropertyInfo = "filter"
    type AttrOrigin FileChooserRequestFilterPropertyInfo = FileChooserRequest
    attrGet _ = getFileChooserRequestFilter
    attrSet _ = undefined
    attrConstruct _ = undefined
    attrClear _ = undefined

-- VVV Prop "mime-types"
   -- Type: TCArray True (-1) (-1) (TBasicType TUTF8)
   -- Flags: [PropertyReadable]
   -- Nullable: (Just False,Nothing)

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

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

-- VVV Prop "select-multiple"
   -- Type: TBasicType TBoolean
   -- Flags: [PropertyReadable]
   -- Nullable: (Just False,Nothing)

getFileChooserRequestSelectMultiple :: (MonadIO m, IsFileChooserRequest 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 = IsFileChooserRequest
    type AttrGetType FileChooserRequestSelectMultiplePropertyInfo = Bool
    type AttrLabel FileChooserRequestSelectMultiplePropertyInfo = "select-multiple"
    type AttrOrigin FileChooserRequestSelectMultiplePropertyInfo = FileChooserRequest
    attrGet _ = getFileChooserRequestSelectMultiple
    attrSet _ = undefined
    attrConstruct _ = undefined
    attrClear _ = undefined

-- VVV Prop "selected-files"
   -- Type: TCArray True (-1) (-1) (TBasicType TUTF8)
   -- Flags: [PropertyReadable]
   -- Nullable: (Just False,Nothing)

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

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

instance O.HasAttributeList FileChooserRequest
type instance O.AttributeList FileChooserRequest = FileChooserRequestAttributeList
type FileChooserRequestAttributeList = ('[ '("filter", FileChooserRequestFilterPropertyInfo), '("mimeTypes", FileChooserRequestMimeTypesPropertyInfo), '("selectMultiple", FileChooserRequestSelectMultiplePropertyInfo), '("selectedFiles", FileChooserRequestSelectedFilesPropertyInfo)] :: [(Symbol, *)])

fileChooserRequestFilter :: AttrLabelProxy "filter"
fileChooserRequestFilter = AttrLabelProxy

fileChooserRequestMimeTypes :: AttrLabelProxy "mimeTypes"
fileChooserRequestMimeTypes = AttrLabelProxy

fileChooserRequestSelectMultiple :: AttrLabelProxy "selectMultiple"
fileChooserRequestSelectMultiple = AttrLabelProxy

fileChooserRequestSelectedFiles :: AttrLabelProxy "selectedFiles"
fileChooserRequestSelectedFiles = AttrLabelProxy

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

-- method FileChooserRequest::cancel
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "request", argType = TInterface (Name {namespace = "WebKit2", name = "FileChooserRequest"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #WebKitFileChooserRequest", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "webkit_file_chooser_request_cancel" webkit_file_chooser_request_cancel :: 
    Ptr FileChooserRequest ->               -- request : TInterface (Name {namespace = "WebKit2", name = "FileChooserRequest"})
    IO ()

{- |
Ask WebKit to cancel the request. It\'s important to do this in case
no selection has been made in the client, otherwise the request
won\'t be properly completed and the browser will keep the request
pending forever, which might cause the browser to hang.
-}
fileChooserRequestCancel ::
    (B.CallStack.HasCallStack, MonadIO m, IsFileChooserRequest a) =>
    a
    {- ^ /@request@/: a 'GI.WebKit2.Objects.FileChooserRequest.FileChooserRequest' -}
    -> m ()
fileChooserRequestCancel request = liftIO $ do
    request' <- unsafeManagedPtrCastPtr request
    webkit_file_chooser_request_cancel request'
    touchManagedPtr request
    return ()

data FileChooserRequestCancelMethodInfo
instance (signature ~ (m ()), MonadIO m, IsFileChooserRequest a) => O.MethodInfo FileChooserRequestCancelMethodInfo a signature where
    overloadedMethod _ = fileChooserRequestCancel

-- method FileChooserRequest::get_mime_types
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "request", argType = TInterface (Name {namespace = "WebKit2", name = "FileChooserRequest"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #WebKitFileChooserRequest", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (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 ->               -- request : TInterface (Name {namespace = "WebKit2", name = "FileChooserRequest"})
    IO (Ptr CString)

{- |
Get the list of MIME types the file chooser dialog should handle,
in the format specified in RFC 2046 for \"media types\". Its contents
depend on the value of the \'accept\' attribute for HTML input
elements. This function should normally be called before presenting
the file chooser dialog to the user, to decide whether to allow the
user to select multiple files at once or only one.
-}
fileChooserRequestGetMimeTypes ::
    (B.CallStack.HasCallStack, MonadIO m, IsFileChooserRequest a) =>
    a
    {- ^ /@request@/: a 'GI.WebKit2.Objects.FileChooserRequest.FileChooserRequest' -}
    -> m [T.Text]
    {- ^ __Returns:__ a
'Nothing'-terminated array of strings if a list of accepted MIME types
is defined or 'Nothing' otherwise, meaning that any MIME type should be
accepted. This array and its contents are owned by WebKitGTK+ and
should not be modified or freed. -}
fileChooserRequestGetMimeTypes request = liftIO $ do
    request' <- unsafeManagedPtrCastPtr request
    result <- webkit_file_chooser_request_get_mime_types request'
    checkUnexpectedReturnNULL "fileChooserRequestGetMimeTypes" result
    result' <- unpackZeroTerminatedUTF8CArray result
    touchManagedPtr request
    return result'

data FileChooserRequestGetMimeTypesMethodInfo
instance (signature ~ (m [T.Text]), MonadIO m, IsFileChooserRequest a) => O.MethodInfo FileChooserRequestGetMimeTypesMethodInfo a signature where
    overloadedMethod _ = fileChooserRequestGetMimeTypes

-- method FileChooserRequest::get_mime_types_filter
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "request", argType = TInterface (Name {namespace = "WebKit2", name = "FileChooserRequest"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #WebKitFileChooserRequest", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gtk", name = "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 ->               -- request : TInterface (Name {namespace = "WebKit2", name = "FileChooserRequest"})
    IO (Ptr Gtk.FileFilter.FileFilter)

{- |
Get the filter currently associated with the request, ready to be
used by 'GI.Gtk.Interfaces.FileChooser.FileChooser'. This function should normally be called
before presenting the file chooser dialog to the user, to decide
whether to apply a filter so the user would not be allowed to
select files with other MIME types.

See 'GI.WebKit2.Objects.FileChooserRequest.fileChooserRequestGetMimeTypes' if you are
interested in getting the list of accepted MIME types.
-}
fileChooserRequestGetMimeTypesFilter ::
    (B.CallStack.HasCallStack, MonadIO m, IsFileChooserRequest a) =>
    a
    {- ^ /@request@/: a 'GI.WebKit2.Objects.FileChooserRequest.FileChooserRequest' -}
    -> m Gtk.FileFilter.FileFilter
    {- ^ __Returns:__ a 'GI.Gtk.Objects.FileFilter.FileFilter' if a list of accepted
MIME types is defined or 'Nothing' otherwise. The returned object is
owned by WebKitGTK+ should not be modified or freed. -}
fileChooserRequestGetMimeTypesFilter request = liftIO $ do
    request' <- unsafeManagedPtrCastPtr request
    result <- webkit_file_chooser_request_get_mime_types_filter request'
    checkUnexpectedReturnNULL "fileChooserRequestGetMimeTypesFilter" result
    result' <- (newObject Gtk.FileFilter.FileFilter) result
    touchManagedPtr request
    return result'

data FileChooserRequestGetMimeTypesFilterMethodInfo
instance (signature ~ (m Gtk.FileFilter.FileFilter), MonadIO m, IsFileChooserRequest a) => O.MethodInfo FileChooserRequestGetMimeTypesFilterMethodInfo a signature where
    overloadedMethod _ = fileChooserRequestGetMimeTypesFilter

-- method FileChooserRequest::get_select_multiple
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "request", argType = TInterface (Name {namespace = "WebKit2", name = "FileChooserRequest"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #WebKitFileChooserRequest", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (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 ->               -- request : TInterface (Name {namespace = "WebKit2", name = "FileChooserRequest"})
    IO CInt

{- |
Determine whether the file chooser associated to this
'GI.WebKit2.Objects.FileChooserRequest.FileChooserRequest' should allow selecting multiple files,
which depends on the HTML input element having a \'multiple\'
attribute defined.
-}
fileChooserRequestGetSelectMultiple ::
    (B.CallStack.HasCallStack, MonadIO m, IsFileChooserRequest a) =>
    a
    {- ^ /@request@/: a 'GI.WebKit2.Objects.FileChooserRequest.FileChooserRequest' -}
    -> m Bool
    {- ^ __Returns:__ 'True' if the file chooser should allow selecting multiple files or 'False' otherwise. -}
fileChooserRequestGetSelectMultiple request = liftIO $ do
    request' <- unsafeManagedPtrCastPtr request
    result <- webkit_file_chooser_request_get_select_multiple request'
    let result' = (/= 0) result
    touchManagedPtr request
    return result'

data FileChooserRequestGetSelectMultipleMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsFileChooserRequest a) => O.MethodInfo FileChooserRequestGetSelectMultipleMethodInfo a signature where
    overloadedMethod _ = fileChooserRequestGetSelectMultiple

-- method FileChooserRequest::get_selected_files
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "request", argType = TInterface (Name {namespace = "WebKit2", name = "FileChooserRequest"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #WebKitFileChooserRequest", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (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 ->               -- request : TInterface (Name {namespace = "WebKit2", name = "FileChooserRequest"})
    IO (Ptr CString)

{- |
Get the list of selected files currently associated to the
request. Initially, the return value of this method contains any
files selected in previous file chooser requests for this HTML
input element. Once webkit_file_chooser_request_select_files, the
value will reflect whatever files are given.

This function should normally be called only before presenting the
file chooser dialog to the user, to decide whether to perform some
extra action, like pre-selecting the files from a previous request.
-}
fileChooserRequestGetSelectedFiles ::
    (B.CallStack.HasCallStack, MonadIO m, IsFileChooserRequest a) =>
    a
    {- ^ /@request@/: a 'GI.WebKit2.Objects.FileChooserRequest.FileChooserRequest' -}
    -> m [T.Text]
    {- ^ __Returns:__ a
'Nothing'-terminated array of strings if there are selected files
associated with the request or 'Nothing' otherwise. This array and its
contents are owned by WebKitGTK+ and should not be modified or
freed. -}
fileChooserRequestGetSelectedFiles request = liftIO $ do
    request' <- unsafeManagedPtrCastPtr request
    result <- webkit_file_chooser_request_get_selected_files request'
    checkUnexpectedReturnNULL "fileChooserRequestGetSelectedFiles" result
    result' <- unpackZeroTerminatedUTF8CArray result
    touchManagedPtr request
    return result'

data FileChooserRequestGetSelectedFilesMethodInfo
instance (signature ~ (m [T.Text]), MonadIO m, IsFileChooserRequest a) => O.MethodInfo FileChooserRequestGetSelectedFilesMethodInfo a signature where
    overloadedMethod _ = fileChooserRequestGetSelectedFiles

-- method FileChooserRequest::select_files
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "request", argType = TInterface (Name {namespace = "WebKit2", name = "FileChooserRequest"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #WebKitFileChooserRequest", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "files", argType = TCArray True (-1) (-1) (TBasicType TUTF8), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a\n%NULL-terminated array of strings, containing paths to local files.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "webkit_file_chooser_request_select_files" webkit_file_chooser_request_select_files :: 
    Ptr FileChooserRequest ->               -- request : TInterface (Name {namespace = "WebKit2", name = "FileChooserRequest"})
    Ptr CString ->                          -- files : TCArray True (-1) (-1) (TBasicType TUTF8)
    IO ()

{- |
Ask WebKit to select local files for upload and complete the
request.
-}
fileChooserRequestSelectFiles ::
    (B.CallStack.HasCallStack, MonadIO m, IsFileChooserRequest a) =>
    a
    {- ^ /@request@/: a 'GI.WebKit2.Objects.FileChooserRequest.FileChooserRequest' -}
    -> [T.Text]
    {- ^ /@files@/: a
'Nothing'-terminated array of strings, containing paths to local files. -}
    -> m ()
fileChooserRequestSelectFiles request files = liftIO $ do
    request' <- unsafeManagedPtrCastPtr request
    files' <- packZeroTerminatedUTF8CArray files
    webkit_file_chooser_request_select_files request' files'
    touchManagedPtr request
    mapZeroTerminatedCArray freeMem files'
    freeMem files'
    return ()

data FileChooserRequestSelectFilesMethodInfo
instance (signature ~ ([T.Text] -> m ()), MonadIO m, IsFileChooserRequest a) => O.MethodInfo FileChooserRequestSelectFilesMethodInfo a signature where
    overloadedMethod _ = fileChooserRequestSelectFiles