From 879d4b342d7c94d962297a28136a9054b4b891e1 Mon Sep 17 00:00:00 2001 From: travis-ci Date: Fri, 3 Jun 2016 12:08:47 +0000 Subject: [PATCH] Lastest docs updated travis build: 24 commit: e310879d616f8deb4105a776c61862ba9d7f8c89 auto-pushed to gh-pages --- HSFM-GUI-Gtk-Callbacks.html | 2 +- HSFM-GUI-Gtk-Data.html | 4 +- HSFM-GUI-Gtk-MyView.html | 4 +- Paths_hsfm.html | 2 +- doc-index-All.html | 2 +- doc-index-N.html | 2 +- doc-index-R.html | 2 +- hsfm.haddock | Bin 43286 -> 43406 bytes mini_HSFM-GUI-Gtk-Callbacks.html | 2 +- mini_HSFM-GUI-Gtk-MyView.html | 2 +- src/HSFM-GUI-Gtk-Callbacks-Utils.html | 14 +- src/HSFM-GUI-Gtk-Callbacks.html | 1045 +++++++++++++------------ src/HSFM-GUI-Gtk-Data.html | 80 +- src/HSFM-GUI-Gtk-MyView.html | 731 +++++++++-------- 14 files changed, 964 insertions(+), 928 deletions(-) diff --git a/HSFM-GUI-Gtk-Callbacks.html b/HSFM-GUI-Gtk-Callbacks.html index 1bf38e8..3639436 100644 --- a/HSFM-GUI-Gtk-Callbacks.html +++ b/HSFM-GUI-Gtk-Callbacks.html @@ -1,5 +1,5 @@ HSFM.GUI.Gtk.Callbacks

hsfm-gtk

Safe HaskellNone
LanguageHaskell2010

HSFM.GUI.Gtk.Callbacks

Synopsis

Documentation

setGUICallbacks :: MyGUI -> IO () Source #

Set callbacks for the whole gui, on hotkeys, events and stuff.

setViewCallbacks :: MyGUI -> MyView -> IO () Source #

Set callbacks specific to a given view, on hotkeys, events and stuff.

closeTab :: MyGUI -> MyView -> IO () Source #

Closes the current tab, but only if there is more than one tab.

del :: [Item] -> MyGUI -> MyView -> IO () Source #

Supposed to be used with withRows. Deletes a file or directory.

moveInit :: [Item] -> MyGUI -> MyView -> IO () Source #

Initializes a file move operation.

copyInit :: [Item] -> MyGUI -> MyView -> IO () Source #

Supposed to be used with withRows. Initializes a file copy operation.

operationFinal :: MyGUI -> MyView -> Maybe Item -> IO () Source #

Finalizes a file operation, such as copy or move.

newFile :: MyGUI -> MyView -> IO () Source #

Create a new file.

newDir :: MyGUI -> MyView -> IO () Source #

Create a new directory.

renameF :: [Item] -> MyGUI -> MyView -> IO () Source #

urlGoTo :: MyGUI -> MyView -> IO () Source #

Go to the url given at the urlBar and visualize it in the given +

Safe HaskellNone
LanguageHaskell2010

HSFM.GUI.Gtk.Callbacks

Synopsis

Documentation

setGUICallbacks :: MyGUI -> IO () Source #

Set callbacks for the whole gui, on hotkeys, events and stuff.

setViewCallbacks :: MyGUI -> MyView -> IO () Source #

Set callbacks specific to a given view, on hotkeys, events and stuff.

closeTab :: MyGUI -> MyView -> IO () Source #

Closes the current tab, but only if there is more than one tab.

newTab :: MyGUI -> IO FMView -> Item -> IO MyView Source #

Creates a new tab with its own view and refreshes the view.

del :: [Item] -> MyGUI -> MyView -> IO () Source #

Supposed to be used with withRows. Deletes a file or directory.

moveInit :: [Item] -> MyGUI -> MyView -> IO () Source #

Initializes a file move operation.

copyInit :: [Item] -> MyGUI -> MyView -> IO () Source #

Supposed to be used with withRows. Initializes a file copy operation.

operationFinal :: MyGUI -> MyView -> Maybe Item -> IO () Source #

Finalizes a file operation, such as copy or move.

newFile :: MyGUI -> MyView -> IO () Source #

Create a new file.

newDir :: MyGUI -> MyView -> IO () Source #

Create a new directory.

renameF :: [Item] -> MyGUI -> MyView -> IO () Source #

urlGoTo :: MyGUI -> MyView -> IO () Source #

Go to the url given at the urlBar and visualize it in the given treeView.

If the url is invalid, does nothing.

execute :: [Item] -> MyGUI -> MyView -> IO () Source #

Execute a given file.

open :: [Item] -> MyGUI -> MyView -> IO () Source #

Supposed to be used with withRows. Opens a file or directory.

upDir :: MyGUI -> MyView -> IO () Source #

Go up one directory and visualize it in the treeView.

goHistoryPrev :: MyGUI -> MyView -> IO () Source #

Go "back" in the history.

goHistoryNext :: MyGUI -> MyView -> IO () Source #

Go "forth" in the history.

\ No newline at end of file diff --git a/HSFM-GUI-Gtk-Data.html b/HSFM-GUI-Gtk-Data.html index 32bcfc6..0867636 100644 --- a/HSFM-GUI-Gtk-Data.html +++ b/HSFM-GUI-Gtk-Data.html @@ -1,8 +1,8 @@ HSFM.GUI.Gtk.Data
Safe HaskellNone
LanguageHaskell2010

HSFM.GUI.Gtk.Data

Synopsis

Documentation

data MyGUI Source #

Monolithic object passed to various GUI functions in order +

Safe HaskellNone
LanguageHaskell2010

HSFM.GUI.Gtk.Data

Synopsis

Documentation

data MyGUI Source #

Monolithic object passed to various GUI functions in order to keep the API stable and not alter the parameters too much. This only holds GUI widgets that are needed to be read during runtime.

Constructors

MkMyGUI 

Fields

data MyView Source #

This describes the contents of the current view and is separated from MyGUI, - because we might want to have multiple views.

Constructors

MkMyView 

Fields

data MenuBar Source #

Constructors

MkMenuBar 

Fields

data RightClickMenu Source #

Constructors

MkRightClickMenu 

Fields

data FilePropertyGrid Source #

Constructors

MkFilePropertyGrid 

Fields

data FMSettings Source #

FM-wide settings.

Constructors

MkFMSettings 

Fields

data FMView Source #

Constructors

FMTreeView !TreeView 
FMIconView !IconView 
\ No newline at end of file + because we might want to have multiple views.

Constructors

MkMyView 

Fields

data MenuBar Source #

Constructors

MkMenuBar 

Fields

data RightClickMenu Source #

Constructors

MkRightClickMenu 

Fields

data FilePropertyGrid Source #

Constructors

MkFilePropertyGrid 

Fields

data FMSettings Source #

FM-wide settings.

Constructors

MkFMSettings 

Fields

data FMView Source #

Constructors

FMTreeView !TreeView 
FMIconView !IconView 
\ No newline at end of file diff --git a/HSFM-GUI-Gtk-MyView.html b/HSFM-GUI-Gtk-MyView.html index 8eae4a1..dccda88 100644 --- a/HSFM-GUI-Gtk-MyView.html +++ b/HSFM-GUI-Gtk-MyView.html @@ -1,9 +1,9 @@ HSFM.GUI.Gtk.MyView
Safe HaskellNone
LanguageHaskell2010

HSFM.GUI.Gtk.MyView

Documentation

newTab :: MyGUI -> IO FMView -> Item -> IO MyView Source #

Creates a new tab with its own view and refreshes the view.

createMyView :: MyGUI -> IO FMView -> IO MyView Source #

Constructs the initial MyView object with a few dummy models. +

Safe HaskellNone
LanguageHaskell2010

HSFM.GUI.Gtk.MyView

Documentation

createMyView :: MyGUI -> IO FMView -> IO MyView Source #

Constructs the initial MyView object with a few dummy models. It also initializes the callbacks.

switchView :: MyGUI -> MyView -> IO FMView -> IO () Source #

Switch the existing view in MyView with the one that the - io action returns.

destroyView :: MyGUI -> MyView -> IO Int Source #

Destroys the current view by disconnecting the watcher + io action returns.

destroyView :: MyGUI -> MyView -> IO Int Source #

Destroys the given view by disconnecting the watcher and destroying the active FMView container.

Everything that needs to be done in order to forget about a view needs to be done here.

Returns the page in the tab list this view corresponds to.

createIconView :: IO FMView Source #

Createss an IconView.

createTreeView :: IO FMView Source #

Creates a TreeView.

refreshView :: MyGUI -> MyView -> Item -> IO () Source #

Refreshes the View based on the given directory.

Throws:

constructView :: MyGUI -> MyView -> IO () Source #

Constructs the visible View with the current underlying mutable models, which are retrieved from MyGUI.

This sort of merges the components mygui and myview and fires up diff --git a/Paths_hsfm.html b/Paths_hsfm.html index 9edbce3..0bd468a 100644 --- a/Paths_hsfm.html +++ b/Paths_hsfm.html @@ -1,4 +1,4 @@ Paths_hsfm

\ No newline at end of file + \ No newline at end of file diff --git a/doc-index-All.html b/doc-index-All.html index 3830eb9..60b67ad 100644 --- a/doc-index-All.html +++ b/doc-index-All.html @@ -1,4 +1,4 @@ hsfm-gtk (Index)

Index

