mirror of
https://github.com/stashapp/stash.git
synced 2025-12-06 16:34:02 +01:00
Fix exit from systray (#4337)
This commit is contained in:
parent
d4ef182871
commit
ccb1b7c3c4
3 changed files with 15 additions and 10 deletions
|
|
@ -23,7 +23,7 @@ type FaviconProvider interface {
|
|||
|
||||
// Start starts the desktop icon process. It blocks until the process exits.
|
||||
// MUST be run on the main goroutine or will have no effect on macOS
|
||||
func Start(exit chan<- int, faviconProvider FaviconProvider) {
|
||||
func Start(exit chan int, faviconProvider FaviconProvider) {
|
||||
if IsDesktop() {
|
||||
hideConsole()
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
package desktop
|
||||
|
||||
func startSystray(exit chan<- int, favicon FaviconProvider) {
|
||||
func startSystray(exit chan int, favicon FaviconProvider) {
|
||||
// The systray is not available on Linux because the required libraries (libappindicator3 and gtk+3.0)
|
||||
// are not able to be statically compiled. Technically, the systray works perfectly fine when dynamically
|
||||
// linked, but we cannot distribute it for compatibility reasons.
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ import (
|
|||
)
|
||||
|
||||
// MUST be run on the main goroutine or will have no effect on macOS
|
||||
func startSystray(exit chan<- int, faviconProvider FaviconProvider) {
|
||||
func startSystray(exit chan int, faviconProvider FaviconProvider) {
|
||||
// Shows a small notification to inform that Stash will no longer show a terminal window,
|
||||
// and instead will be available in the tray. Will only show the first time a pre-desktop integration
|
||||
// system is started from a non-terminal method, e.g. double-clicking an icon.
|
||||
|
|
@ -23,7 +23,7 @@ func startSystray(exit chan<- int, faviconProvider FaviconProvider) {
|
|||
SendNotification("Stash has moved!", "Stash now runs in your tray, instead of a terminal window.")
|
||||
c.Set(config.ShowOneTimeMovedNotification, false)
|
||||
if err := c.Write(); err != nil {
|
||||
logger.Errorf("Error while writing configuration file: %s", err.Error())
|
||||
logger.Errorf("Error while writing configuration file: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -37,12 +37,17 @@ func startSystray(exit chan<- int, faviconProvider FaviconProvider) {
|
|||
// }
|
||||
// }()
|
||||
|
||||
for {
|
||||
// "intercept" an exit code to quit the systray, allowing the call to systray.Run() below to return.
|
||||
go func() {
|
||||
exitCode := <-exit
|
||||
systray.Quit()
|
||||
exit <- exitCode
|
||||
}()
|
||||
|
||||
systray.Run(func() {
|
||||
systrayInitialize(exit, faviconProvider)
|
||||
}, nil)
|
||||
}
|
||||
}
|
||||
|
||||
func systrayInitialize(exit chan<- int, faviconProvider FaviconProvider) {
|
||||
favicon := faviconProvider.GetFavicon()
|
||||
|
|
@ -85,8 +90,8 @@ func systrayInitialize(exit chan<- int, faviconProvider FaviconProvider) {
|
|||
case <-openStashButton.ClickedCh:
|
||||
openURLInBrowser("")
|
||||
case <-quitStashButton.ClickedCh:
|
||||
systray.Quit()
|
||||
exit <- 0
|
||||
return
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
|
|
|||
Loading…
Reference in a new issue