{-# LINE 2 "./Graphics/UI/Gtk/Selectors/FileChooser.chs" #-}
-- -*-haskell-*-
-- GIMP Toolkit (GTK) Interface FileChooser
--
-- Author : Duncan Coutts
--
-- Created: 24 April 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)
--
-- File chooser interface used by 'FileChooserWidget' and
-- 'FileChooserDialog'
--
-- * Module available since Gtk+ version 2.4
--
module Graphics.UI.Gtk.Selectors.FileChooser (
-- * Detail
--
-- | 'FileChooser' is an interface that can be implemented by file selection
-- widgets. In Gtk+, the main objects that implement this interface are
-- 'FileChooserWidget', 'FileChooserDialog', and 'FileChooserButton'. You do
-- not need to write an object that implements the 'FileChooser' interface
-- unless you are trying to adapt an existing file selector to expose a
-- standard programming interface.
--
-- 'FileChooser' allows for shortcuts to various places in the filesystem.
-- In the default implementation these are displayed in the left pane. It may
-- be a bit confusing at first taht these shortcuts come from various sources
-- and in various flavours, so lets explain the terminology here:

-- ** File Names and Encodings
--
-- | When the user is finished selecting files in a 'FileChooser', your
-- program can get the selected names either as filenames or as URIs. For URIs,
-- the normal escaping rules are applied if the URI contains non-ASCII
-- characters. However, filenames are /always/ returned in the character set
-- specified by the G_FILENAME_ENCODING environment variable. Please see the
-- Glib documentation for more details about this variable.

-- ** Adding a Preview Widget
--
-- | You can add a custom preview widget to a file chooser and then get
-- notification about when the preview needs to be updated. To install a
-- preview widget, use 'fileChooserSetPreviewWidget'. Then, connect to the
-- updatePreview signal to get notified when you need to update
-- the contents of the preview.
--
-- Your callback should use 'fileChooserGetPreviewFilename' to see what
-- needs previewing. Once you have generated the preview for the corresponding
-- file, you must call 'fileChooserSetPreviewWidgetActive' with a boolean flag
-- that indicates whether your callback could successfully generate a preview.

-- ** Adding Extra Widgets
--
-- | You can add extra widgets to a file chooser to provide options that are
-- not present in the default design. For example, you can add a toggle button
-- to give the user the option to open a file in read-only mode. You can use
-- 'fileChooserSetExtraWidget' to insert additional widgets in a file chooser.

-- ** Key Bindings
--
-- | Internally, Gtk+ implements a file chooser's graphical user interface
-- with the private GtkFileChooserDefaultClass. This widget has several key
-- bindings and their associated signals. This section describes the available
-- key binding signals.
--
-- * GtkFileChooser key binding example
--
-- The default keys that activate the 'keyBinding' signals in
-- GtkFileChooserDefaultClass are as follows:
--
-- [Signal name] Key
--
-- [location-popup] Control-L
--
-- [up-folder] Alt-Up
--
-- [down-folder] Alt-Down
--
-- [home-folder] Alt-Home
--
-- To change these defaults to something else, you could include the
-- following fragment in your .gtkrc-2.0 file:
--
-- > binding "my-own-gtkfilechooser-bindings" {
-- > bind "AltShiftl" {
-- > "location-popup" ()
-- > }
-- > bind "AltShiftUp" {
-- > "up-folder" ()
-- > }
-- > bind "AltShiftDown" {
-- > "down-folder" ()
-- > }
-- > bind "AltShiftHome" {
-- > "home-folder-folder" ()
-- > }
-- > }
-- >
-- > class "GtkFileChooserDefault" binding "my-own-gtkfilechooser-bindings"
-- >
--

-- * Class Hierarchy
-- |
-- @
-- | GInterface
-- | +----FileChooser
-- @


-- * Types
  FileChooser,
  FileChooserClass,
  castToFileChooser, gTypeFileChooser,
  toFileChooser,
  FileChooserAction(..),
  FileChooserError(..),

  FileChooserConfirmation(..),


-- * Methods
  fileChooserSetAction,
  fileChooserGetAction,
  fileChooserSetLocalOnly,
  fileChooserGetLocalOnly,
  fileChooserSetSelectMultiple,
  fileChooserGetSelectMultiple,
  fileChooserSetCurrentName,
  fileChooserGetFilename,
  fileChooserSetFilename,
  fileChooserSelectFilename,
  fileChooserUnselectFilename,
  fileChooserSelectAll,
  fileChooserUnselectAll,
  fileChooserGetFilenames,
  fileChooserSetCurrentFolder,
  fileChooserGetCurrentFolder,
  fileChooserGetURI,
  fileChooserSetURI,
  fileChooserSelectURI,
  fileChooserUnselectURI,
  fileChooserGetURIs,
  fileChooserSetCurrentFolderURI,
  fileChooserGetCurrentFolderURI,
  fileChooserSetPreviewWidget,
  fileChooserGetPreviewWidget,
  fileChooserSetPreviewWidgetActive,
  fileChooserGetPreviewWidgetActive,
  fileChooserSetUsePreviewLabel,
  fileChooserGetUsePreviewLabel,
  fileChooserGetPreviewFilename,
  fileChooserGetPreviewURI,
  fileChooserSetExtraWidget,
  fileChooserGetExtraWidget,
  fileChooserAddFilter,
  fileChooserRemoveFilter,
  fileChooserListFilters,
  fileChooserSetFilter,
  fileChooserGetFilter,
  fileChooserAddShortcutFolder,
  fileChooserRemoveShortcutFolder,
  fileChooserListShortcutFolders,
  fileChooserAddShortcutFolderURI,
  fileChooserRemoveShortcutFolderURI,
  fileChooserListShortcutFolderURIs,
  fileChooserErrorDomain,

  fileChooserSetShowHidden,
  fileChooserGetShowHidden,


  fileChooserSetDoOverwriteConfirmation,
  fileChooserGetDoOverwriteConfirmation,


-- * Attributes
  fileChooserUsePreviewLabel,

  fileChooserShowHidden,

  fileChooserSelectMultiple,
  fileChooserPreviewWidgetActive,
  fileChooserPreviewWidget,
  fileChooserLocalOnly,
  fileChooserFilter,
  fileChooserExtraWidget,

  fileChooserDoOverwriteConfirmation,

  fileChooserAction,

-- * Signals
  onCurrentFolderChanged,
  afterCurrentFolderChanged,
  onFileActivated,
  afterFileActivated,
-- onSelectionChanged,
-- afterSelectionChanged,
  onUpdatePreview,
  afterUpdatePreview,

  onConfirmOverwrite,
  afterConfirmOverwrite,


  ) where

import Control.Monad (liftM)

