Changeset eca5805 for launchers


Ignore:
Timestamp:
Dec 8, 2018 9:08:22 AM (16 months ago)
Author:
meeh <meeh@…>
Branches:
master
Children:
8841fed
Parents:
b8681dd
Message:

Mac OS X Launcher: Adding selectors for Preferences window launch, and for view of experimental console webview.

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

Legend:

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

    rb8681dd reca5805  
    2121  }
    2222 
     23  @IBAction func onPreferencesClick(_ sender: Any) {
     24    StatusBarController.launchPreferences(sender)
     25  }
    2326 
    2427  override func viewDidLoad() {
  • launchers/macosx/I2PLauncher/userinterface/StatusBarController.swift

    rb8681dd reca5805  
    1717 
    1818  var ctrl : PopoverViewController?
     19  private static var preferencesController: NSWindowController?
     20  private static var experimentalConsoleViewController: NSWindowController?
    1921
    2022  @IBOutlet var routerStatusTabView: RouterStatusView?
     
    3234    updateMenuItem.isEnabled = true
    3335    */
     36   
     37    let preferencesMenuItem = NSMenuItem(title: "Preferences", action: #selector(StatusBarController.launchPreferences(_:)), keyEquivalent: "P")
     38    preferencesMenuItem.isEnabled = true
     39   
    3440    menu.addItem(NSMenuItem(title: "Open I2P Console", action: #selector(self.handleOpenConsole(_:)), keyEquivalent: "O"))
    3541    menu.addItem(NSMenuItem.separator())
    3642    //menu.addItem(updateMenuItem)
     43    menu.addItem(preferencesMenuItem)
    3744    menu.addItem(NSMenuItem.separator())
    3845    menu.addItem(NSMenuItem(title: "Quit I2P Launcher", action: #selector(SwiftMainDelegate.terminate(_:)), keyEquivalent: "q"))
    3946   
    4047    return menu
     48  }
     49 
     50  static func onExperimentalConsoleViewClick(_ sender: NSButton) {
     51    if #available(OSX 10.12, *) {
     52      print("Clicked for Experimental Console WebView")
     53      if !(experimentalConsoleViewController != nil) {
     54        let storyboard = NSStoryboard(name: "ConsoleWebView", bundle: Bundle.main)
     55        experimentalConsoleViewController = storyboard.instantiateInitialController() as? NSWindowController
     56        print("created experimental console webview controller")
     57      }
     58      if (experimentalConsoleViewController != nil) {
     59        experimentalConsoleViewController!.showWindow(sender)
     60        print("trying to view: Console WebView")
     61      }
     62    } else {
     63      // Sorry, only OSX >= 10.12
     64    }
     65  }
     66 
     67  static func launchPreferences(_ sender: Any) {
     68    print("Preferences clicked")
     69    if !(preferencesController != nil) {
     70      let storyboard = NSStoryboard(name: "Preferences", bundle: Bundle.main)
     71      preferencesController = storyboard.instantiateInitialController() as? NSWindowController
     72      print("created preferences controller")
     73    }
     74    if (preferencesController != nil) {
     75      NSApp.activate(ignoringOtherApps: true)
     76      preferencesController!.showWindow(sender)
     77      print("trying to view: Preferences")
     78    }
     79  }
     80 
     81  static func launchRouterConsole(_ sender: Any) {
     82    if (!Preferences.shared().featureToggleExperimental) {
     83      // The normal...
     84      NSWorkspace.shared().open(URL(string: "http://127.0.0.1:7657")!)
     85    } else {
     86      // Experimental
     87    }
    4188  }
    4289 
     
    74121    NSLog("openConsoleClicked got clicked")
    75122    let realSender = sender as! NSMenuItem
    76     NSWorkspace.shared().open(URL(string: "http://127.0.0.1:7657")!)
    77123    NSLog("Sender: @%", realSender)
    78124  }
Note: See TracChangeset for help on using the changeset viewer.