aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/ui/syntax/syntaxedit.go
diff options
context:
space:
mode:
authorAlexander Neumann <alexander.neumann@picos-software.com>2019-04-08 15:30:10 +0200
committerAlexander Neumann <alexander.neumann@picos-software.com>2019-04-23 11:04:59 +0200
commit808ff79d554177be79fbcbf5c2b95d50283d811b (patch)
tree18b418b2aeab9850cc19d4b2d9bdf3af44a9c5ea /ui/syntax/syntaxedit.go
parentui: update status and active CIDRs menu items (diff)
downloadwireguard-windows-808ff79d554177be79fbcbf5c2b95d50283d811b.tar.xz
wireguard-windows-808ff79d554177be79fbcbf5c2b95d50283d811b.zip
ui: replace PrivateKeyEvent with walk.StringEvent
Signed-off-by: Alexander Neumann <alexander.neumann@picos-software.com> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to '')
-rw-r--r--ui/syntax/syntaxedit.go39
1 files changed, 2 insertions, 37 deletions
diff --git a/ui/syntax/syntaxedit.go b/ui/syntax/syntaxedit.go
index 95cf576c..5598d7a8 100644
--- a/ui/syntax/syntaxedit.go
+++ b/ui/syntax/syntaxedit.go
@@ -18,45 +18,10 @@ import (
// #include "syntaxedit.h"
import "C"
-type PrivateKeyHandler func(privateKey string)
-type PrivateKeyEvent struct {
- handlers []PrivateKeyHandler
-}
-
-func (e *PrivateKeyEvent) Attach(handler PrivateKeyHandler) int {
- for i, h := range e.handlers {
- if h == nil {
- e.handlers[i] = handler
- return i
- }
- }
-
- e.handlers = append(e.handlers, handler)
- return len(e.handlers) - 1
-}
-func (e *PrivateKeyEvent) Detach(handle int) {
- e.handlers[handle] = nil
-}
-
-type PrivateKeyPublisher struct {
- event PrivateKeyEvent
-}
-
-func (p *PrivateKeyPublisher) Event() *PrivateKeyEvent {
- return &p.event
-}
-func (p *PrivateKeyPublisher) Publish(privateKey string) {
- for _, handler := range p.event.handlers {
- if handler != nil {
- handler(privateKey)
- }
- }
-}
-
type SyntaxEdit struct {
walk.WidgetBase
textChangedPublisher walk.EventPublisher
- privateKeyPublisher PrivateKeyPublisher
+ privateKeyPublisher walk.StringEventPublisher
}
func (se *SyntaxEdit) LayoutFlags() walk.LayoutFlags {
@@ -94,7 +59,7 @@ func (se *SyntaxEdit) TextChanged() *walk.Event {
return se.textChangedPublisher.Event()
}
-func (se *SyntaxEdit) PrivateKeyChanged() *PrivateKeyEvent {
+func (se *SyntaxEdit) PrivateKeyChanged() *walk.StringEvent {
return se.privateKeyPublisher.Event()
}