2016-08-14 15:29:50 +03:00
|
|
|
/**
|
|
|
|
* Tae Won Ha - http://taewon.de - @hataewon
|
|
|
|
* See LICENSE
|
|
|
|
*/
|
|
|
|
|
|
|
|
import Cocoa
|
|
|
|
import PureLayout
|
|
|
|
import RxSwift
|
|
|
|
|
|
|
|
struct GeneralPrefData {
|
|
|
|
let openNewWindowWhenLaunching: Bool
|
|
|
|
let openNewWindowOnReactivation: Bool
|
|
|
|
}
|
|
|
|
|
|
|
|
class GeneralPrefPane: PrefPane {
|
|
|
|
|
|
|
|
let openNewWindowWhenLaunching: Bool
|
|
|
|
let openNewWindowOnReactivation: Bool
|
|
|
|
|
|
|
|
init(source: Observable<Any>, initialData: GeneralPrefData) {
|
|
|
|
self.openNewWindowWhenLaunching = initialData.openNewWindowWhenLaunching
|
|
|
|
self.openNewWindowOnReactivation = initialData.openNewWindowOnReactivation
|
|
|
|
|
|
|
|
super.init(source: source)
|
|
|
|
}
|
|
|
|
|
|
|
|
required init?(coder: NSCoder) {
|
|
|
|
fatalError("init(coder:) has not been implemented")
|
|
|
|
}
|
|
|
|
|
|
|
|
override func addViews() {
|
|
|
|
let paneTitle = paneTitleTextField(title: "General")
|
|
|
|
|
2016-08-14 16:01:28 +03:00
|
|
|
let openUntitledWindowTitle = titleTextField(title: "Open Untitled Window:")
|
|
|
|
let openWhenLaunching = self.checkbox(title: "On Launch",
|
|
|
|
action: #selector(GeneralPrefPane.openUntitledWindowWhenLaunchingAction(_:)))
|
|
|
|
let openOnReactivation = self.checkbox(title: "On Re-Activation",
|
|
|
|
action: #selector(GeneralPrefPane.openUntitledWindowOnReactivation(_:)))
|
|
|
|
|
2016-08-14 15:29:50 +03:00
|
|
|
self.addSubview(paneTitle)
|
|
|
|
|
2016-08-14 16:01:28 +03:00
|
|
|
self.addSubview(openUntitledWindowTitle)
|
|
|
|
self.addSubview(openWhenLaunching)
|
|
|
|
self.addSubview(openOnReactivation)
|
|
|
|
|
2016-08-14 15:29:50 +03:00
|
|
|
paneTitle.autoPinEdgeToSuperviewEdge(.Top, withInset: 18)
|
|
|
|
paneTitle.autoPinEdgeToSuperviewEdge(.Left, withInset: 18)
|
2016-08-14 16:01:28 +03:00
|
|
|
|
|
|
|
openUntitledWindowTitle.autoAlignAxis(.Baseline, toSameAxisOfView: openWhenLaunching, withOffset: 0)
|
|
|
|
openUntitledWindowTitle.autoPinEdgeToSuperviewEdge(.Left, withInset: 18)
|
|
|
|
|
|
|
|
openWhenLaunching.autoPinEdge(.Top, toEdge: .Bottom, ofView: paneTitle, withOffset: 18)
|
|
|
|
openWhenLaunching.autoPinEdge(.Left, toEdge: .Right, ofView: openUntitledWindowTitle, withOffset: 5)
|
|
|
|
|
|
|
|
openOnReactivation.autoPinEdge(.Top, toEdge: .Bottom, ofView: openWhenLaunching, withOffset: 5)
|
|
|
|
openOnReactivation.autoPinEdge(.Left, toEdge: .Left, ofView: openWhenLaunching)
|
|
|
|
openOnReactivation.autoPinEdgeToSuperviewEdge(.Bottom, withInset: 18)
|
2016-08-14 15:29:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
override func subscription(source source: Observable<Any>) -> Disposable {
|
|
|
|
return source
|
|
|
|
.subscribeNext { event in
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
2016-08-14 16:01:28 +03:00
|
|
|
|
|
|
|
private func updateViews() {
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// MARK: - Actions
|
|
|
|
extension GeneralPrefPane {
|
|
|
|
|
|
|
|
func openUntitledWindowWhenLaunchingAction(sender: NSButton) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
func openUntitledWindowOnReactivation(sender: NSButton) {
|
|
|
|
|
|
|
|
}
|
2016-08-14 15:29:50 +03:00
|
|
|
}
|