class TestSuiteDelegate attr_accessor :window def application(application, didFinishLaunchingWithOptions:launchOptions) @window = UIWindow.alloc.initWithFrame(UIScreen.mainScreen.bounds) @window.rootViewController = UIViewController.alloc.init @window.makeKeyAndVisible true end end class TestSuiteOSXDelegate def applicationDidFinishLaunching(notification) buildMenu buildWindow end def buildWindow @mainWindow = NSWindow.alloc.initWithContentRect([[240, 180], [480, 360]], styleMask: NSTitledWindowMask|NSClosableWindowMask|NSMiniaturizableWindowMask|NSResizableWindowMask, backing: NSBackingStoreBuffered, defer: false) @mainWindow.title = "BubbleWrap Tests" end def buildMenu @mainMenu = NSMenu.new appName = "BubbleWrap Tests" addMenu(appName) do addItemWithTitle("About #{appName}", action: 'orderFrontStandardAboutPanel:', keyEquivalent: '') addItem(NSMenuItem.separatorItem) addItemWithTitle('Preferences', action: 'openPreferences:', keyEquivalent: ',') addItem(NSMenuItem.separatorItem) servicesItem = addItemWithTitle('Services', action: nil, keyEquivalent: '') NSApp.servicesMenu = servicesItem.submenu = NSMenu.new addItem(NSMenuItem.separatorItem) addItemWithTitle("Hide #{appName}", action: 'hide:', keyEquivalent: 'h') item = addItemWithTitle('Hide Others', action: 'hideOtherApplications:', keyEquivalent: 'H') item.keyEquivalentModifierMask = NSCommandKeyMask|NSAlternateKeyMask addItemWithTitle('Show All', action: 'unhideAllApplications:', keyEquivalent: '') addItem(NSMenuItem.separatorItem) addItemWithTitle("Quit #{appName}", action: 'terminate:', keyEquivalent: 'q') end NSApp.helpMenu = addMenu('Help') do addItemWithTitle("#{appName} Help", action: 'showHelp:', keyEquivalent: '?') end.menu NSApp.mainMenu = @mainMenu end private def addMenu(title, &b) item = createMenu(title, &b) @mainMenu.addItem item item end def createMenu(title, &b) menu = NSMenu.alloc.initWithTitle(title) menu.instance_eval(&b) if b item = NSMenuItem.alloc.initWithTitle(title, action: nil, keyEquivalent: '') item.submenu = menu item end end