forked from I2P_Developers/i2p.i2p
Mac OS X Launcher: Adding optional Dock Icon functionality
This commit is contained in:
@ -52,9 +52,8 @@ class Logger {
|
|||||||
} // End of init()
|
} // End of init()
|
||||||
|
|
||||||
@objc func findInstalledI2PVersion() {
|
@objc func findInstalledI2PVersion() {
|
||||||
var i2pPath = NSHomeDirectory()
|
var i2pPath = Preferences.shared().i2pBaseDirectory
|
||||||
i2pPath += "/Library/I2P"
|
let jExecPath:String = Preferences.shared().javaCommandPath
|
||||||
let jExecPath:String = "/usr/libexec/java_home -v 1.7+ --exec java "
|
|
||||||
|
|
||||||
let jarPath = i2pPath + "/lib/i2p.jar"
|
let jarPath = i2pPath + "/lib/i2p.jar"
|
||||||
|
|
||||||
@ -81,7 +80,35 @@ class Logger {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func triggerDockIconShowHide(showIcon state: Bool) -> Bool {
|
||||||
|
var result: Bool
|
||||||
|
if state {
|
||||||
|
result = NSApp.setActivationPolicy(NSApplicationActivationPolicy.regular)
|
||||||
|
} else {
|
||||||
|
result = NSApp.setActivationPolicy(NSApplicationActivationPolicy.accessory)
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
func getDockIconStateIsShowing() -> Bool {
|
||||||
|
if NSApp.activationPolicy() == NSApplicationActivationPolicy.regular {
|
||||||
|
return true
|
||||||
|
} else {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@objc func applicationDidFinishLaunching() {
|
@objc func applicationDidFinishLaunching() {
|
||||||
|
switch Preferences.shared().showAsIconMode {
|
||||||
|
case .bothIcon, .dockIcon:
|
||||||
|
if (!getDockIconStateIsShowing()) {
|
||||||
|
triggerDockIconShowHide(showIcon: true)
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
if (getDockIconStateIsShowing()) {
|
||||||
|
triggerDockIconShowHide(showIcon: false)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc func listenForEvent(eventName: String, callbackActionFn: @escaping ((Any?)->()) ) {
|
@objc func listenForEvent(eventName: String, callbackActionFn: @escaping ((Any?)->()) ) {
|
||||||
@ -99,8 +126,7 @@ class Logger {
|
|||||||
|
|
||||||
@objc func applicationWillTerminate() {
|
@objc func applicationWillTerminate() {
|
||||||
// Shutdown stuff
|
// Shutdown stuff
|
||||||
let userPreferences = UserDefaults.standard
|
if (Preferences.shared().stopRouterOnLauncherShutdown) {
|
||||||
if (!userPreferences.bool(forKey: "letRouterLiveEvenLauncherDied")) {
|
|
||||||
RouterManager.shared().routerRunner.TeardownLaunchd()
|
RouterManager.shared().routerRunner.TeardownLaunchd()
|
||||||
sleep(2)
|
sleep(2)
|
||||||
let status: AgentStatus? = RouterRunner.launchAgent?.status()
|
let status: AgentStatus? = RouterRunner.launchAgent?.status()
|
||||||
|
Reference in New Issue
Block a user