try out sync.Once
This commit is contained in:
parent
54bbe72aa8
commit
6127fa1cbb
6
init.go
6
init.go
|
@ -73,9 +73,9 @@ func toolkitInit() {
|
||||||
me.BG.tk = makeNewInternalWidget(me.BG.wId)
|
me.BG.tk = makeNewInternalWidget(me.BG.wId)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SETUP libnotify
|
// SETUP libnotify clock and menu
|
||||||
makeNotifyClock(me.notify.clock.wId)
|
me.notify.clock.once.Do(makeNotifyClock)
|
||||||
makeNotifyMenu(me.notify.menu.wId)
|
me.notify.menu.once.Do(makeNotifyMenu)
|
||||||
|
|
||||||
// PUT INIT DEBUG COOE HERE
|
// PUT INIT DEBUG COOE HERE
|
||||||
var toggle bool
|
var toggle bool
|
||||||
|
|
14
libnotify.go
14
libnotify.go
|
@ -1,10 +1,8 @@
|
||||||
// Copyright 2014 The gocui Authors. All rights reserved.
|
|
||||||
// Copyright 2017-2025 WIT.COM Inc. 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 the GPL 3.0
|
||||||
|
|
||||||
// Use of this source code is governed by a BSD-style
|
// this file implements a libnotify-like menu
|
||||||
// license that can be found in the LICENSE file.
|
// also there is SIGWINCH resizing
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -52,12 +50,12 @@ func makeNewInternalWidget(wId int) *guiWidget {
|
||||||
return tk
|
return tk
|
||||||
}
|
}
|
||||||
|
|
||||||
func makeNotifyClock(wId int) {
|
func makeNotifyClock() {
|
||||||
if me.treeRoot == nil {
|
if me.treeRoot == nil {
|
||||||
log.Info("gogui makeClock() error. treeRoot == nil")
|
log.Info("gogui makeClock() error. treeRoot == nil")
|
||||||
return
|
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.dumpWidget("init() clock")
|
||||||
me.notify.clock.tk.MoveToOffset(0, 0)
|
me.notify.clock.tk.MoveToOffset(0, 0)
|
||||||
me.notify.clock.tk.labelN = time.Now().Format("15:04:05")
|
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 {
|
if me.treeRoot == nil {
|
||||||
log.Info("gogui makeClock() error. treeRoot == nil")
|
log.Info("gogui makeClock() error. treeRoot == nil")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
me.notify.menu.tk = makeNewInternalWidget(wId)
|
me.notify.menu.tk = makeNewInternalWidget(me.notify.menu.wId)
|
||||||
me.notify.menu.tk.dumpWidget("init() menu")
|
me.notify.menu.tk.dumpWidget("init() menu")
|
||||||
w, _ := me.baseGui.Size()
|
w, _ := me.baseGui.Size()
|
||||||
me.notify.menu.tk.MoveToOffset(w-5, me.notify.menu.offsetH)
|
me.notify.menu.tk.MoveToOffset(w-5, me.notify.menu.offsetH)
|
||||||
|
|
|
@ -138,6 +138,7 @@ type dropdown struct {
|
||||||
|
|
||||||
// settings for the dropdown window
|
// settings for the dropdown window
|
||||||
type internalTK struct {
|
type internalTK struct {
|
||||||
|
once sync.Once // for init
|
||||||
tk *guiWidget // where to show STDOUT
|
tk *guiWidget // where to show STDOUT
|
||||||
callerTK *guiWidget // which widget called the dropdown menu
|
callerTK *guiWidget // which widget called the dropdown menu
|
||||||
wId int // the widget id to use
|
wId int // the widget id to use
|
||||||
|
|
Loading…
Reference in New Issue