    {-# LINE 2 "./Graphics/UI/Gtk/Multiline/TextTagTable.chs" #-}
    -- -*-haskell-*-
    -- GIMP Toolkit (GTK) Widget TextTagTable
    --
    -- Author : Duncan Coutts
    --
    -- Created: 4 August 2004
    --
    -- Copyright (C) 2004-2005 Duncan Coutts
    --
    -- 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)
    --
    -- Collection of tags that can be used together
    --
    module Graphics.UI.Gtk.Multiline.TextTagTable (
    -- * Detail
    --
    -- | You may wish to begin by reading the text widget conceptual overview
    -- which gives an overview of all the objects and data types related to the
    -- text widget and how they work together.

    -- * Class Hierarchy
    -- |
    -- @
    -- | 'GObject'
    -- | +----TextTagTable
    -- @

    -- * Types
      TextTagTable,
      TextTagTableClass,
      castToTextTagTable, gTypeTextTagTable,
      toTextTagTable,

    -- * Constructors
      textTagTableNew,

    -- * Methods
      textTagTableAdd,
      textTagTableRemove,
      textTagTableLookup,
      textTagTableForeach,
      textTagTableGetSize
      ) where

    import Control.Monad (liftM, void)

    import System.Glib.FFI (withForeignPtr, nullPtr, Ptr(..), CInt(..), CChar(..), FunPtr(..), maybeNull)
    import System.Glib.UTFString
    import Graphics.UI.Gtk.Types
    {-# LINE 64 "./Graphics/UI/Gtk/Multiline/TextTagTable.chs" #-}

    {-# LINE 66 "./Graphics/UI/Gtk/Multiline/TextTagTable.chs" #-}

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

    -- | Creates a new 'TextTagTable'. The table contains no tags by default.
    --
    textTagTableNew :: IO TextTagTable
    textTagTableNew :: IO TextTagTable
    textTagTableNew =
      (ForeignPtr TextTagTable -> TextTagTable,
     FinalizerPtr TextTagTable)
    -> IO (Ptr TextTagTable) -> IO TextTagTable
    forall obj.
    GObjectClass obj =>
    (ForeignPtr obj -> obj, FinalizerPtr obj) -> IO (Ptr obj) -> IO obj
    wrapNewGObject (ForeignPtr TextTagTable -> TextTagTable,
     FinalizerPtr TextTagTable)
    forall {a}.
    (ForeignPtr TextTagTable -> TextTagTable, FinalizerPtr a)
    mkTextTagTable (IO (Ptr TextTagTable) -> IO TextTagTable)
    -> IO (Ptr TextTagTable) -> IO TextTagTable
    forall a b. (a -> b) -> a -> b
    $
      IO (Ptr TextTagTable)
    gtk_text_tag_table_new
    {-# LINE 76 "./Graphics/UI/Gtk/Multiline/TextTagTable.chs" #-}

    --------------------
    -- Methods

    -- | Add a tag to the table. The tag is assigned the highest priority in the
    -- table.
    --
    -- The tag must not be in a tag table already, and may not have the same name as
    -- an already-added tag.
    --
    textTagTableAdd :: (TextTagTableClass self, TextTagClass tag) => self -> tag -> IO ()
    textTagTableAdd :: forall self tag.
    (TextTagTableClass self, TextTagClass tag) =>
    self -> tag -> IO ()
    textTagTableAdd self
    self tag
    tag = IO CInt -> IO ()
    forall (f :: * -> *) a. Functor f => f a -> f ()
    void (IO CInt -> IO ()) -> IO CInt -> IO ()
    forall a b. (a -> b) -> a -> b
    $
      (\(TextTagTable ForeignPtr TextTagTable
    arg1) (TextTag ForeignPtr TextTag
    arg2) -> ForeignPtr TextTagTable -> (Ptr TextTagTable -> IO CInt) -> IO CInt
    forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
    withForeignPtr ForeignPtr TextTagTable
    arg1 ((Ptr TextTagTable -> IO CInt) -> IO CInt)
    -> (Ptr TextTagTable -> IO CInt) -> IO CInt
    forall a b. (a -> b) -> a -> b
    $ \Ptr TextTagTable
    argPtr1 ->ForeignPtr TextTag -> (Ptr TextTag -> IO CInt) -> IO CInt
    forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
    withForeignPtr ForeignPtr TextTag
    arg2 ((Ptr TextTag -> IO CInt) -> IO CInt)
    -> (Ptr TextTag -> IO CInt) -> IO CInt
    forall a b. (a -> b) -> a -> b
    $ \Ptr TextTag
    argPtr2 ->Ptr TextTagTable -> Ptr TextTag -> IO CInt
    gtk_text_tag_table_add Ptr TextTagTable
    argPtr1 Ptr TextTag
    argPtr2)
    {-# LINE 89 "./Graphics/UI/Gtk/Multiline/TextTagTable.chs" #-}
        (toTextTagTable self)
        (tag -> TextTag
    forall o. TextTagClass o => o -> TextTag
    toTextTag tag
    tag)

    -- | Remove a tag from the table.
    --
    textTagTableRemove :: (TextTagTableClass self, TextTagClass tag) => self -> tag -> IO ()
    textTagTableRemove :: forall self tag.
    (TextTagTableClass self, TextTagClass tag) =>
    self -> tag -> IO ()
    textTagTableRemove self
    self tag
    tag =
      (\(TextTagTable ForeignPtr TextTagTable
    arg1) (TextTag ForeignPtr TextTag
    arg2) -> ForeignPtr TextTagTable -> (Ptr TextTagTable -> IO ()) -> IO ()
    forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
    withForeignPtr ForeignPtr TextTagTable
    arg1 ((Ptr TextTagTable -> IO ()) -> IO ())
    -> (Ptr TextTagTable -> IO ()) -> IO ()
    forall a b. (a -> b) -> a -> b
    $ \Ptr TextTagTable
    argPtr1 ->ForeignPtr TextTag -> (Ptr TextTag -> IO ()) -> IO ()
    forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
    withForeignPtr ForeignPtr TextTag
    arg2 ((Ptr TextTag -> IO ()) -> IO ())
    -> (Ptr TextTag -> IO ()) -> IO ()
    forall a b. (a -> b) -> a -> b
    $ \Ptr TextTag
    argPtr2 ->Ptr TextTagTable -> Ptr TextTag -> IO ()
    gtk_text_tag_table_remove Ptr TextTagTable
    argPtr1 Ptr TextTag
    argPtr2)
    {-# LINE 97 "./Graphics/UI/Gtk/Multiline/TextTagTable.chs" #-}
        (toTextTagTable self)
        (tag -> TextTag
    forall o. TextTagClass o => o -> TextTag
    toTextTag tag
    tag)

    -- | Look up a named tag.
    --
    textTagTableLookup :: (TextTagTableClass self, GlibString string) => self
     -> string -- ^ @name@ - name of a tag
     -> IO (Maybe TextTag) -- ^ returns The tag, or @Nothing@ if none by that name
                           -- is in the table.
    textTagTableLookup :: forall self string.
    (TextTagTableClass self, GlibString string) =>
    self -> string -> IO (Maybe TextTag)
    textTagTableLookup self
    self string
    name =
      (IO (Ptr TextTag) -> IO TextTag)
    -> IO (Ptr TextTag) -> IO (Maybe TextTag)
    forall a. (IO (Ptr a) -> IO a) -> IO (Ptr a) -> IO (Maybe a)
    maybeNull ((ForeignPtr TextTag -> TextTag, FinalizerPtr TextTag)
    -> IO (Ptr TextTag) -> IO TextTag
    forall obj.
    GObjectClass obj =>
    (ForeignPtr obj -> obj, FinalizerPtr obj) -> IO (Ptr obj) -> IO obj
    makeNewGObject (ForeignPtr TextTag -> TextTag, FinalizerPtr TextTag)
    forall {a}. (ForeignPtr TextTag -> TextTag, FinalizerPtr a)
    mkTextTag) (IO (Ptr TextTag) -> IO (Maybe TextTag))
    -> IO (Ptr TextTag) -> IO (Maybe TextTag)
    forall a b. (a -> b) -> a -> b
    $
      string -> (CString -> IO (Ptr TextTag)) -> IO (Ptr TextTag)
    forall a. string -> (CString -> IO a) -> IO a
    forall s a. GlibString s => s -> (CString -> IO a) -> IO a
    withUTFString string
    name ((CString -> IO (Ptr TextTag)) -> IO (Ptr TextTag))
    -> (CString -> IO (Ptr TextTag)) -> IO (Ptr TextTag)
    forall a b. (a -> b) -> a -> b
    $ \CString
    namePtr ->
      (\(TextTagTable ForeignPtr TextTagTable
    arg1) CString
    arg2 -> ForeignPtr TextTagTable
    -> (Ptr TextTagTable -> IO (Ptr TextTag)) -> IO (Ptr TextTag)
    forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
    withForeignPtr ForeignPtr TextTagTable
    arg1 ((Ptr TextTagTable -> IO (Ptr TextTag)) -> IO (Ptr TextTag))
    -> (Ptr TextTagTable -> IO (Ptr TextTag)) -> IO (Ptr TextTag)
    forall a b. (a -> b) -> a -> b
    $ \Ptr TextTagTable
    argPtr1 ->Ptr TextTagTable -> CString -> IO (Ptr TextTag)
    gtk_text_tag_table_lookup Ptr TextTagTable
    argPtr1 CString
    arg2)
    {-# LINE 110 "./Graphics/UI/Gtk/Multiline/TextTagTable.chs" #-}
        (toTextTagTable self)
        CString
    namePtr

    -- | Maps over each tag in the table.
    --
    textTagTableForeach :: TextTagTableClass self => self
     -> (TextTag -> IO ())
     -> IO ()
    textTagTableForeach :: forall self.
    TextTagTableClass self =>
    self -> (TextTag -> IO ()) -> IO ()
    textTagTableForeach self
    self TextTag -> IO ()
    func = do
      funcPtr <- (Ptr TextTag -> Ptr () -> IO ()) -> IO TextTagTableForeach
    mkTextTagTableForeach (\Ptr TextTag
    tagPtr Ptr ()
    _ -> do
        tag <- (ForeignPtr TextTag -> TextTag, FinalizerPtr TextTag)
    -> IO (Ptr TextTag) -> IO TextTag
    forall obj.
    GObjectClass obj =>
    (ForeignPtr obj -> obj, FinalizerPtr obj) -> IO (Ptr obj) -> IO obj
    makeNewGObject (ForeignPtr TextTag -> TextTag, FinalizerPtr TextTag)
    forall {a}. (ForeignPtr TextTag -> TextTag, FinalizerPtr a)
    mkTextTag (Ptr TextTag -> IO (Ptr TextTag)
    forall a. a -> IO a
    forall (m :: * -> *) a. Monad m => a -> m a
    return Ptr TextTag
    tagPtr)
        func tag)
      (\(TextTagTable ForeignPtr TextTagTable
    arg1) TextTagTableForeach
    arg2 Ptr ()
    arg3 -> ForeignPtr TextTagTable -> (Ptr TextTagTable -> IO ()) -> IO ()
    forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
    withForeignPtr ForeignPtr TextTagTable
    arg1 ((Ptr TextTagTable -> IO ()) -> IO ())
    -> (Ptr TextTagTable -> IO ()) -> IO ()
    forall a b. (a -> b) -> a -> b
    $ \Ptr TextTagTable
    argPtr1 ->Ptr TextTagTable -> TextTagTableForeach -> Ptr () -> IO ()
    gtk_text_tag_table_foreach Ptr TextTagTable
    argPtr1 TextTagTableForeach
    arg2 Ptr ()
    arg3)
    {-# LINE 123 "./Graphics/UI/Gtk/Multiline/TextTagTable.chs" #-}
        (toTextTagTable self)
        funcPtr
        nullPtr

    type TextTagTableForeach = FunPtr (((Ptr TextTag) -> ((Ptr ()) -> (IO ()))))
    {-# LINE 128 "./Graphics/UI/Gtk/Multiline/TextTagTable.chs" #-}

    foreign import ccall "wrapper" mkTextTagTableForeach ::
      (Ptr TextTag -> Ptr () -> IO ()) -> IO TextTagTableForeach

    -- | Returns the size of the table (the number of tags).
    --
    textTagTableGetSize :: TextTagTableClass self => self -> IO Int
    textTagTableGetSize :: forall self. TextTagTableClass self => self -> IO Int
    textTagTableGetSize self
    self =
      (CInt -> Int) -> IO CInt -> IO Int
    forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
    liftM CInt -> Int
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral (IO CInt -> IO Int) -> IO CInt -> IO Int
    forall a b. (a -> b) -> a -> b
    $
      (\(TextTagTable ForeignPtr TextTagTable
    arg1) -> ForeignPtr TextTagTable -> (Ptr TextTagTable -> IO CInt) -> IO CInt
    forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
    withForeignPtr ForeignPtr TextTagTable
    arg1 ((Ptr TextTagTable -> IO CInt) -> IO CInt)
    -> (Ptr TextTagTable -> IO CInt) -> IO CInt
    forall a b. (a -> b) -> a -> b
    $ \Ptr TextTagTable
    argPtr1 ->Ptr TextTagTable -> IO CInt
    gtk_text_tag_table_get_size Ptr TextTagTable
    argPtr1)
    {-# LINE 138 "./Graphics/UI/Gtk/Multiline/TextTagTable.chs" #-}
        (toTextTagTable self)

    foreign import ccall unsafe "gtk_text_tag_table_new"
      gtk_text_tag_table_new :: (IO (Ptr TextTagTable))

    foreign import ccall safe "gtk_text_tag_table_add"
      gtk_text_tag_table_add :: ((Ptr TextTagTable) -> ((Ptr TextTag) -> (IO CInt)))

    foreign import ccall safe "gtk_text_tag_table_remove"
      gtk_text_tag_table_remove :: ((Ptr TextTagTable) -> ((Ptr TextTag) -> (IO ())))

    foreign import ccall unsafe "gtk_text_tag_table_lookup"
      gtk_text_tag_table_lookup :: ((Ptr TextTagTable) -> ((Ptr CChar) -> (IO (Ptr TextTag))))

    foreign import ccall safe "gtk_text_tag_table_foreach"
      gtk_text_tag_table_foreach :: ((Ptr TextTagTable) -> ((FunPtr ((Ptr TextTag) -> ((Ptr ()) -> (IO ())))) -> ((Ptr ()) -> (IO ()))))

    foreign import ccall unsafe "gtk_text_tag_table_get_size"
      gtk_text_tag_table_get_size :: ((Ptr TextTagTable) -> (IO CInt))