Changeset c3b8317 for launchers/macosx


Ignore:
Timestamp:
Dec 8, 2018 9:16:28 AM (19 months ago)
Author:
meeh <meeh@…>
Branches:
master
Children:
b946bb0
Parents:
f90e2ee
Message:

Mac OS X Launcher: Adding optional Dock Icon functionality

File:
1 edited

Legend:

Unmodified
Added
Removed
  • launchers/macosx/I2PLauncher/SwiftMainDelegate.swift

    rf90e2ee rc3b8317  
    5353 
    5454  @objc func findInstalledI2PVersion() {
    55     var i2pPath = NSHomeDirectory()
    56     i2pPath += "/Library/I2P"
    57     let jExecPath:String = "/usr/libexec/java_home -v 1.7+ --exec java "
     55    var i2pPath = Preferences.shared().i2pBaseDirectory
     56    let jExecPath:String = Preferences.shared().javaCommandPath
    5857   
    5958    let jarPath = i2pPath + "/lib/i2p.jar"
     
    8281  }
    8382 
     83  func triggerDockIconShowHide(showIcon state: Bool) -> Bool {
     84    var result: Bool
     85    if state {
     86      result = NSApp.setActivationPolicy(NSApplicationActivationPolicy.regular)
     87    } else {
     88      result = NSApp.setActivationPolicy(NSApplicationActivationPolicy.accessory)
     89    }
     90    return result
     91  }
     92 
     93  func getDockIconStateIsShowing() -> Bool {
     94    if NSApp.activationPolicy() == NSApplicationActivationPolicy.regular {
     95      return true
     96    } else {
     97      return false
     98    }
     99  }
     100 
    84101  @objc func applicationDidFinishLaunching() {
     102    switch Preferences.shared().showAsIconMode {
     103    case .bothIcon, .dockIcon:
     104      if (!getDockIconStateIsShowing()) {
     105        triggerDockIconShowHide(showIcon: true)
     106      }
     107    default:
     108      if (getDockIconStateIsShowing()) {
     109        triggerDockIconShowHide(showIcon: false)
     110      }
     111    }
    85112  }
    86113 
     
    100127  @objc func applicationWillTerminate() {
    101128    // Shutdown stuff
    102     let userPreferences = UserDefaults.standard
    103     if (!userPreferences.bool(forKey: "letRouterLiveEvenLauncherDied")) {
     129    if (Preferences.shared().stopRouterOnLauncherShutdown) {
    104130      RouterManager.shared().routerRunner.TeardownLaunchd()
    105131      sleep(2)
Note: See TracChangeset for help on using the changeset viewer.