Skip to content

Commit bf54158

Browse files
committed
rework fyne systray menu
1 parent a3e44ab commit bf54158

File tree

8 files changed

+66
-36
lines changed

8 files changed

+66
-36
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ jobs:
9595
uses: actions/upload-artifact@v4
9696
with:
9797
name: massastation_${{ matrix.target }}_${{ matrix.arch }}_package
98-
path: MassaStation.tar.xz
98+
path: massastation.tar.xz
9999
if-no-files-found: error
100100
retention-days: 1
101101

Taskfile.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ tasks:
109109
desc: Packages MassaStation using fyne
110110
platforms: [linux, darwin]
111111
cmds:
112-
- cmd: fyne package -name MassaStation -icon ../../int/systray/embedded/logo.png --app-id net.massalabs.massastation -src ./cmd/massastation {{if .OS}}--os {{.OS}}{{end}}
112+
- cmd: fyne package -src ./cmd/massastation -icon ../../int/systray/embedded/logo.png {{if .OS}}--os {{.OS}}{{end}}
113113

114114
generate-dirs:
115115
desc: Generates required directories for MassaStation
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package main
2+
3+
import (
4+
"strings"
5+
6+
"fyne.io/fyne/v2"
7+
"fyne.io/fyne/v2/app"
8+
9+
"github.com/massalabs/station/int/config"
10+
"github.com/massalabs/station/int/systray/embedded"
11+
)
12+
13+
func init() {
14+
app.SetMetadata(fyne.AppMetadata{
15+
ID: "net.massalabs.massastation",
16+
Name: "MassaStation",
17+
Version: config.Version,
18+
Build: 1,
19+
Icon: &fyne.StaticResource{
20+
StaticName: "logo.png",
21+
StaticContent: embedded.Logo,
22+
},
23+
Release: !strings.Contains(config.Version, "dev"),
24+
})
25+
}

installer/deb/create_deb.sh

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ BUILD_DIR=builddeb
88
TMP_DIR=tmpdeb
99
PKGVERSION=0.0.0-dev
1010

11-
MASSASTATION_ARCHIVE_NAME=MassaStation.tar.xz
11+
MASSASTATION_ARCHIVE_NAME=massastation.tar.xz
1212
MASSASTATION_BINARY_NAME=massastation
1313

1414
# Print error message to stderr and exit with code 1.
@@ -19,7 +19,8 @@ fatal() {
1919

2020
# Install dependencies required to build the MassaStation binary.
2121
install_massastation_build_dependencies() {
22-
sudo apt-get install libgl1-mesa-dev xorg-dev -y || fatal "failed to install libgl1-mesa-dev xorg-dev"
22+
sudo apt-get update || fatal "failed to update apt"
23+
sudo apt-get install -y --fix-missing libgl1-mesa-dev xorg-dev || fatal "failed to install libgl1-mesa-dev xorg-dev"
2324
go install fyne.io/tools/cmd/fyne@v1.7.0 || fatal "failed to install fyne.io/tools/cmd/fyne@v1.7.0"
2425
go install github.com/go-swagger/go-swagger/cmd/swagger@latest || fatal "failed to install github.com/go-swagger/go-swagger/cmd/swagger@latest"
2526
go install golang.org/x/tools/cmd/stringer@latest || fatal "failed to install golang.org/x/tools/cmd/stringer@latest"
@@ -29,11 +30,13 @@ install_massastation_build_dependencies() {
2930
build_massastation() {
3031
install_massastation_build_dependencies
3132

33+
# Ensure go install binaries are in PATH
34+
export PATH="$PATH:$(go env GOPATH)/bin"
35+
3236
go generate ../... || fatal "go generate failed for $MASSASTATION_BINARY_NAME"
3337
export GOARCH=$ARCH
3438
export CGO_ENABLED=1
35-
# -icon is based on the path of the -src flag.
36-
fyne package -icon ../../int/systray/embedded/logo.png -name MassaStation --app-id com.massalabs.massastation -src ../cmd/massastation || fatal "fyne package failed for $MASSASTATION_BINARY_NAME"
39+
fyne package -src ../cmd/massastation -icon ../../int/systray/embedded/logo.png || fatal "fyne package failed for $MASSASTATION_BINARY_NAME"
3740
}
3841

3942
# Delete the build directory if it exists.

installer/macos/create_pkg.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,7 @@ build_massastation() {
4949
go generate ../... || fatal "go generate failed for $MASSASTATION_APPLICATION_NAME"
5050
export GOARCH=$ARCH
5151
export CGO_ENABLED=1
52-
# -icon is based on the path of the -src flag.
53-
fyne package -icon ../../int/systray/embedded/logo.png -name MassaStation --app-id com.massalabs.massastation -src ../cmd/massastation || fatal "fyne package failed for $MASSASTATION_APPLICATION_NAME"
52+
fyne package -src ../cmd/massastation -icon ../../int/systray/embedded/logo.png || fatal "fyne package failed for $MASSASTATION_APPLICATION_NAME"
5453
chmod +x $MASSASTATION_APPLICATION_NAME || fatal "failed to chmod $MASSASTATION_APPLICATION_NAME"
5554
}
5655

int/systray/systray.go

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,36 +11,26 @@ import (
1111

1212
func MakeGUI() (fyne.App, *fyne.Menu) {
1313
stationGUI := app.New()
14-
menu := fyne.NewMenu("MassaStation")
1514

1615
if desk, ok := stationGUI.(fyneDesktop.App); ok {
1716
icon := fyne.NewStaticResource("logo", embedded.Logo)
18-
titleMenu := fyne.NewMenuItem("MassaStation", nil)
19-
homeShortCutMenu := fyne.NewMenuItem("Open MassaStation", nil)
20-
testMenu := fyne.NewMenuItem("Test", nil)
21-
22-
titleMenu.Disabled = true
23-
titleMenu.Icon = icon
24-
25-
testMenu.Action = func() {
26-
notification := fyne.NewNotification("Test notification", "This is a test notification from MassaStation")
27-
stationGUI.SendNotification(notification)
28-
}
2917

18+
homeShortCutMenu := fyne.NewMenuItem("Open MassaStation", nil)
3019
homeShortCutMenu.Action = func() {
3120
utils.OpenURL(&stationGUI, "https://"+config.MassaStationURL)
3221
}
3322

34-
menu.Items = append(menu.Items,
35-
titleMenu,
23+
menu := fyne.NewMenu(
24+
"MassaStation",
3625
fyne.NewMenuItemSeparator(),
3726
homeShortCutMenu,
38-
// testMenu,
3927
)
4028

4129
desk.SetSystemTrayIcon(icon)
4230
desk.SetSystemTrayMenu(menu)
31+
32+
return stationGUI, menu
4333
}
4434

45-
return stationGUI, menu
35+
return stationGUI, nil
4636
}

int/systray/update/update_check.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,12 @@ func StartUpdateCheck(app *fyne.App, systrayMenu *fyne.Menu) {
125125
return
126126
}
127127

128+
// If systrayMenu is nil (e.g., desktop interface assertion failed), skip update checks.
129+
if systrayMenu == nil {
130+
logger.Debug("Systray menu is nil, skipping update checks")
131+
return
132+
}
133+
128134
// We check for updates on startup.
129135
updateCheck(app, systrayMenu)
130136

web/massastation/package-lock.json

Lines changed: 19 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)