Skip to content

Commit cda2cb4

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

File tree

8 files changed

+76
-43
lines changed

8 files changed

+76
-43
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: 17 additions & 11 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.
@@ -64,18 +67,21 @@ main() {
6467

6568
mkdir -p $BUILD_DIR/usr/bin || fatal "failed to create $BUILD_DIR/usr/bin"
6669

67-
# Check if the binary isn't named massastation. If it isn't, rename it to massastation.
68-
if [ ! -f $TMP_DIR/usr/local/bin/$MASSASTATION_BINARY_NAME ]; then
69-
mv $TMP_DIR/usr/local/bin/massastation_* $TMP_DIR/usr/local/bin/$MASSASTATION_BINARY_NAME || fatal "failed to rename binary to $MASSASTATION_BINARY_NAME"
70-
fi
71-
cp $TMP_DIR/usr/local/bin/$MASSASTATION_BINARY_NAME $BUILD_DIR/usr/bin || fatal "failed to copy $MASSASTATION_BINARY_NAME to $BUILD_DIR/usr/bin"
70+
# Find and copy the binary
71+
BINARY_PATH=$(find $TMP_DIR -type f -name "$MASSASTATION_BINARY_NAME" -o -name "massastation_*" | head -1)
72+
[ -z "$BINARY_PATH" ] && fatal "failed to find $MASSASTATION_BINARY_NAME binary in $TMP_DIR"
73+
cp "$BINARY_PATH" $BUILD_DIR/usr/bin/$MASSASTATION_BINARY_NAME || fatal "failed to copy $MASSASTATION_BINARY_NAME to $BUILD_DIR/usr/bin"
7274
chmod +x $BUILD_DIR/usr/bin/$MASSASTATION_BINARY_NAME || fatal "failed to make $MASSASTATION_BINARY_NAME executable"
7375

7476
mkdir -p $BUILD_DIR/usr/share/applications || fatal "failed to create $BUILD_DIR/usr/share/applications"
75-
cp $TMP_DIR/usr/local/share/applications/net.massalabs.massastation.desktop $BUILD_DIR/usr/share/applications || fatal "failed to copy net.massalabs.massastation.desktop to $BUILD_DIR/usr/share/applications"
77+
DESKTOP_PATH=$(find $TMP_DIR -type f -name "*.desktop" | head -1)
78+
[ -z "$DESKTOP_PATH" ] && fatal "failed to find .desktop file in $TMP_DIR"
79+
cp "$DESKTOP_PATH" $BUILD_DIR/usr/share/applications/net.massalabs.massastation.desktop || fatal "failed to copy .desktop file to $BUILD_DIR/usr/share/applications"
7680

7781
mkdir -p $BUILD_DIR/usr/share/pixmaps || fatal "failed to create $BUILD_DIR/usr/share/pixmaps"
78-
cp $TMP_DIR/usr/local/share/pixmaps/net.massalabs.massastation.png $BUILD_DIR/usr/share/pixmaps || fatal "failed to copy net.massalabs.massastation.png to $BUILD_DIR/usr/share/pixmaps"
82+
ICON_PATH=$(find $TMP_DIR -type f -name "*.png" | head -1)
83+
[ -z "$ICON_PATH" ] && fatal "failed to find .png icon in $TMP_DIR"
84+
cp "$ICON_PATH" $BUILD_DIR/usr/share/pixmaps/net.massalabs.massastation.png || fatal "failed to copy icon to $BUILD_DIR/usr/share/pixmaps"
7985

8086
mkdir -p $BUILD_DIR/usr/share/doc/massastation || fatal "failed to create $BUILD_DIR/usr/share/doc/massastation"
8187
cp common/MassaStation_ToS.txt $BUILD_DIR/usr/share/doc/massastation/terms-and-conditions.txt || fatal "failed to copy MassaStation_ToS.txt to $BUILD_DIR/usr/share/doc/massastation/terms-and-conditions.txt"

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)