Skip to content

Instantly share code, notes, and snippets.

@nickludlam
Created April 28, 2010 00:42
Show Gist options
  • Save nickludlam/381569 to your computer and use it in GitHub Desktop.
Save nickludlam/381569 to your computer and use it in GitHub Desktop.
def awakeFromNib
@menu = NSMenu.alloc.initWithTitle("Main Menu")
@status_bar = NSStatusBar.systemStatusBar
@status_item = @status_bar.statusItemWithLength(NSVariableStatusItemLength)
@status_item.setHighlightMode(true)
@status_item.setMenu(@menu)
@app_icon = NSImage.imageNamed('iplayer_logo_small_black.tiff')
@app_icon_alt = NSImage.imageNamed('iplayer_logo_small_white.tiff')
@status_item.setImage(@app_icon)
@status_item.setAlternateImage(@app_icon_alt)
setupMenu()
end
def setupMenu
appMenu = NSMenu.alloc.init
appMenu.setAutoenablesItems(false)
addMenuItemToMenu(appMenu, "Start Webrick", "startWebrick")
addMenuItemToMenu(appMenu, "Stop Webrick", "stopWebrick")
addMenuItemToMenu(appMenu, "Test change response", "changeResponse")
addMenuItemToMenu(appMenu, "Version 1.0", "test")
appMenuItem = NSMenuItem.alloc.init
appMenuItem.title = "WEBrick control"
appMenuItem.submenu = appMenu
appMenuItem.enabled = true
@status_item.menu.insertItem_atIndex_(appMenuItem, 0)
@startDownloaderMenuItem = addMenuItemToMenu(@status_item.menu, "Run iCatcher now", "startStopDownloaderLoop")
addMenuItemToMenu(@status_item.menu, "Show output window", "showDownloaderWindow")
addMenuItemToMenu(@status_item.menu, "Show RSS feeds", "openRSSFeedList")
addMenuItemToMenu(@status_item.menu, "test", "test")
addMenuItemToMenu(@status_item.menu, "Check for updates...", "checkForUpdates")
addMenuItemToMenu(@status_item.menu, "Quit", "quit")
end
def addMenuItemToMenu(menu, menuTitle, methodName)
newMenuItem = menu.addItemWithTitle_action_keyEquivalent(menuTitle, methodName, "")
newMenuItem.target = self
newMenuItem.enabled = true
newMenuItem
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment