Skip to content
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 status icons #2768

Merged
merged 29 commits into from
Aug 27, 2024
Merged

Add status icons #2768

merged 29 commits into from
Aug 27, 2024

Conversation

freakboy3742
Copy link
Member

@freakboy3742 freakboy3742 commented Aug 15, 2024

Adds an API allowing users to register status icons with an app.

  • Adds a status_icons attribute to app. Status icons can be registered with the app, and can provided with an icon (falling back to the app's icon if no icon is provided), and a text label (falling back to the app name).
  • Adds a StatusIcon class, representing a "button-like" status icon. This has an on_press handler.
  • Adds a MenuStatusIcon class, representing a "menu-like" status icon.
  • A MenuStatusIcon can also act as a group, so groups can be created using the MenuStatusIcon as a parent.
  • The status icons list has a commands CommandSet. Commands that you want to appear in status menus are registered with that CommandSet.
  • Any command registered against the COMMANDS group will be added to the first MenuStatusIcon that is added to status_icons. This allows for a safe default if you define commands without a specific status icon group.
  • Standard commands (currently About and Exit) are added to status_icons.commands, and registered as part of the COMMANDS group, so they will be added to the first MenuStatusIcon for the app.
  • Any command that is part of a group that isn't added to status_icons, and isn't COMMANDS, will be ignored.

There's one TODO in the implementation at present, waiting on the new "Standard command" API from #2666.

There is a stub implementation on Android, iOS, Web and Textual. This allows apps that define status icons to at least start, albeit with a warning.

The GTK implementation uses XApp, rather than AyatanaAppIndicator3 as discussed in the ticket. XApp uses almost the same API as Ayatana, but is being developed by Mint who (unlike Ubuntu) actually do believe in status icons, and as a result, the implementation actually works as you'd expect.

Fixes #97

PR Checklist:

  • All new features have been tested
  • All new features have been documented
  • I have read the CONTRIBUTING.md file
  • I will abide by the code of conduct

@freakboy3742 freakboy3742 mentioned this pull request Aug 15, 2024
@freakboy3742 freakboy3742 marked this pull request as ready for review August 17, 2024 06:57
@mhsmith
Copy link
Member

mhsmith commented Aug 19, 2024

  • Any command that is part of a group that isn't added to status_icons, and isn't COMMANDS, will be ignored.

Since this must be a programming error, rather than failing silently I think it would make sense to throw an exception so the developer is pointed directly at the cause.

docs/reference/api/resources/statusicons.rst Outdated Show resolved Hide resolved
core/src/toga/app.py Outdated Show resolved Hide resolved
docs/reference/api/resources/statusicons.rst Outdated Show resolved Hide resolved
docs/reference/api/resources/statusicons.rst Outdated Show resolved Hide resolved
docs/reference/api/resources/statusicons.rst Outdated Show resolved Hide resolved
core/src/toga/statusicons.py Outdated Show resolved Hide resolved
core/src/toga/statusicons.py Outdated Show resolved Hide resolved
core/src/toga/statusicons.py Outdated Show resolved Hide resolved
core/src/toga/statusicons.py Outdated Show resolved Hide resolved
core/src/toga/statusicons.py Outdated Show resolved Hide resolved
docs/reference/api/resources/statusicons.rst Outdated Show resolved Hide resolved
docs/reference/api/resources/statusicons.rst Outdated Show resolved Hide resolved
docs/reference/api/resources/statusicons.rst Outdated Show resolved Hide resolved
docs/reference/api/resources/statusicons.rst Outdated Show resolved Hide resolved
@freakboy3742
Copy link
Member Author

I've incorporated those doc updates, merged with main, replaced the TODO about standard commands with the actual standard command mechanism, and updated the tests and screenshots to reflect the standard menu items. I think that makes this ready for final review and merge.

@mhsmith mhsmith merged commit e757387 into beeware:main Aug 27, 2024
35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Systray support ?
2 participants