    -- GENERATED by C->Haskell Compiler, version 0.13.13 (gtk2hs branch) "Bin IO", 27 May 2012 (Haskell)
    -- Edit the ORIGINAL .chs file instead!

    {-# LINE 1 "./Graphics/UI/Gtk/General/DNDTypes.chs" #-}
    {-# OPTIONS_HADDOCK hide #-}
    -- -*-haskell-*-
    --  GIMP Toolkit (GTK) Type declarations for DND and Selections
    --
    --  Author : Axel Simon
    --
    --  Created: 11 April 2007
    --
    --  Copyright (C) 2007 Axel Simon
    --
    --  This library is free software; you can redistribute it and/or
    --  modify it under the terms of the GNU Lesser General Public
    --  License as published by the Free Software Foundation; either
    --  version 2.1 of the License, or (at your option) any later version.
    --
    --  This library is distributed in the hope that it will be useful,
    --  but WITHOUT ANY WARRANTY; without even the implied warranty of
    --  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    --  Lesser General Public License for more details.
    --
    -- functions that seem to be internal: gtk_selection_convert
    -- functions that relate to target tables are not bound since they seem
    -- superfluous
    --
    -- Type declarations for Selections that are used for DND and Clipboards.
    -- #hide
    module Graphics.UI.Gtk.General.DNDTypes (

    -- * Types
      InfoId,
      TargetTag,
      SelectionTag,
      SelectionTypeTag,
      PropertyTag,
      Atom(Atom),
      TargetList(TargetList),
      SelectionData,
      SelectionDataM,

    -- * Constructors
      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" #-}

    -- | A number that the application can use to differentiate between different
    --   data types or application states.
    type InfoId = (CUInt)
    {-# LINE 56 "./Graphics/UI/Gtk/General/DNDTypes.chs" #-}

    -- | A tag that uniquely identifies a selection. A selection denotes the
    -- exchange mechanism that is being used, for instance, the clipboard is the
    -- most common exchange mechanism. For drag and drop applications, a new
    -- selection tag is usually created for each different kind of data that is
    -- being exchanged.
    type SelectionTag = Atom

    -- | A tag that uniquely identifies a target. A target describes the format of
    -- the underlying data source, for instance, it might be a string. A single
    -- selection may support multiple targets: suppose a new target is created for
    -- the Haskell data type 'Double'. In this case, the value of the floating
    -- point number could also be offered as a string.
    type TargetTag = Atom

    -- | A tag that defines the encoding of the binary data. For instance, a
    -- string might be encoded as UTF-8 or in a different locale. Each encoding
    -- would use the same 'TargetTag' but a different 'SelectionTypeTag'.
    type SelectionTypeTag = Atom

    -- | A tag
    -- that uniquely identifies a property of a
    -- 'Graphics.UI.Gtk.Gdk.DrawWindow.DrawWindow'.
    --
    type PropertyTag = Atom

    -- | An atom is an index into a global string table. It is possible to
    -- associate binary data with each entry. This facility is used for
    -- inter-application data exchange such as properties of
    -- 'Graphics.UI.Gtk.Gdk.DrawWindow.DrawWindow' (using 'PropertyTag'),
    -- 'Graphics.UI.Gtk.Clipboard.Clipboard' or 'Graphics.UI.Gtk.General.Drag'
    -- ('SelectionId' and 'TargetId').
    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
            strPtr <- Ptr () -> IO (Ptr CChar)
    gdk_atom_name Ptr ()
    ptr
            readUTFString strPtr

    -- | A 'TargetList' contains information about all possible formats
    -- (represented as 'TargetTag') that a widget can create or receive in form of
    -- a selection.
    --
    newtype TargetList = TargetList (ForeignPtr (TargetList))
    {-# LINE 102 "./Graphics/UI/Gtk/General/DNDTypes.chs" #-}

    --------------------
    -- Constructors

    -- | Create a new 'TargetTag', 'SelectionTag', 'SelectionTypeTag' or
    --   'PropertyTag'. Note that creating two target tags with the same name will
    --   create the same tag, in particular, the tag will be the same across
    --   different applications. Note that the name of an 'Atom' can be printed
    --   by 'show' though comparing the atom is merely an integer comparison.
    --
    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

    -- | Create a new, empty 'TargetList'.
    --
    targetListNew :: IO TargetList
    targetListNew :: IO TargetList
    targetListNew = do
      tlPtr <- Ptr () -> CUInt -> IO (Ptr TargetList)
    gtk_target_list_new Ptr ()
    forall a. Ptr a
    nullPtr CUInt
    0
      liftM TargetList $ newForeignPtr tlPtr target_list_unref

    foreign import ccall unsafe "&gtk_target_list_unref"
      target_list_unref :: FinalizerPtr TargetList

    -- Wrap a 'TargetList' pointer.
    mkTargetList :: Ptr TargetList -> IO TargetList
    mkTargetList :: Ptr TargetList -> IO TargetList
    mkTargetList Ptr TargetList
    tlPtr = do
      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) tl
      return tl

    -- | A pointer to selection data.
    type SelectionData = Ptr (())
    {-# LINE 136 "./Graphics/UI/Gtk/General/DNDTypes.chs" #-}

    -- | A monad providing access to selection data.
    --
    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)))