Make grayscaleIcon setting in theme Info.plist work.

This commit is contained in:
Brent Simmons committed 2026-11-10 18:31:42 -08:00
1 parent 8f35dd116d
commit 518ef1cf5d
6 files changed
+25 -5

No files matched your search

@@ -16,7 +16,7 @@ final class DetailIconSchemeHandler: NSObject, WKURLSchemeHandler {
func webView(_ webView: WKWebView, start urlSchemeTask: WKURLSchemeTask) {
guard let responseURL = urlSchemeTask.request.url, let iconImage = self.currentArticle?.iconImage() else {
guard let responseURL = urlSchemeTask.request.url, let iconImage = self.currentArticle?.articleViewIconImage() else {
urlSchemeTask.didFailWithError(URLError(.fileDoesNotExist))
return
}
+5 -1
View File
@@ -43,11 +43,15 @@ struct ArticleTheme: Equatable, Sendable {
return String(describing: info?.version ?? 0)
}
var usesGrayscaleIcon: Bool {
info?.grayscaleIcon ?? false
}
private let info: ArticleThemePlist?
init() {
self.url = nil
self.info = ArticleThemePlist(name: "Article Theme", themeIdentifier: "com.ranchero.netnewswire.theme.article", creatorHomePage: "https://netnewswire.com/", creatorName: "Ranchero Software", version: 1)
self.info = ArticleThemePlist(name: "Article Theme", themeIdentifier: "com.ranchero.netnewswire.theme.article", creatorHomePage: "https://netnewswire.com/", creatorName: "Ranchero Software", version: 1, grayscaleIcon: nil)
let corePath = Bundle.main.path(forResource: "core", ofType: "css")!
let stylesheetPath = Bundle.main.path(forResource: "stylesheet", ofType: "css")!
@@ -14,6 +14,7 @@ public struct ArticleThemePlist: Codable, Equatable, Sendable {
public let creatorHomePage: String
public let creatorName: String
public let version: Int
public let grayscaleIcon: Bool?
enum CodingKeys: String, CodingKey {
case name = "Name"
@@ -21,5 +22,6 @@ public struct ArticleThemePlist: Codable, Equatable, Sendable {
case creatorHomePage = "CreatorHomePage"
case creatorName = "CreatorName"
case version = "Version"
case grayscaleIcon = "grayscaleIcon"
}
}
+8
View File
@@ -107,6 +107,14 @@ extension Article {
return IconImageCache.shared.imageForArticle(self)
}
/// Grayscale when the current theme’s Info.plist sets `grayscaleIcon`.
func articleViewIconImage() -> IconImage? {
guard let iconImage = iconImage() else {
return nil
}
return ArticleThemesManager.shared.currentTheme.usesGrayscaleIcon ? iconImage.grayscaleIconImage : iconImage
}
/// True when an icon notification is about an icon this article might show:
/// its feed’s icon, or one of its authors’ avatars.
func mightShowIcon(in notification: Notification) -> Bool {
+8 -2
View File
@@ -19,7 +19,13 @@ The `Info.plist` requires the following keys/types:
|`CreatorName`|`String`||
|`Version`|`Integer`||
These keys are optional. They fill in the theme's Get Info window in the Finder, and NetNewsWire ignores them:
This key is optional:
|Key|Type|Notes|
|---|---|---|
|`grayscaleIcon`|`Boolean`|When `true`, the feed icon or author avatar in the article view is grayscale.|
These keys are optional too. They fill in the theme's Get Info window in the Finder, and NetNewsWire ignores them:
|Key|Type|Notes|
|---|---|---|
@@ -35,7 +41,7 @@ The page loads with the article's link as its base URL, else the feed's home pag
NetNewsWire 7.3 and later use this file instead of `template.html` when a theme includes it, and older versions ignore it. Put `[[primary_media]]` and `[[enclosures]]` here, since older versions would show them as literal text. [Verdana Revival](../Themes/Verdana%20Revival.nnwtheme/template7.3.html) is an example.
### stylesheet.css
This provides a starting point for editing the style of the page.
This provides a starting point for editing the style of the page.
## Article Media
+1 -1
View File
@@ -29,7 +29,7 @@ final class ArticleIconSchemeHandler: NSObject, WKURLSchemeHandler {
return
}
let articleID = components.path
guard let iconImage = coordinator.articleFor(articleID)?.iconImage() else {
guard let iconImage = coordinator.articleFor(articleID)?.articleViewIconImage() else {
urlSchemeTask.didFailWithError(URLError(.fileDoesNotExist))
return
}