packages feed

gi-gtk-0.3.18.13: GI/Gtk/Structs/TargetEntry.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 #GtkTargetEntry represents a single type of
data than can be supplied for by a widget for a selection
or for supplied or received during drag-and-drop.
-}

module GI.Gtk.Structs.TargetEntry
    ( 

-- * Exported types
    TargetEntry(..)                         ,
    newZeroTargetEntry                      ,
    noTargetEntry                           ,


 -- * Methods
-- ** targetEntryCopy
    TargetEntryCopyMethodInfo               ,
    targetEntryCopy                         ,


-- ** targetEntryFree
    TargetEntryFreeMethodInfo               ,
    targetEntryFree                         ,


-- ** targetEntryNew
    targetEntryNew                          ,




 -- * Properties
-- ** Flags
    targetEntryReadFlags                    ,


-- ** Info
    targetEntryReadInfo                     ,


-- ** Target
    targetEntryReadTarget                   ,




    ) 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

newtype TargetEntry = TargetEntry (ForeignPtr TargetEntry)
foreign import ccall "gtk_target_entry_get_type" c_gtk_target_entry_get_type :: 
    IO GType

instance BoxedObject TargetEntry where
    boxedType _ = c_gtk_target_entry_get_type

-- | Construct a `TargetEntry` struct initialized to zero.
newZeroTargetEntry :: MonadIO m => m TargetEntry
newZeroTargetEntry = liftIO $ callocBoxedBytes 16 >>= wrapBoxed TargetEntry

noTargetEntry :: Maybe TargetEntry
noTargetEntry = Nothing

targetEntryReadTarget :: TargetEntry -> IO T.Text
targetEntryReadTarget s = withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 0) :: IO CString
    val' <- cstringToText val
    return val'

targetEntryReadFlags :: TargetEntry -> IO Word32
targetEntryReadFlags s = withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 8) :: IO Word32
    return val

targetEntryReadInfo :: TargetEntry -> IO Word32
targetEntryReadInfo s = withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 12) :: IO Word32
    return val

-- method TargetEntry::new
-- method type : Constructor
-- Args : [Arg {argCName = "target", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "flags", argType = TBasicType TUInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "info", argType = TBasicType TUInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : TInterface "Gtk" "TargetEntry"
-- throws : False
-- Skip return : False

foreign import ccall "gtk_target_entry_new" gtk_target_entry_new :: 
    CString ->                              -- target : TBasicType TUTF8
    Word32 ->                               -- flags : TBasicType TUInt32
    Word32 ->                               -- info : TBasicType TUInt32
    IO (Ptr TargetEntry)


targetEntryNew ::
    (MonadIO m) =>
    T.Text                                  -- target
    -> Word32                               -- flags
    -> Word32                               -- info
    -> m TargetEntry                        -- result
targetEntryNew target flags info = liftIO $ do
    target' <- textToCString target
    result <- gtk_target_entry_new target' flags info
    checkUnexpectedReturnNULL "gtk_target_entry_new" result
    result' <- (wrapBoxed TargetEntry) result
    freeMem target'
    return result'

-- method TargetEntry::copy
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "_obj", argType = TInterface "Gtk" "TargetEntry", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : TInterface "Gtk" "TargetEntry"
-- throws : False
-- Skip return : False

foreign import ccall "gtk_target_entry_copy" gtk_target_entry_copy :: 
    Ptr TargetEntry ->                      -- _obj : TInterface "Gtk" "TargetEntry"
    IO (Ptr TargetEntry)


targetEntryCopy ::
    (MonadIO m) =>
    TargetEntry                             -- _obj
    -> m TargetEntry                        -- result
targetEntryCopy _obj = liftIO $ do
    let _obj' = unsafeManagedPtrGetPtr _obj
    result <- gtk_target_entry_copy _obj'
    checkUnexpectedReturnNULL "gtk_target_entry_copy" result
    result' <- (wrapBoxed TargetEntry) result
    touchManagedPtr _obj
    return result'

data TargetEntryCopyMethodInfo
instance (signature ~ (m TargetEntry), MonadIO m) => MethodInfo TargetEntryCopyMethodInfo TargetEntry signature where
    overloadedMethod _ = targetEntryCopy

-- method TargetEntry::free
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "_obj", argType = TInterface "Gtk" "TargetEntry", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False

foreign import ccall "gtk_target_entry_free" gtk_target_entry_free :: 
    Ptr TargetEntry ->                      -- _obj : TInterface "Gtk" "TargetEntry"
    IO ()


targetEntryFree ::
    (MonadIO m) =>
    TargetEntry                             -- _obj
    -> m ()                                 -- result
targetEntryFree _obj = liftIO $ do
    let _obj' = unsafeManagedPtrGetPtr _obj
    gtk_target_entry_free _obj'
    touchManagedPtr _obj
    return ()

data TargetEntryFreeMethodInfo
instance (signature ~ (m ()), MonadIO m) => MethodInfo TargetEntryFreeMethodInfo TargetEntry signature where
    overloadedMethod _ = targetEntryFree

type family ResolveTargetEntryMethod (t :: Symbol) (o :: *) :: * where
    ResolveTargetEntryMethod "copy" o = TargetEntryCopyMethodInfo
    ResolveTargetEntryMethod "free" o = TargetEntryFreeMethodInfo
    ResolveTargetEntryMethod l o = MethodResolutionFailed l o

instance (info ~ ResolveTargetEntryMethod t TargetEntry, MethodInfo info TargetEntry p) => IsLabelProxy t (TargetEntry -> p) where
    fromLabelProxy _ = overloadedMethod (MethodProxy :: MethodProxy info)

#if MIN_VERSION_base(4,9,0)
instance (info ~ ResolveTargetEntryMethod t TargetEntry, MethodInfo info TargetEntry p) => IsLabel t (TargetEntry -> p) where
    fromLabel _ = overloadedMethod (MethodProxy :: MethodProxy info)
#endif