From 83f68cca4a459b66f498d5d33e1f21ac88cb9012 Mon Sep 17 00:00:00 2001 From: Aaron Bieber Date: Wed, 30 Oct 2024 07:24:25 -0600 Subject: [PATCH] add enable/disable functions to unify the behaviors --- main.go | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/main.go b/main.go index 60e746e..730b10d 100644 --- a/main.go +++ b/main.go @@ -42,6 +42,19 @@ func main() { } var desk desktop.App + + disable := func() { + enabled = false + icon.Enabled = enabled + desk.SetSystemTrayIcon(icon.Draw(0.0)) + systray.SetTooltip("Disabled") + } + + enable := func() { + enabled = true + icon.Enabled = enabled + } + if !*makeIcon { a := app.New() driver := fyne.CurrentApp().Driver().(desktop.Driver) @@ -53,12 +66,10 @@ func main() { desk.SetSystemTrayMenu( fyne.NewMenu("fynado", fyne.NewMenuItem("Enable", func() { - enabled = true - icon.Enabled = enabled + enable() }), fyne.NewMenuItem("Disable", func() { - enabled = false - icon.Enabled = enabled + disable() }), ), ) @@ -98,11 +109,9 @@ func main() { container.NewBorder(timerText, nil, nil, nil), container.NewBorder(roundsText, nil, nil, nil), container.NewBorder(nil, widget.NewButton("Extended Break", func() { - enabled = false rounds = 0 w.Hide() - desk.SetSystemTrayIcon(icon.Draw(0.0)) - systray.SetTooltip("Disabled") + disable() }), nil, nil), )), ),