Guest User

Untitled

a guest
Mar 13th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. require 'osx/cocoa'
  2. include OSX
  3.  
  4. class ToasterWindowController < OSX::NSWindowController
  5. ib_outlet :qcView
  6.  
  7. attr_accessor :notificationCenter, :workspace
  8.  
  9. def awakeFromNib
  10. # workspace
  11. @workspace = NSWorkspace.sharedWorkspace()
  12.  
  13. # notification center
  14. @notificationCenter = workspace.notificationCenter()
  15. @notificationCenter.addObserver_selector_name_object(self, "cookWaffle", NSWorkspaceDidMountNotification, nil)
  16.  
  17. # this works here
  18. # @qcView.loadCompositionFromFile("/Users/jbaker/Desktop/Toaster Idle Screen.qtz")
  19. # log
  20. NSLog "ToasterApp: Listening for mounts"
  21. end
  22.  
  23. def process
  24. # this does not work here
  25. # @qcView.loadCompositionFromFile("/Users/jbaker/Desktop/Toaster Idle Screen.qtz")
  26. end
  27.  
  28. def finished
  29. @workspace.unmountAndEjectDeviceAtPath '/Volumes/TapeOnline.com'
  30. end
  31.  
  32. def cookWaffle(notification)
  33. NSLog "ToasterApp: volume mount detected. #{notification.userInfo()['NSDevicePath']}"
  34. process unless notification.userInfo()['NSDevicePath'] != '/Volumes/TapeOnline.com'
  35. end
  36. end
Add Comment
Please, Sign In to add comment