Apr 29

Here’s what I’m thinking of doing to keep my project interesting:

  • System.Gnome.VFS.VolumeMonitor – To monitor mounts & dismounts. Mounted locations would be shown above where the directory tree is right now i.e. the directory tree “pane” would be halved in height, and mounts displayed in the freed space. Also maybe do something with System.Gnome.VFS.Drive.
  • Fix it so that it handles symlinks properly. At the moment it just ignores symlinks, due to problems during the project and and a short development timeline.
  • System.Gnome.VFS.FileInfo and System.Gnome.VFS.Util and System.Gnome.VFS.Ops to do somemore file stuff, display more information, and add a “Properties” pop-up selectable from the right-click menu.
  • System.Gnome.VFS.Xfer to complete copies and moves – I’ll have to see if I can transfer files etc.

Sin é!

M

Tagged with:
Apr 26

Haskell File Manager has just been released :D

It is hosted over at haskell.org, and can be obtained by doing the following command:

darcs get http://code.haskell.org/haskellfm

And can then be install by running the following commands:

runhaskell Setup configure
runhaskell Setup build
runhaskell Setup install

This project relies upon FileManip for searching, and as such you must have this installed.

cabal install FileManip

Here is a screen shot of it running in Ubuntu:

Screenshot

M

Tagged with:
Apr 04

We’ll I got my project demo done and out of the way, thank god!

At the moment, I still have a few bits to do with it before I release it!

For now, I’m just gonna change to using the default Haskell libraries for working with files & directories, as opposed to my own one using System.Cmd.

M

Tagged with:
Mar 22

I have search *kind of* fixed.

I’m using the FileManip from Hackage to do my Regex matching, it’s basically what I was doing already, but a LOT faster. It’s functionality for finding matching directory/file names is blazing fast compared to my own functions. I also have the within files searching fixed, but that adds a big delay to getting the results. Here’s some code!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
checkFile :: String -- ^ The expression to be searched for.
          -> FilePath -- ^ The path to the file to be checked.
          -> IO Bool -- ^ Whether or not the pattern is found.
checkFile pattern file = withFile file ReadMode ( \h -> do
      conts <- hGetContents h
      return $!( any ( ~~ pattern ) ( words conts ) ) )
 
searchDirectoryFiles :: FilePath -> GlobPattern -> IO [FilePath]
searchDirectoryFiles dir pattern = find ( always ) ( fileName ~~? pattern ) dir >>= (\d ->
    recurseSearchFiles dir pattern >>= (\c -> return ( d ++ c) ) )
 
recurseSearchFiles :: FilePath -> String -> IO [FilePath]
recurseSearchFiles dir pattern = do
    conts <- ( getDirectoryContents dir `Er.catch` (\_ -> return ([]) ) ) >>= (\c ->
             filterLinks ( map (\p -> dir ++ "/" ++ p) ( filter ( not . isPrefixOf "." ) ( filter ( not . isSuffixOf "~" ) c ) ) ) )
    dirs <- filterM doesDirectoryExist conts
    files <- filterM doesFileExist conts
    matches <- filterM ( checkFile pattern ) files
    subR <- forM dirs $ \d -> recurseSearchFiles d pattern
    return ( matches ++ ( concat subR ) )

Basically now how its done is:

  • Using the FileManip functions, get all matching file & directory names below the supplied directory.
  • Then, get the contents of a directory and filter the trash out of it. Split it into directories & files. Use checkFile to filter out the files containing a String matching the pattern. Recurse into the subdirectories, and carry out these steps on those too.
  • Concat all these results together, and return them.

M

Tagged with:
Mar 09

I got Drag And Drop working with the File Manager now. To do it I had instead of a normal ListStore declare a ListStoreDND. When declaring a drag’n'drop listStoreDND, you have to defined you’re DND functionality there and then, which is quite annoying to be honest. An `onRowDrag` function would be a lot better, and in keeping with the rest of the library and how actions are done. Also, when you are doing a drag, you have to put data into a “selection” and in the library documentation I could see functions like “selectionSetText”, and “selectionGetText”, which looked like they’d be very useful to me. Denied. You can only put numbers into a selection, and there was one line about this somewhere near the bottom of the library documents. Why have a method like selectionSetText if you can’t set the text in the selection? Makes no sense at all. Regardless, what I do to get around this is: Feed a 0 or 1 into the selection depending on what store the row is being dragged from. Then feed the selected row’s index into it. The if the first number in the selection is 0, I know its from the directory store. So I just pop off the text at that index, and then the text from the dropping position, and then do a move with those. Happy days.

Will post code later when I tidy it up.

M

Tagged with:
Mar 08

