Update the theme popup when the themes change

This commit is contained in:
Maurice Parker 2021-09-08 17:36:52 -05:00
parent 9db72e50e8
commit e68e7420b8
2 changed files with 10 additions and 0 deletions

View File

@ -40,6 +40,10 @@ final class GeneralPreferencesViewController: NSViewController {
updateUI()
}
@objc func articleThemeNamesDidChangeNotification(_ note: Notification) {
updateArticleThemePopup()
}
// MARK: - Actions
@IBAction func articleThemePopUpDidChange(_ sender: Any) {
@ -67,6 +71,7 @@ private extension GeneralPreferencesViewController {
func commonInit() {
NotificationCenter.default.addObserver(self, selector: #selector(applicationWillBecomeActive(_:)), name: NSApplication.willBecomeActiveNotification, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(articleThemeNamesDidChangeNotification(_:)), name: .ArticleThemeNamesDidChangeNotification, object: nil)
}
func updateUI() {
@ -86,6 +91,9 @@ private extension GeneralPreferencesViewController {
}
articleThemePopup.selectItem(withTitle: ArticleThemesManager.shared.currentThemeName)
if articleThemePopup.indexOfSelectedItem == -1 {
articleThemePopup.selectItem(withTitle: ArticleTheme.defaultTheme.name)
}
}
func updateBrowserPopup() {

View File

@ -81,6 +81,8 @@ final class ArticleThemesManager {
}
try FileManager.default.copyItem(atPath: filename, toPath: toFilename)
updateThemeNames()
}
// MARK: Notifications