Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 16 additions & 22 deletions app.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"path/filepath"
"sync"

"github.com/getlantern/systray"
"github.com/masahide/OmniSSHAgent/pkg/cygwinsocket"
"github.com/masahide/OmniSSHAgent/pkg/namedpipe"
"github.com/masahide/OmniSSHAgent/pkg/pageant"
Expand All @@ -17,16 +16,14 @@ import (
"github.com/masahide/OmniSSHAgent/pkg/store"
"github.com/masahide/OmniSSHAgent/pkg/unix"
"github.com/masahide/OmniSSHAgent/pkg/winopen"

//"github.com/masahide/OmniSSHAgent/pkg/wintray"
"github.com/masahide/OmniSSHAgent/icon"
"github.com/masahide/OmniSSHAgent/pkg/wintray"
"github.com/wailsapp/wails/v2/pkg/runtime"
)

// App application struct
type App struct {
ctx context.Context
//ti *wintray.TrayIcon
ctx context.Context
ti *wintray.TrayIcon
keyRing *sshutil.KeyRing
settings *store.Settings
wg sync.WaitGroup
Expand All @@ -37,14 +34,13 @@ func NewApp() *App {
return &App{}
}

func (a *App) systrayOnRedy() {
systray.SetIcon(icon.Data)
systray.SetTitle(AppName)
systray.SetTooltip(AppName)
mShowWindow := systray.AddMenuItem("ShowWindow", "Show main window")
mQuit := systray.AddMenuItem("Quit", "Quit the whole app")
mLogCheckBox := systray.AddMenuItemCheckbox("Debug log", "Enable debug log file output", false)
mLogDirOpen := systray.AddMenuItem("Open log directory", "open log directory")
func (a *App) systrayOnReady() {
a.ti.SetTitle(AppName)
a.ti.SetTooltip(AppName)
mShowWindow := a.ti.AddMenuItem("ShowWindow", "Show main window")
mQuit := a.ti.AddMenuItem("Quit", "Quit the whole app")
mLogCheckBox := a.ti.AddMenuItemCheckbox("Debug log", "Enable debug log file output", false)
mLogDirOpen := a.ti.AddMenuItem("Open log directory", "open log directory")
mLogDirOpen.Disable()
go func() {
for {
Expand Down Expand Up @@ -84,12 +80,10 @@ func (a *App) systrayOnExit() {
func (a *App) startup(ctx context.Context) {
// Perform your setup here
a.ctx = ctx
/*
a.ti = wintray.NewTrayIcon()
a.ti.BalloonClickFunc = a.showWindow
a.ti.TrayClickFunc = a.showWindow
go a.ti.RunTray()
*/
a.ti = wintray.NewTrayIcon()
a.ti.BalloonClickFunc = a.showWindow
a.ti.TrayClickFunc = a.showWindow

a.wg.Add(1)
go func() {
defer func() {
Expand All @@ -98,7 +92,7 @@ func (a *App) startup(ctx context.Context) {
}
a.Quit()
}()
systray.Run(a.systrayOnRedy, a.systrayOnExit)
a.ti.Run(a.systrayOnReady, a.systrayOnExit)
}()

debug := false
Expand Down Expand Up @@ -172,7 +166,7 @@ func (a *App) Quit() {
// shutdown はruntime.Quitから呼ばれる
func (a *App) shutdown(ctx context.Context) {
log.Print("shutdown")
systray.Quit()
a.ti.Quit()
a.wg.Wait()
}

Expand Down
19 changes: 1 addition & 18 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,30 +17,13 @@ require (
golang.org/x/sys v0.20.0
)

require (
github.com/getlantern/context v0.0.0-20220418194847-3d5e7a086201 // indirect
github.com/getlantern/errors v1.0.4 // indirect
github.com/getlantern/golog v0.0.0-20230503153817-8e72de7e0a65 // indirect
github.com/getlantern/hex v0.0.0-20220104173244-ad7e4b9194dc // indirect
github.com/getlantern/hidden v0.0.0-20220104173330-f221c5a24770 // indirect
github.com/getlantern/ops v0.0.0-20231025133620-f368ab734534 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-stack/stack v1.8.1 // indirect
github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c // indirect
go.opentelemetry.io/otel v1.27.0 // indirect
go.opentelemetry.io/otel/metric v1.27.0 // indirect
go.opentelemetry.io/otel/trace v1.27.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.27.0 // indirect
)
require github.com/stretchr/testify v1.9.0 // indirect

require (
github.com/alessio/shellescape v1.4.2 // indirect
github.com/apenwarr/w32 v0.0.0-20190407065021-aa00fece76ab // indirect
github.com/bep/debounce v1.2.1 // indirect
github.com/danieljoos/wincred v1.2.1 // indirect
github.com/getlantern/systray v1.2.2
github.com/go-ole/go-ole v1.3.0 // indirect
github.com/godbus/dbus/v5 v5.1.0 // indirect
github.com/jchv/go-winloader v0.0.0-20210711035445-715c2860da7e // indirect
Expand Down
Loading