I have my search functions working again. The problem was that when Gtk was updated, and I updated my code to this I also changed how FilePath’s were passed around to the various methods. I did this to only pass around what was necessary, rather than the full paths, and I never reflected this within my search code! Pretty stupid really, but an easy mistake to make. A mistake that also had a domino effect on the methods that search uses!! So when search was fixed, I had to go through the other methods and update those too!

I edited my openFile method so that, it tries to open the supplied file using “xdg-open”. If that is successful, it returns ExitSuccess, and the function exits. However, if it returns any other type of exit, i.e. ExitFailure Int, it searches a file containg extensions & commands. It searches for the extension of the supplied file. If it’s found it asks the user for a command to run the file with, i.e. .hs files are opened in gedit. If the command that the user enters is successful, it then writes the extension command combo to the file for future use.

I finally figured out how to do a right-click menu, which is pretty good, the code is 90% identical to the file menu code. Originally, following the example I found, the action had to be added to the overall window, but I found that that didn’t work. It has to be added to the ScrolledWindow that the user will be making selections from. This has a couple of benefits: Different menu’s for different parts of the screen.

I still have to try to:

  • Implement Drag and Drop.
  • Expand tree to selected
  • Now that I have the right-click menu, try renaming within the scrolled window.

M

Tagged with:
Mar 07

Just spent the last 2 days commenting all my code. That took a lot longer than I expected, but there was a lot to cover. I commented all the code using haddock style comments, even the functions that are hidden, as I think its a good way of commenting the code, and explaining the arguments to functions.

All the documentation is available here: Documentation

Now all that’s left is

  • Fix my search function.
  • Add in custom commands for opening programs.
  • Try to implement drag and drop functionality between the panes.
  • Get the directory tree to expand to the currently selected directory.

M

Tagged with:
Mar 05

To start with, I’ve created two types for my program, a StoreRow type and a Browser type, these have enabled me to make my code a bit more readable, and also to decrease the length of my function signatures :D , as some of them spanned 2 lines in my editor. It also allows me to work more freely, as I can pass the respective types around, taking what I need from them where I need it.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
data StoreRow = StoreRow {
    name :: String,
    icon :: Pixbuf,
    size :: String,
    lastAccess :: String,
    permissions :: String }
 
data FileBrowser = FileBrowser {
    switch :: ToggleButton,
    location :: Entry,
    treeScroll :: ScrolledWindow,
    dirScroll :: ScrolledWindow,
    fileScroll :: ScrolledWindow,
    treeTree :: TreeView,
    dirTree :: TreeView,
    fileTree :: TreeView,
    treeStore :: TreeStore String,
    dirStore :: ListStore StoreRow,
    fileStore :: ListStore StoreRow }

Secondly, as stated before, I’m using xdg-open to open files, using System.Cmd. I’ve been messing around with it a bit today, and I thought before that if it couldn’t find a default application it still returned ExitSuccess to rawSystem, but, it actually doesn’t so what I plan to do now is, if it doesn’t find an application to open the passed file, pop up an error window, prompting the user to supply a command name to open it with, then write this to a file, along with the extension of the file being opened. Next time it happens, scan through the file, and if a command isn’t found to match the extension, query the user!

Problem solved…. In theory!

I’m going to start documenting the code using Haddock and I’ll upload that later.

M

Tagged with:
Mar 03

I spent the day today rewriting my SystemOperation module, to handle multiple selections. I got multiple selections working yesterday, but I felt it was done poorly, so out with the old in with the new. Due to reducing all my previous code as far as I could, I had to rewrite each function out again, i.e. renameFile, renameFolder etc etc, and then reduce down based on that.

I also added:

  • File Size information, 0 if directory
  • Last Modified Time
  • Permissions

To each element in both the directory and file tree.

This is the point where I would love to be able to actually set the size for the widgets myself, as the directory tree is taking up way too much space on screen, and is annoying the hell out of me. I spent the evening trawling the libraries for something that would let me resize it, on the off chance that they had included this functionality into the new library. No, would be the answer to that. So it’s all or nothing. I also reduced a fair bit of the rest of my code, a line or two here, a line or two there, so all in all, quite the productive day.

M

Tagged with:
Mar 01

Right, have all thee code changed to the new version of Gtk2HS… I am liking the new stuff, typed stores do save a lot of hassle when trying to get selected values back out of the store!

So the file manager, is pretty much finished now :D every addition from here is just an improvement, and I only have two things that I really want to do:

Multiple Selections:
Open multiple files, copy multiple files, delete multiple files, move multiple files.

Drag and drop:
Use the drag and drop functionality for moving multiple files/directories!!

M

Edit: To work in multiple selections means that I am going to have to restructure a lot of my code again :(

Tagged with:
preload preload preload