fyne-io / systray

a cross platfrom Go library to place an icon and menu in the notification area
Apache License 2.0
223 stars 41 forks source link

refactor to allow instances to be created and closed separately #44

Open DeedleFake opened 1 year ago

DeedleFake commented 1 year ago

The intention of this pull request, once it's ready, is to allow individual instances of tray icons to be created and closed without affecting others. This became a problem with my own app that I'm working on because it needed the ability to remove the tray icon while running and potentially create it again later, but I was somewhat disappointed to discover that Quit() uses a sync.Once and can't be called twice.

Once this refactor is finished, the goal is to have a new instance-based API that allows more fine control and to restructure the old API to simply call some default instance, thus allowing full backwards compatibility.

andydotxyz commented 1 year ago

Would it not be easier to just support hiding the menu whilst this is still running? Stopping a GUI event loop complete and then restarting can be really problematic.

DeedleFake commented 1 year ago

Perhaps for some use cases. In my case, the icon can be disabled via user preferences, so it doesn't really make sense to keep the icon around doing nothing when the user has it turned off anyways.

andydotxyz commented 1 year ago

Good point. Looks like a good enabler. As long as the original API continues to work of course :). I too prefer an instance object based API - but it would be nice for this to continue to be a drop-in replacement for the original getlantern project