gi-gtk-0.3.18.13: GI/Gtk/Structs/TargetPair.hs
{- |
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 #GtkTargetPair is used to represent the same
information as a table of #GtkTargetEntry, but in
an efficient form.
-}
module GI.Gtk.Structs.TargetPair
(
-- * Exported types
TargetPair(..) ,
newZeroTargetPair ,
noTargetPair ,
-- * Properties
-- ** Flags
targetPairReadFlags ,
-- ** Info
targetPairReadInfo ,
-- ** Target
targetPairReadTarget ,
) 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.Gdk as Gdk
newtype TargetPair = TargetPair (ForeignPtr TargetPair)
-- | Construct a `TargetPair` struct initialized to zero.
newZeroTargetPair :: MonadIO m => m TargetPair
newZeroTargetPair = liftIO $ callocBytes 16 >>= wrapPtr TargetPair
noTargetPair :: Maybe TargetPair
noTargetPair = Nothing
targetPairReadTarget :: TargetPair -> IO Gdk.Atom
targetPairReadTarget s = withManagedPtr s $ \ptr -> do
val <- peek (ptr `plusPtr` 0) :: IO (Ptr Gdk.Atom)
-- XXX Wrapping a foreign struct/union with no known destructor, leak?
val' <- (\x -> Gdk.Atom <$> newForeignPtr_ x) val
return val'
targetPairReadFlags :: TargetPair -> IO Word32
targetPairReadFlags s = withManagedPtr s $ \ptr -> do
val <- peek (ptr `plusPtr` 8) :: IO Word32
return val
targetPairReadInfo :: TargetPair -> IO Word32
targetPairReadInfo s = withManagedPtr s $ \ptr -> do
val <- peek (ptr `plusPtr` 12) :: IO Word32
return val
type family ResolveTargetPairMethod (t :: Symbol) (o :: *) :: * where
ResolveTargetPairMethod l o = MethodResolutionFailed l o
instance (info ~ ResolveTargetPairMethod t TargetPair, MethodInfo info TargetPair p) => IsLabelProxy t (TargetPair -> p) where
fromLabelProxy _ = overloadedMethod (MethodProxy :: MethodProxy info)
#if MIN_VERSION_base(4,9,0)
instance (info ~ ResolveTargetPairMethod t TargetPair, MethodInfo info TargetPair p) => IsLabel t (TargetPair -> p) where
fromLabel _ = overloadedMethod (MethodProxy :: MethodProxy info)
#endif