gi-webkit-0.2.4.12: GI/WebKit/Interfaces/SpellChecker.hs
{- |
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.WebKit.Interfaces.SpellChecker
(
-- * Exported types
SpellChecker(..) ,
noSpellChecker ,
SpellCheckerK ,
toSpellChecker ,
-- * Methods
-- ** spellCheckerCheckSpellingOfString
spellCheckerCheckSpellingOfString ,
-- ** spellCheckerGetAutocorrectSuggestionsForMisspelledWord
spellCheckerGetAutocorrectSuggestionsForMisspelledWord,
-- ** spellCheckerGetGuessesForWord
spellCheckerGetGuessesForWord ,
-- ** spellCheckerIgnoreWord
spellCheckerIgnoreWord ,
-- ** spellCheckerLearnWord
spellCheckerLearnWord ,
-- ** spellCheckerUpdateSpellCheckingLanguages
spellCheckerUpdateSpellCheckingLanguages,
) 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.WebKit.Types
import GI.WebKit.Callbacks
import qualified GI.GObject as GObject
-- interface SpellChecker
newtype SpellChecker = SpellChecker (ForeignPtr SpellChecker)
noSpellChecker :: Maybe SpellChecker
noSpellChecker = Nothing
type instance AttributeList SpellChecker = SpellCheckerAttributeList
type SpellCheckerAttributeList = ('[ ] :: [(Symbol, *)])
type instance SignalList SpellChecker = SpellCheckerSignalList
type SpellCheckerSignalList = ('[ '("notify", GObject.ObjectNotifySignalInfo), '("notify::[property]", GObjectNotifySignalInfo)] :: [(Symbol, *)])
foreign import ccall "webkit_spell_checker_get_type"
c_webkit_spell_checker_get_type :: IO GType
type instance ParentTypes SpellChecker = SpellCheckerParentTypes
type SpellCheckerParentTypes = '[GObject.Object]
instance GObject SpellChecker where
gobjectIsInitiallyUnowned _ = False
gobjectType _ = c_webkit_spell_checker_get_type
class GObject o => SpellCheckerK o
instance (GObject o, IsDescendantOf SpellChecker o) => SpellCheckerK o
toSpellChecker :: SpellCheckerK o => o -> IO SpellChecker
toSpellChecker = unsafeCastTo SpellChecker
-- method SpellChecker::check_spelling_of_string
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "WebKit" "SpellChecker", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "string", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "misspelling_location", argType = TBasicType TInt32, direction = DirectionOut, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferEverything},Arg {argName = "misspelling_length", argType = TBasicType TInt32, direction = DirectionOut, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferEverything}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "WebKit" "SpellChecker", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "string", argType = 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_spell_checker_check_spelling_of_string" webkit_spell_checker_check_spelling_of_string ::
Ptr SpellChecker -> -- _obj : TInterface "WebKit" "SpellChecker"
CString -> -- string : TBasicType TUTF8
Ptr Int32 -> -- misspelling_location : TBasicType TInt32
Ptr Int32 -> -- misspelling_length : TBasicType TInt32
IO ()
spellCheckerCheckSpellingOfString ::
(MonadIO m, SpellCheckerK a) =>
a -> -- _obj
T.Text -> -- string
m (Int32,Int32)
spellCheckerCheckSpellingOfString _obj string = liftIO $ do
let _obj' = unsafeManagedPtrCastPtr _obj
string' <- textToCString string
misspelling_location <- allocMem :: IO (Ptr Int32)
misspelling_length <- allocMem :: IO (Ptr Int32)
webkit_spell_checker_check_spelling_of_string _obj' string' misspelling_location misspelling_length
misspelling_location' <- peek misspelling_location
misspelling_length' <- peek misspelling_length
touchManagedPtr _obj
freeMem string'
freeMem misspelling_location
freeMem misspelling_length
return (misspelling_location', misspelling_length')
-- method SpellChecker::get_autocorrect_suggestions_for_misspelled_word
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "WebKit" "SpellChecker", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "word", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "WebKit" "SpellChecker", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "word", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TUTF8
-- throws : False
-- Skip return : False
foreign import ccall "webkit_spell_checker_get_autocorrect_suggestions_for_misspelled_word" webkit_spell_checker_get_autocorrect_suggestions_for_misspelled_word ::
Ptr SpellChecker -> -- _obj : TInterface "WebKit" "SpellChecker"
CString -> -- word : TBasicType TUTF8
IO CString
spellCheckerGetAutocorrectSuggestionsForMisspelledWord ::
(MonadIO m, SpellCheckerK a) =>
a -> -- _obj
T.Text -> -- word
m T.Text
spellCheckerGetAutocorrectSuggestionsForMisspelledWord _obj word = liftIO $ do
let _obj' = unsafeManagedPtrCastPtr _obj
word' <- textToCString word
result <- webkit_spell_checker_get_autocorrect_suggestions_for_misspelled_word _obj' word'
checkUnexpectedReturnNULL "webkit_spell_checker_get_autocorrect_suggestions_for_misspelled_word" result
result' <- cstringToText result
freeMem result
touchManagedPtr _obj
freeMem word'
return result'
-- method SpellChecker::get_guesses_for_word
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "WebKit" "SpellChecker", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "word", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "context", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "WebKit" "SpellChecker", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "word", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "context", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TCArray True (-1) (-1) (TBasicType TUTF8)
-- throws : False
-- Skip return : False
foreign import ccall "webkit_spell_checker_get_guesses_for_word" webkit_spell_checker_get_guesses_for_word ::
Ptr SpellChecker -> -- _obj : TInterface "WebKit" "SpellChecker"
CString -> -- word : TBasicType TUTF8
CString -> -- context : TBasicType TUTF8
IO (Ptr CString)
spellCheckerGetGuessesForWord ::
(MonadIO m, SpellCheckerK a) =>
a -> -- _obj
T.Text -> -- word
Maybe (T.Text) -> -- context
m [T.Text]
spellCheckerGetGuessesForWord _obj word context = liftIO $ do
let _obj' = unsafeManagedPtrCastPtr _obj
word' <- textToCString word
maybeContext <- case context of
Nothing -> return nullPtr
Just jContext -> do
jContext' <- textToCString jContext
return jContext'
result <- webkit_spell_checker_get_guesses_for_word _obj' word' maybeContext
checkUnexpectedReturnNULL "webkit_spell_checker_get_guesses_for_word" result
result' <- unpackZeroTerminatedUTF8CArray result
mapZeroTerminatedCArray freeMem result
freeMem result
touchManagedPtr _obj
freeMem word'
freeMem maybeContext
return result'
-- method SpellChecker::ignore_word
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "WebKit" "SpellChecker", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "word", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "WebKit" "SpellChecker", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "word", argType = 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_spell_checker_ignore_word" webkit_spell_checker_ignore_word ::
Ptr SpellChecker -> -- _obj : TInterface "WebKit" "SpellChecker"
CString -> -- word : TBasicType TUTF8
IO ()
spellCheckerIgnoreWord ::
(MonadIO m, SpellCheckerK a) =>
a -> -- _obj
T.Text -> -- word
m ()
spellCheckerIgnoreWord _obj word = liftIO $ do
let _obj' = unsafeManagedPtrCastPtr _obj
word' <- textToCString word
webkit_spell_checker_ignore_word _obj' word'
touchManagedPtr _obj
freeMem word'
return ()
-- method SpellChecker::learn_word
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "WebKit" "SpellChecker", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "word", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "WebKit" "SpellChecker", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "word", argType = 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_spell_checker_learn_word" webkit_spell_checker_learn_word ::
Ptr SpellChecker -> -- _obj : TInterface "WebKit" "SpellChecker"
CString -> -- word : TBasicType TUTF8
IO ()
spellCheckerLearnWord ::
(MonadIO m, SpellCheckerK a) =>
a -> -- _obj
T.Text -> -- word
m ()
spellCheckerLearnWord _obj word = liftIO $ do
let _obj' = unsafeManagedPtrCastPtr _obj
word' <- textToCString word
webkit_spell_checker_learn_word _obj' word'
touchManagedPtr _obj
freeMem word'
return ()
-- method SpellChecker::update_spell_checking_languages
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "WebKit" "SpellChecker", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "languages", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "WebKit" "SpellChecker", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "languages", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False
foreign import ccall "webkit_spell_checker_update_spell_checking_languages" webkit_spell_checker_update_spell_checking_languages ::
Ptr SpellChecker -> -- _obj : TInterface "WebKit" "SpellChecker"
CString -> -- languages : TBasicType TUTF8
IO ()
spellCheckerUpdateSpellCheckingLanguages ::
(MonadIO m, SpellCheckerK a) =>
a -> -- _obj
Maybe (T.Text) -> -- languages
m ()
spellCheckerUpdateSpellCheckingLanguages _obj languages = liftIO $ do
let _obj' = unsafeManagedPtrCastPtr _obj
maybeLanguages <- case languages of
Nothing -> return nullPtr
Just jLanguages -> do
jLanguages' <- textToCString jLanguages
return jLanguages'
webkit_spell_checker_update_spell_checking_languages _obj' maybeLanguages
touchManagedPtr _obj
freeMem maybeLanguages
return ()