fyne-io / systray

a cross platfrom Go library to place an icon and menu in the notification area
Apache License 2.0
223 stars 41 forks source link

SetTitle not working in another module #68

Closed wilsonsilva closed 8 months ago

wilsonsilva commented 8 months ago

Issue The app has two calls to SetTitle. The first sets the title correctly to "Buggy". The second one, called from another module, should set it to "Working", but it doesn't.

Expected The tray title should say "Working"

Actual The tray title says "Buggy"

Code

// main.go
package main

import (
    "github.com/wilsonsilva/systray-set-title-issue/tray"
)

func main() {
    tray.InitializeAndRun()
    tray.SetTitle("Working")
}
// tray/tray.go
package tray

import (
    "fyne.io/systray"
    "fyne.io/systray/example/icon"
)

func InitializeAndRun() {
    systray.Run(onReady, func() {})
}

func SetTitle(title string) {
    systray.SetTitle(title)
}

func onReady() {
    systray.SetIcon(icon.Data)
    systray.SetTitle("Buggy")
}

Environment

// go.mod
module github.com/wilsonsilva/systray-set-title-issue

go 1.21.4

require (
    fyne.io/systray v1.10.0 // indirect
    github.com/godbus/dbus/v5 v5.0.4 // indirect
    github.com/tevino/abool v1.2.0 // indirect
    golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9 // indirect
)
// go.sum
fyne.io/systray v1.10.0 h1:Yr1D9Lxeiw3+vSuZWPlaHC8BMjIHZXJKkek706AfYQk=
fyne.io/systray v1.10.0/go.mod h1:oM2AQqGJ1AMo4nNqZFYU8xYygSBZkW2hmdJ7n4yjedE=
github.com/godbus/dbus/v5 v5.0.4 h1:9349emZab16e7zQvpmsbtjc18ykshndd8y2PG3sgJbA=
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
github.com/tevino/abool v1.2.0 h1:heAkClL8H6w+mK5md9dzsuohKeXHUpY7Vw0ZCKW+huA=
github.com/tevino/abool v1.2.0/go.mod h1:qc66Pna1RiIsPa7O4Egxxs9OqkuxDX55zznh9K07Tzg=
golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9 h1:YTzHMGlqJu67/uEo1lBv0n3wBXhXNeUbB1XfN2vmTm0=
golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=

MacbookPro M1 Max 16-inch, 2021 MacOS Sonoma 14.0 (23A344)

wilsonsilva commented 8 months ago

This is an extremely simplified version of my code. By opening this issue and rubber-ducking, I realised that I was missing a goroutine.

andydotxyz commented 8 months ago

Glad you got it sorted :)