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

The AtkDocument interface should be supported by any object whose
content is a representation or view of a document.  The AtkDocument
interface should appear on the toplevel container for the document
content; however AtkDocument instances may be nested (i.e. an
AtkDocument may be a descendant of another AtkDocument) in those
cases where one document contains \"embedded content\" which can
reasonably be considered a document in its own right.
-}

module GI.Atk.Interfaces.Document
    ( 

-- * Exported types
    Document(..)                            ,
    noDocument                              ,
    IsDocument                              ,


 -- * Methods
-- ** getAttributeValue #method:getAttributeValue#
    DocumentGetAttributeValueMethodInfo     ,
    documentGetAttributeValue               ,


-- ** getAttributes #method:getAttributes#
    DocumentGetAttributesMethodInfo         ,
    documentGetAttributes                   ,


-- ** getCurrentPageNumber #method:getCurrentPageNumber#
    DocumentGetCurrentPageNumberMethodInfo  ,
    documentGetCurrentPageNumber            ,


-- ** getDocument #method:getDocument#
    DocumentGetDocumentMethodInfo           ,
    documentGetDocument                     ,


-- ** getDocumentType #method:getDocumentType#
    DocumentGetDocumentTypeMethodInfo       ,
    documentGetDocumentType                 ,


-- ** getLocale #method:getLocale#
    DocumentGetLocaleMethodInfo             ,
    documentGetLocale                       ,


-- ** getPageCount #method:getPageCount#
    DocumentGetPageCountMethodInfo          ,
    documentGetPageCount                    ,


-- ** setAttributeValue #method:setAttributeValue#
    DocumentSetAttributeValueMethodInfo     ,
    documentSetAttributeValue               ,




 -- * Signals
-- ** loadComplete #signal:loadComplete#
    C_DocumentLoadCompleteCallback          ,
    DocumentLoadCompleteCallback            ,
    DocumentLoadCompleteSignalInfo          ,
    afterDocumentLoadComplete               ,
    genClosure_DocumentLoadComplete         ,
    mk_DocumentLoadCompleteCallback         ,
    noDocumentLoadCompleteCallback          ,
    onDocumentLoadComplete                  ,
    wrap_DocumentLoadCompleteCallback       ,


-- ** loadStopped #signal:loadStopped#
    C_DocumentLoadStoppedCallback           ,
    DocumentLoadStoppedCallback             ,
    DocumentLoadStoppedSignalInfo           ,
    afterDocumentLoadStopped                ,
    genClosure_DocumentLoadStopped          ,
    mk_DocumentLoadStoppedCallback          ,
    noDocumentLoadStoppedCallback           ,
    onDocumentLoadStopped                   ,
    wrap_DocumentLoadStoppedCallback        ,


-- ** pageChanged #signal:pageChanged#
    C_DocumentPageChangedCallback           ,
    DocumentPageChangedCallback             ,
    DocumentPageChangedSignalInfo           ,
    afterDocumentPageChanged                ,
    genClosure_DocumentPageChanged          ,
    mk_DocumentPageChangedCallback          ,
    noDocumentPageChangedCallback           ,
    onDocumentPageChanged                   ,
    wrap_DocumentPageChangedCallback        ,


-- ** reload #signal:reload#
    C_DocumentReloadCallback                ,
    DocumentReloadCallback                  ,
    DocumentReloadSignalInfo                ,
    afterDocumentReload                     ,
    genClosure_DocumentReload               ,
    mk_DocumentReloadCallback               ,
    noDocumentReloadCallback                ,
    onDocumentReload                        ,
    wrap_DocumentReloadCallback             ,




    ) 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


-- interface Document 
newtype Document = Document (ManagedPtr Document)
noDocument :: Maybe Document
noDocument = Nothing

type family ResolveDocumentMethod (t :: Symbol) (o :: *) :: * where
    ResolveDocumentMethod "getAttributeValue" o = DocumentGetAttributeValueMethodInfo
    ResolveDocumentMethod "getAttributes" o = DocumentGetAttributesMethodInfo
    ResolveDocumentMethod "getCurrentPageNumber" o = DocumentGetCurrentPageNumberMethodInfo
    ResolveDocumentMethod "getDocument" o = DocumentGetDocumentMethodInfo
    ResolveDocumentMethod "getDocumentType" o = DocumentGetDocumentTypeMethodInfo
    ResolveDocumentMethod "getLocale" o = DocumentGetLocaleMethodInfo
    ResolveDocumentMethod "getPageCount" o = DocumentGetPageCountMethodInfo
    ResolveDocumentMethod "setAttributeValue" o = DocumentSetAttributeValueMethodInfo
    ResolveDocumentMethod l o = O.MethodResolutionFailed l o

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

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

