{-# LANGUAGE ScopedTypeVariables #-}
{-# LINE 2 "./Graphics/UI/Gtk/Misc/IMContextSimple.chs" #-}
module Graphics.UI.Gtk.Misc.IMContextSimple (
IMContextSimple,
IMContextSimpleClass,
castToIMContextSimple,
toIMContextSimple,
imContextSimpleNew,
imContextSimpleAddTable,
) where
import Control.Monad (liftM)
import Data.Map (Map)
import System.Glib.FFI
import System.Glib.UTFString
import Graphics.UI.Gtk.Types
{-# LINE 58 "./Graphics/UI/Gtk/Misc/IMContextSimple.chs" #-}
{-# LINE 60 "./Graphics/UI/Gtk/Misc/IMContextSimple.chs" #-}
import qualified Data.Map as M
imContextSimpleNew :: IO IMContextSimple
imContextSimpleNew :: IO IMContextSimple
imContextSimpleNew =
(ForeignPtr IMContextSimple -> IMContextSimple,
FinalizerPtr IMContextSimple)
-> IO (Ptr IMContextSimple) -> IO IMContextSimple
forall obj.
GObjectClass obj =>
(ForeignPtr obj -> obj, FinalizerPtr obj) -> IO (Ptr obj) -> IO obj
wrapNewGObject (ForeignPtr IMContextSimple -> IMContextSimple,
FinalizerPtr IMContextSimple)
forall {a}.
(ForeignPtr IMContextSimple -> IMContextSimple, FinalizerPtr a)
mkIMContextSimple (IO (Ptr IMContextSimple) -> IO IMContextSimple)
-> IO (Ptr IMContextSimple) -> IO IMContextSimple
forall a b. (a -> b) -> a -> b
$
(Ptr IMContext -> Ptr IMContextSimple)
-> IO (Ptr IMContext) -> IO (Ptr IMContextSimple)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM Ptr IMContext -> Ptr IMContextSimple
forall a b. Ptr a -> Ptr b
castPtr IO (Ptr IMContext)
gtk_im_context_simple_new
{-# LINE 72 "./Graphics/UI/Gtk/Misc/IMContextSimple.chs" #-}
imContextSimpleAddTable :: (IMContextSimpleClass self, GlibString string) => self
-> Map string string
-> Int
-> Int
-> IO ()
imContextSimpleAddTable :: forall self string.
(IMContextSimpleClass self, GlibString string) =>
self -> Map string string -> Int -> Int -> IO ()
imContextSimpleAddTable self
self Map string string
table Int
maxSeqLen Int
nSeqs = do
[(CString, CString)]
tableList <- ((string, string) -> IO (CString, CString))
-> [(string, string)] -> IO [(CString, CString)]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM (\(string
x,string
y) -> do
CString
nx <- string -> IO CString
forall s. GlibString s => s -> IO CString
newUTFString string
x
CString
ny <- string -> IO CString
forall s. GlibString s => s -> IO CString
newUTFString string
y
(CString, CString) -> IO (CString, CString)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (CString
nx, CString
ny)) (Map string string -> [(string, string)]
forall k a. Map k a -> [(k, a)]
M.toList Map string string
table)
[CString] -> (Ptr CString -> IO ()) -> IO ()
forall a b. Storable a => [a] -> (Ptr a -> IO b) -> IO b
withArray (((CString, CString) -> [CString])
-> [(CString, CString)] -> [CString]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (\(CString
x,CString
y) -> [CString
x, CString
y]) [(CString, CString)]
tableList) ((Ptr CString -> IO ()) -> IO ())
-> (Ptr CString -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \(Ptr CString
tablePtr :: Ptr CString) ->
(\(IMContextSimple ForeignPtr IMContextSimple
arg1) Ptr CUShort
arg2 CInt
arg3 CInt
arg4 -> ForeignPtr IMContextSimple
-> (Ptr IMContextSimple -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr IMContextSimple
arg1 ((Ptr IMContextSimple -> IO ()) -> IO ())
-> (Ptr IMContextSimple -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr IMContextSimple
argPtr1 ->Ptr IMContextSimple -> Ptr CUShort -> CInt -> CInt -> IO ()
gtk_im_context_simple_add_table Ptr IMContextSimple
argPtr1 Ptr CUShort
arg2 CInt
arg3 CInt
arg4)
{-# LINE 96 "./Graphics/UI/Gtk/Misc/IMContextSimple.chs" #-}
(self -> IMContextSimple
forall o. IMContextSimpleClass o => o -> IMContextSimple
toIMContextSimple self
self)
(Ptr CString -> Ptr CUShort
forall a b. Ptr a -> Ptr b
castPtr Ptr CString
tablePtr)
(Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
maxSeqLen)
(Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
nSeqs)
foreign import ccall safe "gtk_im_context_simple_new"
gtk_im_context_simple_new :: (IO (Ptr IMContext))
foreign import ccall safe "gtk_im_context_simple_add_table"
gtk_im_context_simple_add_table :: ((Ptr IMContextSimple) -> ((Ptr CUShort) -> (CInt -> (CInt -> (IO ())))))