-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Tray & Menu bar icon? #2649
Comments
is this still blocked ? |
Planned to be available this year. |
Is it possible to do this for OS X using MonoMac.Standard or will there be some conflict with Avalonia's codebase? |
Using MonoMac for tray icons should work. |
Any ETA or news about it? I was thinking about create an app that needs system tray support, actually I tried Xamarin.Forms and work well with it, but the poor support of multiple windows make me search other libs and check Avalonia, I just want a way to hook code into the NSAppDelegate and WPF Application in order to support NSStatusItem and NotifyIcon |
Lack of System Tray support is indeed a problem - one of the basic Windows persistent application enhancements is not possible. Is there a way to add tray icon using native dll bindings which was already done anywhere else, so that it can be included with conditional compilation flags for Windows build? |
Just for windows u can use this code: |
Brillant, many thanks! |
we could look at https://github.com/hardcodet/wpf-notifyicon for ideas on api design. |
@josegomez Many thanks, this is working great. |
NP @MikeAndrews90 glad it works for you, we've been using it for a while now works great, linux is still kinda ify depending on whether they are running GNOME or KDE, or Random other thing... but it mostly works. |
@josegomez Thanks for providing this! I tested it just on Windows and it worked fine except the icon would pop back up in the system tray after quitting the program. I fixed this by manually calling NotifyIcon.Remove() on the Desktop_Exit event. I see there's a deconstructor that does the same thing but for whatever reason it's not firing. I would totally use this but unfortunately it's GPL. Anyone know if the Avolonia team still working on their own solution? |
GPL license? 🤔 can I ask why that matters in your case just curious @seanocali |
Because any software I use it in would legally also have to be GPL. |
@seanocali we are planning to support this, after 0.10 release |
@danwalmsley I'm very excited for this feature! It's the only thing hindering me from porting my application to Avalonia. |
Same here. This is mandatory for me. |
Its definately coming... if someone wants to make a PR it could come sooner... and there is nothing to stop users doing this today by calling the native apis themselves. It shouldnt be a huge amount to work I dont think to add this. |
Ok. Sorry, you guys are doing a splendid job ;) |
I happened to find this clean implemented MIT licensed native wrapper for osx and windows notification tray icons ;-). I have been meaning to make it a nuget, it can certainly be ripped apart and implemented here. I didn't have the time honestly to do a linux portion. The C++ Is all CMake with build wrappers, visual studio 2019 for windows builds, standard OSX command line tools and xcode are all that's needed for OSX Builds, and of course latest CMAKE. The binaries are prebuilts right now. If you need it for a project feel free to take it, fork it, build it, run it, rip it to pieces and re-write it, w/e. If someone is so inclined integrate it into Avalonia. I needed the tray icons for work, and got as far as something easy to include them, and had to move on from there. Planning a wedding I don't have much free time for free work ;-) https://github.com/darkfrostystorm/NotificationTrayIconSharp edit: A linux implementation is missing as I did not need it, but GTK was starting to be added to the cmake etc. GTK seems like the best way to add this feature, there are examples out there. Seems like almost every DE on linux handles GTK tray icons the same, KDE and Gnome were working in examples I found using GTK. I think GTK is used in python to similar ends as well. At some point this will be my project to get into CI and Nuget feeds, my company is moving a bunch of code from our internal devops to github, and i'll eventually learn how to do that ;-) although the build is not super complicated anyways. |
So what is the current status of this issue? Any ideas when this feature will be ready? |
I meant when do you plan to make it part of Avalonia itself? |
@josegomez Too bad it's GPL:d 😓
is there interest of integrating it into the platform itself through a PR? Not binding of course, but just as a heads up if you think it belongs in the core library or not. |
@piksel as long as PR uses NativeMenu infrastructure and supports non-clickable icons (i. e. appindicator is only allowed to export a menu, it can't handle actual clicks on the icon), we'll accept it. Most of the infrastructure for Linux and macOS is already there, we support synchronizing NativeMenu items to NSMenu and can export menu items via dbusmenu which is almost the same as appindicator. |
@kekekeks thanks, thats exactly the type pointers I needed. My current implementation does support double-clicking the icon (to restore a minimize-to-tray app). Maybe that could be left as a platform-specific feature (since it's just there to comply with the common UX pattern for the OS). The current implementation executes the menu item command that has a IsDefault property set (attached). |
Just a heads up: |
The windows part of my implementation works but needs some polish, but the macOS and linux platforms turned out to be much harder to do...
You weren't kidding. After several hours trying to get it to work using pure DBUS I finally retorted to using Regarding the macos port, there is a lot of code-generation stuff not documented (afaict) and the native parts written in Objective C. Adding the correct bits is pretty trivial in an ordinary app, but I have yet to figure out how to do it correctly in the avalonia app-stub. |
The issue @seanocali raised is because I wasn't calling true on the blocking for the loop in the demo app. I exposed a wrapper to NSRunloop / windows messages so that you can run notifications in a context where there isn't one already setup. But I never called the blocking call which lowers CPU usage. It's toggle-able incase you are chaining runloop listeners so you can block or peek. I toggled the default to true in the console test app. This is a code block for creating an avalonia application that sits in the tray. Pay attention to OSXAppDelegate, you have to mess around a little bit to create an app that only lives in the OSX dock sometimes. This example requires the MonoMac Nuget. Sometime in the next few weeks I will have a nupkg up, my library also includes TOAST notifications on OSX and windows. Although I am doing more testing on that before pushing it. I am doing just basic Icon/Text notifications. For the reasons @piksel has mentioned, and because we don't have a business case at my work, I have yet to touch attempting to add any linux stuff. Although, it seems the consensus is if you use GTK as a dependency, you will have the most reliable tray notifications, since most DEs try and support as much of GTK/Gnome convention as they can, since it is arguably the most popular DE. GTK notifications work fine in KDE/Cinnamon/Gnome (of course)/XFCE, as I have seen with another application I found on github. Downside is now GTK is a dependency. I hope someone gets good use out of my code ;-). Just ignore the fact I am old school and do extern C apis for pinvoking :-)
|
Is this still planned to be supported directly in Avalonia? |
I love Avalonia, and try to keep it up in productive code. Therefore an official variant would be the best solution. |
I am about to adopt Avalonia as it seems like a true diamond in the rough. |
@MeertenR work has started to add apis for this. |
YOOOO You really did it with this one!!!! |
https://www.freedesktop.org/wiki/Specifications/systemtray-spec/ support for this would be nice, this is the normal spec for linux, not everything supports the kde appindicator spec, without this avalonia apps crash on launch on various window managers |
Hi,
Does Avalonia currently support System Tray Icon (Windows) and Menu Bar Icon (MacOS)? In order to minimize and hide the main app window, but still run in the background?
The text was updated successfully, but these errors were encountered: