After my first steps yesterday to 'improve' Nicholas's neat IceCoffee application enhancer module, I was a bit frustrated because I knew I was really close to making it do what I wanted it to do but it still didn't.
The aim was to make IceCoffee remove all the inactive items from the Services menu it can insert into the contextual menu. I tried the removing bit in one of my own apps and it seemed to work fine. Still, I always ended up with the complete Services menu when doing the contextual menu magic. I would get as far as having the program do what I wanted, except that I had to click into the menu bar before every invocation of the contextual menu to make it work properly. (It's no coincidence this smells exactly like the bug in AppKit that makes keyboard equivalents of services not work before you've used the menu.)
So I phoned Steffen this morning to ask for advice how I could track down what exactly AppKit is doing to make the Services menu work. We didn't figure directly, so we first used Hydra, so I could talk Steffen through what the existing code was, what it did and my changes were supposed to do. We did this mainly to try out Hydra but it turned out to be extremely neat, quick and productive. The application definitely is a must-have.
Then Steffen quickly copied me Share My Desktop, which apparently is a VNC client. Once it was in his public folder on my drive I simply double clicked it, hit the huge on-screen button. That launched the server and automatically copied the access information (IP, Port, randomly generated password) onto the clipboard so I could IM it to Steffen. Now that was neat. I didn't even know what VNC is and four mouse clicks later I was using it and Steffen could see my screen.
Then, using the Apple provided ObjectAlloc application we tracked down a little what happens in a menu event. It's a lot, but finally we figured that we don't need to dig into Cocoa's intestines but only call
[[NSApp servicesMenu] update], which in turn calls all those important intestines, to have a nice and fresh Services menu. In fact that resolves the bug in AppKit I wrote about above and I included it in my augmented version of IceCoffee to fix it.
Now we had that sorted but all the menu items would still appear. They were all still active (i.e. not validated otherwise) and my algorithm just dumped the inactive ones. Unfortunately any standard method to validate those menu items failed. We only solved that bit due to being observant while using the amazing MagicHat application that digs through the libraries and shows you what's really in there instead of what Apple wished to reveal. Using that we found the
NSServicesMenuHandler class which does just what's needed. Everything works now. Cool. Will send the changes to Nicholas and see what he thinks.
Using the phone, instant messaging, a shared text editor and a shared screen made us work very efficiently. Better than I thought was possible from a distance. Our department has installed video conferencing facilities with a shared blackboard recently. So I'll have to find an excuse and opportunity to try that out.
Received data seems to be invalid. The wanted file does probably not exist or the guys at last.fm changed something.