Systray implementation design #2108
Replies: 3 comments 21 replies
-
We're highly unlikely to add a "menu" API when we've managed to develop an entire App and Toolbar API that allows for app menus without once using the word "menu" in an API. Another big gap in this API proposal is the "systray-only app". This proposal seems to be aimed at apps that have a main window and have a systray icon, but the much more pressing use case I can see is an app whose systray is the "main window". |
Beta Was this translation helpful? Give feedback.
-
The issue isn't the name. It's the entire pattern you're proposing for constructing a menu. 3 questions for you that might be illuminating:
Yes, there's a very good reason. A macOS app isn't required to have a Main Window. I believe the same is true of GTK as well. In terms of Toga's API - in the case of a DocumentApp, there literally isn't a main window. There's a window for each document; and when you start the app, there isn't necessarily a document open.
That's certainly a common pattern, but I wouldn't say it's universal. I've got several examples of apps in my system tray that don't have anything you could call their "main" window. The only element I'd say is universal is the preferences dialog - but that's not a main window. |
Beta Was this translation helpful? Give feedback.
-
I agree it's Windows specific; the only thing I'd say in the defence of that name is that the 3 or so times it's come up, the request has been for a "System tray icon". However, that may be because the people requesting it are Windows users. I could live with StatusIcon though - a quick straw poll of some friends all hit on "Status bar" as the name of the place where these icons live; and Material Design guidelines apparently calls that area a Status Bar.
Yes - but a status bar app doesn't need to have a main window. Dropbox and Docker are good examples here - in both cases, you can interact with the app without any window being open, anything appearing in the Dock, or the app menu changing. In the case of Docker, you only get a change in the App menu when you open the Docker Desktop Dashboard. So - we need to be able to create an app that doesn't have a main window - and toga.App requires a main window. In the case of Windows, the MainWindow is actually critical to event processing, so we need an entirely different app startup mechanism.
Can you give an example of a use case? I can't think of any apps that have multiple status bar icons. |
Beta Was this translation helpful? Give feedback.
-
I will implement systray support. But, I have not forgotten about #1890, which I will be implementing later on.
As the systray implementation is overlapping with notification implementation(especially on winforms), hence I think that a new class is needed. This will represent the app's icon in the System Tray(Windows) or status bar or notification area(for mobile).
I am not sure about the naming of the class, as calling it systray icon would be confusing for other platforms. Hence, I have came up with
NotificationAreaIcon
orStatusAreaIcon
.The App class will have an instance of the
StatusAreaIcon
that will be automatically instantiated(with default settings) on the first access ofToga.App.StatusAreaIcon
.The following will be the members and methods of
StatusAreaIcon
:icon
- Gets and sets the icon of typeToga.Image()
.description
- Gets and sets the string representing the current status of the app or the progress of the work that the app is doing currently. Or more specifically the tooltip of theStatusAreaIcon
.show
- boolean to show/hide theStatusAreaIcon
add_to_menu("Name of the option", on_press=None)
- Adds a single option to theStatusAreaIcon
menu with a handler.add_to_menu(options=[("Name of the option1", on_press=None), ("Name of the option2", on_press=None),..])
- Adds multiple options to theStatusAreaIcon
menu.remove_from_menu("Name of the option")
- Remove an option from the menu.What else do you think that needs to be in this API?
Related: #97 #1890 #907
Beta Was this translation helpful? Give feedback.
All reactions