-- | Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
-- License    : LGPL-2.1
-- Maintainer : Iñaki García Etxebarria

#if (MIN_VERSION_haskell_gi_overloading(1,0,0) && !defined(__HADDOCK_VERSION__))
#define ENABLE_OVERLOADING
#endif

module GI.IBus.Functions
    ( 

 -- * Methods
-- ** acceleratorName #method:acceleratorName#

    acceleratorName                         ,


-- ** acceleratorParse #method:acceleratorParse#

    acceleratorParse                        ,


-- ** acceleratorValid #method:acceleratorValid#

    acceleratorValid                        ,


-- ** attrBackgroundNew #method:attrBackgroundNew#

    attrBackgroundNew                       ,


-- ** attrForegroundNew #method:attrForegroundNew#

    attrForegroundNew                       ,


-- ** emojiDictLoad #method:emojiDictLoad#

    emojiDictLoad                           ,


-- ** emojiDictSave #method:emojiDictSave#

    emojiDictSave                           ,


-- ** freeStrv #method:freeStrv#

    freeStrv                                ,


-- ** getAddress #method:getAddress#

    getAddress                              ,


-- ** getDaemonUid #method:getDaemonUid#

    getDaemonUid                            ,


-- ** getLanguageName #method:getLanguageName#

    getLanguageName                         ,


-- ** getLocalMachineId #method:getLocalMachineId#

    getLocalMachineId                       ,


-- ** getSocketPath #method:getSocketPath#

    getSocketPath                           ,


-- ** getTimeout #method:getTimeout#

    getTimeout                              ,


-- ** getUntranslatedLanguageName #method:getUntranslatedLanguageName#

    getUntranslatedLanguageName             ,


-- ** getUserName #method:getUserName#

    getUserName                             ,


-- ** init #method:init#

    init                                    ,


-- ** keyEventFromString #method:keyEventFromString#

    keyEventFromString                      ,


-- ** keyEventToString #method:keyEventToString#

    keyEventToString                        ,


-- ** keyvalConvertCase #method:keyvalConvertCase#

    keyvalConvertCase                       ,


-- ** keyvalFromName #method:keyvalFromName#

    keyvalFromName                          ,


-- ** keyvalName #method:keyvalName#

    keyvalName                              ,


-- ** keyvalToLower #method:keyvalToLower#

    keyvalToLower                           ,


-- ** keyvalToUnicode #method:keyvalToUnicode#

    keyvalToUnicode                         ,


-- ** keyvalToUpper #method:keyvalToUpper#

    keyvalToUpper                           ,


-- ** main #method:main#

    main                                    ,


-- ** quit #method:quit#

    quit                                    ,


-- ** setDisplay #method:setDisplay#

    setDisplay                              ,


-- ** setLogHandler #method:setLogHandler#

    setLogHandler                           ,


-- ** unicodeToKeyval #method:unicodeToKeyval#

    unicodeToKeyval                         ,


-- ** unsetLogHandler #method:unsetLogHandler#

    unsetLogHandler                         ,


-- ** writeAddress #method:writeAddress#

    writeAddress                            ,




    ) 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.BasicTypes as B.Types
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.GI.Base.Signals as B.Signals
import qualified Control.Monad.IO.Class as MIO
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

