2020-07-13 01:35:00 +00:00
|
|
|
//
|
|
|
|
// AppDelegate.swift
|
|
|
|
// Gemini
|
|
|
|
//
|
|
|
|
// Created by Shadowfacts on 7/12/20.
|
|
|
|
//
|
|
|
|
|
|
|
|
import Cocoa
|
|
|
|
import SwiftUI
|
2020-07-13 22:22:36 +00:00
|
|
|
import GeminiProtocol
|
2020-07-15 22:30:12 +00:00
|
|
|
import Combine
|
2020-07-13 01:35:00 +00:00
|
|
|
|
|
|
|
@NSApplicationMain
|
|
|
|
class AppDelegate: NSObject, NSApplicationDelegate {
|
|
|
|
|
2020-07-15 22:30:12 +00:00
|
|
|
// var window: NSWindow!
|
|
|
|
|
|
|
|
var windowControllers = [BrowserWindowController]()
|
2020-07-13 01:35:00 +00:00
|
|
|
|
2020-07-15 03:15:56 +00:00
|
|
|
let homePage = URL(string: "gemini://gemini.circumlunar.space/")!
|
2020-07-15 22:30:12 +00:00
|
|
|
// private(set) lazy var navigationManager = NavigationManager(url: homePage)
|
|
|
|
|
|
|
|
// private var toolbarTextField: NSTextField!
|
|
|
|
// private var toolbarUpdater: Cancellable?
|
2020-07-13 22:22:36 +00:00
|
|
|
|
2020-07-13 01:35:00 +00:00
|
|
|
func applicationDidFinishLaunching(_ aNotification: Notification) {
|
2020-07-15 22:30:12 +00:00
|
|
|
// // Create the SwiftUI view that provides the window contents.
|
|
|
|
// let contentView = ContentView(navigator: navigationManager)
|
|
|
|
//
|
|
|
|
// // Create the window and set the content view.
|
|
|
|
// window = NSWindow(
|
|
|
|
// contentRect: NSRect(x: 0, y: 0, width: 480, height: 300),
|
|
|
|
// styleMask: [.titled, .closable, .miniaturizable, .resizable, .fullSizeContentView],
|
|
|
|
// backing: .buffered, defer: false)
|
|
|
|
// window.isReleasedWhenClosed = false
|
|
|
|
// window.center()
|
|
|
|
// window.setFrameAutosaveName("Main Window")
|
|
|
|
// window.contentView = NSHostingView(rootView: contentView)
|
|
|
|
//// window.title = "Gemini"
|
|
|
|
//// let toolbar = NSToolbar()
|
|
|
|
//// toolbar.delegate = self
|
|
|
|
//// toolbar.displayMode = .iconAndLabel
|
|
|
|
//// window.toolbar = toolbar
|
|
|
|
// window.makeKeyAndOrderFront(nil)
|
|
|
|
//
|
|
|
|
// toolbarTextField = NSTextField(string: navigationManager.currentURL.absoluteString)
|
|
|
|
// toolbarTextField.delegate = self
|
|
|
|
//
|
|
|
|
// toolbarTextField.widthAnchor.constraint(equalToConstant: 250).isActive = true
|
|
|
|
//
|
|
|
|
// toolbarUpdater = navigationManager.$currentURL.sink(receiveValue: { (newValue) in
|
|
|
|
// self.toolbarTextField.stringValue = newValue.absoluteString
|
|
|
|
// })
|
|
|
|
|
|
|
|
let wc = BrowserWindowController()
|
|
|
|
windowControllers.append(wc)
|
|
|
|
wc.showWindow(nil)
|
2020-07-13 01:35:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func applicationWillTerminate(_ aNotification: Notification) {
|
|
|
|
// Insert code here to tear down your application
|
|
|
|
}
|
|
|
|
|
2020-07-13 22:22:36 +00:00
|
|
|
}
|
2020-07-15 22:30:12 +00:00
|
|
|
|
|
|
|
//extension AppDelegate: NSToolbarDelegate {
|
|
|
|
// func toolbarAllowedItemIdentifiers(_ toolbar: NSToolbar) -> [NSToolbarItem.Identifier] {
|
|
|
|
// return [
|
|
|
|
// .flexibleSpace,
|
|
|
|
// .urlField,
|
|
|
|
// ]
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// func toolbarDefaultItemIdentifiers(_ toolbar: NSToolbar) -> [NSToolbarItem.Identifier] {
|
|
|
|
// return [
|
|
|
|
// .flexibleSpace,
|
|
|
|
// .urlField,
|
|
|
|
// .flexibleSpace,
|
|
|
|
// ]
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// func toolbar(_ toolbar: NSToolbar, itemForItemIdentifier itemIdentifier: NSToolbarItem.Identifier, willBeInsertedIntoToolbar flag: Bool) -> NSToolbarItem? {
|
|
|
|
// if itemIdentifier == .urlField {
|
|
|
|
// let item = NSToolbarItem(itemIdentifier: .urlField)
|
|
|
|
// item.label = "URL"
|
|
|
|
// item.view = toolbarTextField
|
|
|
|
// return item
|
|
|
|
// } else {
|
|
|
|
// return NSToolbarItem(itemIdentifier: .urlField)
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//}
|
|
|
|
//
|
|
|
|
//extension AppDelegate: NSTextFieldDelegate {
|
|
|
|
// func controlTextDidEndEditing(_ obj: Notification) {
|
|
|
|
// print("did end edting, new text: '\(toolbarTextField.stringValue)'")
|
|
|
|
// }
|
|
|
|
//}
|
|
|
|
//
|
|
|
|
//extension NSToolbarItem.Identifier {
|
|
|
|
// static let urlField = NSToolbarItem.Identifier("GeminiUrlField")
|
|
|
|
//}
|