summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxengineering <me@xengineering.eu>2023-07-09 16:26:52 +0200
committerxengineering <me@xengineering.eu>2023-07-09 16:26:52 +0200
commit4e90179c2c72f6c73f1db302b24bfa0cf75aada7 (patch)
tree90a7d18c3831bb054f5e739738574383bc73cd5f
parentffd41bba908fecc617970cf101d9b63b1db28d40 (diff)
downloadlimox-4e90179c2c72f6c73f1db302b24bfa0cf75aada7.tar
limox-4e90179c2c72f6c73f1db302b24bfa0cf75aada7.tar.zst
limox-4e90179c2c72f6c73f1db302b24bfa0cf75aada7.zip
Introduce separate disconnect button
This prepares the roster view which should contain the disconnect button. The now added button will be moved to this view as soon as it is created.
-rw-r--r--gui.go7
-rw-r--r--limox.go10
2 files changed, 17 insertions, 0 deletions
diff --git a/gui.go b/gui.go
index 8fcfed6..d3f6b2d 100644
--- a/gui.go
+++ b/gui.go
@@ -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)
diff --git a/limox.go b/limox.go
index 4914ff5..d1cbd79 100644
--- a/limox.go
+++ b/limox.go
@@ -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
+}