{-# LANGUAGE TypeApplications #-}
#if (MIN_VERSION_haskell_gi_overloading(1,0,0) && !defined(__HADDOCK_VERSION__))
#define ENABLE_OVERLOADING
#endif
module GI.IBus.Objects.Keymap
(
Keymap(..) ,
IsKeymap ,
toKeymap ,
#if defined(ENABLE_OVERLOADING)
ResolveKeymapMethod ,
#endif
keymapGet ,
#if defined(ENABLE_OVERLOADING)
KeymapLookupKeysymMethodInfo ,
#endif
keymapLookupKeysym ,
keymapNew ,
) 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.GArray as B.GArray
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 qualified GHC.Records as R
import qualified GI.GObject.Objects.Object as GObject.Object
import {-# SOURCE #-} qualified GI.IBus.Objects.Object as IBus.Object
newtype Keymap = Keymap (SP.ManagedPtr Keymap)
deriving (Keymap -> Keymap -> Bool
(Keymap -> Keymap -> Bool)
-> (Keymap -> Keymap -> Bool) -> Eq Keymap
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Keymap -> Keymap -> Bool
$c/= :: Keymap -> Keymap -> Bool
== :: Keymap -> Keymap -> Bool
$c== :: Keymap -> Keymap -> Bool
Eq)
instance SP.ManagedPtrNewtype Keymap where
toManagedPtr :: Keymap -> ManagedPtr Keymap
toManagedPtr (Keymap ManagedPtr Keymap
p) = ManagedPtr Keymap
p
foreign import ccall "ibus_keymap_get_type"
c_ibus_keymap_get_type :: IO B.Types.GType
instance B.Types.TypedObject Keymap where
glibType :: IO GType
glibType = IO GType
c_ibus_keymap_get_type
instance B.Types.GObject Keymap
class (SP.GObject o, O.IsDescendantOf Keymap o) => IsKeymap o
instance (SP.GObject o, O.IsDescendantOf Keymap o) => IsKeymap o
instance O.HasParentTypes Keymap
type instance O.ParentTypes Keymap = '[IBus.Object.Object, GObject.Object.Object]
toKeymap :: (MIO.MonadIO m, IsKeymap o) => o -> m Keymap
toKeymap :: forall (m :: * -> *) o. (MonadIO m, IsKeymap o) => o -> m Keymap
toKeymap = IO Keymap -> m Keymap
forall (m :: * -> *) a. MonadIO m => IO a -> m a
MIO.liftIO (IO Keymap -> m Keymap) -> (o -> IO Keymap) -> o -> m Keymap
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ManagedPtr Keymap -> Keymap) -> o -> IO Keymap
forall o o'.
(HasCallStack, ManagedPtrNewtype o, TypedObject o,
ManagedPtrNewtype o', TypedObject o') =>
(ManagedPtr o' -> o') -> o -> IO o'
B.ManagedPtr.unsafeCastTo ManagedPtr Keymap -> Keymap
Keymap
instance B.GValue.IsGValue (Maybe Keymap) where
gvalueGType_ :: IO GType
gvalueGType_ = IO GType
c_ibus_keymap_get_type
gvalueSet_ :: Ptr GValue -> Maybe Keymap -> IO ()
gvalueSet_ Ptr GValue
gv Maybe Keymap
P.Nothing = Ptr GValue -> Ptr Keymap -> IO ()
forall a. GObject a => Ptr GValue -> Ptr a -> IO ()
B.GValue.set_object Ptr GValue
gv (Ptr Keymap
forall a. Ptr a
FP.nullPtr :: FP.Ptr Keymap)
gvalueSet_ Ptr GValue
gv (P.Just Keymap
obj) = Keymap -> (Ptr Keymap -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
B.ManagedPtr.withManagedPtr Keymap
obj (Ptr GValue -> Ptr Keymap -> IO ()
forall a. GObject a => Ptr GValue -> Ptr a -> IO ()
B.GValue.set_object Ptr GValue
gv)
gvalueGet_ :: Ptr GValue -> IO (Maybe Keymap)
gvalueGet_ Ptr GValue
gv = do
Ptr Keymap
ptr <- Ptr GValue -> IO (Ptr Keymap)
forall a. GObject a => Ptr GValue -> IO (Ptr a)
B.GValue.get_object Ptr GValue
gv :: IO (FP.Ptr Keymap)
if Ptr Keymap
ptr Ptr Keymap -> Ptr Keymap -> Bool
forall a. Eq a => a -> a -> Bool
/= Ptr Keymap
forall a. Ptr a
FP.nullPtr
then Keymap -> Maybe Keymap
forall a. a -> Maybe a
P.Just (Keymap -> Maybe Keymap) -> IO Keymap -> IO (Maybe Keymap)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (ManagedPtr Keymap -> Keymap) -> Ptr Keymap -> IO Keymap
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
B.ManagedPtr.newObject ManagedPtr Keymap -> Keymap
Keymap Ptr Keymap
ptr
else Maybe Keymap -> IO (Maybe Keymap)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe Keymap
forall a. Maybe a
P.Nothing
#if defined(ENABLE_OVERLOADING)
type family ResolveKeymapMethod (t :: Symbol) (o :: *) :: * where
ResolveKeymapMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
ResolveKeymapMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
ResolveKeymapMethod "destroy" o = IBus.Object.ObjectDestroyMethodInfo
ResolveKeymapMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
ResolveKeymapMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
ResolveKeymapMethod "getv" o = GObject.Object.ObjectGetvMethodInfo
ResolveKeymapMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
ResolveKeymapMethod "lookupKeysym" o = KeymapLookupKeysymMethodInfo
ResolveKeymapMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
ResolveKeymapMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
ResolveKeymapMethod "ref" o = GObject.Object.ObjectRefMethodInfo
ResolveKeymapMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
ResolveKeymapMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
ResolveKeymapMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
ResolveKeymapMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
ResolveKeymapMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
ResolveKeymapMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
ResolveKeymapMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
ResolveKeymapMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
ResolveKeymapMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
ResolveKeymapMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
ResolveKeymapMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
ResolveKeymapMethod "setDataFull" o = GObject.Object.ObjectSetDataFullMethodInfo
ResolveKeymapMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
ResolveKeymapMethod l o = O.MethodResolutionFailed l o
instance (info ~ ResolveKeymapMethod t Keymap, O.OverloadedMethod info Keymap p) => OL.IsLabel t (Keymap -> p) where
#if MIN_VERSION_base(4,10,0)
fromLabel = O.overloadedMethod @info
#else
fromLabel _ = O.overloadedMethod @info
#endif
#if MIN_VERSION_base(4,13,0)
instance (info ~ ResolveKeymapMethod t Keymap, O.OverloadedMethod info Keymap p, R.HasField t Keymap p) => R.HasField t Keymap p where
getField = O.overloadedMethod @info
#endif
instance (info ~ ResolveKeymapMethod t Keymap, O.OverloadedMethodInfo info Keymap) => OL.IsLabel t (O.MethodProxy info Keymap) where
#if MIN_VERSION_base(4,10,0)
fromLabel = O.MethodProxy
#else
fromLabel _ = O.MethodProxy
#endif
#endif
#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList Keymap
type instance O.AttributeList Keymap = KeymapAttributeList
type KeymapAttributeList = ('[ ] :: [(Symbol, *)])
#endif
#if defined(ENABLE_OVERLOADING)
#endif
#if defined(ENABLE_OVERLOADING)
type instance O.SignalList Keymap = KeymapSignalList
type KeymapSignalList = ('[ '("destroy", IBus.Object.ObjectDestroySignalInfo), '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, *)])
#endif
foreign import ccall "ibus_keymap_new" ibus_keymap_new ::
CString ->
IO (Ptr Keymap)
{-# DEPRECATED keymapNew ["This function has been deprecated and should","not be used in newly written code. Please use 'GI.IBus.Objects.Keymap.keymapGet'."] #-}
keymapNew ::
(B.CallStack.HasCallStack, MonadIO m) =>
T.Text
-> m Keymap
keymapNew :: forall (m :: * -> *). (HasCallStack, MonadIO m) => Text -> m Keymap
keymapNew Text
name = IO Keymap -> m Keymap
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Keymap -> m Keymap) -> IO Keymap -> m Keymap
forall a b. (a -> b) -> a -> b
$ do
CString
name' <- Text -> IO CString
textToCString Text
name
Ptr Keymap
result <- CString -> IO (Ptr Keymap)
ibus_keymap_new CString
name'
Text -> Ptr Keymap -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"keymapNew" Ptr Keymap
result
Keymap
result' <- ((ManagedPtr Keymap -> Keymap) -> Ptr Keymap -> IO Keymap
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
newObject ManagedPtr Keymap -> Keymap
Keymap) Ptr Keymap
result
CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
name'
Keymap -> IO Keymap
forall (m :: * -> *) a. Monad m => a -> m a
return Keymap
result'
#if defined(ENABLE_OVERLOADING)
#endif
foreign import ccall "ibus_keymap_lookup_keysym" ibus_keymap_lookup_keysym ::
Ptr Keymap ->
Word16 ->
Word32 ->
IO Word32
keymapLookupKeysym ::
(B.CallStack.HasCallStack, MonadIO m, IsKeymap a) =>
a
-> Word16
-> Word32
-> m Word32
keymapLookupKeysym :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsKeymap a) =>
a -> Word16 -> Word32 -> m Word32
keymapLookupKeysym a
keymap Word16
keycode Word32
state = 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
Ptr Keymap
keymap' <- a -> IO (Ptr Keymap)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
keymap
Word32
result <- Ptr Keymap -> Word16 -> Word32 -> IO Word32
ibus_keymap_lookup_keysym Ptr Keymap
keymap' Word16
keycode Word32
state
a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
keymap
Word32 -> IO Word32
forall (m :: * -> *) a. Monad m => a -> m a
return Word32
result
#if defined(ENABLE_OVERLOADING)
data KeymapLookupKeysymMethodInfo
instance (signature ~ (Word16 -> Word32 -> m Word32), MonadIO m, IsKeymap a) => O.OverloadedMethod KeymapLookupKeysymMethodInfo a signature where
overloadedMethod = keymapLookupKeysym
instance O.OverloadedMethodInfo KeymapLookupKeysymMethodInfo a where
overloadedMethodInfo = O.MethodInfo {
O.overloadedMethodName = "GI.IBus.Objects.Keymap.keymapLookupKeysym",
O.overloadedMethodURL = "https://hackage.haskell.org/package/gi-ibus-1.5.3/docs/GI-IBus-Objects-Keymap.html#v:keymapLookupKeysym"
}
#endif
foreign import ccall "ibus_keymap_get" ibus_keymap_get ::
CString ->
IO (Ptr Keymap)
keymapGet ::
(B.CallStack.HasCallStack, MonadIO m) =>
T.Text
-> m Keymap
keymapGet :: forall (m :: * -> *). (HasCallStack, MonadIO m) => Text -> m Keymap
keymapGet Text
name = IO Keymap -> m Keymap
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Keymap -> m Keymap) -> IO Keymap -> m Keymap
forall a b. (a -> b) -> a -> b
$ do
CString
name' <- Text -> IO CString
textToCString Text
name
Ptr Keymap
result <- CString -> IO (Ptr Keymap)
ibus_keymap_get CString
name'
Text -> Ptr Keymap -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"keymapGet" Ptr Keymap
result
Keymap
result' <- ((ManagedPtr Keymap -> Keymap) -> Ptr Keymap -> IO Keymap
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
wrapObject ManagedPtr Keymap -> Keymap
Keymap) Ptr Keymap
result
CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
name'
Keymap -> IO Keymap
forall (m :: * -> *) a. Monad m => a -> m a
return Keymap
result'
#if defined(ENABLE_OVERLOADING)
#endif