{- | Copyright : Will Thompson, Iñaki García Etxebarria and Jonas Platte License : LGPL-2.1 Maintainer : Iñaki García Etxebarria (garetxe@gmail.com) A binding set maintains a list of activatable key bindings. A single binding set can match multiple types of widgets. Similar to style contexts, can be matched by any information contained in a widgets #GtkWidgetPath. When a binding within a set is matched upon activation, an action signal is emitted on the target widget to carry out the actual activation. -} module GI.Gtk.Structs.BindingSet ( -- * Exported types BindingSet(..) , noBindingSet , -- * Methods -- ** bindingSetActivate bindingSetActivate , -- ** bindingSetAddPath bindingSetAddPath , -- * Properties -- ** ClassBranchPspecs bindingSetReadClassBranchPspecs , -- ** Current bindingSetReadCurrent , -- ** Entries bindingSetReadEntries , -- ** Parsed bindingSetReadParsed , -- ** Priority bindingSetReadPriority , -- ** SetName bindingSetReadSetName , -- ** WidgetClassPspecs bindingSetReadWidgetClassPspecs , -- ** WidgetPathPspecs bindingSetReadWidgetPathPspecs , ) where import Prelude () import Data.GI.Base.ShortPrelude import qualified Data.Text as T import qualified Data.ByteString.Char8 as B import qualified Data.Map as Map import GI.Gtk.Types import GI.Gtk.Callbacks import qualified GI.GObject as GObject import qualified GI.Gdk as Gdk newtype BindingSet = BindingSet (ForeignPtr BindingSet) noBindingSet :: Maybe BindingSet noBindingSet = Nothing bindingSetReadSetName :: BindingSet -> IO T.Text bindingSetReadSetName s = withManagedPtr s $ \ptr -> do val <- peek (ptr `plusPtr` 0) :: IO CString val' <- cstringToText val return val' bindingSetReadPriority :: BindingSet -> IO Int32 bindingSetReadPriority s = withManagedPtr s $ \ptr -> do val <- peek (ptr `plusPtr` 8) :: IO Int32 return val bindingSetReadWidgetPathPspecs :: BindingSet -> IO ([Ptr ()]) bindingSetReadWidgetPathPspecs s = withManagedPtr s $ \ptr -> do val <- peek (ptr `plusPtr` 16) :: IO (Ptr (GSList (Ptr ()))) val' <- unpackGSList val return val' bindingSetReadWidgetClassPspecs :: BindingSet -> IO ([Ptr ()]) bindingSetReadWidgetClassPspecs s = withManagedPtr s $ \ptr -> do val <- peek (ptr `plusPtr` 24) :: IO (Ptr (GSList (Ptr ()))) val' <- unpackGSList val return val' bindingSetReadClassBranchPspecs :: BindingSet -> IO ([Ptr ()]) bindingSetReadClassBranchPspecs s = withManagedPtr s $ \ptr -> do val <- peek (ptr `plusPtr` 32) :: IO (Ptr (GSList (Ptr ()))) val' <- unpackGSList val return val' bindingSetReadEntries :: BindingSet -> IO BindingEntry bindingSetReadEntries s = withManagedPtr s $ \ptr -> do val <- peek (ptr `plusPtr` 40) :: IO (Ptr BindingEntry) val' <- (newPtr 56 BindingEntry) val return val' bindingSetReadCurrent :: BindingSet -> IO BindingEntry bindingSetReadCurrent s = withManagedPtr s $ \ptr -> do val <- peek (ptr `plusPtr` 48) :: IO (Ptr BindingEntry) val' <- (newPtr 56 BindingEntry) val return val' bindingSetReadParsed :: BindingSet -> IO Word32 bindingSetReadParsed s = withManagedPtr s $ \ptr -> do val <- peek (ptr `plusPtr` 56) :: IO Word32 return val -- method BindingSet::activate -- method type : OrdinaryMethod -- Args : [Arg {argName = "_obj", argType = TInterface "Gtk" "BindingSet", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "keyval", argType = TBasicType TUInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "modifiers", argType = TInterface "Gdk" "ModifierType", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "object", argType = TInterface "GObject" "Object", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- Lengths : [] -- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gtk" "BindingSet", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "keyval", argType = TBasicType TUInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "modifiers", argType = TInterface "Gdk" "ModifierType", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "object", argType = TInterface "GObject" "Object", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- returnType : TBasicType TBoolean -- throws : False -- Skip return : False foreign import ccall "gtk_binding_set_activate" gtk_binding_set_activate :: Ptr BindingSet -> -- _obj : TInterface "Gtk" "BindingSet" Word32 -> -- keyval : TBasicType TUInt32 CUInt -> -- modifiers : TInterface "Gdk" "ModifierType" Ptr GObject.Object -> -- object : TInterface "GObject" "Object" IO CInt bindingSetActivate :: (MonadIO m, GObject.ObjectK a) => BindingSet -> -- _obj Word32 -> -- keyval [Gdk.ModifierType] -> -- modifiers a -> -- object m Bool bindingSetActivate _obj keyval modifiers object = liftIO $ do let _obj' = unsafeManagedPtrGetPtr _obj let modifiers' = gflagsToWord modifiers let object' = unsafeManagedPtrCastPtr object result <- gtk_binding_set_activate _obj' keyval modifiers' object' let result' = (/= 0) result touchManagedPtr _obj touchManagedPtr object return result' -- method BindingSet::add_path -- method type : OrdinaryMethod -- Args : [Arg {argName = "_obj", argType = TInterface "Gtk" "BindingSet", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "path_type", argType = TInterface "Gtk" "PathType", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "path_pattern", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "priority", argType = TInterface "Gtk" "PathPriorityType", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- Lengths : [] -- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gtk" "BindingSet", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "path_type", argType = TInterface "Gtk" "PathType", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "path_pattern", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "priority", argType = TInterface "Gtk" "PathPriorityType", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- returnType : TBasicType TVoid -- throws : False -- Skip return : False foreign import ccall "gtk_binding_set_add_path" gtk_binding_set_add_path :: Ptr BindingSet -> -- _obj : TInterface "Gtk" "BindingSet" CUInt -> -- path_type : TInterface "Gtk" "PathType" CString -> -- path_pattern : TBasicType TUTF8 CUInt -> -- priority : TInterface "Gtk" "PathPriorityType" IO () {-# DEPRECATED bindingSetAddPath ["(Since version 3.0)"]#-} bindingSetAddPath :: (MonadIO m) => BindingSet -> -- _obj PathType -> -- path_type T.Text -> -- path_pattern PathPriorityType -> -- priority m () bindingSetAddPath _obj path_type path_pattern priority = liftIO $ do let _obj' = unsafeManagedPtrGetPtr _obj let path_type' = (fromIntegral . fromEnum) path_type path_pattern' <- textToCString path_pattern let priority' = (fromIntegral . fromEnum) priority gtk_binding_set_add_path _obj' path_type' path_pattern' priority' touchManagedPtr _obj freeMem path_pattern' return ()