-
Notifications
You must be signed in to change notification settings - Fork 169
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactored note windows to be managed by the window controllers
- Loading branch information
1 parent
95a7d61
commit 4fc3b11
Showing
7 changed files
with
63 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// | ||
// NoteWindowManager.swift | ||
// Simplenote | ||
// | ||
// Created by Charlie Scheer on 4/15/24. | ||
// Copyright © 2024 Simperium. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
class NoteWindowController: NSWindowController { | ||
init(note: Note) { | ||
let window = NoteWindow(note: note) | ||
super.init(window: window) | ||
} | ||
|
||
required init?(coder: NSCoder) { | ||
fatalError("init(coder:) has not been implemented") | ||
} | ||
} | ||
|
||
class NoteWindowManager: NSObject { | ||
var controllers = Set<NSWindowController>() | ||
|
||
func prepareWindowController(for note: Note) -> NSWindowController { | ||
let windowController = NoteWindowController(note: note) | ||
windowController.window?.delegate = self | ||
|
||
controllers.insert(windowController) | ||
|
||
return windowController | ||
} | ||
} | ||
|
||
extension NoteWindowManager: NSWindowDelegate { | ||
func windowWillClose(_ notification: Notification) { | ||
if let window = notification.object as? NSWindow, | ||
let controller = window.windowController { | ||
controllers.remove(controller) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters