Changeset 605f987 for launchers


Ignore:
Timestamp:
Jan 18, 2019 4:29:12 PM (22 months ago)
Author:
meeh <meeh@…>
Branches:
master
Children:
a367778
Parents:
5212591
Message:

Mac OSX Launcher: UI code updates, integration of firefox manager.

Location:
launchers/macosx/I2PLauncher/userinterface
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • launchers/macosx/I2PLauncher/userinterface/RouterStatusView.swift

    r5212591 r605f987  
    1919  }
    2020 
     21  var isFirefoxEnabled = false
     22 
    2123  @IBOutlet var routerStatusLabel: NSTextField?
    2224  @IBOutlet var routerVersionLabel: NSTextField?
     
    2931  @IBOutlet var routerStartStopButton: NSButton?
    3032  @IBOutlet var openConsoleButton: NSButton?
     33  @IBOutlet var launchFirefoxButton: NSButton?
    3134 
    3235 
     
    7881  }
    7982 
     83  @objc func actionBtnLaunchFirefox(_ sender: Any?) {
     84    DispatchQueue.global(qos: .background).async {
     85      Swift.print("Starting firefox")
     86      FirefoxManager.shared().executeFirefox()
     87    }
     88  }
     89 
    8090  func restartFn() {
    8191    RouterManager.shared().routerRunner.StopAgent({
     
    117127  }
    118128 
     129  func setupFirefoxBtn() {
     130    DispatchQueue.global(qos: .background).async {
     131      if (FirefoxManager.shared().IsFirefoxFound() && !self.isFirefoxEnabled) {
     132        Swift.print("Enabling Firefox Launch Button")
     133        DispatchQueue.main.async {
     134          self.isFirefoxEnabled = true
     135          self.launchFirefoxButton?.isEnabled = true
     136          self.launchFirefoxButton?.isTransparent = false
     137          self.launchFirefoxButton?.needsDisplay = true
     138          self.launchFirefoxButton?.action = #selector(self.actionBtnLaunchFirefox(_:))
     139          self.launchFirefoxButton?.target = self
     140        }
     141      }
     142    }
     143  }
     144 
    119145  override func viewWillDraw() {
    120146    super.viewWillDraw()
     
    123149    }
    124150    self.reEnableButton()
    125     openConsoleButton!.cell!.action = #selector(self.actionBtnOpenConsole(_:))
    126     openConsoleButton!.cell!.target = self
     151    openConsoleButton?.cell?.action = #selector(self.actionBtnOpenConsole(_:))
     152    openConsoleButton?.cell?.target = self
    127153   
    128154  }
     
    198224    super.init(coder: c)!
    199225    self.setupObservers()
     226    self.setupFirefoxBtn()
    200227    self.toggleSetButtonStart()
    201228    self.reEnableButton()
     
    205232    super.init(coder: decoder)
    206233    self.setupObservers()
     234    self.setupFirefoxBtn()
    207235    self.toggleSetButtonStart()
    208236    self.reEnableButton()
  • launchers/macosx/I2PLauncher/userinterface/StatusBarController.swift

    r5212591 r605f987  
    109109    RouterManager.shared().eventManager.listenTo(eventName: "toggle_popover", action: event_toggle)
    110110   
     111    FirefoxManager.shared().tryAutoDetect()
     112   
     113    print("Is Firefox found? \(FirefoxManager.shared().IsFirefoxFound())")
     114    print("Is Firefox profile extracted at \(Preferences.shared()["I2Pref_firefoxProfilePath"] as! String)? \(FirefoxManager.shared().IsProfileExtracted())")
     115    if (!FirefoxManager.shared().IsProfileExtracted()) {
     116      FirefoxManager.shared().unzipProfile()
     117    }
     118   
    111119    if let button = statusItem.button {
    112120      button.image = NSImage(named:"StatusBarButtonImage")
  • launchers/macosx/I2PLauncher/userinterface/preferences/PreferencesViewController.swift

    r5212591 r605f987  
    1111
    1212import Cocoa
     13import ServiceManagement
    1314
    1415
     
    6566    self.updateRadioButtonEffect(mode: Preferences.shared().showAsIconMode, withSideEffect: false)
    6667   
     68    if (Preferences.shared().stopRouterOnLauncherShutdown) {
     69      self.checkboxStopWithLauncher?.state = NSOnState;
     70    } else {
     71      self.checkboxStopWithLauncher?.state = NSOffState;
     72    }
     73    if (Preferences.shared().startRouterOnLauncherStart) {
     74      self.checkboxStartWithLauncher?.state = NSOnState;
     75    } else {
     76      self.checkboxStartWithLauncher?.state = NSOffState;
     77    }
     78   
     79   
    6780  }
    6881 
     
    111124 
    112125  @IBAction func checkboxStartLauncherOnOSXStartupClicked(_ sender: NSButton) {
    113     switch sender.state {
    114     case NSOnState:
    115       print("on")
    116     case NSOffState:
    117       print("off")
     126    let launcherAppId = "net.i2p.bootstrap.macosx.StartupItemApp"
     127    switch sender.state {
     128    case NSOnState:
     129      print("on")
     130      Preferences.shared()["I2Pref_startLauncherAtLogin"] = true
     131      let success = SMLoginItemSetEnabled(launcherAppId as CFString, true)
     132      print("SMLoginItemSetEnabled returned \(success)....")
     133    case NSOffState:
     134      print("off")
     135      Preferences.shared()["I2Pref_startLauncherAtLogin"] = false
     136      let success = SMLoginItemSetEnabled(launcherAppId as CFString, false)
     137      print("SMLoginItemSetEnabled returned \(success)....")
    118138    case NSMixedState:
    119139      print("mixed")
Note: See TracChangeset for help on using the changeset viewer.