BOOKMARKS! BOOKMARKS! WE GOT BOOKMARKS PEOPLE
This commit is contained in:
107
main.go
107
main.go
@@ -90,7 +90,6 @@ var cancelB64 string = base64.StdEncoding.EncodeToString(cancelBytes)
|
||||
var tagBytes []byte
|
||||
var tagB64 string = base64.StdEncoding.EncodeToString(tagBytes)
|
||||
|
||||
|
||||
//go:embed assets/lambda-disabled.png
|
||||
var logoDisabledBytes []byte
|
||||
var logoDisabledB64 string = base64.StdEncoding.EncodeToString(logoDisabledBytes)
|
||||
@@ -99,10 +98,28 @@ var logoDisabledB64 string = base64.StdEncoding.EncodeToString(logoDisabledBytes
|
||||
var groupBytes []byte
|
||||
var groupB64 string = base64.StdEncoding.EncodeToString(groupBytes)
|
||||
|
||||
//go:embed assets/door_in.png
|
||||
var doorInBytes []byte
|
||||
var doorInB64 string = base64.StdEncoding.EncodeToString(doorInBytes)
|
||||
|
||||
//go:embed assets/door_out.png
|
||||
var doorOutBytes []byte
|
||||
var doorOutB64 string = base64.StdEncoding.EncodeToString(doorOutBytes)
|
||||
|
||||
//go:embed assets/large_group.png
|
||||
var largeGroupBytes []byte
|
||||
var largeGroupB64 string = base64.StdEncoding.EncodeToString(largeGroupBytes)
|
||||
|
||||
//go:embed assets/world.png
|
||||
var worldBytes []byte
|
||||
var worldB64 string = base64.StdEncoding.EncodeToString(worldBytes)
|
||||
|
||||
var clientAssets map[string]gdk.Paintabler = make(map[string]gdk.Paintabler)
|
||||
var lockedJIDs map[string]bool = make(map[string]bool)
|
||||
|
||||
func init() {
|
||||
beeep.AppName = "Lambda"
|
||||
|
||||
go func() {
|
||||
for fn := range uiQueue {
|
||||
glib.IdleAdd(func() bool {
|
||||
@@ -176,7 +193,6 @@ func init() {
|
||||
|
||||
clientAssets["outcast"] = gdk.NewTextureForPixbuf(loader.Pixbuf())
|
||||
|
||||
|
||||
loader = gdkpixbuf.NewPixbufLoader()
|
||||
|
||||
disabledLogoData, _ := base64.StdEncoding.DecodeString(logoDisabledB64)
|
||||
@@ -192,6 +208,38 @@ func init() {
|
||||
loader.Close()
|
||||
|
||||
clientAssets["group"] = gdk.NewTextureForPixbuf(loader.Pixbuf())
|
||||
|
||||
loader = gdkpixbuf.NewPixbufLoader()
|
||||
|
||||
doorInData, _ := base64.StdEncoding.DecodeString(doorInB64)
|
||||
loader.Write(doorInData)
|
||||
loader.Close()
|
||||
|
||||
clientAssets["door_in"] = gdk.NewTextureForPixbuf(loader.Pixbuf())
|
||||
|
||||
loader = gdkpixbuf.NewPixbufLoader()
|
||||
|
||||
doorOutData, _ := base64.StdEncoding.DecodeString(doorOutB64)
|
||||
loader.Write(doorOutData)
|
||||
loader.Close()
|
||||
|
||||
clientAssets["door_out"] = gdk.NewTextureForPixbuf(loader.Pixbuf())
|
||||
|
||||
loader = gdkpixbuf.NewPixbufLoader()
|
||||
|
||||
largeGroupData, _ := base64.StdEncoding.DecodeString(largeGroupB64)
|
||||
loader.Write(largeGroupData)
|
||||
loader.Close()
|
||||
|
||||
clientAssets["large_group"] = gdk.NewTextureForPixbuf(loader.Pixbuf())
|
||||
|
||||
loader = gdkpixbuf.NewPixbufLoader()
|
||||
|
||||
worldData, _ := base64.StdEncoding.DecodeString(worldB64)
|
||||
loader.Write(worldData)
|
||||
loader.Close()
|
||||
|
||||
clientAssets["world"] = gdk.NewTextureForPixbuf(loader.Pixbuf())
|
||||
}
|
||||
|
||||
func main() {
|
||||
@@ -368,8 +416,8 @@ func main() {
|
||||
_, ok := typed_unit.Members.Load(id)
|
||||
if !ok {
|
||||
glib.IdleAdd(func() {
|
||||
b := gtk.NewLabel("")
|
||||
ba, ok := generatePresenceWidget(p).(*gtk.Label)
|
||||
b := gtk.NewBox(gtk.OrientationVertical, 0)
|
||||
ba, ok := generatePresenceWidget(p).(*gtk.Box)
|
||||
if ok {
|
||||
b = ba
|
||||
}
|
||||
@@ -389,8 +437,8 @@ func main() {
|
||||
} else {
|
||||
typed_unit.Members.Delete(id)
|
||||
glib.IdleAdd(func() {
|
||||
b := gtk.NewLabel("")
|
||||
ba, ok := generatePresenceWidget(p).(*gtk.Label)
|
||||
b := gtk.NewBox(gtk.OrientationVertical, 0)
|
||||
ba, ok := generatePresenceWidget(p).(*gtk.Box)
|
||||
if ok {
|
||||
b = ba
|
||||
}
|
||||
@@ -462,8 +510,49 @@ func main() {
|
||||
|
||||
cm := xmpp.NewStreamManager(c, func(c xmpp.Sender) {
|
||||
fmt.Println("XMPP client connected")
|
||||
/*
|
||||
*/
|
||||
books, err := stanza.NewItemsRequest("", "urn:xmpp:bookmarks:1", 0)
|
||||
if err == nil {
|
||||
mychan, err := c.SendIQ(context.TODO(), books)
|
||||
result := <-mychan
|
||||
if err == nil {
|
||||
res, ok := result.Payload.(*stanza.PubSubGeneric)
|
||||
if ok {
|
||||
for _, item := range res.Items.List {
|
||||
jid := item.Id
|
||||
node := item.Any
|
||||
autojoin := false
|
||||
nick := loadedConfig.Nick
|
||||
for _, attr := range node.Attrs {
|
||||
if attr.Name.Local == "autojoin" {
|
||||
autojoin = attr.Value == "true"
|
||||
}
|
||||
}
|
||||
|
||||
for _, node := range node.Nodes {
|
||||
if node.XMLName.Local == "nick" {
|
||||
nick = node.Content
|
||||
}
|
||||
}
|
||||
|
||||
_, ok := tabs.Load(jid)
|
||||
if !ok && autojoin {
|
||||
err := joinMuc(client, clientroot.Session.BindJid, jid, nick)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
createTab(jid, true)
|
||||
b := gtk.NewButtonWithLabel(jid)
|
||||
b.ConnectClicked(func() {
|
||||
b.AddCSSClass("accent")
|
||||
switchToTab(jid, &window.Window)
|
||||
})
|
||||
menu.Append(b)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
go func() {
|
||||
@@ -509,7 +598,7 @@ func activate(app *gtk.Application) {
|
||||
|
||||
destroymucAction := gio.NewSimpleAction("destroymuc", nil)
|
||||
destroymucAction.ConnectActivate(func(p *glib.Variant) {
|
||||
cur, ok := tabs.Load(current)
|
||||
cur, ok := tabs.Load(current)
|
||||
if ok {
|
||||
cur := cur.(*chatTab)
|
||||
if cur.isMuc {
|
||||
|
||||
Reference in New Issue
Block a user