Skip to content

Commit

Permalink
Force the .icns extension, and allow a no-cover on the missing icon.
Browse files Browse the repository at this point in the history
  • Loading branch information
freakboy3742 committed May 7, 2024
1 parent 7368392 commit 6791ed5
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions cocoa/src/toga_cocoa/icons.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,19 @@ def __init__(self, interface, path):
if path is None:
# Look to the app bundle, and get the icon. Set self.path as None
# as an indicator that this is the app's default icon.
# This bundle icon file definition might not contain an extension,
# even thought the actual file will; so force the .icns extension.
bundle_icon = Path(
NSBundle.mainBundle.objectForInfoDictionaryKey("CFBundleIconFile")
)
path = NSBundle.mainBundle.pathForResource(
bundle_icon.stem,
ofType=bundle_icon.suffix,
ofType=".icns",
)
# If the icon file doesn't exist, raise the problem as FileNotFoundError
# This can't be tested, as the app will always have an icon.
if not Path(path).is_file():
raise FileNotFoundError()
raise FileNotFoundError() # pragma: no cover

self.path = None
else:
Expand Down

0 comments on commit 6791ed5

Please sign in to comment.