{-# LINE 2 "./Graphics/UI/Gtk/Selectors/FileSelection.chs" #-}
module Graphics.UI.Gtk.Selectors.FileSelection (
FileSelection,
FileSelectionClass,
castToFileSelection, gTypeFileSelection,
toFileSelection,
fileSelectionNew,
fileSelectionSetFilename,
fileSelectionGetFilename,
fileSelectionShowFileopButtons,
fileSelectionHideFileopButtons,
fileSelectionGetButtons,
fileSelectionComplete,
fileSelectionGetSelections,
fileSelectionSetSelectMultiple,
fileSelectionGetSelectMultiple,
fileSelectionFilename,
fileSelectionShowFileops,
fileSelectionSelectMultiple,
) where
import Control.Monad (liftM)
import System.Glib.FFI
import System.Glib.UTFString
import System.Glib.Attributes
import System.Glib.Properties
import Graphics.UI.Gtk.Types
{-# LINE 103 "./Graphics/UI/Gtk/Selectors/FileSelection.chs" #-}
import Graphics.UI.Gtk.Abstract.Object (makeNewObject)
import Graphics.UI.Gtk.General.Structs (fileSelectionGetButtons)
{-# LINE 107 "./Graphics/UI/Gtk/Selectors/FileSelection.chs" #-}
fileSelectionNew :: GlibString string
=> string
-> IO FileSelection
fileSelectionNew :: forall string. GlibString string => string -> IO FileSelection
fileSelectionNew string
title =
(ForeignPtr FileSelection -> FileSelection,
FinalizerPtr FileSelection)
-> IO (Ptr FileSelection) -> IO FileSelection
forall obj.
ObjectClass obj =>
(ForeignPtr obj -> obj, FinalizerPtr obj) -> IO (Ptr obj) -> IO obj
makeNewObject (ForeignPtr FileSelection -> FileSelection,
FinalizerPtr FileSelection)
forall {a}.
(ForeignPtr FileSelection -> FileSelection, FinalizerPtr a)
mkFileSelection (IO (Ptr FileSelection) -> IO FileSelection)
-> IO (Ptr FileSelection) -> IO FileSelection
forall a b. (a -> b) -> a -> b
$
(Ptr Widget -> Ptr FileSelection)
-> IO (Ptr Widget) -> IO (Ptr FileSelection)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (Ptr Widget -> Ptr FileSelection
forall a b. Ptr a -> Ptr b
castPtr :: Ptr Widget -> Ptr FileSelection) (IO (Ptr Widget) -> IO (Ptr FileSelection))
-> IO (Ptr Widget) -> IO (Ptr FileSelection)
forall a b. (a -> b) -> a -> b
$
string -> (CString -> IO (Ptr Widget)) -> IO (Ptr Widget)
forall a. string -> (CString -> IO a) -> IO a
forall s a. GlibString s => s -> (CString -> IO a) -> IO a
withUTFString string
title ((CString -> IO (Ptr Widget)) -> IO (Ptr Widget))
-> (CString -> IO (Ptr Widget)) -> IO (Ptr Widget)
forall a b. (a -> b) -> a -> b
$ \CString
titlePtr ->
CString -> IO (Ptr Widget)
gtk_file_selection_new
{-# LINE 125 "./Graphics/UI/Gtk/Selectors/FileSelection.chs" #-}
titlePtr
fileSelectionSetFilename :: (FileSelectionClass self, GlibString string) => self
-> string
-> IO ()
fileSelectionSetFilename :: forall self string.
(FileSelectionClass self, GlibString string) =>
self -> string -> IO ()
fileSelectionSetFilename self
self string
filename =
string -> (CString -> IO ()) -> IO ()
forall a. string -> (CString -> IO a) -> IO a
forall s a. GlibString s => s -> (CString -> IO a) -> IO a
withUTFString string
filename ((CString -> IO ()) -> IO ()) -> (CString -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \CString
filenamePtr ->
(\(FileSelection ForeignPtr FileSelection
arg1) CString
arg2 -> ForeignPtr FileSelection -> (Ptr FileSelection -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr FileSelection
arg1 ((Ptr FileSelection -> IO ()) -> IO ())
-> (Ptr FileSelection -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr FileSelection
argPtr1 ->Ptr FileSelection -> CString -> IO ()
gtk_file_selection_set_filename Ptr FileSelection
argPtr1 CString
arg2)
{-# LINE 147 "./Graphics/UI/Gtk/Selectors/FileSelection.chs" #-}
(self -> FileSelection
forall o. FileSelectionClass o => o -> FileSelection
toFileSelection self
self)
CString
filenamePtr
fileSelectionGetFilename :: (FileSelectionClass self, GlibString string) => self
-> IO string
fileSelectionGetFilename :: forall self string.
(FileSelectionClass self, GlibString string) =>
self -> IO string
fileSelectionGetFilename self
self =
(\(FileSelection ForeignPtr FileSelection
arg1) -> ForeignPtr FileSelection
-> (Ptr FileSelection -> IO CString) -> IO CString
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr FileSelection
arg1 ((Ptr FileSelection -> IO CString) -> IO CString)
-> (Ptr FileSelection -> IO CString) -> IO CString
forall a b. (a -> b) -> a -> b
$ \Ptr FileSelection
argPtr1 ->Ptr FileSelection -> IO CString
gtk_file_selection_get_filename Ptr FileSelection
argPtr1)
{-# LINE 162 "./Graphics/UI/Gtk/Selectors/FileSelection.chs" #-}
(self -> FileSelection
forall o. FileSelectionClass o => o -> FileSelection
toFileSelection self
self)
IO CString -> (CString -> IO string) -> IO string
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= CString -> IO string
forall s. GlibString s => CString -> IO s
peekUTFString
fileSelectionShowFileopButtons :: FileSelectionClass self => self -> IO ()
fileSelectionShowFileopButtons :: forall self. FileSelectionClass self => self -> IO ()
fileSelectionShowFileopButtons self
self =
(\(FileSelection ForeignPtr FileSelection
arg1) -> ForeignPtr FileSelection -> (Ptr FileSelection -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr FileSelection
arg1 ((Ptr FileSelection -> IO ()) -> IO ())
-> (Ptr FileSelection -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr FileSelection
argPtr1 ->Ptr FileSelection -> IO ()
gtk_file_selection_show_fileop_buttons Ptr FileSelection
argPtr1)
{-# LINE 172 "./Graphics/UI/Gtk/Selectors/FileSelection.chs" #-}
(toFileSelection self)
fileSelectionHideFileopButtons :: FileSelectionClass self => self -> IO ()
fileSelectionHideFileopButtons :: forall self. FileSelectionClass self => self -> IO ()
fileSelectionHideFileopButtons self
self =
(\(FileSelection ForeignPtr FileSelection
arg1) -> ForeignPtr FileSelection -> (Ptr FileSelection -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr FileSelection
arg1 ((Ptr FileSelection -> IO ()) -> IO ())
-> (Ptr FileSelection -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr FileSelection
argPtr1 ->Ptr FileSelection -> IO ()
gtk_file_selection_hide_fileop_buttons Ptr FileSelection
argPtr1)
{-# LINE 181 "./Graphics/UI/Gtk/Selectors/FileSelection.chs" #-}
(toFileSelection self)
fileSelectionComplete :: (FileSelectionClass self, GlibString string) => self
-> string
-> IO ()
fileSelectionComplete :: forall self string.
(FileSelectionClass self, GlibString string) =>
self -> string -> IO ()
fileSelectionComplete self
self string
pattern =
string -> (CString -> IO ()) -> IO ()
forall a. string -> (CString -> IO a) -> IO a
forall s a. GlibString s => s -> (CString -> IO a) -> IO a
withUTFString string
pattern ((CString -> IO ()) -> IO ()) -> (CString -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \CString
patternPtr ->
(\(FileSelection ForeignPtr FileSelection
arg1) CString
arg2 -> ForeignPtr FileSelection -> (Ptr FileSelection -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr FileSelection
arg1 ((Ptr FileSelection -> IO ()) -> IO ())
-> (Ptr FileSelection -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr FileSelection
argPtr1 ->Ptr FileSelection -> CString -> IO ()
gtk_file_selection_complete Ptr FileSelection
argPtr1 CString
arg2)
{-# LINE 197 "./Graphics/UI/Gtk/Selectors/FileSelection.chs" #-}
(toFileSelection self)
CString
patternPtr
fileSelectionGetSelections :: (FileSelectionClass self, GlibString string) => self -> IO [string]
fileSelectionGetSelections :: forall self string.
(FileSelectionClass self, GlibString string) =>
self -> IO [string]
fileSelectionGetSelections self
self = do
Ptr CString
cStrArr <-
(\(FileSelection ForeignPtr FileSelection
arg1) -> ForeignPtr FileSelection
-> (Ptr FileSelection -> IO (Ptr CString)) -> IO (Ptr CString)
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr FileSelection
arg1 ((Ptr FileSelection -> IO (Ptr CString)) -> IO (Ptr CString))
-> (Ptr FileSelection -> IO (Ptr CString)) -> IO (Ptr CString)
forall a b. (a -> b) -> a -> b
$ \Ptr FileSelection
argPtr1 ->Ptr FileSelection -> IO (Ptr CString)
gtk_file_selection_get_selections Ptr FileSelection
argPtr1)
{-# LINE 211 "./Graphics/UI/Gtk/Selectors/FileSelection.chs" #-}
(self -> FileSelection
forall o. FileSelectionClass o => o -> FileSelection
toFileSelection self
self)
[CString]
cStrs <- CString -> Ptr CString -> IO [CString]
forall a. (Storable a, Eq a) => a -> Ptr a -> IO [a]
peekArray0 CString
forall a. Ptr a
nullPtr Ptr CString
cStrArr
[string]
result <- (CString -> IO string) -> [CString] -> IO [string]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM CString -> IO string
forall s. GlibString s => CString -> IO s
peekUTFString [CString]
cStrs
Ptr CString -> IO ()
g_strfreev Ptr CString
cStrArr
[string] -> IO [string]
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return [string]
result
fileSelectionSetSelectMultiple :: FileSelectionClass self => self
-> Bool
-> IO ()
fileSelectionSetSelectMultiple :: forall self. FileSelectionClass self => self -> Bool -> IO ()
fileSelectionSetSelectMultiple self
self Bool
selectMultiple =
(\(FileSelection ForeignPtr FileSelection
arg1) CInt
arg2 -> ForeignPtr FileSelection -> (Ptr FileSelection -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr FileSelection
arg1 ((Ptr FileSelection -> IO ()) -> IO ())
-> (Ptr FileSelection -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr FileSelection
argPtr1 ->Ptr FileSelection -> CInt -> IO ()
gtk_file_selection_set_select_multiple Ptr FileSelection
argPtr1 CInt
arg2)
{-# LINE 227 "./Graphics/UI/Gtk/Selectors/FileSelection.chs" #-}
(toFileSelection self)
(Bool -> CInt
forall a. Num a => Bool -> a
fromBool Bool
selectMultiple)
fileSelectionGetSelectMultiple :: FileSelectionClass self => self
-> IO Bool
fileSelectionGetSelectMultiple :: forall self. FileSelectionClass self => self -> IO Bool
fileSelectionGetSelectMultiple self
self =
(CInt -> Bool) -> IO CInt -> IO Bool
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM CInt -> Bool
forall a. (Eq a, Num a) => a -> Bool
toBool (IO CInt -> IO Bool) -> IO CInt -> IO Bool
forall a b. (a -> b) -> a -> b
$
(\(FileSelection ForeignPtr FileSelection
arg1) -> ForeignPtr FileSelection
-> (Ptr FileSelection -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr FileSelection
arg1 ((Ptr FileSelection -> IO CInt) -> IO CInt)
-> (Ptr FileSelection -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr FileSelection
argPtr1 ->Ptr FileSelection -> IO CInt
gtk_file_selection_get_select_multiple Ptr FileSelection
argPtr1)
{-# LINE 239 "./Graphics/UI/Gtk/Selectors/FileSelection.chs" #-}
(toFileSelection self)
fileSelectionFilename :: (FileSelectionClass self, GlibString string) => Attr self string
fileSelectionFilename :: forall self string.
(FileSelectionClass self, GlibString string) =>
Attr self string
fileSelectionFilename = (self -> IO string)
-> (self -> string -> IO ()) -> ReadWriteAttr self string string
forall o a b.
(o -> IO a) -> (o -> b -> IO ()) -> ReadWriteAttr o a b
newAttr
self -> IO string
forall self string.
(FileSelectionClass self, GlibString string) =>
self -> IO string
fileSelectionGetFilename
self -> string -> IO ()
forall self string.
(FileSelectionClass self, GlibString string) =>
self -> string -> IO ()
fileSelectionSetFilename
fileSelectionShowFileops :: FileSelectionClass self => Attr self Bool
fileSelectionShowFileops :: forall self. FileSelectionClass self => Attr self Bool
fileSelectionShowFileops = String -> Attr self Bool
forall gobj. GObjectClass gobj => String -> Attr gobj Bool
newAttrFromBoolProperty String
"show-fileops"
fileSelectionSelectMultiple :: FileSelectionClass self => Attr self Bool
fileSelectionSelectMultiple :: forall self. FileSelectionClass self => Attr self Bool
fileSelectionSelectMultiple = (self -> IO Bool)
-> (self -> Bool -> IO ()) -> ReadWriteAttr self Bool Bool
forall o a b.
(o -> IO a) -> (o -> b -> IO ()) -> ReadWriteAttr o a b
newAttr
self -> IO Bool
forall self. FileSelectionClass self => self -> IO Bool
fileSelectionGetSelectMultiple
self -> Bool -> IO ()
forall self. FileSelectionClass self => self -> Bool -> IO ()
fileSelectionSetSelectMultiple
foreign import ccall unsafe "gtk_file_selection_new"
gtk_file_selection_new :: ((Ptr CChar) -> (IO (Ptr Widget)))
foreign import ccall unsafe "gtk_file_selection_set_filename"
gtk_file_selection_set_filename :: ((Ptr FileSelection) -> ((Ptr CChar) -> (IO ())))
foreign import ccall unsafe "gtk_file_selection_get_filename"
gtk_file_selection_get_filename :: ((Ptr FileSelection) -> (IO (Ptr CChar)))
foreign import ccall safe "gtk_file_selection_show_fileop_buttons"
gtk_file_selection_show_fileop_buttons :: ((Ptr FileSelection) -> (IO ()))
foreign import ccall safe "gtk_file_selection_hide_fileop_buttons"
gtk_file_selection_hide_fileop_buttons :: ((Ptr FileSelection) -> (IO ()))
foreign import ccall safe "gtk_file_selection_complete"
gtk_file_selection_complete :: ((Ptr FileSelection) -> ((Ptr CChar) -> (IO ())))
foreign import ccall safe "gtk_file_selection_get_selections"
gtk_file_selection_get_selections :: ((Ptr FileSelection) -> (IO (Ptr (Ptr CChar))))
foreign import ccall unsafe "g_strfreev"
g_strfreev :: ((Ptr (Ptr CChar)) -> (IO ()))
foreign import ccall safe "gtk_file_selection_set_select_multiple"
gtk_file_selection_set_select_multiple :: ((Ptr FileSelection) -> (CInt -> (IO ())))
foreign import ccall safe "gtk_file_selection_get_select_multiple"
gtk_file_selection_get_select_multiple :: ((Ptr FileSelection) -> (IO CInt))