accessTimeHSFM.FileSystem.FileType
accessTimeHiResHSFM.FileSystem.FileType
addHistoryHSFM.GUI.Gtk.Utils
BlockDevHSFM.FileSystem.FileType
BrokenSymlinkHSFM.FileSystem.FileType
brokenSymlinkHSFM.FileSystem.FileType
CharDevHSFM.FileSystem.FileType
clearStatusBarHSFM.GUI.Gtk.Data
closeTabHSFM.GUI.Gtk.Callbacks
comparingConstrHSFM.FileSystem.FileType
constructViewHSFM.GUI.Gtk.MyView
Copy 
1 (Type/Class)HSFM.FileSystem.UtilTypes
2 (Data Constructor)HSFM.FileSystem.UtilTypes
copyInitHSFM.GUI.Gtk.Callbacks
createIconViewHSFM.GUI.Gtk.MyView
createMyGUIHSFM.GUI.Gtk.MyGUI
createMyViewHSFM.GUI.Gtk.MyView
createTreeViewHSFM.GUI.Gtk.MyView
cwdHSFM.GUI.Gtk.Data
c_strlenHSFM.GUI.Glib.GlibString
delHSFM.GUI.Gtk.Callbacks
destroyViewHSFM.GUI.Gtk.MyView
deviceIDHSFM.FileSystem.FileType
DirHSFM.FileSystem.FileType
DirListHSFM.FileSystem.FileType
DirOrSymHSFM.FileSystem.FileType
DirSymHSFM.FileSystem.FileType
dirSymHSFM.FileSystem.FileType
doFileOperationHSFM.GUI.Gtk.Callbacks.Utils
epochToStringHSFM.FileSystem.FileType
executeHSFM.GUI.Gtk.Callbacks
FCollisonModeHSFM.FileSystem.UtilTypes
FCopyHSFM.FileSystem.UtilTypes
FDeleteHSFM.FileSystem.UtilTypes
FExecuteHSFM.FileSystem.UtilTypes
FileHSFM.FileSystem.FileType
fileCollisionDialogHSFM.GUI.Gtk.Dialogs
fileGroupHSFM.FileSystem.FileType
fileIDHSFM.FileSystem.FileType
FileInfo 
1 (Type/Class)HSFM.FileSystem.FileType
2 (Data Constructor)HSFM.FileSystem.FileType
FileLikeHSFM.FileSystem.FileType
fileLikeHSFM.FileSystem.FileType
FileLikeListHSFM.FileSystem.FileType
FileLikeOrSymHSFM.FileSystem.FileType
FileLikeSymHSFM.FileSystem.FileType
fileLikeSymHSFM.FileSystem.FileType
fileListStoreHSFM.GUI.Gtk.Utils
fileModeHSFM.FileSystem.FileType
FileOperationHSFM.FileSystem.UtilTypes
fileOwnerHSFM.FileSystem.FileType
FilePropertyGridHSFM.GUI.Gtk.Data
fileSizeHSFM.FileSystem.FileType
filteredModelHSFM.GUI.Gtk.Data
FMIconViewHSFM.GUI.Gtk.Data
FMoveHSFM.FileSystem.UtilTypes
FMSettingsHSFM.GUI.Gtk.Data
FMTreeViewHSFM.GUI.Gtk.Data
FMViewHSFM.GUI.Gtk.Data
fmViewToContainerHSFM.GUI.Gtk.Data
FOpenHSFM.FileSystem.UtilTypes
fpropHSFM.GUI.Gtk.Data
fpropAcEntryHSFM.GUI.Gtk.Data
fpropFnEntryHSFM.GUI.Gtk.Data
fpropFTEntryHSFM.GUI.Gtk.Data
fpropGridHSFM.GUI.Gtk.Data
fpropLDEntryHSFM.GUI.Gtk.Data
fpropLocEntryHSFM.GUI.Gtk.Data
fpropModEntryHSFM.GUI.Gtk.Data
fpropPermEntryHSFM.GUI.Gtk.Data
fpropTsEntryHSFM.GUI.Gtk.Data
fromFreeVarHSFM.FileSystem.FileType
fvarHSFM.FileSystem.FileType
getBinDirPaths_hsfm
getContentsHSFM.FileSystem.FileType
getCurrentDirHSFM.GUI.Gtk.Utils
getDataDirPaths_hsfm
getDataFileNamePaths_hsfm
getFileInfoHSFM.FileSystem.FileType
getFirstItemHSFM.GUI.Gtk.Utils
getFPasStrHSFM.FileSystem.FileType
getFreeVarHSFM.FileSystem.FileType
getIconHSFM.GUI.Gtk.Icons
getLibDirPaths_hsfm
getLibexecDirPaths_hsfm
getSelectedItemsHSFM.GUI.Gtk.Utils
getSelectedTreePathsHSFM.GUI.Gtk.Utils
getSymlinkIconHSFM.GUI.Gtk.Icons
getSysconfDirPaths_hsfm
goDirHSFM.GUI.Gtk.Callbacks.Utils
goHistoryNextHSFM.GUI.Gtk.Callbacks
goHistoryPrevHSFM.GUI.Gtk.Callbacks
goHomeHSFM.GUI.Gtk.Callbacks
goUpHSFM.FileSystem.FileType
goUp'HSFM.FileSystem.FileType
GtkExceptionHSFM.GUI.Gtk.Errors
GtkIconHSFM.GUI.Gtk.Icons
historyHSFM.GUI.Gtk.Data
homeViewBHSFM.GUI.Gtk.Data
iconSizeHSFM.GUI.Gtk.Data
IErrorHSFM.GUI.Gtk.Icons
IFileHSFM.GUI.Gtk.Icons
IFolderHSFM.GUI.Gtk.Icons
inotifyHSFM.GUI.Gtk.Data
isBlockCHSFM.FileSystem.FileType
isBrokenSymlinkHSFM.FileSystem.FileType
isCharCHSFM.FileSystem.FileType
isDirCHSFM.FileSystem.FileType
isFileCHSFM.FileSystem.FileType
isLazyHSFM.GUI.Gtk.Data
isNamedCHSFM.FileSystem.FileType
isSocketCHSFM.FileSystem.FileType
isSymCHSFM.FileSystem.FileType
ItemHSFM.GUI.Gtk.Data
linkCountHSFM.FileSystem.FileType
listIndicesHSFM.Utils.MyPrelude
mainMain
maybeDHSFM.Utils.MyPrelude
MenuBarHSFM.GUI.Gtk.Data
menubarHSFM.GUI.Gtk.Data
menubarFileQuitHSFM.GUI.Gtk.Data
menubarHelpAboutHSFM.GUI.Gtk.Data
MkFilePropertyGridHSFM.GUI.Gtk.Data
MkFMSettingsHSFM.GUI.Gtk.Data
MkMenuBarHSFM.GUI.Gtk.Data
MkMyGUIHSFM.GUI.Gtk.Data
MkMyViewHSFM.GUI.Gtk.Data
MkRightClickMenuHSFM.GUI.Gtk.Data
modificationTimeHSFM.FileSystem.FileType
modificationTimeHiResHSFM.FileSystem.FileType
modifyTVarIOHSFM.Utils.IO
Move 
1 (Type/Class)HSFM.FileSystem.UtilTypes
2 (Data Constructor)HSFM.FileSystem.UtilTypes
moveInitHSFM.GUI.Gtk.Callbacks
MyGUIHSFM.GUI.Gtk.Data
MyViewHSFM.GUI.Gtk.Data
NamedPipeHSFM.FileSystem.FileType
newDirHSFM.GUI.Gtk.Callbacks
newFileHSFM.GUI.Gtk.Callbacks
newTabHSFM.GUI.Gtk.MyView
newTabHereHSFM.GUI.Gtk.Callbacks
NoneHSFM.FileSystem.UtilTypes
noNullPtrsHSFM.GUI.Glib.GlibString
notebookHSFM.GUI.Gtk.Data
openHSFM.GUI.Gtk.Callbacks
openTerminalHereHSFM.GUI.Gtk.Callbacks
operationBufferHSFM.GUI.Gtk.Data
operationFinalHSFM.GUI.Gtk.Callbacks
OverwriteHSFM.FileSystem.UtilTypes
OverwriteAllHSFM.FileSystem.UtilTypes
packAccessTimeHSFM.FileSystem.FileType
packFileTypeHSFM.FileSystem.FileType
packLinkDestinationHSFM.FileSystem.FileType
packModTimeHSFM.FileSystem.FileType
packPermissionsHSFM.FileSystem.FileType
PartialCopyHSFM.FileSystem.UtilTypes
PartialMoveHSFM.FileSystem.UtilTypes
pathHSFM.FileSystem.FileType
popStatusbarHSFM.GUI.Gtk.Utils
pushStatusBarHSFM.GUI.Gtk.Utils
rawdestHSFM.FileSystem.FileType
rawModelHSFM.GUI.Gtk.Data
rawPathToItemHSFM.GUI.Gtk.Utils
rawPathToIterHSFM.GUI.Gtk.Utils
rcFileCopyHSFM.GUI.Gtk.Data
rcFileCutHSFM.GUI.Gtk.Data
rcFileDeleteHSFM.GUI.Gtk.Data
rcFileExecuteHSFM.GUI.Gtk.Data
rcFileIconViewHSFM.GUI.Gtk.Data
rcFileNewDirHSFM.GUI.Gtk.Data
rcFileNewRegFileHSFM.GUI.Gtk.Data
rcFileOpenHSFM.GUI.Gtk.Data
rcFilePasteHSFM.GUI.Gtk.Data
rcFilePropertyHSFM.GUI.Gtk.Data
rcFileRenameHSFM.GUI.Gtk.Data
rcFileTreeViewHSFM.GUI.Gtk.Data
rcMenuHSFM.GUI.Gtk.Data
rcmenuHSFM.GUI.Gtk.Data
readDirectoryContentsHSFM.FileSystem.FileType
readFileHSFM.FileSystem.FileType
refreshViewHSFM.GUI.Gtk.MyView
refreshViewBHSFM.GUI.Gtk.Data
RegFileHSFM.FileSystem.FileType
RenameHSFM.FileSystem.UtilTypes
renameDialogHSFM.GUI.Gtk.Dialogs
renameFHSFM.GUI.Gtk.Callbacks
RightClickMenuHSFM.GUI.Gtk.Data
rootWinHSFM.GUI.Gtk.Data
scrollHSFM.GUI.Gtk.Data
sdestHSFM.FileSystem.FileType
sdirHSFM.FileSystem.FileType
setGUICallbacksHSFM.GUI.Gtk.Callbacks
settingsHSFM.GUI.Gtk.Data
setViewCallbacksHSFM.GUI.Gtk.Callbacks
sfileLikeHSFM.FileSystem.FileType
showAboutDialogHSFM.GUI.Gtk.Dialogs
showConfirmationDialogHSFM.GUI.Gtk.Dialogs
showErrorDialogHSFM.GUI.Gtk.Dialogs
showFilePropertyDialogHSFM.GUI.Gtk.Dialogs
showHiddenHSFM.GUI.Gtk.Data
SkipHSFM.FileSystem.UtilTypes
SocketHSFM.FileSystem.FileType
sortedModelHSFM.GUI.Gtk.Data
specialDeviceIDHSFM.FileSystem.FileType
statusBarHSFM.GUI.Gtk.Data
statusChangeTimeHSFM.FileSystem.FileType
statusChangeTimeHiResHSFM.FileSystem.FileType
StrictHSFM.FileSystem.UtilTypes
switchViewHSFM.GUI.Gtk.MyView
SymLHSFM.GUI.Gtk.Icons
SymLinkHSFM.FileSystem.FileType
textInputDialogHSFM.GUI.Gtk.Dialogs
UnknownDialogButtonHSFM.GUI.Gtk.Errors
upDirHSFM.GUI.Gtk.Callbacks
upViewBHSFM.GUI.Gtk.Data
urlBarHSFM.GUI.Gtk.Data
urlGoToHSFM.GUI.Gtk.Callbacks
versionPaths_hsfm
viewHSFM.GUI.Gtk.Data
viewBoxHSFM.GUI.Gtk.Data
withConfirmationDialogHSFM.GUI.Gtk.Dialogs
withErrorDialogHSFM.GUI.Gtk.Dialogs
withItemsHSFM.GUI.Gtk.Utils
writeTVarIOHSFM.Utils.IO
_doFileOperationHSFM.GUI.Gtk.Callbacks.Utils
\ No newline at end of file +

Index