import {-# SOURCE #-} qualified GI.IBus.Flags as IBus.Flags
import {-# SOURCE #-} qualified GI.IBus.Objects.Attribute as IBus.Attribute

-- function write_address
-- Args: [ Arg
--           { argCName = "address"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "D-Bus address of IBus."
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "ibus_write_address" ibus_write_address :: 
    CString ->                              -- address : TBasicType TUTF8
    IO ()

-- | Write D-Bus address to socket file.
-- 
-- See also: 'GI.IBus.Functions.getAddress'.
writeAddress ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    -- ^ /@address@/: D-Bus address of IBus.
    -> m ()
writeAddress :: Text -> m ()
writeAddress Text
address = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    CString
address' <- Text -> IO CString
textToCString Text
address
    CString -> IO ()
ibus_write_address CString
address'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
address'
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()


-- function unset_log_handler
-- Args: []
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "ibus_unset_log_handler" ibus_unset_log_handler :: 
    IO ()

-- | Remove the log handler which is set by ibus_set_log_handler.
unsetLogHandler ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m ()
unsetLogHandler :: m ()
unsetLogHandler  = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    IO ()
ibus_unset_log_handler
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()


-- function unicode_to_keyval
-- Args: [ Arg
--           { argCName = "wc"
--           , argType = TBasicType TUniChar
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a ISO10646 encoded character"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TUInt)
-- throws : False
-- Skip return : False

foreign import ccall "ibus_unicode_to_keyval" ibus_unicode_to_keyval :: 
    CInt ->                                 -- wc : TBasicType TUniChar
    IO Word32

-- | Convert from a ISO10646 character to a key symbol.
unicodeToKeyval ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Char
    -- ^ /@wc@/: a ISO10646 encoded character
    -> m Word32
    -- ^ __Returns:__ the corresponding IBus key symbol, if one exists.
    --          or, if there is no corresponding symbol,
    --          wc | 0x01000000
unicodeToKeyval :: Char -> m Word32
unicodeToKeyval Char
wc = IO Word32 -> m Word32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Word32 -> m Word32) -> IO Word32 -> m Word32
forall a b. (a -> b) -> a -> b
$ do
    let wc' :: CInt
wc' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt) -> (Char -> Int) -> Char -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> Int
ord) Char
wc
    Word32
result <- CInt -> IO Word32
ibus_unicode_to_keyval CInt
wc'
    Word32 -> IO Word32
forall (m :: * -> *) a. Monad m => a -> m a
return Word32
result


-- function set_log_handler
-- Args: [ Arg
--           { argCName = "verbose"
--           , argType = TBasicType TBoolean
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "TRUE for verbose logging."
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "ibus_set_log_handler" ibus_set_log_handler :: 
    CInt ->                                 -- verbose : TBasicType TBoolean
    IO ()

-- | Sets GLIB\'s log handler to ours. Our log handler adds time info
-- including hour, minute, second, and microsecond, like:
-- 
-- (ibus-daemon:7088): IBUS-DEBUG: 18:06:45.822819: ibus-daemon started
-- 
-- If /@verbose@/ is 'P.True', all levels of messages will be logged. Otherwise,
-- DEBUG and WARNING messages will be ignored.  The function is used in
-- ibus-daemon, but can be useful for IBus client programs as well for
-- debugging. It\'s totally fine for not calling this function. If you
-- don\'t set a custom GLIB log handler, the default GLIB log handler will
-- be used.
setLogHandler ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Bool
    -- ^ /@verbose@/: TRUE for verbose logging.
    -> m ()
setLogHandler :: Bool -> m ()
setLogHandler Bool
verbose = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    let verbose' :: CInt
verbose' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt) -> (Bool -> Int) -> Bool -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Bool -> Int
forall a. Enum a => a -> Int
fromEnum) Bool
verbose
    CInt -> IO ()
ibus_set_log_handler CInt
verbose'
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()


-- function set_display
-- Args: [ Arg
--           { argCName = "display"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "Display address, as in DISPLAY environment for X."
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "ibus_set_display" ibus_set_display :: 
    CString ->                              -- display : TBasicType TUTF8
    IO ()

-- | Set the display address.
setDisplay ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    -- ^ /@display@/: Display address, as in DISPLAY environment for X.
    -> m ()
setDisplay :: Text -> m ()
setDisplay Text
display = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    CString
display' <- Text -> IO CString
textToCString Text
display
    CString -> IO ()
ibus_set_display CString
display'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
display'
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()


-- function quit
-- Args: []
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "ibus_quit" ibus_quit :: 
    IO ()

-- | Stops an IBus from running.
-- 
-- Any calls to 'GI.IBus.Functions.quit' for the loop will return.
-- See also: 'GI.IBus.Functions.main'.
quit ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m ()
quit :: m ()
quit  = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    IO ()
ibus_quit
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()


-- function main
-- Args: []
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "ibus_main" ibus_main :: 
    IO ()

-- | Runs an IBus main loop until 'GI.IBus.Functions.quit' is called in the loop.
-- 
-- See also: 'GI.IBus.Functions.quit'.
main ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m ()
main :: m ()
main  = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    IO ()
ibus_main
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()


-- function keyval_to_upper
-- Args: [ Arg
--           { argCName = "keyval"
--           , argType = TBasicType TUInt
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a key value." , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TUInt)
-- throws : False
-- Skip return : False

foreign import ccall "ibus_keyval_to_upper" ibus_keyval_to_upper :: 
    Word32 ->                               -- keyval : TBasicType TUInt
    IO Word32

-- | Converts a key value to upper case, if applicable.
keyvalToUpper ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Word32
    -- ^ /@keyval@/: a key value.
    -> m Word32
    -- ^ __Returns:__ the upper case form of /@keyval@/, or /@keyval@/ itself if it is already
    --   in upper case or it is not subject to case conversion.
keyvalToUpper :: Word32 -> m Word32
keyvalToUpper Word32
keyval = IO Word32 -> m Word32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Word32 -> m Word32) -> IO Word32 -> m Word32
forall a b. (a -> b) -> a -> b
$ do
    Word32
result <- Word32 -> IO Word32
ibus_keyval_to_upper Word32
keyval
    Word32 -> IO Word32
forall (m :: * -> *) a. Monad m => a -> m a
return Word32
result


-- function keyval_to_unicode
-- Args: [ Arg
--           { argCName = "keyval"
--           , argType = TBasicType TUInt
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "an IBus key symbol" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TUniChar)
-- throws : False
-- Skip return : False

foreign import ccall "ibus_keyval_to_unicode" ibus_keyval_to_unicode :: 
    Word32 ->                               -- keyval : TBasicType TUInt
    IO CInt

-- | Convert from an IBus key symbol to the corresponding ISO10646 (Unicode)
-- character.
keyvalToUnicode ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Word32
    -- ^ /@keyval@/: an IBus key symbol
    -> m Char
    -- ^ __Returns:__ the corresponding unicode character, or 0 if there
    --          is no corresponding character.
keyvalToUnicode :: Word32 -> m Char
keyvalToUnicode Word32
keyval = IO Char -> m Char
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Char -> m Char) -> IO Char -> m Char
forall a b. (a -> b) -> a -> b
$ do
    CInt
result <- Word32 -> IO CInt
ibus_keyval_to_unicode Word32
keyval
    let result' :: Char
result' = (Int -> Char
chr (Int -> Char) -> (CInt -> Int) -> CInt -> Char
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral) CInt
result
    Char -> IO Char
forall (m :: * -> *) a. Monad m => a -> m a
return Char
result'


-- function keyval_to_lower
-- Args: [ Arg
--           { argCName = "keyval"
--           , argType = TBasicType TUInt
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a key value." , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TUInt)
-- throws : False
-- Skip return : False

foreign import ccall "ibus_keyval_to_lower" ibus_keyval_to_lower :: 
    Word32 ->                               -- keyval : TBasicType TUInt
    IO Word32

-- | Converts a key value to lower case, if applicable.
keyvalToLower ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Word32
    -- ^ /@keyval@/: a key value.
    -> m Word32
    -- ^ __Returns:__ the lower case form of /@keyval@/, or /@keyval@/ itself if it is already
    --  in lower case or it is not subject to case conversion.
keyvalToLower :: Word32 -> m Word32
keyvalToLower Word32
keyval = IO Word32 -> m Word32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Word32 -> m Word32) -> IO Word32 -> m Word32
forall a b. (a -> b) -> a -> b
$ do
    Word32
result <- Word32 -> IO Word32
ibus_keyval_to_lower Word32
keyval
    Word32 -> IO Word32
forall (m :: * -> *) a. Monad m => a -> m a
return Word32
result


-- function keyval_name
-- Args: [ Arg
--           { argCName = "keyval"
--           , argType = TBasicType TUInt
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "Key symbol." , 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 "ibus_keyval_name" ibus_keyval_name :: 
    Word32 ->                               -- keyval : TBasicType TUInt
    IO CString

-- | Return the name of a key symbol.
-- 
-- Note that the returned string is used internally, so don\'t free it.
keyvalName ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Word32
    -- ^ /@keyval@/: Key symbol.
    -> m T.Text
    -- ^ __Returns:__ Corresponding key name. 'P.Nothing' if no such key symbol.
keyvalName :: Word32 -> m Text
keyvalName Word32
keyval = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    CString
result <- Word32 -> IO CString
ibus_keyval_name Word32
keyval
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"keyvalName" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result'


-- function keyval_from_name
-- Args: [ Arg
--           { argCName = "keyval_name"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "Key name in #gdk_keys_by_name."
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TUInt)
-- throws : False
-- Skip return : False

foreign import ccall "ibus_keyval_from_name" ibus_keyval_from_name :: 
    CString ->                              -- keyval_name : TBasicType TUTF8
    IO Word32

-- | Return the key symbol that associate with the key name.
keyvalFromName ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    -- ^ /@keyvalName@/: Key name in @/gdk_keys_by_name/@.
    -> m Word32
    -- ^ __Returns:__ Corresponding key symbol.
keyvalFromName :: Text -> m Word32
keyvalFromName Text
keyvalName = IO Word32 -> m Word32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Word32 -> m Word32) -> IO Word32 -> m Word32
forall a b. (a -> b) -> a -> b
$ do
    CString
keyvalName' <- Text -> IO CString
textToCString Text
keyvalName
    Word32
result <- CString -> IO Word32
ibus_keyval_from_name CString
keyvalName'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
keyvalName'
    Word32 -> IO Word32
forall (m :: * -> *) a. Monad m => a -> m a
return Word32
result


-- function keyval_convert_case
-- Args: [ Arg
--           { argCName = "symbol"
--           , argType = TBasicType TUInt
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a keyval" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "lower"
--           , argType = TBasicType TUInt
--           , direction = DirectionOut
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "return location for lowercase version of @symbol"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferEverything
--           }
--       , Arg
--           { argCName = "upper"
--           , argType = TBasicType TUInt
--           , direction = DirectionOut
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "return location for uppercase version of @symbol"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferEverything
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "ibus_keyval_convert_case" ibus_keyval_convert_case :: 
    Word32 ->                               -- symbol : TBasicType TUInt
    Ptr Word32 ->                           -- lower : TBasicType TUInt
    Ptr Word32 ->                           -- upper : TBasicType TUInt
    IO ()

-- | Obtains the upper- and lower-case versions of the keyval /@symbol@/.
-- Examples of keyvals are 'GI.IBus.Constants.KEY_a', 'GI.IBus.Constants.KEY_Return', 'GI.IBus.Constants.KEY_F1', etc.
keyvalConvertCase ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Word32
    -- ^ /@symbol@/: a keyval
    -> m ((Word32, Word32))
keyvalConvertCase :: Word32 -> m (Word32, Word32)
keyvalConvertCase Word32
symbol = IO (Word32, Word32) -> m (Word32, Word32)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Word32, Word32) -> m (Word32, Word32))
-> IO (Word32, Word32) -> m (Word32, Word32)
forall a b. (a -> b) -> a -> b
$ do
    Ptr Word32
lower <- IO (Ptr Word32)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr Word32)
    Ptr Word32
upper <- IO (Ptr Word32)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr Word32)
    Word32 -> Ptr Word32 -> Ptr Word32 -> IO ()
ibus_keyval_convert_case Word32
symbol Ptr Word32
lower Ptr Word32
upper
    Word32
lower' <- Ptr Word32 -> IO Word32
forall a. Storable a => Ptr a -> IO a
peek Ptr Word32
lower
    Word32
upper' <- Ptr Word32 -> IO Word32
forall a. Storable a => Ptr a -> IO a
peek Ptr Word32
upper
    Ptr Word32 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word32
lower
    Ptr Word32 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word32
upper
    (Word32, Word32) -> IO (Word32, Word32)
forall (m :: * -> *) a. Monad m => a -> m a
return (Word32
lower', Word32
upper')


-- function key_event_to_string
-- Args: [ Arg
--           { argCName = "keyval"
--           , argType = TBasicType TUInt
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "Key symbol." , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "modifiers"
--           , argType = TBasicType TUInt
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "Modifiers such as Ctrl or Shift."
--                 , 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 "ibus_key_event_to_string" ibus_key_event_to_string :: 
    Word32 ->                               -- keyval : TBasicType TUInt
    Word32 ->                               -- modifiers : TBasicType TUInt
    IO CString

-- | Return the name of a key symbol and modifiers.
-- 
-- For example, if press ctrl, shift, and enter, then this function returns:
-- Shift+Control+enter.
keyEventToString ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Word32
    -- ^ /@keyval@/: Key symbol.
    -> Word32
    -- ^ /@modifiers@/: Modifiers such as Ctrl or Shift.
    -> m T.Text
    -- ^ __Returns:__ The name of a key symbol and modifier.
keyEventToString :: Word32 -> Word32 -> m Text
keyEventToString Word32
keyval Word32
modifiers = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    CString
result <- Word32 -> Word32 -> IO CString
ibus_key_event_to_string Word32
keyval Word32
modifiers
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"keyEventToString" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result
    Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result'


-- function key_event_from_string
-- Args: [ Arg
--           { argCName = "string"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "Key event string." , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "keyval"
--           , argType = TBasicType TUInt
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "Variable that hold key symbol result."
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "modifiers"
--           , argType = TBasicType TUInt
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "Variable that hold modifiers result."
--                 , 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 "ibus_key_event_from_string" ibus_key_event_from_string :: 
    CString ->                              -- string : TBasicType TUTF8
    Word32 ->                               -- keyval : TBasicType TUInt
    Word32 ->                               -- modifiers : TBasicType TUInt
    IO CInt

-- | Parse key event string and return key symbol and modifiers.
keyEventFromString ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    -- ^ /@string@/: Key event string.
    -> Word32
    -- ^ /@keyval@/: Variable that hold key symbol result.
    -> Word32
    -- ^ /@modifiers@/: Variable that hold modifiers result.
    -> m Bool
    -- ^ __Returns:__ 'P.True' for succeed; 'P.False' if failed.
keyEventFromString :: Text -> Word32 -> Word32 -> m Bool
keyEventFromString Text
string Word32
keyval Word32
modifiers = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    CString
string' <- Text -> IO CString
textToCString Text
string
    CInt
result <- CString -> Word32 -> Word32 -> IO CInt
ibus_key_event_from_string CString
string' Word32
keyval Word32
modifiers
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
string'
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'


-- function init
-- Args: []
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "ibus_init" ibus_init :: 
    IO ()

-- | Initialize the ibus types.
init ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m ()
init :: m ()
init  = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    IO ()
ibus_init
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()


-- function get_user_name
-- Args: []
-- Lengths: []
-- returnType: Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "ibus_get_user_name" ibus_get_user_name :: 
    IO CString

-- | Get the current user name.
-- It is determined by:
-- \<orderedlist>
--    \<listitem>\<para>@/getlogin()/@\<\/para>\<\/listitem>
--    \<listitem>\<para>Environment variable SUDO_USER\<\/para>\<\/listitem>
--    \<listitem>\<para>Environment variable USERHELPER_UID\<\/para>\<\/listitem>
--    \<listitem>\<para>Environment variable USERNAME\<\/para>\<\/listitem>
--    \<listitem>\<para>Environment variable LOGNAME\<\/para>\<\/listitem>
--    \<listitem>\<para>Environment variable USER\<\/para>\<\/listitem>
--    \<listitem>\<para>Environment variable LNAME\<\/para>\<\/listitem>
-- \<\/orderedlist>
getUserName ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m T.Text
    -- ^ __Returns:__ A newly allocated string that stores current user name.
getUserName :: m Text
getUserName  = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    CString
result <- IO CString
ibus_get_user_name
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"getUserName" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result'


-- function get_untranslated_language_name
-- Args: [ Arg
--           { argCName = "_locale"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "A const locale name."
--                 , 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 "ibus_get_untranslated_language_name" ibus_get_untranslated_language_name :: 
    CString ->                              -- _locale : TBasicType TUTF8
    IO CString

-- | /No description available in the introspection data./
getUntranslatedLanguageName ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    -- ^ /@locale_@/: A const locale name.
    -> m T.Text
    -- ^ __Returns:__ untranslated language name
getUntranslatedLanguageName :: Text -> m Text
getUntranslatedLanguageName Text
_locale = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    CString
_locale' <- Text -> IO CString
textToCString Text
_locale
    CString
result <- CString -> IO CString
ibus_get_untranslated_language_name CString
_locale'
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"getUntranslatedLanguageName" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
_locale'
    Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result'


-- function get_timeout
-- Args: []
-- Lengths: []
-- returnType: Just (TBasicType TInt)
-- throws : False
-- Skip return : False

foreign import ccall "ibus_get_timeout" ibus_get_timeout :: 
    IO Int32

-- | Get the GDBus timeout in milliseconds. The timeout is for clients (e.g.
-- im-ibus.so), not for ibus-daemon.
-- Note that the timeout for ibus-daemon could be set by --timeout command
-- line option of the daemon.
getTimeout ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m Int32
    -- ^ __Returns:__ A GDBus timeout in milliseconds. -1 when default timeout for
    --     GDBus should be used.
getTimeout :: m Int32
getTimeout  = IO Int32 -> m Int32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Int32 -> m Int32) -> IO Int32 -> m Int32
forall a b. (a -> b) -> a -> b
$ do
    Int32
result <- IO Int32
ibus_get_timeout
    Int32 -> IO Int32
forall (m :: * -> *) a. Monad m => a -> m a
return Int32
result


-- function get_socket_path
-- Args: []
-- Lengths: []
-- returnType: Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "ibus_get_socket_path" ibus_get_socket_path :: 
    IO CString

-- | Get the path of socket file.
getSocketPath ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m T.Text
    -- ^ __Returns:__ A newly allocated string that stores the path of socket file.
getSocketPath :: m Text
getSocketPath  = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    CString
result <- IO CString
ibus_get_socket_path
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"getSocketPath" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result'


-- function get_local_machine_id
-- Args: []
-- Lengths: []
-- returnType: Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "ibus_get_local_machine_id" ibus_get_local_machine_id :: 
    IO CString

-- | Obtains the machine UUID of the machine this process is running on.
getLocalMachineId ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m T.Text
    -- ^ __Returns:__ A newly allocated string that shows the UUID of the machine.
getLocalMachineId :: m Text
getLocalMachineId  = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    CString
result <- IO CString
ibus_get_local_machine_id
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"getLocalMachineId" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result'


-- function get_language_name
-- Args: [ Arg
--           { argCName = "_locale"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "A const locale name."
--                 , 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 "ibus_get_language_name" ibus_get_language_name :: 
    CString ->                              -- _locale : TBasicType TUTF8
    IO CString

-- | /No description available in the introspection data./
getLanguageName ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    -- ^ /@locale_@/: A const locale name.
    -> m T.Text
    -- ^ __Returns:__ translated language name
getLanguageName :: Text -> m Text
getLanguageName Text
_locale = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    CString
_locale' <- Text -> IO CString
textToCString Text
_locale
    CString
result <- CString -> IO CString
ibus_get_language_name CString
_locale'
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"getLanguageName" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
_locale'
    Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result'


-- function get_daemon_uid
-- Args: []
-- Lengths: []
-- returnType: Just (TBasicType TLong)
-- throws : False
-- Skip return : False

foreign import ccall "ibus_get_daemon_uid" ibus_get_daemon_uid :: 
    IO CLong

{-# DEPRECATED getDaemonUid ["This function has been deprecated and should","not be used in newly written code."] #-}
-- | Get UID of ibus-daemon.
getDaemonUid ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m CLong
    -- ^ __Returns:__ UID of ibus-daemon; or 0 if UID is not available.
getDaemonUid :: m CLong
getDaemonUid  = IO CLong -> m CLong
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO CLong -> m CLong) -> IO CLong -> m CLong
forall a b. (a -> b) -> a -> b
$ do
    CLong
result <- IO CLong
ibus_get_daemon_uid
    CLong -> IO CLong
forall (m :: * -> *) a. Monad m => a -> m a
return CLong
result


-- function get_address
-- Args: []
-- Lengths: []
-- returnType: Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "ibus_get_address" ibus_get_address :: 
    IO CString

-- | Return the D-Bus address of IBus.
-- It will find the address from following source:
-- \<orderedlist>
--    \<listitem>\<para>Environment variable IBUS_ADDRESS\<\/para>\<\/listitem>
--    \<listitem>\<para>Socket file under ~\/.config\/ibus\/bus\/\<\/para>\<\/listitem>
-- \<\/orderedlist>
getAddress ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m T.Text
    -- ^ __Returns:__ D-Bus address of IBus. 'P.Nothing' for not found.
    -- 
    -- See also: 'GI.IBus.Functions.writeAddress'.
getAddress :: m Text
getAddress  = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    CString
result <- IO CString
ibus_get_address
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"getAddress" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result'


-- function free_strv
-- Args: [ Arg
--           { argCName = "strv"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "List of strings." , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "ibus_free_strv" ibus_free_strv :: 
    CString ->                              -- strv : TBasicType TUTF8
    IO ()

{-# DEPRECATED freeStrv ["This function has been deprecated and should","not be used in newly written code."] #-}
-- | Free a list of strings.
freeStrv ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    -- ^ /@strv@/: List of strings.
    -> m ()
freeStrv :: Text -> m ()
freeStrv Text
strv = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    CString
strv' <- Text -> IO CString
textToCString Text
strv
    CString -> IO ()
ibus_free_strv CString
strv'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
strv'
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()


-- function emoji_dict_save
-- Args: [ Arg
--           { argCName = "path"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "A path of the saved dictionary file."
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "dict"
--           , argType = TGHash (TBasicType TUTF8) (TBasicType TPtr)
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "An Emoji dictionary"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "ibus_emoji_dict_save" ibus_emoji_dict_save :: 
    CString ->                              -- path : TBasicType TUTF8
    Ptr (GHashTable CString (Ptr ())) ->    -- dict : TGHash (TBasicType TUTF8) (TBasicType TPtr)
    IO ()

-- | Saves the Emoji dictionary to the cache file.
-- Recommend to use 'GI.IBus.Objects.EmojiData.emojiDataSave' instead becase GSList in
-- GHashTable does not work with Gir and Vala.
-- Calls 'GI.IBus.Objects.EmojiData.emojiDataSave' internally. The format of the hash table
-- changed and now is { emoji character, t'GI.IBus.Objects.EmojiData.EmojiData' object }.
emojiDictSave ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    -- ^ /@path@/: A path of the saved dictionary file.
    -> Map.Map T.Text (Ptr ())
    -- ^ /@dict@/: An Emoji dictionary
    -> m ()
emojiDictSave :: Text -> Map Text (Ptr ()) -> m ()
emojiDictSave Text
path Map Text (Ptr ())
dict = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    CString
path' <- Text -> IO CString
textToCString Text
path
    let dict' :: [(Text, Ptr ())]
dict' = Map Text (Ptr ()) -> [(Text, Ptr ())]
forall k a. Map k a -> [(k, a)]
Map.toList Map Text (Ptr ())
dict
    [(CString, Ptr ())]
dict'' <- (Text -> IO CString) -> [(Text, Ptr ())] -> IO [(CString, Ptr ())]
forall (f :: * -> *) a c b.
Applicative f =>
(a -> f c) -> [(a, b)] -> f [(c, b)]
mapFirstA Text -> IO CString
textToCString [(Text, Ptr ())]
dict'
    let dict''' :: [(PtrWrapped CString, Ptr ())]
dict''' = (CString -> PtrWrapped CString)
-> [(CString, Ptr ())] -> [(PtrWrapped CString, Ptr ())]
forall a c b. (a -> c) -> [(a, b)] -> [(c, b)]
mapFirst CString -> PtrWrapped CString
cstringPackPtr [(CString, Ptr ())]
dict''
    let dict'''' :: [(PtrWrapped CString, PtrWrapped (Ptr ()))]
dict'''' = (Ptr () -> PtrWrapped (Ptr ()))
-> [(PtrWrapped CString, Ptr ())]
-> [(PtrWrapped CString, PtrWrapped (Ptr ()))]
forall b c a. (b -> c) -> [(a, b)] -> [(a, c)]
mapSecond Ptr () -> PtrWrapped (Ptr ())
forall a. Ptr a -> PtrWrapped (Ptr a)
ptrPackPtr [(PtrWrapped CString, Ptr ())]
dict'''
    Ptr (GHashTable CString (Ptr ()))
dict''''' <- GHashFunc CString
-> GEqualFunc CString
-> Maybe (GDestroyNotify CString)
-> Maybe (GDestroyNotify (Ptr ()))
-> [(PtrWrapped CString, PtrWrapped (Ptr ()))]
-> IO (Ptr (GHashTable CString (Ptr ())))
forall a b.
GHashFunc a
-> GEqualFunc a
-> Maybe (GDestroyNotify a)
-> Maybe (GDestroyNotify b)
-> [(PtrWrapped a, PtrWrapped b)]
-> IO (Ptr (GHashTable a b))
packGHashTable GHashFunc CString
gStrHash GEqualFunc CString
gStrEqual (GDestroyNotify CString -> Maybe (GDestroyNotify CString)
forall a. a -> Maybe a
Just GDestroyNotify CString
forall a. FunPtr (Ptr a -> IO ())
ptr_to_g_free) Maybe (GDestroyNotify (Ptr ()))
forall a. Maybe a
Nothing [(PtrWrapped CString, PtrWrapped (Ptr ()))]
dict''''
    CString -> Ptr (GHashTable CString (Ptr ())) -> IO ()
ibus_emoji_dict_save CString
path' Ptr (GHashTable CString (Ptr ()))
dict'''''
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
path'
    Ptr (GHashTable CString (Ptr ())) -> IO ()
forall a b. Ptr (GHashTable a b) -> IO ()
unrefGHashTable Ptr (GHashTable CString (Ptr ()))
dict'''''
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()


-- function emoji_dict_lookup
-- XXX Could not generate function emoji_dict_lookup

-- Not implemented: GHashTable element of type TInterface (Name {namespace = "IBus", name = "EmojiData"}) unsupported.

-- function emoji_dict_load
-- Args: [ Arg
--           { argCName = "path"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "A path of the saved dictionary file."
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TGHash (TBasicType TUTF8) (TBasicType TPtr))
-- throws : False
-- Skip return : False

foreign import ccall "ibus_emoji_dict_load" ibus_emoji_dict_load :: 
    CString ->                              -- path : TBasicType TUTF8
    IO (Ptr (GHashTable CString (Ptr ())))

-- | /No description available in the introspection data./
emojiDictLoad ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    -- ^ /@path@/: A path of the saved dictionary file.
    -> m (Map.Map T.Text (Ptr ()))
    -- ^ __Returns:__ An Emoji dictionary
    -- file loaded from the saved cache file.
    -- 
    -- A hash table of { emoji character, t'GI.IBus.Objects.EmojiData.EmojiData' object } is loaded
    -- from the saved cache file.
    -- Recommend to use 'GI.IBus.Objects.EmojiData.emojiDataLoad' instead becase GSList in
    -- GHashTable does not work with Gir and Vala.
    -- Calls 'GI.IBus.Objects.EmojiData.emojiDataLoad' internally.
emojiDictLoad :: Text -> m (Map Text (Ptr ()))
emojiDictLoad Text
path = IO (Map Text (Ptr ())) -> m (Map Text (Ptr ()))
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Map Text (Ptr ())) -> m (Map Text (Ptr ())))
-> IO (Map Text (Ptr ())) -> m (Map Text (Ptr ()))
forall a b. (a -> b) -> a -> b
$ do
    CString
path' <- Text -> IO CString
textToCString Text
path
    Ptr (GHashTable CString (Ptr ()))
result <- CString -> IO (Ptr (GHashTable CString (Ptr ())))
ibus_emoji_dict_load CString
path'
    Text -> Ptr (GHashTable CString (Ptr ())) -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"emojiDictLoad" Ptr (GHashTable CString (Ptr ()))
result
    [(PtrWrapped CString, PtrWrapped (Ptr ()))]
result' <- Ptr (GHashTable CString (Ptr ()))
-> IO [(PtrWrapped CString, PtrWrapped (Ptr ()))]
forall a b.
Ptr (GHashTable a b) -> IO [(PtrWrapped a, PtrWrapped b)]
unpackGHashTable Ptr (GHashTable CString (Ptr ()))
result
    let result'' :: [(CString, PtrWrapped (Ptr ()))]
result'' = (PtrWrapped CString -> CString)
-> [(PtrWrapped CString, PtrWrapped (Ptr ()))]
-> [(CString, PtrWrapped (Ptr ()))]
forall a c b. (a -> c) -> [(a, b)] -> [(c, b)]
mapFirst PtrWrapped CString -> CString
cstringUnpackPtr [(PtrWrapped CString, PtrWrapped (Ptr ()))]
result'
    [(Text, PtrWrapped (Ptr ()))]
result''' <- (CString -> IO Text)
-> [(CString, PtrWrapped (Ptr ()))]
-> IO [(Text, PtrWrapped (Ptr ()))]
forall (f :: * -> *) a c b.
Applicative f =>
(a -> f c) -> [(a, b)] -> f [(c, b)]
mapFirstA HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText [(CString, PtrWrapped (Ptr ()))]
result''
    let result'''' :: [(Text, Ptr ())]
result'''' = (PtrWrapped (Ptr ()) -> Ptr ())
-> [(Text, PtrWrapped (Ptr ()))] -> [(Text, Ptr ())]
forall b c a. (b -> c) -> [(a, b)] -> [(a, c)]
mapSecond PtrWrapped (Ptr ()) -> Ptr ()
forall a. PtrWrapped (Ptr a) -> Ptr a
ptrUnpackPtr [(Text, PtrWrapped (Ptr ()))]
result'''
    let result''''' :: Map Text (Ptr ())
result''''' = [(Text, Ptr ())] -> Map Text (Ptr ())
forall k a. Ord k => [(k, a)] -> Map k a
Map.fromList [(Text, Ptr ())]
result''''
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
path'
    Map Text (Ptr ()) -> IO (Map Text (Ptr ()))
forall (m :: * -> *) a. Monad m => a -> m a
return Map Text (Ptr ())
result'''''


-- function attr_foreground_new
-- Args: [ Arg
--           { argCName = "color"
--           , argType = TBasicType TUInt
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "Color in RGB." , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "start_index"
--           , argType = TBasicType TUInt
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "Where attribute starts."
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "end_index"
--           , argType = TBasicType TUInt
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "Where attribute ends."
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TInterface Name { namespace = "IBus" , name = "Attribute" })
-- throws : False
-- Skip return : False

foreign import ccall "ibus_attr_foreground_new" ibus_attr_foreground_new :: 
    Word32 ->                               -- color : TBasicType TUInt
    Word32 ->                               -- start_index : TBasicType TUInt
    Word32 ->                               -- end_index : TBasicType TUInt
    IO (Ptr IBus.Attribute.Attribute)

-- | Creates a new foreground t'GI.IBus.Objects.Attribute.Attribute'.
attrForegroundNew ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Word32
    -- ^ /@color@/: Color in RGB.
    -> Word32
    -- ^ /@startIndex@/: Where attribute starts.
    -> Word32
    -- ^ /@endIndex@/: Where attribute ends.
    -> m IBus.Attribute.Attribute
    -- ^ __Returns:__ A newly allocated t'GI.IBus.Objects.Attribute.Attribute'.
attrForegroundNew :: Word32 -> Word32 -> Word32 -> m Attribute
attrForegroundNew Word32
color Word32
startIndex Word32
endIndex = IO Attribute -> m Attribute
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Attribute -> m Attribute) -> IO Attribute -> m Attribute
forall a b. (a -> b) -> a -> b
$ do
    Ptr Attribute
result <- Word32 -> Word32 -> Word32 -> IO (Ptr Attribute)
ibus_attr_foreground_new Word32
color Word32
startIndex Word32
endIndex
    Text -> Ptr Attribute -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"attrForegroundNew" Ptr Attribute
result
    Attribute
result' <- ((ManagedPtr Attribute -> Attribute)
-> Ptr Attribute -> IO Attribute
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
newObject ManagedPtr Attribute -> Attribute
IBus.Attribute.Attribute) Ptr Attribute
result
    Attribute -> IO Attribute
forall (m :: * -> *) a. Monad m => a -> m a
return Attribute
result'


-- function attr_background_new
-- Args: [ Arg
--           { argCName = "color"
--           , argType = TBasicType TUInt
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "Color in RGB." , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "start_index"
--           , argType = TBasicType TUInt
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "Where attribute starts."
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "end_index"
--           , argType = TBasicType TUInt
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "Where attribute ends."
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TInterface Name { namespace = "IBus" , name = "Attribute" })
-- throws : False
-- Skip return : False

foreign import ccall "ibus_attr_background_new" ibus_attr_background_new :: 
    Word32 ->                               -- color : TBasicType TUInt
    Word32 ->                               -- start_index : TBasicType TUInt
    Word32 ->                               -- end_index : TBasicType TUInt
    IO (Ptr IBus.Attribute.Attribute)

-- | Creates a new background t'GI.IBus.Objects.Attribute.Attribute'.
attrBackgroundNew ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Word32
    -- ^ /@color@/: Color in RGB.
    -> Word32
    -- ^ /@startIndex@/: Where attribute starts.
    -> Word32
    -- ^ /@endIndex@/: Where attribute ends.
    -> m IBus.Attribute.Attribute
    -- ^ __Returns:__ A newly allocated t'GI.IBus.Objects.Attribute.Attribute'.
attrBackgroundNew :: Word32 -> Word32 -> Word32 -> m Attribute
attrBackgroundNew Word32
color Word32
startIndex Word32
endIndex = IO Attribute -> m Attribute
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Attribute -> m Attribute) -> IO Attribute -> m Attribute
forall a b. (a -> b) -> a -> b
$ do
    Ptr Attribute
result <- Word32 -> Word32 -> Word32 -> IO (Ptr Attribute)
ibus_attr_background_new Word32
color Word32
startIndex Word32
endIndex
    Text -> Ptr Attribute -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"attrBackgroundNew" Ptr Attribute
result
    Attribute
result' <- ((ManagedPtr Attribute -> Attribute)
-> Ptr Attribute -> IO Attribute
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
newObject ManagedPtr Attribute -> Attribute
IBus.Attribute.Attribute) Ptr Attribute
result
    Attribute -> IO Attribute
forall (m :: * -> *) a. Monad m => a -> m a
return Attribute
result'


-- function accelerator_valid
-- Args: [ Arg
--           { argCName = "keyval"
--           , argType = TBasicType TUInt
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a GDK keyval" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "modifiers"
--           , argType =
--               TInterface Name { namespace = "IBus" , name = "ModifierType" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "modifier mask" , 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 "ibus_accelerator_valid" ibus_accelerator_valid :: 
    Word32 ->                               -- keyval : TBasicType TUInt
    CUInt ->                                -- modifiers : TInterface (Name {namespace = "IBus", name = "ModifierType"})
    IO CInt

-- | Determines whether a given keyval and modifier mask constitute
-- a valid keyboard accelerator. For example, the 'GI.IBus.Constants.KEY_a' keyval
-- plus @/IBUS_CONTROL_MASK/@ is valid - this is a “Ctrl+a” accelerator.
-- But, you can\'t, for instance, use the 'GI.IBus.Constants.KEY_Control_L' keyval
-- as an accelerator.
acceleratorValid ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Word32
    -- ^ /@keyval@/: a GDK keyval
    -> [IBus.Flags.ModifierType]
    -- ^ /@modifiers@/: modifier mask
    -> m Bool
    -- ^ __Returns:__ 'P.True' if the accelerator is valid
acceleratorValid :: Word32 -> [ModifierType] -> m Bool
acceleratorValid Word32
keyval [ModifierType]
modifiers = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    let modifiers' :: CUInt
modifiers' = [ModifierType] -> CUInt
forall b a. (Num b, IsGFlag a) => [a] -> b
gflagsToWord [ModifierType]
modifiers
    CInt
result <- Word32 -> CUInt -> IO CInt
ibus_accelerator_valid Word32
keyval CUInt
modifiers'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'


-- function accelerator_parse
-- Args: [ Arg
--           { argCName = "accelerator"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "string representing an accelerator"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "accelerator_key"
--           , argType = TBasicType TUInt
--           , direction = DirectionOut
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "return location for accelerator\n    keyval, or %NULL"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferEverything
--           }
--       , Arg
--           { argCName = "accelerator_mods"
--           , argType =
--               TInterface Name { namespace = "IBus" , name = "ModifierType" }
--           , direction = DirectionOut
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "return location for accelerator\n    modifier mask, %NULL"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferEverything
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "ibus_accelerator_parse" ibus_accelerator_parse :: 
    CString ->                              -- accelerator : TBasicType TUTF8
    Ptr Word32 ->                           -- accelerator_key : TBasicType TUInt
    Ptr CUInt ->                            -- accelerator_mods : TInterface (Name {namespace = "IBus", name = "ModifierType"})
    IO ()

-- | Parses a string representing an accelerator. The format looks like
-- “\<Control>a” or “\<Shift>\<Alt>F1” or “\<Release>z” (the last one is
-- for key release).
-- 
-- The parser is fairly liberal and allows lower or upper case, and also
-- abbreviations such as “\<Ctl>” and “\<Ctrl>”. Key names are parsed using
-- @/gdk_keyval_from_name()/@. For character keys the name is not the symbol,
-- but the lowercase name, e.g. one would use “\<Ctrl>minus” instead of
-- “\<Ctrl>-”.
-- 
-- If the parse fails, /@acceleratorKey@/ and /@acceleratorMods@/ will
-- be set to 0 (zero).
-- 
-- /Since: 1.5.18/
acceleratorParse ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    -- ^ /@accelerator@/: string representing an accelerator
    -> m ((Word32, [IBus.Flags.ModifierType]))
acceleratorParse :: Text -> m (Word32, [ModifierType])
acceleratorParse Text
accelerator = IO (Word32, [ModifierType]) -> m (Word32, [ModifierType])
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Word32, [ModifierType]) -> m (Word32, [ModifierType]))
-> IO (Word32, [ModifierType]) -> m (Word32, [ModifierType])
forall a b. (a -> b) -> a -> b
$ do
    CString
accelerator' <- Text -> IO CString
textToCString Text
accelerator
    Ptr Word32
acceleratorKey <- IO (Ptr Word32)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr Word32)
    Ptr CUInt
acceleratorMods <- IO (Ptr CUInt)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr CUInt)
    CString -> Ptr Word32 -> Ptr CUInt -> IO ()
ibus_accelerator_parse CString
accelerator' Ptr Word32
acceleratorKey Ptr CUInt
acceleratorMods
    Word32
acceleratorKey' <- Ptr Word32 -> IO Word32
forall a. Storable a => Ptr a -> IO a
peek Ptr Word32
acceleratorKey
    CUInt
acceleratorMods' <- Ptr CUInt -> IO CUInt
forall a. Storable a => Ptr a -> IO a
peek Ptr CUInt
acceleratorMods
    let acceleratorMods'' :: [ModifierType]
acceleratorMods'' = CUInt -> [ModifierType]
forall a b. (Storable a, Integral a, Bits a, IsGFlag b) => a -> [b]
wordToGFlags CUInt
acceleratorMods'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
accelerator'
    Ptr Word32 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word32
acceleratorKey
    Ptr CUInt -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CUInt
acceleratorMods
    (Word32, [ModifierType]) -> IO (Word32, [ModifierType])
forall (m :: * -> *) a. Monad m => a -> m a
return (Word32
acceleratorKey', [ModifierType]
acceleratorMods'')


-- function accelerator_name
-- Args: [ Arg
--           { argCName = "accelerator_key"
--           , argType = TBasicType TUInt
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "accelerator keyval" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "accelerator_mods"
--           , argType =
--               TInterface Name { namespace = "IBus" , name = "ModifierType" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "accelerator modifier mask"
--                 , 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 "ibus_accelerator_name" ibus_accelerator_name :: 
    Word32 ->                               -- accelerator_key : TBasicType TUInt
    CUInt ->                                -- accelerator_mods : TInterface (Name {namespace = "IBus", name = "ModifierType"})
    IO CString

-- | Converts an accelerator keyval and modifier mask into a string
-- parseable by @/gtk_accelerator_parse()/@. For example, if you pass in
-- 'GI.IBus.Constants.KEY_q' and @/IBUS_CONTROL_MASK/@, this function returns “\<Control>q”.
-- 
-- If you need to display accelerators in the user interface,
-- see @/gtk_accelerator_get_label()/@.
acceleratorName ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Word32
    -- ^ /@acceleratorKey@/: accelerator keyval
    -> [IBus.Flags.ModifierType]
    -- ^ /@acceleratorMods@/: accelerator modifier mask
    -> m T.Text
    -- ^ __Returns:__ a newly-allocated accelerator name
acceleratorName :: Word32 -> [ModifierType] -> m Text
acceleratorName Word32
acceleratorKey [ModifierType]
acceleratorMods = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    let acceleratorMods' :: CUInt
acceleratorMods' = [ModifierType] -> CUInt
forall b a. (Num b, IsGFlag a) => [a] -> b
gflagsToWord [ModifierType]
acceleratorMods
    CString
result <- Word32 -> CUInt -> IO CString
ibus_accelerator_name Word32
acceleratorKey CUInt
acceleratorMods'
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"acceleratorName" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result
    Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result'