diff --git a/gtk-helpers.go b/gtk-helpers.go index 984ef0b..119cb30 100644 --- a/gtk-helpers.go +++ b/gtk-helpers.go @@ -5,6 +5,7 @@ import ( "fmt" "github.com/diamondburned/gotk4/pkg/glib/v2" "github.com/diamondburned/gotk4/pkg/gtk/v4" + "github.com/diamondburned/gotk4/pkg/pango" "gosrc.io/xmpp/stanza" ) @@ -19,7 +20,9 @@ func scrollToBottomAfterUpdate(scrolledWindow *gtk.ScrolledWindow) { func createTab(jid string, isMuc bool) bool { fmt.Println("Creating tab", jid, "isMuc:", isMuc) _, ok := tabs.Load(jid) - if !ok { + _, uok := userdevices.Load(jid) + _, mok := mucmembers.Load(jid) + if !ok && !uok && !mok { newTab := new(chatTab) newTab.isMuc = isMuc newTab.msgs = gtk.NewListBox() @@ -60,6 +63,7 @@ func switchToTab(jid string, w *gtk.Window) { u.Get(&ocu) nick_label := gtk.NewLabel(JidMustParse(u.From).Resource) + nick_label.SetEllipsize(pango.EllipsizeEnd) /* affil_label := gtk.NewLabel("") switch mu.MucUserItem.Affiliation { diff --git a/main.go b/main.go index e4b3df6..f55a69e 100644 --- a/main.go +++ b/main.go @@ -11,7 +11,6 @@ import ( "github.com/diamondburned/gotk4/pkg/glib/v2" "github.com/diamondburned/gotk4/pkg/gtk/v4" "github.com/diamondburned/gotk4/pkg/gdkpixbuf/v2" - _ "github.com/kr/pretty" "path/filepath" "github.com/BurntSushi/toml" @@ -86,6 +85,7 @@ var cancelBytes []byte var cancelB64 string = base64.StdEncoding.EncodeToString(cancelBytes) var clientAssets map[string]gdk.Paintabler = make(map[string]gdk.Paintabler) +var lockedJIDs map[string]bool = make(map[string]bool) func init() { go func() { @@ -187,7 +187,7 @@ func main() { Jid: loadedConfig.Username + "/lambda." + str, Credential: xmpp.Password(loadedConfig.Password), Insecure: loadedConfig.Insecure, - StreamLogger: os.Stdout, + // StreamLogger: os.Stdout, } router := xmpp.NewRouter() @@ -317,7 +317,6 @@ func main() { } else { typed_unit.Members.Delete(ocu.ID) glib.IdleAdd(func() { - //uiQueue <- func() { b := gtk.NewLabel("") ba, ok := generatePresenceWidget(p).(*gtk.Label) if ok { @@ -333,7 +332,6 @@ func main() { } else { fmt.Println("Got message when the tab does not exist!") } - //} }) } @@ -346,7 +344,7 @@ func main() { _, mok := mucmembers.Load(user) if !ok && !mok { // FIXME: The initial muc presence gets picked up from this check ok := createTab(user, false) - if ok { + if ok && !lockedJIDs[user]{ userdevices.Store(user, userUnit{}) b := gtk.NewButtonWithLabel(user) @@ -374,6 +372,7 @@ func main() { } userdevices.Store(user, typed_unit) + lockedJIDs[user] = true } time.Sleep(1 * time.Second) })