-- signal Document::load-complete
type DocumentLoadCompleteCallback =
    IO ()

noDocumentLoadCompleteCallback :: Maybe DocumentLoadCompleteCallback
noDocumentLoadCompleteCallback = Nothing

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

foreign import ccall "wrapper"
    mk_DocumentLoadCompleteCallback :: C_DocumentLoadCompleteCallback -> IO (FunPtr C_DocumentLoadCompleteCallback)

genClosure_DocumentLoadComplete :: DocumentLoadCompleteCallback -> IO Closure
genClosure_DocumentLoadComplete cb = do
    let cb' = wrap_DocumentLoadCompleteCallback cb
    mk_DocumentLoadCompleteCallback cb' >>= newCClosure


wrap_DocumentLoadCompleteCallback ::
    DocumentLoadCompleteCallback ->
    Ptr () ->
    Ptr () ->
    IO ()
wrap_DocumentLoadCompleteCallback _cb _ _ = do
    _cb 


onDocumentLoadComplete :: (GObject a, MonadIO m) => a -> DocumentLoadCompleteCallback -> m SignalHandlerId
onDocumentLoadComplete obj cb = liftIO $ connectDocumentLoadComplete obj cb SignalConnectBefore
afterDocumentLoadComplete :: (GObject a, MonadIO m) => a -> DocumentLoadCompleteCallback -> m SignalHandlerId
afterDocumentLoadComplete obj cb = connectDocumentLoadComplete obj cb SignalConnectAfter

connectDocumentLoadComplete :: (GObject a, MonadIO m) =>
                               a -> DocumentLoadCompleteCallback -> SignalConnectMode -> m SignalHandlerId
connectDocumentLoadComplete obj cb after = liftIO $ do
    let cb' = wrap_DocumentLoadCompleteCallback cb
    cb'' <- mk_DocumentLoadCompleteCallback cb'
    connectSignalFunPtr obj "load-complete" cb'' after

-- signal Document::load-stopped
type DocumentLoadStoppedCallback =
    IO ()

noDocumentLoadStoppedCallback :: Maybe DocumentLoadStoppedCallback
noDocumentLoadStoppedCallback = Nothing

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

foreign import ccall "wrapper"
    mk_DocumentLoadStoppedCallback :: C_DocumentLoadStoppedCallback -> IO (FunPtr C_DocumentLoadStoppedCallback)

genClosure_DocumentLoadStopped :: DocumentLoadStoppedCallback -> IO Closure
genClosure_DocumentLoadStopped cb = do
    let cb' = wrap_DocumentLoadStoppedCallback cb
    mk_DocumentLoadStoppedCallback cb' >>= newCClosure


wrap_DocumentLoadStoppedCallback ::
    DocumentLoadStoppedCallback ->
    Ptr () ->
    Ptr () ->
    IO ()
wrap_DocumentLoadStoppedCallback _cb _ _ = do
    _cb 


onDocumentLoadStopped :: (GObject a, MonadIO m) => a -> DocumentLoadStoppedCallback -> m SignalHandlerId
onDocumentLoadStopped obj cb = liftIO $ connectDocumentLoadStopped obj cb SignalConnectBefore
afterDocumentLoadStopped :: (GObject a, MonadIO m) => a -> DocumentLoadStoppedCallback -> m SignalHandlerId
afterDocumentLoadStopped obj cb = connectDocumentLoadStopped obj cb SignalConnectAfter

connectDocumentLoadStopped :: (GObject a, MonadIO m) =>
                              a -> DocumentLoadStoppedCallback -> SignalConnectMode -> m SignalHandlerId
connectDocumentLoadStopped obj cb after = liftIO $ do
    let cb' = wrap_DocumentLoadStoppedCallback cb
    cb'' <- mk_DocumentLoadStoppedCallback cb'
    connectSignalFunPtr obj "load-stopped" cb'' after

-- signal Document::page-changed
type DocumentPageChangedCallback =
    Int32 ->
    IO ()

noDocumentPageChangedCallback :: Maybe DocumentPageChangedCallback
noDocumentPageChangedCallback = Nothing

type C_DocumentPageChangedCallback =
    Ptr () ->                               -- object
    Int32 ->
    Ptr () ->                               -- user_data
    IO ()

