{-| This module contains functionality for creating the core components of the browser window. These are: * Toggle button for knowing which tree is selected. * Entry box containing the current location ( home folder by default ). * Scrolled window containing the expanible tree. * Scrolled window containing the directory TreeView. * Scrolled window containing the files TreeView. * Expandible tree for browsing the file system. * TreeView containing the directories. * TreeView containing the files. * TreeStore with the expandible tree. * ListStore with the directories. * ListStore with the files. -} module Browser ( createFileBrowser ) where import Components import DirectoryTree import Graphics.UI.Gtk import System.Directory ( setCurrentDirectory ) import TreeViewOperations import Types import Util {-| The createFileBrowser function creates a 'FileBrowser', containing the elements detailed above, by setting the current directory to the home folder. It then gets a list of the directories and files contained in the home folder, and creates a directory listing, and a files listing. It also creates an expandible tree for browsing the whole system at a high level. It then creates the entryBox and toggle button associated with it and returns the resulting 'FileBrowser'. -} createFileBrowser :: IO FileBrowser -- ^ Returns a 'FileBrowser' containing the elements detailed above. createFileBrowser = getHomeFolder >>= ( \h -> do setCurrentDirectory h (dirs, files) <- viewDirectory h ( index, indexscroll, indexstore ) <- getListing (dirtv, filetv, dirscroll, filscroll, dirstore, filestore ) <- createListing ("Directories", "Files") (dirs, files) entryNew >>= ( \l -> do entrySetText l h toggleButtonNew >>= ( \d -> do toggleButtonSetActive d True return ( FileBrowser d l indexscroll dirscroll filscroll index dirtv filetv indexstore dirstore filestore ) ) ) )