fixed problem with c2hs not finding chi file

{-# LANGUAGE ForeignFunctionInterface #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE ExistentialQuantification #-}
{-# LANGUAGE StandaloneDeriving #-}

module GDAL.Internal.Warper (
    ResampleAlg (..)
  , WarpOptions (..)
  , GDALWarpException (..)
  , reprojectImage
  , setTransformer
  , autoCreateWarpedVRT
  , createWarpedVRT
  , def
) where

import Control.Applicative ((<$>), (<*>))
import Control.Monad (when, void)
import Control.Monad.IO.Class (liftIO)
import Control.DeepSeq (NFData(rnf))
import Control.Exception (Exception(..), bracket)
import Data.Maybe (isJust)
import Data.Typeable (Typeable)
import Data.Default (Default(..))
import Foreign.C.String (CString)
import Foreign.C.Types (CDouble(..), CInt(..), CChar(..))
import Foreign.Ptr (Ptr, FunPtr, nullPtr, castPtr, castFunPtr, nullFunPtr)
import Foreign.Marshal.Alloc (alloca, malloc, free)
import Foreign.Marshal.Array (mallocArray)
import Foreign.Storable (Storable(..))

import GDAL.Internal.Types
import GDAL.Internal.Util (fromEnumC)
import GDAL.Internal.Algorithms
{#import GDAL.Internal.CPLError #}
{#import GDAL.Internal.CPLString #}
{#import GDAL.Internal.CPLProgress #}
{#import GDAL.Internal.OSR #}
{#import GDAL.Internal.GDAL #}

#include "gdal.h"
#include "gdalwarper.h"

data GDALWarpException
  = WarpStopped
  deriving (Typeable, Show, Eq)

instance NFData GDALWarpException where
  rnf a = a `seq` ()

instance Exception GDALWarpException where
  toException   = bindingExceptionToException
  fromException = bindingExceptionFromException

{# enum GDALResampleAlg as ResampleAlg {upcaseFirstLetter}
     deriving (Eq,Read,Show) #}

data WarpOptions s a b
  = forall t. (Transformer t, Show (t s a b), GDALType a, GDALType b)
  => WarpOptions {
      woResampleAlg     :: ResampleAlg
    , woWarpOptions     :: OptionList
    , woMemoryLimit     :: Double
    , woWorkingDatatype :: Datatype
    , woBands           :: [(Int,Int)]
    , woTransfomer      :: Maybe (t s a b)
    , woSrcNodata       :: Maybe a
    , woDstNodata       :: Maybe b
    , woProgressFun     :: Maybe ProgressFun
    }

deriving instance Show (WarpOptions s a b)

instance (GDALType a, GDALType b) => Default (WarpOptions s a b) where
  def = WarpOptions {
          woResampleAlg     = GRA_NearestNeighbour
        , woWarpOptions     = []
        , woMemoryLimit     = 0
        , woWorkingDatatype = GDT_Unknown
        , woBands           = []
        , woTransfomer      = Just (def :: GenImgProjTransformer s a b)
        , woSrcNodata       = Nothing
        , woDstNodata       = Nothing
        , woProgressFun     = Nothing
        }

-- Avoids "Record update for insufficiently polymorphic field" when doigs
-- opts { woTransfomer = Just ...}
setTransformer
  :: forall t s a b. (Transformer t, Show (t s a b), GDALType a, GDALType b)
  => WarpOptions s a b -> t s a b -> WarpOptions s a b
setTransformer opts t = WarpOptions {
    woResampleAlg     = woResampleAlg opts
  , woWarpOptions     = woWarpOptions opts
  , woMemoryLimit     = woMemoryLimit opts
  , woWorkingDatatype = woWorkingDatatype opts
  , woBands           = woBands opts
  , woTransfomer      = Just t
  , woSrcNodata       = woSrcNodata opts
  , woDstNodata       = woDstNodata opts
  , woProgressFun     = woProgressFun opts
  }

withWarpOptionsPtr
  :: (GDALType a, GDALType b)
  => Ptr (RODataset s a) -> Maybe (WarpOptions s a b)
  -> (Ptr (WarpOptions s a b) -> IO c) -> IO c
withWarpOptionsPtr _ Nothing f = f nullPtr
withWarpOptionsPtr dsPtr (Just wo) f = do
  ret <- withProgressFun (woProgressFun wo) $ \pFun -> do
           (p, finalizer) <- mkWarpOptionsPtr dsPtr wo
           {#set GDALWarpOptions.pfnProgress #} p pFun
           bracket (return p) (const finalizer) f
  maybe (throwBindingException WarpStopped) return ret

mkWarpOptionsPtr
  :: (GDALType a, GDALType b)
  => Ptr (RODataset s a) -> WarpOptions s a b
  -> IO (Ptr (WarpOptions s a b), IO ())
mkWarpOptionsPtr dsPtr WarpOptions{..} = do
  p <- createWarpOptions
  return (p, destroyWarpOptions p)
  where
    createWarpOptions = do
      p <- c_createWarpOptions
      {#set GDALWarpOptions.eResampleAlg #} p (fromEnumC woResampleAlg)
      oListPtr <- toOptionListPtr woWarpOptions
      {#set GDALWarpOptions.papszWarpOptions #} p oListPtr
      {#set GDALWarpOptions.dfWarpMemoryLimit #} p (realToFrac woMemoryLimit)
      {#set GDALWarpOptions.eWorkingDataType #} p (fromEnumC woWorkingDatatype)
      {#set GDALWarpOptions.nBandCount #} p (fromIntegral (length woBands))
      {#set GDALWarpOptions.panSrcBands #} p =<< intListToPtr (map fst woBands)
      {#set GDALWarpOptions.panDstBands #} p =<< intListToPtr (map snd woBands)
      case woTransfomer of
        Just t -> do
          {#set GDALWarpOptions.pfnTransformer #} p
            (castFunPtr (transformerFunc t))
          tArg <- fmap castPtr (createTransformer dsPtr t)
          {#set GDALWarpOptions.pTransformerArg #} p tArg
        Nothing -> do
          {#set GDALWarpOptions.pfnTransformer #} p nullFunPtr
          {#set GDALWarpOptions.pTransformerArg #} p nullPtr
      case woDstNodata of
        Just v -> do
          vPtr <- malloc
          poke vPtr (toNodata v)
          {#set GDALWarpOptions.padfDstNoDataReal #} p vPtr
          {#set GDALWarpOptions.padfDstNoDataImag #} p vPtr
        Nothing -> return ()
      case woSrcNodata of
        Just v -> do
          vPtr <- malloc
          poke vPtr (toNodata v)
          {#set GDALWarpOptions.padfSrcNoDataReal #} p vPtr
          {#set GDALWarpOptions.padfSrcNoDataImag #} p vPtr
        Nothing -> return ()
      return p

    destroyWarpOptions p = do
      case woTransfomer of
        Just (_ :: t s a b) -> do
          t <- {#get GDALWarpOptions.pTransformerArg #} p
          destroyTransformer (castPtr t :: Ptr (t s a b))
        Nothing -> return ()
      when (isJust woSrcNodata) $
        ({#get GDALWarpOptions.padfSrcNoDataReal #} p >>= free)
      when (isJust woDstNodata) $
        ({#get GDALWarpOptions.padfDstNoDataReal #} p >>= free)
      c_destroyWarpOptions p

    intListToPtr [] = return nullPtr
    intListToPtr l = do
      ptr <- mallocArray (length l)
      mapM_ (\(i,v) -> pokeElemOff ptr i (fromIntegral v)) (zip [0..] l)
      return ptr

foreign import ccall unsafe "gdalwarper.h GDALCreateWarpOptions"
  c_createWarpOptions :: IO (Ptr (WarpOptions s a b))

foreign import ccall unsafe "gdalwarper.h GDALDestroyWarpOptions"
  c_destroyWarpOptions :: Ptr (WarpOptions s a b) -> IO ()

reprojectImage
  :: (GDALType a, GDALType b)
  => RODataset s a
  -> RWDataset s b
  -> Maybe (WarpOptions s a b)
  -> GDAL s ()
reprojectImage srcDs dstDs opts =
  liftIO $ void $ throwIfError "reprojectImage" $
    withLockedDatasetPtr srcDs $ \srcPtr ->
    withLockedDatasetPtr dstDs $ \dstPtr ->
    withWarpOptionsPtr srcPtr opts $
      c_reprojectImage srcPtr nullPtr dstPtr nullPtr 0 0 0 nullFunPtr nullPtr

foreign import ccall safe "gdalwarper.h GDALReprojectImage" c_reprojectImage
  :: Ptr (Dataset s t a)     -- ^Source dataset
  -> CString                 -- ^Source proj (WKT)
  -> Ptr (RWDataset s b)     -- ^Dest dataset
  -> CString                 -- ^Dest proj (WKT)
  -> CInt                    -- ^Resample alg
  -> CDouble                 -- ^Memory limit
  -> CDouble                 -- ^Max error
  -> ProgressFunPtr          -- ^Progress func
  -> Ptr ()                  -- ^Progress arg (unused)
  -> Ptr (WarpOptions s a b) -- ^warp options
  -> IO CInt

autoCreateWarpedVRT
  :: (GDALType a, GDALType b)
  => RODataset s a
  -> Maybe SpatialReference
  -> WarpOptions s a b
  -> GDAL s (RODataset s b)
autoCreateWarpedVRT ds dstSrs options = do
  (opts, finalizeOpts) <- liftIO (mkWarpOptionsPtr dsPtr options)
  registerFinalizer finalizeOpts
  newDsPtr <- liftIO $ withMaybeSRAsCString dstSrs $ \srs ->
    c_autoCreateWarpedVRT dsPtr nullPtr srs 0 0 opts
  newDerivedDatasetHandle ds newDsPtr
  where dsPtr = unDataset ds

foreign import ccall safe "gdalwarper.h GDALAutoCreateWarpedVRT" c_autoCreateWarpedVRT
  :: Ptr (RODataset s a)     -- ^Source dataset
  -> CString                 -- ^Source proj (WKT)
  -> CString                 -- ^Dest proj (WKT)
  -> CInt                    -- ^Resample alg
  -> CDouble                 -- ^Max error
  -> Ptr (WarpOptions s a b) -- ^warp options
  -> IO (Ptr (RODataset s b))

createWarpedVRT
  :: (GDALType a, GDALType b)
  => RODataset s a
  -> Int
  -> Int
  -> Geotransform
  -> WarpOptions s a b
  -> GDAL s (RODataset s b)
createWarpedVRT srcDs nPixels nLines geotransform options = do
  let dsPtr      = unDataset srcDs
      nBands     = datasetBandCount srcDs
      options'
        | null (woBands options)
        = options { woBands = map (\i -> (i,i)) [1..nBands]}
        | otherwise
        = options
  (opts,finalizeOpts) <- liftIO (mkWarpOptionsPtr dsPtr options')
  registerFinalizer finalizeOpts
  newDsPtr <- liftIO $ alloca $ \gt -> do
    poke (castPtr gt) geotransform
    {#set GDALWarpOptions.hSrcDS #} opts (castPtr dsPtr)
    pArg <- {#get GDALWarpOptions.pTransformerArg #} opts
    when (pArg /= nullPtr) $
      {#call GDALSetGenImgProjTransformerDstGeoTransform as ^#} pArg gt
    c_createWarpedVRT dsPtr (fromIntegral nPixels) (fromIntegral nLines) gt opts
  newDerivedDatasetHandle srcDs newDsPtr

foreign import ccall safe "gdalwarper.h GDALCreateWarpedVRT" c_createWarpedVRT
  :: Ptr (RODataset s a)     -- ^Source dataset
  -> CInt                    -- ^nPixels
  -> CInt                    -- ^nLines
  -> Ptr CDouble             -- ^geotransform
  -> Ptr (WarpOptions s a b) -- ^warp options
  -> IO (Ptr (RODataset s b))

{-# LANGUAGE ForeignFunctionInterface #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE ExistentialQuantification #-}
{-# LANGUAGE StandaloneDeriving #-}

module GDAL.Internal.Warper (
    ResampleAlg (..)
  , WarpOptions (..)
  , GDALWarpException (..)
  , reprojectImage
  , setTransformer
  , autoCreateWarpedVRT
  , createWarpedVRT
  , def
) where

import Control.Applicative ((<$>), (<*>))
import Control.Monad (when, void)
import Control.Monad.IO.Class (liftIO)
import Control.DeepSeq (NFData(rnf))
import Control.Exception (Exception(..), bracket)
import Data.Maybe (isJust)
import Data.Typeable (Typeable)
import Data.Default (Default(..))
import Foreign.C.String (CString)
import Foreign.C.Types (CDouble(..), CInt(..), CChar(..))
import Foreign.Ptr (Ptr, FunPtr, nullPtr, castPtr, castFunPtr, nullFunPtr)
import Foreign.Marshal.Alloc (alloca, malloc, free)
import Foreign.Marshal.Array (mallocArray)
import Foreign.Storable (Storable(..))

import GDAL.Internal.Types
import GDAL.Internal.Util (fromEnumC)
{#import GDAL.Internal.Algorithms #}
{#import GDAL.Internal.CPLError #}
{#import GDAL.Internal.CPLString #}
{#import GDAL.Internal.CPLProgress #}
{#import GDAL.Internal.OSR #}
{#import GDAL.Internal.GDAL #}

#include "gdal.h"
#include "gdalwarper.h"

data GDALWarpException
  = WarpStopped
  deriving (Typeable, Show, Eq)

instance NFData GDALWarpException where
  rnf a = a `seq` ()

instance Exception GDALWarpException where
  toException   = bindingExceptionToException
  fromException = bindingExceptionFromException

{# enum GDALResampleAlg as ResampleAlg {upcaseFirstLetter}
     deriving (Eq,Read,Show) #}

data WarpOptions s a b
  = forall t. (Transformer t, Show (t s a b), GDALType a, GDALType b)
  => WarpOptions {
      woResampleAlg     :: ResampleAlg
    , woWarpOptions     :: OptionList
    , woMemoryLimit     :: Double
    , woWorkingDatatype :: Datatype
    , woBands           :: [(Int,Int)]
    , woTransfomer      :: Maybe (t s a b)
    , woSrcNodata       :: Maybe a
    , woDstNodata       :: Maybe b
    , woProgressFun     :: Maybe ProgressFun
    }

deriving instance Show (WarpOptions s a b)

instance (GDALType a, GDALType b) => Default (WarpOptions s a b) where
  def = WarpOptions {
          woResampleAlg     = GRA_NearestNeighbour
        , woWarpOptions     = []
        , woMemoryLimit     = 0
        , woWorkingDatatype = GDT_Unknown
        , woBands           = []
        , woTransfomer      = Just (def :: GenImgProjTransformer s a b)
        , woSrcNodata       = Nothing
        , woDstNodata       = Nothing
        , woProgressFun     = Nothing
        }

-- Avoids "Record update for insufficiently polymorphic field" when doigs
-- opts { woTransfomer = Just ...}
setTransformer
  :: forall t s a b. (Transformer t, Show (t s a b), GDALType a, GDALType b)
  => WarpOptions s a b -> t s a b -> WarpOptions s a b
setTransformer opts t = WarpOptions {
    woResampleAlg     = woResampleAlg opts
  , woWarpOptions     = woWarpOptions opts
  , woMemoryLimit     = woMemoryLimit opts
  , woWorkingDatatype = woWorkingDatatype opts
  , woBands           = woBands opts
  , woTransfomer      = Just t
  , woSrcNodata       = woSrcNodata opts
  , woDstNodata       = woDstNodata opts
  , woProgressFun     = woProgressFun opts
  }

withWarpOptionsPtr
  :: (GDALType a, GDALType b)
  => Ptr (RODataset s a) -> Maybe (WarpOptions s a b)
  -> (Ptr (WarpOptions s a b) -> IO c) -> IO c
withWarpOptionsPtr _ Nothing f = f nullPtr
withWarpOptionsPtr dsPtr (Just wo) f = do
  ret <- withProgressFun (woProgressFun wo) $ \pFun -> do
           (p, finalizer) <- mkWarpOptionsPtr dsPtr wo
           {#set GDALWarpOptions.pfnProgress #} p pFun
           bracket (return p) (const finalizer) f
  maybe (throwBindingException WarpStopped) return ret

mkWarpOptionsPtr
  :: (GDALType a, GDALType b)
  => Ptr (RODataset s a) -> WarpOptions s a b
  -> IO (Ptr (WarpOptions s a b), IO ())
mkWarpOptionsPtr dsPtr WarpOptions{..} = do
  p <- createWarpOptions
  return (p, destroyWarpOptions p)
  where
    createWarpOptions = do
      p <- c_createWarpOptions
      {#set GDALWarpOptions.eResampleAlg #} p (fromEnumC woResampleAlg)
      oListPtr <- toOptionListPtr woWarpOptions
      {#set GDALWarpOptions.papszWarpOptions #} p oListPtr
      {#set GDALWarpOptions.dfWarpMemoryLimit #} p (realToFrac woMemoryLimit)
      {#set GDALWarpOptions.eWorkingDataType #} p (fromEnumC woWorkingDatatype)
      {#set GDALWarpOptions.nBandCount #} p (fromIntegral (length woBands))
      {#set GDALWarpOptions.panSrcBands #} p =<< intListToPtr (map fst woBands)
      {#set GDALWarpOptions.panDstBands #} p =<< intListToPtr (map snd woBands)
      case woTransfomer of
        Just t -> do
          {#set GDALWarpOptions.pfnTransformer #} p
            (castFunPtr (transformerFunc t))
          tArg <- fmap castPtr (createTransformer dsPtr t)
          {#set GDALWarpOptions.pTransformerArg #} p tArg
        Nothing -> do
          {#set GDALWarpOptions.pfnTransformer #} p nullFunPtr
          {#set GDALWarpOptions.pTransformerArg #} p nullPtr
      case woDstNodata of
        Just v -> do
          vPtr <- malloc
          poke vPtr (toNodata v)
          {#set GDALWarpOptions.padfDstNoDataReal #} p vPtr
          {#set GDALWarpOptions.padfDstNoDataImag #} p vPtr
        Nothing -> return ()
      case woSrcNodata of
        Just v -> do
          vPtr <- malloc
          poke vPtr (toNodata v)
          {#set GDALWarpOptions.padfSrcNoDataReal #} p vPtr
          {#set GDALWarpOptions.padfSrcNoDataImag #} p vPtr
        Nothing -> return ()
      return p

    destroyWarpOptions p = do
      case woTransfomer of
        Just (_ :: t s a b) -> do
          t <- {#get GDALWarpOptions.pTransformerArg #} p
          destroyTransformer (castPtr t :: Ptr (t s a b))
        Nothing -> return ()
      when (isJust woSrcNodata) $
        ({#get GDALWarpOptions.padfSrcNoDataReal #} p >>= free)
      when (isJust woDstNodata) $
        ({#get GDALWarpOptions.padfDstNoDataReal #} p >>= free)
      c_destroyWarpOptions p

    intListToPtr [] = return nullPtr
    intListToPtr l = do
      ptr <- mallocArray (length l)
      mapM_ (\(i,v) -> pokeElemOff ptr i (fromIntegral v)) (zip [0..] l)
      return ptr

foreign import ccall unsafe "gdalwarper.h GDALCreateWarpOptions"
  c_createWarpOptions :: IO (Ptr (WarpOptions s a b))

foreign import ccall unsafe "gdalwarper.h GDALDestroyWarpOptions"
  c_destroyWarpOptions :: Ptr (WarpOptions s a b) -> IO ()

reprojectImage
  :: (GDALType a, GDALType b)
  => RODataset s a
  -> RWDataset s b
  -> Maybe (WarpOptions s a b)
  -> GDAL s ()
reprojectImage srcDs dstDs opts =
  liftIO $ void $ throwIfError "reprojectImage" $
    withLockedDatasetPtr srcDs $ \srcPtr ->
    withLockedDatasetPtr dstDs $ \dstPtr ->
    withWarpOptionsPtr srcPtr opts $
      c_reprojectImage srcPtr nullPtr dstPtr nullPtr 0 0 0 nullFunPtr nullPtr

foreign import ccall safe "gdalwarper.h GDALReprojectImage" c_reprojectImage
  :: Ptr (Dataset s t a)     -- ^Source dataset
  -> CString                 -- ^Source proj (WKT)
  -> Ptr (RWDataset s b)     -- ^Dest dataset
  -> CString                 -- ^Dest proj (WKT)
  -> CInt                    -- ^Resample alg
  -> CDouble                 -- ^Memory limit
  -> CDouble                 -- ^Max error
  -> ProgressFunPtr          -- ^Progress func
  -> Ptr ()                  -- ^Progress arg (unused)
  -> Ptr (WarpOptions s a b) -- ^warp options
  -> IO CInt

autoCreateWarpedVRT
  :: (GDALType a, GDALType b)
  => RODataset s a
  -> Maybe SpatialReference
  -> WarpOptions s a b
  -> GDAL s (RODataset s b)
autoCreateWarpedVRT ds dstSrs options = do
  (opts, finalizeOpts) <- liftIO (mkWarpOptionsPtr dsPtr options)
  registerFinalizer finalizeOpts
  newDsPtr <- liftIO $ withMaybeSRAsCString dstSrs $ \srs ->
    c_autoCreateWarpedVRT dsPtr nullPtr srs 0 0 opts
  newDerivedDatasetHandle ds newDsPtr
  where dsPtr = unDataset ds

foreign import ccall safe "gdalwarper.h GDALAutoCreateWarpedVRT" c_autoCreateWarpedVRT
  :: Ptr (RODataset s a)     -- ^Source dataset
  -> CString                 -- ^Source proj (WKT)
  -> CString                 -- ^Dest proj (WKT)
  -> CInt                    -- ^Resample alg
  -> CDouble                 -- ^Max error
  -> Ptr (WarpOptions s a b) -- ^warp options
  -> IO (Ptr (RODataset s b))

createWarpedVRT
  :: (GDALType a, GDALType b)
  => RODataset s a
  -> Int
  -> Int
  -> Geotransform
  -> WarpOptions s a b
  -> GDAL s (RODataset s b)
createWarpedVRT srcDs nPixels nLines geotransform options = do
  let dsPtr      = unDataset srcDs
      nBands     = datasetBandCount srcDs
      options'
        | null (woBands options)
        = options { woBands = map (\i -> (i,i)) [1..nBands]}
        | otherwise
        = options
  (opts,finalizeOpts) <- liftIO (mkWarpOptionsPtr dsPtr options')
  registerFinalizer finalizeOpts
  newDsPtr <- liftIO $ alloca $ \gt -> do
    poke (castPtr gt) geotransform
    {#set GDALWarpOptions.hSrcDS #} opts (castPtr dsPtr)
    pArg <- {#get GDALWarpOptions.pTransformerArg #} opts
    when (pArg /= nullPtr) $
      {#call GDALSetGenImgProjTransformerDstGeoTransform as ^#} pArg gt
    c_createWarpedVRT dsPtr (fromIntegral nPixels) (fromIntegral nLines) gt opts
  newDerivedDatasetHandle srcDs newDsPtr

foreign import ccall safe "gdalwarper.h GDALCreateWarpedVRT" c_createWarpedVRT
  :: Ptr (RODataset s a)     -- ^Source dataset
  -> CInt                    -- ^nPixels
  -> CInt                    -- ^nLines
  -> Ptr CDouble             -- ^geotransform
  -> Ptr (WarpOptions s a b) -- ^warp options
  -> IO (Ptr (RODataset s b))


Fix GtkSourceView.chs Enums haddock docs.

{-# LANGUAGE CPP #-}
-- -*-haskell-*-
--  GIMP Toolkit (GTK) Widget SourceView
--
--  Author : Peter Gavin
--  derived from sourceview bindings by Axel Simon and Duncan Coutts
--
--  Created: 18 December 2008
--
--  Copyright (C) 2004-2008 Peter Gavin, Duncan Coutts, Axel Simon
--  Copyright (C) 2010 Andy Stewart
--
--  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.
--
-- |
-- Maintainer  : gtk2hs-users@lists.sourceforge.net
-- Stability   : provisional
-- Portability : portable (depends on GHC)
--
module Graphics.UI.Gtk.SourceView.SourceView (
-- * Types
  SourceView,
  SourceViewClass,

-- * Enums
  SourceSmartHomeEndType(..),
  SourceDrawSpacesFlags(..),

-- * Methods
  castToSourceView,
  sourceViewNew,
  sourceViewNewWithBuffer,
  sourceViewSetAutoIndent,
  sourceViewGetAutoIndent,
  sourceViewSetIndentOnTab,
  sourceViewGetIndentOnTab,
  sourceViewSetIndentWidth,
  sourceViewGetIndentWidth,
  sourceViewSetInsertSpacesInsteadOfTabs,
  sourceViewGetInsertSpacesInsteadOfTabs,
  sourceViewSetSmartHomeEnd,
  sourceViewGetSmartHomeEnd,
  sourceViewSetMarkCategoryPriority,
  sourceViewGetMarkCategoryPriority,
  sourceViewSetMarkCategoryIconFromPixbuf,
  sourceViewSetMarkCategoryIconFromStock,
  sourceViewSetMarkCategoryIconFromIconName,
  sourceViewSetMarkCategoryBackground,
  sourceViewGetMarkCategoryBackground,
  sourceViewSetHighlightCurrentLine,
  sourceViewGetHighlightCurrentLine,
  sourceViewSetShowLineMarks,
  sourceViewGetShowLineMarks,
  sourceViewSetShowLineNumbers,
  sourceViewGetShowLineNumbers,
  sourceViewSetShowRightMargin,
  sourceViewGetShowRightMargin,
  sourceViewSetRightMarginPosition,
  sourceViewGetRightMarginPosition,
  sourceViewSetTabWidth,
  sourceViewGetTabWidth,
  sourceViewSetDrawSpaces,
  sourceViewGetDrawSpaces,

-- * Attributes
  sourceViewAutoIndent,
  sourceViewDrawSpaces,
  sourceViewHighlightCurrentLine,
  sourceViewIndentOnTab,
  sourceViewIndentWidth,
  sourceViewInsertSpacesInsteadOfTabs,
  sourceViewRightMarginPosition,
  sourceViewShowLineNumbers,
  sourceViewShowRightMargin,
  sourceViewSmartHomeEnd,
  sourceViewTabWidth,

-- * Signals
  sourceViewUndo,
  sourceViewRedo,
  sourceViewMoveLines,
  sourceViewShowCompletion,

-- * Deprecated
#ifndef DISABLE_DEPRECATED
  sourceViewSetMarkCategoryPixbuf,
  sourceViewGetMarkCategoryPixbuf,
#endif
  ) where

import Control.Monad	(liftM)
import Data.Maybe    (fromMaybe)

import System.Glib.FFI
{#import System.Glib.Properties#}
import System.Glib.Attributes
import Graphics.UI.Gtk.Abstract.Object	(makeNewObject)
import Graphics.UI.Gtk.Abstract.Widget (Color)
{#import Graphics.UI.Gtk.SourceView.Types#}
{#import Graphics.UI.Gtk.SourceView.Signals#}

{# context lib="gtk" prefix="gtk" #}

{# enum SourceSmartHomeEndType {underscoreToCase} deriving (Eq, Bounded, Show, Read) #}

{# enum SourceDrawSpacesFlags {underscoreToCase} deriving (Eq, Bounded, Show, Read) #}

-- | Create a new 'SourceView' widget with a default 'SourceBuffer'.
--
sourceViewNew :: IO SourceView
sourceViewNew = makeNewObject mkSourceView $ liftM castPtr
  {#call unsafe source_view_new#}

-- | Create a new 'SourceView'
-- widget with the given 'SourceBuffer'.
--
sourceViewNewWithBuffer :: SourceBuffer -> IO SourceView
sourceViewNewWithBuffer sb = makeNewObject mkSourceView $ liftM castPtr $
  {#call source_view_new_with_buffer#} sb

-- | If 'True' auto indentation of text is enabled.
--
sourceViewSetAutoIndent :: SourceViewClass sv => sv
                        -> Bool  -- ^ @enable@ whether to enable auto indentation.
                        -> IO ()
sourceViewSetAutoIndent sv enable =
  {#call source_view_set_auto_indent#} (toSourceView sv) (fromBool enable)

-- | Returns whether auto indentation of text is enabled.
--
sourceViewGetAutoIndent :: SourceViewClass sv => sv
                        -> IO Bool  -- ^ returns 'True' if auto indentation is enabled.
sourceViewGetAutoIndent sv = liftM toBool $
  {#call unsafe source_view_get_auto_indent#} (toSourceView sv)

-- | If 'True', when the tab key is pressed and there is a selection, the selected text is indented of one
-- level instead of being replaced with the \t characters. Shift+Tab unindents the selection.
--
sourceViewSetIndentOnTab :: SourceViewClass sv => sv
                         -> Bool  -- ^ @enable@ whether to indent a block when tab is pressed.
                         -> IO ()
sourceViewSetIndentOnTab sv enable =
  {#call source_view_set_indent_on_tab#} (toSourceView sv) (fromBool enable)

-- | Returns whether when the tab key is pressed the current selection should get indented instead of
-- replaced with the \t character.
--
sourceViewGetIndentOnTab :: SourceViewClass sv => sv
                         -> IO Bool  -- ^ returns 'True' if the selection is indented when tab is pressed.
sourceViewGetIndentOnTab sv = liftM toBool $
  {#call unsafe source_view_get_indent_on_tab#} (toSourceView sv)

-- | Sets the number of spaces to use for each step of indent. If width is -1, the value of the
-- 'tabWidth' property will be used.
--
sourceViewSetIndentWidth :: SourceViewClass sv => sv
                         -> Int  -- ^ @width@ indent width in characters.
                         -> IO ()
sourceViewSetIndentWidth sv width =
  {#call source_view_set_indent_width#} (toSourceView sv) (fromIntegral width)

-- | Returns the number of spaces to use for each step of indent. See 'sourceViewSetIndentWidth'
-- for details.
--
sourceViewGetIndentWidth :: SourceViewClass sv => sv
                         -> IO Int -- ^ returns indent width.
sourceViewGetIndentWidth sv = liftM fromIntegral $
  {#call unsafe source_view_get_indent_width#} (toSourceView sv)

-- | If 'True' any tabulator character inserted is replaced by a group of space characters.
--
sourceViewSetInsertSpacesInsteadOfTabs :: SourceViewClass sv => sv
                                       -> Bool  -- ^ @enable@ whether to insert spaces instead of tabs.
                                       -> IO ()
sourceViewSetInsertSpacesInsteadOfTabs sv enable =
  {#call source_view_set_insert_spaces_instead_of_tabs#} (toSourceView sv) (fromBool enable)

-- | Returns whether when inserting a tabulator character it should be replaced by a group of space
-- characters.
--
sourceViewGetInsertSpacesInsteadOfTabs :: SourceViewClass sv => sv
                                       -> IO Bool  -- ^ returns 'True' if spaces are inserted instead of tabs.
sourceViewGetInsertSpacesInsteadOfTabs sv = liftM toBool $
  {#call unsafe source_view_get_insert_spaces_instead_of_tabs#} (toSourceView sv)

-- | Set the desired movement of the cursor when HOME and END keys are pressed.
--
sourceViewSetSmartHomeEnd :: SourceViewClass sv => sv
                          -> SourceSmartHomeEndType  -- ^ @smartHe@ the desired behavior among 'SourceSmartHomeEndType'.
                          -> IO ()
sourceViewSetSmartHomeEnd sv newVal =
  {#call source_view_set_smart_home_end#} (toSourceView sv) (fromIntegral $ fromEnum newVal)

-- | Returns a 'SourceSmartHomeEndType' end value specifying how the cursor will move when HOME and END
-- keys are pressed.
--
sourceViewGetSmartHomeEnd :: SourceViewClass sv => sv
                          -> IO SourceSmartHomeEndType -- ^ returns a 'SourceSmartHomeEndTypeend' value.
sourceViewGetSmartHomeEnd sv = liftM (toEnum . fromIntegral) $
  {#call unsafe source_view_get_smart_home_end#} (toSourceView sv)

-- | If show is 'True' the current line is highlighted.
--
sourceViewSetHighlightCurrentLine :: SourceViewClass sv => sv
                                  -> Bool  -- ^ @show@ whether to highlight the current line
                                  -> IO ()
sourceViewSetHighlightCurrentLine sv newVal =
  {#call source_view_set_highlight_current_line#} (toSourceView sv) (fromBool newVal)

-- | Returns whether the current line is highlighted
--
sourceViewGetHighlightCurrentLine :: SourceViewClass sv => sv
                                  -> IO Bool  -- ^ returns 'True' if the current line is highlighted.
sourceViewGetHighlightCurrentLine sv = liftM toBool $
  {#call unsafe source_view_get_highlight_current_line#} (toSourceView sv)

-- | If 'True' line marks will be displayed beside the text.
--
sourceViewSetShowLineMarks :: SourceViewClass sv => sv
                           -> Bool  -- ^ @show@ whether line marks should be displayed.
                           -> IO ()
sourceViewSetShowLineMarks sv newVal =
  {#call source_view_set_show_line_marks#} (toSourceView sv) (fromBool newVal)

-- | Returns whether line marks are displayed beside the text.
--
sourceViewGetShowLineMarks :: SourceViewClass sv => sv
                           -> IO Bool  -- ^ returns 'True' if the line marks are displayed.
sourceViewGetShowLineMarks sv = liftM toBool $
  {#call unsafe source_view_get_show_line_marks#} (toSourceView sv)

-- | If 'True' line numbers will be displayed beside the text.
--
sourceViewSetShowLineNumbers :: SourceViewClass sv => sv
                             -> Bool  -- ^ @show@ whether line numbers should be displayed.
                             -> IO ()
sourceViewSetShowLineNumbers sv newVal =
  {#call source_view_set_show_line_numbers#} (toSourceView sv) (fromBool newVal)

-- | Returns whether line numbers are displayed beside the text.
--
sourceViewGetShowLineNumbers :: SourceViewClass sv => sv
                             -> IO Bool  -- ^ returns 'True' if the line numbers are displayed.
sourceViewGetShowLineNumbers sv = liftM toBool $
  {#call unsafe source_view_get_show_line_numbers#} (toSourceView sv)

-- | If 'True' a right margin is displayed
--
sourceViewSetShowRightMargin :: SourceViewClass sv => sv
                             -> Bool  -- ^ @show@ whether to show a right margin.
                             -> IO ()
sourceViewSetShowRightMargin sv newVal =
  {#call source_view_set_show_right_margin#} (toSourceView sv) (fromBool newVal)

-- | Returns whether a right margin is displayed.
--
sourceViewGetShowRightMargin :: SourceViewClass sv => sv
                             -> IO Bool -- ^ returns 'True' if the right margin is shown.
sourceViewGetShowRightMargin sv = liftM toBool $
  {#call source_view_get_show_right_margin#} (toSourceView sv)

-- | Sets the position of the right margin in the given view.
--
sourceViewSetRightMarginPosition :: SourceViewClass sv => sv
                                 -> Word -- ^ @pos@  the width in characters where to position the right margin.
                                 -> IO ()
sourceViewSetRightMarginPosition sv margin =
  {#call source_view_set_right_margin_position#} (toSourceView sv) (fromIntegral margin)

-- | Gets the position of the right margin in the given view.
--
sourceViewGetRightMarginPosition :: SourceViewClass sv => sv
                                 -> IO Int  -- ^ returns the position of the right margin.
sourceViewGetRightMarginPosition sv = liftM fromIntegral $
  {#call unsafe source_view_get_right_margin_position#} (toSourceView sv)

-- | Sets the width of tabulation in characters.
--
sourceViewSetTabWidth :: SourceViewClass sv => sv
                      -> Int  -- ^ @width@ width of tab in characters.
                      -> IO ()
sourceViewSetTabWidth sv width =
  {#call source_view_set_tab_width#} (toSourceView sv) (fromIntegral width)

-- | Returns the width of tabulation in characters.
--
sourceViewGetTabWidth :: SourceViewClass sv => sv
                      -> IO Int -- ^ returns width of tab.
sourceViewGetTabWidth sv = liftM fromIntegral $
  {#call unsafe source_view_get_tab_width#} (toSourceView sv)

-- | Set if and how the spaces should be visualized. Specifying flags as 0 will disable display of
-- spaces.
sourceViewSetDrawSpaces :: SourceViewClass sv => sv
                        -> SourceDrawSpacesFlags -- ^ @flags@ 'SourceDrawSpacesFlags' specifing how white spaces should be displayed
                        -> IO ()
sourceViewSetDrawSpaces view flags =
  {#call gtk_source_view_set_draw_spaces #}
    (toSourceView view)
    (fromIntegral $ fromEnum flags)

-- | Returns the 'SourceDrawSpacesFlags' specifying if and how spaces should be displayed for this view.
sourceViewGetDrawSpaces :: SourceViewClass sv => sv
                        -> IO SourceDrawSpacesFlags -- ^ returns the 'SourceDrawSpacesFlags', 0 if no spaces should be drawn.
sourceViewGetDrawSpaces view =
  liftM (toEnum . fromIntegral) $
  {#call gtk_source_view_get_draw_spaces #}
     (toSourceView view)

-- | Set the priority for the given mark category. When there are multiple marks on the same line, marks
-- of categories with higher priorities will be drawn on top.
--
sourceViewSetMarkCategoryPriority :: SourceViewClass sv => sv
                                  -> String  -- ^ @category@ a mark category.
                                  -> Int  -- ^ @priority@ the priority for the category
                                  -> IO ()
sourceViewSetMarkCategoryPriority sv markerType priority = withCString markerType $ \strPtr ->
  {#call source_view_set_mark_category_priority#} (toSourceView sv) strPtr (fromIntegral priority)

-- | Gets the priority which is associated with the given category.
--
sourceViewGetMarkCategoryPriority :: SourceViewClass sv => sv
                                  -> String  -- ^ @category@ a mark category.
                                  -> IO Int -- ^ returns  the priority or if category exists but no priority was set, it defaults to 0.
sourceViewGetMarkCategoryPriority sv markerType = withCString markerType $ \strPtr ->
  liftM fromIntegral $
  {#call unsafe source_view_get_mark_category_priority#} (toSourceView sv) strPtr

-- | Sets the icon to be used for category to pixbuf. If pixbuf is 'Nothing', the icon is unset.
sourceViewSetMarkCategoryIconFromPixbuf :: SourceViewClass sv => sv
                                        -> String -- ^ @category@ a mark category.
                                        -> Maybe Pixbuf -- ^ @pixbuf@   a 'Pixbuf' or 'Nothing'.
                                        -> IO ()
sourceViewSetMarkCategoryIconFromPixbuf sv category pixbuf =
  withCString category $ \categoryPtr ->
  {#call gtk_source_view_set_mark_category_icon_from_pixbuf #}
     (toSourceView sv)
     categoryPtr
     (fromMaybe (Pixbuf nullForeignPtr) pixbuf)

-- | Sets the icon to be used for category to the stock item @stockId@. If @stockId@ is 'Nothing', the icon is
-- unset.
sourceViewSetMarkCategoryIconFromStock :: SourceViewClass sv => sv
                                       -> String -- ^ @category@ a mark category.
                                       -> Maybe String -- ^ @stockId@ the stock id or 'Nothing'.
                                       -> IO ()
sourceViewSetMarkCategoryIconFromStock sv category stockId =
  withCString category $ \categoryPtr ->
  maybeWith withCString stockId $ \stockIdPtr ->
  {#call gtk_source_view_set_mark_category_icon_from_stock #}
    (toSourceView sv)
    categoryPtr
    stockIdPtr

-- | Sets the icon to be used for category to the named theme item name. If name is 'Nothing', the icon is
-- unset.
sourceViewSetMarkCategoryIconFromIconName :: SourceViewClass sv => sv
                                       -> String -- ^ @category@ a mark category.
                                       -> Maybe String -- ^ @name@     the themed icon name or 'Nothing'.
                                       -> IO ()
sourceViewSetMarkCategoryIconFromIconName sv category name =
  withCString category $ \categoryPtr ->
  maybeWith withCString name $ \namePtr ->
  {#call gtk_source_view_set_mark_category_icon_from_icon_name #}
    (toSourceView sv)
    categoryPtr
    namePtr

-- | Sets given background color for mark category. If color is 'Nothing', the background color is unset.
sourceViewSetMarkCategoryBackground :: SourceViewClass sv => sv
                                    -> String -- ^ @category@ a mark category.
                                    -> Maybe Color  -- ^ @color@    background color or 'Nothing' to unset it.
                                    -> IO ()
sourceViewSetMarkCategoryBackground sv category color =
  let withMB :: Storable a => Maybe a -> (Ptr a -> IO b) -> IO b
      withMB Nothing f = f nullPtr
      withMB (Just x) f = with x f
  in withCString category $ \categoryPtr ->
     withMB color $ \colorPtr ->
     {#call gtk_source_view_set_mark_category_background #}
       (toSourceView sv)
       categoryPtr
       (castPtr colorPtr)

-- | Gets the background color associated with given category.
sourceViewGetMarkCategoryBackground :: SourceViewClass sv => sv
                                    -> String -- ^ @category@ a mark category.
                                    -> Color -- ^ @dest@     destination 'Color' structure to fill in.
                                    -> IO Bool -- ^ returns  'True' if background color for category was set and dest is set to a valid color, or 'False' otherwise.
sourceViewGetMarkCategoryBackground sv category color =
    liftM toBool $
    withCString category $ \ categoryPtr ->
    with color $ \ colorPtr ->
    {#call gtk_source_view_get_mark_category_background #}
      (toSourceView sv)
      categoryPtr
      (castPtr colorPtr)

-- | Whether to enable auto indentation.
--
-- Default value: 'False'
--
sourceViewAutoIndent :: SourceViewClass sv => Attr sv Bool
sourceViewAutoIndent = newAttrFromBoolProperty "auto-indent"

-- | Set if and how the spaces should be visualized.
--
sourceViewDrawSpaces :: SourceViewClass sv => Attr sv SourceDrawSpacesFlags
sourceViewDrawSpaces = newAttrFromEnumProperty "draw-spaces" {#call fun gtk_source_draw_spaces_flags_get_type#}

-- | Whether to highlight the current line.
--
-- Default value: 'False'
--
sourceViewHighlightCurrentLine :: SourceViewClass sv => Attr sv Bool
sourceViewHighlightCurrentLine = newAttrFromBoolProperty "highlight-current-line"

-- | Whether to indent the selected text when the tab key is pressed.
--
-- Default value: 'True'
--
sourceViewIndentOnTab :: SourceViewClass sv => Attr sv Bool
sourceViewIndentOnTab = newAttrFromBoolProperty "indent-on-tab"

-- | Width of an indentation step expressed in number of spaces.
--
-- Allowed values: [GMaxulong,32]
--
-- Default value: -1
--
sourceViewIndentWidth :: SourceViewClass sv => Attr sv Int
sourceViewIndentWidth = newAttrFromIntProperty "indent-width"

-- | Whether to insert spaces instead of tabs.
--
-- Default value: 'False'
--
sourceViewInsertSpacesInsteadOfTabs :: SourceViewClass sv => Attr sv Bool
sourceViewInsertSpacesInsteadOfTabs = newAttrFromBoolProperty "insert-spaces-instead-of-tabs"

-- | Position of the right margin.
--
-- Allowed values: [1,200]
--
-- Default value: 80
--
sourceViewRightMarginPosition :: SourceViewClass sv => Attr sv Int
sourceViewRightMarginPosition = newAttrFromUIntProperty "right-margin-position"

-- | Whether to display line numbers
--
-- Default value: 'False'
--
sourceViewShowLineNumbers :: SourceViewClass sv => Attr sv Bool
sourceViewShowLineNumbers = newAttrFromBoolProperty "show-line-numbers"

-- | Whether to display line mark pixbufs
--
-- Default value: 'False'
--
sourceViewShowRightMargin :: SourceViewClass sv => Attr sv Bool
sourceViewShowRightMargin = newAttrFromBoolProperty "show-right-margin"

-- | Set the behavior of the HOME and END keys.
--
-- Default value: 'SourceSmartHomeEndDisabled'
--
-- Since 2.0
--
sourceViewSmartHomeEnd :: SourceViewClass sv => Attr sv SourceSmartHomeEndType
sourceViewSmartHomeEnd = newAttrFromEnumProperty "smart-home-end" {#call fun gtk_source_smart_home_end_type_get_type#}

-- | Width of an tab character expressed in number of spaces.
--
-- Allowed values: [1,32]
--
-- Default value: 8
--
sourceViewTabWidth :: SourceViewClass sv => Attr sv Int
sourceViewTabWidth = newAttrFromUIntProperty "tab-width"

-- |
--
sourceViewUndo :: SourceViewClass sv => Signal sv (IO ())
sourceViewUndo = Signal $ connect_NONE__NONE "undo"

-- |
--
sourceViewRedo :: SourceViewClass sv => Signal sv (IO ())
sourceViewRedo = Signal $ connect_NONE__NONE "redo"

-- | The 'moveLines' signal is a keybinding which gets emitted when the user initiates moving a
-- line. The default binding key is Alt+Up/Down arrow. And moves the currently selected lines, or the
-- current line by count. For the moment, only count of -1 or 1 is valid.
sourceViewMoveLines :: SourceViewClass sv => Signal sv (Bool -> Int -> IO ())
sourceViewMoveLines = Signal $ connect_BOOL_INT__NONE "move-lines"

-- | The 'showCompletion' signal is a keybinding signal which gets emitted when the user initiates a
-- completion in default mode.
--
-- Applications should not connect to it, but may emit it with @gSignalEmitByName@ if they need to
-- control the default mode completion activation.
sourceViewShowCompletion :: SourceViewClass sv => Signal sv (IO ())
sourceViewShowCompletion = Signal $ connect_NONE__NONE "show-completion"

-- * Deprecated
#ifndef DISABLE_DEPRECATED
-- | 'sourceViewSetMarkCategoryPixbuf' is deprecated and should not be used in newly-written
-- code. Use 'sourceViewSetMarkCategoryIconFromPixbuf' instead
--
sourceViewSetMarkCategoryPixbuf :: SourceViewClass sv => sv -> String -> Pixbuf -> IO ()
sourceViewSetMarkCategoryPixbuf sv markerType marker = withCString markerType $ \strPtr ->
  {#call source_view_set_mark_category_pixbuf#} (toSourceView sv) strPtr marker

-- | 'sourceViewGetMarkCategoryPixbuf' is deprecated and should not be used in newly-written code.
--
sourceViewGetMarkCategoryPixbuf :: SourceViewClass sv => sv -> String -> IO Pixbuf
sourceViewGetMarkCategoryPixbuf sv markerType = withCString markerType $ \strPtr ->
  constructNewGObject mkPixbuf $
  {#call unsafe source_view_get_mark_category_pixbuf#} (toSourceView sv) strPtr
#endif

{-# LANGUAGE CPP #-}
-- -*-haskell-*-
--  GIMP Toolkit (GTK) Widget SourceView
--
--  Author : Peter Gavin
--  derived from sourceview bindings by Axel Simon and Duncan Coutts
--
--  Created: 18 December 2008
--
--  Copyright (C) 2004-2008 Peter Gavin, Duncan Coutts, Axel Simon
--  Copyright (C) 2010 Andy Stewart
--
--  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.
--
-- |
-- Maintainer  : gtk2hs-users@lists.sourceforge.net
-- Stability   : provisional
-- Portability : portable (depends on GHC)
--
module Graphics.UI.Gtk.SourceView.SourceView (
-- * Types
  SourceView,
  SourceViewClass,
  SourceSmartHomeEndType(..),
  SourceDrawSpacesFlags(..),

-- * Methods
  castToSourceView,
  sourceViewNew,
  sourceViewNewWithBuffer,
  sourceViewSetAutoIndent,
  sourceViewGetAutoIndent,
  sourceViewSetIndentOnTab,
  sourceViewGetIndentOnTab,
  sourceViewSetIndentWidth,
  sourceViewGetIndentWidth,
  sourceViewSetInsertSpacesInsteadOfTabs,
  sourceViewGetInsertSpacesInsteadOfTabs,
  sourceViewSetSmartHomeEnd,
  sourceViewGetSmartHomeEnd,
  sourceViewSetMarkCategoryPriority,
  sourceViewGetMarkCategoryPriority,
  sourceViewSetMarkCategoryIconFromPixbuf,
  sourceViewSetMarkCategoryIconFromStock,
  sourceViewSetMarkCategoryIconFromIconName,
  sourceViewSetMarkCategoryBackground,
  sourceViewGetMarkCategoryBackground,
  sourceViewSetHighlightCurrentLine,
  sourceViewGetHighlightCurrentLine,
  sourceViewSetShowLineMarks,
  sourceViewGetShowLineMarks,
  sourceViewSetShowLineNumbers,
  sourceViewGetShowLineNumbers,
  sourceViewSetShowRightMargin,
  sourceViewGetShowRightMargin,
  sourceViewSetRightMarginPosition,
  sourceViewGetRightMarginPosition,
  sourceViewSetTabWidth,
  sourceViewGetTabWidth,
  sourceViewSetDrawSpaces,
  sourceViewGetDrawSpaces,

-- * Attributes
  sourceViewAutoIndent,
  sourceViewDrawSpaces,
  sourceViewHighlightCurrentLine,
  sourceViewIndentOnTab,
  sourceViewIndentWidth,
  sourceViewInsertSpacesInsteadOfTabs,
  sourceViewRightMarginPosition,
  sourceViewShowLineNumbers,
  sourceViewShowRightMargin,
  sourceViewSmartHomeEnd,
  sourceViewTabWidth,

-- * Signals
  sourceViewUndo,
  sourceViewRedo,
  sourceViewMoveLines,
  sourceViewShowCompletion,

-- * Deprecated
#ifndef DISABLE_DEPRECATED
  sourceViewSetMarkCategoryPixbuf,
  sourceViewGetMarkCategoryPixbuf,
#endif
  ) where

import Control.Monad	(liftM)
import Data.Maybe    (fromMaybe)

import System.Glib.FFI
{#import System.Glib.Properties#}
import System.Glib.Attributes
import Graphics.UI.Gtk.Abstract.Object	(makeNewObject)
import Graphics.UI.Gtk.Abstract.Widget (Color)
{#import Graphics.UI.Gtk.SourceView.Types#}
{#import Graphics.UI.Gtk.SourceView.Signals#}

{# context lib="gtk" prefix="gtk" #}

{# enum SourceSmartHomeEndType {underscoreToCase} deriving (Eq, Bounded, Show, Read) #}

{# enum SourceDrawSpacesFlags {underscoreToCase} deriving (Eq, Bounded, Show, Read) #}

-- | Create a new 'SourceView' widget with a default 'SourceBuffer'.
--
sourceViewNew :: IO SourceView
sourceViewNew = makeNewObject mkSourceView $ liftM castPtr
  {#call unsafe source_view_new#}

-- | Create a new 'SourceView'
-- widget with the given 'SourceBuffer'.
--
sourceViewNewWithBuffer :: SourceBuffer -> IO SourceView
sourceViewNewWithBuffer sb = makeNewObject mkSourceView $ liftM castPtr $
  {#call source_view_new_with_buffer#} sb

-- | If 'True' auto indentation of text is enabled.
--
sourceViewSetAutoIndent :: SourceViewClass sv => sv
                        -> Bool  -- ^ @enable@ whether to enable auto indentation.
                        -> IO ()
sourceViewSetAutoIndent sv enable =
  {#call source_view_set_auto_indent#} (toSourceView sv) (fromBool enable)

-- | Returns whether auto indentation of text is enabled.
--
sourceViewGetAutoIndent :: SourceViewClass sv => sv
                        -> IO Bool  -- ^ returns 'True' if auto indentation is enabled.
sourceViewGetAutoIndent sv = liftM toBool $
  {#call unsafe source_view_get_auto_indent#} (toSourceView sv)

-- | If 'True', when the tab key is pressed and there is a selection, the selected text is indented of one
-- level instead of being replaced with the \t characters. Shift+Tab unindents the selection.
--
sourceViewSetIndentOnTab :: SourceViewClass sv => sv
                         -> Bool  -- ^ @enable@ whether to indent a block when tab is pressed.
                         -> IO ()
sourceViewSetIndentOnTab sv enable =
  {#call source_view_set_indent_on_tab#} (toSourceView sv) (fromBool enable)

-- | Returns whether when the tab key is pressed the current selection should get indented instead of
-- replaced with the \t character.
--
sourceViewGetIndentOnTab :: SourceViewClass sv => sv
                         -> IO Bool  -- ^ returns 'True' if the selection is indented when tab is pressed.
sourceViewGetIndentOnTab sv = liftM toBool $
  {#call unsafe source_view_get_indent_on_tab#} (toSourceView sv)

-- | Sets the number of spaces to use for each step of indent. If width is -1, the value of the
-- 'tabWidth' property will be used.
--
sourceViewSetIndentWidth :: SourceViewClass sv => sv
                         -> Int  -- ^ @width@ indent width in characters.
                         -> IO ()
sourceViewSetIndentWidth sv width =
  {#call source_view_set_indent_width#} (toSourceView sv) (fromIntegral width)

-- | Returns the number of spaces to use for each step of indent. See 'sourceViewSetIndentWidth'
-- for details.
--
sourceViewGetIndentWidth :: SourceViewClass sv => sv
                         -> IO Int -- ^ returns indent width.
sourceViewGetIndentWidth sv = liftM fromIntegral $
  {#call unsafe source_view_get_indent_width#} (toSourceView sv)

-- | If 'True' any tabulator character inserted is replaced by a group of space characters.
--
sourceViewSetInsertSpacesInsteadOfTabs :: SourceViewClass sv => sv
                                       -> Bool  -- ^ @enable@ whether to insert spaces instead of tabs.
                                       -> IO ()
sourceViewSetInsertSpacesInsteadOfTabs sv enable =
  {#call source_view_set_insert_spaces_instead_of_tabs#} (toSourceView sv) (fromBool enable)

-- | Returns whether when inserting a tabulator character it should be replaced by a group of space
-- characters.
--
sourceViewGetInsertSpacesInsteadOfTabs :: SourceViewClass sv => sv
                                       -> IO Bool  -- ^ returns 'True' if spaces are inserted instead of tabs.
sourceViewGetInsertSpacesInsteadOfTabs sv = liftM toBool $
  {#call unsafe source_view_get_insert_spaces_instead_of_tabs#} (toSourceView sv)

-- | Set the desired movement of the cursor when HOME and END keys are pressed.
--
sourceViewSetSmartHomeEnd :: SourceViewClass sv => sv
                          -> SourceSmartHomeEndType  -- ^ @smartHe@ the desired behavior among 'SourceSmartHomeEndType'.
                          -> IO ()
sourceViewSetSmartHomeEnd sv newVal =
  {#call source_view_set_smart_home_end#} (toSourceView sv) (fromIntegral $ fromEnum newVal)

-- | Returns a 'SourceSmartHomeEndType' end value specifying how the cursor will move when HOME and END
-- keys are pressed.
--
sourceViewGetSmartHomeEnd :: SourceViewClass sv => sv
                          -> IO SourceSmartHomeEndType -- ^ returns a 'SourceSmartHomeEndTypeend' value.
sourceViewGetSmartHomeEnd sv = liftM (toEnum . fromIntegral) $
  {#call unsafe source_view_get_smart_home_end#} (toSourceView sv)

-- | If show is 'True' the current line is highlighted.
--
sourceViewSetHighlightCurrentLine :: SourceViewClass sv => sv
                                  -> Bool  -- ^ @show@ whether to highlight the current line
                                  -> IO ()
sourceViewSetHighlightCurrentLine sv newVal =
  {#call source_view_set_highlight_current_line#} (toSourceView sv) (fromBool newVal)

-- | Returns whether the current line is highlighted
--
sourceViewGetHighlightCurrentLine :: SourceViewClass sv => sv
                                  -> IO Bool  -- ^ returns 'True' if the current line is highlighted.
sourceViewGetHighlightCurrentLine sv = liftM toBool $
  {#call unsafe source_view_get_highlight_current_line#} (toSourceView sv)

-- | If 'True' line marks will be displayed beside the text.
--
sourceViewSetShowLineMarks :: SourceViewClass sv => sv
                           -> Bool  -- ^ @show@ whether line marks should be displayed.
                           -> IO ()
sourceViewSetShowLineMarks sv newVal =
  {#call source_view_set_show_line_marks#} (toSourceView sv) (fromBool newVal)

-- | Returns whether line marks are displayed beside the text.
--
sourceViewGetShowLineMarks :: SourceViewClass sv => sv
                           -> IO Bool  -- ^ returns 'True' if the line marks are displayed.
sourceViewGetShowLineMarks sv = liftM toBool $
  {#call unsafe source_view_get_show_line_marks#} (toSourceView sv)

-- | If 'True' line numbers will be displayed beside the text.
--
sourceViewSetShowLineNumbers :: SourceViewClass sv => sv
                             -> Bool  -- ^ @show@ whether line numbers should be displayed.
                             -> IO ()
sourceViewSetShowLineNumbers sv newVal =
  {#call source_view_set_show_line_numbers#} (toSourceView sv) (fromBool newVal)

-- | Returns whether line numbers are displayed beside the text.
--
sourceViewGetShowLineNumbers :: SourceViewClass sv => sv
                             -> IO Bool  -- ^ returns 'True' if the line numbers are displayed.
sourceViewGetShowLineNumbers sv = liftM toBool $
  {#call unsafe source_view_get_show_line_numbers#} (toSourceView sv)

-- | If 'True' a right margin is displayed
--
sourceViewSetShowRightMargin :: SourceViewClass sv => sv
                             -> Bool  -- ^ @show@ whether to show a right margin.
                             -> IO ()
sourceViewSetShowRightMargin sv newVal =
  {#call source_view_set_show_right_margin#} (toSourceView sv) (fromBool newVal)

-- | Returns whether a right margin is displayed.
--
sourceViewGetShowRightMargin :: SourceViewClass sv => sv
                             -> IO Bool -- ^ returns 'True' if the right margin is shown.
sourceViewGetShowRightMargin sv = liftM toBool $
  {#call source_view_get_show_right_margin#} (toSourceView sv)

-- | Sets the position of the right margin in the given view.
--
sourceViewSetRightMarginPosition :: SourceViewClass sv => sv
                                 -> Word -- ^ @pos@  the width in characters where to position the right margin.
                                 -> IO ()
sourceViewSetRightMarginPosition sv margin =
  {#call source_view_set_right_margin_position#} (toSourceView sv) (fromIntegral margin)

-- | Gets the position of the right margin in the given view.
--
sourceViewGetRightMarginPosition :: SourceViewClass sv => sv
                                 -> IO Int  -- ^ returns the position of the right margin.
sourceViewGetRightMarginPosition sv = liftM fromIntegral $
  {#call unsafe source_view_get_right_margin_position#} (toSourceView sv)

-- | Sets the width of tabulation in characters.
--
sourceViewSetTabWidth :: SourceViewClass sv => sv
                      -> Int  -- ^ @width@ width of tab in characters.
                      -> IO ()
sourceViewSetTabWidth sv width =
  {#call source_view_set_tab_width#} (toSourceView sv) (fromIntegral width)

-- | Returns the width of tabulation in characters.
--
sourceViewGetTabWidth :: SourceViewClass sv => sv
                      -> IO Int -- ^ returns width of tab.
sourceViewGetTabWidth sv = liftM fromIntegral $
  {#call unsafe source_view_get_tab_width#} (toSourceView sv)

-- | Set if and how the spaces should be visualized. Specifying flags as 0 will disable display of
-- spaces.
sourceViewSetDrawSpaces :: SourceViewClass sv => sv
                        -> SourceDrawSpacesFlags -- ^ @flags@ 'SourceDrawSpacesFlags' specifing how white spaces should be displayed
                        -> IO ()
sourceViewSetDrawSpaces view flags =
  {#call gtk_source_view_set_draw_spaces #}
    (toSourceView view)
    (fromIntegral $ fromEnum flags)

-- | Returns the 'SourceDrawSpacesFlags' specifying if and how spaces should be displayed for this view.
sourceViewGetDrawSpaces :: SourceViewClass sv => sv
                        -> IO SourceDrawSpacesFlags -- ^ returns the 'SourceDrawSpacesFlags', 0 if no spaces should be drawn.
sourceViewGetDrawSpaces view =
  liftM (toEnum . fromIntegral) $
  {#call gtk_source_view_get_draw_spaces #}
     (toSourceView view)

-- | Set the priority for the given mark category. When there are multiple marks on the same line, marks
-- of categories with higher priorities will be drawn on top.
--
sourceViewSetMarkCategoryPriority :: SourceViewClass sv => sv
                                  -> String  -- ^ @category@ a mark category.
                                  -> Int  -- ^ @priority@ the priority for the category
                                  -> IO ()
sourceViewSetMarkCategoryPriority sv markerType priority = withCString markerType $ \strPtr ->
  {#call source_view_set_mark_category_priority#} (toSourceView sv) strPtr (fromIntegral priority)

-- | Gets the priority which is associated with the given category.
--
sourceViewGetMarkCategoryPriority :: SourceViewClass sv => sv
                                  -> String  -- ^ @category@ a mark category.
                                  -> IO Int -- ^ returns  the priority or if category exists but no priority was set, it defaults to 0.
sourceViewGetMarkCategoryPriority sv markerType = withCString markerType $ \strPtr ->
  liftM fromIntegral $
  {#call unsafe source_view_get_mark_category_priority#} (toSourceView sv) strPtr

-- | Sets the icon to be used for category to pixbuf. If pixbuf is 'Nothing', the icon is unset.
sourceViewSetMarkCategoryIconFromPixbuf :: SourceViewClass sv => sv
                                        -> String -- ^ @category@ a mark category.
                                        -> Maybe Pixbuf -- ^ @pixbuf@   a 'Pixbuf' or 'Nothing'.
                                        -> IO ()
sourceViewSetMarkCategoryIconFromPixbuf sv category pixbuf =
  withCString category $ \categoryPtr ->
  {#call gtk_source_view_set_mark_category_icon_from_pixbuf #}
     (toSourceView sv)
     categoryPtr
     (fromMaybe (Pixbuf nullForeignPtr) pixbuf)

-- | Sets the icon to be used for category to the stock item @stockId@. If @stockId@ is 'Nothing', the icon is
-- unset.
sourceViewSetMarkCategoryIconFromStock :: SourceViewClass sv => sv
                                       -> String -- ^ @category@ a mark category.
                                       -> Maybe String -- ^ @stockId@ the stock id or 'Nothing'.
                                       -> IO ()
sourceViewSetMarkCategoryIconFromStock sv category stockId =
  withCString category $ \categoryPtr ->
  maybeWith withCString stockId $ \stockIdPtr ->
  {#call gtk_source_view_set_mark_category_icon_from_stock #}
    (toSourceView sv)
    categoryPtr
    stockIdPtr

-- | Sets the icon to be used for category to the named theme item name. If name is 'Nothing', the icon is
-- unset.
sourceViewSetMarkCategoryIconFromIconName :: SourceViewClass sv => sv
                                       -> String -- ^ @category@ a mark category.
                                       -> Maybe String -- ^ @name@     the themed icon name or 'Nothing'.
                                       -> IO ()
sourceViewSetMarkCategoryIconFromIconName sv category name =
  withCString category $ \categoryPtr ->
  maybeWith withCString name $ \namePtr ->
  {#call gtk_source_view_set_mark_category_icon_from_icon_name #}
    (toSourceView sv)
    categoryPtr
    namePtr

-- | Sets given background color for mark category. If color is 'Nothing', the background color is unset.
sourceViewSetMarkCategoryBackground :: SourceViewClass sv => sv
                                    -> String -- ^ @category@ a mark category.
                                    -> Maybe Color  -- ^ @color@    background color or 'Nothing' to unset it.
                                    -> IO ()
sourceViewSetMarkCategoryBackground sv category color =
  let withMB :: Storable a => Maybe a -> (Ptr a -> IO b) -> IO b
      withMB Nothing f = f nullPtr
      withMB (Just x) f = with x f
  in withCString category $ \categoryPtr ->
     withMB color $ \colorPtr ->
     {#call gtk_source_view_set_mark_category_background #}
       (toSourceView sv)
       categoryPtr
       (castPtr colorPtr)

-- | Gets the background color associated with given category.
sourceViewGetMarkCategoryBackground :: SourceViewClass sv => sv
                                    -> String -- ^ @category@ a mark category.
                                    -> Color -- ^ @dest@     destination 'Color' structure to fill in.
                                    -> IO Bool -- ^ returns  'True' if background color for category was set and dest is set to a valid color, or 'False' otherwise.
sourceViewGetMarkCategoryBackground sv category color =
    liftM toBool $
    withCString category $ \ categoryPtr ->
    with color $ \ colorPtr ->
    {#call gtk_source_view_get_mark_category_background #}
      (toSourceView sv)
      categoryPtr
      (castPtr colorPtr)

-- | Whether to enable auto indentation.
--
-- Default value: 'False'
--
sourceViewAutoIndent :: SourceViewClass sv => Attr sv Bool
sourceViewAutoIndent = newAttrFromBoolProperty "auto-indent"

-- | Set if and how the spaces should be visualized.
--
sourceViewDrawSpaces :: SourceViewClass sv => Attr sv SourceDrawSpacesFlags
sourceViewDrawSpaces = newAttrFromEnumProperty "draw-spaces" {#call fun gtk_source_draw_spaces_flags_get_type#}

-- | Whether to highlight the current line.
--
-- Default value: 'False'
--
sourceViewHighlightCurrentLine :: SourceViewClass sv => Attr sv Bool
sourceViewHighlightCurrentLine = newAttrFromBoolProperty "highlight-current-line"

-- | Whether to indent the selected text when the tab key is pressed.
--
-- Default value: 'True'
--
sourceViewIndentOnTab :: SourceViewClass sv => Attr sv Bool
sourceViewIndentOnTab = newAttrFromBoolProperty "indent-on-tab"

-- | Width of an indentation step expressed in number of spaces.
--
-- Allowed values: [GMaxulong,32]
--
-- Default value: -1
--
sourceViewIndentWidth :: SourceViewClass sv => Attr sv Int
sourceViewIndentWidth = newAttrFromIntProperty "indent-width"

-- | Whether to insert spaces instead of tabs.
--
-- Default value: 'False'
--
sourceViewInsertSpacesInsteadOfTabs :: SourceViewClass sv => Attr sv Bool
sourceViewInsertSpacesInsteadOfTabs = newAttrFromBoolProperty "insert-spaces-instead-of-tabs"

-- | Position of the right margin.
--
-- Allowed values: [1,200]
--
-- Default value: 80
--
sourceViewRightMarginPosition :: SourceViewClass sv => Attr sv Int
sourceViewRightMarginPosition = newAttrFromUIntProperty "right-margin-position"

-- | Whether to display line numbers
--
-- Default value: 'False'
--
sourceViewShowLineNumbers :: SourceViewClass sv => Attr sv Bool
sourceViewShowLineNumbers = newAttrFromBoolProperty "show-line-numbers"

-- | Whether to display line mark pixbufs
--
-- Default value: 'False'
--
sourceViewShowRightMargin :: SourceViewClass sv => Attr sv Bool
sourceViewShowRightMargin = newAttrFromBoolProperty "show-right-margin"

-- | Set the behavior of the HOME and END keys.
--
-- Default value: 'SourceSmartHomeEndDisabled'
--
-- Since 2.0
--
sourceViewSmartHomeEnd :: SourceViewClass sv => Attr sv SourceSmartHomeEndType
sourceViewSmartHomeEnd = newAttrFromEnumProperty "smart-home-end" {#call fun gtk_source_smart_home_end_type_get_type#}

-- | Width of an tab character expressed in number of spaces.
--
-- Allowed values: [1,32]
--
-- Default value: 8
--
sourceViewTabWidth :: SourceViewClass sv => Attr sv Int
sourceViewTabWidth = newAttrFromUIntProperty "tab-width"

-- |
--
sourceViewUndo :: SourceViewClass sv => Signal sv (IO ())
sourceViewUndo = Signal $ connect_NONE__NONE "undo"

-- |
--
sourceViewRedo :: SourceViewClass sv => Signal sv (IO ())
sourceViewRedo = Signal $ connect_NONE__NONE "redo"

-- | The 'moveLines' signal is a keybinding which gets emitted when the user initiates moving a
-- line. The default binding key is Alt+Up/Down arrow. And moves the currently selected lines, or the
-- current line by count. For the moment, only count of -1 or 1 is valid.
sourceViewMoveLines :: SourceViewClass sv => Signal sv (Bool -> Int -> IO ())
sourceViewMoveLines = Signal $ connect_BOOL_INT__NONE "move-lines"

-- | The 'showCompletion' signal is a keybinding signal which gets emitted when the user initiates a
-- completion in default mode.
--
-- Applications should not connect to it, but may emit it with @gSignalEmitByName@ if they need to
-- control the default mode completion activation.
sourceViewShowCompletion :: SourceViewClass sv => Signal sv (IO ())
sourceViewShowCompletion = Signal $ connect_NONE__NONE "show-completion"

-- * Deprecated
#ifndef DISABLE_DEPRECATED
-- | 'sourceViewSetMarkCategoryPixbuf' is deprecated and should not be used in newly-written
-- code. Use 'sourceViewSetMarkCategoryIconFromPixbuf' instead
--
sourceViewSetMarkCategoryPixbuf :: SourceViewClass sv => sv -> String -> Pixbuf -> IO ()
sourceViewSetMarkCategoryPixbuf sv markerType marker = withCString markerType $ \strPtr ->
  {#call source_view_set_mark_category_pixbuf#} (toSourceView sv) strPtr marker

-- | 'sourceViewGetMarkCategoryPixbuf' is deprecated and should not be used in newly-written code.
--
sourceViewGetMarkCategoryPixbuf :: SourceViewClass sv => sv -> String -> IO Pixbuf
sourceViewGetMarkCategoryPixbuf sv markerType = withCString markerType $ \strPtr ->
  constructNewGObject mkPixbuf $
  {#call unsafe source_view_get_mark_category_pixbuf#} (toSourceView sv) strPtr
#endif


Remove removed signals in the re-export module.

{-# LANGUAGE CPP #-}
-- -*-haskell-*-
--  GIMP Toolkit (GTK)
--
--  Author : Axel Simon
--
--  Created: 9 April 2001
--
--  Copyright (C) 2001-2005 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.
--
-- Everything that is marked as deprecated, vanishing or useless for
--   applications is not bound.
--
-- The following modules are not bound:
--   DialogMessage : has only one variadic function which cannot be bound.
--		     The same functionality can be simulated with Dialog.
--   Item :	     The only child of this abstract class is MenuItem. The
--		     three signals Item defines are therefore bound in
--		     MenuItem.
--
-- TODO
--
-- Every module that is commented out and not mentioned above.
--
-- |
-- Maintainer  : gtk2hs-users@lists.sourceforge.net
-- Stability   : provisional
-- Portability : portable (depends on GHC)
--
-- This module gathers all publicly available functions from the Gtk binding.
--
module Graphics.UI.Gtk (
  -- * General things, initialization
  module Graphics.UI.Gtk.General.General,
  module Graphics.UI.Gtk.General.IconFactory,
  module Graphics.UI.Gtk.General.StockItems,
  module Graphics.UI.Gtk.General.Selection,
  module Graphics.UI.Gtk.General.Drag,
  module Graphics.UI.Gtk.Gdk.Keys,
  module Graphics.UI.Gtk.General.Style,
  module Graphics.UI.Gtk.General.RcStyle,
  module Graphics.UI.Gtk.General.Clipboard,

  -- * Drawing and other Low-Level Operations
  module Graphics.UI.Gtk.Gdk.Cursor,
  module Graphics.UI.Gtk.Gdk.Drawable,
  module Graphics.UI.Gtk.Gdk.DrawWindow,
  module Graphics.UI.Gtk.Gdk.Region,
--  module Graphics.UI.Gtk.Gdk.GC,
  module Graphics.UI.Gtk.Gdk.EventM,
  module Graphics.UI.Gtk.Gdk.Pixbuf,
  module Graphics.UI.Gtk.Gdk.Pixmap,
  module Graphics.UI.Gtk.Gdk.Screen,
  module Graphics.UI.Gtk.Gdk.Display,
  module Graphics.UI.Gtk.Gdk.Gdk,
  -- ** cairo integration
  module Graphics.UI.Gtk.Cairo,
  -- * Windows
  module Graphics.UI.Gtk.Windows.Window,
  module Graphics.UI.Gtk.Windows.Invisible,
  module Graphics.UI.Gtk.Windows.Dialog,
  module Graphics.UI.Gtk.Windows.AboutDialog,
  module Graphics.UI.Gtk.Windows.MessageDialog,
  module Graphics.UI.Gtk.Windows.WindowGroup,
  -- * Display widgets,
  module Graphics.UI.Gtk.Display.AccelLabel,
  module Graphics.UI.Gtk.Display.Image,
  module Graphics.UI.Gtk.Display.Label,
  module Graphics.UI.Gtk.Display.ProgressBar,
  module Graphics.UI.Gtk.Display.Statusbar,
  module Graphics.UI.Gtk.Display.StatusIcon,
  -- * Buttons and toggles
  module Graphics.UI.Gtk.Buttons.Button,
  module Graphics.UI.Gtk.Buttons.CheckButton,
  module Graphics.UI.Gtk.Buttons.RadioButton,
  module Graphics.UI.Gtk.Buttons.ToggleButton,
  -- * Numeric\/text data entry
  module Graphics.UI.Gtk.Entry.Editable,
  module Graphics.UI.Gtk.Entry.Entry,
  module Graphics.UI.Gtk.Entry.EntryCompletion,
  module Graphics.UI.Gtk.Entry.HScale,
  module Graphics.UI.Gtk.Entry.VScale,
  module Graphics.UI.Gtk.Entry.SpinButton,
  -- * Multiline text editor
  module Graphics.UI.Gtk.Multiline.TextIter,
  module Graphics.UI.Gtk.Multiline.TextMark,
  module Graphics.UI.Gtk.Multiline.TextBuffer,
  module Graphics.UI.Gtk.Multiline.TextTag,
  module Graphics.UI.Gtk.Multiline.TextTagTable,
  module Graphics.UI.Gtk.Multiline.TextView,
  -- * Tree and list widget
  module Graphics.UI.Gtk.ModelView.CellLayout,
  module Graphics.UI.Gtk.ModelView.CellRenderer,
  module Graphics.UI.Gtk.ModelView.CellRendererCombo,
  module Graphics.UI.Gtk.ModelView.CellRendererPixbuf,
  module Graphics.UI.Gtk.ModelView.CellRendererProgress,
  module Graphics.UI.Gtk.ModelView.CellRendererText,
  module Graphics.UI.Gtk.ModelView.CellRendererToggle,
  module Graphics.UI.Gtk.ModelView.CellView,
  module Graphics.UI.Gtk.ModelView.CustomStore,
  module Graphics.UI.Gtk.ModelView.IconView,
  module Graphics.UI.Gtk.ModelView.ListStore,
  module Graphics.UI.Gtk.ModelView.TreeDrag,
  module Graphics.UI.Gtk.ModelView.TreeModel,
  module Graphics.UI.Gtk.ModelView.TreeModelSort,
  module Graphics.UI.Gtk.ModelView.TreeSortable,
  module Graphics.UI.Gtk.ModelView.TreeModelFilter,
  module Graphics.UI.Gtk.ModelView.TreeRowReference,
  module Graphics.UI.Gtk.ModelView.TreeSelection,
  module Graphics.UI.Gtk.ModelView.TreeStore,
  module Graphics.UI.Gtk.ModelView.TreeView,
  module Graphics.UI.Gtk.ModelView.TreeViewColumn,
  -- * Menus, combo box, toolbar
  module Graphics.UI.Gtk.MenuComboToolbar.CheckMenuItem,
  module Graphics.UI.Gtk.MenuComboToolbar.Combo,
  module Graphics.UI.Gtk.MenuComboToolbar.ComboBox,
  module Graphics.UI.Gtk.MenuComboToolbar.ComboBoxEntry,
  module Graphics.UI.Gtk.MenuComboToolbar.Menu,
  module Graphics.UI.Gtk.MenuComboToolbar.MenuBar,
  module Graphics.UI.Gtk.MenuComboToolbar.MenuItem,
  module Graphics.UI.Gtk.MenuComboToolbar.MenuShell,
  module Graphics.UI.Gtk.MenuComboToolbar.OptionMenu,
  module Graphics.UI.Gtk.MenuComboToolbar.ImageMenuItem,
  module Graphics.UI.Gtk.MenuComboToolbar.RadioMenuItem,
  module Graphics.UI.Gtk.MenuComboToolbar.TearoffMenuItem,
  module Graphics.UI.Gtk.MenuComboToolbar.Toolbar,
  module Graphics.UI.Gtk.MenuComboToolbar.ToolItem,
  module Graphics.UI.Gtk.MenuComboToolbar.ToolButton,
  module Graphics.UI.Gtk.MenuComboToolbar.MenuToolButton,
  module Graphics.UI.Gtk.MenuComboToolbar.ToggleToolButton,
  module Graphics.UI.Gtk.MenuComboToolbar.RadioToolButton,
  module Graphics.UI.Gtk.MenuComboToolbar.SeparatorMenuItem,
  module Graphics.UI.Gtk.MenuComboToolbar.SeparatorToolItem,
-- * Action-based menus and toolbars
  module Graphics.UI.Gtk.ActionMenuToolbar.Action,
  module Graphics.UI.Gtk.ActionMenuToolbar.ActionGroup,
  module Graphics.UI.Gtk.ActionMenuToolbar.ToggleAction,
  module Graphics.UI.Gtk.ActionMenuToolbar.RadioAction,
  module Graphics.UI.Gtk.ActionMenuToolbar.UIManager,
  -- * Selectors (file\/font\/color)
  module Graphics.UI.Gtk.Selectors.ColorSelection,
  module Graphics.UI.Gtk.Selectors.ColorSelectionDialog,
  module Graphics.UI.Gtk.Selectors.ColorButton,
  module Graphics.UI.Gtk.Selectors.FileSelection,
  module Graphics.UI.Gtk.Selectors.FontSelection,
  module Graphics.UI.Gtk.Selectors.FontSelectionDialog,
  module Graphics.UI.Gtk.Selectors.FontButton,
--  module InputDialog,
  -- ** File chooser
  module Graphics.UI.Gtk.Selectors.FileChooser,
  module Graphics.UI.Gtk.Selectors.FileChooserDialog,
  module Graphics.UI.Gtk.Selectors.FileChooserWidget,
  module Graphics.UI.Gtk.Selectors.FileChooserButton,
  module Graphics.UI.Gtk.Selectors.FileFilter,
  -- * Layout containers
  module Graphics.UI.Gtk.Layout.Alignment,
  module Graphics.UI.Gtk.Layout.AspectFrame,
  module Graphics.UI.Gtk.Layout.HBox,
  module Graphics.UI.Gtk.Layout.HButtonBox,
  module Graphics.UI.Gtk.Layout.Fixed,
  module Graphics.UI.Gtk.Layout.HPaned,
  module Graphics.UI.Gtk.Layout.Layout,
  module Graphics.UI.Gtk.Layout.Notebook,
  module Graphics.UI.Gtk.Layout.Expander,
  module Graphics.UI.Gtk.Layout.Table,
  module Graphics.UI.Gtk.Layout.VBox,
  module Graphics.UI.Gtk.Layout.VButtonBox,
  module Graphics.UI.Gtk.Layout.VPaned,
  -- * Ornaments
  module Graphics.UI.Gtk.Ornaments.Frame,
  module Graphics.UI.Gtk.Ornaments.HSeparator,
  module Graphics.UI.Gtk.Ornaments.VSeparator,
  -- * Scrolling
  module Graphics.UI.Gtk.Scrolling.HScrollbar,
  module Graphics.UI.Gtk.Scrolling.ScrolledWindow,
  module Graphics.UI.Gtk.Scrolling.VScrollbar,
  -- * Miscellaneous
  module Graphics.UI.Gtk.Misc.Adjustment,
  module Graphics.UI.Gtk.Misc.Arrow,
  module Graphics.UI.Gtk.Misc.Calendar,
  module Graphics.UI.Gtk.Misc.DrawingArea,
  module Graphics.UI.Gtk.Misc.EventBox,
  module Graphics.UI.Gtk.Misc.HandleBox,
  module Graphics.UI.Gtk.Misc.IMMulticontext,
  module Graphics.UI.Gtk.Misc.SizeGroup,
  module Graphics.UI.Gtk.Misc.Tooltips,
  module Graphics.UI.Gtk.Misc.Viewport,
  -- * Abstract base classes
  module Graphics.UI.Gtk.Abstract.Box,
  module Graphics.UI.Gtk.Abstract.ButtonBox,
  module Graphics.UI.Gtk.Abstract.Container,
  module Graphics.UI.Gtk.Abstract.Bin,
  module Graphics.UI.Gtk.Abstract.Misc,
  module Graphics.UI.Gtk.Abstract.IMContext,
  module Graphics.UI.Gtk.Abstract.Object,
  module Graphics.UI.Gtk.Abstract.Paned,
  module Graphics.UI.Gtk.Abstract.Range,
  module Graphics.UI.Gtk.Abstract.Scale,
  module Graphics.UI.Gtk.Abstract.Scrollbar,
  module Graphics.UI.Gtk.Abstract.Separator,
  module Graphics.UI.Gtk.Abstract.Widget,
  -- * Cross-process embedding
  module Graphics.UI.Gtk.Embedding.Plug,
  module Graphics.UI.Gtk.Embedding.Socket,
  -- * Non-widgets
  module System.Glib.Signals,
  module System.Glib.Attributes,
  module System.Glib.GObject,
  module Graphics.UI.Gtk.Builder,

  -- * Pango text layout modules
  module Graphics.Rendering.Pango.Context,
  module Graphics.Rendering.Pango.Markup,
  module Graphics.Rendering.Pango.Layout,
  module Graphics.Rendering.Pango.Rendering,
  module Graphics.Rendering.Pango.Font,
  module Graphics.Rendering.Pango.Enums
  ) where

-- general things, initialization
import Graphics.UI.Gtk.General.General
import Graphics.UI.Gtk.General.IconFactory
import Graphics.UI.Gtk.General.StockItems
import Graphics.UI.Gtk.General.Selection
import Graphics.UI.Gtk.General.Drag
import Graphics.UI.Gtk.General.Clipboard
-- drawing
import Graphics.UI.Gtk.Gdk.Keys
import Graphics.UI.Gtk.General.Style
import Graphics.UI.Gtk.General.RcStyle
import Graphics.UI.Gtk.Gdk.Cursor
import Graphics.UI.Gtk.Gdk.Drawable
import Graphics.UI.Gtk.Gdk.DrawWindow
import Graphics.UI.Gtk.Gdk.Region		hiding (makeNewRegion)
--import Graphics.UI.Gtk.Gdk.GC
import Graphics.UI.Gtk.Gdk.EventM
import Graphics.UI.Gtk.Gdk.Pixbuf
import Graphics.UI.Gtk.Gdk.Pixmap
import Graphics.UI.Gtk.Gdk.Screen
import Graphics.UI.Gtk.Gdk.Display
import Graphics.UI.Gtk.Gdk.Gdk
-- cairo integration
import Graphics.UI.Gtk.Cairo
-- windows
import Graphics.UI.Gtk.Windows.Dialog
import Graphics.UI.Gtk.Windows.Window
import Graphics.UI.Gtk.Windows.Invisible
import Graphics.UI.Gtk.Windows.AboutDialog
import Graphics.UI.Gtk.Windows.MessageDialog
import Graphics.UI.Gtk.Windows.WindowGroup
-- display widgets
import Graphics.UI.Gtk.Display.AccelLabel
import Graphics.UI.Gtk.Display.Image
import Graphics.UI.Gtk.Display.Label
import Graphics.UI.Gtk.Display.ProgressBar
import Graphics.UI.Gtk.Display.Statusbar
#if GTK_CHECK_VERSION(2,10,0) && !DISABLE_DEPRECATED
import Graphics.UI.Gtk.Display.StatusIcon hiding (onActivate,afterActivate,onPopupMenu,afterPopupMenu)
#else
import Graphics.UI.Gtk.Display.StatusIcon
#endif
-- buttons and toggles
import Graphics.UI.Gtk.Buttons.Button
import Graphics.UI.Gtk.Buttons.CheckButton
import Graphics.UI.Gtk.Buttons.RadioButton
import Graphics.UI.Gtk.Buttons.ToggleButton
-- numeric\/text data entry
import Graphics.UI.Gtk.Entry.Editable
import Graphics.UI.Gtk.Entry.Entry
import Graphics.UI.Gtk.Entry.EntryCompletion
import Graphics.UI.Gtk.Entry.HScale
import Graphics.UI.Gtk.Entry.VScale
import Graphics.UI.Gtk.Entry.SpinButton
-- multiline text editor
import Graphics.UI.Gtk.Multiline.TextIter
import Graphics.UI.Gtk.Multiline.TextMark
import Graphics.UI.Gtk.Multiline.TextBuffer
import Graphics.UI.Gtk.Multiline.TextTag
import Graphics.UI.Gtk.Multiline.TextTagTable
import qualified Graphics.UI.Gtk.Multiline.TextView
import Graphics.UI.Gtk.Multiline.TextView
-- tree and list widget
import Graphics.UI.Gtk.ModelView.CellLayout
import Graphics.UI.Gtk.ModelView.CellRenderer
import Graphics.UI.Gtk.ModelView.CellRendererCombo
import Graphics.UI.Gtk.ModelView.CellRendererPixbuf
import Graphics.UI.Gtk.ModelView.CellRendererProgress
import Graphics.UI.Gtk.ModelView.CellRendererText
import Graphics.UI.Gtk.ModelView.CellRendererToggle
import Graphics.UI.Gtk.ModelView.CellView
import Graphics.UI.Gtk.ModelView.CustomStore
import Graphics.UI.Gtk.ModelView.IconView
import Graphics.UI.Gtk.ModelView.ListStore
import Graphics.UI.Gtk.ModelView.TreeDrag
import Graphics.UI.Gtk.ModelView.TreeModel
import Graphics.UI.Gtk.ModelView.TreeModelSort
import Graphics.UI.Gtk.ModelView.TreeSortable
import Graphics.UI.Gtk.ModelView.TreeModelFilter
import Graphics.UI.Gtk.ModelView.TreeRowReference
import Graphics.UI.Gtk.ModelView.TreeSelection
import Graphics.UI.Gtk.ModelView.TreeStore
import Graphics.UI.Gtk.ModelView.TreeView
import Graphics.UI.Gtk.ModelView.TreeViewColumn
-- menus, combo box, toolbar
import Graphics.UI.Gtk.MenuComboToolbar.Combo
import Graphics.UI.Gtk.MenuComboToolbar.ComboBox
import Graphics.UI.Gtk.MenuComboToolbar.ComboBoxEntry
-- import ItemFactory
import Graphics.UI.Gtk.MenuComboToolbar.Menu
import Graphics.UI.Gtk.MenuComboToolbar.MenuBar
import Graphics.UI.Gtk.MenuComboToolbar.MenuItem
import Graphics.UI.Gtk.MenuComboToolbar.MenuShell
import Graphics.UI.Gtk.MenuComboToolbar.OptionMenu
import Graphics.UI.Gtk.MenuComboToolbar.ImageMenuItem
import Graphics.UI.Gtk.MenuComboToolbar.RadioMenuItem
import Graphics.UI.Gtk.MenuComboToolbar.CheckMenuItem
import Graphics.UI.Gtk.MenuComboToolbar.TearoffMenuItem
import Graphics.UI.Gtk.MenuComboToolbar.Toolbar
import Graphics.UI.Gtk.MenuComboToolbar.ToolItem
import Graphics.UI.Gtk.MenuComboToolbar.ToolButton
import Graphics.UI.Gtk.MenuComboToolbar.MenuToolButton
import Graphics.UI.Gtk.MenuComboToolbar.ToggleToolButton
import Graphics.UI.Gtk.MenuComboToolbar.RadioToolButton
import Graphics.UI.Gtk.MenuComboToolbar.SeparatorMenuItem
import Graphics.UI.Gtk.MenuComboToolbar.SeparatorToolItem
-- action based menus and toolbars
import Graphics.UI.Gtk.ActionMenuToolbar.Action
import Graphics.UI.Gtk.ActionMenuToolbar.ActionGroup
import Graphics.UI.Gtk.ActionMenuToolbar.ToggleAction
import Graphics.UI.Gtk.ActionMenuToolbar.RadioAction
import Graphics.UI.Gtk.ActionMenuToolbar.UIManager
-- selectors (file\/font\/color\/input device)
import Graphics.UI.Gtk.Selectors.ColorSelection
import Graphics.UI.Gtk.Selectors.ColorSelectionDialog
import Graphics.UI.Gtk.Selectors.ColorButton
import Graphics.UI.Gtk.Selectors.FileSelection
import Graphics.UI.Gtk.Selectors.FileChooser
import Graphics.UI.Gtk.Selectors.FileChooserDialog
import Graphics.UI.Gtk.Selectors.FileChooserWidget
import Graphics.UI.Gtk.Selectors.FileChooserButton
import Graphics.UI.Gtk.Selectors.FileFilter
import Graphics.UI.Gtk.Selectors.FontSelection
import Graphics.UI.Gtk.Selectors.FontSelectionDialog
import Graphics.UI.Gtk.Selectors.FontButton
--import InputDialog
-- layout containers
import Graphics.UI.Gtk.Layout.Alignment
import Graphics.UI.Gtk.Layout.AspectFrame
import Graphics.UI.Gtk.Layout.HBox
import Graphics.UI.Gtk.Layout.VBox
import Graphics.UI.Gtk.Layout.HButtonBox
import Graphics.UI.Gtk.Layout.VButtonBox
import Graphics.UI.Gtk.Layout.Fixed
import Graphics.UI.Gtk.Layout.HPaned
import Graphics.UI.Gtk.Layout.VPaned
import Graphics.UI.Gtk.Layout.Layout
import Graphics.UI.Gtk.Layout.Notebook
import Graphics.UI.Gtk.Layout.Expander
import Graphics.UI.Gtk.Layout.Table
-- ornaments
import Graphics.UI.Gtk.Ornaments.Frame
import Graphics.UI.Gtk.Ornaments.HSeparator
import Graphics.UI.Gtk.Ornaments.VSeparator
-- scrolling
import Graphics.UI.Gtk.Scrolling.HScrollbar
import Graphics.UI.Gtk.Scrolling.VScrollbar
import Graphics.UI.Gtk.Scrolling.ScrolledWindow
-- miscellaneous
import Graphics.UI.Gtk.Misc.Adjustment
import Graphics.UI.Gtk.Misc.Arrow
import Graphics.UI.Gtk.Misc.Calendar
import Graphics.UI.Gtk.Misc.DrawingArea
import Graphics.UI.Gtk.Misc.EventBox
import Graphics.UI.Gtk.Misc.HandleBox
import Graphics.UI.Gtk.Misc.IMMulticontext
import Graphics.UI.Gtk.Misc.SizeGroup
import Graphics.UI.Gtk.Misc.Tooltips
import Graphics.UI.Gtk.Misc.Viewport
--import Accessible
-- abstract base classes
import Graphics.UI.Gtk.Abstract.Box
import Graphics.UI.Gtk.Abstract.ButtonBox
import Graphics.UI.Gtk.Abstract.Container
import Graphics.UI.Gtk.Abstract.Bin
import Graphics.UI.Gtk.Abstract.Misc
import Graphics.UI.Gtk.Abstract.IMContext
import Graphics.UI.Gtk.Abstract.Object (
  Object,
  ObjectClass,
  castToObject,
  toObject,
  GWeakNotify,
  objectWeakref,
  objectWeakunref,
  objectDestroy )
import Graphics.UI.Gtk.Abstract.Paned
import Graphics.UI.Gtk.Abstract.Range
import Graphics.UI.Gtk.Abstract.Scale
import Graphics.UI.Gtk.Abstract.Scrollbar
import Graphics.UI.Gtk.Abstract.Separator
import Graphics.UI.Gtk.Abstract.Widget
-- cross-process embedding
import Graphics.UI.Gtk.Embedding.Plug
import Graphics.UI.Gtk.Embedding.Socket

-- non widgets
import System.Glib.Signals
{- do eport 'on' and 'after'
		(ConnectId, disconnect,
					 signalDisconnect,
					 signalBlock,
					 signalUnblock)
-}
import System.Glib.Attributes
import System.Glib.GObject (
  GObject,
  GObjectClass,
  toGObject,
  castToGObject,
  quarkFromString,
  objectCreateAttribute,
  objectSetAttribute,
  objectGetAttributeUnsafe,
  isA
  )
import Graphics.UI.Gtk.Builder

-- pango modules
import Graphics.Rendering.Pango.Context
import Graphics.Rendering.Pango.Markup
import Graphics.Rendering.Pango.Layout
import Graphics.Rendering.Pango.Rendering
import Graphics.Rendering.Pango.Font
import Graphics.Rendering.Pango.Enums

{-# LANGUAGE CPP #-}
-- -*-haskell-*-
--  GIMP Toolkit (GTK)
--
--  Author : Axel Simon
--
--  Created: 9 April 2001
--
--  Copyright (C) 2001-2005 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.
--
-- Everything that is marked as deprecated, vanishing or useless for
--   applications is not bound.
--
-- The following modules are not bound:
--   DialogMessage : has only one variadic function which cannot be bound.
--		     The same functionality can be simulated with Dialog.
--   Item :	     The only child of this abstract class is MenuItem. The
--		     three signals Item defines are therefore bound in
--		     MenuItem.
--
-- TODO
--
-- Every module that is commented out and not mentioned above.
--
-- |
-- Maintainer  : gtk2hs-users@lists.sourceforge.net
-- Stability   : provisional
-- Portability : portable (depends on GHC)
--
-- This module gathers all publicly available functions from the Gtk binding.
--
module Graphics.UI.Gtk (
  -- * General things, initialization
  module Graphics.UI.Gtk.General.General,
  module Graphics.UI.Gtk.General.IconFactory,
  module Graphics.UI.Gtk.General.StockItems,
  module Graphics.UI.Gtk.General.Selection,
  module Graphics.UI.Gtk.General.Drag,
  module Graphics.UI.Gtk.Gdk.Keys,
  module Graphics.UI.Gtk.General.Style,
  module Graphics.UI.Gtk.General.RcStyle,
  module Graphics.UI.Gtk.General.Clipboard,

  -- * Drawing and other Low-Level Operations
  module Graphics.UI.Gtk.Gdk.Cursor,
  module Graphics.UI.Gtk.Gdk.Drawable,
  module Graphics.UI.Gtk.Gdk.DrawWindow,
  module Graphics.UI.Gtk.Gdk.Region,
--  module Graphics.UI.Gtk.Gdk.GC,
  module Graphics.UI.Gtk.Gdk.EventM,
  module Graphics.UI.Gtk.Gdk.Pixbuf,
  module Graphics.UI.Gtk.Gdk.Pixmap,
  module Graphics.UI.Gtk.Gdk.Screen,
  module Graphics.UI.Gtk.Gdk.Display,
  module Graphics.UI.Gtk.Gdk.Gdk,
  -- ** cairo integration
  module Graphics.UI.Gtk.Cairo,
  -- * Windows
  module Graphics.UI.Gtk.Windows.Window,
  module Graphics.UI.Gtk.Windows.Invisible,
  module Graphics.UI.Gtk.Windows.Dialog,
  module Graphics.UI.Gtk.Windows.AboutDialog,
  module Graphics.UI.Gtk.Windows.MessageDialog,
  module Graphics.UI.Gtk.Windows.WindowGroup,
  -- * Display widgets,
  module Graphics.UI.Gtk.Display.AccelLabel,
  module Graphics.UI.Gtk.Display.Image,
  module Graphics.UI.Gtk.Display.Label,
  module Graphics.UI.Gtk.Display.ProgressBar,
  module Graphics.UI.Gtk.Display.Statusbar,
  module Graphics.UI.Gtk.Display.StatusIcon,
  -- * Buttons and toggles
  module Graphics.UI.Gtk.Buttons.Button,
  module Graphics.UI.Gtk.Buttons.CheckButton,
  module Graphics.UI.Gtk.Buttons.RadioButton,
  module Graphics.UI.Gtk.Buttons.ToggleButton,
  -- * Numeric\/text data entry
  module Graphics.UI.Gtk.Entry.Editable,
  module Graphics.UI.Gtk.Entry.Entry,
  module Graphics.UI.Gtk.Entry.EntryCompletion,
  module Graphics.UI.Gtk.Entry.HScale,
  module Graphics.UI.Gtk.Entry.VScale,
  module Graphics.UI.Gtk.Entry.SpinButton,
  -- * Multiline text editor
  module Graphics.UI.Gtk.Multiline.TextIter,
  module Graphics.UI.Gtk.Multiline.TextMark,
  module Graphics.UI.Gtk.Multiline.TextBuffer,
  module Graphics.UI.Gtk.Multiline.TextTag,
  module Graphics.UI.Gtk.Multiline.TextTagTable,
  module Graphics.UI.Gtk.Multiline.TextView,
  -- * Tree and list widget
  module Graphics.UI.Gtk.ModelView.CellLayout,
  module Graphics.UI.Gtk.ModelView.CellRenderer,
  module Graphics.UI.Gtk.ModelView.CellRendererCombo,
  module Graphics.UI.Gtk.ModelView.CellRendererPixbuf,
  module Graphics.UI.Gtk.ModelView.CellRendererProgress,
  module Graphics.UI.Gtk.ModelView.CellRendererText,
  module Graphics.UI.Gtk.ModelView.CellRendererToggle,
  module Graphics.UI.Gtk.ModelView.CellView,
  module Graphics.UI.Gtk.ModelView.CustomStore,
  module Graphics.UI.Gtk.ModelView.IconView,
  module Graphics.UI.Gtk.ModelView.ListStore,
  module Graphics.UI.Gtk.ModelView.TreeDrag,
  module Graphics.UI.Gtk.ModelView.TreeModel,
  module Graphics.UI.Gtk.ModelView.TreeModelSort,
  module Graphics.UI.Gtk.ModelView.TreeSortable,
  module Graphics.UI.Gtk.ModelView.TreeModelFilter,
  module Graphics.UI.Gtk.ModelView.TreeRowReference,
  module Graphics.UI.Gtk.ModelView.TreeSelection,
  module Graphics.UI.Gtk.ModelView.TreeStore,
  module Graphics.UI.Gtk.ModelView.TreeView,
  module Graphics.UI.Gtk.ModelView.TreeViewColumn,
  -- * Menus, combo box, toolbar
  module Graphics.UI.Gtk.MenuComboToolbar.CheckMenuItem,
  module Graphics.UI.Gtk.MenuComboToolbar.Combo,
  module Graphics.UI.Gtk.MenuComboToolbar.ComboBox,
  module Graphics.UI.Gtk.MenuComboToolbar.ComboBoxEntry,
  module Graphics.UI.Gtk.MenuComboToolbar.Menu,
  module Graphics.UI.Gtk.MenuComboToolbar.MenuBar,
  module Graphics.UI.Gtk.MenuComboToolbar.MenuItem,
  module Graphics.UI.Gtk.MenuComboToolbar.MenuShell,
  module Graphics.UI.Gtk.MenuComboToolbar.OptionMenu,
  module Graphics.UI.Gtk.MenuComboToolbar.ImageMenuItem,
  module Graphics.UI.Gtk.MenuComboToolbar.RadioMenuItem,
  module Graphics.UI.Gtk.MenuComboToolbar.TearoffMenuItem,
  module Graphics.UI.Gtk.MenuComboToolbar.Toolbar,
  module Graphics.UI.Gtk.MenuComboToolbar.ToolItem,
  module Graphics.UI.Gtk.MenuComboToolbar.ToolButton,
  module Graphics.UI.Gtk.MenuComboToolbar.MenuToolButton,
  module Graphics.UI.Gtk.MenuComboToolbar.ToggleToolButton,
  module Graphics.UI.Gtk.MenuComboToolbar.RadioToolButton,
  module Graphics.UI.Gtk.MenuComboToolbar.SeparatorMenuItem,
  module Graphics.UI.Gtk.MenuComboToolbar.SeparatorToolItem,
-- * Action-based menus and toolbars
  module Graphics.UI.Gtk.ActionMenuToolbar.Action,
  module Graphics.UI.Gtk.ActionMenuToolbar.ActionGroup,
  module Graphics.UI.Gtk.ActionMenuToolbar.ToggleAction,
  module Graphics.UI.Gtk.ActionMenuToolbar.RadioAction,
  module Graphics.UI.Gtk.ActionMenuToolbar.UIManager,
  -- * Selectors (file\/font\/color)
  module Graphics.UI.Gtk.Selectors.ColorSelection,
  module Graphics.UI.Gtk.Selectors.ColorSelectionDialog,
  module Graphics.UI.Gtk.Selectors.ColorButton,
  module Graphics.UI.Gtk.Selectors.FileSelection,
  module Graphics.UI.Gtk.Selectors.FontSelection,
  module Graphics.UI.Gtk.Selectors.FontSelectionDialog,
  module Graphics.UI.Gtk.Selectors.FontButton,
--  module InputDialog,
  -- ** File chooser
  module Graphics.UI.Gtk.Selectors.FileChooser,
  module Graphics.UI.Gtk.Selectors.FileChooserDialog,
  module Graphics.UI.Gtk.Selectors.FileChooserWidget,
  module Graphics.UI.Gtk.Selectors.FileChooserButton,
  module Graphics.UI.Gtk.Selectors.FileFilter,
  -- * Layout containers
  module Graphics.UI.Gtk.Layout.Alignment,
  module Graphics.UI.Gtk.Layout.AspectFrame,
  module Graphics.UI.Gtk.Layout.HBox,
  module Graphics.UI.Gtk.Layout.HButtonBox,
  module Graphics.UI.Gtk.Layout.Fixed,
  module Graphics.UI.Gtk.Layout.HPaned,
  module Graphics.UI.Gtk.Layout.Layout,
  module Graphics.UI.Gtk.Layout.Notebook,
  module Graphics.UI.Gtk.Layout.Expander,
  module Graphics.UI.Gtk.Layout.Table,
  module Graphics.UI.Gtk.Layout.VBox,
  module Graphics.UI.Gtk.Layout.VButtonBox,
  module Graphics.UI.Gtk.Layout.VPaned,
  -- * Ornaments
  module Graphics.UI.Gtk.Ornaments.Frame,
  module Graphics.UI.Gtk.Ornaments.HSeparator,
  module Graphics.UI.Gtk.Ornaments.VSeparator,
  -- * Scrolling
  module Graphics.UI.Gtk.Scrolling.HScrollbar,
  module Graphics.UI.Gtk.Scrolling.ScrolledWindow,
  module Graphics.UI.Gtk.Scrolling.VScrollbar,
  -- * Miscellaneous
  module Graphics.UI.Gtk.Misc.Adjustment,
  module Graphics.UI.Gtk.Misc.Arrow,
  module Graphics.UI.Gtk.Misc.Calendar,
  module Graphics.UI.Gtk.Misc.DrawingArea,
  module Graphics.UI.Gtk.Misc.EventBox,
  module Graphics.UI.Gtk.Misc.HandleBox,
  module Graphics.UI.Gtk.Misc.IMMulticontext,
  module Graphics.UI.Gtk.Misc.SizeGroup,
  module Graphics.UI.Gtk.Misc.Tooltips,
  module Graphics.UI.Gtk.Misc.Viewport,
  -- * Abstract base classes
  module Graphics.UI.Gtk.Abstract.Box,
  module Graphics.UI.Gtk.Abstract.ButtonBox,
  module Graphics.UI.Gtk.Abstract.Container,
  module Graphics.UI.Gtk.Abstract.Bin,
  module Graphics.UI.Gtk.Abstract.Misc,
  module Graphics.UI.Gtk.Abstract.IMContext,
  module Graphics.UI.Gtk.Abstract.Object,
  module Graphics.UI.Gtk.Abstract.Paned,
  module Graphics.UI.Gtk.Abstract.Range,
  module Graphics.UI.Gtk.Abstract.Scale,
  module Graphics.UI.Gtk.Abstract.Scrollbar,
  module Graphics.UI.Gtk.Abstract.Separator,
  module Graphics.UI.Gtk.Abstract.Widget,
  -- * Cross-process embedding
  module Graphics.UI.Gtk.Embedding.Plug,
  module Graphics.UI.Gtk.Embedding.Socket,
  -- * Non-widgets
  module System.Glib.Signals,
  module System.Glib.Attributes,
  module System.Glib.GObject,
  module Graphics.UI.Gtk.Builder,

  -- * Pango text layout modules
  module Graphics.Rendering.Pango.Context,
  module Graphics.Rendering.Pango.Markup,
  module Graphics.Rendering.Pango.Layout,
  module Graphics.Rendering.Pango.Rendering,
  module Graphics.Rendering.Pango.Font,
  module Graphics.Rendering.Pango.Enums
  ) where

-- general things, initialization
import Graphics.UI.Gtk.General.General
import Graphics.UI.Gtk.General.IconFactory
import Graphics.UI.Gtk.General.StockItems
import Graphics.UI.Gtk.General.Selection
import Graphics.UI.Gtk.General.Drag
import Graphics.UI.Gtk.General.Clipboard
-- drawing
import Graphics.UI.Gtk.Gdk.Keys
import Graphics.UI.Gtk.General.Style
import Graphics.UI.Gtk.General.RcStyle
import Graphics.UI.Gtk.Gdk.Cursor
import Graphics.UI.Gtk.Gdk.Drawable
import Graphics.UI.Gtk.Gdk.DrawWindow
import Graphics.UI.Gtk.Gdk.Region		hiding (makeNewRegion)
--import Graphics.UI.Gtk.Gdk.GC
import Graphics.UI.Gtk.Gdk.EventM
import Graphics.UI.Gtk.Gdk.Pixbuf
import Graphics.UI.Gtk.Gdk.Pixmap
import Graphics.UI.Gtk.Gdk.Screen
import Graphics.UI.Gtk.Gdk.Display
import Graphics.UI.Gtk.Gdk.Gdk
-- cairo integration
import Graphics.UI.Gtk.Cairo
-- windows
import Graphics.UI.Gtk.Windows.Dialog
import Graphics.UI.Gtk.Windows.Window
import Graphics.UI.Gtk.Windows.Invisible
import Graphics.UI.Gtk.Windows.AboutDialog
import Graphics.UI.Gtk.Windows.MessageDialog
import Graphics.UI.Gtk.Windows.WindowGroup
-- display widgets
import Graphics.UI.Gtk.Display.AccelLabel
import Graphics.UI.Gtk.Display.Image
import Graphics.UI.Gtk.Display.Label
import Graphics.UI.Gtk.Display.ProgressBar
import Graphics.UI.Gtk.Display.Statusbar
#if GTK_CHECK_VERSION(2,10,0) && !DISABLE_DEPRECATED
import Graphics.UI.Gtk.Display.StatusIcon hiding (onActivate,afterActivate,onPopupMenu,afterPopupMenu)
#else
import Graphics.UI.Gtk.Display.StatusIcon
#endif
-- buttons and toggles
import Graphics.UI.Gtk.Buttons.Button
import Graphics.UI.Gtk.Buttons.CheckButton
import Graphics.UI.Gtk.Buttons.RadioButton
import Graphics.UI.Gtk.Buttons.ToggleButton
-- numeric\/text data entry
import Graphics.UI.Gtk.Entry.Editable
import Graphics.UI.Gtk.Entry.Entry
import Graphics.UI.Gtk.Entry.EntryCompletion
import Graphics.UI.Gtk.Entry.HScale
import Graphics.UI.Gtk.Entry.VScale
import Graphics.UI.Gtk.Entry.SpinButton
-- multiline text editor
import Graphics.UI.Gtk.Multiline.TextIter
import Graphics.UI.Gtk.Multiline.TextMark
import Graphics.UI.Gtk.Multiline.TextBuffer
import Graphics.UI.Gtk.Multiline.TextTag
import Graphics.UI.Gtk.Multiline.TextTagTable
import qualified Graphics.UI.Gtk.Multiline.TextView
import Graphics.UI.Gtk.Multiline.TextView
#ifndef DISABLE_DEPRECATED
        hiding (afterSetScrollAdjustments,
		onSetScrollAdjustments, afterCopyClipboard, onCopyClipboard,
		afterCutClipboard, onCutClipboard, afterInsertAtCursor,
		onInsertAtCursor, afterPasteClipboard, onPasteClipboard,
		afterToggleOverwrite, onToggleOverwrite, setScrollAdjustments)
#endif
-- tree and list widget
import Graphics.UI.Gtk.ModelView.CellLayout
import Graphics.UI.Gtk.ModelView.CellRenderer
import Graphics.UI.Gtk.ModelView.CellRendererCombo
import Graphics.UI.Gtk.ModelView.CellRendererPixbuf
import Graphics.UI.Gtk.ModelView.CellRendererProgress
import Graphics.UI.Gtk.ModelView.CellRendererText
import Graphics.UI.Gtk.ModelView.CellRendererToggle
import Graphics.UI.Gtk.ModelView.CellView
import Graphics.UI.Gtk.ModelView.CustomStore
import Graphics.UI.Gtk.ModelView.IconView
import Graphics.UI.Gtk.ModelView.ListStore
import Graphics.UI.Gtk.ModelView.TreeDrag
import Graphics.UI.Gtk.ModelView.TreeModel
import Graphics.UI.Gtk.ModelView.TreeModelSort
import Graphics.UI.Gtk.ModelView.TreeSortable
import Graphics.UI.Gtk.ModelView.TreeModelFilter
import Graphics.UI.Gtk.ModelView.TreeRowReference
import Graphics.UI.Gtk.ModelView.TreeSelection
import Graphics.UI.Gtk.ModelView.TreeStore
import Graphics.UI.Gtk.ModelView.TreeView
import Graphics.UI.Gtk.ModelView.TreeViewColumn
-- menus, combo box, toolbar
import Graphics.UI.Gtk.MenuComboToolbar.Combo
import Graphics.UI.Gtk.MenuComboToolbar.ComboBox
import Graphics.UI.Gtk.MenuComboToolbar.ComboBoxEntry
-- import ItemFactory
import Graphics.UI.Gtk.MenuComboToolbar.Menu
import Graphics.UI.Gtk.MenuComboToolbar.MenuBar
import Graphics.UI.Gtk.MenuComboToolbar.MenuItem
import Graphics.UI.Gtk.MenuComboToolbar.MenuShell
import Graphics.UI.Gtk.MenuComboToolbar.OptionMenu
import Graphics.UI.Gtk.MenuComboToolbar.ImageMenuItem
import Graphics.UI.Gtk.MenuComboToolbar.RadioMenuItem
import Graphics.UI.Gtk.MenuComboToolbar.CheckMenuItem
import Graphics.UI.Gtk.MenuComboToolbar.TearoffMenuItem
import Graphics.UI.Gtk.MenuComboToolbar.Toolbar
import Graphics.UI.Gtk.MenuComboToolbar.ToolItem
import Graphics.UI.Gtk.MenuComboToolbar.ToolButton
import Graphics.UI.Gtk.MenuComboToolbar.MenuToolButton
import Graphics.UI.Gtk.MenuComboToolbar.ToggleToolButton
import Graphics.UI.Gtk.MenuComboToolbar.RadioToolButton
import Graphics.UI.Gtk.MenuComboToolbar.SeparatorMenuItem
import Graphics.UI.Gtk.MenuComboToolbar.SeparatorToolItem
-- action based menus and toolbars
import Graphics.UI.Gtk.ActionMenuToolbar.Action
import Graphics.UI.Gtk.ActionMenuToolbar.ActionGroup
import Graphics.UI.Gtk.ActionMenuToolbar.ToggleAction
import Graphics.UI.Gtk.ActionMenuToolbar.RadioAction
import Graphics.UI.Gtk.ActionMenuToolbar.UIManager
-- selectors (file\/font\/color\/input device)
import Graphics.UI.Gtk.Selectors.ColorSelection
import Graphics.UI.Gtk.Selectors.ColorSelectionDialog
import Graphics.UI.Gtk.Selectors.ColorButton
import Graphics.UI.Gtk.Selectors.FileSelection
import Graphics.UI.Gtk.Selectors.FileChooser
import Graphics.UI.Gtk.Selectors.FileChooserDialog
import Graphics.UI.Gtk.Selectors.FileChooserWidget
import Graphics.UI.Gtk.Selectors.FileChooserButton
import Graphics.UI.Gtk.Selectors.FileFilter
import Graphics.UI.Gtk.Selectors.FontSelection
import Graphics.UI.Gtk.Selectors.FontSelectionDialog
import Graphics.UI.Gtk.Selectors.FontButton
--import InputDialog
-- layout containers
import Graphics.UI.Gtk.Layout.Alignment
import Graphics.UI.Gtk.Layout.AspectFrame
import Graphics.UI.Gtk.Layout.HBox
import Graphics.UI.Gtk.Layout.VBox
import Graphics.UI.Gtk.Layout.HButtonBox
import Graphics.UI.Gtk.Layout.VButtonBox
import Graphics.UI.Gtk.Layout.Fixed
import Graphics.UI.Gtk.Layout.HPaned
import Graphics.UI.Gtk.Layout.VPaned
import Graphics.UI.Gtk.Layout.Layout
import Graphics.UI.Gtk.Layout.Notebook
import Graphics.UI.Gtk.Layout.Expander
import Graphics.UI.Gtk.Layout.Table
-- ornaments
import Graphics.UI.Gtk.Ornaments.Frame
import Graphics.UI.Gtk.Ornaments.HSeparator
import Graphics.UI.Gtk.Ornaments.VSeparator
-- scrolling
import Graphics.UI.Gtk.Scrolling.HScrollbar
import Graphics.UI.Gtk.Scrolling.VScrollbar
import Graphics.UI.Gtk.Scrolling.ScrolledWindow
-- miscellaneous
import Graphics.UI.Gtk.Misc.Adjustment
import Graphics.UI.Gtk.Misc.Arrow
import Graphics.UI.Gtk.Misc.Calendar
import Graphics.UI.Gtk.Misc.DrawingArea
import Graphics.UI.Gtk.Misc.EventBox
import Graphics.UI.Gtk.Misc.HandleBox
import Graphics.UI.Gtk.Misc.IMMulticontext
import Graphics.UI.Gtk.Misc.SizeGroup
import Graphics.UI.Gtk.Misc.Tooltips
import Graphics.UI.Gtk.Misc.Viewport
--import Accessible
-- abstract base classes
import Graphics.UI.Gtk.Abstract.Box
import Graphics.UI.Gtk.Abstract.ButtonBox
import Graphics.UI.Gtk.Abstract.Container
import Graphics.UI.Gtk.Abstract.Bin
import Graphics.UI.Gtk.Abstract.Misc
import Graphics.UI.Gtk.Abstract.IMContext
import Graphics.UI.Gtk.Abstract.Object (
  Object,
  ObjectClass,
  castToObject,
  toObject,
  GWeakNotify,
  objectWeakref,
  objectWeakunref,
  objectDestroy )
import Graphics.UI.Gtk.Abstract.Paned
import Graphics.UI.Gtk.Abstract.Range
import Graphics.UI.Gtk.Abstract.Scale
import Graphics.UI.Gtk.Abstract.Scrollbar
import Graphics.UI.Gtk.Abstract.Separator
import Graphics.UI.Gtk.Abstract.Widget
-- cross-process embedding
import Graphics.UI.Gtk.Embedding.Plug
import Graphics.UI.Gtk.Embedding.Socket

-- non widgets
import System.Glib.Signals
{- do eport 'on' and 'after'
		(ConnectId, disconnect,
					 signalDisconnect,
					 signalBlock,
					 signalUnblock)
-}
import System.Glib.Attributes
import System.Glib.GObject (
  GObject,
  GObjectClass,
  toGObject,
  castToGObject,
  quarkFromString,
  objectCreateAttribute,
  objectSetAttribute,
  objectGetAttributeUnsafe,
  isA
  )
import Graphics.UI.Gtk.Builder

-- pango modules
import Graphics.Rendering.Pango.Context
import Graphics.Rendering.Pango.Markup
import Graphics.Rendering.Pango.Layout
import Graphics.Rendering.Pango.Rendering
import Graphics.Rendering.Pango.Font
import Graphics.Rendering.Pango.Enums