source: launchers/macosx/I2PLauncher/Utils/browser/EmbeddedConsoleView.swift @ f4496a0

Last change on this file since f4496a0 was f4496a0, checked in by meeh <meeh@…>, 20 months ago

Mac OS X Launcher: Unfinished experimental code, adding so other people can compile the xcode project.

  • Property mode set to 100644
File size: 2.0 KB
Line 
1//
2//  EmbeddedConsoleView.swift
3//  I2PLauncher
4//
5//  Created by Mikal Villa on 08/12/2018.
6//  Copyright © 2018 The I2P Project. All rights reserved.
7//
8
9import AppKit
10import WebKit
11
12/*
13protocol EConsoleViewWrapper {}
14
15class WebViewSource {
16  class func webView() -> EConsoleViewWrapper {
17    if #available(OSX 10.12, *) {
18      //
19      return EmbeddedConsoleView(coder: NSCoder())!
20    } else {
21      // Sorry
22      return EmbeddedConsoleViewDummy()
23    }
24  }
25}
26
27extension EConsoleViewWrapper {
28  static func instantiate(frame frameRect: NSRect) -> EConsoleViewWrapper {
29    return WebViewSource.webView()
30  }
31}
32*/
33
34class ConsoleWindowController: NSWindowController {
35  override func windowDidLoad() {
36    super.windowDidLoad()
37/*    let v: NSView = WebViewSource.webView() as! NSView
38    v.wantsLayer = true
39    self.window?.contentView?.addSubview(v)*/
40  }
41}
42
43class ConsoleViewController: NSViewController {
44  var webView: WKWebView!
45  let consoleWebUrl = URL(string: "http://127.0.0.1:7657")
46 
47  override func loadView() {
48    let webConfiguration = WKWebViewConfiguration()
49    webView = WKWebView(frame: .zero, configuration: webConfiguration)
50    //webView.uiDelegate = self
51    view = webView
52  }
53  override func viewDidLoad() {
54    super.viewDidLoad()
55   
56    webView.load(URLRequest(url: consoleWebUrl!))
57  }
58
59}
60
61/*
62@available(OSX 10.12, *)
63class EmbeddedConsoleView: WKWebView, EConsoleViewWrapper {
64 
65  let consoleWebUrl = URL(string: "http://127.0.0.1:7657")
66 
67  func setupWebViewForConsole(_ f: NSRect = NSRect(x: 0, y: 0, width: 800, height: 400)) {
68    self.allowsBackForwardNavigationGestures = true
69    self.configuration.preferences.javaScriptEnabled = true
70    self.configuration.preferences.plugInsEnabled = false
71   
72    self.load(URLRequest(url: consoleWebUrl!))
73  }
74 
75  override func viewWillDraw() {
76    super.viewWillDraw()
77  }
78 
79  required init?(coder decoder: NSCoder) {
80    super.init(coder: decoder)
81    self.setupWebViewForConsole()
82  }
83 
84}
85
86class EmbeddedConsoleViewDummy: NSView, EConsoleViewWrapper {}
87*/
88
Note: See TracBrowser for help on using the repository browser.