{- | Copyright : Will Thompson, Iñaki García Etxebarria and Jonas Platte License : LGPL-2.1 Maintainer : Iñaki García Etxebarria (inaki@blueleaf.cc) /No description available in the introspection data./ -} #define ENABLE_OVERLOADING (MIN_VERSION_haskell_gi_overloading(1,0,0) \ && !defined(__HADDOCK_VERSION__)) module GI.GtkSource.Structs.Encoding ( -- * Exported types Encoding(..) , noEncoding , -- * Methods -- ** copy #method:copy# #if ENABLE_OVERLOADING EncodingCopyMethodInfo , #endif encodingCopy , -- ** free #method:free# #if ENABLE_OVERLOADING EncodingFreeMethodInfo , #endif encodingFree , -- ** getAll #method:getAll# encodingGetAll , -- ** getCharset #method:getCharset# #if ENABLE_OVERLOADING EncodingGetCharsetMethodInfo , #endif encodingGetCharset , -- ** getCurrent #method:getCurrent# encodingGetCurrent , -- ** getDefaultCandidates #method:getDefaultCandidates# encodingGetDefaultCandidates , -- ** getFromCharset #method:getFromCharset# encodingGetFromCharset , -- ** getName #method:getName# #if ENABLE_OVERLOADING EncodingGetNameMethodInfo , #endif encodingGetName , -- ** getUtf8 #method:getUtf8# encodingGetUtf8 , -- ** toString #method:toString# #if ENABLE_OVERLOADING EncodingToStringMethodInfo , #endif encodingToString , ) 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.GClosure as B.GClosure import qualified Data.GI.Base.GError as B.GError import qualified Data.GI.Base.GVariant as B.GVariant import qualified Data.GI.Base.GValue as B.GValue import qualified Data.GI.Base.GParamSpec as B.GParamSpec import qualified Data.GI.Base.CallStack as B.CallStack import qualified Data.GI.Base.Properties as B.Properties 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 GHC.OverloadedLabels as OL -- | Memory-managed wrapper type. newtype Encoding = Encoding (ManagedPtr Encoding) foreign import ccall "gtk_source_encoding_get_type" c_gtk_source_encoding_get_type :: IO GType instance BoxedObject Encoding where boxedType _ = c_gtk_source_encoding_get_type -- | A convenience alias for `Nothing` :: `Maybe` `Encoding`. noEncoding :: Maybe Encoding noEncoding = Nothing #if ENABLE_OVERLOADING instance O.HasAttributeList Encoding type instance O.AttributeList Encoding = EncodingAttributeList type EncodingAttributeList = ('[ ] :: [(Symbol, *)]) #endif -- method Encoding::copy -- method type : OrdinaryMethod -- Args : [Arg {argCName = "enc", argType = TInterface (Name {namespace = "GtkSource", name = "Encoding"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GtkSourceEncoding.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TInterface (Name {namespace = "GtkSource", name = "Encoding"})) -- throws : False -- Skip return : False foreign import ccall "gtk_source_encoding_copy" gtk_source_encoding_copy :: Ptr Encoding -> -- enc : TInterface (Name {namespace = "GtkSource", name = "Encoding"}) IO (Ptr Encoding) {- | Used by language bindings. /Since: 3.14/ -} encodingCopy :: (B.CallStack.HasCallStack, MonadIO m) => Encoding {- ^ /@enc@/: a 'GI.GtkSource.Structs.Encoding.Encoding'. -} -> m Encoding {- ^ __Returns:__ a copy of /@enc@/. -} encodingCopy enc = liftIO $ do enc' <- unsafeManagedPtrGetPtr enc result <- gtk_source_encoding_copy enc' checkUnexpectedReturnNULL "encodingCopy" result result' <- (wrapBoxed Encoding) result touchManagedPtr enc return result' #if ENABLE_OVERLOADING data EncodingCopyMethodInfo instance (signature ~ (m Encoding), MonadIO m) => O.MethodInfo EncodingCopyMethodInfo Encoding signature where overloadedMethod _ = encodingCopy #endif -- method Encoding::free -- method type : OrdinaryMethod -- Args : [Arg {argCName = "enc", argType = TInterface (Name {namespace = "GtkSource", name = "Encoding"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GtkSourceEncoding.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "gtk_source_encoding_free" gtk_source_encoding_free :: Ptr Encoding -> -- enc : TInterface (Name {namespace = "GtkSource", name = "Encoding"}) IO () {- | Used by language bindings. /Since: 3.14/ -} encodingFree :: (B.CallStack.HasCallStack, MonadIO m) => Encoding {- ^ /@enc@/: a 'GI.GtkSource.Structs.Encoding.Encoding'. -} -> m () encodingFree enc = liftIO $ do enc' <- unsafeManagedPtrGetPtr enc gtk_source_encoding_free enc' touchManagedPtr enc return () #if ENABLE_OVERLOADING data EncodingFreeMethodInfo instance (signature ~ (m ()), MonadIO m) => O.MethodInfo EncodingFreeMethodInfo Encoding signature where overloadedMethod _ = encodingFree #endif -- method Encoding::get_charset -- method type : OrdinaryMethod -- Args : [Arg {argCName = "enc", argType = TInterface (Name {namespace = "GtkSource", name = "Encoding"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GtkSourceEncoding.", 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 "gtk_source_encoding_get_charset" gtk_source_encoding_get_charset :: Ptr Encoding -> -- enc : TInterface (Name {namespace = "GtkSource", name = "Encoding"}) IO CString {- | Gets the character set of the 'GI.GtkSource.Structs.Encoding.Encoding', such as \"UTF-8\" or \"ISO-8859-1\". /Since: 3.14/ -} encodingGetCharset :: (B.CallStack.HasCallStack, MonadIO m) => Encoding {- ^ /@enc@/: a 'GI.GtkSource.Structs.Encoding.Encoding'. -} -> m T.Text {- ^ __Returns:__ the character set of the 'GI.GtkSource.Structs.Encoding.Encoding'. -} encodingGetCharset enc = liftIO $ do enc' <- unsafeManagedPtrGetPtr enc result <- gtk_source_encoding_get_charset enc' checkUnexpectedReturnNULL "encodingGetCharset" result result' <- cstringToText result touchManagedPtr enc return result' #if ENABLE_OVERLOADING data EncodingGetCharsetMethodInfo instance (signature ~ (m T.Text), MonadIO m) => O.MethodInfo EncodingGetCharsetMethodInfo Encoding signature where overloadedMethod _ = encodingGetCharset #endif -- method Encoding::get_name -- method type : OrdinaryMethod -- Args : [Arg {argCName = "enc", argType = TInterface (Name {namespace = "GtkSource", name = "Encoding"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GtkSourceEncoding.", 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 "gtk_source_encoding_get_name" gtk_source_encoding_get_name :: Ptr Encoding -> -- enc : TInterface (Name {namespace = "GtkSource", name = "Encoding"}) IO CString {- | Gets the name of the 'GI.GtkSource.Structs.Encoding.Encoding' such as \"Unicode\" or \"Western\". /Since: 3.14/ -} encodingGetName :: (B.CallStack.HasCallStack, MonadIO m) => Encoding {- ^ /@enc@/: a 'GI.GtkSource.Structs.Encoding.Encoding'. -} -> m T.Text {- ^ __Returns:__ the name of the 'GI.GtkSource.Structs.Encoding.Encoding'. -} encodingGetName enc = liftIO $ do enc' <- unsafeManagedPtrGetPtr enc result <- gtk_source_encoding_get_name enc' checkUnexpectedReturnNULL "encodingGetName" result result' <- cstringToText result touchManagedPtr enc return result' #if ENABLE_OVERLOADING data EncodingGetNameMethodInfo instance (signature ~ (m T.Text), MonadIO m) => O.MethodInfo EncodingGetNameMethodInfo Encoding signature where overloadedMethod _ = encodingGetName #endif -- method Encoding::to_string -- method type : OrdinaryMethod -- Args : [Arg {argCName = "enc", argType = TInterface (Name {namespace = "GtkSource", name = "Encoding"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GtkSourceEncoding.", 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 "gtk_source_encoding_to_string" gtk_source_encoding_to_string :: Ptr Encoding -> -- enc : TInterface (Name {namespace = "GtkSource", name = "Encoding"}) IO CString {- | /No description available in the introspection data./ /Since: 3.14/ -} encodingToString :: (B.CallStack.HasCallStack, MonadIO m) => Encoding {- ^ /@enc@/: a 'GI.GtkSource.Structs.Encoding.Encoding'. -} -> m T.Text {- ^ __Returns:__ a string representation. Free with 'GI.GLib.Functions.free' when no longer needed. -} encodingToString enc = liftIO $ do enc' <- unsafeManagedPtrGetPtr enc result <- gtk_source_encoding_to_string enc' checkUnexpectedReturnNULL "encodingToString" result result' <- cstringToText result freeMem result touchManagedPtr enc return result' #if ENABLE_OVERLOADING data EncodingToStringMethodInfo instance (signature ~ (m T.Text), MonadIO m) => O.MethodInfo EncodingToStringMethodInfo Encoding signature where overloadedMethod _ = encodingToString #endif -- method Encoding::get_all -- method type : MemberFunction -- Args : [] -- Lengths : [] -- returnType : Just (TGSList (TInterface (Name {namespace = "GtkSource", name = "Encoding"}))) -- throws : False -- Skip return : False foreign import ccall "gtk_source_encoding_get_all" gtk_source_encoding_get_all :: IO (Ptr (GSList (Ptr Encoding))) {- | Gets all encodings. /Since: 3.14/ -} encodingGetAll :: (B.CallStack.HasCallStack, MonadIO m) => m [Encoding] {- ^ __Returns:__ a list of all 'GI.GtkSource.Structs.Encoding.Encoding'\'s. Free with @/g_slist_free()/@. -} encodingGetAll = liftIO $ do result <- gtk_source_encoding_get_all result' <- unpackGSList result result'' <- mapM (newBoxed Encoding) result' g_slist_free result return result'' #if ENABLE_OVERLOADING #endif -- method Encoding::get_current -- method type : MemberFunction -- Args : [] -- Lengths : [] -- returnType : Just (TInterface (Name {namespace = "GtkSource", name = "Encoding"})) -- throws : False -- Skip return : False foreign import ccall "gtk_source_encoding_get_current" gtk_source_encoding_get_current :: IO (Ptr Encoding) {- | Gets the 'GI.GtkSource.Structs.Encoding.Encoding' for the current locale. See also 'GI.GLib.Functions.getCharset'. /Since: 3.14/ -} encodingGetCurrent :: (B.CallStack.HasCallStack, MonadIO m) => m Encoding {- ^ __Returns:__ the current locale encoding. -} encodingGetCurrent = liftIO $ do result <- gtk_source_encoding_get_current checkUnexpectedReturnNULL "encodingGetCurrent" result result' <- (newBoxed Encoding) result return result' #if ENABLE_OVERLOADING #endif -- method Encoding::get_default_candidates -- method type : MemberFunction -- Args : [] -- Lengths : [] -- returnType : Just (TGSList (TInterface (Name {namespace = "GtkSource", name = "Encoding"}))) -- throws : False -- Skip return : False foreign import ccall "gtk_source_encoding_get_default_candidates" gtk_source_encoding_get_default_candidates :: IO (Ptr (GSList (Ptr Encoding))) {- | Gets the list of default candidate encodings to try when loading a file. See 'GI.GtkSource.Objects.FileLoader.fileLoaderSetCandidateEncodings'. This function returns a different list depending on the current locale (i.e. language, country and default encoding). The UTF-8 encoding and the current locale encoding are guaranteed to be present in the returned list. /Since: 3.18/ -} encodingGetDefaultCandidates :: (B.CallStack.HasCallStack, MonadIO m) => m [Encoding] {- ^ __Returns:__ the list of default candidate encodings. Free with @/g_slist_free()/@. -} encodingGetDefaultCandidates = liftIO $ do result <- gtk_source_encoding_get_default_candidates result' <- unpackGSList result result'' <- mapM (newBoxed Encoding) result' g_slist_free result return result'' #if ENABLE_OVERLOADING #endif -- method Encoding::get_from_charset -- method type : MemberFunction -- Args : [Arg {argCName = "charset", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a character set.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TInterface (Name {namespace = "GtkSource", name = "Encoding"})) -- throws : False -- Skip return : False foreign import ccall "gtk_source_encoding_get_from_charset" gtk_source_encoding_get_from_charset :: CString -> -- charset : TBasicType TUTF8 IO (Ptr Encoding) {- | Gets a 'GI.GtkSource.Structs.Encoding.Encoding' from a character set such as \"UTF-8\" or \"ISO-8859-1\". /Since: 3.14/ -} encodingGetFromCharset :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@charset@/: a character set. -} -> m (Maybe Encoding) {- ^ __Returns:__ the corresponding 'GI.GtkSource.Structs.Encoding.Encoding', or 'Nothing' if not found. -} encodingGetFromCharset charset = liftIO $ do charset' <- textToCString charset result <- gtk_source_encoding_get_from_charset charset' maybeResult <- convertIfNonNull result $ \result' -> do result'' <- (newBoxed Encoding) result' return result'' freeMem charset' return maybeResult #if ENABLE_OVERLOADING #endif -- method Encoding::get_utf8 -- method type : MemberFunction -- Args : [] -- Lengths : [] -- returnType : Just (TInterface (Name {namespace = "GtkSource", name = "Encoding"})) -- throws : False -- Skip return : False foreign import ccall "gtk_source_encoding_get_utf8" gtk_source_encoding_get_utf8 :: IO (Ptr Encoding) {- | /No description available in the introspection data./ /Since: 3.14/ -} encodingGetUtf8 :: (B.CallStack.HasCallStack, MonadIO m) => m Encoding {- ^ __Returns:__ the UTF-8 encoding. -} encodingGetUtf8 = liftIO $ do result <- gtk_source_encoding_get_utf8 checkUnexpectedReturnNULL "encodingGetUtf8" result result' <- (newBoxed Encoding) result return result' #if ENABLE_OVERLOADING #endif #if ENABLE_OVERLOADING type family ResolveEncodingMethod (t :: Symbol) (o :: *) :: * where ResolveEncodingMethod "copy" o = EncodingCopyMethodInfo ResolveEncodingMethod "free" o = EncodingFreeMethodInfo ResolveEncodingMethod "toString" o = EncodingToStringMethodInfo ResolveEncodingMethod "getCharset" o = EncodingGetCharsetMethodInfo ResolveEncodingMethod "getName" o = EncodingGetNameMethodInfo ResolveEncodingMethod l o = O.MethodResolutionFailed l o instance (info ~ ResolveEncodingMethod t Encoding, O.MethodInfo info Encoding p) => OL.IsLabel t (Encoding -> p) where #if MIN_VERSION_base(4,10,0) fromLabel = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info) #else fromLabel _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info) #endif #endif