    {-# LINE 2 "./Graphics/UI/Gtk/Selectors/FontSelection.chs" #-}
    -- -*-haskell-*-
    -- GIMP Toolkit (GTK) Widget FontSelection
    --
    -- Author : Duncan Coutts
    --
    -- Created: 2 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)
    --
    -- A widget for selecting fonts
    --
    module Graphics.UI.Gtk.Selectors.FontSelection (
    -- * Detail
    --
    -- | The 'FontSelection' widget lists the available fonts, styles and sizes,
    -- allowing the user to select a font. It is used in the 'FontSelectionDialog'
    -- widget to provide a dialog box for selecting fonts.
    --
    -- To set the font which is initially selected, use
    -- 'fontSelectionSetFontName'.
    --
    -- To get the selected font use 'fontSelectionGetFontName'.
    --
    -- To change the text which is shown in the preview area, use
    -- 'fontSelectionSetPreviewText'.

    -- * Class Hierarchy
    -- |
    -- @
    -- | 'GObject'
    -- | +----'Object'
    -- | +----'Widget'
    -- | +----'Container'
    -- | +----'Box'
    -- | +----'VBox'
    -- | +----FontSelection
    -- @

    -- * Types
      FontSelection,
      FontSelectionClass,
      castToFontSelection, gTypeFontSelection,
      toFontSelection,

    -- * Constructors
      fontSelectionNew,

    -- * Methods
      fontSelectionGetFontName,
      fontSelectionSetFontName,
      fontSelectionGetPreviewText,
      fontSelectionSetPreviewText,

    -- * Attributes
      fontSelectionFontName,
      fontSelectionPreviewText,
      ) where

    import Control.Monad (liftM)

    import System.Glib.FFI
    import System.Glib.UTFString
    import System.Glib.Attributes
    import System.Glib.Properties
    import Graphics.UI.Gtk.Abstract.Object (makeNewObject)
    import Graphics.UI.Gtk.Types
    {-# LINE 83 "./Graphics/UI/Gtk/Selectors/FontSelection.chs" #-}

    {-# LINE 85 "./Graphics/UI/Gtk/Selectors/FontSelection.chs" #-}

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

    -- | Creates a new 'FontSelection'.
    --
    fontSelectionNew :: IO FontSelection
    fontSelectionNew :: IO FontSelection
    fontSelectionNew =
      (ForeignPtr FontSelection -> FontSelection,
     FinalizerPtr FontSelection)
    -> IO (Ptr FontSelection) -> IO FontSelection
    forall obj.
    GObjectClass obj =>
    (ForeignPtr obj -> obj, FinalizerPtr obj) -> IO (Ptr obj) -> IO obj
    makeNewObject (ForeignPtr FontSelection -> FontSelection,
     FinalizerPtr FontSelection)
    forall {a}.
    (ForeignPtr FontSelection -> FontSelection, FinalizerPtr a)
    mkFontSelection (IO (Ptr FontSelection) -> IO FontSelection)
    -> IO (Ptr FontSelection) -> IO FontSelection
    forall a b. (a -> b) -> a -> b
    $
      (Ptr Widget -> Ptr FontSelection)
    -> IO (Ptr Widget) -> IO (Ptr FontSelection)
    forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
    liftM (Ptr Widget -> Ptr FontSelection
    forall a b. Ptr a -> Ptr b
    castPtr :: Ptr Widget -> Ptr FontSelection) (IO (Ptr Widget) -> IO (Ptr FontSelection))
    -> IO (Ptr Widget) -> IO (Ptr FontSelection)
    forall a b. (a -> b) -> a -> b
    $
      IO (Ptr Widget)
    gtk_font_selection_new
    {-# LINE 96 "./Graphics/UI/Gtk/Selectors/FontSelection.chs" #-}

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

    -- | Gets the currently-selected font name.
    --
    fontSelectionGetFontName :: (FontSelectionClass self, GlibString string) => self
     -> IO (Maybe string) -- ^ returns the name of the currently selected font, or
                          -- @Nothing@ if no font is selected.
    fontSelectionGetFontName :: forall self string.
    (FontSelectionClass self, GlibString string) =>
    self -> IO (Maybe string)
    fontSelectionGetFontName self
    self =
      (\(FontSelection ForeignPtr FontSelection
    arg1) -> ForeignPtr FontSelection
    -> (Ptr FontSelection -> IO (Ptr CChar)) -> IO (Ptr CChar)
    forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
    withForeignPtr ForeignPtr FontSelection
    arg1 ((Ptr FontSelection -> IO (Ptr CChar)) -> IO (Ptr CChar))
    -> (Ptr FontSelection -> IO (Ptr CChar)) -> IO (Ptr CChar)
    forall a b. (a -> b) -> a -> b
    $ \Ptr FontSelection
    argPtr1 ->Ptr FontSelection -> IO (Ptr CChar)
    gtk_font_selection_get_font_name Ptr FontSelection
    argPtr1)
    {-# LINE 107 "./Graphics/UI/Gtk/Selectors/FontSelection.chs" #-}
        (toFontSelection self)
      IO (Ptr CChar)
    -> (Ptr CChar -> IO (Maybe string)) -> IO (Maybe string)
    forall a b. IO a -> (a -> IO b) -> IO b
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= (Ptr CChar -> IO string) -> Ptr CChar -> IO (Maybe string)
    forall a b. (Ptr a -> IO b) -> Ptr a -> IO (Maybe b)
    maybePeek Ptr CChar -> IO string
    forall s. GlibString s => Ptr CChar -> IO s
    readUTFString

    -- | Sets the currently-selected font.
    --
    fontSelectionSetFontName :: (FontSelectionClass self, GlibString string) => self
     -> string -- ^ @fontname@ - a fontname.
     -> IO Bool -- ^ returns @True@ if the font was found.
    fontSelectionSetFontName :: forall self string.
    (FontSelectionClass self, GlibString string) =>
    self -> string -> IO Bool
    fontSelectionSetFontName self
    self string
    fontname =
      (CInt -> Bool) -> IO CInt -> IO Bool
    forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
    liftM CInt -> Bool
    forall a. (Eq a, Num a) => a -> Bool
    toBool (IO CInt -> IO Bool) -> IO CInt -> IO Bool
    forall a b. (a -> b) -> a -> b
    $
      string -> (Ptr CChar -> IO CInt) -> IO CInt
    forall a. string -> (Ptr CChar -> IO a) -> IO a
    forall s a. GlibString s => s -> (Ptr CChar -> IO a) -> IO a
    withUTFString string
    fontname ((Ptr CChar -> IO CInt) -> IO CInt)
    -> (Ptr CChar -> IO CInt) -> IO CInt
    forall a b. (a -> b) -> a -> b
    $ \Ptr CChar
    fontnamePtr ->
      (\(FontSelection ForeignPtr FontSelection
    arg1) Ptr CChar
    arg2 -> ForeignPtr FontSelection
    -> (Ptr FontSelection -> IO CInt) -> IO CInt
    forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
    withForeignPtr ForeignPtr FontSelection
    arg1 ((Ptr FontSelection -> IO CInt) -> IO CInt)
    -> (Ptr FontSelection -> IO CInt) -> IO CInt
    forall a b. (a -> b) -> a -> b
    $ \Ptr FontSelection
    argPtr1 ->Ptr FontSelection -> Ptr CChar -> IO CInt
    gtk_font_selection_set_font_name Ptr FontSelection
    argPtr1 Ptr CChar
    arg2)
    {-# LINE 119 "./Graphics/UI/Gtk/Selectors/FontSelection.chs" #-}
        (toFontSelection self)
        Ptr CChar
    fontnamePtr

    -- | Gets the text displayed in the preview area.
    --
    fontSelectionGetPreviewText :: (FontSelectionClass self, GlibString string) => self -> IO string
    fontSelectionGetPreviewText :: forall self string.
    (FontSelectionClass self, GlibString string) =>
    self -> IO string
    fontSelectionGetPreviewText self
    self =
      (\(FontSelection ForeignPtr FontSelection
    arg1) -> ForeignPtr FontSelection
    -> (Ptr FontSelection -> IO (Ptr CChar)) -> IO (Ptr CChar)
    forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
    withForeignPtr ForeignPtr FontSelection
    arg1 ((Ptr FontSelection -> IO (Ptr CChar)) -> IO (Ptr CChar))
    -> (Ptr FontSelection -> IO (Ptr CChar)) -> IO (Ptr CChar)
    forall a b. (a -> b) -> a -> b
    $ \Ptr FontSelection
    argPtr1 ->Ptr FontSelection -> IO (Ptr CChar)
    gtk_font_selection_get_preview_text Ptr FontSelection
    argPtr1)
    {-# LINE 127 "./Graphics/UI/Gtk/Selectors/FontSelection.chs" #-}
        (toFontSelection self)
      IO (Ptr CChar) -> (Ptr CChar -> IO string) -> IO string
    forall a b. IO a -> (a -> IO b) -> IO b
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= Ptr CChar -> IO string
    forall s. GlibString s => Ptr CChar -> IO s
    peekUTFString

    -- | Sets the text displayed in the preview area.
    --
    fontSelectionSetPreviewText :: (FontSelectionClass self, GlibString string) => self -> string -> IO ()
    fontSelectionSetPreviewText :: forall self string.
    (FontSelectionClass self, GlibString string) =>
    self -> string -> IO ()
    fontSelectionSetPreviewText self
    self string
    text =
      string -> (Ptr CChar -> IO ()) -> IO ()
    forall a. string -> (Ptr CChar -> IO a) -> IO a
    forall s a. GlibString s => s -> (Ptr CChar -> IO a) -> IO a
    withUTFString string
    text ((Ptr CChar -> IO ()) -> IO ()) -> (Ptr CChar -> IO ()) -> IO ()
    forall a b. (a -> b) -> a -> b
    $ \Ptr CChar
    textPtr ->
      (\(FontSelection ForeignPtr FontSelection
    arg1) Ptr CChar
    arg2 -> ForeignPtr FontSelection -> (Ptr FontSelection -> IO ()) -> IO ()
    forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
    withForeignPtr ForeignPtr FontSelection
    arg1 ((Ptr FontSelection -> IO ()) -> IO ())
    -> (Ptr FontSelection -> IO ()) -> IO ()
    forall a b. (a -> b) -> a -> b
    $ \Ptr FontSelection
    argPtr1 ->Ptr FontSelection -> Ptr CChar -> IO ()
    gtk_font_selection_set_preview_text Ptr FontSelection
    argPtr1 Ptr CChar
    arg2)
    {-# LINE 136 "./Graphics/UI/Gtk/Selectors/FontSelection.chs" #-}
        (toFontSelection self)
        Ptr CChar
    textPtr

    --------------------
    -- Attributes

    -- | The X string that represents this font.
    --
    -- Default value: \"\"
    --
    fontSelectionFontName :: (FontSelectionClass self, GlibString string) => Attr self string
    fontSelectionFontName :: forall self string.
    (FontSelectionClass self, GlibString string) =>
    Attr self string
    fontSelectionFontName = String -> Attr self string
    forall gobj string.
    (GObjectClass gobj, GlibString string) =>
    String -> Attr gobj string
    newAttrFromStringProperty String
    "font_name"

    -- | The text to display in order to demonstrate the selected font.
    --
    -- Default value: \"abcdefghijk ABCDEFGHIJK\"
    --
    fontSelectionPreviewText :: (FontSelectionClass self, GlibString string) => Attr self string
    fontSelectionPreviewText :: forall self string.
    (FontSelectionClass self, GlibString string) =>
    Attr self string
    fontSelectionPreviewText = (self -> IO string)
    -> (self -> string -> IO ()) -> ReadWriteAttr self string string
    forall o a b.
    (o -> IO a) -> (o -> b -> IO ()) -> ReadWriteAttr o a b
    newAttr
      self -> IO string
    forall self string.
    (FontSelectionClass self, GlibString string) =>
    self -> IO string
    fontSelectionGetPreviewText
      self -> string -> IO ()
    forall self string.
    (FontSelectionClass self, GlibString string) =>
    self -> string -> IO ()
    fontSelectionSetPreviewText

    foreign import ccall unsafe "gtk_font_selection_new"
      gtk_font_selection_new :: (IO (Ptr Widget))

    foreign import ccall unsafe "gtk_font_selection_get_font_name"
      gtk_font_selection_get_font_name :: ((Ptr FontSelection) -> (IO (Ptr CChar)))

    foreign import ccall safe "gtk_font_selection_set_font_name"
      gtk_font_selection_set_font_name :: ((Ptr FontSelection) -> ((Ptr CChar) -> (IO CInt)))

    foreign import ccall unsafe "gtk_font_selection_get_preview_text"
      gtk_font_selection_get_preview_text :: ((Ptr FontSelection) -> (IO (Ptr CChar)))

    foreign import ccall safe "gtk_font_selection_set_preview_text"
      gtk_font_selection_set_preview_text :: ((Ptr FontSelection) -> ((Ptr CChar) -> (IO ())))