Skip to content

Commit

Permalink
Add quit menu item. Fixes #83.
Browse files Browse the repository at this point in the history
  • Loading branch information
thomassnielsen committed Apr 29, 2015
1 parent 4712544 commit fc92912
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Ember Hearth/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele
ProjectController.sharedInstance.toggleServer(sender)
}

@IBAction func terminate(sender: AnyObject?) {
NSApplication.sharedApplication().terminate(self)
}

func toggleProjectMenus() {
var mainMenu = NSApplication.sharedApplication().mainMenu
let projectActive = activeProject != nil
Expand Down
7 changes: 7 additions & 0 deletions Ember Hearth/StatusBarManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class StatusBarManager: NSObject {
var statusBarMenu: NSMenu?
var nameMenuItem: NSMenuItem?
var runServerMenuItem: NSMenuItem?
var terminateMenuItem: NSMenuItem?

let noProjectString = "No project selected"

Expand Down Expand Up @@ -54,6 +55,12 @@ class StatusBarManager: NSObject {
runServerMenuItem = NSMenuItem(title: "Run Server", action: "toggleServer:", keyEquivalent: "")
statusBarMenu?.addItem(runServerMenuItem!)

let separator = NSMenuItem.separatorItem()
statusBarMenu?.addItem(separator)

terminateMenuItem = NSMenuItem(title: "Quit Ember Hearth", action: "terminate:", keyEquivalent: "")
statusBarMenu?.addItem(terminateMenuItem!)

statusBarMenu?.autoenablesItems = false
runServerMenuItem?.enabled = true
statusBarItem?.menu = statusBarMenu
Expand Down

3 comments on commit fc92912

@kimroen
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will trigger the running server exiting as well, yes?

@thomassnielsen
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it will run through the usual ApplicationWillTerminate first, where we stop any running server.

@kimroen
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Please sign in to comment.