Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'osx/cocoa'
- include OSX
- class ToasterWindowController < OSX::NSWindowController
- ib_outlet :qcView
- attr_accessor :notificationCenter, :workspace
- def awakeFromNib
- # workspace
- @workspace = NSWorkspace.sharedWorkspace()
- # notification center
- @notificationCenter = workspace.notificationCenter()
- @notificationCenter.addObserver_selector_name_object(self, "cookWaffle", NSWorkspaceDidMountNotification, nil)
- # this works here
- # @qcView.loadCompositionFromFile("/Users/jbaker/Desktop/Toaster Idle Screen.qtz")
- # log
- NSLog "ToasterApp: Listening for mounts"
- end
- def process
- # this does not work here
- # @qcView.loadCompositionFromFile("/Users/jbaker/Desktop/Toaster Idle Screen.qtz")
- end
- def finished
- @workspace.unmountAndEjectDeviceAtPath '/Volumes/TapeOnline.com'
- end
- def cookWaffle(notification)
- NSLog "ToasterApp: volume mount detected. #{notification.userInfo()['NSDevicePath']}"
- process unless notification.userInfo()['NSDevicePath'] != '/Volumes/TapeOnline.com'
- end
- end
Add Comment
Please, Sign In to add comment