    {-# LINE 2 "./Graphics/UI/Gtk/Selectors/FileChooserButton.chs" #-}
    -- -*-haskell-*-
    -- GIMP Toolkit (GTK) Widget FileChooserButton
    --
    -- Author : Duncan Coutts
    --
    -- Created: 5 April 2005
    --
    -- Copyright (C) 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 button to launch a file selection dialog
    --
    -- * Module available since Gtk+ version 2.6
    --
    module Graphics.UI.Gtk.Selectors.FileChooserButton (
    -- * Detail
    --
    -- | The 'FileChooserButton' is a widget that lets the user select a file. It
    -- implements the 'FileChooser' interface. Visually, it is a file name with a
    -- button to bring up a 'FileChooserDialog'. The user can then use that dialog
    -- to change the file associated with that button. This widget does not support
    -- setting the \"select-multiple\" property to @True@.
    --
    -- The 'FileChooserButton' supports the 'FileChooserAction's
    -- 'FileChooserActionOpen' and 'FileChooserActionSelectFolder'.

    -- * Class Hierarchy
    -- |
    -- @
    -- | 'GObject'
    -- | +----'Object'
    -- | +----'Widget'
    -- | +----'Container'
    -- | +----'Box'
    -- | +----'HBox'
    -- | +----FileChooserButton
    -- @

    -- * Types
      FileChooserButton,
      FileChooserButtonClass,
      castToFileChooserButton, gTypeFileChooserButton,
      toFileChooserButton,

    -- * Constructors
      fileChooserButtonNew,

      fileChooserButtonNewWithDialog,

    -- * Methods
      fileChooserButtonGetTitle,
      fileChooserButtonSetTitle,
      fileChooserButtonGetWidthChars,
      fileChooserButtonSetWidthChars,

    -- * Attributes
      fileChooserButtonDialog,
      fileChooserButtonTitle,
      fileChooserButtonWidthChars,

    -- * Signals
      fileChooserButtonFileSet

      ) 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 92 "./Graphics/UI/Gtk/Selectors/FileChooserButton.chs" #-}
    import Graphics.UI.Gtk.Signals
    {-# LINE 93 "./Graphics/UI/Gtk/Selectors/FileChooserButton.chs" #-}

    import Graphics.UI.Gtk.Selectors.FileChooser (FileChooserAction)

    {-# LINE 98 "./Graphics/UI/Gtk/Selectors/FileChooserButton.chs" #-}

    --------------------
    -- Interfaces

    instance FileChooserClass FileChooserButton

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

    -- | Creates a new file-selecting button widget.
    --
    fileChooserButtonNew :: GlibString string
     => string -- ^ @title@ - the title of the browse dialog.
     -> FileChooserAction -- ^ @action@ - the open mode for the widget.
     -> IO FileChooserButton
    fileChooserButtonNew :: forall string.
    GlibString string =>
    string -> FileChooserAction -> IO FileChooserButton
    fileChooserButtonNew string
    title FileChooserAction
    action =
      (ForeignPtr FileChooserButton -> FileChooserButton,
     FinalizerPtr FileChooserButton)
    -> IO (Ptr FileChooserButton) -> IO FileChooserButton
    forall obj.
    GObjectClass obj =>
    (ForeignPtr obj -> obj, FinalizerPtr obj) -> IO (Ptr obj) -> IO obj
    makeNewObject (ForeignPtr FileChooserButton -> FileChooserButton,
     FinalizerPtr FileChooserButton)
    forall {a}.
    (ForeignPtr FileChooserButton -> FileChooserButton, FinalizerPtr a)
    mkFileChooserButton (IO (Ptr FileChooserButton) -> IO FileChooserButton)
    -> IO (Ptr FileChooserButton) -> IO FileChooserButton
    forall a b. (a -> b) -> a -> b
    $
      (Ptr Widget -> Ptr FileChooserButton)
    -> IO (Ptr Widget) -> IO (Ptr FileChooserButton)
    forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
    liftM (Ptr Widget -> Ptr FileChooserButton
    forall a b. Ptr a -> Ptr b
    castPtr :: Ptr Widget -> Ptr FileChooserButton) (IO (Ptr Widget) -> IO (Ptr FileChooserButton))
    -> IO (Ptr Widget) -> IO (Ptr FileChooserButton)
    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 -> CInt -> IO (Ptr Widget)
    gtk_file_chooser_button_new
    {-# LINE 118 "./Graphics/UI/Gtk/Selectors/FileChooserButton.chs" #-}
        titlePtr
        ((Int -> CInt
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral (Int -> CInt)
    -> (FileChooserAction -> Int) -> FileChooserAction -> CInt
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . FileChooserAction -> Int
    forall a. Enum a => a -> Int
    fromEnum) FileChooserAction
    action)
    {-# LINE 142 "./Graphics/UI/Gtk/Selectors/FileChooserButton.chs" #-}
    -- | Creates a 'FileChooserButton' widget which uses @dialog@ as it's
    -- file-picking window.
    --
    fileChooserButtonNewWithDialog :: FileChooserDialogClass dialog =>
        dialog -- ^ @dialog@ - the 'FileChooserDialog' widget to
                             -- use.
     -> IO FileChooserButton
    fileChooserButtonNewWithDialog :: forall dialog.
    FileChooserDialogClass dialog =>
    dialog -> IO FileChooserButton
    fileChooserButtonNewWithDialog dialog
    dialog =
      (ForeignPtr FileChooserButton -> FileChooserButton,
     FinalizerPtr FileChooserButton)
    -> IO (Ptr FileChooserButton) -> IO FileChooserButton
    forall obj.
    GObjectClass obj =>
    (ForeignPtr obj -> obj, FinalizerPtr obj) -> IO (Ptr obj) -> IO obj
    makeNewObject (ForeignPtr FileChooserButton -> FileChooserButton,
     FinalizerPtr FileChooserButton)
    forall {a}.
    (ForeignPtr FileChooserButton -> FileChooserButton, FinalizerPtr a)
    mkFileChooserButton (IO (Ptr FileChooserButton) -> IO FileChooserButton)
    -> IO (Ptr FileChooserButton) -> IO FileChooserButton
    forall a b. (a -> b) -> a -> b
    $
      (Ptr Widget -> Ptr FileChooserButton)
    -> IO (Ptr Widget) -> IO (Ptr FileChooserButton)
    forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
    liftM (Ptr Widget -> Ptr FileChooserButton
    forall a b. Ptr a -> Ptr b
    castPtr :: Ptr Widget -> Ptr FileChooserButton) (IO (Ptr Widget) -> IO (Ptr FileChooserButton))
    -> IO (Ptr Widget) -> IO (Ptr FileChooserButton)
    forall a b. (a -> b) -> a -> b
    $
      (\(Widget ForeignPtr Widget
    arg1) -> ForeignPtr Widget
    -> (Ptr Widget -> IO (Ptr Widget)) -> IO (Ptr Widget)
    forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
    withForeignPtr ForeignPtr Widget
    arg1 ((Ptr Widget -> IO (Ptr Widget)) -> IO (Ptr Widget))
    -> (Ptr Widget -> IO (Ptr Widget)) -> IO (Ptr Widget)
    forall a b. (a -> b) -> a -> b
    $ \Ptr Widget
    argPtr1 ->Ptr Widget -> IO (Ptr Widget)
    gtk_file_chooser_button_new_with_dialog Ptr Widget
    argPtr1)
    {-# LINE 153 "./Graphics/UI/Gtk/Selectors/FileChooserButton.chs" #-}
        (toWidget dialog)

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

    -- | Retrieves the title of the browse dialog used by the button.
    --
    fileChooserButtonGetTitle :: (FileChooserButtonClass self, GlibString string) => self
     -> IO string -- ^ returns a pointer to the browse dialog's title.
    fileChooserButtonGetTitle :: forall self string.
    (FileChooserButtonClass self, GlibString string) =>
    self -> IO string
    fileChooserButtonGetTitle self
    self =
      (\(FileChooserButton ForeignPtr FileChooserButton
    arg1) -> ForeignPtr FileChooserButton
    -> (Ptr FileChooserButton -> IO CString) -> IO CString
    forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
    withForeignPtr ForeignPtr FileChooserButton
    arg1 ((Ptr FileChooserButton -> IO CString) -> IO CString)
    -> (Ptr FileChooserButton -> IO CString) -> IO CString
    forall a b. (a -> b) -> a -> b
    $ \Ptr FileChooserButton
    argPtr1 ->Ptr FileChooserButton -> IO CString
    gtk_file_chooser_button_get_title Ptr FileChooserButton
    argPtr1)
    {-# LINE 164 "./Graphics/UI/Gtk/Selectors/FileChooserButton.chs" #-}
        (toFileChooserButton 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

    -- | Modifies the @title@ of the browse dialog used by the button.
    --
    fileChooserButtonSetTitle :: (FileChooserButtonClass self, GlibString string) => self
     -> string -- ^ @title@ - the new browse dialog title.
     -> IO ()
    fileChooserButtonSetTitle :: forall self string.
    (FileChooserButtonClass self, GlibString string) =>
    self -> string -> IO ()
    fileChooserButtonSetTitle self
    self string
    title =
      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
    title ((CString -> IO ()) -> IO ()) -> (CString -> IO ()) -> IO ()
    forall a b. (a -> b) -> a -> b
    $ \CString
    titlePtr ->
      (\(FileChooserButton ForeignPtr FileChooserButton
    arg1) CString
    arg2 -> ForeignPtr FileChooserButton
    -> (Ptr FileChooserButton -> IO ()) -> IO ()
    forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
    withForeignPtr ForeignPtr FileChooserButton
    arg1 ((Ptr FileChooserButton -> IO ()) -> IO ())
    -> (Ptr FileChooserButton -> IO ()) -> IO ()
    forall a b. (a -> b) -> a -> b
    $ \Ptr FileChooserButton
    argPtr1 ->Ptr FileChooserButton -> CString -> IO ()
    gtk_file_chooser_button_set_title Ptr FileChooserButton
    argPtr1 CString
    arg2)
    {-# LINE 175 "./Graphics/UI/Gtk/Selectors/FileChooserButton.chs" #-}
        (toFileChooserButton self)
        CString
    titlePtr

    -- | Retrieves the width in characters of the @button@ widget's entry and\/or
    -- label.
    --
    fileChooserButtonGetWidthChars :: FileChooserButtonClass self => self
     -> IO Int -- ^ returns an integer width (in characters) that the button will
               -- use to size itself.
    fileChooserButtonGetWidthChars :: forall self. FileChooserButtonClass self => self -> IO Int
    fileChooserButtonGetWidthChars 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
    $
      (\(FileChooserButton ForeignPtr FileChooserButton
    arg1) -> ForeignPtr FileChooserButton
    -> (Ptr FileChooserButton -> IO CInt) -> IO CInt
    forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
    withForeignPtr ForeignPtr FileChooserButton
    arg1 ((Ptr FileChooserButton -> IO CInt) -> IO CInt)
    -> (Ptr FileChooserButton -> IO CInt) -> IO CInt
    forall a b. (a -> b) -> a -> b
    $ \Ptr FileChooserButton
    argPtr1 ->Ptr FileChooserButton -> IO CInt
    gtk_file_chooser_button_get_width_chars Ptr FileChooserButton
    argPtr1)
    {-# LINE 187 "./Graphics/UI/Gtk/Selectors/FileChooserButton.chs" #-}
        (toFileChooserButton self)

    -- | Sets the width (in characters) that the button will use to @nChars@.
    --
    fileChooserButtonSetWidthChars :: FileChooserButtonClass self => self
     -> Int -- ^ @nChars@ - the new width, in characters.
     -> IO ()
    fileChooserButtonSetWidthChars :: forall self. FileChooserButtonClass self => self -> Int -> IO ()
    fileChooserButtonSetWidthChars self
    self Int
    nChars =
      (\(FileChooserButton ForeignPtr FileChooserButton
    arg1) CInt
    arg2 -> ForeignPtr FileChooserButton
    -> (Ptr FileChooserButton -> IO ()) -> IO ()
    forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
    withForeignPtr ForeignPtr FileChooserButton
    arg1 ((Ptr FileChooserButton -> IO ()) -> IO ())
    -> (Ptr FileChooserButton -> IO ()) -> IO ()
    forall a b. (a -> b) -> a -> b
    $ \Ptr FileChooserButton
    argPtr1 ->Ptr FileChooserButton -> CInt -> IO ()
    gtk_file_chooser_button_set_width_chars Ptr FileChooserButton
    argPtr1 CInt
    arg2)
    {-# LINE 196 "./Graphics/UI/Gtk/Selectors/FileChooserButton.chs" #-}
        (toFileChooserButton self)
        (Int -> CInt
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral Int
    nChars)

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

    -- | Instance of the 'FileChooserDialog' associated with the button.
    --
    fileChooserButtonDialog :: (FileChooserButtonClass self, FileChooserDialogClass fileChooserDialog) => WriteAttr self fileChooserDialog
    fileChooserButtonDialog :: forall self fileChooserDialog.
    (FileChooserButtonClass self,
     FileChooserDialogClass fileChooserDialog) =>
    WriteAttr self fileChooserDialog
    fileChooserButtonDialog = String -> GType -> WriteAttr self fileChooserDialog
    forall gobj gobj'.
    (GObjectClass gobj, GObjectClass gobj') =>
    String -> GType -> WriteAttr gobj gobj'
    writeAttrFromObjectProperty String
    "dialog"
      GType
    gtk_file_chooser_dialog_get_type
    {-# LINE 207 "./Graphics/UI/Gtk/Selectors/FileChooserButton.chs" #-}

    -- | Title to put on the 'FileChooserDialog' associated with the button.
    --
    -- Default value: \"Select A File\"
    --
    fileChooserButtonTitle :: (FileChooserButtonClass self, GlibString string) => Attr self string
    fileChooserButtonTitle :: forall self string.
    (FileChooserButtonClass self, GlibString string) =>
    Attr self string
    fileChooserButtonTitle = (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.
    (FileChooserButtonClass self, GlibString string) =>
    self -> IO string
    fileChooserButtonGetTitle
      self -> string -> IO ()
    forall self string.
    (FileChooserButtonClass self, GlibString string) =>
    self -> string -> IO ()
    fileChooserButtonSetTitle

    -- |
    --
    fileChooserButtonWidthChars :: FileChooserButtonClass self => Attr self Int
    fileChooserButtonWidthChars :: forall self. FileChooserButtonClass self => Attr self Int
    fileChooserButtonWidthChars = (self -> IO Int)
    -> (self -> Int -> IO ()) -> ReadWriteAttr self Int Int
    forall o a b.
    (o -> IO a) -> (o -> b -> IO ()) -> ReadWriteAttr o a b
    newAttr
      self -> IO Int
    forall self. FileChooserButtonClass self => self -> IO Int
    fileChooserButtonGetWidthChars
      self -> Int -> IO ()
    forall self. FileChooserButtonClass self => self -> Int -> IO ()
    fileChooserButtonSetWidthChars

    --------------------
    -- Signals

    -- %hash c:b660 d:ab72
    -- | Emitted when the user selects a file.
    --
    fileChooserButtonFileSet :: FileChooserButtonClass self => Signal self (IO ())
    fileChooserButtonFileSet :: forall self. FileChooserButtonClass self => Signal self (IO ())
    fileChooserButtonFileSet = (Bool -> self -> IO () -> IO (ConnectId self))
    -> Signal self (IO ())
    forall object handler.
    (Bool -> object -> handler -> IO (ConnectId object))
    -> Signal object handler
    Signal (String -> Bool -> self -> IO () -> IO (ConnectId self)
    forall obj.
    GObjectClass obj =>
    String -> Bool -> obj -> IO () -> IO (ConnectId obj)
    connect_NONE__NONE String
    "file-set")

    foreign import ccall safe "gtk_file_chooser_button_new"
      gtk_file_chooser_button_new :: ((Ptr CChar) -> (CInt -> (IO (Ptr Widget))))

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

    foreign import ccall safe "gtk_file_chooser_button_get_title"
      gtk_file_chooser_button_get_title :: ((Ptr FileChooserButton) -> (IO (Ptr CChar)))

    foreign import ccall safe "gtk_file_chooser_button_set_title"
      gtk_file_chooser_button_set_title :: ((Ptr FileChooserButton) -> ((Ptr CChar) -> (IO ())))

    foreign import ccall safe "gtk_file_chooser_button_get_width_chars"
      gtk_file_chooser_button_get_width_chars :: ((Ptr FileChooserButton) -> (IO CInt))

    foreign import ccall safe "gtk_file_chooser_button_set_width_chars"
      gtk_file_chooser_button_set_width_chars :: ((Ptr FileChooserButton) -> (CInt -> (IO ())))

    foreign import ccall unsafe "gtk_file_chooser_dialog_get_type"
      gtk_file_chooser_dialog_get_type :: CULong