{-# LINE 1 "./Graphics/UI/Gtk/General/DNDTypes.chs" #-}
{-# OPTIONS_HADDOCK hide #-}
module Graphics.UI.Gtk.General.DNDTypes (
InfoId,
TargetTag,
SelectionTag,
SelectionTypeTag,
PropertyTag,
Atom(Atom),
TargetList(TargetList),
SelectionData,
SelectionDataM,
atomNew,
targetListNew,
mkTargetList
) where
import System.Glib.FFI
import System.Glib.UTFString
import Graphics.UI.Gtk.Types ()
import Control.Monad ( liftM )
import Control.Monad.Reader ( ReaderT )
{-# LINE 52 "./Graphics/UI/Gtk/General/DNDTypes.chs" #-}
type InfoId = (CUInt)
{-# LINE 56 "./Graphics/UI/Gtk/General/DNDTypes.chs" #-}
type SelectionTag = Atom
type TargetTag = Atom
type SelectionTypeTag = Atom
type PropertyTag = Atom
newtype Atom = Atom (Ptr ()) deriving Atom -> Atom -> Bool
(Atom -> Atom -> Bool) -> (Atom -> Atom -> Bool) -> Eq Atom
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Atom -> Atom -> Bool
== :: Atom -> Atom -> Bool
$c/= :: Atom -> Atom -> Bool
/= :: Atom -> Atom -> Bool
Eq
instance Show Atom where
show :: Atom -> String
show (Atom Ptr ()
ptr) = DefaultGlibString -> String
forall a. Show a => a -> String
show (Ptr () -> DefaultGlibString
forall {a}. GlibString a => Ptr () -> a
atomToString Ptr ()
ptr :: DefaultGlibString)
atomToString :: Ptr () -> a
atomToString Ptr ()
ptr = IO a -> a
forall a. IO a -> a
unsafePerformIO (IO a -> a) -> IO a -> a
forall a b. (a -> b) -> a -> b
$ do
Ptr CChar
strPtr <- Ptr () -> IO (Ptr CChar)
gdk_atom_name Ptr ()
ptr
Ptr CChar -> IO a
forall s. GlibString s => Ptr CChar -> IO s
readUTFString Ptr CChar
strPtr
newtype TargetList = TargetList (ForeignPtr (TargetList))
{-# LINE 102 "./Graphics/UI/Gtk/General/DNDTypes.chs" #-}
atomNew :: GlibString string => string -> IO Atom
atomNew :: forall string. GlibString string => string -> IO Atom
atomNew string
name = string -> (Ptr CChar -> IO Atom) -> IO Atom
forall a. string -> (Ptr CChar -> IO a) -> IO a
forall s a. GlibString s => s -> (Ptr CChar -> IO a) -> IO a
withUTFString string
name ((Ptr CChar -> IO Atom) -> IO Atom)
-> (Ptr CChar -> IO Atom) -> IO Atom
forall a b. (a -> b) -> a -> b
$ \Ptr CChar
strPtr ->
(Ptr () -> Atom) -> IO (Ptr ()) -> IO Atom
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM Ptr () -> Atom
Atom (IO (Ptr ()) -> IO Atom) -> IO (Ptr ()) -> IO Atom
forall a b. (a -> b) -> a -> b
$ Ptr CChar -> CInt -> IO (Ptr ())
gdk_atom_intern Ptr CChar
strPtr CInt
0
targetListNew :: IO TargetList
targetListNew :: IO TargetList
targetListNew = do
Ptr TargetList
tlPtr <- Ptr () -> CUInt -> IO (Ptr TargetList)
gtk_target_list_new Ptr ()
forall a. Ptr a
nullPtr CUInt
0
(ForeignPtr TargetList -> TargetList)
-> IO (ForeignPtr TargetList) -> IO TargetList
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM ForeignPtr TargetList -> TargetList
TargetList (IO (ForeignPtr TargetList) -> IO TargetList)
-> IO (ForeignPtr TargetList) -> IO TargetList
forall a b. (a -> b) -> a -> b
$ Ptr TargetList
-> FinalizerPtr TargetList -> IO (ForeignPtr TargetList)
forall a. Ptr a -> FinalizerPtr a -> IO (ForeignPtr a)
newForeignPtr Ptr TargetList
tlPtr FinalizerPtr TargetList
target_list_unref
foreign import ccall unsafe ">k_target_list_unref"
target_list_unref :: FinalizerPtr TargetList
mkTargetList :: Ptr TargetList -> IO TargetList
mkTargetList :: Ptr TargetList -> IO TargetList
mkTargetList Ptr TargetList
tlPtr = do
TargetList
tl <- (ForeignPtr TargetList -> TargetList)
-> IO (ForeignPtr TargetList) -> IO TargetList
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM ForeignPtr TargetList -> TargetList
TargetList (IO (ForeignPtr TargetList) -> IO TargetList)
-> IO (ForeignPtr TargetList) -> IO TargetList
forall a b. (a -> b) -> a -> b
$ Ptr TargetList
-> FinalizerPtr TargetList -> IO (ForeignPtr TargetList)
forall a. Ptr a -> FinalizerPtr a -> IO (ForeignPtr a)
newForeignPtr Ptr TargetList
tlPtr FinalizerPtr TargetList
target_list_unref
(\(TargetList ForeignPtr TargetList
arg1) -> ForeignPtr TargetList
-> (Ptr TargetList -> IO (Ptr TargetList)) -> IO (Ptr TargetList)
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr TargetList
arg1 ((Ptr TargetList -> IO (Ptr TargetList)) -> IO (Ptr TargetList))
-> (Ptr TargetList -> IO (Ptr TargetList)) -> IO (Ptr TargetList)
forall a b. (a -> b) -> a -> b
$ \Ptr TargetList
argPtr1 ->Ptr TargetList -> IO (Ptr TargetList)
gtk_target_list_ref Ptr TargetList
argPtr1) TargetList
tl
TargetList -> IO TargetList
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return TargetList
tl
type SelectionData = Ptr (())
{-# LINE 136 "./Graphics/UI/Gtk/General/DNDTypes.chs" #-}
type SelectionDataM a = ReaderT (Ptr ()) IO a
foreign import ccall unsafe "gdk_atom_name"
gdk_atom_name :: ((Ptr ()) -> (IO (Ptr CChar)))
foreign import ccall unsafe "gdk_atom_intern"
gdk_atom_intern :: ((Ptr CChar) -> (CInt -> (IO (Ptr ()))))
foreign import ccall unsafe "gtk_target_list_new"
gtk_target_list_new :: ((Ptr ()) -> (CUInt -> (IO (Ptr TargetList))))
foreign import ccall unsafe "gtk_target_list_ref"
gtk_target_list_ref :: ((Ptr TargetList) -> (IO (Ptr TargetList)))