File: Types.chs

package info (click to toggle)
haskell-gtk 0.11.0-5
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 2,920 kB
  • ctags: 82
  • sloc: haskell: 1,929; ansic: 714; sh: 5; makefile: 3
file content (67 lines) | stat: -rw-r--r-- 1,812 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
{-# LANGUAGE CPP #-}
{-# OPTIONS_HADDOCK hide #-}
-- -*-haskell-*-
--  GIMP Toolkit (GTK) Multiline internal types
--
--  Author : Axel Simon
--
--  Created: 2 March 2006
--
--  Copyright (C) 2002-2006 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.
--
-- #hide
module Graphics.UI.Gtk.Multiline.Types (

-- * Types
  TextIter(TextIter),

-- * Methods
  textIterCopy,
  mkTextIterCopy,
  makeEmptyTextIter
  ) where

import System.Glib.FFI
import Graphics.UI.Gtk.General.Structs	(textIterSize)

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

-- methods

{#pointer *TextIter foreign newtype #}

-- | Copy the iterator.
--
textIterCopy :: TextIter -> IO TextIter
textIterCopy (TextIter iter) = do
  iter' <- mallocForeignPtrBytes textIterSize
  withForeignPtr iter' $ \iterPtr' ->
    withForeignPtr iter $ \iterPtr ->
      copyBytes iterPtr' iterPtr textIterSize
  return (TextIter iter')

-- | Interal marshaling util
--
mkTextIterCopy :: Ptr TextIter -> IO TextIter
mkTextIterCopy iterPtr = do
  iter' <- mallocForeignPtrBytes textIterSize
  withForeignPtr iter' $ \iterPtr' ->
    copyBytes iterPtr' iterPtr textIterSize
  return (TextIter iter')

-- | Allocate memory to be filled with a TextIter.
--
makeEmptyTextIter :: IO TextIter
makeEmptyTextIter = do
  iter <- mallocForeignPtrBytes textIterSize
  return (TextIter iter)