-
-
Notifications
You must be signed in to change notification settings - Fork 669
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add the ability to specify platform-specific icons #2260
Conversation
27b1f7d
to
8b15e4c
Compare
0faf194
to
2c239be
Compare
I think this needs to be rebased again – it still contains all of #2259. |
Done. |
7e2318a
to
d84d920
Compare
On GTK, Toga will look for (in order): | ||
* ``myicon-linux-72.png`` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RST requires a blank line before a list.
On GTK, Toga will look for (in order): | |
* ``myicon-linux-72.png`` | |
On GTK, Toga will look for (in order): | |
* ``myicon-linux-72.png`` |
core/src/toga/icons.py
Outdated
def TOGA_ICON(cls) -> Icon: | ||
return Icon("resources/toga", system=True) | ||
return Icon("toga", system=True) | ||
|
||
@cachedicon | ||
def DEFAULT_ICON(cls) -> Icon: | ||
return Icon("resources/toga", system=True) | ||
return Icon("toga", system=True) | ||
|
||
@cachedicon | ||
def OPTION_CONTAINER_DEFAULT_TAB_ICON(cls) -> Icon: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These should have some docstrings, which should at least explain the distinction between TOGA_ICON and DEFAULT_ICON. If there isn't any distinction, maybe we should deprecate one of them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed documenting these is desirable... is it possible? How do you docstring a constant?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, I see these aren't normal @properties
, so I'm not sure how Sphinx would deal with them. Maybe it could be done by making cachedicon
copy the __doc__
attribute from the underlying method to itself. Or maybe we could use the #:
syntax that works in Enums (e.g. in toga/core/src/toga/constants/__init__.py
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh wait... these are properties... Forgot about that.
#2259 revealed a need for platform specific icons, as the toolbar icon used for iOS is unlikely to be useful on other platforms. This problem has been seen in other forms - for example, the default .png icon is a useful size for GTK toolbars, but not for Android toolbars.
This PR makes icons a resource that is provided by the backend, rather than the core package; this avoids shipping .icns or .ico files on to platforms that can't use those files.
It also modifies the icon loading process to include a platform-specific filename suffix as part of the lookup scheme (so it will look for
foobar-macOS.png
before looking forfoobar.png
.Builds on #2259 because it corrects the OptionContainer tests to avoid the use of the "-iOS" suffix.
PR Checklist: