Launch at login.

This commit is contained in:
Charlie Qiu
2016-06-10 21:23:10 +08:00
parent 5f30f9f011
commit bc12db75c9

View File

@ -16,6 +16,8 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele
var preferencesWinCtrl: PreferencesWindowController!
var advPreferencesWinCtrl: AdvPreferencesWindowController!
var launchAtLoginController: LaunchAtLoginController = LaunchAtLoginController()
@IBOutlet weak var window: NSWindow!
@IBOutlet weak var statusMenu: NSMenu!
@ -110,6 +112,8 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele
updateMainMenu()
updateRunningModeMenu()
updateLaunchAtLoginMenu()
ProxyConfHelper.install()
applyConfig()
}
@ -190,7 +194,8 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele
}
@IBAction func toggleLaunghAtLogin(sender: NSMenuItem) {
launchAtLoginController.launchAtLogin = !launchAtLoginController.launchAtLogin;
updateLaunchAtLoginMenu()
}
@IBAction func selectPACMode(sender: NSMenuItem) {
@ -242,6 +247,14 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele
}
}
func updateLaunchAtLoginMenu() {
if launchAtLoginController.launchAtLogin {
lanchAtLoginMenuItem.state = 1
} else {
lanchAtLoginMenuItem.state = 0
}
}
func updateRunningModeMenu() {
let defaults = NSUserDefaults.standardUserDefaults()
let mode = defaults.stringForKey("ShadowsocksRunningMode")