i forgor to commit sorry

This commit is contained in:
2026-04-06 11:04:53 +01:00
parent 60d6a287e5
commit ce83000e0c
12 changed files with 327 additions and 55 deletions
+25 -12
View File
@@ -16,6 +16,7 @@ import (
"os"
"path/filepath"
"runtime"
"strings"
)
func generatePresenceWidget(p stanza.Packet) gtk.Widgetter {
@@ -67,7 +68,7 @@ func generateMessageWidget(p stanza.Packet) gtk.Widgetter {
if ok {
b := gtk.NewBox(gtk.OrientationHorizontal, 0)
b.Append(gtk.NewLabel(fmt.Sprintf("%s is typing...", JidMustParse(m.From).Resource)))
return b
return b
}
if m.Error.Type != "" {
@@ -95,7 +96,7 @@ func generateMessageWidget(p stanza.Packet) gtk.Widgetter {
rc_box := gtk.NewBox(gtk.OrientationVertical, 0)
reactions := gtk.NewBox(gtk.OrientationHorizontal, 0)
reaction := []string{"👍", "👎", "♥️", "🤣", "😭"}
reaction := []string{"👍", "👎", "♥️", "🤣", "💀"}
for _, v := range reaction {
like := gtk.NewButton()
like.SetLabel(v)
@@ -117,7 +118,15 @@ func generateMessageWidget(p stanza.Packet) gtk.Widgetter {
quote := gtk.NewButtonWithLabel("Quote")
quote.ConnectClicked(func() {
message_en.SetText("> " + m.Body + "\n")
lines := strings.Split(m.Body, "\n")
for i, line := range lines {
quoteline:= "> " + line
lines[i] = quoteline
}
newstr := strings.Join(lines, "\n") + "\n\n"
message_en.SetText(newstr)
})
rc_box.Append(quote)
@@ -170,13 +179,13 @@ func generateMessageWidget(p stanza.Packet) gtk.Widgetter {
im.AddCSSClass("author_img")
authorBox.Append(im)
} else {
im := gtk.NewImageFromPaintable(clientAssets["DefaultAvatar"])
im := createIdenticon(m.From)
im.SetPixelSize(40)
im.AddCSSClass("author_img")
authorBox.Append(im)
}
} else {
im := gtk.NewImageFromPaintable(clientAssets["DefaultAvatar"])
im := createIdenticon(m.From)
im.SetPixelSize(40)
im.AddCSSClass("author_img")
authorBox.Append(im)
@@ -251,25 +260,27 @@ func getAvatar(j, hash string) *gtk.Image { // TODO: This function probably shou
oghash := hash
p, err := ensureCache()
if err != nil {
return gtk.NewImageFromPaintable(clientAssets["FailedAvatar"])
return createIdenticon(j)
}
if hash == "" {
fmt.Println("Hash is nil!")
return gtk.NewImageFromPaintable(clientAssets["DefaultAvatar"])
return createIdenticon(j)
}
_, ok := invalidImages[hash]
if ok {
fmt.Println("Image is invalid")
return gtk.NewImageFromPaintable(clientAssets["FailedAvatar"])
return createIdenticon(j)
}
hash = filepath.Join(p, sanitizefilename.Sanitize(hash))
_, err = os.ReadFile(hash)
if err == nil {
return newImageFromPath(hash)
i := newImageFromPath(hash)
i.AddCSSClass(loadedConfig.CVD.String()+"_CVD")
return i
}
iqResp, err := stanza.NewIQ(stanza.Attrs{
@@ -294,14 +305,14 @@ func getAvatar(j, hash string) *gtk.Image { // TODO: This function probably shou
result := <-mychan
card, ok := result.Payload.(*VCard)
if !ok {
return gtk.NewImageFromPaintable(clientAssets["DefaultAvatar"])
return createIdenticon(j)
}
base64_data := card.Photo.Binval
if card.Photo.Binval == "" || ((card.Photo.Type == "image/svg+xml" || card.Photo.Type == "image/webp") && (runtime.GOOS == "windows" || runtime.GOOS == "netbsd")) {
fmt.Println("Blocking image")
invalidImages[oghash] = true
return gtk.NewImageFromPaintable(clientAssets["FailedAvatar"])
return createIdenticon(j)
}
data, err := base64.StdEncoding.DecodeString(base64_data)
@@ -314,5 +325,7 @@ func getAvatar(j, hash string) *gtk.Image { // TODO: This function probably shou
panic(err)
}
return newImageFromPath(hash)
i := newImageFromPath(hash)
i.AddCSSClass(loadedConfig.CVD.String()+"_CVD")
return i
}