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
Haskell File Manager has just been released
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 installThis project relies upon FileManip for searching, and as such you must have this installed.
cabal install FileManipHere is a screen shot of it running in Ubuntu:
M
Hey all,
A different subject to normal. The anti-haskell: Javaish stuff!!
Well, I got a Mac recently and was trying to get a Tomcat server with MySQL integration going, and had a built of difficulty on the way!!
Note: For this tutorial I use the Bash terminal. To set your Mac to use Bash by default, as it uses Zsh by default, open a terminal, and then click:
Terminal->Preferences->Startup->Shell opens with: custom command
and make sure that the input box reads:
/bin/bash
I found this tutorial: Ben Slade’s tutorial. This is a good starting point but I think it’s a bit out-dated. So my tutorial here is a modernised version of that.
Firstly, you have to have the Java JDK installed, to find out type this into a terminal:
javac -versionIf you get an error message, then you don’t have it installed, so head over to the Apple Developer Center and get the latest XCode. That should install it for you.
Next, go and get MySQL for OSX here and get the OSX version. This will download a disk image that will be mounted for you. In that double-click the .dmg file that starts with “mysql-……”. This will install MySQL for you. Next double-click the MySQLStartupItem.pkg, and confirm the prompts. This will enable an auto-start of MySQL when you boot into OSX.
Now a bit of setup for MySQL:
Restart your terminal (so that it’s definately a bash terminal), and type the following:
nano ~/.bash_profile
If that file doesn’t exist, thats fine. Just create it.
In the editor that opens up, type the following:
PATH=$PATH:/usr/local/mysql/bin
This loads the MySQL command line utilities when you open a bash terminal.
Now would be a good time to reboot your Mac, just to make sure everything loads alright. After rebooting, you need to set user passwords for the root account. Open up a terminal and type the following:
mysql -u rootTo remove anonymous logins now type the following:
DELETE FROM mysql.user WHERE User = ' '; FLUSH PRIVILEGES;
Now, find your computers names:
SELECT DISTINCT(Host) AS Host FROM mysql.user WHERE Host != "localhost";
You should see something like:
————————-
| Host |
————————-
| 127.0.0.1 |
| username’s-macbook.local |
————————-
Now type:
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('new_pass'); SET PASSWORD FOR 'root'@'username's-macbook.LOCAL' = PASSWORD('new_pass');
Where new_pass is your new password.
Now make a test login, exactly like below…
CREATE DATABASE javatest; GRANT ALL ON javatest.* TO 'some_login'@'localhost' IDENTIFIED BY 'some_password'; FLUSH PRIVILEGES;
Where some_login is the username you will be using earlier and some_password is the password you will use to log some_login in.
flush privileges;
Next, get Jakarta Tomcat and download the latest stable release, for OSX. Download it to ~/. Next you need to copy the tar to your local directory. Do the following:
sudo mv apache-tomcat-<i>version-number</i>.tar.gz /usr/local cd /usr/local sudo tar -xf apache-tomcat-<i>version-number</i>.tar.gz sudo rm apache-tomcat-<i>version-number</i>.tar.gz
Now create a symlink for Tomcat for easy access:
sudo ln -s apache-tomcat-<i>version-number</i> tomcat
Now take ownership of the files:
sudo chown -R $LOGNAME: apache-tomcat-<i>version-number</i>
Now set up the $CATALINA_HOME variable to point to the tomcat installation:
And add the following line: Now, create two scripts - one for starting the tomcat server and one for stopping it: And add the following to that: Then: And add the following to that: Make the two scripts you just created executable: And add the ~/bin directory to your $PATH variable: And add this to it: Now, you can use tomcat_start to start the server: Now load up Safari and go to http://localhost:8080 and you should see the tomcat default page. Next, run your tomcat_stop script, and type the following into terminal: Add the following into the file: Now to sort out the connectivity between tomcat and SQL download the latest ConnectorJ. When that's downloaded, copy it into the java extensions directory: nano ~/bin/tomcat_start.sh
#!/bin/sh
$CATALINA_HOME/bin/startup.sh
nano ~/bin/tomcat_stop.sh
#!/bin/sh
$CATALINA_HOME/bin/shutdown.sh
$ chmod u+x ~/bin/*_tomcatnano ~/.bash_profile
PATH=$PATH:/Users/$LOGNAME/bin
$ tomcat_start
nano $CATALINA_HOME/conf/tomcat-users.xml
<user username="myusername" password="mypassword" roles="tomcat,admin,manager"/>cp connectorJFileName /Library/Java/Extension
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
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
Just a brief update:
I have gotten the tree on the left to expand to the currently viewed directory on refresh. It was tricky enough to get my head around.
Code to follow, along with the code for drag ‘n’ drop on the list store.
Now I have to:
Try to fix the search.
Try and make my retrieval methods more generic.
Tidy up a few little pieces here and there.
Add to the documentation.
Maybe implement drag ‘n’ drop into the tree on the left?!?
Do a User Manual.
My presentation next week, then I can release it ( I think ).
I’ve already got webspace over at SourceForge.
Aside: Found a nice Haskell IDE, implemented in Haskell, using Gtk2HS.
Been a few days since I posted here, I’m not doing much development at the moment, as I am working on my technical specification, and user guide.
Still to be posted: Drag and drop source, I want to try to reduce this a bit more before it’s posted!
M
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
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
