Add hat icon, change some CSS and remove all reply support
This commit is contained in:
@@ -3,3 +3,5 @@
|
||||
an XMPP client
|
||||
|
||||
icons are from Psi+ ([https://github.com/psi-im](https://github.com/psi-im))
|
||||
|
||||
additional icons are by Mark James's Silk Icon Set [https://peacocksoftware.com/sites/peacocksoftware/silk_icons/comment.png](https://peacocksoftware.com/sites/peacocksoftware/silk_icons/comment.png)
|
||||
|
||||
BIN
assets/tag.png
Normal file
BIN
assets/tag.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 666 B |
@@ -2,6 +2,8 @@ package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/sha1"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"github.com/diamondburned/gotk4/pkg/glib/v2"
|
||||
"github.com/diamondburned/gotk4/pkg/gtk/v4"
|
||||
@@ -105,11 +107,28 @@ func switchToTab(jid string, w *gtk.Window) {
|
||||
userbox.Append(nick_label)
|
||||
// userbox.Append(affil_label)
|
||||
|
||||
var hats Hats
|
||||
ok := u.Get(&hats)
|
||||
if ok {
|
||||
for _, hat := range hats.Hats {
|
||||
tag := gtk.NewImageFromPaintable(clientAssets["tag"])
|
||||
tag.SetTooltipText(hat.Title)
|
||||
// tag.SetHAlign(gtk.AlignEnd)
|
||||
// tag.SetHExpand(true)
|
||||
userbox.Prepend(tag)
|
||||
}
|
||||
}
|
||||
|
||||
medal := gtk.NewImageFromPaintable(clientAssets[mu.MucUserItem.Affiliation])
|
||||
medal.SetTooltipText(mu.MucUserItem.Affiliation)
|
||||
|
||||
medal.SetHAlign(gtk.AlignEnd)
|
||||
medal.SetHExpand(true)
|
||||
userbox.Append(medal)
|
||||
|
||||
|
||||
|
||||
|
||||
gesture := gtk.NewGestureClick()
|
||||
gesture.SetButton(3) // Right click
|
||||
|
||||
@@ -143,7 +162,9 @@ func switchToTab(jid string, w *gtk.Window) {
|
||||
ok := u.Get(&hats)
|
||||
if ok {
|
||||
for _, hat := range hats.Hats {
|
||||
profile_box.Append(gtk.NewLabel(hat.Title))
|
||||
l := gtk.NewLabel(hat.Title)
|
||||
l.AddCSSClass("hat")
|
||||
profile_box.Append(l)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -157,6 +178,43 @@ func switchToTab(jid string, w *gtk.Window) {
|
||||
profile_box.Append(gtk.NewLabel("Affiliated as " + mu.MucUserItem.Affiliation))
|
||||
}
|
||||
|
||||
go func() {
|
||||
fmt.Println("Attempting to get Disco info")
|
||||
|
||||
myIQ, err := stanza.NewIQ(stanza.Attrs{
|
||||
Type: "get",
|
||||
From: clientroot.Session.BindJid,
|
||||
To: u.From,
|
||||
Id: "dicks",
|
||||
Lang: "en",
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
myIQ.Payload = &stanza.DiscoInfo{}
|
||||
|
||||
ctx := context.TODO()
|
||||
mychan, err := client.SendIQ(ctx, myIQ)
|
||||
if err == nil {
|
||||
result := <-mychan
|
||||
res, ok := result.Payload.(*stanza.DiscoInfo)
|
||||
if ok {
|
||||
idents := res.Identity
|
||||
for i, ident := range idents {
|
||||
profile_box.Append(gtk.NewLabel(fmt.Sprintf("Identity %d: Name: %s, Category: %s, Type: %s", i+1, ident.Name, ident.Category, ident.Type)))
|
||||
}
|
||||
|
||||
s := fmt.Sprintf("%v", res.Features)
|
||||
h := sha1.New()
|
||||
h.Write([]byte(s))
|
||||
sha1_hash := hex.EncodeToString(h.Sum(nil))
|
||||
profile_box.Append(gtk.NewLabel(fmt.Sprintf("The hash of this user's Disco features is:\n%s\nUse the disco feature to view them", sha1_hash)))
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
go func() {
|
||||
ctx := context.TODO()
|
||||
mychan, err := client.SendIQ(ctx, iqResp)
|
||||
@@ -169,9 +227,7 @@ func switchToTab(jid string, w *gtk.Window) {
|
||||
version := ver.Version
|
||||
os := ver.OS
|
||||
|
||||
profile_box.Append(gtk.NewLabel(name))
|
||||
profile_box.Append(gtk.NewLabel(version))
|
||||
profile_box.Append(gtk.NewLabel(os))
|
||||
profile_box.Append(gtk.NewLabel(fmt.Sprintf("%s %s %s", name, version, os)))
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
@@ -6,8 +6,8 @@ import (
|
||||
"context"
|
||||
"encoding/base64"
|
||||
"fmt"
|
||||
"github.com/diamondburned/gotk4/pkg/gtk/v4"
|
||||
"github.com/diamondburned/gotk4/pkg/gdk/v4"
|
||||
"github.com/diamondburned/gotk4/pkg/gtk/v4"
|
||||
"github.com/google/uuid"
|
||||
"github.com/jacoblockett/sanitizefilename"
|
||||
"github.com/jasonlovesdoggo/gopen"
|
||||
@@ -54,9 +54,9 @@ func generateMessageWidget(p stanza.Packet) gtk.Widgetter {
|
||||
return b
|
||||
}
|
||||
|
||||
indicator := stanza.StateComposing{}
|
||||
ok = m.Get(&indicator)
|
||||
if ok { // TODO: Display typing indicator in a stat bar or something similar
|
||||
composing := stanza.StateComposing{}
|
||||
ok = m.Get(&composing)
|
||||
if ok {
|
||||
b := gtk.NewBox(gtk.OrientationHorizontal, 0)
|
||||
b.Append(gtk.NewLabel(fmt.Sprintf("%s is typing...", JidMustParse(m.From).Resource)))
|
||||
return b
|
||||
@@ -72,7 +72,6 @@ func generateMessageWidget(p stanza.Packet) gtk.Widgetter {
|
||||
return error_box
|
||||
}
|
||||
|
||||
|
||||
sid := StanzaID{}
|
||||
m.Get(&sid)
|
||||
|
||||
@@ -80,7 +79,6 @@ func generateMessageWidget(p stanza.Packet) gtk.Widgetter {
|
||||
gesture := gtk.NewGestureClick()
|
||||
gesture.SetButton(3) // Right click
|
||||
|
||||
|
||||
popover := gtk.NewPopover()
|
||||
popover.SetParent(mainBox)
|
||||
popover.SetHasArrow(false)
|
||||
@@ -123,7 +121,6 @@ func generateMessageWidget(p stanza.Packet) gtk.Widgetter {
|
||||
rc_box.Append(moderate)
|
||||
}
|
||||
|
||||
|
||||
popover.SetChild(rc_box)
|
||||
|
||||
gesture.Connect("pressed", func(n_press, x, y int) {
|
||||
@@ -134,14 +131,6 @@ func generateMessageWidget(p stanza.Packet) gtk.Widgetter {
|
||||
|
||||
mainBox.AddController(gesture)
|
||||
|
||||
reply := Reply{}
|
||||
ok = m.Get(&reply)
|
||||
if ok {
|
||||
replyBox := gtk.NewBox(gtk.OrientationHorizontal, 0)
|
||||
replyBox.Append(gtk.NewLabel("↱ " + jid.MustParse(reply.To).Resourcepart()))
|
||||
mainBox.Append(replyBox)
|
||||
}
|
||||
|
||||
ocu := OccupantID{}
|
||||
|
||||
m.Get(&ocu)
|
||||
@@ -190,7 +179,6 @@ func generateMessageWidget(p stanza.Packet) gtk.Widgetter {
|
||||
al.SetText(al.Text() + " whispers")
|
||||
}
|
||||
|
||||
|
||||
authorBox.Append(al)
|
||||
mlabel := gtk.NewLabel(m.Body)
|
||||
mlabel.SetWrap(true)
|
||||
|
||||
22
main.go
22
main.go
@@ -7,10 +7,10 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/diamondburned/gotk4/pkg/gdk/v4"
|
||||
"github.com/diamondburned/gotk4/pkg/gdkpixbuf/v2"
|
||||
"github.com/diamondburned/gotk4/pkg/gio/v2"
|
||||
"github.com/diamondburned/gotk4/pkg/glib/v2"
|
||||
"github.com/diamondburned/gotk4/pkg/gtk/v4"
|
||||
"github.com/diamondburned/gotk4/pkg/gdkpixbuf/v2"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/BurntSushi/toml"
|
||||
@@ -20,10 +20,11 @@ import (
|
||||
"time"
|
||||
|
||||
_ "embed"
|
||||
"encoding/base64"
|
||||
"encoding/xml"
|
||||
"math/rand/v2"
|
||||
"runtime"
|
||||
"encoding/base64"
|
||||
"github.com/kr/pretty"
|
||||
)
|
||||
|
||||
var loadedConfig lambdaConfig
|
||||
@@ -84,6 +85,10 @@ var outcastMedalB64 string = base64.StdEncoding.EncodeToString(outcastMedalBytes
|
||||
var cancelBytes []byte
|
||||
var cancelB64 string = base64.StdEncoding.EncodeToString(cancelBytes)
|
||||
|
||||
//go:embed assets/tag.png
|
||||
var tagBytes []byte
|
||||
var tagB64 string = base64.StdEncoding.EncodeToString(tagBytes)
|
||||
|
||||
var clientAssets map[string]gdk.Paintabler = make(map[string]gdk.Paintabler)
|
||||
var lockedJIDs map[string]bool = make(map[string]bool)
|
||||
|
||||
@@ -105,7 +110,6 @@ func init() {
|
||||
loader.Close()
|
||||
clientAssets["DefaultAvatar"] = gdk.NewTextureForPixbuf(loader.Pixbuf())
|
||||
|
||||
|
||||
loader = gdkpixbuf.NewPixbufLoader()
|
||||
|
||||
ownerMedalData, _ := base64.StdEncoding.DecodeString(ownerMedalB64)
|
||||
@@ -124,6 +128,14 @@ func init() {
|
||||
|
||||
loader = gdkpixbuf.NewPixbufLoader()
|
||||
|
||||
tagData, _ := base64.StdEncoding.DecodeString(tagB64)
|
||||
loader.Write(tagData)
|
||||
loader.Close()
|
||||
|
||||
clientAssets["tag"] = gdk.NewTextureForPixbuf(loader.Pixbuf())
|
||||
|
||||
loader = gdkpixbuf.NewPixbufLoader()
|
||||
|
||||
adminMedalData, _ := base64.StdEncoding.DecodeString(adminMedalB64)
|
||||
loader.Write(adminMedalData)
|
||||
loader.Close()
|
||||
@@ -219,7 +231,6 @@ func main() {
|
||||
{Var: "jabber:iq:version"},
|
||||
{Var: "urn:xmpp:delegation:1"},
|
||||
{Var: "http://jabber.org/protocol/muc"},
|
||||
{Var: "urn:xmpp:reply:0"},
|
||||
{Var: "λ"},
|
||||
},
|
||||
}
|
||||
@@ -252,6 +263,8 @@ func main() {
|
||||
return
|
||||
}
|
||||
|
||||
pretty.Println(m)
|
||||
|
||||
e := stanza.PubSubEvent{}
|
||||
ok = m.Get(&e)
|
||||
if ok {
|
||||
@@ -510,7 +523,6 @@ func activate(app *gtk.Application) {
|
||||
the_menu.AppendSubmenu("File", fileMenu)
|
||||
the_menu.AppendSubmenu("Help", helpMenu)
|
||||
|
||||
|
||||
the_menuBar := gtk.NewPopoverMenuBarFromModel(the_menu)
|
||||
app.SetMenubar(gio.NewMenu())
|
||||
|
||||
|
||||
@@ -33,3 +33,9 @@
|
||||
.visitor {
|
||||
color: grey;
|
||||
}
|
||||
|
||||
.hat {
|
||||
background-color: orange;
|
||||
color: black;
|
||||
font-family: monospace;
|
||||
}
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
package main
|
||||
|
||||
// Implementation of XEP-0461
|
||||
// https://xmpp.org/extensions/xep-0461.html#business-id
|
||||
|
||||
import (
|
||||
"encoding/xml"
|
||||
"gosrc.io/xmpp/stanza"
|
||||
)
|
||||
|
||||
type Reply struct {
|
||||
stanza.MsgExtension
|
||||
XMLName xml.Name `xml:"urn:xmpp:reply:0 reply"`
|
||||
To string `xml:"to,attr"`
|
||||
ID string `xml:"id,attr"`
|
||||
}
|
||||
|
||||
func init() {
|
||||
stanza.TypeRegistry.MapExtension(stanza.PKTMessage, xml.Name{Space: "urn:xmpp:reply:0", Local: "reply"}, Reply{})
|
||||
}
|
||||
Reference in New Issue
Block a user