Add an interface for creating system trays#11234
Add an interface for creating system trays#11234expenses merged 31 commits intoslint-ui:feature/systrayfrom
Conversation
|
Todo:
|
|
Todo looks good. I'd say that in terms of API surface to our users we only want a Slint component. I just realize that we should probably keep track of that in #6053 - that way you can work with multiple PRs. |
internal/core/system_tray.rs
Outdated
| } | ||
|
|
||
| let tray = KsniTray { icon: ksni::Icon { width, height, data } } | ||
| .spawn() |
There was a problem hiding this comment.
Since spawn returns a future and ksni builds on top of smol, I think it's best to poll that future in a slint task (spawn_local), similar to the xdg settings watcher perhaps.
That way you also don't need custom event enums / variants.
There was a problem hiding this comment.
Would prefer to do that as part of a later commit
| change_tracker: crate::properties::ChangeTracker, | ||
| } | ||
|
|
||
| impl Item for SystemTray { |
There was a problem hiding this comment.
I wonder if we really need the SystemTray to be an Item
the Compiler would probably need to generate some special code of it.
But thats fine to have it temporarily as an experiment.
There was a problem hiding this comment.
What would the alternative be?
test stuff Work Add basic system tray thing to internal/core Clean up, use event loop Further changes, add to platform trait Some internal backends stuff more small fixes Feature changes Add ksni support Add icon support to ksni Add ksni to rust api Update flake.nix (don't push) Add systray example (also dont merge) Adjust example
This reverts commit 0b59887.
should be renamed later
ogoffart
left a comment
There was a problem hiding this comment.
Looks like a good start.
I'd be OK to merge this into master if it is gated as experimental.
| //-is_internal | ||
| } | ||
|
|
||
| export component SystemTray { |
There was a problem hiding this comment.
Can you make it as experimental so it is only available when using SLINT_ENABLE_EXPERIMENTAL_FEATURES=1 ?
There was a problem hiding this comment.
Done. Where does that leave the example? Should I remove it now?
|
I see the CI is failling because it needs experimental. One way to fix this is to add in the build.rs, and use the |
Cargo.lock
Outdated
| ] | ||
|
|
||
| [[package]] | ||
| name = "gtk" |
There was a problem hiding this comment.
This will not make the security check happy :-(
Same here. I would however suggest to target a feature/systray branch instead of master as this will I think otherwise immediately trigger a security alert for the slint repo due to the gtk dependency. I have some hope to resolve that before the feature is shipped |
I agree. I've created the branch and took the liberty to re-target this PR. |
|
After merging this, please move the todo list from #11234 (comment) to the GitHub issue, update it, and work forward with that. |
Initial work on #6053. The idea is to use the ksni crate on linux and tray-icon everywhere else. I haven't yet added a SystemTray type to slint as getting this hooked up seems to be a little tricky - we make quite a few assumptions that the root exported type is a window and not something else. Icons successfully display in ksni, tooltips etc need more work.