48 lines
1.3 KiB
Swift
48 lines
1.3 KiB
Swift
//
|
|
// AppDelegate.swift
|
|
// Gemini
|
|
//
|
|
// Created by Shadowfacts on 7/12/20.
|
|
//
|
|
|
|
import Cocoa
|
|
import SwiftUI
|
|
import GeminiProtocol
|
|
import Combine
|
|
|
|
@NSApplicationMain
|
|
class AppDelegate: NSObject, NSApplicationDelegate {
|
|
|
|
var windowControllers = [BrowserWindowController]()
|
|
|
|
static let homePage = URL(string: "gemini://gemini.circumlunar.space/")!
|
|
|
|
func applicationDidFinishLaunching(_ aNotification: Notification) {
|
|
let wc = BrowserWindowController()
|
|
windowControllers.append(wc)
|
|
wc.showWindow(nil)
|
|
}
|
|
|
|
func applicationWillTerminate(_ aNotification: Notification) {
|
|
// Insert code here to tear down your application
|
|
}
|
|
|
|
func createNewWindowTab(attachedTo existingWindow: NSWindow) {
|
|
let wc = BrowserWindowController()
|
|
windowControllers.append(wc)
|
|
|
|
if let tabGroup = existingWindow.tabGroup {
|
|
wc.window!.setFrame(existingWindow.frame, display: false)
|
|
tabGroup.addWindow(wc.window!)
|
|
tabGroup.selectedWindow = wc.window!
|
|
}
|
|
}
|
|
|
|
@IBAction func newTab(_ sender: Any?) {
|
|
if let keyWindow = windowControllers.first(where: { $0.window != nil && $0.window!.isKeyWindow })?.window {
|
|
createNewWindowTab(attachedTo: keyWindow)
|
|
}
|
|
}
|
|
|
|
}
|