summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-03-03 23:50:11 -0600
committerJeff Carr <[email protected]>2025-03-03 23:50:11 -0600
commit6127fa1cbb8a68f0b125f50b760822828c7f20e5 (patch)
tree0d636d5b50a84a8969bc4e854a6532680c701726
parent54bbe72aa8fe60c21e3bca46a5455a2965859c5b (diff)
try out sync.Once
-rw-r--r--init.go6
-rw-r--r--libnotify.go14
-rw-r--r--structs.go1
3 files changed, 10 insertions, 11 deletions
diff --git a/init.go b/init.go
index 3580116..e549b18 100644
--- a/init.go
+++ b/init.go
@@ -73,9 +73,9 @@ func toolkitInit() {
me.BG.tk = makeNewInternalWidget(me.BG.wId)
}
- // SETUP libnotify
- makeNotifyClock(me.notify.clock.wId)
- makeNotifyMenu(me.notify.menu.wId)
+ // SETUP libnotify clock and menu
+ me.notify.clock.once.Do(makeNotifyClock)
+ me.notify.menu.once.Do(makeNotifyMenu)
// PUT INIT DEBUG COOE HERE
var toggle bool
diff --git a/libnotify.go b/libnotify.go
index 487c429..5bfa077 100644
--- a/libnotify.go
+++ b/libnotify.go
@@ -1,10 +1,8 @@
-// Copyright 2014 The gocui Authors. All rights reserved.
// Copyright 2017-2025 WIT.COM Inc. All rights reserved.
// Use of this source code is governed by the GPL 3.0
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
+// this file implements a libnotify-like menu
+// also there is SIGWINCH resizing
package main
import (
@@ -52,12 +50,12 @@ func makeNewInternalWidget(wId int) *guiWidget {
return tk
}
-func makeNotifyClock(wId int) {
+func makeNotifyClock() {
if me.treeRoot == nil {
log.Info("gogui makeClock() error. treeRoot == nil")
return
}
- me.notify.clock.tk = makeNewInternalWidget(wId)
+ me.notify.clock.tk = makeNewInternalWidget(me.notify.clock.wId)
me.notify.clock.tk.dumpWidget("init() clock")
me.notify.clock.tk.MoveToOffset(0, 0)
me.notify.clock.tk.labelN = time.Now().Format("15:04:05")
@@ -69,12 +67,12 @@ func makeNotifyClock(wId int) {
}
-func makeNotifyMenu(wId int) {
+func makeNotifyMenu() {
if me.treeRoot == nil {
log.Info("gogui makeClock() error. treeRoot == nil")
return
}
- me.notify.menu.tk = makeNewInternalWidget(wId)
+ me.notify.menu.tk = makeNewInternalWidget(me.notify.menu.wId)
me.notify.menu.tk.dumpWidget("init() menu")
w, _ := me.baseGui.Size()
me.notify.menu.tk.MoveToOffset(w-5, me.notify.menu.offsetH)
diff --git a/structs.go b/structs.go
index dd9ed14..4e72e80 100644
--- a/structs.go
+++ b/structs.go
@@ -138,6 +138,7 @@ type dropdown struct {
// settings for the dropdown window
type internalTK struct {
+ once sync.Once // for init
tk *guiWidget // where to show STDOUT
callerTK *guiWidget // which widget called the dropdown menu
wId int // the widget id to use