{-# LINE 2 "./Graphics/UI/Gtk/Selectors/FontSelectionDialog.chs" #-}
-- -*-haskell-*-
-- GIMP Toolkit (GTK) Widget FontSelectionDialog
--
-- 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 dialog box for selecting fonts
--
module Graphics.UI.Gtk.Selectors.FontSelectionDialog (
-- * Detail
--
-- | The 'FontSelectionDialog' widget is a dialog box for selecting a font.
--
-- To set the font which is initially selected, use
-- 'fontSelectionDialogSetFontName'.
--
-- To get the selected font use 'fontSelectionDialogGetFontName'.
--
-- To change the text which is shown in the preview area, use
-- 'fontSelectionDialogSetPreviewText'.

-- * Class Hierarchy
-- |
-- @
-- | 'GObject'
-- | +----'Object'
-- | +----'Widget'
-- | +----'Container'
-- | +----'Bin'
-- | +----'Window'
-- | +----'Dialog'
-- | +----FontSelectionDialog
-- @

-- * Types
  FontSelectionDialog,
  FontSelectionDialogClass,
  castToFontSelectionDialog, gTypeFontSelectionDialog,
  toFontSelectionDialog,

-- * Constructors
  fontSelectionDialogNew,

-- * Methods
  fontSelectionDialogGetFontName,
  fontSelectionDialogSetFontName,
  fontSelectionDialogGetPreviewText,
  fontSelectionDialogSetPreviewText,

  fontSelectionDialogGetCancelButton,
  fontSelectionDialogGetOkButton,


  fontSelectionDialogGetFontSelection,


-- * Attributes
  fontSelectionDialogPreviewText,
  ) where

import Control.Monad (liftM)

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


{-# LINE 89 "./Graphics/UI/Gtk/Selectors/FontSelectionDialog.chs" #-}

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

-- | Creates a new 'FontSelectionDialog'.
--
fontSelectionDialogNew :: GlibString string
 => string -- ^ @title@ - the title of the dialog box.
 -> IO FontSelectionDialog
fontSelectionDialogNew :: forall string.
GlibString string =>
string -> IO FontSelectionDialog
fontSelectionDialogNew string
title =
  (ForeignPtr FontSelectionDialog -> FontSelectionDialog,
 FinalizerPtr FontSelectionDialog)
-> IO (Ptr FontSelectionDialog) -> IO FontSelectionDialog
forall obj.
GObjectClass obj =>
(ForeignPtr obj -> obj, FinalizerPtr obj) -> IO (Ptr obj) -> IO obj
makeNewObject (ForeignPtr FontSelectionDialog -> FontSelectionDialog,
 FinalizerPtr FontSelectionDialog)
forall {a}.
(ForeignPtr FontSelectionDialog -> FontSelectionDialog,
 FinalizerPtr a)
mkFontSelectionDialog (IO (Ptr FontSelectionDialog) -> IO FontSelectionDialog)
-> IO (Ptr FontSelectionDialog) -> IO FontSelectionDialog
forall a b. (a -> b) -> a -> b
$
  (Ptr Widget -> Ptr FontSelectionDialog)
-> IO (Ptr Widget) -> IO (Ptr FontSelectionDialog)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (Ptr Widget -> Ptr FontSelectionDialog
forall a b. Ptr a -> Ptr b
castPtr :: Ptr Widget -> Ptr FontSelectionDialog) (IO (Ptr Widget) -> IO (Ptr FontSelectionDialog))
-> IO (Ptr Widget) -> IO (Ptr FontSelectionDialog)
forall a b. (a -> b) -> a -> b
$
  string -> (CString -> IO (Ptr Widget)) -> IO (Ptr Widget)
forall a. string -> (CString -> IO a) -> IO a
forall s a. GlibString s => s -> (CString -> IO a) -> IO a
withUTFString string
title ((CString -> IO (Ptr Widget)) -> IO (Ptr Widget))
-> (CString -> IO (Ptr Widget)) -> IO (Ptr Widget)
forall a b. (a -> b) -> a -> b
$ \CString
titlePtr ->
  CString -> IO (Ptr Widget)
gtk_font_selection_dialog_new
{-# LINE 103 "./Graphics/UI/Gtk/Selectors/FontSelectionDialog.chs" #-}
    titlePtr

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

-- | Gets the currently-selected font name.
--
fontSelectionDialogGetFontName :: (FontSelectionDialogClass self, GlibString string) => self
 -> IO (Maybe string) -- ^ returns the currently-selected font name, or
                      -- @Nothing@ if no font is selected.
fontSelectionDialogGetFontName :: forall self string.
(FontSelectionDialogClass self, GlibString string) =>
self -> IO (Maybe string)
fontSelectionDialogGetFontName self
self =
  (\(FontSelectionDialog ForeignPtr FontSelectionDialog
arg1) -> ForeignPtr FontSelectionDialog
-> (Ptr FontSelectionDialog -> IO CString) -> IO CString
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr FontSelectionDialog
arg1 ((Ptr FontSelectionDialog -> IO CString) -> IO CString)
-> (Ptr FontSelectionDialog -> IO CString) -> IO CString
forall a b. (a -> b) -> a -> b
$ \Ptr FontSelectionDialog
argPtr1 ->Ptr FontSelectionDialog -> IO CString
gtk_font_selection_dialog_get_font_name Ptr FontSelectionDialog
argPtr1)
{-# LINE 115 "./Graphics/UI/Gtk/Selectors/FontSelectionDialog.chs" #-}
    (toFontSelectionDialog self)
  IO CString -> (CString -> 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
>>= (CString -> IO string) -> CString -> IO (Maybe string)
forall a b. (Ptr a -> IO b) -> Ptr a -> IO (Maybe b)
maybePeek CString -> IO string
forall s. GlibString s => CString -> IO s
readUTFString

-- | Sets the currently-selected font.
--
fontSelectionDialogSetFontName :: (FontSelectionDialogClass self, GlibString string) => self
 -> string -- ^ @fontname@ - a fontname.
 -> IO Bool -- ^ returns @True@ if the font was found.
fontSelectionDialogSetFontName :: forall self string.
(FontSelectionDialogClass self, GlibString string) =>
self -> string -> IO Bool
fontSelectionDialogSetFontName 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 -> (CString -> IO CInt) -> IO CInt
forall a. string -> (CString -> IO a) -> IO a
forall s a. GlibString s => s -> (CString -> IO a) -> IO a
withUTFString string
fontname ((CString -> IO CInt) -> IO CInt)
-> (CString -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \CString
fontnamePtr ->
  (\(FontSelectionDialog ForeignPtr FontSelectionDialog
arg1) CString
arg2 -> ForeignPtr FontSelectionDialog
-> (Ptr FontSelectionDialog -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr FontSelectionDialog
arg1 ((Ptr FontSelectionDialog -> IO CInt) -> IO CInt)
-> (Ptr FontSelectionDialog -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr FontSelectionDialog
argPtr1 ->Ptr FontSelectionDialog -> CString -> IO CInt
gtk_font_selection_dialog_set_font_name Ptr FontSelectionDialog
argPtr1 CString
arg2)
{-# LINE 127 "./Graphics/UI/Gtk/Selectors/FontSelectionDialog.chs" #-}
    (toFontSelectionDialog self)
    CString
fontnamePtr

-- | Gets the text displayed in the preview area.
--
fontSelectionDialogGetPreviewText :: (FontSelectionDialogClass self, GlibString string) => self -> IO string
fontSelectionDialogGetPreviewText :: forall self string.
(FontSelectionDialogClass self, GlibString string) =>
self -> IO string
fontSelectionDialogGetPreviewText self
self =
  (\(FontSelectionDialog ForeignPtr FontSelectionDialog
arg1) -> ForeignPtr FontSelectionDialog
-> (Ptr FontSelectionDialog -> IO CString) -> IO CString
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr FontSelectionDialog
arg1 ((Ptr FontSelectionDialog -> IO CString) -> IO CString)
-> (Ptr FontSelectionDialog -> IO CString) -> IO CString
forall a b. (a -> b) -> a -> b
$ \Ptr FontSelectionDialog
argPtr1 ->Ptr FontSelectionDialog -> IO CString
gtk_font_selection_dialog_get_preview_text Ptr FontSelectionDialog
argPtr1)
{-# LINE 135 "./Graphics/UI/Gtk/Selectors/FontSelectionDialog.chs" #-}
    (toFontSelectionDialog self)
  IO CString -> (CString -> 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
>>= CString -> IO string
forall s. GlibString s => CString -> IO s
peekUTFString

-- | Sets the text displayed in the preview area.
--
fontSelectionDialogSetPreviewText :: (FontSelectionDialogClass self, GlibString string) => self -> string -> IO ()
fontSelectionDialogSetPreviewText :: forall self string.
(FontSelectionDialogClass self, GlibString string) =>
self -> string -> IO ()
fontSelectionDialogSetPreviewText self
self string
text =
  string -> (CString -> IO ()) -> IO ()
forall a. string -> (CString -> IO a) -> IO a
forall s a. GlibString s => s -> (CString -> IO a) -> IO a
withUTFString string
text ((CString -> IO ()) -> IO ()) -> (CString -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \CString
textPtr ->
  (\(FontSelectionDialog ForeignPtr FontSelectionDialog
arg1) CString
arg2 -> ForeignPtr FontSelectionDialog
-> (Ptr FontSelectionDialog -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr FontSelectionDialog
arg1 ((Ptr FontSelectionDialog -> IO ()) -> IO ())
-> (Ptr FontSelectionDialog -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr FontSelectionDialog
argPtr1 ->Ptr FontSelectionDialog -> CString -> IO ()
gtk_font_selection_dialog_set_preview_text Ptr FontSelectionDialog
argPtr1 CString
arg2)
{-# LINE 144 "./Graphics/UI/Gtk/Selectors/FontSelectionDialog.chs" #-}
    (toFontSelectionDialog self)
    CString
textPtr


-- | Gets the 'Cancel' button.
--
-- * Available since Gtk+ version 2.14
--
fontSelectionDialogGetCancelButton :: FontSelectionDialogClass self => self
                                    -> IO Widget -- ^ returns the 'Widget' used in the dialog for the 'Cancel' button.
fontSelectionDialogGetCancelButton :: forall self. FontSelectionDialogClass self => self -> IO Widget
fontSelectionDialogGetCancelButton self
self =
  (ForeignPtr Widget -> Widget, FinalizerPtr Widget)
-> IO (Ptr Widget) -> IO Widget
forall obj.
GObjectClass obj =>
(ForeignPtr obj -> obj, FinalizerPtr obj) -> IO (Ptr obj) -> IO obj
makeNewObject (ForeignPtr Widget -> Widget, FinalizerPtr Widget)
forall {a}. (ForeignPtr Widget -> Widget, FinalizerPtr a)
mkWidget (IO (Ptr Widget) -> IO Widget) -> IO (Ptr Widget) -> IO Widget
forall a b. (a -> b) -> a -> b
$
  (\(FontSelectionDialog ForeignPtr FontSelectionDialog
arg1) -> ForeignPtr FontSelectionDialog
-> (Ptr FontSelectionDialog -> IO (Ptr Widget)) -> IO (Ptr Widget)
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr FontSelectionDialog
arg1 ((Ptr FontSelectionDialog -> IO (Ptr Widget)) -> IO (Ptr Widget))
-> (Ptr FontSelectionDialog -> IO (Ptr Widget)) -> IO (Ptr Widget)
forall a b. (a -> b) -> a -> b
$ \Ptr FontSelectionDialog
argPtr1 ->Ptr FontSelectionDialog -> IO (Ptr Widget)
gtk_font_selection_dialog_get_cancel_button Ptr FontSelectionDialog
argPtr1)
{-# LINE 157 "./Graphics/UI/Gtk/Selectors/FontSelectionDialog.chs" #-}
     (toFontSelectionDialog self)

-- | Gets the 'OK' button.
--
-- * Available since Gtk+ version 2.14
--
fontSelectionDialogGetOkButton :: FontSelectionDialogClass self => self
                               -> IO Widget -- ^ returns the 'Widget' used in the dialog for the 'OK' button.
fontSelectionDialogGetOkButton :: forall self. FontSelectionDialogClass self => self -> IO Widget
fontSelectionDialogGetOkButton self
self =
  (ForeignPtr Widget -> Widget, FinalizerPtr Widget)
-> IO (Ptr Widget) -> IO Widget
forall obj.
GObjectClass obj =>
(ForeignPtr obj -> obj, FinalizerPtr obj) -> IO (Ptr obj) -> IO obj
makeNewObject (ForeignPtr Widget -> Widget, FinalizerPtr Widget)
forall {a}. (ForeignPtr Widget -> Widget, FinalizerPtr a)
mkWidget (IO (Ptr Widget) -> IO Widget) -> IO (Ptr Widget) -> IO Widget
forall a b. (a -> b) -> a -> b
$
  (\(FontSelectionDialog ForeignPtr FontSelectionDialog
arg1) -> ForeignPtr FontSelectionDialog
-> (Ptr FontSelectionDialog -> IO (Ptr Widget)) -> IO (Ptr Widget)
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr FontSelectionDialog
arg1 ((Ptr FontSelectionDialog -> IO (Ptr Widget)) -> IO (Ptr Widget))
-> (Ptr FontSelectionDialog -> IO (Ptr Widget)) -> IO (Ptr Widget)
forall a b. (a -> b) -> a -> b
$ \Ptr FontSelectionDialog
argPtr1 ->Ptr FontSelectionDialog -> IO (Ptr Widget)
gtk_font_selection_dialog_get_ok_button Ptr FontSelectionDialog
argPtr1)
{-# LINE 168 "./Graphics/UI/Gtk/Selectors/FontSelectionDialog.chs" #-}
     (toFontSelectionDialog self)




-- | Retrieves the 'FontSelection' widget embedded in the dialog.
--
-- * Available since Gtk+ version 2.22
--
fontSelectionDialogGetFontSelection :: FontSelectionDialogClass self => self
                                    -> IO FontSelection -- ^ returns the embedded 'FontSelection'
fontSelectionDialogGetFontSelection :: forall self.
FontSelectionDialogClass self =>
self -> IO FontSelection
fontSelectionDialogGetFontSelection self
self =
  (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
$
  (\(FontSelectionDialog ForeignPtr FontSelectionDialog
arg1) -> ForeignPtr FontSelectionDialog
-> (Ptr FontSelectionDialog -> IO (Ptr Widget)) -> IO (Ptr Widget)
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr FontSelectionDialog
arg1 ((Ptr FontSelectionDialog -> IO (Ptr Widget)) -> IO (Ptr Widget))
-> (Ptr FontSelectionDialog -> IO (Ptr Widget)) -> IO (Ptr Widget)
forall a b. (a -> b) -> a -> b
$ \Ptr FontSelectionDialog
argPtr1 ->Ptr FontSelectionDialog -> IO (Ptr Widget)
gtk_font_selection_dialog_get_font_selection Ptr FontSelectionDialog
argPtr1)
{-# LINE 183 "./Graphics/UI/Gtk/Selectors/FontSelectionDialog.chs" #-}
     (toFontSelectionDialog self)


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

-- | \'previewText\' property. See 'fontSelectionDialogGetPreviewText' and
-- 'fontSelectionDialogSetPreviewText'
--
fontSelectionDialogPreviewText :: (FontSelectionDialogClass self, GlibString string) => Attr self string
fontSelectionDialogPreviewText :: forall self string.
(FontSelectionDialogClass self, GlibString string) =>
Attr self string
fontSelectionDialogPreviewText = (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.
(FontSelectionDialogClass self, GlibString string) =>
self -> IO string
fontSelectionDialogGetPreviewText
  self -> string -> IO ()
forall self string.
(FontSelectionDialogClass self, GlibString string) =>
self -> string -> IO ()
fontSelectionDialogSetPreviewText

foreign import ccall unsafe "gtk_font_selection_dialog_new"
  gtk_font_selection_dialog_new :: ((Ptr CChar) -> (IO (Ptr Widget)))

foreign import ccall safe "gtk_font_selection_dialog_get_font_name"
  gtk_font_selection_dialog_get_font_name :: ((Ptr FontSelectionDialog) -> (IO (Ptr CChar)))

foreign import ccall safe "gtk_font_selection_dialog_set_font_name"
  gtk_font_selection_dialog_set_font_name :: ((Ptr FontSelectionDialog) -> ((Ptr CChar) -> (IO CInt)))

foreign import ccall unsafe "gtk_font_selection_dialog_get_preview_text"
  gtk_font_selection_dialog_get_preview_text :: ((Ptr FontSelectionDialog) -> (IO (Ptr CChar)))

foreign import ccall safe "gtk_font_selection_dialog_set_preview_text"
  gtk_font_selection_dialog_set_preview_text :: ((Ptr FontSelectionDialog) -> ((Ptr CChar) -> (IO ())))

foreign import ccall safe "gtk_font_selection_dialog_get_cancel_button"
  gtk_font_selection_dialog_get_cancel_button :: ((Ptr FontSelectionDialog) -> (IO (Ptr Widget)))

foreign import ccall safe "gtk_font_selection_dialog_get_ok_button"
  gtk_font_selection_dialog_get_ok_button :: ((Ptr FontSelectionDialog) -> (IO (Ptr Widget)))

foreign import ccall safe "gtk_font_selection_dialog_get_font_selection"
  gtk_font_selection_dialog_get_font_selection :: ((Ptr FontSelectionDialog) -> (IO (Ptr Widget)))