can we pretend that airplanes in the night sky are like shooting stars

This commit is contained in:
2026-08-20 11:01:25 +01:00
parent 58ae55e061
commit 2717137270
10 changed files with 195 additions and 92 deletions
+42 -28
View File
@@ -18,6 +18,7 @@ import (
"path/filepath"
"runtime"
"strings"
"time"
)
func generatePresenceWidget(p stanza.Packet) gtk.Widgetter {
@@ -247,10 +248,6 @@ func generateMessageWidget(p stanza.Packet, blocked bool, target string) (gtk.Wi
if loadedConfig.CompactMode {
if m.Body == "" {
/*
mlabel.SetText(loadedLocale["noBodySet"])
mlabel.AddCSSClass("visitor")
*/
return nil, false
}
al := gtk.NewLabel(name)
@@ -274,9 +271,20 @@ func generateMessageWidget(p stanza.Packet, blocked bool, target string) (gtk.Wi
// mlabel.SetHAlign(gtk.AlignFill)
mainBox.Append(mlabel)
// TODO: Decouple this from widget generation
if store_label {
typed_tab.msg_refsID[m.Id].label_ref = mlabel
tabs.Store(target, tab)
msg, ok := typed_tab.msg_refsID[m.Id]
if !ok {
msg = new(abMessage)
typed_tab.msg_refsID[m.Id] = msg
}
msg.label_ref = mlabel
msg.ocu_id = ocu.ID
if sid.ID != "" {
typed_tab.msg_refsOSID[sid.ID] = msg
}
}
} else {
authorBox := gtk.NewBox(gtk.OrientationHorizontal, 10)
@@ -318,11 +326,6 @@ func generateMessageWidget(p stanza.Packet, blocked bool, target string) (gtk.Wi
}
} else {
createIdenticon(m.From, false, im)
/*
im.SetPixelSize(40)
im.AddCSSClass("author_img")
authorBox.Append(im)
*/
}
} else if m.Type == stanza.MessageTypeChat {
al.SetText(al.Text() + loadedLocale["whispers"])
@@ -348,10 +351,6 @@ func generateMessageWidget(p stanza.Packet, blocked bool, target string) (gtk.Wi
mlabel := gtk.NewLabel("")
if m.Body == "" {
/*
mlabel.SetText(loadedLocale["noBodySet"])
mlabel.AddCSSClass("visitor")
*/
return nil, false
}
@@ -360,6 +359,7 @@ func generateMessageWidget(p stanza.Packet, blocked bool, target string) (gtk.Wi
mlabel.SetSelectable(true)
mlabel.SetHAlign(gtk.AlignFill)
// TODO: Decouple this from widget generation
if store_label {
msg, ok := typed_tab.msg_refsID[m.Id]
if !ok {
@@ -369,8 +369,12 @@ func generateMessageWidget(p stanza.Packet, blocked bool, target string) (gtk.Wi
msg.label_ref = mlabel
msg.ocu_id = ocu.ID
tabs.Store(target, typed_tab)
if sid.ID != "" {
typed_tab.msg_refsOSID[sid.ID] = msg
}
}
contentBox.Append(mlabel)
mainBox.Append(authorBox)
@@ -478,14 +482,6 @@ func getAvatar(j, hash string, i *gtk.Image) { // TODO: This function probably s
_, err = os.ReadFile(hash)
if err == nil {
/*
i, err = newImageFromPath(hash)
if err != nil {
invalidImages.Store(oghash, true)
createIdenticon(j, false, i)
}
*/
glib.IdleAdd(func() {
setImageFromPath(hash, i)
})
@@ -506,12 +502,30 @@ func getAvatar(j, hash string, i *gtk.Image) { // TODO: This function probably s
iqResp.Payload = &VCard{}
ctx := context.TODO()
mychan, err := client.SendIQ(ctx, iqResp)
ctx := context.Background()
timeoutctx, cancel := context.WithTimeout(ctx, time.Second*30)
defer cancel()
mychan, err := client.SendIQ(timeoutctx, iqResp)
if err != nil {
panic(err)
createIdenticon(j, false, i)
return
// panic(err)
}
result := <-mychan
var result stanza.IQ
select {
case <-timeoutctx.Done():
createIdenticon(j, false, i)
return
case result = <-mychan:
if result.Error != nil {
createIdenticon(j, false, i)
return
}
}
card, ok := result.Payload.(*VCard)
if !ok {
createIdenticon(j, false, i)