mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2024-12-12 17:36:19 +01:00
51 lines
1.3 KiB
Swift
51 lines
1.3 KiB
Swift
//
|
|
// AccountsDeleteWindowController.swift
|
|
// NetNewsWire
|
|
//
|
|
// Created by Maurice Parker on 5/1/19.
|
|
// Copyright © 2019 Ranchero Software. All rights reserved.
|
|
//
|
|
|
|
import AppKit
|
|
import Account
|
|
|
|
class AccountsDeleteWindowController: NSWindowController {
|
|
|
|
@IBOutlet weak var deleteLabel: NSTextField!
|
|
private weak var hostWindow: NSWindow?
|
|
|
|
var account: Account?
|
|
|
|
convenience init(account: Account) {
|
|
self.init(windowNibName: NSNib.Name("AccountsDelete"))
|
|
self.account = account
|
|
}
|
|
|
|
override func windowDidLoad() {
|
|
let deletePrompt = NSLocalizedString("Delete", comment: "Delete")
|
|
deleteLabel.stringValue = "\(deletePrompt) \"\(account?.nameForDisplay ?? "")\"?"
|
|
}
|
|
|
|
// MARK: API
|
|
|
|
func runSheetOnWindow(_ hostWindow: NSWindow, completionHandler handler: ((NSApplication.ModalResponse) -> Void)? = nil) {
|
|
self.hostWindow = hostWindow
|
|
hostWindow.beginSheet(window!, completionHandler: handler)
|
|
}
|
|
|
|
// MARK: Actions
|
|
|
|
@IBAction func cancel(_ sender: Any) {
|
|
hostWindow!.endSheet(window!, returnCode: NSApplication.ModalResponse.cancel)
|
|
}
|
|
|
|
@IBAction func delete(_ sender: Any) {
|
|
guard let account = account else {
|
|
return
|
|
}
|
|
AccountManager.shared.deleteAccount(account)
|
|
hostWindow!.endSheet(window!, returnCode: NSApplication.ModalResponse.OK)
|
|
}
|
|
|
|
}
|