From bb9b5f633f5a53fa4515d86aee1f86c517a4543d Mon Sep 17 00:00:00 2001 From: Andy Williams Date: Mon, 17 Jun 2024 19:34:43 +0100 Subject: [PATCH] support checks in the menu --- modules/systray/main.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/systray/main.go b/modules/systray/main.go index 08cf8f65..e190f58e 100644 --- a/modules/systray/main.go +++ b/modules/systray/main.go @@ -233,8 +233,13 @@ func (t *tray) parseMenuItem(id int32, menu *menu.Dbusmenu, in interface{}, pos } } else { ret.Label = fmt.Sprintf("%s", data["label"].Value()) + if checkType, ok := data["toggle-type"]; ok && checkType.Value() == "checkmark" { + if checkState, ok := data["toggle-state"]; ok && checkState.Value().(int32) > 0 { + ret.Checked = true + } + } ret.Action = func() { - err := menu.Event(t.conn.Context(), int32(id), "clicked", dbus.MakeVariant(id), uint32(time.Now().Unix())) + err := menu.Event(t.conn.Context(), id, "clicked", dbus.MakeVariant(id), uint32(time.Now().Unix())) if err != nil { fyne.LogError("Failed to message menu tap", err) }