GFX :: Monk

The online portfolio of Tim Cuthbertson (aka gfxmonk)

<Home>

My First Widget

Posted Monday, February 06, 2006
iRank Widget Screenshot

It was more out of necessity than anything else, but since I had to port iRank to OSX, I figured I might as well give these "widgets" a try, since the dashboard seems like a pretty suitable place to put iRank.

I've finally got it working, thankfully. It's got some weird bugs (and you have to edit the source to customise it), so call it a beta ;)
Here are some observations on the process.

  • Talking to iTunes is done by calling widget.system, and passing the name of an applescript (and some variables) to /usr/bin/osascript, which then executes the applescript. This seems very inefficient to me, but it's done infrequently so it's not a big deal.
  • iTunes won't send events. I don't think you can catch events with a widget, but even if you write a fully-fledged program you can't get notified of iTunes events - you just have to poll it every n seconds. Apparently there is a framework in place for inter-application messages, but iTunes doesn't expose any events...
  • Debugging is not much fun. You can use safari (after using this trick to enable developer features like a JavaScript console), but then you can't use the widget object (to do stuff a regular webpage can't). And you can keep switching to dashboard and reloading it, but it's very difficult to debug code when you have no error logging or alert().
  • The use of JSON: I tried constructing objects as JSON instead of using tedious calls to document.createElement() and element.setAttribute(), which works nicely for simple data structures. But if you construct a HTML fragment with this method and then try and insert it into the DOM, you get a wonderfully usless error message: "DOM Exception 8". I still have no idea what this error means (googling revealed nothing), so I just ended up doing things the tedious way.
  • Using Preferences looks like hard work :/
    I ought to set this up at some stage, but for the moment I don't think anybody else uses it, and you only really need to set the preferences once...

If you're happy to change settings by editing an array in a javascript file, go ahead and give it a try (settings are on the first line of iRank.js).


Check it out, I'm a Mac Geek!

Posted Friday, February 03, 2006

...so I got a big shiney new iMac the other day. It's a friggin awesome machine, and I'm loving it. Thought I may as well post some thoughts:

  • Switching: Easy. I've found mac alternatives (and generally they're an improvement) to pretty much all the windows-only software I need.
  • Mail: I've imported all my gmail to Mail.app - The gmail interface is probably a bit better, but Mail is much speedier (and the interface is better than most - at least it has conversation threading!).
  • Address Book: Bloody brilliant. Once you've got it set up, it works together with iCal and Mail to display (for example) people's photos on the top of their emails - very cool.
  • Spotlight: Also brilliant. Probably the best feature in OSX.
  • iTunes: Much the same as on windows, but less crap. It still won't let me keep some of my old meta-data, so I'm in the prcess of writing a script to import my library and set the appropriate meta-data.
  • GarageBand: Really good - I haven explored this much, but I want to...
  • Browsers: Safari is nice and quick, but I rely on Firefox's smart bookmarks and extensions. I'm using Camino at the moment, but might switch to firefox when they get around to releasing the intel version.
  • IM: Adium is better than any windows client I've seen. Oh, except for the default sound theme which is inexplicably hideous (it sounds much like an incredibly sick duck). Luckily that's easy to change.
  • Dashboard: Pretty useful, but quite the memory hog.
  • Tools: Having a unix-based system is incredibly handy. I can finally download and compile stuff just using "make". This is no different from linux, but a huge improvement over windows.
  • iWeb: Absolutely useless if you don't have a .Mac account (screw that). Dissapointing, but it's not like I'd use it anyways...
  • iPhoto: Unforgivably poor. I would greatly appreciate any tips for better programs. I used Picasa on the PC, and it was great. iPhoto sucks in these ways:
    • Ignores folder structure entirely - who doesn't organise their photos in folders?
    • Screws up the date data - apparently I took a lot of photos on christmas day, 2026. Even when I set the dates back to a more sane date, it ignores the date I set and keeps listing them as 2026.
    • Can't monitor folders for new photos - you have to add them all manually.
    • Doesn't recognise picasa comments - forgivable, although spotlight seems to manage it. I may be able to batch-add comments via some manner of script though.
    • Doesn't add meta-data to image files - meta-data seems to be stored in a link to the photo, so when you search in spotlight it comes up as a document instead of an image - which means you get no thumbnails.

So overall I'm very happy with my Mac. I would love to replace iPhoto though, if anyone has any suggestions there...