aboutsummaryrefslogtreecommitdiffstats
path: root/example
diff options
context:
space:
mode:
authorjoesis2017-08-28 15:02:45 +0800
committerGitHub2017-08-28 15:02:45 +0800
commit6f1d1d82e189395fa6266fcdb665a50531918d25 (patch)
tree7bb33595a16c1a57b4454f014b48fc08e1ec2406 /example
parent0068f6ae40ea39bfd683043e8452024097fff0e4 (diff)
parente78cfcfa229acdd9af7489540c20419ee5cb05a8 (diff)
downloadsystray-6f1d1d82e189395fa6266fcdb665a50531918d25.tar.bz2
Merge pull request #29 from getlantern/flashlight-258
Exit handling improvements
Diffstat (limited to 'example')
-rw-r--r--example/main.go14
1 files changed, 12 insertions, 2 deletions
diff --git a/example/main.go b/example/main.go
index 01b9ee8..4b927da 100644
--- a/example/main.go
+++ b/example/main.go
@@ -2,14 +2,23 @@ package main
import (
"fmt"
+ "io/ioutil"
+ "time"
+
"github.com/getlantern/systray"
"github.com/getlantern/systray/example/icon"
"github.com/skratchdot/open-golang/open"
)
func main() {
+ onExit := func() {
+ fmt.Println("Starting onExit")
+ now := time.Now()
+ ioutil.WriteFile(fmt.Sprintf(`on_exit_%d.txt`, now.UnixNano()), []byte(now.String()), 0644)
+ fmt.Println("Finished onExit")
+ }
// Should be called at the very beginning of main().
- systray.Run(onReady)
+ systray.Run(onReady, onExit)
}
func onReady() {
@@ -19,8 +28,9 @@ func onReady() {
mQuit := systray.AddMenuItem("Quit", "Quit the whole app")
go func() {
<-mQuit.ClickedCh
+ fmt.Println("Requesting quit")
systray.Quit()
- fmt.Println("Quit now...")
+ fmt.Println("Finished quitting")
}()
// We can manipulate the systray in other goroutines