From: Duncan C. <dun...@us...> - 2005-04-03 12:56:20
|
Update of /cvsroot/gtk2hs/gtk2hs/gtk/Graphics/UI/Gtk/Selectors In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18765/gtk/Graphics/UI/Gtk/Selectors Modified Files: ColorSelection.chs ColorSelectionDialog.chs FileChooser.chs.pp FileChooserDialog.chs.pp FileChooserWidget.chs.pp FileSelection.chs.pp FontSelection.chs FontSelectionDialog.chs Log Message: Merge from generated modules. Changed code formatting and documentation. Index: FontSelection.chs =================================================================== RCS file: /cvsroot/gtk2hs/gtk2hs/gtk/Graphics/UI/Gtk/Selectors/FontSelection.chs,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- FontSelection.chs 13 Mar 2005 19:34:37 -0000 1.4 +++ FontSelection.chs 3 Apr 2005 12:56:07 -0000 1.5 @@ -24,10 +24,10 @@ -- Stability : provisional -- Portability : portable (depends on GHC) -- --- A widget for selecting fonts. +-- A widget for selecting fonts -- module Graphics.UI.Gtk.Selectors.FontSelection ( --- * Description +-- * Detail -- -- | The 'FontSelection' widget lists the available fonts, styles and sizes, -- allowing the user to select a font. It is used in the 'FontSelectionDialog' @@ -90,40 +90,50 @@ -- fontSelectionNew :: IO FontSelection fontSelectionNew = - makeNewObject mkFontSelection $ liftM castPtr $ - {#call unsafe font_selection_new#} + makeNewObject mkFontSelection $ + liftM (castPtr :: Ptr Widget -> Ptr FontSelection) $ + {# call unsafe font_selection_new #} -------------------- -- Methods --- | Gets the currently-selected font name. Returns Nothing if no font is --- selected. +-- | Gets the currently-selected font name. -- -fontSelectionGetFontName :: FontSelectionClass obj => obj -> IO (Maybe String) -fontSelectionGetFontName obj = - {#call unsafe font_selection_get_font_name#} (toFontSelection obj) - >>= maybePeek readUTFString +fontSelectionGetFontName :: FontSelectionClass self => self + -> IO (Maybe String) -- ^ returns @Nothing@ if no font is selected. +fontSelectionGetFontName self = + {# call unsafe font_selection_get_font_name #} + (toFontSelection self) + >>= maybePeek readUTFString --- | Sets the currently-selected font. Returns False if the font was not found. +-- | Sets the currently-selected font. -- -fontSelectionSetFontName :: FontSelectionClass obj => obj -> String -> IO Bool -fontSelectionSetFontName obj fontname = liftM toBool $ - withUTFString fontname $ \strPtr -> - {#call font_selection_set_font_name#} (toFontSelection obj) strPtr +fontSelectionSetFontName :: FontSelectionClass self => self + -> String -- ^ @fontname@ - a fontname. + -> IO Bool -- ^ returns @True@ if the font was found. +fontSelectionSetFontName self fontname = + liftM toBool $ + withUTFString fontname $ \fontnamePtr -> + {# call font_selection_set_font_name #} + (toFontSelection self) + fontnamePtr -- | Gets the text displayed in the preview area. -- -fontSelectionGetPreviewText :: FontSelectionClass obj => obj -> IO String -fontSelectionGetPreviewText obj = - {#call unsafe font_selection_get_preview_text#} (toFontSelection obj) - >>= peekUTFString +fontSelectionGetPreviewText :: FontSelectionClass self => self -> IO String +fontSelectionGetPreviewText self = + {# call unsafe font_selection_get_preview_text #} + (toFontSelection self) + >>= peekUTFString -- | Sets the text displayed in the preview area. -- -fontSelectionSetPreviewText :: FontSelectionClass obj => obj -> String -> IO () -fontSelectionSetPreviewText obj text = - withUTFString text $ \strPtr -> - {#call font_selection_set_preview_text#} (toFontSelection obj) strPtr +fontSelectionSetPreviewText :: FontSelectionClass self => self -> String -> IO () +fontSelectionSetPreviewText self text = + withUTFString text $ \textPtr -> + {# call font_selection_set_preview_text #} + (toFontSelection self) + textPtr -------------------- -- Properties @@ -132,7 +142,7 @@ -- -- Default value: \"abcdefghijk ABCDEFGHIJK\" -- -fontSelectionPreviewText :: Attr FontSelection String +fontSelectionPreviewText :: FontSelectionClass self => Attr self String fontSelectionPreviewText = Attr fontSelectionGetPreviewText fontSelectionSetPreviewText Index: FontSelectionDialog.chs =================================================================== RCS file: /cvsroot/gtk2hs/gtk2hs/gtk/Graphics/UI/Gtk/Selectors/FontSelectionDialog.chs,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- FontSelectionDialog.chs 13 Mar 2005 19:34:37 -0000 1.4 +++ FontSelectionDialog.chs 3 Apr 2005 12:56:07 -0000 1.5 @@ -24,10 +24,10 @@ -- Stability : provisional -- Portability : portable (depends on GHC) -- --- A dialog box for selecting fonts. +-- A dialog box for selecting fonts -- module Graphics.UI.Gtk.Selectors.FontSelectionDialog ( --- * Description +-- * Detail -- -- | The 'FontSelectionDialog' widget is a dialog box for selecting a font. -- @@ -87,48 +87,57 @@ -- | Creates a new 'FontSelectionDialog'. -- -fontSelectionDialogNew :: String -> IO FontSelectionDialog +fontSelectionDialogNew :: + String -- ^ @title@ - the title of the dialog box. + -> IO FontSelectionDialog fontSelectionDialogNew title = - makeNewObject mkFontSelectionDialog $ liftM castPtr $ - withUTFString title $ \strPtr -> - {#call unsafe font_selection_dialog_new#} strPtr + makeNewObject mkFontSelectionDialog $ + liftM (castPtr :: Ptr Widget -> Ptr FontSelectionDialog) $ + withUTFString title $ \titlePtr -> + {# call unsafe font_selection_dialog_new #} + titlePtr -------------------- -- Methods --- | Gets the currently-selected font name. Returns Nothing if no font is --- selected. +-- | Gets the currently-selected font name. -- -fontSelectionDialogGetFontName :: FontSelectionDialogClass obj => obj - -> IO (Maybe String) -fontSelectionDialogGetFontName obj = - {#call font_selection_dialog_get_font_name#} (toFontSelectionDialog obj) - >>= maybePeek readUTFString +fontSelectionDialogGetFontName :: FontSelectionDialogClass self => self + -> IO (Maybe String) -- ^ returns the currently-selected font name, or + -- @Nothing@ if no font is selected. +fontSelectionDialogGetFontName self = + {# call font_selection_dialog_get_font_name #} + (toFontSelectionDialog self) + >>= maybePeek readUTFString --- | Sets the currently-selected font. Returns False if the font was not found. +-- | Sets the currently-selected font. -- -fontSelectionDialogSetFontName :: FontSelectionDialogClass obj => obj -> String -> IO Bool -fontSelectionDialogSetFontName obj fontname = liftM toBool $ - withUTFString fontname $ \strPtr -> - {#call font_selection_dialog_set_font_name#} (toFontSelectionDialog obj) - strPtr +fontSelectionDialogSetFontName :: FontSelectionDialogClass self => self + -> String -- ^ @fontname@ - a fontname. + -> IO Bool -- ^ returns @True@ if the font was found. +fontSelectionDialogSetFontName self fontname = + liftM toBool $ + withUTFString fontname $ \fontnamePtr -> + {# call font_selection_dialog_set_font_name #} + (toFontSelectionDialog self) + fontnamePtr -- | Gets the text displayed in the preview area. -- -fontSelectionDialogGetPreviewText :: FontSelectionDialogClass obj => obj - -> IO String -fontSelectionDialogGetPreviewText obj = - {#call unsafe font_selection_dialog_get_preview_text#} (toFontSelectionDialog obj) - >>= peekUTFString +fontSelectionDialogGetPreviewText :: FontSelectionDialogClass self => self -> IO String +fontSelectionDialogGetPreviewText self = + {# call unsafe font_selection_dialog_get_preview_text #} + (toFontSelectionDialog self) + >>= peekUTFString -- | Sets the text displayed in the preview area. -- -fontSelectionDialogSetPreviewText :: FontSelectionDialogClass obj => obj - -> String -> IO () -fontSelectionDialogSetPreviewText obj text = - withUTFString text $ \strPtr -> - {#call font_selection_dialog_set_preview_text#} (toFontSelectionDialog obj) - strPtr +fontSelectionDialogSetPreviewText :: FontSelectionDialogClass self => self -> String -> IO () +fontSelectionDialogSetPreviewText self text = + withUTFString text $ \textPtr -> + {# call font_selection_dialog_set_preview_text #} + (toFontSelectionDialog self) + textPtr -------------------- -- Properties @@ -136,7 +145,7 @@ -- | \'previewText\' property. See 'fontSelectionDialogGetPreviewText' and -- 'fontSelectionDialogSetPreviewText' -- -fontSelectionDialogPreviewText :: Attr FontSelectionDialog String +fontSelectionDialogPreviewText :: FontSelectionDialogClass self => Attr self String fontSelectionDialogPreviewText = Attr fontSelectionDialogGetPreviewText fontSelectionDialogSetPreviewText Index: FileChooserDialog.chs.pp =================================================================== RCS file: /cvsroot/gtk2hs/gtk2hs/gtk/Graphics/UI/Gtk/Selectors/FileChooserDialog.chs.pp,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- FileChooserDialog.chs.pp 25 Feb 2005 22:53:42 -0000 1.4 +++ FileChooserDialog.chs.pp 3 Apr 2005 12:56:07 -0000 1.5 @@ -24,16 +24,13 @@ -- Stability : provisional -- Portability : portable (depends on GHC) -- --- The file chooser dialog and widget is a replacement --- for the old "FileSel"ection dialog. It provides a better user --- interface and an improved API. --- --- * This is the dialog variant of the 'FileChooser' +-- A file chooser dialog, suitable for \"File\/Open\" or \"File\/Save\" +-- commands -- --- * Added in GTK+ 2.4 +-- * Module available since Gtk+ version 2.4 -- module Graphics.UI.Gtk.Selectors.FileChooserDialog ( --- * Description +-- * Detail -- -- | 'FileChooserDialog' is a dialog box suitable for use with \"File\/Open\" -- or \"File\/Save as\" commands. This widget works by putting a @@ -44,8 +41,6 @@ -- -- Note that 'FileChooserDialog' does not have any methods of its own. -- Instead, you should use the functions that work on a 'FileChooser'. --- --- * Module available since Gtk version 2.4 -- ** Response Codes -- @@ -78,8 +73,6 @@ #endif ) where -#if GTK_CHECK_VERSION(2,4,0) - import Monad (liftM, when) import Maybe (isJust, fromJust) @@ -95,6 +88,7 @@ {# context lib="gtk" prefix="gtk" #} +#if GTK_CHECK_VERSION(2,4,0) -------------------- -- Interfaces @@ -103,6 +97,8 @@ -------------------- -- Constructors +-- | Creates a new 'FileChooserDialog'. +-- fileChooserDialogNew :: Maybe String -- ^ Title of the dialog (or default) -> Maybe Window -- ^ Transient parent of the dialog (or none) @@ -112,6 +108,10 @@ fileChooserDialogNew title parent action buttons = internalFileChooserDialogNew title parent action buttons Nothing +-- | Creates a new 'FileChooserDialog' with a specified backend. This is +-- especially useful if you use 'fileChooserSetLocalOnly' to allow non-local +-- files and you use a more expressive vfs, such as gnome-vfs, to load files. +-- fileChooserDialogNewWithBackend :: Maybe String -- ^ Title of the dialog (or default) -> Maybe Window -- ^ Transient parent of the dialog (or none) @@ -121,7 +121,6 @@ -> IO FileChooserDialog fileChooserDialogNewWithBackend title parent action buttons backend = internalFileChooserDialogNew title parent action buttons (Just backend) - -- Annoyingly, the constructor for FileChooserDialog uses varargs so we can't -- call it using the Haskell FFI. The GTK people do not consider this an api @@ -150,5 +149,4 @@ mapM_ (\(btnName, btnResponse) -> dialogAddButton dialog btnName btnResponse) buttons return dialog - #endif Index: FileSelection.chs.pp =================================================================== RCS file: /cvsroot/gtk2hs/gtk2hs/gtk/Graphics/UI/Gtk/Selectors/FileSelection.chs.pp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- FileSelection.chs.pp 26 Feb 2005 02:17:27 -0000 1.1 +++ FileSelection.chs.pp 3 Apr 2005 12:56:07 -0000 1.2 @@ -28,12 +28,12 @@ -- Stability : provisional -- Portability : portable (depends on GHC) -- --- Prompt the user for a file or directory name. +-- Prompt the user for a file or directory name -- -- * As of Gtk+ 2.4 this module has been deprecated in favour of 'FileChooser' -- module Graphics.UI.Gtk.Selectors.FileSelection ( --- * Description +-- * Detail -- -- | 'FileSelection' should be used to retrieve file or directory names from -- the user. It will create a new dialog window containing a directory list, @@ -84,30 +84,38 @@ fileSelectionShowFileopButtons, fileSelectionHideFileopButtons, fileSelectionGetButtons, - fileSelectionComplete + fileSelectionComplete, + +-- * Properties + fileSelectionFilename ) where import Monad (liftM) import System.Glib.FFI import System.Glib.UTFString +import System.Glib.Attributes (Attr(..)) {#import Graphics.UI.Gtk.Types#} -import Graphics.UI.Gtk.Abstract.Object (makeNewObject) -import Graphics.UI.Gtk.General.Structs (fileSelectionGetButtons) +import Graphics.UI.Gtk.Abstract.Object (makeNewObject) +import Graphics.UI.Gtk.General.Structs (fileSelectionGetButtons) {# context lib="libgtk" prefix="gtk" #} -------------------- -- Constructors --- | Create a new file selection dialog with --- the given window title. +-- | Creates a new file selection dialog box. By default it will contain a +-- 'TreeView' of the application's current working directory, and a file +-- listing. Operation buttons that allow the user to create a directory, delete +-- files and rename files, are also present. -- -fileSelectionNew :: - String +fileSelectionNew :: + String -- ^ @title@ - a message that will be placed in the file + -- requestor's titlebar. -> IO FileSelection fileSelectionNew title = - makeNewObject mkFileSelection $ liftM castPtr $ + makeNewObject mkFileSelection $ + liftM (castPtr :: Ptr Widget -> Ptr FileSelection) $ withUTFString title $ \titlePtr -> {# call unsafe file_selection_new #} titlePtr @@ -115,46 +123,58 @@ -------------------- -- Methods --- | Set the filename for the given file --- selection dialog. +-- | Sets a default path for the file requestor. If @filename@ includes a +-- directory path, then the requestor will open with that path as its current +-- working directory. -- -fileSelectionSetFilename :: FileSelectionClass fsel => fsel -> String -> IO () -fileSelectionSetFilename fsel str = - withUTFString str $ \strPtr -> +-- This has the consequence that in order to open the requestor with a +-- working directory and an empty filename, @filename@ must have a trailing +-- directory separator. +-- +fileSelectionSetFilename :: FileSelectionClass self => self + -> String -- ^ @filename@ - a string to set as the default file name. + -> IO () +fileSelectionSetFilename self filename = + withUTFString filename $ \filenamePtr -> #if defined (WIN32) && GTK_CHECK_VERSION(2,6,0) - {#call unsafe file_selection_set_filename_utf8#} + {# call unsafe gtk_file_selection_set_filename_utf8 #} #else - {#call unsafe file_selection_set_filename#} + {# call unsafe gtk_file_selection_set_filename #} #endif - (toFileSelection fsel) strPtr + (toFileSelection self) + filenamePtr --- | Get the filename currently selected by --- the given file selection dialog. +-- | This function returns the selected filename. -- -fileSelectionGetFilename :: FileSelectionClass fsel => fsel -> IO String -fileSelectionGetFilename fsel = - do +-- If no file is selected then the selected directory path is returned. +-- +fileSelectionGetFilename :: FileSelectionClass self => self + -> IO String -- ^ returns currently-selected filename +fileSelectionGetFilename self = #if defined (WIN32) && GTK_CHECK_VERSION(2,6,0) - strPtr <- {#call unsafe file_selection_get_filename_utf8#} + {# call unsafe gtk_file_selection_get_filename_utf8 #} #else - strPtr <- {#call unsafe file_selection_get_filename#} + {# call unsafe gtk_file_selection_get_filename #} #endif - (toFileSelection fsel) - peekUTFString strPtr + (toFileSelection self) + >>= peekUTFString --- | Show the file operation buttons --- of the given file selection dialog. +-- | Shows the file operation buttons, if they have previously been hidden. +-- The rest of the widgets in the dialog will be resized accordingly. -- -fileSelectionShowFileopButtons :: FileSelectionClass fsel => fsel -> IO () -fileSelectionShowFileopButtons = - {#call file_selection_show_fileop_buttons#} . toFileSelection +fileSelectionShowFileopButtons :: FileSelectionClass self => self -> IO () +fileSelectionShowFileopButtons self = + {# call file_selection_show_fileop_buttons #} + (toFileSelection self) --- | Hide the file operation buttons --- of the given file selection dialog. +-- | Hides the file operation buttons that normally appear at the top of the +-- dialog. Useful if you wish to create a custom file selector, based on +-- 'FileSelection'. -- -fileSelectionHideFileopButtons :: FileSelectionClass fsel => fsel -> IO () -fileSelectionHideFileopButtons = - {#call file_selection_hide_fileop_buttons#} . toFileSelection +fileSelectionHideFileopButtons :: FileSelectionClass self => self -> IO () +fileSelectionHideFileopButtons self = + {# call file_selection_hide_fileop_buttons #} + (toFileSelection self) -- currently broken -- -- query the widgets of the file selectors buttons @@ -172,9 +192,30 @@ -- cancel <- {#get FileSelection.cancel_button#} ptr -- return (castToButton ok, castToButton cancel) --- | Only show files matching pattern. +-- | Will attempt to match @pattern@ to a valid filenames or subdirectories in +-- the current directory. If a match can be made, the matched filename will +-- appear in the text entry field of the file selection dialog. If a partial +-- match can be made, the \"Files\" list will contain those file names which +-- have been partially matched, and the \"Folders\" list those directories +-- which have been partially matched. -- -fileSelectionComplete :: FileSelectionClass fsel => fsel -> String -> IO () -fileSelectionComplete fsel pattern = +fileSelectionComplete :: FileSelectionClass self => self + -> String -- ^ @pattern@ - a string of characters which may or may not match + -- any filenames in the current directory. + -> IO () +fileSelectionComplete self pattern = withUTFString pattern $ \patternPtr -> - {#call file_selection_complete#} (toFileSelection fsel) patternPtr + {# call file_selection_complete #} + (toFileSelection self) + patternPtr + +-------------------- +-- Properties + +-- | The currently selected filename. +-- +-- +fileSelectionFilename :: FileSelectionClass self => Attr self String +fileSelectionFilename = Attr + fileSelectionGetFilename + fileSelectionSetFilename Index: ColorSelectionDialog.chs =================================================================== RCS file: /cvsroot/gtk2hs/gtk2hs/gtk/Graphics/UI/Gtk/Selectors/ColorSelectionDialog.chs,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- ColorSelectionDialog.chs 25 Feb 2005 01:11:37 -0000 1.3 +++ ColorSelectionDialog.chs 3 Apr 2005 12:56:07 -0000 1.4 @@ -24,10 +24,10 @@ -- Stability : provisional -- Portability : portable (depends on GHC) -- --- A standard dialog box for selecting a color. +-- A standard dialog box for selecting a color -- module Graphics.UI.Gtk.Selectors.ColorSelectionDialog ( --- * Description +-- * Detail -- -- | The 'ColorSelectionDialog' provides a standard dialog which allows the -- user to select a color much like the 'FileSelection' provides a standard @@ -70,8 +70,13 @@ -- | Creates a new 'ColorSelectionDialog'. -- -colorSelectionDialogNew :: String -> IO ColorSelectionDialog +colorSelectionDialogNew :: + String -- ^ @title@ - a string containing the title text + -- for the dialog. + -> IO ColorSelectionDialog colorSelectionDialogNew title = - makeNewObject mkColorSelectionDialog $ liftM castPtr $ - withUTFString title $ \strPtr -> - {#call unsafe color_selection_dialog_new#} strPtr + makeNewObject mkColorSelectionDialog $ + liftM (castPtr :: Ptr Widget -> Ptr ColorSelectionDialog) $ + withUTFString title $ \titlePtr -> + {# call unsafe color_selection_dialog_new #} + titlePtr Index: FileChooser.chs.pp =================================================================== RCS file: /cvsroot/gtk2hs/gtk2hs/gtk/Graphics/UI/Gtk/Selectors/FileChooser.chs.pp,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- FileChooser.chs.pp 13 Mar 2005 19:34:37 -0000 1.6 +++ FileChooser.chs.pp 3 Apr 2005 12:56:07 -0000 1.7 @@ -1,5 +1,5 @@ -- -*-haskell-*- --- GIMP Toolkit (GTK) FileChooser +-- GIMP Toolkit (GTK) Interface FileChooser -- -- Author : Duncan Coutts -- @@ -24,24 +24,20 @@ -- Stability : provisional -- Portability : portable (depends on GHC) -- --- The file chooser dialog and widget is a replacement [...975 lines suppressed...] +-- +-- 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 +#endif ------------------------------------------------------ -- Utility functions that really ought to go elsewhere @@ -576,6 +957,3 @@ toStringGSList strs = do strPtrs <- mapM newCString strs toGSList strPtrs - -#endif - Index: ColorSelection.chs =================================================================== RCS file: /cvsroot/gtk2hs/gtk2hs/gtk/Graphics/UI/Gtk/Selectors/ColorSelection.chs,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- ColorSelection.chs 13 Mar 2005 19:34:37 -0000 1.5 +++ ColorSelection.chs 3 Apr 2005 12:56:07 -0000 1.6 @@ -24,10 +24,10 @@ -- Stability : provisional -- Portability : portable (depends on GHC) -- --- A widget used to select a color. +-- A widget used to select a color -- module Graphics.UI.Gtk.Selectors.ColorSelection ( --- * Description +-- * Detail -- -- | The 'ColorSelection' is a widget that is used to select a color. It -- consists of a color wheel and number of sliders and entry boxes for color @@ -90,128 +90,152 @@ -------------------- -- Constructors --- | Creates a new ColorSelection widget. +-- | Creates a new 'ColorSelection'. -- colorSelectionNew :: IO ColorSelection colorSelectionNew = - makeNewObject mkColorSelection $ liftM castPtr $ - {#call unsafe color_selection_new#} + makeNewObject mkColorSelection $ + liftM (castPtr :: Ptr Widget -> Ptr ColorSelection) $ + {# call unsafe color_selection_new #} -------------------- -- Methods -- | Returns the current alpha value. -- --- * The alpha value is represented by an integer between 0 and 65535. --- -colorSelectionGetCurrentAlpha :: ColorSelectionClass obj => obj -> IO Int -colorSelectionGetCurrentAlpha obj = liftM fromIntegral $ - {#call unsafe color_selection_get_current_alpha#} (toColorSelection obj) +colorSelectionGetCurrentAlpha :: ColorSelectionClass self => self + -> IO Int -- ^ returns an integer between 0 and 65535. +colorSelectionGetCurrentAlpha self = + liftM fromIntegral $ + {# call unsafe color_selection_get_current_alpha #} + (toColorSelection self) --- | Sets the current opacity. The first time this is called, it will also set --- the original opacity too. --- --- * The alpha value is represented by an integer between 0 and 65535. +-- | Sets the current opacity to be @alpha@. The first time this is called, it +-- will also set the original opacity to be @alpha@ too. -- -colorSelectionSetCurrentAlpha :: ColorSelectionClass obj => obj -> Int -> IO () -colorSelectionSetCurrentAlpha obj alpha = - {#call color_selection_set_current_alpha#} (toColorSelection obj) +colorSelectionSetCurrentAlpha :: ColorSelectionClass self => self + -> Int -- ^ @alpha@ - an integer between 0 and 65535. + -> IO () +colorSelectionSetCurrentAlpha self alpha = + {# call color_selection_set_current_alpha #} + (toColorSelection self) (fromIntegral alpha) --- | Gets the current color in the ColorSelection widget. +-- | Gets the current color in the 'ColorSelection' widget. -- -colorSelectionGetCurrentColor :: ColorSelectionClass obj => obj -> IO Color -colorSelectionGetCurrentColor obj = +colorSelectionGetCurrentColor :: ColorSelectionClass self => self -> IO Color +colorSelectionGetCurrentColor self = alloca $ \colorPtr -> do - {#call unsafe color_selection_get_current_color#} (toColorSelection obj) + {# call unsafe color_selection_get_current_color #} + (toColorSelection self) (castPtr colorPtr) peek colorPtr --- | Sets the current color. The first time this is called, it will also set the --- original color too. +-- | Sets the current color to be @color@. The first time this is called, it +-- will also set the original color to be @color@ too. -- -colorSelectionSetCurrentColor :: ColorSelectionClass obj => obj - -> Color -> IO () -colorSelectionSetCurrentColor obj color = - alloca $ \colorPtr -> do - poke colorPtr color - {#call color_selection_set_current_color#} (toColorSelection obj) +colorSelectionSetCurrentColor :: ColorSelectionClass self => self + -> Color -- ^ @color@ - A 'Color' to set the current color with. + -> IO () +colorSelectionSetCurrentColor self color = + with color $ \colorPtr -> + {# call color_selection_set_current_color #} + (toColorSelection self) (castPtr colorPtr) --- | Sets the ColorSelection widget to use or not use opacity. +-- | Determines whether the 'ColorSelection' widget has an opacity control. -- -colorSelectionGetHasOpacityControl :: ColorSelectionClass obj => obj -> IO Bool -colorSelectionGetHasOpacityControl obj = liftM toBool $ - {#call unsafe color_selection_get_has_opacity_control#} (toColorSelection obj) +colorSelectionGetHasOpacityControl :: ColorSelectionClass self => self + -> IO Bool -- ^ returns @True@ if the color selector has an opacity control. + -- @False@ if it does't. +colorSelectionGetHasOpacityControl self = + liftM toBool $ + {# call unsafe color_selection_get_has_opacity_control #} + (toColorSelection self) --- | Determines whether the ColorSelection widget has an opacity control. +-- | Sets the 'ColorSelection' widget to use or not use opacity. -- -colorSelectionSetHasOpacityControl :: ColorSelectionClass obj => obj - -> Bool -> IO () -colorSelectionSetHasOpacityControl obj hasOpacity = - {#call color_selection_set_has_opacity_control#} (toColorSelection obj) +colorSelectionSetHasOpacityControl :: ColorSelectionClass self => self + -> Bool -- ^ @hasOpacity@ - @True@ if color selector can set the opacity, + -- @False@ otherwise. + -> IO () +colorSelectionSetHasOpacityControl self hasOpacity = + {# call color_selection_set_has_opacity_control #} + (toColorSelection self) (fromBool hasOpacity) -- | Determines whether the color selector has a color palette. -- -colorSelectionGetHasPalette :: ColorSelectionClass obj => obj -> IO Bool -colorSelectionGetHasPalette obj = liftM toBool $ - {#call unsafe color_selection_get_has_palette#} (toColorSelection obj) +colorSelectionGetHasPalette :: ColorSelectionClass self => self + -> IO Bool -- ^ returns @True@ if the selector has a palette. @False@ if it + -- hasn't. +colorSelectionGetHasPalette self = + liftM toBool $ + {# call unsafe color_selection_get_has_palette #} + (toColorSelection self) -- | Sets whether to show or hide the palette. -- -colorSelectionSetHasPalette :: ColorSelectionClass obj => obj -> Bool -> IO () -colorSelectionSetHasPalette obj hasPalette = - {#call color_selection_set_has_palette#} (toColorSelection obj) +colorSelectionSetHasPalette :: ColorSelectionClass self => self + -> Bool -- ^ @hasPalette@ - @True@ if palette is to be visible, @False@ + -- otherwise. + -> IO () +colorSelectionSetHasPalette self hasPalette = + {# call color_selection_set_has_palette #} + (toColorSelection self) (fromBool hasPalette) -- | Returns the previous alpha value. -- -colorSelectionGetPreviousAlpha :: ColorSelectionClass obj => obj -> IO Int -colorSelectionGetPreviousAlpha obj = liftM fromIntegral $ - {#call unsafe color_selection_get_previous_alpha#} (toColorSelection obj) +colorSelectionGetPreviousAlpha :: ColorSelectionClass self => self + -> IO Int -- ^ returns an integer between 0 and 65535. +colorSelectionGetPreviousAlpha self = + liftM fromIntegral $ + {# call unsafe color_selection_get_previous_alpha #} + (toColorSelection self) --- | Sets the \'previous\' alpha to the given value. --- --- * This function should be called with some hesitations, as it might seem --- confusing to have that alpha change. +-- | Sets the \'previous\' alpha to be @alpha@. This function should be called +-- with some hesitations, as it might seem confusing to have that alpha change. -- -colorSelectionSetPreviousAlpha :: ColorSelectionClass obj => obj -> Int -> IO () -colorSelectionSetPreviousAlpha obj alpha = - {#call color_selection_set_previous_alpha#} (toColorSelection obj) +colorSelectionSetPreviousAlpha :: ColorSelectionClass self => self + -> Int -- ^ @alpha@ - an integer between 0 and 65535. + -> IO () +colorSelectionSetPreviousAlpha self alpha = + {# call color_selection_set_previous_alpha #} + (toColorSelection self) (fromIntegral alpha) -- | Returns the original color value. -- -colorSelectionGetPreviousColor :: ColorSelectionClass obj => obj -> IO Color -colorSelectionGetPreviousColor obj = +colorSelectionGetPreviousColor :: ColorSelectionClass self => self -> IO Color +colorSelectionGetPreviousColor self = alloca $ \colorPtr -> do - {#call unsafe color_selection_get_previous_color#} (toColorSelection obj) + {# call unsafe color_selection_get_previous_color #} + (toColorSelection self) (castPtr colorPtr) peek colorPtr --- | Sets the \'previous\' color. --- --- * This function should be called with some hesitations, as it might seem --- confusing to have that color change. --- --- * Calling 'colorSelectionSetCurrentColor' will also set this color the first +-- | Sets the \'previous\' color to be @color@. This function should be called +-- with some hesitations, as it might seem confusing to have that color change. +-- Calling 'colorSelectionSetCurrentColor' will also set this color the first -- time it is called. -- -colorSelectionSetPreviousColor :: ColorSelectionClass obj => obj - -> Color -> IO () -colorSelectionSetPreviousColor obj color = - alloca $ \colorPtr -> do - poke colorPtr color - {#call color_selection_set_previous_color#} (toColorSelection obj) +colorSelectionSetPreviousColor :: ColorSelectionClass self => self + -> Color -> IO () +colorSelectionSetPreviousColor self color = + with color $ \colorPtr -> + {# call color_selection_set_previous_color #} + (toColorSelection self) (castPtr colorPtr) -- | Gets the current state of the widget. Returns True if the user is currently -- dragging a color around, and False if the selection has stopped. -- -colorSelectionIsAdjusting :: ColorSelectionClass obj => obj -> IO Bool -colorSelectionIsAdjusting obj = liftM toBool $ - {#call unsafe color_selection_is_adjusting#} (toColorSelection obj) +colorSelectionIsAdjusting :: ColorSelectionClass self => self -> IO Bool +colorSelectionIsAdjusting self = + liftM toBool $ + {# call unsafe color_selection_is_adjusting #} + (toColorSelection self) -------------------- -- Properties @@ -220,7 +244,7 @@ -- -- Default value: @False@ -- -colorSelectionHasOpacityControl :: Attr ColorSelection Bool +colorSelectionHasOpacityControl :: ColorSelectionClass self => Attr self Bool colorSelectionHasOpacityControl = Attr colorSelectionGetHasOpacityControl colorSelectionSetHasOpacityControl @@ -229,7 +253,7 @@ -- -- Default value: @False@ -- -colorSelectionHasPalette :: Attr ColorSelection Bool +colorSelectionHasPalette :: ColorSelectionClass self => Attr self Bool colorSelectionHasPalette = Attr colorSelectionGetHasPalette colorSelectionSetHasPalette @@ -240,7 +264,7 @@ -- -- Default value: 65535 -- -colorSelectionCurrentAlpha :: Attr ColorSelection Int +colorSelectionCurrentAlpha :: ColorSelectionClass self => Attr self Int colorSelectionCurrentAlpha = Attr colorSelectionGetCurrentAlpha colorSelectionSetCurrentAlpha @@ -248,7 +272,7 @@ -- | \'previousAlpha\' property. See 'colorSelectionGetPreviousAlpha' and -- 'colorSelectionSetPreviousAlpha' -- -colorSelectionPreviousAlpha :: Attr ColorSelection Int +colorSelectionPreviousAlpha :: ColorSelectionClass self => Attr self Int colorSelectionPreviousAlpha = Attr colorSelectionGetPreviousAlpha colorSelectionSetPreviousAlpha Index: FileChooserWidget.chs.pp =================================================================== RCS file: /cvsroot/gtk2hs/gtk2hs/gtk/Graphics/UI/Gtk/Selectors/FileChooserWidget.chs.pp,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- FileChooserWidget.chs.pp 25 Feb 2005 22:53:43 -0000 1.4 +++ FileChooserWidget.chs.pp 3 Apr 2005 12:56:07 -0000 1.5 @@ -24,16 +24,12 @@ -- Stability : provisional -- Portability : portable (depends on GHC) -- --- The file chooser dialog and widget is a replacement --- for the old 'FileSel'ection dialog. It provides a better user --- interface and an improved API. --- --- * This is the widget variant of the 'FileChooser' +-- File chooser widget that can be embedded in other widgets -- --- * Added in GTK+ 2.4 +-- * Module available since Gtk+ version 2.4 -- module Graphics.UI.Gtk.Selectors.FileChooserWidget ( --- * Description +-- * Detail -- -- | 'FileChooserWidget' is a widget suitable for selecting files. It is the -- main building block of a 'FileChooserDialog'. Most applications will only @@ -42,8 +38,6 @@ -- -- Note that 'FileChooserWidget' does not have any methods of its own. -- Instead, you should use the functions that work on a 'FileChooser'. --- --- * Module available since Gtk version 2.4 -- * Class Hierarchy -- | @@ -57,7 +51,6 @@ -- | +----FileChooserWidget -- @ - #if GTK_CHECK_VERSION(2,4,0) -- * Types FileChooserWidget, @@ -71,8 +64,6 @@ #endif ) where -#if GTK_CHECK_VERSION(2,4,0) - import Monad (liftM) import System.Glib.FFI @@ -82,6 +73,7 @@ {# context lib="gtk" prefix="gtk" #} +#if GTK_CHECK_VERSION(2,4,0) -------------------- -- Interfaces @@ -90,17 +82,34 @@ -------------------- -- Constructors -fileChooserWidgetNew :: FileChooserAction -> IO FileChooserWidget +-- | 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 $ + makeNewObject mkFileChooserWidget $ + liftM (castPtr :: Ptr Widget -> Ptr FileChooserWidget) $ {# call unsafe gtk_file_chooser_widget_new #} - (fromIntegral $ fromEnum action) + ((fromIntegral . fromEnum) action) -fileChooserWidgetNewWithBackend :: FileChooserAction -> String -> IO FileChooserWidget +-- | 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 $ - withCString backend $ \strPtr -> + makeNewObject mkFileChooserWidget $ + liftM (castPtr :: Ptr Widget -> Ptr FileChooserWidget) $ + withCString backend $ \backendPtr -> {# call unsafe gtk_file_chooser_widget_new_with_backend #} - (fromIntegral $ fromEnum action) strPtr - + ((fromIntegral . fromEnum) action) + backendPtr #endif |