accessTimeHSFM.FileSystem.FileType
accessTimeHiResHSFM.FileSystem.FileType
addHistoryHSFM.GUI.Gtk.Utils
BlockDevHSFM.FileSystem.FileType
BrokenSymlinkHSFM.FileSystem.FileType
brokenSymlinkHSFM.FileSystem.FileType
CharDevHSFM.FileSystem.FileType
clearStatusBarHSFM.GUI.Gtk.Data
closeTabHSFM.GUI.Gtk.Callbacks
comparingConstrHSFM.FileSystem.FileType
constructViewHSFM.GUI.Gtk.MyView
Copy 
1 (Type/Class)HSFM.FileSystem.UtilTypes
2 (Data Constructor)HSFM.FileSystem.UtilTypes
copyInitHSFM.GUI.Gtk.Callbacks
createIconViewHSFM.GUI.Gtk.MyView
createMyGUIHSFM.GUI.Gtk.MyGUI
createMyViewHSFM.GUI.Gtk.MyView
createTreeViewHSFM.GUI.Gtk.MyView
cwdHSFM.GUI.Gtk.Data
c_strlenHSFM.GUI.Glib.GlibString
delHSFM.GUI.Gtk.Callbacks
destroyViewHSFM.GUI.Gtk.MyView
deviceIDHSFM.FileSystem.FileType
DirHSFM.FileSystem.FileType
DirListHSFM.FileSystem.FileType
DirOrSymHSFM.FileSystem.FileType
DirSymHSFM.FileSystem.FileType
dirSymHSFM.FileSystem.FileType
doFileOperationHSFM.GUI.Gtk.Callbacks.Utils
epochToStringHSFM.FileSystem.FileType
executeHSFM.GUI.Gtk.Callbacks
FCollisonModeHSFM.FileSystem.UtilTypes
FCopyHSFM.FileSystem.UtilTypes
FDeleteHSFM.FileSystem.UtilTypes
FExecuteHSFM.FileSystem.UtilTypes
FileHSFM.FileSystem.FileType
fileCollisionDialogHSFM.GUI.Gtk.Dialogs
fileGroupHSFM.FileSystem.FileType
fileIDHSFM.FileSystem.FileType
FileInfo 
1 (Type/Class)HSFM.FileSystem.FileType
2 (Data Constructor)HSFM.FileSystem.FileType
FileLikeHSFM.FileSystem.FileType
fileLikeHSFM.FileSystem.FileType
FileLikeListHSFM.FileSystem.FileType
FileLikeOrSymHSFM.FileSystem.FileType
FileLikeSymHSFM.FileSystem.FileType
fileLikeSymHSFM.FileSystem.FileType
fileListStoreHSFM.GUI.Gtk.Utils
fileModeHSFM.FileSystem.FileType
FileOperationHSFM.FileSystem.UtilTypes
fileOwnerHSFM.FileSystem.FileType
FilePropertyGridHSFM.GUI.Gtk.Data
fileSizeHSFM.FileSystem.FileType
filteredModelHSFM.GUI.Gtk.Data
FMIconViewHSFM.GUI.Gtk.Data
FMoveHSFM.FileSystem.UtilTypes
FMSettingsHSFM.GUI.Gtk.Data
FMTreeViewHSFM.GUI.Gtk.Data
FMViewHSFM.GUI.Gtk.Data
fmViewToContainerHSFM.GUI.Gtk.Data
FOpenHSFM.FileSystem.UtilTypes
fpropHSFM.GUI.Gtk.Data
fpropAcEntryHSFM.GUI.Gtk.Data
fpropFnEntryHSFM.GUI.Gtk.Data
fpropFTEntryHSFM.GUI.Gtk.Data
fpropGridHSFM.GUI.Gtk.Data
fpropLDEntryHSFM.GUI.Gtk.Data
fpropLocEntryHSFM.GUI.Gtk.Data
fpropModEntryHSFM.GUI.Gtk.Data
fpropPermEntryHSFM.GUI.Gtk.Data
fpropTsEntryHSFM.GUI.Gtk.Data
fromFreeVarHSFM.FileSystem.FileType
fvarHSFM.FileSystem.FileType
getBinDirPaths_hsfm
getContentsHSFM.FileSystem.FileType
getCurrentDirHSFM.GUI.Gtk.Utils
getDataDirPaths_hsfm
getDataFileNamePaths_hsfm
getFileInfoHSFM.FileSystem.FileType
getFirstItemHSFM.GUI.Gtk.Utils
getFPasStrHSFM.FileSystem.FileType
getFreeVarHSFM.FileSystem.FileType
getIconHSFM.GUI.Gtk.Icons
getLibDirPaths_hsfm
getLibexecDirPaths_hsfm
getSelectedItemsHSFM.GUI.Gtk.Utils
getSelectedTreePathsHSFM.GUI.Gtk.Utils
getSymlinkIconHSFM.GUI.Gtk.Icons
getSysconfDirPaths_hsfm
goDirHSFM.GUI.Gtk.Callbacks.Utils
goHistoryNextHSFM.GUI.Gtk.Callbacks
goHistoryPrevHSFM.GUI.Gtk.Callbacks
goHomeHSFM.GUI.Gtk.Callbacks
goUpHSFM.FileSystem.FileType
goUp'HSFM.FileSystem.FileType
GtkExceptionHSFM.GUI.Gtk.Errors
GtkIconHSFM.GUI.Gtk.Icons
historyHSFM.GUI.Gtk.Data
homeViewBHSFM.GUI.Gtk.Data
iconSizeHSFM.GUI.Gtk.Data
IErrorHSFM.GUI.Gtk.Icons
IFileHSFM.GUI.Gtk.Icons
IFolderHSFM.GUI.Gtk.Icons
inotifyHSFM.GUI.Gtk.Data
isBlockCHSFM.FileSystem.FileType
isBrokenSymlinkHSFM.FileSystem.FileType
isCharCHSFM.FileSystem.FileType
isDirCHSFM.FileSystem.FileType
isFileCHSFM.FileSystem.FileType
isLazyHSFM.GUI.Gtk.Data
isNamedCHSFM.FileSystem.FileType
isSocketCHSFM.FileSystem.FileType
isSymCHSFM.FileSystem.FileType
ItemHSFM.GUI.Gtk.Data
linkCountHSFM.FileSystem.FileType
listIndicesHSFM.Utils.MyPrelude
mainMain
maybeDHSFM.Utils.MyPrelude
MenuBarHSFM.GUI.Gtk.Data
menubarHSFM.GUI.Gtk.Data
menubarFileQuitHSFM.GUI.Gtk.Data
menubarHelpAboutHSFM.GUI.Gtk.Data
MkFilePropertyGridHSFM.GUI.Gtk.Data
MkFMSettingsHSFM.GUI.Gtk.Data
MkMenuBarHSFM.GUI.Gtk.Data
MkMyGUIHSFM.GUI.Gtk.Data
MkMyViewHSFM.GUI.Gtk.Data
MkRightClickMenuHSFM.GUI.Gtk.Data
modificationTimeHSFM.FileSystem.FileType
modificationTimeHiResHSFM.FileSystem.FileType
modifyTVarIOHSFM.Utils.IO
Move 
1 (Type/Class)HSFM.FileSystem.UtilTypes
2 (Data Constructor)HSFM.FileSystem.UtilTypes
moveInitHSFM.GUI.Gtk.Callbacks
MyGUIHSFM.GUI.Gtk.Data
MyViewHSFM.GUI.Gtk.Data
NamedPipeHSFM.FileSystem.FileType
newDirHSFM.GUI.Gtk.Callbacks
newFileHSFM.GUI.Gtk.Callbacks
newTabHSFM.GUI.Gtk.Callbacks
newTabHereHSFM.GUI.Gtk.Callbacks
NoneHSFM.FileSystem.UtilTypes
noNullPtrsHSFM.GUI.Glib.GlibString
notebookHSFM.GUI.Gtk.Data
openHSFM.GUI.Gtk.Callbacks
openTerminalHereHSFM.GUI.Gtk.Callbacks
operationBufferHSFM.GUI.Gtk.Data
operationFinalHSFM.GUI.Gtk.Callbacks
OverwriteHSFM.FileSystem.UtilTypes
OverwriteAllHSFM.FileSystem.UtilTypes
packAccessTimeHSFM.FileSystem.FileType
packFileTypeHSFM.FileSystem.FileType
packLinkDestinationHSFM.FileSystem.FileType
packModTimeHSFM.FileSystem.FileType
packPermissionsHSFM.FileSystem.FileType
PartialCopyHSFM.FileSystem.UtilTypes
PartialMoveHSFM.FileSystem.UtilTypes
pathHSFM.FileSystem.FileType
popStatusbarHSFM.GUI.Gtk.Utils
pushStatusBarHSFM.GUI.Gtk.Utils
rawdestHSFM.FileSystem.FileType
rawModelHSFM.GUI.Gtk.Data
rawPathToItemHSFM.GUI.Gtk.Utils
rawPathToIterHSFM.GUI.Gtk.Utils
rcFileCopyHSFM.GUI.Gtk.Data
rcFileCutHSFM.GUI.Gtk.Data
rcFileDeleteHSFM.GUI.Gtk.Data
rcFileExecuteHSFM.GUI.Gtk.Data
rcFileIconViewHSFM.GUI.Gtk.Data
rcFileNewDirHSFM.GUI.Gtk.Data
rcFileNewRegFileHSFM.GUI.Gtk.Data
rcFileNewTabHSFM.GUI.Gtk.Data
rcFileNewTabHereHSFM.GUI.Gtk.Data
rcFileOpenHSFM.GUI.Gtk.Data
rcFilePasteHSFM.GUI.Gtk.Data
rcFilePropertyHSFM.GUI.Gtk.Data
rcFileRenameHSFM.GUI.Gtk.Data
rcFileTreeViewHSFM.GUI.Gtk.Data
rcMenuHSFM.GUI.Gtk.Data
rcmenuHSFM.GUI.Gtk.Data
readDirectoryContentsHSFM.FileSystem.FileType
readFileHSFM.FileSystem.FileType
refreshViewHSFM.GUI.Gtk.MyView
refreshViewBHSFM.GUI.Gtk.Data
RegFileHSFM.FileSystem.FileType
RenameHSFM.FileSystem.UtilTypes
renameDialogHSFM.GUI.Gtk.Dialogs
renameFHSFM.GUI.Gtk.Callbacks
RightClickMenuHSFM.GUI.Gtk.Data
rootWinHSFM.GUI.Gtk.Data
scrollHSFM.GUI.Gtk.Data
sdestHSFM.FileSystem.FileType
sdirHSFM.FileSystem.FileType
setGUICallbacksHSFM.GUI.Gtk.Callbacks
settingsHSFM.GUI.Gtk.Data
setViewCallbacksHSFM.GUI.Gtk.Callbacks
sfileLikeHSFM.FileSystem.FileType
showAboutDialogHSFM.GUI.Gtk.Dialogs
showConfirmationDialogHSFM.GUI.Gtk.Dialogs
showErrorDialogHSFM.GUI.Gtk.Dialogs
showFilePropertyDialogHSFM.GUI.Gtk.Dialogs
showHiddenHSFM.GUI.Gtk.Data
SkipHSFM.FileSystem.UtilTypes
SocketHSFM.FileSystem.FileType
sortedModelHSFM.GUI.Gtk.Data
specialDeviceIDHSFM.FileSystem.FileType
statusBarHSFM.GUI.Gtk.Data
statusChangeTimeHSFM.FileSystem.FileType
statusChangeTimeHiResHSFM.FileSystem.FileType
StrictHSFM.FileSystem.UtilTypes
switchViewHSFM.GUI.Gtk.MyView
SymLHSFM.GUI.Gtk.Icons
SymLinkHSFM.FileSystem.FileType
textInputDialogHSFM.GUI.Gtk.Dialogs
UnknownDialogButtonHSFM.GUI.Gtk.Errors
upDirHSFM.GUI.Gtk.Callbacks
upViewBHSFM.GUI.Gtk.Data
urlBarHSFM.GUI.Gtk.Data
urlGoToHSFM.GUI.Gtk.Callbacks
versionPaths_hsfm
viewHSFM.GUI.Gtk.Data
viewBoxHSFM.GUI.Gtk.Data
withConfirmationDialogHSFM.GUI.Gtk.Dialogs
withErrorDialogHSFM.GUI.Gtk.Dialogs
withItemsHSFM.GUI.Gtk.Utils
writeTVarIOHSFM.Utils.IO
_doFileOperationHSFM.GUI.Gtk.Callbacks.Utils
\ No newline at end of file diff --git a/doc-index-N.html b/doc-index-N.html index bafb9a6..0df300c 100644 --- a/doc-index-N.html +++ b/doc-index-N.html @@ -1,4 +1,4 @@ hsfm-gtk (Index - N) \ No newline at end of file + \ No newline at end of file diff --git a/doc-index-R.html b/doc-index-R.html index 1eeaee2..cb22e19 100644 --- a/doc-index-R.html +++ b/doc-index-R.html @@ -1,4 +1,4 @@ hsfm-gtk (Index - R) \ No newline at end of file + \ No newline at end of file diff --git a/hsfm.haddock b/hsfm.haddock index 927aa25c6bcac3a53e918f7de19697ae6b7f52dd..f82516a420fde25ea20c94f17177b9f6a7842ba6 100644 GIT binary patch delta 1769 zcma)6dr*{B6#vfmvCBT$H84#qARlOBspFWVZKX2?4&&}3FqFWkyaJRQ#RrM`SYPPq zXmFwl6?K~Mm4?lo-3;_p@wzT)-8M^c+``zM^B~FDNjI+l>FYd5cMf}WRmCY|~ z?y&il&2Mb(VqVCs|B(|R432xFv|iPL74~p3z;(b36{7yNy8ws9XR!_qs<0_;3``aG z zNOxk%^jHK>JXB+XCl#FdiN`gF0w0i;Yh?N|$**wWO7{eebeqA9Bi)ft5GOxEqhG98 zQWS;nddEX8HhXV})+#`OTE9`{fc5cnpbnp%aRQFv%^BC>b8JYcf)k=3aRtB^;!aWm zSnFi&3shS#+{w!UgJuqadhB`qxYnSUvEz-wyuo_X28sBmNCc`GVdiirgTB*N6uZ8z zv1UHWlZvKJ#3`=m(wBqqNZP>C)X8W~$$}=aAZ0BWn-vXIEAH||;NWB%o>*hl?x~1l zV?xE`G?xme#EMy|0AGqLv#S8U!cFO$;WYNo*al}rWyWlP7GcQR4bUnov#)`*k(Y9k zO%ra(NrPtW%yD63?o*}~CR-INdUA*Iei*k(#QTwm7jh_fjM1Np9l2?SV2ZVg=jUz) zIE%IOinI##IrQa)qj!-L)ALsw&ncj(>3A!D0*+oAhRc_S3C~-Fn&E5Oc7NJdIR3c6 zWjIeLR3dl03FqXQaK^%+mJ3`vhQ5%1H}WQ6^rA34y|7&SU40VkQ$lfB!L;Culmco7 zj-C4|?u<1F$D$ap9QGfWrY50p&H%A=@kD@NtXuMok>~Y0C9cI5P+XhTbByAWKr+B#fIB7`*^Gxmx#6N*Fh(~vSA){ z;lU0027ZP$7+IX`Ag7a*nv9=YRXnwy&UG=JuJZ=I^g>tG?z`9#FT96z{_Ug z4i7=3bc4Z2EbtqodN6TBuAWAV$SnKNI?Ps(8IzZv?a3}oO3$D;i}P`AT6RIU_;=4o TLE=c|AP6?jmzkn*Z=(7i=l8jZ delta 1653 zcma)6eNa_J6u;*_9=s3U$A~5k4|xO;Uwj&J60tQRld4k3cygr#hTw` z;6$+xF5NSi)n|mtbdq&srITl$NDqZQ!VlI$57?Jmd7=%TnZc|s+dqSI`2(+C+)@H4xLrw4tTGt9l>dR#*z8?iJy0%Li0y(mCI?M78z z@NC3CPmS`0Fp?MPspOmSfh`bQ{iC!xj=w@&#iV{f(#Sa+C89kbi0ykio9GOt^UF0Y zayY6heUa?#gSIVIo@d2(ZNviwOI&vm$#xbLYqVeU{CQYf5rF%OV(1%W7p2iTd{lIe zCeiv#CY}HAS%{izDt3}l*;X87K*B`H0=h`E&Rc_+hv@Qu_l(^A!|U zvy6U3VNIFlpd1F;I-gC~1d;Y9PMC*?wL!R8twVT}FY>p|rJoU5Sr60p674TM{ty}- zOhbN@71K2-c(^v0ennR87P^d6wFL$raaM8oAvo&R=~Xy{x9XNDXh;wQ@+Mi0DrBdt z5Ul)@(*s3ajVV9km|~LhbB&3Gl`+M_USVDt;@;kIyYzy%Uj<@ryAvExfyjAR1tRC5 z3dDS91|a6u1EGSfwohe)PiNxX_-qD1*Z5SZ=)qF2+b61AI_UVF zvu>9OM&33>AC|szyUf^)^}G@Pfe_w^ZB1i~t?r2QCpZ2Q;BPKBx!e-Ryv;=nr8EEI zvN?dGIo3{`KpsMAd4T7WxNP!ru}H_-n_G>n;_ba2UY>=U%GTuMGN1i{#1h(8$^QZs CJewE* diff --git a/mini_HSFM-GUI-Gtk-Callbacks.html b/mini_HSFM-GUI-Gtk-Callbacks.html index 41cf993..eb754f9 100644 --- a/mini_HSFM-GUI-Gtk-Callbacks.html +++ b/mini_HSFM-GUI-Gtk-Callbacks.html @@ -1,4 +1,4 @@ HSFM.GUI.Gtk.Callbacks

HSFM.GUI.Gtk.Callbacks

\ No newline at end of file +

HSFM.GUI.Gtk.Callbacks

\ No newline at end of file diff --git a/mini_HSFM-GUI-Gtk-MyView.html b/mini_HSFM-GUI-Gtk-MyView.html index f1ac52a..5df1e42 100644 --- a/mini_HSFM-GUI-Gtk-MyView.html +++ b/mini_HSFM-GUI-Gtk-MyView.html @@ -1,4 +1,4 @@ HSFM.GUI.Gtk.MyView

HSFM.GUI.Gtk.MyView

\ No newline at end of file +

HSFM.GUI.Gtk.MyView

\ No newline at end of file diff --git a/src/HSFM-GUI-Gtk-Callbacks-Utils.html b/src/HSFM-GUI-Gtk-Callbacks-Utils.html index 653b558..c40325d 100644 --- a/src/HSFM-GUI-Gtk-Callbacks-Utils.html +++ b/src/HSFM-GUI-Gtk-Callbacks-Utils.html @@ -120,8 +120,16 @@ -- set notebook tab label page <- notebookGetCurrentPage (notebook mygui) child <- fromJust <$> notebookGetNthPage (notebook mygui) page - notebookSetTabLabelText (notebook mygui) child - (maybe (P.fromAbs $ path item) P.fromRel $ P.basename . path $ item) - + + -- get the label + ebox <- (castToEventBox . fromJust) + <$> notebookGetTabLabel (notebook mygui) child + label <- (castToLabel . head) <$> containerGetChildren ebox + + -- set the label + labelSetText label + (maybe (P.fromAbs $ path item) + P.fromRel $ P.basename . path $ item) + diff --git a/src/HSFM-GUI-Gtk-Callbacks.html b/src/HSFM-GUI-Gtk-Callbacks.html index 4b9db6a..5649391 100644 --- a/src/HSFM-GUI-Gtk-Callbacks.html +++ b/src/HSFM-GUI-Gtk-Callbacks.html @@ -41,527 +41,580 @@ ) import Control.Monad ( - forM_ - , forM + forM + , forM_ , join - , void - , when - ) -import Control.Monad.IO.Class - ( - liftIO - ) -import Data.ByteString - ( - ByteString - ) -import Data.ByteString.UTF8 - ( - fromString - , toString - ) -import Data.Foldable - ( - for_ - ) -import Graphics.UI.Gtk -import qualified HPath as P -import HPath - ( - Abs - , Path - ) -import HPath.IO -import HPath.IO.Errors -import HPath.IO.Utils -import HSFM.FileSystem.FileType -import HSFM.FileSystem.UtilTypes -import HSFM.GUI.Gtk.Callbacks.Utils -import HSFM.GUI.Gtk.Data -import HSFM.GUI.Gtk.Dialogs -import HSFM.GUI.Gtk.MyView -import HSFM.GUI.Gtk.Utils -import HSFM.Utils.IO -import Prelude hiding(readFile) -import System.Glib.UTFString - ( - glibToString - ) -import System.Posix.Env.ByteString - ( - getEnv - ) -import qualified System.Posix.Process.ByteString as SPP -import System.Posix.Types + , unless + , void + , when + ) +import Control.Monad.IO.Class + ( + liftIO + ) +import Data.ByteString + ( + ByteString + ) +import Data.ByteString.UTF8 + ( + fromString + , toString + ) +import Data.Foldable + ( + for_ + ) +import Data.Maybe + ( + fromJust + ) +import Graphics.UI.Gtk +import qualified HPath as P +import HPath + ( + Abs + , Path + ) +import HPath.IO +import HPath.IO.Errors +import HPath.IO.Utils +import HSFM.FileSystem.FileType +import HSFM.FileSystem.UtilTypes +import HSFM.GUI.Gtk.Callbacks.Utils +import HSFM.GUI.Gtk.Data +import HSFM.GUI.Gtk.Dialogs +import HSFM.GUI.Gtk.MyView +import HSFM.GUI.Gtk.Utils +import HSFM.Utils.IO +import Prelude hiding(readFile) +import System.Glib.UTFString + ( + glibToString + ) +import System.IO.Error ( - ProcessID - ) - - - - - - ----------------- - --[ Callbacks ]-- - ----------------- - - + catchIOError + , isUserError + ) +import System.Posix.Env.ByteString + ( + getEnv + ) +import qualified System.Posix.Process.ByteString as SPP +import System.Posix.Types + ( + ProcessID + ) ----- MAIN CALLBACK ENTRYPOINT ---- + --- |Set callbacks for the whole gui, on hotkeys, events and stuff. -setGUICallbacks :: MyGUI -> IO () -setGUICallbacks mygui = do + ----------------- + --[ Callbacks ]-- + ----------------- - _ <- clearStatusBar mygui `on` buttonActivated $ do - popStatusbar mygui - writeTVarIO (operationBuffer mygui) None - - -- menubar-file - _ <- (menubarFileQuit . menubar) mygui `on` menuItemActivated $ - mainQuit - - -- menubar-help - _ <- (menubarHelpAbout . menubar) mygui `on` menuItemActivated $ - liftIO showAboutDialog - return () - - -- key events - _ <- rootWin mygui `on` keyPressEvent $ tryEvent $ do - [Control] <- eventModifier - "q" <- fmap glibToString eventKeyName - liftIO mainQuit - - return () - - --- |Set callbacks specific to a given view, on hotkeys, events and stuff. -setViewCallbacks :: MyGUI -> MyView -> IO () -setViewCallbacks mygui myview = do - view' <- readTVarIO $ view myview - case view' of - fmv@(FMTreeView treeView) -> do - _ <- treeView `on` rowActivated - $ (\_ _ -> withItems mygui myview open) + + + +---- MAIN CALLBACK ENTRYPOINT ---- + + +-- |Set callbacks for the whole gui, on hotkeys, events and stuff. +setGUICallbacks :: MyGUI -> IO () +setGUICallbacks mygui = do + + _ <- clearStatusBar mygui `on` buttonActivated $ do + popStatusbar mygui + writeTVarIO (operationBuffer mygui) None + + -- menubar-file + _ <- (menubarFileQuit . menubar) mygui `on` menuItemActivated $ + mainQuit + + -- menubar-help + _ <- (menubarHelpAbout . menubar) mygui `on` menuItemActivated $ + liftIO showAboutDialog + return () + + -- key events + _ <- rootWin mygui `on` keyPressEvent $ tryEvent $ do + [Control] <- eventModifier + "q" <- fmap glibToString eventKeyName + liftIO mainQuit + + return () - -- drag events - _ <- treeView `on` dragBegin $ - \_ -> withItems mygui myview moveInit - _ <- treeView `on` dragDrop $ - \dc p ts -> do - p' <- treeViewConvertWidgetToTreeCoords treeView p - mpath <- treeViewGetPathAtPos treeView p' - case mpath of - Nothing -> do - dragFinish dc False False ts - return False - Just _ -> do - atom <- atomNew ("HSFM" :: String) - dragGetData treeView dc atom ts - return True - _ <- treeView `on` dragDataReceived $ - \dc p _ ts -> - liftIO $ do - signalStopEmission treeView "drag_data_received" - p' <- treeViewConvertWidgetToTreeCoords treeView p - mpath <- treeViewGetPathAtPos treeView p' - case mpath of - Nothing -> dragFinish dc False False ts - Just (tp, _, _) -> do - mitem <- rawPathToItem myview tp - forM_ mitem $ \item -> - operationFinal mygui myview (Just item) - dragFinish dc True False ts - - commonGuiEvents fmv - return () - fmv@(FMIconView iconView) -> do - _ <- iconView `on` itemActivated - $ (\_ -> withItems mygui myview open) - commonGuiEvents fmv - return () - where - commonGuiEvents fmv = do - let view = fmViewToContainer fmv - - -- GUI events - _ <- urlBar myview `on` entryActivated $ urlGoTo mygui myview - _ <- upViewB myview `on` buttonActivated $ - upDir mygui myview - _ <- homeViewB myview `on` buttonActivated $ - goHome mygui myview - _ <- refreshViewB myview `on` buttonActivated $ do - cdir <- liftIO $ getCurrentDir myview - refreshView mygui myview cdir + +-- |Set callbacks specific to a given view, on hotkeys, events and stuff. +setViewCallbacks :: MyGUI -> MyView -> IO () +setViewCallbacks mygui myview = do + view' <- readTVarIO $ view myview + case view' of + fmv@(FMTreeView treeView) -> do + _ <- treeView `on` rowActivated + $ (\_ _ -> withItems mygui myview open) + + -- drag events + _ <- treeView `on` dragBegin $ + \_ -> withItems mygui myview moveInit + _ <- treeView `on` dragDrop $ + \dc p ts -> do + p' <- treeViewConvertWidgetToTreeCoords treeView p + mpath <- treeViewGetPathAtPos treeView p' + case mpath of + Nothing -> do + dragFinish dc False False ts + return False + Just _ -> do + atom <- atomNew ("HSFM" :: String) + dragGetData treeView dc atom ts + return True + _ <- treeView `on` dragDataReceived $ + \dc p _ ts -> + liftIO $ do + signalStopEmission treeView "drag_data_received" + p' <- treeViewConvertWidgetToTreeCoords treeView p + mpath <- treeViewGetPathAtPos treeView p' + case mpath of + Nothing -> dragFinish dc False False ts + Just (tp, _, _) -> do + mitem <- rawPathToItem myview tp + forM_ mitem $ \item -> + operationFinal mygui myview (Just item) + dragFinish dc True False ts + + commonGuiEvents fmv + return () + fmv@(FMIconView iconView) -> do + _ <- iconView `on` itemActivated + $ (\_ -> withItems mygui myview open) + commonGuiEvents fmv + return () + where + commonGuiEvents fmv = do + let view = fmViewToContainer fmv - -- key events - _ <- viewBox myview `on` keyPressEvent $ tryEvent $ do - [Control] <- eventModifier - "h" <- fmap glibToString eventKeyName - cdir <- liftIO $ getCurrentDir myview - liftIO $ modifyTVarIO (settings mygui) - (\x -> x { showHidden = not . showHidden $ x}) - >> refreshView mygui myview cdir - _ <- viewBox myview `on` keyPressEvent $ tryEvent $ do - [Alt] <- eventModifier - "Up" <- fmap glibToString eventKeyName - liftIO $ upDir mygui myview - _ <- viewBox myview `on` keyPressEvent $ tryEvent $ do - [Alt] <- eventModifier - "Left" <- fmap glibToString eventKeyName - liftIO $ goHistoryPrev mygui myview - _ <- viewBox myview `on` keyPressEvent $ tryEvent $ do - [Alt] <- eventModifier - "Right" <- fmap glibToString eventKeyName - liftIO $ goHistoryNext mygui myview - _ <- view `on` keyPressEvent $ tryEvent $ do - "Delete" <- fmap glibToString eventKeyName - liftIO $ withItems mygui myview del - _ <- view `on` keyPressEvent $ tryEvent $ do - [] <- eventModifier - "Return" <- fmap glibToString eventKeyName - liftIO $ withItems mygui myview open - _ <- view `on` keyPressEvent $ tryEvent $ do - [Control] <- eventModifier - "c" <- fmap glibToString eventKeyName - liftIO $ withItems mygui myview copyInit - _ <- view `on` keyPressEvent $ tryEvent $ do - [Control] <- eventModifier - "x" <- fmap glibToString eventKeyName - liftIO $ withItems mygui myview moveInit - _ <- viewBox myview `on` keyPressEvent $ tryEvent $ do - [Control] <- eventModifier - "v" <- fmap glibToString eventKeyName - liftIO $ operationFinal mygui myview Nothing - _ <- viewBox myview `on` keyPressEvent $ tryEvent $ do - [Control] <- eventModifier - "t" <- fmap glibToString eventKeyName - liftIO $ void $ do - cwd <- getCurrentDir myview - newTabHere mygui cwd + -- GUI events + _ <- urlBar myview `on` entryActivated $ urlGoTo mygui myview + _ <- upViewB myview `on` buttonActivated $ + upDir mygui myview + _ <- homeViewB myview `on` buttonActivated $ + goHome mygui myview + _ <- refreshViewB myview `on` buttonActivated $ do + cdir <- liftIO $ getCurrentDir myview + refreshView mygui myview cdir + + -- key events + _ <- viewBox myview `on` keyPressEvent $ tryEvent $ do + [Control] <- eventModifier + "h" <- fmap glibToString eventKeyName + cdir <- liftIO $ getCurrentDir myview + liftIO $ modifyTVarIO (settings mygui) + (\x -> x { showHidden = not . showHidden $ x}) + >> refreshView mygui myview cdir + _ <- viewBox myview `on` keyPressEvent $ tryEvent $ do + [Alt] <- eventModifier + "Up" <- fmap glibToString eventKeyName + liftIO $ upDir mygui myview + _ <- viewBox myview `on` keyPressEvent $ tryEvent $ do + [Alt] <- eventModifier + "Left" <- fmap glibToString eventKeyName + liftIO $ goHistoryPrev mygui myview + _ <- viewBox myview `on` keyPressEvent $ tryEvent $ do + [Alt] <- eventModifier + "Right" <- fmap glibToString eventKeyName + liftIO $ goHistoryNext mygui myview + _ <- view `on` keyPressEvent $ tryEvent $ do + "Delete" <- fmap glibToString eventKeyName + liftIO $ withItems mygui myview del + _ <- view `on` keyPressEvent $ tryEvent $ do + [] <- eventModifier + "Return" <- fmap glibToString eventKeyName + liftIO $ withItems mygui myview open + _ <- view `on` keyPressEvent $ tryEvent $ do + [Control] <- eventModifier + "c" <- fmap glibToString eventKeyName + liftIO $ withItems mygui myview copyInit + _ <- view `on` keyPressEvent $ tryEvent $ do + [Control] <- eventModifier + "x" <- fmap glibToString eventKeyName + liftIO $ withItems mygui myview moveInit _ <- viewBox myview `on` keyPressEvent $ tryEvent $ do [Control] <- eventModifier - "w" <- fmap glibToString eventKeyName - liftIO $ void $ closeTab mygui myview + "v" <- fmap glibToString eventKeyName + liftIO $ operationFinal mygui myview Nothing _ <- viewBox myview `on` keyPressEvent $ tryEvent $ do - "F4" <- fmap glibToString eventKeyName - liftIO $ void $ openTerminalHere myview - - -- mouse button click - _ <- view `on` buttonPressEvent $ do - eb <- eventButton - t <- eventTime - case eb of - RightButton -> do - _ <- liftIO $ menuPopup (rcMenu . rcmenu $ myview) - $ Just (RightButton, t) - -- this is just to not screw with current selection - -- on right-click - -- TODO: this misbehaves under IconView - (x, y) <- eventCoordinates - mpath <- liftIO $ getPathAtPos fmv (x, y) - case mpath of - -- item under the cursor, only pass on the signal - -- if the item under the cursor is not within the current - -- selection - (Just tp) -> do - selectedTps <- liftIO $ getSelectedTreePaths mygui myview - return $ elem tp selectedTps - -- no item under the cursor, pass on the signal - Nothing -> return False - MiddleButton -> do - (x, y) <- eventCoordinates - mitem <- liftIO $ (getPathAtPos fmv (x, y)) - >>= \mpos -> fmap join - $ forM mpos (rawPathToItem myview) - - case mitem of - -- item under the cursor, only pass on the signal - -- if the item under the cursor is not within the current - -- selection - (Just item) -> do - liftIO $ newTabHere mygui item - return True - -- no item under the cursor, pass on the signal - Nothing -> return False + [Control] <- eventModifier + "t" <- fmap glibToString eventKeyName + liftIO $ void $ do + cwd <- getCurrentDir myview + newTabHere mygui cwd + _ <- viewBox myview `on` keyPressEvent $ tryEvent $ do + [Control] <- eventModifier + "w" <- fmap glibToString eventKeyName + liftIO $ void $ closeTab mygui myview + _ <- viewBox myview `on` keyPressEvent $ tryEvent $ do + "F4" <- fmap glibToString eventKeyName + liftIO $ void $ openTerminalHere myview + + -- mouse button click + _ <- view `on` buttonPressEvent $ do + eb <- eventButton + t <- eventTime + case eb of + RightButton -> do + _ <- liftIO $ menuPopup (rcMenu . rcmenu $ myview) + $ Just (RightButton, t) + -- this is just to not screw with current selection + -- on right-click + -- TODO: this misbehaves under IconView + (x, y) <- eventCoordinates + mpath <- liftIO $ getPathAtPos fmv (x, y) + case mpath of + -- item under the cursor, only pass on the signal + -- if the item under the cursor is not within the current + -- selection + (Just tp) -> do + selectedTps <- liftIO $ getSelectedTreePaths mygui myview + return $ elem tp selectedTps + -- no item under the cursor, pass on the signal + Nothing -> return False + MiddleButton -> do + (x, y) <- eventCoordinates + mitem <- liftIO $ (getPathAtPos fmv (x, y)) + >>= \mpos -> fmap join + $ forM mpos (rawPathToItem myview) - OtherButton 8 -> do - liftIO $ goHistoryPrev mygui myview - return False - OtherButton 9 -> do - liftIO $ goHistoryNext mygui myview - return False - -- not right-click, so pass on the signal - _ -> return False - - -- right click menu - _ <- (rcFileOpen . rcmenu) myview `on` menuItemActivated $ - liftIO $ withItems mygui myview open - _ <- (rcFileExecute . rcmenu) myview `on` menuItemActivated $ - liftIO $ withItems mygui myview execute - _ <- (rcFileNewRegFile . rcmenu) myview `on` menuItemActivated $ - liftIO $ newFile mygui myview - _ <- (rcFileNewDir . rcmenu) myview `on` menuItemActivated $ - liftIO $ newDir mygui myview - _ <- (rcFileCopy . rcmenu) myview `on` menuItemActivated $ - liftIO $ withItems mygui myview copyInit - _ <- (rcFileRename . rcmenu) myview `on` menuItemActivated $ - liftIO $ withItems mygui myview renameF - _ <- (rcFilePaste . rcmenu) myview `on` menuItemActivated $ - liftIO $ operationFinal mygui myview Nothing - _ <- (rcFileDelete . rcmenu) myview `on` menuItemActivated $ - liftIO $ withItems mygui myview del - _ <- (rcFileProperty . rcmenu) myview `on` menuItemActivated $ - liftIO $ withItems mygui myview showFilePropertyDialog - _ <- (rcFileCut . rcmenu) myview `on` menuItemActivated $ - liftIO $ withItems mygui myview moveInit - _ <- (rcFileIconView . rcmenu) myview `on` menuItemActivated $ - liftIO $ switchView mygui myview createIconView - _ <- (rcFileTreeView . rcmenu) myview `on` menuItemActivated $ - liftIO $ switchView mygui myview createTreeView - return () - - getPathAtPos fmv (x, y) = - case fmv of - FMTreeView treeView -> do - mp <- treeViewGetPathAtPos treeView (round x, round y) - return $ fmap (\(p, _, _) -> p) mp - FMIconView iconView -> - fmap (\tp -> if null tp then Nothing else Just tp) - $ iconViewGetPathAtPos iconView (round x) (round y) - - - - ----- OTHER ---- - - -openTerminalHere :: MyView -> IO ProcessID -openTerminalHere myview = do - cwd <- (P.fromAbs . path) <$> getCurrentDir myview - -- TODO: make terminal configurable - SPP.forkProcess $ SPP.executeFile "sakura" True ["-d", cwd] Nothing - - - - ----- TAB OPERATIONS ---- + case mitem of + -- item under the cursor, only pass on the signal + -- if the item under the cursor is not within the current + -- selection + (Just item) -> do + liftIO $ newTabHere mygui item + return True + -- no item under the cursor, pass on the signal + Nothing -> return False + + OtherButton 8 -> do + liftIO $ goHistoryPrev mygui myview + return False + OtherButton 9 -> do + liftIO $ goHistoryNext mygui myview + return False + -- not right-click, so pass on the signal + _ -> return False + + -- right click menu + _ <- (rcFileOpen . rcmenu) myview `on` menuItemActivated $ + liftIO $ withItems mygui myview open + _ <- (rcFileExecute . rcmenu) myview `on` menuItemActivated $ + liftIO $ withItems mygui myview execute + _ <- (rcFileNewRegFile . rcmenu) myview `on` menuItemActivated $ + liftIO $ newFile mygui myview + _ <- (rcFileNewDir . rcmenu) myview `on` menuItemActivated $ + liftIO $ newDir mygui myview + _ <- (rcFileNewTab . rcmenu) myview `on` menuItemActivated $ + liftIO $ do + cwd <- getCurrentDir myview + newTabHere mygui cwd + _ <- (rcFileNewTabHere . rcmenu) myview `on` menuItemActivated $ + liftIO $ withItems mygui myview $ \items mygui' _ -> + forM_ items $ newTabHere mygui' + _ <- (rcFileCopy . rcmenu) myview `on` menuItemActivated $ + liftIO $ withItems mygui myview copyInit + _ <- (rcFileRename . rcmenu) myview `on` menuItemActivated $ + liftIO $ withItems mygui myview renameF + _ <- (rcFilePaste . rcmenu) myview `on` menuItemActivated $ + liftIO $ operationFinal mygui myview Nothing + _ <- (rcFileDelete . rcmenu) myview `on` menuItemActivated $ + liftIO $ withItems mygui myview del + _ <- (rcFileProperty . rcmenu) myview `on` menuItemActivated $ + liftIO $ withItems mygui myview showFilePropertyDialog + _ <- (rcFileCut . rcmenu) myview `on` menuItemActivated $ + liftIO $ withItems mygui myview moveInit + _ <- (rcFileIconView . rcmenu) myview `on` menuItemActivated $ + liftIO $ switchView mygui myview createIconView + _ <- (rcFileTreeView . rcmenu) myview `on` menuItemActivated $ + liftIO $ switchView mygui myview createTreeView + return () + + getPathAtPos fmv (x, y) = + case fmv of + FMTreeView treeView -> do + mp <- treeViewGetPathAtPos treeView (round x, round y) + return $ fmap (\(p, _, _) -> p) mp + FMIconView iconView -> + fmap (\tp -> if null tp then Nothing else Just tp) + $ iconViewGetPathAtPos iconView (round x) (round y) --- |Closes the current tab, but only if there is more than one tab. -closeTab :: MyGUI -> MyView -> IO () -closeTab mygui myview = do - n <- notebookGetNPages (notebook mygui) - when (n > 1) $ void $ destroyView mygui myview - - -newTabHere :: MyGUI -> Item -> IO () -newTabHere mygui item@(DirOrSym _) = - void $ withErrorDialog $ newTab mygui createTreeView item -newTabHere _ _ = return () + + +---- OTHER ---- + + +openTerminalHere :: MyView -> IO ProcessID +openTerminalHere myview = do + cwd <- (P.fromAbs . path) <$> getCurrentDir myview + -- TODO: make terminal configurable + SPP.forkProcess $ SPP.executeFile "sakura" True ["-d", cwd] Nothing + ----- FILE OPERATION CALLBACKS (COPY, MOVE, ...) ---- +---- TAB OPERATIONS ---- --- |Supposed to be used with 'withRows'. Deletes a file or directory. -del :: [Item] -> MyGUI -> MyView -> IO () -del [item] _ _ = withErrorDialog $ do - let cmsg = "Really delete \"" ++ getFPasStr item ++ "\"?" - withConfirmationDialog cmsg - $ easyDelete . path $ item --- this throws on the first error that occurs -del items@(_:_) _ _ = withErrorDialog $ do - let cmsg = "Really delete " ++ show (length items) ++ " files?" - withConfirmationDialog cmsg - $ forM_ items $ \item -> easyDelete . path $ item -del _ _ _ = withErrorDialog - . throwIO $ InvalidOperation - "Operation not supported on multiple files" - - --- |Initializes a file move operation. -moveInit :: [Item] -> MyGUI -> MyView -> IO () -moveInit items@(_:_) mygui _ = do - writeTVarIO (operationBuffer mygui) (FMove . PartialMove . map path $ items) - let sbmsg = case items of - (item:[]) -> "Move buffer: " ++ getFPasStr item - _ -> "Move buffer: " ++ (show . length $ items) - ++ " items" - popStatusbar mygui - void $ pushStatusBar mygui sbmsg -moveInit _ _ _ = withErrorDialog - . throwIO $ InvalidOperation - "No file selected!" +-- |Closes the current tab, but only if there is more than one tab. +closeTab :: MyGUI -> MyView -> IO () +closeTab mygui myview = do + n <- notebookGetNPages (notebook mygui) + when (n > 1) $ void $ destroyView mygui myview + + +newTabHere :: MyGUI -> Item -> IO () +newTabHere mygui item@(DirOrSym _) = + void $ withErrorDialog $ newTab mygui createTreeView item +newTabHere _ _ = return () + + +-- |Creates a new tab with its own view and refreshes the view. +newTab :: MyGUI -> IO FMView -> Item -> IO MyView +newTab mygui iofmv item = do + -- create eventbox with label + label <- labelNewWithMnemonic + (maybe (P.fromAbs $ path item) P.fromRel $ P.basename $ path item) + ebox <- eventBoxNew + eventBoxSetVisibleWindow ebox False + containerAdd ebox label + widgetShowAll label + + myview <- createMyView mygui iofmv + _ <- notebookAppendPageMenu (notebook mygui) (viewBox myview) + ebox ebox + + notebookSetTabReorderable (notebook mygui) (viewBox myview) True --- |Supposed to be used with 'withRows'. Initializes a file copy operation. -copyInit :: [Item] -> MyGUI -> MyView -> IO () -copyInit items@(_:_) mygui _ = do - writeTVarIO (operationBuffer mygui) (FCopy . PartialCopy . map path $ items) - let sbmsg = case items of - (item:[]) -> "Copy buffer: " ++ getFPasStr item - _ -> "Copy buffer: " ++ (show . length $ items) - ++ " items" - popStatusbar mygui - void $ pushStatusBar mygui sbmsg -copyInit _ _ _ = withErrorDialog - . throwIO $ InvalidOperation - "No file selected!" - - --- |Finalizes a file operation, such as copy or move. -operationFinal :: MyGUI -> MyView -> Maybe Item -> IO () -operationFinal mygui myview mitem = withErrorDialog $ do - op <- readTVarIO (operationBuffer mygui) - cdir <- case mitem of - Nothing -> path <$> getCurrentDir myview - Just x -> return $ path x - case op of - FMove (PartialMove s) -> do - let cmsg = "Really move " ++ imsg s - ++ " to \"" ++ toString (P.fromAbs cdir) - ++ "\"?" - withConfirmationDialog cmsg $ doFileOperation (FMove $ Move s cdir) - popStatusbar mygui - writeTVarIO (operationBuffer mygui) None - FCopy (PartialCopy s) -> do - let cmsg = "Really copy " ++ imsg s - ++ " to \"" ++ toString (P.fromAbs cdir) - ++ "\"?" - withConfirmationDialog cmsg $ doFileOperation (FCopy $ Copy s cdir) - _ -> return () - where - imsg s = case s of - (item:[]) -> "\"" ++ toString (P.fromAbs item) ++ "\"" - items -> (show . length $ items) ++ " items" - - --- |Create a new file. -newFile :: MyGUI -> MyView -> IO () -newFile _ myview = withErrorDialog $ do - mfn <- textInputDialog "Enter file name" ("" :: String) - let pmfn = P.parseFn =<< fromString <$> mfn - for_ pmfn $ \fn -> do - cdir <- getCurrentDir myview - createRegularFile (path cdir P.</> fn) - - --- |Create a new directory. -newDir :: MyGUI -> MyView -> IO () -newDir _ myview = withErrorDialog $ do - mfn <- textInputDialog "Enter directory name" ("" :: String) - let pmfn = P.parseFn =<< fromString <$> mfn - for_ pmfn $ \fn -> do - cdir <- getCurrentDir myview - createDir (path cdir P.</> fn) - - -renameF :: [Item] -> MyGUI -> MyView -> IO () -renameF [item] _ _ = withErrorDialog $ do - iname <- P.fromRel <$> (P.basename $ path item) - mfn <- textInputDialog "Enter new file name" (iname :: ByteString) - let pmfn = P.parseFn =<< fromString <$> mfn - for_ pmfn $ \fn -> do - let cmsg = "Really rename \"" ++ getFPasStr item - ++ "\"" ++ " to \"" - ++ toString (P.fromAbs $ (P.dirname . path $ item) - P.</> fn) ++ "\"?" - withConfirmationDialog cmsg $ - HPath.IO.renameFile (path item) - ((P.dirname $ path item) P.</> fn) -renameF _ _ _ = withErrorDialog - . throwIO $ InvalidOperation - "Operation not supported on multiple files" - - - - ----- DIRECTORY TRAVERSAL AND FILE OPENING CALLBACKS ---- - - --- |Go to the url given at the 'urlBar' and visualize it in the given --- treeView. --- --- If the url is invalid, does nothing. -urlGoTo :: MyGUI -> MyView -> IO () -urlGoTo mygui myview = withErrorDialog $ do - fp <- entryGetText (urlBar myview) - forM_ (P.parseAbs fp :: Maybe (Path Abs)) $ \fp' -> - whenM (canOpenDirectory fp') - (goDir True mygui myview =<< (readFile getFileInfo $ fp')) - - -goHome :: MyGUI -> MyView -> IO () -goHome mygui myview = withErrorDialog $ do - mhomedir <- getEnv "HOME" - forM_ (P.parseAbs =<< mhomedir :: Maybe (Path Abs)) $ \fp' -> - whenM (canOpenDirectory fp') - (goDir True mygui myview =<< (readFile getFileInfo $ fp')) + catchIOError (refreshView mygui myview item) $ \e -> do + unless (isUserError e) (ioError e) + file <- readFile getFileInfo . fromJust . P.parseAbs . fromString + $ "/" + refreshView mygui myview file + labelSetText label (fromString "/") + + -- close callback + _ <- ebox `on` buttonPressEvent $ do + eb <- eventButton + case eb of + MiddleButton -> do + _ <- liftIO $ closeTab mygui myview + return True + _ -> return False + + return myview + + + +---- FILE OPERATION CALLBACKS (COPY, MOVE, ...) ---- + + +-- |Supposed to be used with 'withRows'. Deletes a file or directory. +del :: [Item] -> MyGUI -> MyView -> IO () +del [item] _ _ = withErrorDialog $ do + let cmsg = "Really delete \"" ++ getFPasStr item ++ "\"?" + withConfirmationDialog cmsg + $ easyDelete . path $ item +-- this throws on the first error that occurs +del items@(_:_) _ _ = withErrorDialog $ do + let cmsg = "Really delete " ++ show (length items) ++ " files?" + withConfirmationDialog cmsg + $ forM_ items $ \item -> easyDelete . path $ item +del _ _ _ = withErrorDialog + . throwIO $ InvalidOperation + "Operation not supported on multiple files" + + +-- |Initializes a file move operation. +moveInit :: [Item] -> MyGUI -> MyView -> IO () +moveInit items@(_:_) mygui _ = do + writeTVarIO (operationBuffer mygui) (FMove . PartialMove . map path $ items) + let sbmsg = case items of + (item:[]) -> "Move buffer: " ++ getFPasStr item + _ -> "Move buffer: " ++ (show . length $ items) + ++ " items" + popStatusbar mygui + void $ pushStatusBar mygui sbmsg +moveInit _ _ _ = withErrorDialog + . throwIO $ InvalidOperation + "No file selected!" + +-- |Supposed to be used with 'withRows'. Initializes a file copy operation. +copyInit :: [Item] -> MyGUI -> MyView -> IO () +copyInit items@(_:_) mygui _ = do + writeTVarIO (operationBuffer mygui) (FCopy . PartialCopy . map path $ items) + let sbmsg = case items of + (item:[]) -> "Copy buffer: " ++ getFPasStr item + _ -> "Copy buffer: " ++ (show . length $ items) + ++ " items" + popStatusbar mygui + void $ pushStatusBar mygui sbmsg +copyInit _ _ _ = withErrorDialog + . throwIO $ InvalidOperation + "No file selected!" + + +-- |Finalizes a file operation, such as copy or move. +operationFinal :: MyGUI -> MyView -> Maybe Item -> IO () +operationFinal mygui myview mitem = withErrorDialog $ do + op <- readTVarIO (operationBuffer mygui) + cdir <- case mitem of + Nothing -> path <$> getCurrentDir myview + Just x -> return $ path x + case op of + FMove (PartialMove s) -> do + let cmsg = "Really move " ++ imsg s + ++ " to \"" ++ toString (P.fromAbs cdir) + ++ "\"?" + withConfirmationDialog cmsg $ doFileOperation (FMove $ Move s cdir) + popStatusbar mygui + writeTVarIO (operationBuffer mygui) None + FCopy (PartialCopy s) -> do + let cmsg = "Really copy " ++ imsg s + ++ " to \"" ++ toString (P.fromAbs cdir) + ++ "\"?" + withConfirmationDialog cmsg $ doFileOperation (FCopy $ Copy s cdir) + _ -> return () + where + imsg s = case s of + (item:[]) -> "\"" ++ toString (P.fromAbs item) ++ "\"" + items -> (show . length $ items) ++ " items" + + +-- |Create a new file. +newFile :: MyGUI -> MyView -> IO () +newFile _ myview = withErrorDialog $ do + mfn <- textInputDialog "Enter file name" ("" :: String) + let pmfn = P.parseFn =<< fromString <$> mfn + for_ pmfn $ \fn -> do + cdir <- getCurrentDir myview + createRegularFile (path cdir P.</> fn) --- |Execute a given file. -execute :: [Item] -> MyGUI -> MyView -> IO () -execute [item] _ _ = withErrorDialog $ - void $ executeFile (path item) [] -execute _ _ _ = withErrorDialog - . throwIO $ InvalidOperation - "Operation not supported on multiple files" - +-- |Create a new directory. +newDir :: MyGUI -> MyView -> IO () +newDir _ myview = withErrorDialog $ do + mfn <- textInputDialog "Enter directory name" ("" :: String) + let pmfn = P.parseFn =<< fromString <$> mfn + for_ pmfn $ \fn -> do + cdir <- getCurrentDir myview + createDir (path cdir P.</> fn) --- |Supposed to be used with 'withRows'. Opens a file or directory. -open :: [Item] -> MyGUI -> MyView -> IO () -open [item] mygui myview = withErrorDialog $ - case item of - DirOrSym r -> do - nv <- readFile getFileInfo $ path r - goDir True mygui myview nv - r -> - void $ openFile . path $ r --- this throws on the first error that occurs -open (FileLikeList fs) _ _ = withErrorDialog $ - forM_ fs $ \f -> void $ openFile . path $ f -open _ _ _ = withErrorDialog - . throwIO $ InvalidOperation - "Operation not supported on multiple files" - - --- |Go up one directory and visualize it in the treeView. -upDir :: MyGUI -> MyView -> IO () -upDir mygui myview = withErrorDialog $ do - cdir <- getCurrentDir myview - nv <- goUp cdir - goDir True mygui myview nv + +renameF :: [Item] -> MyGUI -> MyView -> IO () +renameF [item] _ _ = withErrorDialog $ do + iname <- P.fromRel <$> (P.basename $ path item) + mfn <- textInputDialog "Enter new file name" (iname :: ByteString) + let pmfn = P.parseFn =<< fromString <$> mfn + for_ pmfn $ \fn -> do + let cmsg = "Really rename \"" ++ getFPasStr item + ++ "\"" ++ " to \"" + ++ toString (P.fromAbs $ (P.dirname . path $ item) + P.</> fn) ++ "\"?" + withConfirmationDialog cmsg $ + HPath.IO.renameFile (path item) + ((P.dirname $ path item) P.</> fn) +renameF _ _ _ = withErrorDialog + . throwIO $ InvalidOperation + "Operation not supported on multiple files" + + + + +---- DIRECTORY TRAVERSAL AND FILE OPENING CALLBACKS ---- + - --- |Go "back" in the history. -goHistoryPrev :: MyGUI -> MyView -> IO () -goHistoryPrev mygui myview = do - hs <- readTVarIO (history myview) - case hs of - ([], _) -> return () - (x:xs, _) -> do - cdir <- getCurrentDir myview - nv <- readFile getFileInfo $ x - modifyTVarIO (history myview) - (\(_, n) -> (xs, path cdir `addHistory` n)) - goDir False mygui myview nv - - --- |Go "forth" in the history. -goHistoryNext :: MyGUI -> MyView -> IO () -goHistoryNext mygui myview = do - hs <- readTVarIO (history myview) - case hs of - (_, []) -> return () - (_, x:xs) -> do - cdir <- getCurrentDir myview - nv <- readFile getFileInfo $ x - modifyTVarIO (history myview) - (\(p, _) -> (path cdir `addHistory` p, xs)) - goDir False mygui myview nv +-- |Go to the url given at the 'urlBar' and visualize it in the given +-- treeView. +-- +-- If the url is invalid, does nothing. +urlGoTo :: MyGUI -> MyView -> IO () +urlGoTo mygui myview = withErrorDialog $ do + fp <- entryGetText (urlBar myview) + forM_ (P.parseAbs fp :: Maybe (Path Abs)) $ \fp' -> + whenM (canOpenDirectory fp') + (goDir True mygui myview =<< (readFile getFileInfo $ fp')) + + +goHome :: MyGUI -> MyView -> IO () +goHome mygui myview = withErrorDialog $ do + mhomedir <- getEnv "HOME" + forM_ (P.parseAbs =<< mhomedir :: Maybe (Path Abs)) $ \fp' -> + whenM (canOpenDirectory fp') + (goDir True mygui myview =<< (readFile getFileInfo $ fp')) + + +-- |Execute a given file. +execute :: [Item] -> MyGUI -> MyView -> IO () +execute [item] _ _ = withErrorDialog $ + void $ executeFile (path item) [] +execute _ _ _ = withErrorDialog + . throwIO $ InvalidOperation + "Operation not supported on multiple files" + +-- |Supposed to be used with 'withRows'. Opens a file or directory. +open :: [Item] -> MyGUI -> MyView -> IO () +open [item] mygui myview = withErrorDialog $ + case item of + DirOrSym r -> do + nv <- readFile getFileInfo $ path r + goDir True mygui myview nv + r -> + void $ openFile . path $ r +-- this throws on the first error that occurs +open (FileLikeList fs) _ _ = withErrorDialog $ + forM_ fs $ \f -> void $ openFile . path $ f +open _ _ _ = withErrorDialog + . throwIO $ InvalidOperation + "Operation not supported on multiple files" + + +-- |Go up one directory and visualize it in the treeView. +upDir :: MyGUI -> MyView -> IO () +upDir mygui myview = withErrorDialog $ do + cdir <- getCurrentDir myview + nv <- goUp cdir + goDir True mygui myview nv + + +-- |Go "back" in the history. +goHistoryPrev :: MyGUI -> MyView -> IO () +goHistoryPrev mygui myview = do + hs <- readTVarIO (history myview) + case hs of + ([], _) -> return () + (x:xs, _) -> do + cdir <- getCurrentDir myview + nv <- readFile getFileInfo $ x + modifyTVarIO (history myview) + (\(_, n) -> (xs, path cdir `addHistory` n)) + goDir False mygui myview nv + + +-- |Go "forth" in the history. +goHistoryNext :: MyGUI -> MyView -> IO () +goHistoryNext mygui myview = do + hs <- readTVarIO (history myview) + case hs of + (_, []) -> return () + (_, x:xs) -> do + cdir <- getCurrentDir myview + nv <- readFile getFileInfo $ x + modifyTVarIO (history myview) + (\(p, _) -> (path cdir `addHistory` p, xs)) + goDir False mygui myview nv + diff --git a/src/HSFM-GUI-Gtk-Data.html b/src/HSFM-GUI-Gtk-Data.html index 4f11e33..7b80b73 100644 --- a/src/HSFM-GUI-Gtk-Data.html +++ b/src/HSFM-GUI-Gtk-Data.html @@ -116,46 +116,48 @@ , rcFileExecute :: !ImageMenuItem , rcFileNewRegFile :: !ImageMenuItem , rcFileNewDir :: !ImageMenuItem - , rcFileCut :: !ImageMenuItem - , rcFileCopy :: !ImageMenuItem - , rcFileRename :: !ImageMenuItem - , rcFilePaste :: !ImageMenuItem - , rcFileDelete :: !ImageMenuItem - , rcFileProperty :: !ImageMenuItem - , rcFileIconView :: !ImageMenuItem - , rcFileTreeView :: !ImageMenuItem -} - -data FilePropertyGrid = MkFilePropertyGrid { - fpropGrid :: !Grid - , fpropFnEntry :: !Entry - , fpropLocEntry :: !Entry - , fpropTsEntry :: !Entry - , fpropModEntry :: !Entry - , fpropAcEntry :: !Entry - , fpropFTEntry :: !Entry - , fpropPermEntry :: !Entry - , fpropLDEntry :: !Entry -} - - --- |FM-wide settings. -data FMSettings = MkFMSettings { - showHidden :: !Bool - , isLazy :: !Bool - , iconSize :: !Int -} - -data FMView = FMTreeView !TreeView - | FMIconView !IconView - -type Item = File FileInfo + , rcFileNewTab :: !ImageMenuItem + , rcFileNewTabHere :: !ImageMenuItem + , rcFileCut :: !ImageMenuItem + , rcFileCopy :: !ImageMenuItem + , rcFileRename :: !ImageMenuItem + , rcFilePaste :: !ImageMenuItem + , rcFileDelete :: !ImageMenuItem + , rcFileProperty :: !ImageMenuItem + , rcFileIconView :: !ImageMenuItem + , rcFileTreeView :: !ImageMenuItem +} + +data FilePropertyGrid = MkFilePropertyGrid { + fpropGrid :: !Grid + , fpropFnEntry :: !Entry + , fpropLocEntry :: !Entry + , fpropTsEntry :: !Entry + , fpropModEntry :: !Entry + , fpropAcEntry :: !Entry + , fpropFTEntry :: !Entry + , fpropPermEntry :: !Entry + , fpropLDEntry :: !Entry +} + + +-- |FM-wide settings. +data FMSettings = MkFMSettings { + showHidden :: !Bool + , isLazy :: !Bool + , iconSize :: !Int +} + +data FMView = FMTreeView !TreeView + | FMIconView !IconView - +type Item = File FileInfo -fmViewToContainer :: FMView -> Container -fmViewToContainer (FMTreeView x) = castToContainer . toGObject $ x -fmViewToContainer (FMIconView x) = castToContainer . toGObject $ x - + + +fmViewToContainer :: FMView -> Container +fmViewToContainer (FMTreeView x) = castToContainer . toGObject $ x +fmViewToContainer (FMIconView x) = castToContainer . toGObject $ x + diff --git a/src/HSFM-GUI-Gtk-MyView.html b/src/HSFM-GUI-Gtk-MyView.html index 1d17dbe..cf65554 100644 --- a/src/HSFM-GUI-Gtk-MyView.html +++ b/src/HSFM-GUI-Gtk-MyView.html @@ -41,393 +41,366 @@ newTVarIO , readTVarIO ) -import Control.Monad +import Data.Foldable ( - forM_ - , unless - ) -import Data.Foldable - ( - for_ + for_ + ) +import Data.Maybe + ( + catMaybes + , fromJust ) -import Data.Maybe - ( - catMaybes - , fromJust - ) -import Data.String - ( - fromString - ) -import Graphics.UI.Gtk -import {-# SOURCE #-} HSFM.GUI.Gtk.Callbacks (setViewCallbacks) -import qualified HPath as P -import HSFM.FileSystem.FileType -import HSFM.GUI.Glib.GlibString() -import HSFM.GUI.Gtk.Data -import HSFM.GUI.Gtk.Icons -import HSFM.GUI.Gtk.Utils -import HSFM.Utils.IO -import Paths_hsfm - ( - getDataFileName - ) -import Prelude hiding(readFile) -import System.INotify - ( - addWatch - , initINotify - , killINotify - , EventVariety(..) - ) -import System.IO.Error - ( - catchIOError - , ioError - , isUserError - ) -import System.Posix.FilePath - ( - hiddenFile - ) +import Graphics.UI.Gtk +import {-# SOURCE #-} HSFM.GUI.Gtk.Callbacks (setViewCallbacks) +import qualified HPath as P +import HSFM.FileSystem.FileType +import HSFM.GUI.Glib.GlibString() +import HSFM.GUI.Gtk.Data +import HSFM.GUI.Gtk.Icons +import HSFM.GUI.Gtk.Utils +import HSFM.Utils.IO +import Paths_hsfm + ( + getDataFileName + ) +import Prelude hiding(readFile) +import System.INotify + ( + addWatch + , initINotify + , killINotify + , EventVariety(..) + ) +import System.IO.Error + ( + ioError + ) +import System.Posix.FilePath + ( + hiddenFile + ) + + + +-- |Constructs the initial MyView object with a few dummy models. +-- It also initializes the callbacks. +createMyView :: MyGUI + -> IO FMView + -> IO MyView +createMyView mygui iofmv = do + inotify <- newEmptyMVar + history <- newTVarIO ([],[]) - - --- |Creates a new tab with its own view and refreshes the view. -newTab :: MyGUI -> IO FMView -> Item -> IO MyView -newTab mygui iofmv item = do - myview <- createMyView mygui iofmv - i <- notebookAppendPage (notebook mygui) (viewBox myview) - (maybe (P.fromAbs $ path item) P.fromRel $ P.basename $ path item) - mpage <- notebookGetNthPage (notebook mygui) i - forM_ mpage $ \page -> notebookSetTabReorderable (notebook mygui) - page - True - catchIOError (refreshView mygui myview item) $ \e -> do - forM_ mpage $ \page -> do - file <- readFile getFileInfo . fromJust . P.parseAbs . fromString $ "/" - refreshView mygui myview file - notebookSetTabLabelText (notebook mygui) page "/" - unless (isUserError e) (ioError e) - - return myview - - --- |Constructs the initial MyView object with a few dummy models. --- It also initializes the callbacks. -createMyView :: MyGUI - -> IO FMView - -> IO MyView -createMyView mygui iofmv = do - inotify <- newEmptyMVar - history <- newTVarIO ([],[]) - - builder <- builderNew - builderAddFromFile builder =<< getDataFileName "data/Gtk/builder.xml" - - -- create dummy models, so we don't have to use MVar - rawModel <- newTVarIO =<< listStoreNew [] - filteredModel <- newTVarIO =<< (\x -> treeModelFilterNew x []) - =<< readTVarIO rawModel - sortedModel <- newTVarIO =<< treeModelSortNewWithModel - =<< readTVarIO filteredModel - cwd <- newEmptyMVar - view' <- iofmv - view <- newTVarIO view' - - urlBar <- builderGetObject builder castToEntry - "urlBar" - rcMenu <- builderGetObject builder castToMenu - "rcMenu" - rcFileOpen <- builderGetObject builder castToImageMenuItem - "rcFileOpen" - rcFileExecute <- builderGetObject builder castToImageMenuItem - "rcFileExecute" - rcFileNewRegFile <- builderGetObject builder castToImageMenuItem - "rcFileNewRegFile" - rcFileNewDir <- builderGetObject builder castToImageMenuItem - "rcFileNewDir" - rcFileCut <- builderGetObject builder castToImageMenuItem - "rcFileCut" - rcFileCopy <- builderGetObject builder castToImageMenuItem - "rcFileCopy" - rcFileRename <- builderGetObject builder castToImageMenuItem - "rcFileRename" - rcFilePaste <- builderGetObject builder castToImageMenuItem - "rcFilePaste" - rcFileDelete <- builderGetObject builder castToImageMenuItem - "rcFileDelete" - rcFileProperty <- builderGetObject builder castToImageMenuItem - "rcFileProperty" - rcFileIconView <- builderGetObject builder castToImageMenuItem - "rcFileIconView" - rcFileTreeView <- builderGetObject builder castToImageMenuItem - "rcFileTreeView" - upViewB <- builderGetObject builder castToButton - "upViewB" - homeViewB <- builderGetObject builder castToButton - "homeViewB" - refreshViewB <- builderGetObject builder castToButton - "refreshViewB" - scroll <- builderGetObject builder castToScrolledWindow - "mainScroll" - viewBox <- builderGetObject builder castToBox - "viewBox" - - let rcmenu = MkRightClickMenu {..} - let myview = MkMyView {..} + builder <- builderNew + builderAddFromFile builder =<< getDataFileName "data/Gtk/builder.xml" + + -- create dummy models, so we don't have to use MVar + rawModel <- newTVarIO =<< listStoreNew [] + filteredModel <- newTVarIO =<< (\x -> treeModelFilterNew x []) + =<< readTVarIO rawModel + sortedModel <- newTVarIO =<< treeModelSortNewWithModel + =<< readTVarIO filteredModel + cwd <- newEmptyMVar + view' <- iofmv + view <- newTVarIO view' + + urlBar <- builderGetObject builder castToEntry + "urlBar" + rcMenu <- builderGetObject builder castToMenu + "rcMenu" + rcFileOpen <- builderGetObject builder castToImageMenuItem + "rcFileOpen" + rcFileExecute <- builderGetObject builder castToImageMenuItem + "rcFileExecute" + rcFileNewRegFile <- builderGetObject builder castToImageMenuItem + "rcFileNewRegFile" + rcFileNewDir <- builderGetObject builder castToImageMenuItem + "rcFileNewDir" + rcFileNewTab <- builderGetObject builder castToImageMenuItem + "rcFileNewTab" + rcFileNewTabHere <- builderGetObject builder castToImageMenuItem + "rcFileNewTabHere" + rcFileCut <- builderGetObject builder castToImageMenuItem + "rcFileCut" + rcFileCopy <- builderGetObject builder castToImageMenuItem + "rcFileCopy" + rcFileRename <- builderGetObject builder castToImageMenuItem + "rcFileRename" + rcFilePaste <- builderGetObject builder castToImageMenuItem + "rcFilePaste" + rcFileDelete <- builderGetObject builder castToImageMenuItem + "rcFileDelete" + rcFileProperty <- builderGetObject builder castToImageMenuItem + "rcFileProperty" + rcFileIconView <- builderGetObject builder castToImageMenuItem + "rcFileIconView" + rcFileTreeView <- builderGetObject builder castToImageMenuItem + "rcFileTreeView" + upViewB <- builderGetObject builder castToButton + "upViewB" + homeViewB <- builderGetObject builder castToButton + "homeViewB" + refreshViewB <- builderGetObject builder castToButton + "refreshViewB" + scroll <- builderGetObject builder castToScrolledWindow + "mainScroll" + viewBox <- builderGetObject builder castToBox + "viewBox" + + let rcmenu = MkRightClickMenu {..} + let myview = MkMyView {..} + + -- set the bindings + setViewCallbacks mygui myview + + -- add the treeview to the scroll container + let oview = fmViewToContainer view' + containerAdd scroll oview + + widgetShowAll viewBox + + return myview + + +-- |Switch the existing view in `MyView` with the one that the +-- io action returns. +switchView :: MyGUI -> MyView -> IO FMView -> IO () +switchView mygui myview iofmv = do + cwd <- getCurrentDir myview + + oldpage <- destroyView mygui myview + + -- create new view and tab page where the previous one was + nview <- createMyView mygui iofmv + newpage <- notebookInsertPage (notebook mygui) (viewBox nview) + (maybe (P.fromAbs $ path cwd) P.fromRel + $ P.basename . path $ cwd) oldpage + notebookSetCurrentPage (notebook mygui) newpage - -- set the bindings - setViewCallbacks mygui myview + refreshView mygui nview cwd + - -- add the treeview to the scroll container - let oview = fmViewToContainer view' - containerAdd scroll oview - - widgetShowAll viewBox - - return myview - - --- |Switch the existing view in `MyView` with the one that the --- io action returns. -switchView :: MyGUI -> MyView -> IO FMView -> IO () -switchView mygui myview iofmv = do - cwd <- getCurrentDir myview +-- |Destroys the given view by disconnecting the watcher +-- and destroying the active FMView container. +-- +-- Everything that needs to be done in order to forget about a +-- view needs to be done here. +-- +-- Returns the page in the tab list this view corresponds to. +destroyView :: MyGUI -> MyView -> IO Int +destroyView mygui myview = do + -- disconnect watcher + mi <- tryTakeMVar (inotify myview) + for_ mi $ \i -> killINotify i + + page <- fromJust <$> notebookPageNum (notebook mygui) (viewBox myview) - oldpage <- destroyView mygui myview - - -- create new view and tab page where the previous one was - nview <- createMyView mygui iofmv - newpage <- notebookInsertPage (notebook mygui) (viewBox nview) - (maybe (P.fromAbs $ path cwd) P.fromRel - $ P.basename . path $ cwd) oldpage - notebookSetCurrentPage (notebook mygui) newpage - - refreshView mygui nview cwd - - --- |Destroys the current view by disconnecting the watcher --- and destroying the active FMView container. --- --- Everything that needs to be done in order to forget about a --- view needs to be done here. --- --- Returns the page in the tab list this view corresponds to. -destroyView :: MyGUI -> MyView -> IO Int -destroyView mygui myview = do - -- disconnect watcher - mi <- tryTakeMVar (inotify myview) - for_ mi $ \i -> killINotify i - - page <- notebookGetCurrentPage (notebook mygui) - - -- destroy old view and tab page - view' <- readTVarIO $ view myview - widgetDestroy (fmViewToContainer view') - notebookRemovePage (notebook mygui) page - - return page - - --- |Createss an IconView. -createIconView :: IO FMView -createIconView = do - iconv <- iconViewNew - iconViewSetSelectionMode iconv SelectionMultiple - iconViewSetColumns iconv (-1) - iconViewSetSpacing iconv 2 - iconViewSetMargin iconv 0 - {- set iconv [ iconViewItemOrientation := OrientationHorizontal ] -} - {- set iconv [ iconViewOrientation := OrientationHorizontal ] -} - - return $ FMIconView iconv - - --- |Creates a TreeView. -createTreeView :: IO FMView -createTreeView = do - -- create the final view - treeView <- treeViewNew - -- set selection mode - tvs <- treeViewGetSelection treeView - treeSelectionSetMode tvs SelectionMultiple - - -- set drag and drop - tl <- targetListNew - atom <- atomNew ("HSFM" :: String) - targetListAdd tl atom [TargetSameApp] 0 - treeViewEnableModelDragDest treeView tl [ActionCopy] - treeViewEnableModelDragSource treeView [Button1] tl [ActionCopy] - - -- create final tree model columns - renderTxt <- cellRendererTextNew - renderPix <- cellRendererPixbufNew - let ct = cellText :: (CellRendererTextClass cr) => Attr cr String - cp = cellPixbuf :: (CellRendererPixbufClass self) => Attr self Pixbuf - - -- filename column - cF <- treeViewColumnNew - treeViewColumnSetTitle cF ("Filename" :: String) - treeViewColumnSetResizable cF True - treeViewColumnSetClickable cF True - treeViewColumnSetSortColumnId cF 1 - cellLayoutPackStart cF renderPix False - cellLayoutPackStart cF renderTxt True - _ <- treeViewAppendColumn treeView cF - cellLayoutAddColumnAttribute cF renderPix cp $ makeColumnIdPixbuf 0 - cellLayoutAddColumnAttribute cF renderTxt ct $ makeColumnIdString 1 - - -- date column - cMD <- treeViewColumnNew - treeViewColumnSetTitle cMD ("Date" :: String) - treeViewColumnSetResizable cMD True - treeViewColumnSetClickable cMD True - treeViewColumnSetSortColumnId cMD 2 - cellLayoutPackStart cMD renderTxt True - _ <- treeViewAppendColumn treeView cMD - cellLayoutAddColumnAttribute cMD renderTxt ct $ makeColumnIdString 2 - - -- permissions column - cP <- treeViewColumnNew - treeViewColumnSetTitle cP ("Permission" :: String) - treeViewColumnSetResizable cP True - treeViewColumnSetClickable cP True - treeViewColumnSetSortColumnId cP 3 - cellLayoutPackStart cP renderTxt True - _ <- treeViewAppendColumn treeView cP - cellLayoutAddColumnAttribute cP renderTxt ct $ makeColumnIdString 3 + -- destroy old view and tab page + view' <- readTVarIO $ view myview + widgetDestroy (fmViewToContainer view') + notebookRemovePage (notebook mygui) page + + return page + + +-- |Createss an IconView. +createIconView :: IO FMView +createIconView = do + iconv <- iconViewNew + iconViewSetSelectionMode iconv SelectionMultiple + iconViewSetColumns iconv (-1) + iconViewSetSpacing iconv 2 + iconViewSetMargin iconv 0 + {- set iconv [ iconViewItemOrientation := OrientationHorizontal ] -} + {- set iconv [ iconViewOrientation := OrientationHorizontal ] -} + + return $ FMIconView iconv + + +-- |Creates a TreeView. +createTreeView :: IO FMView +createTreeView = do + -- create the final view + treeView <- treeViewNew + -- set selection mode + tvs <- treeViewGetSelection treeView + treeSelectionSetMode tvs SelectionMultiple + + -- set drag and drop + tl <- targetListNew + atom <- atomNew ("HSFM" :: String) + targetListAdd tl atom [TargetSameApp] 0 + treeViewEnableModelDragDest treeView tl [ActionCopy] + treeViewEnableModelDragSource treeView [Button1] tl [ActionCopy] + + -- create final tree model columns + renderTxt <- cellRendererTextNew + renderPix <- cellRendererPixbufNew + let ct = cellText :: (CellRendererTextClass cr) => Attr cr String + cp = cellPixbuf :: (CellRendererPixbufClass self) => Attr self Pixbuf + + -- filename column + cF <- treeViewColumnNew + treeViewColumnSetTitle cF ("Filename" :: String) + treeViewColumnSetResizable cF True + treeViewColumnSetClickable cF True + treeViewColumnSetSortColumnId cF 1 + cellLayoutPackStart cF renderPix False + cellLayoutPackStart cF renderTxt True + _ <- treeViewAppendColumn treeView cF + cellLayoutAddColumnAttribute cF renderPix cp $ makeColumnIdPixbuf 0 + cellLayoutAddColumnAttribute cF renderTxt ct $ makeColumnIdString 1 + + -- date column + cMD <- treeViewColumnNew + treeViewColumnSetTitle cMD ("Date" :: String) + treeViewColumnSetResizable cMD True + treeViewColumnSetClickable cMD True + treeViewColumnSetSortColumnId cMD 2 + cellLayoutPackStart cMD renderTxt True + _ <- treeViewAppendColumn treeView cMD + cellLayoutAddColumnAttribute cMD renderTxt ct $ makeColumnIdString 2 + + -- permissions column + cP <- treeViewColumnNew + treeViewColumnSetTitle cP ("Permission" :: String) + treeViewColumnSetResizable cP True + treeViewColumnSetClickable cP True + treeViewColumnSetSortColumnId cP 3 + cellLayoutPackStart cP renderTxt True + _ <- treeViewAppendColumn treeView cP + cellLayoutAddColumnAttribute cP renderTxt ct $ makeColumnIdString 3 + + return $ FMTreeView treeView + + +-- |Refreshes the View based on the given directory. +-- +-- Throws: +-- +-- - `userError` on inappropriate type +refreshView :: MyGUI + -> MyView + -> Item + -> IO () +refreshView mygui myview SymLink { sdest = Just d@Dir{} } = + refreshView mygui myview d +refreshView mygui myview item@Dir{} = do + newRawModel <- fileListStore item myview + writeTVarIO (rawModel myview) newRawModel + + view' <- readTVarIO $ view myview + + _ <- tryTakeMVar (cwd myview) + putMVar (cwd myview) item + + -- get selected items + tps <- getSelectedTreePaths mygui myview + trs <- catMaybes <$> mapM (treeRowReferenceNew newRawModel) tps - return $ FMTreeView treeView + constructView mygui myview - --- |Refreshes the View based on the given directory. --- --- Throws: --- --- - `userError` on inappropriate type -refreshView :: MyGUI - -> MyView - -> Item - -> IO () -refreshView mygui myview SymLink { sdest = Just d@Dir{} } = - refreshView mygui myview d -refreshView mygui myview item@Dir{} = do - newRawModel <- fileListStore item myview - writeTVarIO (rawModel myview) newRawModel - - view' <- readTVarIO $ view myview - - _ <- tryTakeMVar (cwd myview) - putMVar (cwd myview) item - - -- get selected items - tps <- getSelectedTreePaths mygui myview - trs <- catMaybes <$> mapM (treeRowReferenceNew newRawModel) tps - - constructView mygui myview - - -- reselect selected items - -- TODO: not implemented for icon view yet - case view' of - FMTreeView treeView -> do - tvs <- treeViewGetSelection treeView - ntps <- mapM treeRowReferenceGetPath trs - mapM_ (treeSelectionSelectPath tvs) ntps - _ -> return () -refreshView _ _ _ = ioError $ userError "Inappropriate type!" + -- reselect selected items + -- TODO: not implemented for icon view yet + case view' of + FMTreeView treeView -> do + tvs <- treeViewGetSelection treeView + ntps <- mapM treeRowReferenceGetPath trs + mapM_ (treeSelectionSelectPath tvs) ntps + _ -> return () +refreshView _ _ _ = ioError $ userError "Inappropriate type!" + + +-- |Constructs the visible View with the current underlying mutable models, +-- which are retrieved from 'MyGUI'. +-- +-- This sort of merges the components mygui and myview and fires up +-- the actual models. +constructView :: MyGUI + -> MyView + -> IO () +constructView mygui myview = do + settings' <- readTVarIO $ settings mygui + + -- pix stuff + iT <- iconThemeGetDefault + folderPix <- getIcon IFolder iT (iconSize settings') + folderSymPix <- getSymlinkIcon IFolder iT (iconSize settings') + filePix <- getIcon IFile iT (iconSize settings') + fileSymPix <- getSymlinkIcon IFile iT (iconSize settings') + errorPix <- getIcon IError iT (iconSize settings') + let dirtreePix Dir{} = folderPix + dirtreePix FileLike{} = filePix + dirtreePix DirSym{} = folderSymPix + dirtreePix FileLikeSym{} = fileSymPix + dirtreePix BrokenSymlink{} = errorPix + dirtreePix _ = errorPix + - --- |Constructs the visible View with the current underlying mutable models, --- which are retrieved from 'MyGUI'. --- --- This sort of merges the components mygui and myview and fires up --- the actual models. -constructView :: MyGUI - -> MyView - -> IO () -constructView mygui myview = do - settings' <- readTVarIO $ settings mygui - - -- pix stuff - iT <- iconThemeGetDefault - folderPix <- getIcon IFolder iT (iconSize settings') - folderSymPix <- getSymlinkIcon IFolder iT (iconSize settings') - filePix <- getIcon IFile iT (iconSize settings') - fileSymPix <- getSymlinkIcon IFile iT (iconSize settings') - errorPix <- getIcon IError iT (iconSize settings') - let dirtreePix Dir{} = folderPix - dirtreePix FileLike{} = filePix - dirtreePix DirSym{} = folderSymPix - dirtreePix FileLikeSym{} = fileSymPix - dirtreePix BrokenSymlink{} = errorPix - dirtreePix _ = errorPix - - - view' <- readTVarIO $ view myview - - cdir <- getCurrentDir myview - let cdirp = path cdir - - -- update urlBar - entrySetText (urlBar myview) (P.fromAbs cdirp) - - rawModel' <- readTVarIO $ rawModel myview - - -- filtering - filteredModel' <- treeModelFilterNew rawModel' [] - writeTVarIO (filteredModel myview) filteredModel' - treeModelFilterSetVisibleFunc filteredModel' $ \iter -> do - hidden <- showHidden <$> readTVarIO (settings mygui) - item <- treeModelGetRow rawModel' iter >>= (P.basename . path) - if hidden - then return True - else return . not . hiddenFile . P.fromRel $ item - - -- sorting - sortedModel' <- treeModelSortNewWithModel filteredModel' - writeTVarIO (sortedModel myview) sortedModel' - treeSortableSetSortFunc sortedModel' 1 $ \iter1 iter2 -> do - cIter1 <- treeModelFilterConvertIterToChildIter filteredModel' iter1 - cIter2 <- treeModelFilterConvertIterToChildIter filteredModel' iter2 - item1 <- treeModelGetRow rawModel' cIter1 - item2 <- treeModelGetRow rawModel' cIter2 - return $ compare item1 item2 - treeSortableSetSortColumnId sortedModel' 1 SortAscending - - -- set values - treeModelSetColumn rawModel' (makeColumnIdPixbuf 0) - dirtreePix - treeModelSetColumn rawModel' (makeColumnIdString 1) - (P.toFilePath . fromJust . P.basename . path) - treeModelSetColumn rawModel' (makeColumnIdString 2) - packModTime - treeModelSetColumn rawModel' (makeColumnIdString 3) - packPermissions - - -- update model of view - case view' of - FMTreeView treeView -> do - treeViewSetModel treeView sortedModel' - treeViewSetRubberBanding treeView True - FMIconView iconView -> do - iconViewSetModel iconView (Just sortedModel') - iconViewSetPixbufColumn iconView - (makeColumnIdPixbuf 0 :: ColumnId item Pixbuf) - iconViewSetTextColumn iconView - (makeColumnIdString 1 :: ColumnId item String) - - -- add watcher - mi <- tryTakeMVar (inotify myview) - for_ mi $ \i -> killINotify i - newi <- initINotify - _ <- addWatch - newi - [Move, MoveIn, MoveOut, MoveSelf, Create, Delete, DeleteSelf] - (P.fromAbs cdirp) - (\_ -> postGUIAsync $ refreshView mygui myview cdir) - putMVar (inotify myview) newi - - return () + view' <- readTVarIO $ view myview + + cdir <- getCurrentDir myview + let cdirp = path cdir + + -- update urlBar + entrySetText (urlBar myview) (P.fromAbs cdirp) + + rawModel' <- readTVarIO $ rawModel myview + + -- filtering + filteredModel' <- treeModelFilterNew rawModel' [] + writeTVarIO (filteredModel myview) filteredModel' + treeModelFilterSetVisibleFunc filteredModel' $ \iter -> do + hidden <- showHidden <$> readTVarIO (settings mygui) + item <- treeModelGetRow rawModel' iter >>= (P.basename . path) + if hidden + then return True + else return . not . hiddenFile . P.fromRel $ item + + -- sorting + sortedModel' <- treeModelSortNewWithModel filteredModel' + writeTVarIO (sortedModel myview) sortedModel' + treeSortableSetSortFunc sortedModel' 1 $ \iter1 iter2 -> do + cIter1 <- treeModelFilterConvertIterToChildIter filteredModel' iter1 + cIter2 <- treeModelFilterConvertIterToChildIter filteredModel' iter2 + item1 <- treeModelGetRow rawModel' cIter1 + item2 <- treeModelGetRow rawModel' cIter2 + return $ compare item1 item2 + treeSortableSetSortColumnId sortedModel' 1 SortAscending + + -- set values + treeModelSetColumn rawModel' (makeColumnIdPixbuf 0) + dirtreePix + treeModelSetColumn rawModel' (makeColumnIdString 1) + (P.toFilePath . fromJust . P.basename . path) + treeModelSetColumn rawModel' (makeColumnIdString 2) + packModTime + treeModelSetColumn rawModel' (makeColumnIdString 3) + packPermissions + + -- update model of view + case view' of + FMTreeView treeView -> do + treeViewSetModel treeView sortedModel' + treeViewSetRubberBanding treeView True + FMIconView iconView -> do + iconViewSetModel iconView (Just sortedModel') + iconViewSetPixbufColumn iconView + (makeColumnIdPixbuf 0 :: ColumnId item Pixbuf) + iconViewSetTextColumn iconView + (makeColumnIdString 1 :: ColumnId item String) + + -- add watcher + mi <- tryTakeMVar (inotify myview) + for_ mi $ \i -> killINotify i + newi <- initINotify + _ <- addWatch + newi + [Move, MoveIn, MoveOut, MoveSelf, Create, Delete, DeleteSelf] + (P.fromAbs cdirp) + (\_ -> postGUIAsync $ refreshView mygui myview cdir) + putMVar (inotify myview) newi + + return ()