diff options
-rw-r--r-- | gui.go | 7 | ||||
-rw-r--r-- | limox.go | 10 |
2 files changed, 17 insertions, 0 deletions
@@ -49,6 +49,13 @@ func (l *Limox) draw(e system.FrameEvent) { return btn.Layout(gtx) }, ), + layout.Rigid( + func(gtx layout.Context) layout.Dimensions { + btn := material.Button(l.Theme, &l.DisconnectButton, + "Disconnect") + return btn.Layout(gtx) + }, + ), ) e.Frame(gtx.Ops) @@ -26,6 +26,7 @@ type Limox struct { JidEditor widget.Editor PwdEditor widget.Editor ConnectButton widget.Clickable + DisconnectButton widget.Clickable sessionIn chan<- any sessionOut chan any State LimoxState @@ -63,6 +64,9 @@ func (l *Limox) run() error { if l.ConnectButton.Clicked() { l.connectCallback() } + if l.DisconnectButton.Clicked() { + l.disconnectCallback() + } l.draw(e) } case data := <-l.sessionOut: @@ -97,3 +101,9 @@ func (l *Limox) connectCallback() { l.State = Disconnected } } + +func (l *Limox) disconnectCallback() { + c := l.sessionIn + go func() { c <- xmpp.SessionShouldDisconnect{} }() + l.State = Disconnected +} |