format + allow closing
This commit is contained in:
+32
-3
@@ -14,9 +14,9 @@ import (
|
||||
"github.com/rrivera/identicon"
|
||||
"gosrc.io/xmpp/stanza"
|
||||
"image"
|
||||
"image/color"
|
||||
"image/png"
|
||||
xmpp_color "mellium.im/xmpp/color"
|
||||
"image/color"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
@@ -54,6 +54,34 @@ func createTab(jid string, isMuc bool, name string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func removeTab(jid string, w *gtk.Window) {
|
||||
t, ok := tabs.Load(jid)
|
||||
if ok {
|
||||
tab := t.(*chatTab)
|
||||
tab.msgs.RemoveAll()
|
||||
if tab.isMuc {
|
||||
client.SendRaw(fmt.Sprintf(`
|
||||
<presence from='%s' to='%s' type='unavailable'>
|
||||
<x xmlns='http://jabber.org/protocol/muc'/>
|
||||
</presence>
|
||||
`, clientroot.Session.BindJid, jid+"/"+tab.current_nick))
|
||||
}
|
||||
|
||||
tabs.Delete(jid)
|
||||
mucmembers.Delete(jid)
|
||||
userdevices.Delete(jid)
|
||||
|
||||
if current == jid {
|
||||
current = ""
|
||||
scroller.SetChild(empty_dialog)
|
||||
typingStatus.SetText("")
|
||||
memberList.SetChild(gtk.NewLabel(""))
|
||||
}
|
||||
|
||||
mucmembers.Delete(jid)
|
||||
}
|
||||
}
|
||||
|
||||
func switchToTab(jid string, w *gtk.Window) {
|
||||
current = jid
|
||||
tab, ok := tabs.Load(current)
|
||||
@@ -160,7 +188,6 @@ func switchToTab(jid string, w *gtk.Window) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
status := gtk.NewImageFromPaintable(clientAssets["status_"+string(u.Show)])
|
||||
status.SetTooltipText(string(u.Show))
|
||||
|
||||
@@ -521,6 +548,7 @@ func switchToTab(jid string, w *gtk.Window) {
|
||||
gen.Prepend(muci)
|
||||
muc_name := gtk.NewLabel(typed_tab.name)
|
||||
muc_name.AddCSSClass("author")
|
||||
muc_name.SetWrap(true)
|
||||
gen.Prepend(muc_name)
|
||||
memberList.SetChild(gen)
|
||||
} else {
|
||||
@@ -529,7 +557,7 @@ func switchToTab(jid string, w *gtk.Window) {
|
||||
|
||||
}
|
||||
|
||||
func showErrorDialog(err error) {
|
||||
func showErrorDialog(err error, w *gtk.Window) {
|
||||
err_win := gtk.NewWindow()
|
||||
err_win.SetTitle(loadedLocale["error"])
|
||||
err_win.SetDefaultSize(400, 200)
|
||||
@@ -546,6 +574,7 @@ func showErrorDialog(err error) {
|
||||
})
|
||||
box.Append(close_btn)
|
||||
err_win.SetChild(box)
|
||||
err_win.SetTransientFor(w)
|
||||
err_win.Present()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user