1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116
|
{-# LANGUAGE CPP #-}
-- -*-haskell-*-
-- GIMP Toolkit (GTK) Widget FileChooserWidget
--
-- 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 widget that can be embedded in other widgets
--
-- * Module available since Gtk+ version 2.4
--
module Graphics.UI.Gtk.Selectors.FileChooserWidget (
-- * Detail
--
-- | 'FileChooserWidget' is a widget suitable for selecting files. It is the
-- main building block of a 'FileChooserDialog'. Most applications will only
-- need to use the latter; you can use 'FileChooserWidget' as part of a larger
-- window if you have special needs.
--
-- Note that 'FileChooserWidget' does not have any methods of its own.
-- Instead, you should use the functions that work on a 'FileChooser'.
-- * Class Hierarchy
-- |
-- @
-- | 'GObject'
-- | +----'Object'
-- | +----'Widget'
-- | +----'Container'
-- | +----'Box'
-- | +----'VBox'
-- | +----FileChooserWidget
-- @
#if GTK_CHECK_VERSION(2,4,0)
-- * Types
FileChooserWidget,
FileChooserWidgetClass,
castToFileChooserWidget, gTypeFileChooserWidget,
toFileChooserWidget,
-- * Constructors
FileChooserAction,
fileChooserWidgetNew,
fileChooserWidgetNewWithBackend,
#endif
) where
import Control.Monad (liftM)
import System.Glib.FFI
import Graphics.UI.Gtk.Abstract.Object
{#import Graphics.UI.Gtk.Types#}
#if GTK_CHECK_VERSION(2,4,0)
{#import Graphics.UI.Gtk.Selectors.FileChooser#} (FileChooserAction)
{# context lib="gtk" prefix="gtk" #}
--------------------
-- Interfaces
instance FileChooserClass FileChooserWidget
--------------------
-- Constructors
-- | Creates a new 'FileChooserWidget'. This is a file chooser widget that can
-- be embedded in custom windows, and it is the same widget that is used by
-- 'FileChooserDialog'.
--
fileChooserWidgetNew ::
FileChooserAction -- ^ @action@ - Open or save mode for the widget
-> IO FileChooserWidget
fileChooserWidgetNew action =
makeNewObject mkFileChooserWidget $
liftM (castPtr :: Ptr Widget -> Ptr FileChooserWidget) $
{# call unsafe gtk_file_chooser_widget_new #}
((fromIntegral . fromEnum) action)
-- | Creates a new 'FileChooserWidget' with a specified backend. This is
-- especially useful if you use 'fileChooserSetLocalOnly' to allow non-local
-- files. This is a file chooser widget that can be embedded in custom windows
-- and it is the same widget that is used by 'FileChooserDialog'.
--
fileChooserWidgetNewWithBackend ::
FileChooserAction -- ^ @action@ - Open or save mode for the widget
-> String -- ^ @backend@ - The name of the specific filesystem
-- backend to use.
-> IO FileChooserWidget
fileChooserWidgetNewWithBackend action backend =
makeNewObject mkFileChooserWidget $
liftM (castPtr :: Ptr Widget -> Ptr FileChooserWidget) $
withCString backend $ \backendPtr ->
{# call unsafe gtk_file_chooser_widget_new_with_backend #}
((fromIntegral . fromEnum) action)
backendPtr
#endif
|