I'm working on a small MacRuby project, using 0.5b1, which is implementing the delegate methods required for Growl (the app is using Growl for notifications).
I would like to be able to respond to the Growl callbacks when the notification is clicked, however when you register the Growl delegate with ::GrowlApplicationBridge.setGrowlDelegate self
it asks the delegate for a NSDictionary*
with the Growl registration information.
I have tried returning a standard NSDictionary instance, trying to coerce the object into a pointer etc, but every time I seem to get a segmentation fault (I guess this is because I'm passing back an object, not a pointer to the object).
I'm wondering if it is possible to obtain a pointer to the object its self, or using p = Pointer.new("NSDictionary")
is it possible to assign the data somehow (using p.assign(dict)
results in a type error as it is expecting an Integer).
I guess that the other option is to write an ObjC class to act as the delegate and just hook into that from Ruby, but that somewhat defeats the purpose….
Best Solution
A ruby hash is a NSDictionary in MacRuby. You should be able to do something along the lines of:
Although, I don't have the keys set properly for the growl dictionary (which I believe is due to passing nil to the AllNotifications key. Hopefully, passing in an array of real notifications should work):