foreign import ccall "wrapper"
    mk_DocumentPageChangedCallback :: C_DocumentPageChangedCallback -> IO (FunPtr C_DocumentPageChangedCallback)

genClosure_DocumentPageChanged :: DocumentPageChangedCallback -> IO Closure
genClosure_DocumentPageChanged cb = do
    let cb' = wrap_DocumentPageChangedCallback cb
    mk_DocumentPageChangedCallback cb' >>= newCClosure


wrap_DocumentPageChangedCallback ::
    DocumentPageChangedCallback ->
    Ptr () ->
    Int32 ->
    Ptr () ->
    IO ()
wrap_DocumentPageChangedCallback _cb _ pageNumber _ = do
    _cb  pageNumber


onDocumentPageChanged :: (GObject a, MonadIO m) => a -> DocumentPageChangedCallback -> m SignalHandlerId
onDocumentPageChanged obj cb = liftIO $ connectDocumentPageChanged obj cb SignalConnectBefore
afterDocumentPageChanged :: (GObject a, MonadIO m) => a -> DocumentPageChangedCallback -> m SignalHandlerId
afterDocumentPageChanged obj cb = connectDocumentPageChanged obj cb SignalConnectAfter

connectDocumentPageChanged :: (GObject a, MonadIO m) =>
                              a -> DocumentPageChangedCallback -> SignalConnectMode -> m SignalHandlerId
connectDocumentPageChanged obj cb after = liftIO $ do
    let cb' = wrap_DocumentPageChangedCallback cb
    cb'' <- mk_DocumentPageChangedCallback cb'
    connectSignalFunPtr obj "page-changed" cb'' after

-- signal Document::reload
type DocumentReloadCallback =
    IO ()

noDocumentReloadCallback :: Maybe DocumentReloadCallback
noDocumentReloadCallback = Nothing

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

foreign import ccall "wrapper"
    mk_DocumentReloadCallback :: C_DocumentReloadCallback -> IO (FunPtr C_DocumentReloadCallback)

genClosure_DocumentReload :: DocumentReloadCallback -> IO Closure
genClosure_DocumentReload cb = do
    let cb' = wrap_DocumentReloadCallback cb
    mk_DocumentReloadCallback cb' >>= newCClosure


wrap_DocumentReloadCallback ::
    DocumentReloadCallback ->
    Ptr () ->
    Ptr () ->
    IO ()
wrap_DocumentReloadCallback _cb _ _ = do
    _cb 


onDocumentReload :: (GObject a, MonadIO m) => a -> DocumentReloadCallback -> m SignalHandlerId
onDocumentReload obj cb = liftIO $ connectDocumentReload obj cb SignalConnectBefore
afterDocumentReload :: (GObject a, MonadIO m) => a -> DocumentReloadCallback -> m SignalHandlerId
afterDocumentReload obj cb = connectDocumentReload obj cb SignalConnectAfter

connectDocumentReload :: (GObject a, MonadIO m) =>
                         a -> DocumentReloadCallback -> SignalConnectMode -> m SignalHandlerId
connectDocumentReload obj cb after = liftIO $ do
    let cb' = wrap_DocumentReloadCallback cb
    cb'' <- mk_DocumentReloadCallback cb'
    connectSignalFunPtr obj "reload" cb'' after

