diff --git a/HSFM-GUI-Gtk-Callbacks.html b/HSFM-GUI-Gtk-Callbacks.html index 3639436..1bf38e8 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.

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 +

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 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-MyView.html b/HSFM-GUI-Gtk-MyView.html index dccda88..01bd518 100644 --- a/HSFM-GUI-Gtk-MyView.html +++ b/HSFM-GUI-Gtk-MyView.html @@ -1,7 +1,7 @@ HSFM.GUI.Gtk.MyView
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. +

Safe HaskellNone
LanguageHaskell2010

HSFM.GUI.Gtk.MyView

Documentation

newTab :: MyGUI -> IO FMView -> Item -> Int -> 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. 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 given view by disconnecting the watcher and destroying the active FMView container.

Everything that needs to be done in order to forget about a 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 60b67ad..0578a94 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.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 +

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
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 0df300c..bafb9a6 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/hsfm.haddock b/hsfm.haddock index f82516a..7c0aa43 100644 Binary files a/hsfm.haddock and b/hsfm.haddock differ diff --git a/mini_HSFM-GUI-Gtk-Callbacks.html b/mini_HSFM-GUI-Gtk-Callbacks.html index eb754f9..41cf993 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 5df1e42..f1ac52a 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.html b/src/HSFM-GUI-Gtk-Callbacks.html index 5649391..b3dd050 100644 --- a/src/HSFM-GUI-Gtk-Callbacks.html +++ b/src/HSFM-GUI-Gtk-Callbacks.html @@ -44,577 +44,533 @@ forM , forM_ , join - , 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 + , 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 ( - catchIOError - , isUserError - ) -import System.Posix.Env.ByteString - ( - getEnv - ) -import qualified System.Posix.Process.ByteString as SPP -import System.Posix.Types - ( - ProcessID - ) + ProcessID + ) + + + + + + ----------------- + --[ Callbacks ]-- + ----------------- + + - +---- MAIN CALLBACK ENTRYPOINT ---- - ----------------- - --[ Callbacks ]-- - ----------------- +-- |Set callbacks for the whole gui, on hotkeys, events and stuff. +setGUICallbacks :: MyGUI -> IO () +setGUICallbacks mygui = do - - - ----- 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 () + _ <- 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) - --- |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 + -- 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 - -- 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 + -- 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 _ <- viewBox myview `on` keyPressEvent $ tryEvent $ do [Control] <- eventModifier - "v" <- fmap glibToString eventKeyName - liftIO $ operationFinal mygui myview Nothing + "w" <- fmap glibToString eventKeyName + liftIO $ void $ closeTab mygui myview _ <- viewBox myview `on` keyPressEvent $ tryEvent $ do - [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) + "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 - 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 () + 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) + - 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 ----- 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 ---- + + +-- |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 ----- TAB OPERATIONS ---- - - --- |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 (-1) +newTabHere _ _ = return () + + + + - -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 +---- 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" - myview <- createMyView mygui iofmv - _ <- notebookAppendPageMenu (notebook mygui) (viewBox myview) - ebox ebox - - notebookSetTabReorderable (notebook mygui) (viewBox myview) True - - 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, ...) ---- - + +-- |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!" --- |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" + +-- |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 ---- + - --- |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) - +-- |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')) --- |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) + +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')) + - -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')) - - --- |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 - +-- |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-MyView.html b/src/HSFM-GUI-Gtk-MyView.html index cf65554..04cb99f 100644 --- a/src/HSFM-GUI-Gtk-MyView.html +++ b/src/HSFM-GUI-Gtk-MyView.html @@ -25,382 +25,435 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. --} - +{-# LANGUAGE RecordWildCards #-} -module HSFM.GUI.Gtk.MyView where - + +module HSFM.GUI.Gtk.MyView where -import Control.Concurrent.MVar - ( - newEmptyMVar - , putMVar - , tryTakeMVar - ) -import Control.Concurrent.STM - ( - newTVarIO - , readTVarIO - ) -import Data.Foldable - ( - for_ - ) -import Data.Maybe - ( - catMaybes - , fromJust - ) -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 ([],[]) - - 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 - - refreshView mygui nview cwd - - --- |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) - - -- 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 + +import Control.Concurrent.MVar + ( + newEmptyMVar + , putMVar + , tryTakeMVar + ) +import Control.Concurrent.STM + ( + newTVarIO + , readTVarIO + ) +import Control.Monad + ( + unless + , void + , when + ) +import Control.Monad.IO.Class + ( + liftIO + ) +import Data.Foldable + ( + for_ + ) +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 + ) + + + +-- |Creates a new tab with its own view and refreshes the view. +newTab :: MyGUI -> IO FMView -> Item -> Int -> IO MyView +newTab mygui iofmv item pos = 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 + _ <- notebookInsertPageMenu (notebook mygui) (viewBox myview) + ebox ebox pos + + notebookSetTabReorderable (notebook mygui) (viewBox myview) True + + 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 "/" :: String) + + -- close callback + _ <- ebox `on` buttonPressEvent $ do + eb <- eventButton + case eb of + MiddleButton -> liftIO $ do + n <- notebookGetNPages (notebook mygui) + when (n > 1) $ void $ destroyView mygui myview + return True + _ -> return False + + 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" + 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 + - --- |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] +-- |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 <- newTab mygui iofmv cwd oldpage + + page <- fromJust <$> notebookPageNum (notebook mygui) (viewBox nview) + notebookSetCurrentPage (notebook mygui) page + + refreshView mygui nview cwd + - -- 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 - - 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!" - - --- |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 +-- |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) + + -- 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 - -- update urlBar - entrySetText (urlBar myview) (P.fromAbs cdirp) - - rawModel' <- readTVarIO $ rawModel myview + view' <- readTVarIO $ view myview + + _ <- tryTakeMVar (cwd myview) + putMVar (cwd myview) item - -- 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) + -- 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!" + + +-- |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 + - -- 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 () diff --git a/src/Main.html b/src/Main.html index b2edacc..d35c22f 100644 --- a/src/Main.html +++ b/src/Main.html @@ -66,7 +66,7 @@ _ <- initGUI mygui <- createMyGUI - _ <- newTab mygui createTreeView file + _ <- newTab mygui createTreeView file (-1) setGUICallbacks mygui