From 808ff79d554177be79fbcbf5c2b95d50283d811b Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Mon, 8 Apr 2019 15:30:10 +0200 Subject: ui: replace PrivateKeyEvent with walk.StringEvent Signed-off-by: Alexander Neumann Signed-off-by: Jason A. Donenfeld --- ui/syntax/syntaxedit.go | 39 ++------------------------------------- 1 file 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() } -- cgit v1.2.3-59-g8ed1b