import System.Glib.FFI
import System.Glib.UTFString
import System.Glib.Attributes
import Graphics.UI.Gtk.Types
{-# LINE 231 "./Graphics/UI/Gtk/Selectors/FileChooser.chs" #-}
import Graphics.UI.Gtk.Abstract.Object (makeNewObject)
import Graphics.UI.Gtk.Signals
import System.Glib.GList
{-# LINE 234 "./Graphics/UI/Gtk/Selectors/FileChooser.chs" #-}
import System.Glib.GError (propagateGError, GErrorDomain, GErrorClass(..))


{-# LINE 237 "./Graphics/UI/Gtk/Selectors/FileChooser.chs" #-}



-- | Describes whether a 'FileChooser' is being used to open existing files
-- or to save to a possibly new file.
data FileChooserAction = FileChooserActionOpen
                       | FileChooserActionSave
                       | FileChooserActionSelectFolder
                       | FileChooserActionCreateFolder
                       deriving (Enum)

{-# LINE 243 "./Graphics/UI/Gtk/Selectors/FileChooser.chs" #-}

-- | These identify the various errors that can occur while calling
-- 'FileChooser' functions.
data FileChooserError = FileChooserErrorNonexistent
                      | FileChooserErrorBadFilename
                      | FileChooserErrorAlreadyExists
                      | FileChooserErrorIncompleteHostname
                      deriving (Enum)

{-# LINE 247 "./Graphics/UI/Gtk/Selectors/FileChooser.chs" #-}



-- | Used as a return value of handlers for the 'onConfirmOverwrite'
-- signal of a 'FileChooser'.
--
-- * This value determines whether the file chooser will present the stock
-- confirmation dialog, accept the user's choice of a filename, or let
-- the user choose another filename.
--
-- Since Gtk 2.8.
--
data FileChooserConfirmation = FileChooserConfirmationConfirm
                             | FileChooserConfirmationAcceptFilename
                             | FileChooserConfirmationSelectAgain
                             deriving (Enum)

{-# LINE 260 "./Graphics/UI/Gtk/Selectors/FileChooser.chs" #-}


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

fileChooserErrorDomain :: GErrorDomain
fileChooserErrorDomain = unsafePerformIO gtk_file_chooser_error_quark
{-# LINE 267 "./Graphics/UI/Gtk/Selectors/FileChooser.chs" #-}

instance GErrorClass FileChooserError where
  gerrorDomain _ = fileChooserErrorDomain

-- | Sets the type of operation that the chooser is performing; the user
-- interface is adapted to suit the selected action. For example, an option to
-- create a new folder might be shown if the action is 'FileChooserActionSave'
-- but not if the action is 'FileChooserActionOpen'.
--
fileChooserSetAction :: FileChooserClass self => self
 -> FileChooserAction -- ^ @action@ - the action that the file selector is
                      -- performing
 -> IO ()
fileChooserSetAction self action =
  (\(FileChooser arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->gtk_file_chooser_set_action argPtr1 arg2)
{-# LINE 282 "./Graphics/UI/Gtk/Selectors/FileChooser.chs" #-}
    (toFileChooser self)
    ((fromIntegral . fromEnum) action)

-- | Gets the type of operation that the file chooser is performing; see
-- 'fileChooserSetAction'.
--
fileChooserGetAction :: FileChooserClass self => self -> IO FileChooserAction
fileChooserGetAction self =
  liftM (toEnum . fromIntegral) $
  (\(FileChooser arg1) -> withForeignPtr arg1 $ \argPtr1 ->gtk_file_chooser_get_action argPtr1)
{-# LINE 292 "./Graphics/UI/Gtk/Selectors/FileChooser.chs" #-}
    (toFileChooser self)

-- | Sets whether only local files can be selected in the file selector. If
-- @localOnly@ is @True@ (the default), then the selected file are files are
-- guaranteed to be accessible through the operating systems native file file
-- system and therefore the application only needs to worry about the filename
-- functions in 'FileChooser', like 'fileChooserGetFilename', rather than the
-- URI functions like 'fileChooserGetURI',
--
fileChooserSetLocalOnly :: FileChooserClass self => self -> Bool -> IO ()
fileChooserSetLocalOnly self localOnly =
  (\(FileChooser arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->gtk_file_chooser_set_local_only argPtr1 arg2)
{-# LINE 304 "./Graphics/UI/Gtk/Selectors/FileChooser.chs" #-}
    (toFileChooser self)
    (fromBool localOnly)

-- | Gets whether only local files can be selected in the file selector. See
-- 'fileChooserSetLocalOnly'
--
fileChooserGetLocalOnly :: FileChooserClass self => self -> IO Bool
fileChooserGetLocalOnly self =
  liftM toBool $
  (\(FileChooser arg1) -> withForeignPtr arg1 $ \argPtr1 ->gtk_file_chooser_get_local_only argPtr1)
{-# LINE 314 "./Graphics/UI/Gtk/Selectors/FileChooser.chs" #-}
    (toFileChooser self)

-- | Sets whether multiple files can be selected in the file selector. This is
-- only relevant if the action is set to be 'FileChooserActionOpen' or
-- 'FileChooserActionSave'. It cannot be set with either of the folder actions.
--
fileChooserSetSelectMultiple :: FileChooserClass self => self -> Bool -> IO ()
fileChooserSetSelectMultiple self selectMultiple =
  (\(FileChooser arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->gtk_file_chooser_set_select_multiple argPtr1 arg2)
{-# LINE 323 "./Graphics/UI/Gtk/Selectors/FileChooser.chs" #-}
    (toFileChooser self)
    (fromBool selectMultiple)

-- | Gets whether multiple files can be selected in the file selector. See
-- 'fileChooserSetSelectMultiple'.
--
fileChooserGetSelectMultiple :: FileChooserClass self => self -> IO Bool
fileChooserGetSelectMultiple self =
  liftM toBool $
  (\(FileChooser arg1) -> withForeignPtr arg1 $ \argPtr1 ->gtk_file_chooser_get_select_multiple argPtr1)
{-# LINE 333 "./Graphics/UI/Gtk/Selectors/FileChooser.chs" #-}
    (toFileChooser self)

-- | Sets the current name in the file selector, as if entered by the user.
-- Note that the name passed in here is a Unicode string rather than a filename.
-- This function is meant for such uses as a suggested name in a \"Save As...\"
-- dialog.
--
-- If you want to preselect a particular existing file, you should use
-- 'fileChooserSetFilename' or 'fileChooserSetURI' instead. Please see the
-- documentation for those functions for an example of using
-- 'fileChooserSetCurrentName' as well.
--
fileChooserSetCurrentName :: FileChooserClass self => self
 -> FilePath -- ^ @name@ - the filename to use, as a Unicode string
 -> IO ()
fileChooserSetCurrentName self name =
  withUTFString name $ \namePtr ->
  (\(FileChooser arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->gtk_file_chooser_set_current_name argPtr1 arg2)
{-# LINE 351 "./Graphics/UI/Gtk/Selectors/FileChooser.chs" #-}
    (toFileChooser self)
    namePtr

-- | Gets the filename for the currently selected file in the file selector.
-- If multiple files are selected, one of the filenames will be returned at
-- random.
--
-- If the file chooser is in folder mode, this function returns the selected
-- folder.
--
fileChooserGetFilename :: FileChooserClass self => self
 -> IO (Maybe FilePath) -- ^ returns The currently selected filename, or
                        -- @Nothing@ if no file is selected, or the selected
                        -- file can't be represented with a local filename.
fileChooserGetFilename self =



  (\(FileChooser arg1) -> withForeignPtr arg1 $ \argPtr1 ->gtk_file_chooser_get_filename argPtr1)
{-# LINE 370 "./Graphics/UI/Gtk/Selectors/FileChooser.chs" #-}

    (toFileChooser self)
  >>= maybePeek readCString

-- | Sets @filename@ as the current filename for the file chooser, by changing
-- to the file's parent folder and actually selecting the file in list. If the
-- @chooser@ is in 'FileChooserActionSave' mode, the file's base name will also
-- appear in the dialog's file name entry.
--
-- If the file name isn't in the current folder of @chooser@, then the
-- current folder of @chooser@ will be changed to the folder containing
-- @filename@. This is equivalent to a sequence of 'fileChooserUnselectAll'
-- followed by 'fileChooserSelectFilename'.
--
-- Note that the file must exist, or nothing will be done except for the
-- directory change.
--
-- If you are implementing a File\/Save As... dialog, you should use this
-- function if you already have a file name to which the user may save; for
-- example, when the user opens an existing file and then does File\/Save As...
-- on it. If you don't have a file name already — for example, if the user
-- just created a new file and is saving it for the first time, do not call
-- this function. Instead, use something similar to this:
--
-- > if documentIsNew
-- > then do -- the user just created a new document
-- > fileChooserSetCurrentFolder chooser defaultFolderForSaving
-- > fileChooserSetCurrentName chooser "Untitled document"
-- > else do --the user edited an existing document
-- > fileChooserSetFilename chooser existingFilename
--
fileChooserSetFilename :: FileChooserClass self => self
 -> FilePath -- ^ @filename@ - the filename to set as current
 -> IO Bool -- ^ returns @True@ if both the folder could be changed and the
             -- file was selected successfully, @False@ otherwise.
fileChooserSetFilename self filename =
  liftM toBool $
  withCString filename $ \filenamePtr ->



  (\(FileChooser arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->gtk_file_chooser_set_filename argPtr1 arg2)
{-# LINE 412 "./Graphics/UI/Gtk/Selectors/FileChooser.chs" #-}

    (toFileChooser self)
    filenamePtr

-- | Selects a filename. If the file name isn't in the current folder of
-- the chooser, then the current folder of the chooser will be changed to the
-- folder containing @filename@.
--
fileChooserSelectFilename :: FileChooserClass self => self
 -> FilePath -- ^ @filename@ - the filename to select
 -> IO Bool -- ^ returns @True@ if both the folder could be changed and the
             -- file was selected successfully, @False@ otherwise.
fileChooserSelectFilename self filename =
  liftM toBool $
  withCString filename $ \filenamePtr ->



  (\(FileChooser arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->gtk_file_chooser_select_filename argPtr1 arg2)
{-# LINE 431 "./Graphics/UI/Gtk/Selectors/FileChooser.chs" #-}

    (toFileChooser self)
    filenamePtr

-- | Unselects a currently selected filename. If the filename is not in the
-- current directory, does not exist, or is otherwise not currently selected,
-- does nothing.
--
fileChooserUnselectFilename :: FileChooserClass self => self
 -> FilePath -- ^ @filename@ - the filename to unselect
 -> IO ()
fileChooserUnselectFilename self filename =
  withCString filename $ \filenamePtr ->



  (\(FileChooser arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->gtk_file_chooser_unselect_filename argPtr1 arg2)
{-# LINE 448 "./Graphics/UI/Gtk/Selectors/FileChooser.chs" #-}

    (toFileChooser self)
    filenamePtr

-- | Selects all the files in the current folder of a file chooser.
--
fileChooserSelectAll :: FileChooserClass self => self -> IO ()
fileChooserSelectAll self =
  (\(FileChooser arg1) -> withForeignPtr arg1 $ \argPtr1 ->gtk_file_chooser_select_all argPtr1)
{-# LINE 457 "./Graphics/UI/Gtk/Selectors/FileChooser.chs" #-}
    (toFileChooser self)

-- | Unselects all the files in the current folder of a file chooser.
--
fileChooserUnselectAll :: FileChooserClass self => self -> IO ()
fileChooserUnselectAll self =
  (\(FileChooser arg1) -> withForeignPtr arg1 $ \argPtr1 ->gtk_file_chooser_unselect_all argPtr1)
{-# LINE 464 "./Graphics/UI/Gtk/Selectors/FileChooser.chs" #-}
    (toFileChooser self)

-- | Lists all the selected files and subfolders in the current folder of
-- the chooser. The returned names are full absolute paths. If files in the
-- current folder cannot be represented as local filenames they will be
-- ignored. (See 'fileChooserGetURIs')
--
fileChooserGetFilenames :: FileChooserClass self => self -> IO [FilePath]
fileChooserGetFilenames self =



  (\(FileChooser arg1) -> withForeignPtr arg1 $ \argPtr1 ->gtk_file_chooser_get_filenames argPtr1)
{-# LINE 477 "./Graphics/UI/Gtk/Selectors/FileChooser.chs" #-}

    (toFileChooser self)
  >>= fromStringGSList

-- | Sets the current folder for the chooser from a local filename. The user
-- will be shown the full contents of the current folder, plus user interface
-- elements for navigating to other folders.
--
fileChooserSetCurrentFolder :: FileChooserClass self => self
 -> FilePath -- ^ @filename@ - the full path of the new current folder
 -> IO Bool -- ^ returns @True@ if the folder could be changed successfully,
             -- @False@ otherwise.
fileChooserSetCurrentFolder self filename =
  liftM toBool $
  withCString filename $ \filenamePtr ->



  (\(FileChooser arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->gtk_file_chooser_set_current_folder argPtr1 arg2)
{-# LINE 496 "./Graphics/UI/Gtk/Selectors/FileChooser.chs" #-}

    (toFileChooser self)
    filenamePtr

-- | Gets the current folder of the chooser as a local filename. See
-- 'fileChooserSetCurrentFolder'.
--
fileChooserGetCurrentFolder :: FileChooserClass self => self
 -> IO (Maybe FilePath) -- ^ returns the full path of the current folder, or
                        -- @Nothing@ if the current path cannot be represented
                        -- as a local filename.
fileChooserGetCurrentFolder self =



  (\(FileChooser arg1) -> withForeignPtr arg1 $ \argPtr1 ->gtk_file_chooser_get_current_folder argPtr1)
{-# LINE 512 "./Graphics/UI/Gtk/Selectors/FileChooser.chs" #-}

    (toFileChooser self)
  >>= maybePeek readCString

-- | Gets the URI for the currently selected file in the file selector. If
-- multiple files are selected, one of the filenames will be returned at
-- random.
--
-- If the file chooser is in folder mode, this function returns the selected
-- folder.
--
fileChooserGetURI :: FileChooserClass self => self
 -> IO (Maybe String) -- ^ returns The currently selected URI, or @Nothing@ if
                      -- no file is selected.
fileChooserGetURI self =
  (\(FileChooser arg1) -> withForeignPtr arg1 $ \argPtr1 ->gtk_file_chooser_get_uri argPtr1)
{-# LINE 528 "./Graphics/UI/Gtk/Selectors/FileChooser.chs" #-}
    (toFileChooser self)
  >>= maybePeek readCString

-- | Sets the file referred to by @uri@ as the current file for the file
-- chooser, by changing to the URI's parent folder and actually selecting the
-- URI in the list. If the @chooser@ is 'FileChooserActionSave' mode, the URI's
-- base name will also appear in the dialog's file name entry.
--
-- If the URI isn't in the current folder of @chooser@, then the current
-- folder of @chooser@ will be changed to the folder containing @uri@. This is
-- equivalent to a sequence of 'fileChooserUnselectAll' followed by
-- 'fileChooserSelectURI'.
--
-- Note that the URI must exist, or nothing will be done except for the
-- directory change. If you are implementing a File\/Save As... dialog, you
-- should use this function if you already have a file name to which the user
-- may save; for example, when the user opens an existing file and then does
-- File\/Save As... on it. If you don't have a file name already — for
-- example, if the user just created a new file and is saving it for the first
-- time, do not call this function. Instead, use something similar to this:
--
-- > if documentIsNew
-- > then do -- the user just created a new document
-- > fileChooserSetCurrentFolderURI chooser defaultFolderForSaving
-- > fileChooserSetCurrentName chooser "Untitled document"
-- > else do --the user edited an existing document
-- > fileChooserSetURI chooser existingURI
--
fileChooserSetURI :: FileChooserClass self => self
 -> String -- ^ @uri@ - the URI to set as current
 -> IO Bool -- ^ returns @True@ if both the folder could be changed and the
            -- URI was selected successfully, @False@ otherwise.
fileChooserSetURI self uri =
  liftM toBool $
  withCString uri $ \uriPtr ->
  (\(FileChooser arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->gtk_file_chooser_set_uri argPtr1 arg2)
{-# LINE 564 "./Graphics/UI/Gtk/Selectors/FileChooser.chs" #-}
    (toFileChooser self)
    uriPtr

-- | Selects the file to by @uri@. If the URI doesn't refer to a file in the
-- current folder of the chooser, then the current folder of the chooser will
-- be changed to the folder containing @filename@.
--
fileChooserSelectURI :: FileChooserClass self => self
 -> String -- ^ @uri@ - the URI to select
 -> IO Bool -- ^ returns @True@ if both the folder could be changed and the
            -- URI was selected successfully, @False@ otherwise.
fileChooserSelectURI self uri =
  liftM toBool $
  withCString uri $ \uriPtr ->
  (\(FileChooser arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->gtk_file_chooser_select_uri argPtr1 arg2)
{-# LINE 579 "./Graphics/UI/Gtk/Selectors/FileChooser.chs" #-}
    (toFileChooser self)
    uriPtr

-- | Unselects the file referred to by @uri@. If the file is not in the
-- current directory, does not exist, or is otherwise not currently selected,
-- does nothing.
--
fileChooserUnselectURI :: FileChooserClass self => self
 -> String -- ^ @uri@ - the URI to unselect
 -> IO ()
fileChooserUnselectURI self uri =
  withCString uri $ \uriPtr ->
  (\(FileChooser arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->gtk_file_chooser_unselect_uri argPtr1 arg2)
{-# LINE 592 "./Graphics/UI/Gtk/Selectors/FileChooser.chs" #-}
    (toFileChooser self)
    uriPtr

-- | Lists all the selected files and subfolders in the current folder of
-- the chooser. The returned names are full absolute URIs.
--
fileChooserGetURIs :: FileChooserClass self => self -> IO [String]
fileChooserGetURIs self =
  (\(FileChooser arg1) -> withForeignPtr arg1 $ \argPtr1 ->gtk_file_chooser_get_uris argPtr1)
{-# LINE 601 "./Graphics/UI/Gtk/Selectors/FileChooser.chs" #-}
    (toFileChooser self)
  >>= fromStringGSList

-- | Sets the current folder for the chooser from an URI. The user will be
-- shown the full contents of the current folder, plus user interface elements
-- for navigating to other folders.
--
fileChooserSetCurrentFolderURI :: FileChooserClass self => self
 -> String -- ^ @uri@ - the URI for the new current folder
 -> IO Bool -- ^ returns @True@ if the folder could be changed successfully,
            -- @False@ otherwise.
fileChooserSetCurrentFolderURI self uri =
  liftM toBool $
  withCString uri $ \uriPtr ->
  (\(FileChooser arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->gtk_file_chooser_set_current_folder_uri argPtr1 arg2)
{-# LINE 616 "./Graphics/UI/Gtk/Selectors/FileChooser.chs" #-}
    (toFileChooser self)
    uriPtr

-- | Gets the current folder of the chooser as an URI. See
-- 'fileChooserSetCurrentFolderURI'.
--
fileChooserGetCurrentFolderURI :: FileChooserClass self => self
 -> IO String -- ^ returns the URI for the current folder.
fileChooserGetCurrentFolderURI self =
  (\(FileChooser arg1) -> withForeignPtr arg1 $ \argPtr1 ->gtk_file_chooser_get_current_folder_uri argPtr1)
{-# LINE 626 "./Graphics/UI/Gtk/Selectors/FileChooser.chs" #-}
    (toFileChooser self)
  >>= readCString

-- | Sets an application-supplied widget to use to display a custom preview of
-- the currently selected file. To implement a preview, after setting the
-- preview widget, you connect to the UpdatePreview signal, and call
-- 'fileChooserGetPreviewFilename' or 'fileChooserGetPreviewURI' on each
-- change. If you can display a preview of the new file, update your widget and
-- set the preview active using 'fileChooserSetPreviewWidgetActive'. Otherwise,
-- set the preview inactive.
--
-- When there is no application-supplied preview widget, or the
-- application-supplied preview widget is not active, the file chooser may
-- display an internally generated preview of the current file or it may
-- display no preview at all.
--
fileChooserSetPreviewWidget :: (FileChooserClass self, WidgetClass previewWidget) => self
 -> previewWidget -- ^ @previewWidget@ - widget for displaying preview.
 -> IO ()
fileChooserSetPreviewWidget self previewWidget =
  (\(FileChooser arg1) (Widget arg2) -> withForeignPtr arg1 $ \argPtr1 ->withForeignPtr arg2 $ \argPtr2 ->gtk_file_chooser_set_preview_widget argPtr1 argPtr2)
{-# LINE 647 "./Graphics/UI/Gtk/Selectors/FileChooser.chs" #-}
    (toFileChooser self)
    (toWidget previewWidget)

-- | Gets the current preview widget; see 'fileChooserSetPreviewWidget'.
--
fileChooserGetPreviewWidget :: FileChooserClass self => self
 -> IO (Maybe Widget) -- ^ returns the current preview widget, or @Nothing@
fileChooserGetPreviewWidget self =
  maybeNull (makeNewObject mkWidget) $
  (\(FileChooser arg1) -> withForeignPtr arg1 $ \argPtr1 ->gtk_file_chooser_get_preview_widget argPtr1)
{-# LINE 657 "./Graphics/UI/Gtk/Selectors/FileChooser.chs" #-}
    (toFileChooser self)

-- | Sets whether the preview widget set by 'fileChooserSetPreviewWidget'
-- should be shown for the current filename. When @active@ is set to false, the
-- file chooser may display an internally generated preview of the current file
-- or it may display no preview at all. See 'fileChooserSetPreviewWidget' for
-- more details.
--
fileChooserSetPreviewWidgetActive :: FileChooserClass self => self
 -> Bool -- ^ @active@ - whether to display the user-specified preview widget
 -> IO ()
fileChooserSetPreviewWidgetActive self active =
  (\(FileChooser arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->gtk_file_chooser_set_preview_widget_active argPtr1 arg2)
{-# LINE 670 "./Graphics/UI/Gtk/Selectors/FileChooser.chs" #-}
    (toFileChooser self)
    (fromBool active)

-- | Gets whether the preview widget set by 'fileChooserSetPreviewWidget'
-- should be shown for the current filename. See
-- 'fileChooserSetPreviewWidgetActive'.
--
fileChooserGetPreviewWidgetActive :: FileChooserClass self => self
 -> IO Bool -- ^ returns @True@ if the preview widget is active for the
            -- current filename.
fileChooserGetPreviewWidgetActive self =
  liftM toBool $
  (\(FileChooser arg1) -> withForeignPtr arg1 $ \argPtr1 ->gtk_file_chooser_get_preview_widget_active argPtr1)
{-# LINE 683 "./Graphics/UI/Gtk/Selectors/FileChooser.chs" #-}
    (toFileChooser self)

-- | Sets whether the file chooser should display a stock label with the name
-- of the file that is being previewed; the default is @True@. Applications
-- that want to draw the whole preview area themselves should set this to
-- @False@ and display the name themselves in their preview widget.
--
-- See also: 'fileChooserSetPreviewWidget'
--
fileChooserSetUsePreviewLabel :: FileChooserClass self => self
 -> Bool -- ^ @useLabel@ - whether to display a stock label with the name of
          -- the previewed file
 -> IO ()
fileChooserSetUsePreviewLabel self useLabel =
  (\(FileChooser arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->gtk_file_chooser_set_use_preview_label argPtr1 arg2)
{-# LINE 698 "./Graphics/UI/Gtk/Selectors/FileChooser.chs" #-}
    (toFileChooser self)
    (fromBool useLabel)

-- | Gets whether a stock label should be drawn with the name of the previewed
-- file. See 'fileChooserSetUsePreviewLabel'.
--
fileChooserGetUsePreviewLabel :: FileChooserClass self => self
 -> IO Bool -- ^ returns @True@ if the file chooser is set to display a label
            -- with the name of the previewed file, @False@ otherwise.
fileChooserGetUsePreviewLabel self =
  liftM toBool $
  (\(FileChooser arg1) -> withForeignPtr arg1 $ \argPtr1 ->gtk_file_chooser_get_use_preview_label argPtr1)
{-# LINE 710 "./Graphics/UI/Gtk/Selectors/FileChooser.chs" #-}
    (toFileChooser self)

-- | Gets the filename that should be previewed in a custom preview widget.
-- See 'fileChooserSetPreviewWidget'.
--
fileChooserGetPreviewFilename :: FileChooserClass self => self
 -> IO (Maybe FilePath) -- ^ returns the filename to preview, or @Nothing@ if
                        -- no file is selected, or if the selected file cannot
                        -- be represented as a local filename.
fileChooserGetPreviewFilename self =



  (\(FileChooser arg1) -> withForeignPtr arg1 $ \argPtr1 ->gtk_file_chooser_get_preview_filename argPtr1)
{-# LINE 724 "./Graphics/UI/Gtk/Selectors/FileChooser.chs" #-}

    (toFileChooser self)
  >>= maybePeek readCString

-- | Gets the URI that should be previewed in a custom preview widget. See
-- 'fileChooserSetPreviewWidget'.
--
fileChooserGetPreviewURI :: FileChooserClass self => self
 -> IO (Maybe String) -- ^ returns the URI for the file to preview, or
                      -- @Nothing@ if no file is selected.
fileChooserGetPreviewURI self =
  (\(FileChooser arg1) -> withForeignPtr arg1 $ \argPtr1 ->gtk_file_chooser_get_preview_uri argPtr1)
{-# LINE 736 "./Graphics/UI/Gtk/Selectors/FileChooser.chs" #-}
    (toFileChooser self)
  >>= maybePeek readCString

-- | Sets an application-supplied widget to provide extra options to the user.
--
fileChooserSetExtraWidget :: (FileChooserClass self, WidgetClass extraWidget) => self
 -> extraWidget -- ^ @extraWidget@ - widget for extra options
 -> IO ()
fileChooserSetExtraWidget self extraWidget =
  (\(FileChooser arg1) (Widget arg2) -> withForeignPtr arg1 $ \argPtr1 ->withForeignPtr arg2 $ \argPtr2 ->gtk_file_chooser_set_extra_widget argPtr1 argPtr2)
{-# LINE 746 "./Graphics/UI/Gtk/Selectors/FileChooser.chs" #-}
    (toFileChooser self)
    (toWidget extraWidget)

-- | Gets the current preview widget; see 'fileChooserSetExtraWidget'.
--
fileChooserGetExtraWidget :: FileChooserClass self => self
 -> IO (Maybe Widget) -- ^ returns the current extra widget, or @Nothing@
fileChooserGetExtraWidget self =
  maybeNull (makeNewObject mkWidget) $
  (\(FileChooser arg1) -> withForeignPtr arg1 $ \argPtr1 ->gtk_file_chooser_get_extra_widget argPtr1)
{-# LINE 756 "./Graphics/UI/Gtk/Selectors/FileChooser.chs" #-}
    (toFileChooser self)

-- | Adds the filter to the list of filters that the user can select between.
-- When a filter is selected, only files that are passed by that filter are
-- displayed.
--
fileChooserAddFilter :: FileChooserClass self => self -> FileFilter -> IO ()
fileChooserAddFilter self filter =
  (\(FileChooser arg1) (FileFilter arg2) -> withForeignPtr arg1 $ \argPtr1 ->withForeignPtr arg2 $ \argPtr2 ->gtk_file_chooser_add_filter argPtr1 argPtr2)
{-# LINE 765 "./Graphics/UI/Gtk/Selectors/FileChooser.chs" #-}
    (toFileChooser self)
    filter

-- | Removes the filter from the list of filters that the user can select
-- between.
--
fileChooserRemoveFilter :: FileChooserClass self => self -> FileFilter -> IO ()
fileChooserRemoveFilter self filter =
  (\(FileChooser arg1) (FileFilter arg2) -> withForeignPtr arg1 $ \argPtr1 ->withForeignPtr arg2 $ \argPtr2 ->gtk_file_chooser_remove_filter argPtr1 argPtr2)
{-# LINE 774 "./Graphics/UI/Gtk/Selectors/FileChooser.chs" #-}
    (toFileChooser self)
    filter

-- | Lists the current set of user-selectable filters; see
-- 'fileChooserAddFilter', 'fileChooserRemoveFilter'.
--
fileChooserListFilters :: FileChooserClass self => self -> IO [FileFilter]
fileChooserListFilters self = do
  filterList <- (\(FileChooser arg1) -> withForeignPtr arg1 $ \argPtr1 ->gtk_file_chooser_list_filters argPtr1)
{-# LINE 783 "./Graphics/UI/Gtk/Selectors/FileChooser.chs" #-}
    (toFileChooser self)
  filterPtrs <- fromGSList filterList
  mapM (makeNewObject mkFileFilter . return) filterPtrs

-- | Sets the current filter; only the files that pass the filter will be
-- displayed. If the user-selectable list of filters is non-empty, then the
-- filter should be one of the filters in that list. Setting the current filter
-- when the list of filters is empty is useful if you want to restrict the
-- displayed set of files without letting the user change it.
--
fileChooserSetFilter :: FileChooserClass self => self -> FileFilter -> IO ()
fileChooserSetFilter self filter =
  (\(FileChooser arg1) (FileFilter arg2) -> withForeignPtr arg1 $ \argPtr1 ->withForeignPtr arg2 $ \argPtr2 ->gtk_file_chooser_set_filter argPtr1 argPtr2)
{-# LINE 796 "./Graphics/UI/Gtk/Selectors/FileChooser.chs" #-}
    (toFileChooser self)
    filter

-- | Gets the current filter; see 'fileChooserSetFilter'.
--
fileChooserGetFilter :: FileChooserClass self => self
 -> IO (Maybe FileFilter) -- ^ returns the current filter, or @Nothing@
fileChooserGetFilter self =
  maybeNull (makeNewObject mkFileFilter) $
  (\(FileChooser arg1) -> withForeignPtr arg1 $ \argPtr1 ->gtk_file_chooser_get_filter argPtr1)
{-# LINE 806 "./Graphics/UI/Gtk/Selectors/FileChooser.chs" #-}
    (toFileChooser self)

-- | Adds a folder to be displayed with the shortcut folders in a file
-- chooser. Note that shortcut folders do not get saved, as they are provided
-- by the application. For example, you can use this to add a
-- \"\/usr\/share\/mydrawprogram\/Clipart\" folder to the volume list.
--
-- If the folder can not be added successfully an exception will be thrown.
--
fileChooserAddShortcutFolder :: FileChooserClass self => self
 -> FilePath -- ^ @folder@ - filename of the folder to add
 -> IO ()
fileChooserAddShortcutFolder self folder =
  propagateGError $ \errorPtr ->
  withCString folder $ \folderPtr -> do



  (\(FileChooser arg1) arg2 arg3 -> withForeignPtr arg1 $ \argPtr1 ->gtk_file_chooser_add_shortcut_folder argPtr1 arg2 arg3)
{-# LINE 825 "./Graphics/UI/Gtk/Selectors/FileChooser.chs" #-}

    (toFileChooser self)
    folderPtr
    errorPtr
  return ()

-- | Removes a folder from a file chooser's list of shortcut folders.
--
-- If the folder can not be removed successfully an exception will be thrown.
--
fileChooserRemoveShortcutFolder :: FileChooserClass self => self
 -> FilePath -- ^ @folder@ - filename of the folder to remove
 -> IO ()
fileChooserRemoveShortcutFolder self folder =
  propagateGError $ \errorPtr ->
  withCString folder $ \folderPtr -> do



  (\(FileChooser arg1) arg2 arg3 -> withForeignPtr arg1 $ \argPtr1 ->gtk_file_chooser_remove_shortcut_folder argPtr1 arg2 arg3)
{-# LINE 845 "./Graphics/UI/Gtk/Selectors/FileChooser.chs" #-}

    (toFileChooser self)
    folderPtr
    errorPtr
  return ()

-- | Queries the list of shortcut folders in the file chooser, as set by
-- 'fileChooserAddShortcutFolder'.
--
fileChooserListShortcutFolders :: FileChooserClass self => self -> IO [String]
fileChooserListShortcutFolders self =



  (\(FileChooser arg1) -> withForeignPtr arg1 $ \argPtr1 ->gtk_file_chooser_list_shortcut_folders argPtr1)
{-# LINE 860 "./Graphics/UI/Gtk/Selectors/FileChooser.chs" #-}

    (toFileChooser self)
  >>= fromStringGSList

-- | Adds a folder URI to be displayed with the shortcut folders in a file
-- chooser. Note that shortcut folders do not get saved, as they are provided
-- by the application. For example, you can use this to add a
-- \"file:\/\/\/usr\/share\/mydrawprogram\/Clipart\" folder to the volume list.
--
-- If the folder can not be added successfully an exception will be thrown.
--
fileChooserAddShortcutFolderURI :: FileChooserClass self => self
 -> String -- ^ @uri@ - URI of the folder to add
 -> IO ()
fileChooserAddShortcutFolderURI self uri =
  propagateGError $ \errorPtr ->
  withCString uri $ \uriPtr -> do
  (\(FileChooser arg1) arg2 arg3 -> withForeignPtr arg1 $ \argPtr1 ->gtk_file_chooser_add_shortcut_folder_uri argPtr1 arg2 arg3)
{-# LINE 878 "./Graphics/UI/Gtk/Selectors/FileChooser.chs" #-}
    (toFileChooser self)
    uriPtr
    errorPtr
  return ()

-- | Removes a folder URI from a file chooser's list of shortcut folders.
--
fileChooserRemoveShortcutFolderURI :: FileChooserClass self => self
 -> String -- ^ @uri@ - URI of the folder to remove
 -> IO ()
fileChooserRemoveShortcutFolderURI self uri =
  propagateGError $ \errorPtr ->
  withCString uri $ \uriPtr -> do
  (\(FileChooser arg1) arg2 arg3 -> withForeignPtr arg1 $ \argPtr1 ->gtk_file_chooser_remove_shortcut_folder_uri argPtr1 arg2 arg3)
{-# LINE 892 "./Graphics/UI/Gtk/Selectors/FileChooser.chs" #-}
    (toFileChooser self)
    uriPtr
    errorPtr
  return ()

-- | Queries the list of shortcut folders in the file chooser, as set by
-- 'fileChooserAddShortcutFolderURI'.
--
fileChooserListShortcutFolderURIs :: FileChooserClass self => self -> IO [String]
fileChooserListShortcutFolderURIs self =
  (\(FileChooser arg1) -> withForeignPtr arg1 $ \argPtr1 ->gtk_file_chooser_list_shortcut_folder_uris argPtr1)
{-# LINE 903 "./Graphics/UI/Gtk/Selectors/FileChooser.chs" #-}
    (toFileChooser self)
  >>= fromStringGSList


-- | Sets whether hidden files and folders are displayed in the file selector.
--
-- Available since Gtk+ version 2.6
--
fileChooserSetShowHidden :: FileChooserClass self => self
 -> Bool -- ^ @showHidden@ - @True@ if hidden files and folders should be
          -- displayed.
 -> IO ()
fileChooserSetShowHidden self showHidden =
  (\(FileChooser arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->gtk_file_chooser_set_show_hidden argPtr1 arg2)
{-# LINE 917 "./Graphics/UI/Gtk/Selectors/FileChooser.chs" #-}
    (toFileChooser self)
    (fromBool showHidden)

-- | Gets whether hidden files and folders are displayed in the file selector.
-- See 'fileChooserSetShowHidden'.
--
-- * Available since Gtk+ version 2.6
--
fileChooserGetShowHidden :: FileChooserClass self => self
 -> IO Bool -- ^ returns @True@ if hidden files and folders are displayed.
fileChooserGetShowHidden self =
  liftM toBool $
  (\(FileChooser arg1) -> withForeignPtr arg1 $ \argPtr1 ->gtk_file_chooser_get_show_hidden argPtr1)
{-# LINE 930 "./Graphics/UI/Gtk/Selectors/FileChooser.chs" #-}
    (toFileChooser self)



-- | Sets whether a file chooser in 'FileChooserActionSave' mode will present
-- a confirmation dialog if the user types a file name that already exists.
-- This is @False@ by default.
--
-- Regardless of this setting, the @chooser@ will emit the
-- \"confirm-overwrite\" signal when appropriate.
--
-- If all you need is the stock confirmation dialog, set this property to
-- @True@. You can override the way confirmation is done by actually handling
-- the \"confirm-overwrite\" signal; please refer to its documentation for the
-- details.
--
-- Available since Gtk+ version 2.8
--
fileChooserSetDoOverwriteConfirmation :: FileChooserClass self => self
 -> Bool -- ^ @doOverwriteConfirmation@ - whether to confirm overwriting in
          -- save mode
 -> IO ()
fileChooserSetDoOverwriteConfirmation self doOverwriteConfirmation =
  (\(FileChooser arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->gtk_file_chooser_set_do_overwrite_confirmation argPtr1 arg2)
{-# LINE 954 "./Graphics/UI/Gtk/Selectors/FileChooser.chs" #-}
    (toFileChooser self)
    (fromBool doOverwriteConfirmation)

-- | Queries whether a file chooser is set to confirm for overwriting when the
-- user types a file name that already exists.
--
-- * Available since Gtk+ version 2.8
--
fileChooserGetDoOverwriteConfirmation :: FileChooserClass self => self
 -> IO Bool -- ^ returns @True@ if the file chooser will present a
            -- confirmation dialog; @False@ otherwise.
fileChooserGetDoOverwriteConfirmation self =
  liftM toBool $
  (\(FileChooser arg1) -> withForeignPtr arg1 $ \argPtr1 ->gtk_file_chooser_get_do_overwrite_confirmation argPtr1)
{-# LINE 968 "./Graphics/UI/Gtk/Selectors/FileChooser.chs" #-}
    (toFileChooser self)


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

-- | \'usePreviewLabel\' property. See 'fileChooserGetUsePreviewLabel' and
-- 'fileChooserSetUsePreviewLabel'
--
fileChooserUsePreviewLabel :: FileChooserClass self => Attr self Bool
fileChooserUsePreviewLabel = newAttr
  fileChooserGetUsePreviewLabel
  fileChooserSetUsePreviewLabel


-- | \'showHidden\' property. See 'fileChooserGetShowHidden' and
-- 'fileChooserSetShowHidden'
--
-- Since Gtk 2.6.
fileChooserShowHidden :: FileChooserClass self => Attr self Bool
fileChooserShowHidden = newAttr
  fileChooserGetShowHidden
  fileChooserSetShowHidden


-- | \'selectMultiple\' property. See 'fileChooserGetSelectMultiple' and
-- 'fileChooserSetSelectMultiple'
--
fileChooserSelectMultiple :: FileChooserClass self => Attr self Bool
fileChooserSelectMultiple = newAttr
  fileChooserGetSelectMultiple
  fileChooserSetSelectMultiple

-- | \'previewWidgetActive\' property. See 'fileChooserGetPreviewWidgetActive'
-- and 'fileChooserSetPreviewWidgetActive'
--
fileChooserPreviewWidgetActive :: FileChooserClass self => Attr self Bool
fileChooserPreviewWidgetActive = newAttr
  fileChooserGetPreviewWidgetActive
  fileChooserSetPreviewWidgetActive

-- | \'previewWidget\' property. See 'fileChooserGetPreviewWidget' and
-- 'fileChooserSetPreviewWidget'
--
fileChooserPreviewWidget :: (FileChooserClass self, WidgetClass previewWidget) => ReadWriteAttr self (Maybe Widget) previewWidget
fileChooserPreviewWidget = newAttr
  fileChooserGetPreviewWidget
  fileChooserSetPreviewWidget

-- | \'localOnly\' property. See 'fileChooserGetLocalOnly' and
-- 'fileChooserSetLocalOnly'
--
fileChooserLocalOnly :: FileChooserClass self => Attr self Bool
fileChooserLocalOnly = newAttr
  fileChooserGetLocalOnly
  fileChooserSetLocalOnly

-- | \'filter\' property. See 'fileChooserGetFilter' and
-- 'fileChooserSetFilter'
--
fileChooserFilter :: FileChooserClass self => ReadWriteAttr self (Maybe FileFilter) FileFilter
fileChooserFilter = newAttr
  fileChooserGetFilter
  fileChooserSetFilter

-- | \'extraWidget\' property. See 'fileChooserGetExtraWidget' and
-- 'fileChooserSetExtraWidget'
--
fileChooserExtraWidget :: (FileChooserClass self, WidgetClass extraWidget) => ReadWriteAttr self (Maybe Widget) extraWidget
fileChooserExtraWidget = newAttr
  fileChooserGetExtraWidget
  fileChooserSetExtraWidget


-- | \'doOverwriteConfirmation\' property. See
-- 'fileChooserGetDoOverwriteConfirmation' and
-- 'fileChooserSetDoOverwriteConfirmation'
--
fileChooserDoOverwriteConfirmation :: FileChooserClass self => Attr self Bool
fileChooserDoOverwriteConfirmation = newAttr
  fileChooserGetDoOverwriteConfirmation
  fileChooserSetDoOverwriteConfirmation


-- | \'action\' property. See 'fileChooserGetAction' and
-- 'fileChooserSetAction'
--
fileChooserAction :: FileChooserClass self => Attr self FileChooserAction
fileChooserAction = newAttr
  fileChooserGetAction
  fileChooserSetAction

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

-- | This signal is emitted when the current folder in a 'FileChooser'
-- changes. This can happen due to the user performing some action that changes
-- folders, such as selecting a bookmark or visiting a folder on the file list.
-- It can also happen as a result of calling a function to explicitly change
-- the current folder in a file chooser.
--
-- Normally you do not need to connect to this signal, unless you need to
-- keep track of which folder a file chooser is showing.
--
-- See also: 'fileChooserSetCurrentFolder', 'fileChooserGetCurrentFolder',
-- 'fileChooserSetCurrentFolderURI', 'fileChooserGetCurrentFolderURI'.
--
onCurrentFolderChanged, afterCurrentFolderChanged :: FileChooserClass self => self
 -> IO ()
 -> IO (ConnectId self)
onCurrentFolderChanged = connect_NONE__NONE "current-folder-changed" False
afterCurrentFolderChanged = connect_NONE__NONE "current-folder-changed" True

-- | This signal is emitted when there is a change in the set of selected
-- files in a 'FileChooser'. This can happen when the user modifies the
-- selection with the mouse or the keyboard, or when explicitly calling
-- functions to change the selection.
--
-- Normally you do not need to connect to this signal, as it is easier to
-- wait for the file chooser to finish running, and then to get the list of
-- selected files using the functions mentioned below.
--
-- See also: 'fileChooserSelectFilename', 'fileChooserUnselectFilename',
-- 'fileChooserGetFilename', 'fileChooserGetFilenames', 'fileChooserSelectURI',
-- 'fileChooserUnselectURI', 'fileChooserGetURI', 'fileChooserGetURIs'.
--
--onSelectionChanged, afterSelectionChanged :: FileChooserClass self => self
-- -> IO ()
-- -> IO (ConnectId self)
--onSelectionChanged = connect_NONE__NONE "selection-changed" False
--afterSelectionChanged = connect_NONE__NONE "selection-changed" True

-- | This signal is emitted when the preview in a file chooser should be
-- regenerated. For example, this can happen when the currently selected file
-- changes. You should use this signal if you want your file chooser to have a
-- preview widget.
--
-- Once you have installed a preview widget with
-- 'fileChooserSetPreviewWidget', you should update it when this signal is
-- emitted. You can use the functions 'fileChooserGetPreviewFilename' or
-- 'fileChooserGetPreviewURI' to get the name of the file to preview. Your
-- widget may not be able to preview all kinds of files; your callback must
-- call 'fileChooserSetPreviewWidgetActive' to inform the file chooser about
-- whether the preview was generated successfully or not.
--
-- See also: 'fileChooserSetPreviewWidget',
-- 'fileChooserSetPreviewWidgetActive', 'fileChooserSetUsePreviewLabel',
-- 'fileChooserGetPreviewFilename', 'fileChooserGetPreviewURI'.
--
onUpdatePreview, afterUpdatePreview :: FileChooserClass self => self
 -> IO ()
 -> IO (ConnectId self)
onUpdatePreview = connect_NONE__NONE "update-preview" False
afterUpdatePreview = connect_NONE__NONE "update-preview" True

-- | This signal is emitted when the user \"activates\" a file in the file
-- chooser. This can happen by double-clicking on a file in the file list, or
-- by pressing Enter.
--
-- Normally you do not need to connect to this signal. It is used internally
-- by 'FileChooserDialog' to know when to activate the default button in the
-- dialog.
--
-- See also: 'fileChooserGetFilename', 'fileChooserGetFilenames',
-- 'fileChooserGetURI', 'fileChooserGetURIs'.
--
onFileActivated, afterFileActivated :: FileChooserClass self => self
 -> IO ()
 -> IO (ConnectId self)
onFileActivated = connect_NONE__NONE "file-activated" False
afterFileActivated = connect_NONE__NONE "file-activated" True


-- | This signal gets emitted whenever it is appropriate to present a
-- confirmation dialog when the user has selected a file name that already
-- exists. The signal only gets emitted when the file chooser is in
-- 'FileChooserActionSave' mode.
--
-- Most applications just need to turn on the do-overwrite-confirmation
-- property (or call the 'fileChooserSetDoOverwriteConfirmation' function), and
-- they will automatically get a stock confirmation dialog. Applications which
-- need to customize this behavior should do that, and also connect to the
-- 'confirmOverwrite' signal.
--
-- A signal handler for this signal must return a 'FileChooserConfirmation'
-- value, which indicates the action to take. If the handler determines that
-- the user wants to select a different filename, it should return
-- 'FileChooserConfirmationSelectAgain'. If it determines that the user is
-- satisfied with his choice of file name, it should return
-- 'FileChooserConfirmationAcceptFilename'. On the other hand, if it determines
-- that the stock confirmation dialog should be used, it should return
-- 'FileChooserConfirmationConfirm'.
--
-- Since Gtk 2.8.
--
onConfirmOverwrite, afterConfirmOverwrite :: FileChooserClass self => self
 -> IO FileChooserConfirmation
 -> IO (ConnectId self)
onConfirmOverwrite = connect_NONE__ENUM "confirm-overwrite" False
afterConfirmOverwrite = connect_NONE__ENUM "confirm-overwrite" True




------------------------------------------------------
-- Utility functions that really ought to go elsewhere

-- convenience functions for GSlists of strings
fromStringGSList :: GSList -> IO [String]
fromStringGSList strList = do
  strPtrs <- fromGSList strList
  mapM readCString strPtrs

foreign import ccall unsafe "gtk_file_chooser_error_quark"
  gtk_file_chooser_error_quark :: (IO CUInt)

foreign import ccall safe "gtk_file_chooser_set_action"
  gtk_file_chooser_set_action :: ((Ptr FileChooser) -> (CInt -> (IO ())))

foreign import ccall safe "gtk_file_chooser_get_action"
  gtk_file_chooser_get_action :: ((Ptr FileChooser) -> (IO CInt))

foreign import ccall safe "gtk_file_chooser_set_local_only"
  gtk_file_chooser_set_local_only :: ((Ptr FileChooser) -> (CInt -> (IO ())))

foreign import ccall safe "gtk_file_chooser_get_local_only"
  gtk_file_chooser_get_local_only :: ((Ptr FileChooser) -> (IO CInt))

foreign import ccall safe "gtk_file_chooser_set_select_multiple"
  gtk_file_chooser_set_select_multiple :: ((Ptr FileChooser) -> (CInt -> (IO ())))

foreign import ccall safe "gtk_file_chooser_get_select_multiple"
  gtk_file_chooser_get_select_multiple :: ((Ptr FileChooser) -> (IO CInt))

foreign import ccall safe "gtk_file_chooser_set_current_name"
  gtk_file_chooser_set_current_name :: ((Ptr FileChooser) -> ((Ptr CChar) -> (IO ())))

foreign import ccall safe "gtk_file_chooser_get_filename"
  gtk_file_chooser_get_filename :: ((Ptr FileChooser) -> (IO (Ptr CChar)))

foreign import ccall safe "gtk_file_chooser_set_filename"
  gtk_file_chooser_set_filename :: ((Ptr FileChooser) -> ((Ptr CChar) -> (IO CInt)))

foreign import ccall safe "gtk_file_chooser_select_filename"
  gtk_file_chooser_select_filename :: ((Ptr FileChooser) -> ((Ptr CChar) -> (IO CInt)))

foreign import ccall safe "gtk_file_chooser_unselect_filename"
  gtk_file_chooser_unselect_filename :: ((Ptr FileChooser) -> ((Ptr CChar) -> (IO ())))

foreign import ccall safe "gtk_file_chooser_select_all"
  gtk_file_chooser_select_all :: ((Ptr FileChooser) -> (IO ()))

foreign import ccall safe "gtk_file_chooser_unselect_all"
  gtk_file_chooser_unselect_all :: ((Ptr FileChooser) -> (IO ()))

foreign import ccall safe "gtk_file_chooser_get_filenames"
  gtk_file_chooser_get_filenames :: ((Ptr FileChooser) -> (IO (Ptr ())))

foreign import ccall safe "gtk_file_chooser_set_current_folder"
  gtk_file_chooser_set_current_folder :: ((Ptr FileChooser) -> ((Ptr CChar) -> (IO CInt)))

foreign import ccall safe "gtk_file_chooser_get_current_folder"
  gtk_file_chooser_get_current_folder :: ((Ptr FileChooser) -> (IO (Ptr CChar)))

foreign import ccall safe "gtk_file_chooser_get_uri"
  gtk_file_chooser_get_uri :: ((Ptr FileChooser) -> (IO (Ptr CChar)))

foreign import ccall safe "gtk_file_chooser_set_uri"
  gtk_file_chooser_set_uri :: ((Ptr FileChooser) -> ((Ptr CChar) -> (IO CInt)))

foreign import ccall safe "gtk_file_chooser_select_uri"
  gtk_file_chooser_select_uri :: ((Ptr FileChooser) -> ((Ptr CChar) -> (IO CInt)))

foreign import ccall safe "gtk_file_chooser_unselect_uri"
  gtk_file_chooser_unselect_uri :: ((Ptr FileChooser) -> ((Ptr CChar) -> (IO ())))

foreign import ccall safe "gtk_file_chooser_get_uris"
  gtk_file_chooser_get_uris :: ((Ptr FileChooser) -> (IO (Ptr ())))

foreign import ccall safe "gtk_file_chooser_set_current_folder_uri"
  gtk_file_chooser_set_current_folder_uri :: ((Ptr FileChooser) -> ((Ptr CChar) -> (IO CInt)))

foreign import ccall safe "gtk_file_chooser_get_current_folder_uri"
  gtk_file_chooser_get_current_folder_uri :: ((Ptr FileChooser) -> (IO (Ptr CChar)))

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

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

foreign import ccall safe "gtk_file_chooser_set_preview_widget_active"
  gtk_file_chooser_set_preview_widget_active :: ((Ptr FileChooser) -> (CInt -> (IO ())))

foreign import ccall safe "gtk_file_chooser_get_preview_widget_active"
  gtk_file_chooser_get_preview_widget_active :: ((Ptr FileChooser) -> (IO CInt))

foreign import ccall safe "gtk_file_chooser_set_use_preview_label"
  gtk_file_chooser_set_use_preview_label :: ((Ptr FileChooser) -> (CInt -> (IO ())))

foreign import ccall safe "gtk_file_chooser_get_use_preview_label"
  gtk_file_chooser_get_use_preview_label :: ((Ptr FileChooser) -> (IO CInt))

foreign import ccall safe "gtk_file_chooser_get_preview_filename"
  gtk_file_chooser_get_preview_filename :: ((Ptr FileChooser) -> (IO (Ptr CChar)))

foreign import ccall safe "gtk_file_chooser_get_preview_uri"
  gtk_file_chooser_get_preview_uri :: ((Ptr FileChooser) -> (IO (Ptr CChar)))

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

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

foreign import ccall safe "gtk_file_chooser_add_filter"
  gtk_file_chooser_add_filter :: ((Ptr FileChooser) -> ((Ptr FileFilter) -> (IO ())))

foreign import ccall safe "gtk_file_chooser_remove_filter"
  gtk_file_chooser_remove_filter :: ((Ptr FileChooser) -> ((Ptr FileFilter) -> (IO ())))

foreign import ccall safe "gtk_file_chooser_list_filters"
  gtk_file_chooser_list_filters :: ((Ptr FileChooser) -> (IO (Ptr ())))

foreign import ccall safe "gtk_file_chooser_set_filter"
  gtk_file_chooser_set_filter :: ((Ptr FileChooser) -> ((Ptr FileFilter) -> (IO ())))

foreign import ccall safe "gtk_file_chooser_get_filter"
  gtk_file_chooser_get_filter :: ((Ptr FileChooser) -> (IO (Ptr FileFilter)))

foreign import ccall safe "gtk_file_chooser_add_shortcut_folder"
  gtk_file_chooser_add_shortcut_folder :: ((Ptr FileChooser) -> ((Ptr CChar) -> ((Ptr (Ptr ())) -> (IO CInt))))

foreign import ccall safe "gtk_file_chooser_remove_shortcut_folder"
  gtk_file_chooser_remove_shortcut_folder :: ((Ptr FileChooser) -> ((Ptr CChar) -> ((Ptr (Ptr ())) -> (IO CInt))))

foreign import ccall safe "gtk_file_chooser_list_shortcut_folders"
  gtk_file_chooser_list_shortcut_folders :: ((Ptr FileChooser) -> (IO (Ptr ())))

foreign import ccall safe "gtk_file_chooser_add_shortcut_folder_uri"
  gtk_file_chooser_add_shortcut_folder_uri :: ((Ptr FileChooser) -> ((Ptr CChar) -> ((Ptr (Ptr ())) -> (IO CInt))))

foreign import ccall safe "gtk_file_chooser_remove_shortcut_folder_uri"
  gtk_file_chooser_remove_shortcut_folder_uri :: ((Ptr FileChooser) -> ((Ptr CChar) -> ((Ptr (Ptr ())) -> (IO CInt))))

foreign import ccall safe "gtk_file_chooser_list_shortcut_folder_uris"
  gtk_file_chooser_list_shortcut_folder_uris :: ((Ptr FileChooser) -> (IO (Ptr ())))

foreign import ccall safe "gtk_file_chooser_set_show_hidden"
  gtk_file_chooser_set_show_hidden :: ((Ptr FileChooser) -> (CInt -> (IO ())))

foreign import ccall safe "gtk_file_chooser_get_show_hidden"
  gtk_file_chooser_get_show_hidden :: ((Ptr FileChooser) -> (IO CInt))

foreign import ccall safe "gtk_file_chooser_set_do_overwrite_confirmation"
  gtk_file_chooser_set_do_overwrite_confirmation :: ((Ptr FileChooser) -> (CInt -> (IO ())))

foreign import ccall safe "gtk_file_chooser_get_do_overwrite_confirmation"
  gtk_file_chooser_get_do_overwrite_confirmation :: ((Ptr FileChooser) -> (IO CInt))