instance O.HasAttributeList Document
type instance O.AttributeList Document = DocumentAttributeList
type DocumentAttributeList = ('[ ] :: [(Symbol, *)])

data DocumentLoadCompleteSignalInfo
instance SignalInfo DocumentLoadCompleteSignalInfo where
    type HaskellCallbackType DocumentLoadCompleteSignalInfo = DocumentLoadCompleteCallback
    connectSignal _ = connectDocumentLoadComplete

data DocumentLoadStoppedSignalInfo
instance SignalInfo DocumentLoadStoppedSignalInfo where
    type HaskellCallbackType DocumentLoadStoppedSignalInfo = DocumentLoadStoppedCallback
    connectSignal _ = connectDocumentLoadStopped

data DocumentPageChangedSignalInfo
instance SignalInfo DocumentPageChangedSignalInfo where
    type HaskellCallbackType DocumentPageChangedSignalInfo = DocumentPageChangedCallback
    connectSignal _ = connectDocumentPageChanged

data DocumentReloadSignalInfo
instance SignalInfo DocumentReloadSignalInfo where
    type HaskellCallbackType DocumentReloadSignalInfo = DocumentReloadCallback
    connectSignal _ = connectDocumentReload

type instance O.SignalList Document = DocumentSignalList
type DocumentSignalList = ('[ '("loadComplete", DocumentLoadCompleteSignalInfo), '("loadStopped", DocumentLoadStoppedSignalInfo), '("pageChanged", DocumentPageChangedSignalInfo), '("reload", DocumentReloadSignalInfo)] :: [(Symbol, *)])

class ManagedPtrNewtype a => IsDocument a
instance IsDocument Document
-- XXX Wrapping a foreign struct/union with no known destructor or size, leak?
instance WrappedPtr Document where
    wrappedPtrCalloc = return nullPtr
    wrappedPtrCopy = return
    wrappedPtrFree = Nothing


-- method Document::get_attribute_value
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "document", argType = TInterface (Name {namespace = "Atk", name = "Document"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GObject instance that implements AtkDocumentIface", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "attribute_name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a character string representing the name of the attribute\n           whose value is being queried.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "atk_document_get_attribute_value" atk_document_get_attribute_value :: 
    Ptr Document ->                         -- document : TInterface (Name {namespace = "Atk", name = "Document"})
    CString ->                              -- attribute_name : TBasicType TUTF8
    IO CString

{- |
/No description available in the introspection data./

@since 1.12
-}
documentGetAttributeValue ::
    (B.CallStack.HasCallStack, MonadIO m, IsDocument a) =>
    a
    {- ^ /@document@/: a 'GI.GObject.Objects.Object.Object' instance that implements AtkDocumentIface -}
    -> T.Text
    {- ^ /@attributeName@/: a character string representing the name of the attribute
           whose value is being queried. -}
    -> m (Maybe T.Text)
    {- ^ __Returns:__ a string value associated with the named
   attribute for this document, or NULL if a value for
   @/attribute_name/@ has not been specified for this document. -}
documentGetAttributeValue document attributeName = liftIO $ do
    document' <- unsafeManagedPtrCastPtr document
    attributeName' <- textToCString attributeName
    result <- atk_document_get_attribute_value document' attributeName'
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- cstringToText result'
        return result''
    touchManagedPtr document
    freeMem attributeName'
    return maybeResult

data DocumentGetAttributeValueMethodInfo
instance (signature ~ (T.Text -> m (Maybe T.Text)), MonadIO m, IsDocument a) => O.MethodInfo DocumentGetAttributeValueMethodInfo a signature where
    overloadedMethod _ = documentGetAttributeValue

-- method Document::get_attributes
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "document", argType = TInterface (Name {namespace = "Atk", name = "Document"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GObject instance that implements AtkDocumentIface", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TGSList (TBasicType TPtr))
-- throws : False
-- Skip return : False

foreign import ccall "atk_document_get_attributes" atk_document_get_attributes :: 
    Ptr Document ->                         -- document : TInterface (Name {namespace = "Atk", name = "Document"})
    IO (Ptr (GSList (Ptr ())))

{- |
Gets an AtkAttributeSet which describes document-wide
         attributes as name-value pairs.

@since 1.12
-}
documentGetAttributes ::
    (B.CallStack.HasCallStack, MonadIO m, IsDocument a) =>
    a
    {- ^ /@document@/: a 'GI.GObject.Objects.Object.Object' instance that implements AtkDocumentIface -}
    -> m [Ptr ()]
    {- ^ __Returns:__ An AtkAttributeSet containing the explicitly
         set name-value-pair attributes associated with this document
         as a whole. -}
documentGetAttributes document = liftIO $ do
    document' <- unsafeManagedPtrCastPtr document
    result <- atk_document_get_attributes document'
    result' <- unpackGSList result
    touchManagedPtr document
    return result'

data DocumentGetAttributesMethodInfo
instance (signature ~ (m [Ptr ()]), MonadIO m, IsDocument a) => O.MethodInfo DocumentGetAttributesMethodInfo a signature where
    overloadedMethod _ = documentGetAttributes

-- method Document::get_current_page_number
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "document", argType = TInterface (Name {namespace = "Atk", name = "Document"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #AtkDocument", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TInt)
-- throws : False
-- Skip return : False

foreign import ccall "atk_document_get_current_page_number" atk_document_get_current_page_number :: 
    Ptr Document ->                         -- document : TInterface (Name {namespace = "Atk", name = "Document"})
    IO Int32

{- |
/No description available in the introspection data./

@since 2.12
-}
documentGetCurrentPageNumber ::
    (B.CallStack.HasCallStack, MonadIO m, IsDocument a) =>
    a
    {- ^ /@document@/: the 'GI.Atk.Interfaces.Document.Document' -}
    -> m Int32
    {- ^ __Returns:__ current page number inside /@document@/. -1 if not
implemented, not know by the implementor or irrelevant. -}
documentGetCurrentPageNumber document = liftIO $ do
    document' <- unsafeManagedPtrCastPtr document
    result <- atk_document_get_current_page_number document'
    touchManagedPtr document
    return result

data DocumentGetCurrentPageNumberMethodInfo
instance (signature ~ (m Int32), MonadIO m, IsDocument a) => O.MethodInfo DocumentGetCurrentPageNumberMethodInfo a signature where
    overloadedMethod _ = documentGetCurrentPageNumber

-- method Document::get_document
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "document", argType = TInterface (Name {namespace = "Atk", name = "Document"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GObject instance that implements AtkDocumentIface", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TPtr)
-- throws : False
-- Skip return : False

foreign import ccall "atk_document_get_document" atk_document_get_document :: 
    Ptr Document ->                         -- document : TInterface (Name {namespace = "Atk", name = "Document"})
    IO (Ptr ())

{-# DEPRECATED documentGetDocument ["Since 2.12. /@document@/ is already a representation of","the document. Use it directly, or one of its children, as an","instance of the DOM."] #-}
{- |
Gets a @/gpointer/@ that points to an instance of the DOM.  It is
up to the caller to check atk_document_get_type to determine
how to cast this pointer.
-}
documentGetDocument ::
    (B.CallStack.HasCallStack, MonadIO m, IsDocument a) =>
    a
    {- ^ /@document@/: a 'GI.GObject.Objects.Object.Object' instance that implements AtkDocumentIface -}
    -> m (Ptr ())
    {- ^ __Returns:__ a @/gpointer/@ that points to an instance of the DOM. -}
documentGetDocument document = liftIO $ do
    document' <- unsafeManagedPtrCastPtr document
    result <- atk_document_get_document document'
    touchManagedPtr document
    return result

data DocumentGetDocumentMethodInfo
instance (signature ~ (m (Ptr ())), MonadIO m, IsDocument a) => O.MethodInfo DocumentGetDocumentMethodInfo a signature where
    overloadedMethod _ = documentGetDocument

-- method Document::get_document_type
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "document", argType = TInterface (Name {namespace = "Atk", name = "Document"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GObject instance that implements AtkDocumentIface", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "atk_document_get_document_type" atk_document_get_document_type :: 
    Ptr Document ->                         -- document : TInterface (Name {namespace = "Atk", name = "Document"})
    IO CString

{-# DEPRECATED documentGetDocumentType ["Since 2.12. Please use 'GI.Atk.Interfaces.Document.documentGetAttributes' to","ask for the document type if it applies."] #-}
{- |
Gets a string indicating the document type.
-}
documentGetDocumentType ::
    (B.CallStack.HasCallStack, MonadIO m, IsDocument a) =>
    a
    {- ^ /@document@/: a 'GI.GObject.Objects.Object.Object' instance that implements AtkDocumentIface -}
    -> m T.Text
    {- ^ __Returns:__ a string indicating the document type -}
documentGetDocumentType document = liftIO $ do
    document' <- unsafeManagedPtrCastPtr document
    result <- atk_document_get_document_type document'
    checkUnexpectedReturnNULL "documentGetDocumentType" result
    result' <- cstringToText result
    touchManagedPtr document
    return result'

data DocumentGetDocumentTypeMethodInfo
instance (signature ~ (m T.Text), MonadIO m, IsDocument a) => O.MethodInfo DocumentGetDocumentTypeMethodInfo a signature where
    overloadedMethod _ = documentGetDocumentType

-- method Document::get_locale
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "document", argType = TInterface (Name {namespace = "Atk", name = "Document"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GObject instance that implements AtkDocumentIface", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "atk_document_get_locale" atk_document_get_locale :: 
    Ptr Document ->                         -- document : TInterface (Name {namespace = "Atk", name = "Document"})
    IO CString

{-# DEPRECATED documentGetLocale ["(Since version 2.7.90)","Please use 'GI.Atk.Objects.Object.objectGetObjectLocale' instead."] #-}
{- |
Gets a UTF-8 string indicating the POSIX-style LC_MESSAGES locale
         of the content of this document instance.  Individual
         text substrings or images within this document may have
         a different locale, see atk_text_get_attributes and
         atk_image_get_image_locale.
-}
documentGetLocale ::
    (B.CallStack.HasCallStack, MonadIO m, IsDocument a) =>
    a
    {- ^ /@document@/: a 'GI.GObject.Objects.Object.Object' instance that implements AtkDocumentIface -}
    -> m T.Text
    {- ^ __Returns:__ a UTF-8 string indicating the POSIX-style LC_MESSAGES
         locale of the document content as a whole, or NULL if
         the document content does not specify a locale. -}
documentGetLocale document = liftIO $ do
    document' <- unsafeManagedPtrCastPtr document
    result <- atk_document_get_locale document'
    checkUnexpectedReturnNULL "documentGetLocale" result
    result' <- cstringToText result
    touchManagedPtr document
    return result'

data DocumentGetLocaleMethodInfo
instance (signature ~ (m T.Text), MonadIO m, IsDocument a) => O.MethodInfo DocumentGetLocaleMethodInfo a signature where
    overloadedMethod _ = documentGetLocale

-- method Document::get_page_count
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "document", argType = TInterface (Name {namespace = "Atk", name = "Document"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #AtkDocument", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TInt)
-- throws : False
-- Skip return : False

foreign import ccall "atk_document_get_page_count" atk_document_get_page_count :: 
    Ptr Document ->                         -- document : TInterface (Name {namespace = "Atk", name = "Document"})
    IO Int32

{- |
/No description available in the introspection data./

@since 2.12
-}
documentGetPageCount ::
    (B.CallStack.HasCallStack, MonadIO m, IsDocument a) =>
    a
    {- ^ /@document@/: the 'GI.Atk.Interfaces.Document.Document' -}
    -> m Int32
    {- ^ __Returns:__ total page count of /@document@/. -1 if not implemented, not
know by the implementor or irrelevant. -}
documentGetPageCount document = liftIO $ do
    document' <- unsafeManagedPtrCastPtr document
    result <- atk_document_get_page_count document'
    touchManagedPtr document
    return result

data DocumentGetPageCountMethodInfo
instance (signature ~ (m Int32), MonadIO m, IsDocument a) => O.MethodInfo DocumentGetPageCountMethodInfo a signature where
    overloadedMethod _ = documentGetPageCount

-- method Document::set_attribute_value
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "document", argType = TInterface (Name {namespace = "Atk", name = "Document"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GObject instance that implements AtkDocumentIface", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "attribute_name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a character string representing the name of the attribute\n           whose value is being set.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "attribute_value", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a string value to be associated with #attribute_name.", 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 "atk_document_set_attribute_value" atk_document_set_attribute_value :: 
    Ptr Document ->                         -- document : TInterface (Name {namespace = "Atk", name = "Document"})
    CString ->                              -- attribute_name : TBasicType TUTF8
    CString ->                              -- attribute_value : TBasicType TUTF8
    IO CInt

{- |
/No description available in the introspection data./

@since 1.12
-}
documentSetAttributeValue ::
    (B.CallStack.HasCallStack, MonadIO m, IsDocument a) =>
    a
    {- ^ /@document@/: a 'GI.GObject.Objects.Object.Object' instance that implements AtkDocumentIface -}
    -> T.Text
    {- ^ /@attributeName@/: a character string representing the name of the attribute
           whose value is being set. -}
    -> T.Text
    {- ^ /@attributeValue@/: a string value to be associated with @/attribute_name/@. -}
    -> m Bool
    {- ^ __Returns:__ TRUE if @/value/@ is successfully associated with @/attribute_name/@
         for this document, FALSE otherwise (e.g. if the document does not
         allow the attribute to be modified). -}
documentSetAttributeValue document attributeName attributeValue = liftIO $ do
    document' <- unsafeManagedPtrCastPtr document
    attributeName' <- textToCString attributeName
    attributeValue' <- textToCString attributeValue
    result <- atk_document_set_attribute_value document' attributeName' attributeValue'
    let result' = (/= 0) result
    touchManagedPtr document
    freeMem attributeName'
    freeMem attributeValue'
    return result'

data DocumentSetAttributeValueMethodInfo
instance (signature ~ (T.Text -> T.Text -> m Bool), MonadIO m, IsDocument a) => O.MethodInfo DocumentSetAttributeValueMethodInfo a signature where
    overloadedMethod _ = documentSetAttributeValue