2019-05-01 19:37:13 +02:00
|
|
|
//
|
|
|
|
// AccountsAddLocalWindowController.swift
|
|
|
|
// NetNewsWire
|
|
|
|
//
|
|
|
|
// Created by Maurice Parker on 5/1/19.
|
|
|
|
// Copyright © 2019 Ranchero Software. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
import AppKit
|
|
|
|
import Account
|
|
|
|
|
|
|
|
class AccountsAddLocalWindowController: NSWindowController {
|
|
|
|
|
2019-05-19 23:52:21 +02:00
|
|
|
@IBOutlet private weak var nameTextField: NSTextField!
|
|
|
|
@IBOutlet private weak var localAccountNameTextField: NSTextField!
|
|
|
|
|
2019-05-01 19:37:13 +02:00
|
|
|
private weak var hostWindow: NSWindow?
|
|
|
|
|
|
|
|
convenience init() {
|
|
|
|
self.init(windowNibName: NSNib.Name("AccountsAddLocal"))
|
|
|
|
}
|
|
|
|
|
2019-05-19 23:52:21 +02:00
|
|
|
override func windowDidLoad() {
|
|
|
|
super.windowDidLoad()
|
|
|
|
|
2020-11-06 12:07:28 +01:00
|
|
|
localAccountNameTextField.stringValue = NSLocalizedString("Create a local account on your Mac.", comment: "Account Local")
|
2019-05-19 23:52:21 +02:00
|
|
|
}
|
|
|
|
|
2019-05-01 19:37:13 +02:00
|
|
|
// MARK: API
|
|
|
|
|
|
|
|
func runSheetOnWindow(_ hostWindow: NSWindow) {
|
|
|
|
self.hostWindow = hostWindow
|
|
|
|
hostWindow.beginSheet(window!)
|
|
|
|
}
|
|
|
|
|
|
|
|
// MARK: Actions
|
|
|
|
|
|
|
|
@IBAction func cancel(_ sender: Any) {
|
|
|
|
hostWindow!.endSheet(window!, returnCode: NSApplication.ModalResponse.cancel)
|
|
|
|
}
|
|
|
|
|
|
|
|
@IBAction func create(_ sender: Any) {
|
|
|
|
let account = AccountManager.shared.createAccount(type: .onMyMac)
|
|
|
|
if !nameTextField.stringValue.isEmpty {
|
|
|
|
account.name = nameTextField.stringValue
|
|
|
|
}
|
|
|
|
hostWindow!.endSheet(window!, returnCode: NSApplication.ModalResponse.OK)
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|