forked from sunglocto/lambda
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5c76729a6b | |||
| c260b8b231 | |||
| 971147dcb8 |
BIN
assets/cancel.png
Normal file
BIN
assets/cancel.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 607 B |
BIN
assets/icon.ico
Normal file
BIN
assets/icon.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 264 KiB |
BIN
assets/icon.png
Normal file
BIN
assets/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 12 KiB |
@@ -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 {
|
||||
@@ -196,8 +200,11 @@ func switchToTab(jid string, w *gtk.Window) {
|
||||
win.Present()
|
||||
})
|
||||
userbox.AddController(gesture)
|
||||
|
||||
gen.Append(userbox)
|
||||
if mu.MucUserItem.Role == "moderator" {
|
||||
gen.Prepend(userbox)
|
||||
} else {
|
||||
gen.Append(userbox)
|
||||
}
|
||||
return true
|
||||
})
|
||||
|
||||
|
||||
@@ -49,7 +49,27 @@ func generateMessageWidget(p stanza.Packet) gtk.Widgetter {
|
||||
readmarker := Marker{}
|
||||
ok = m.Get(&readmarker)
|
||||
if ok {
|
||||
return gtk.NewLabel(fmt.Sprintf("%s has read to this point", JidMustParse(m.From).Resource))
|
||||
b := gtk.NewBox(gtk.OrientationHorizontal, 0)
|
||||
b.Append(gtk.NewLabel(fmt.Sprintf("%s has read to this point", JidMustParse(m.From).Resource)))
|
||||
return b
|
||||
}
|
||||
|
||||
indicator := stanza.StateComposing{}
|
||||
ok = m.Get(&indicator)
|
||||
if ok { // TODO: Display typing indicator in a stat bar or something similar
|
||||
b := gtk.NewBox(gtk.OrientationHorizontal, 0)
|
||||
b.Append(gtk.NewLabel(fmt.Sprintf("%s is typing...", JidMustParse(m.From).Resource)))
|
||||
return b
|
||||
}
|
||||
|
||||
if m.Error.Type != "" {
|
||||
error_box := gtk.NewBox(gtk.OrientationHorizontal, 0)
|
||||
cancel_img := gtk.NewImageFromPaintable(clientAssets["cancel"])
|
||||
error_label := gtk.NewLabel(m.Error.Text)
|
||||
|
||||
error_box.Append(cancel_img)
|
||||
error_box.Append(error_label)
|
||||
return error_box
|
||||
}
|
||||
|
||||
|
||||
|
||||
21
main.go
21
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"
|
||||
@@ -81,8 +80,12 @@ var noneMedalB64 string = base64.StdEncoding.EncodeToString(noneMedalBytes)
|
||||
var outcastMedalBytes []byte
|
||||
var outcastMedalB64 string = base64.StdEncoding.EncodeToString(outcastMedalBytes)
|
||||
|
||||
//go:embed assets/cancel.png
|
||||
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() {
|
||||
@@ -113,6 +116,14 @@ func init() {
|
||||
|
||||
loader = gdkpixbuf.NewPixbufLoader()
|
||||
|
||||
cancelData, _ := base64.StdEncoding.DecodeString(cancelB64)
|
||||
loader.Write(cancelData)
|
||||
loader.Close()
|
||||
|
||||
clientAssets["cancel"] = gdk.NewTextureForPixbuf(loader.Pixbuf())
|
||||
|
||||
loader = gdkpixbuf.NewPixbufLoader()
|
||||
|
||||
adminMedalData, _ := base64.StdEncoding.DecodeString(adminMedalB64)
|
||||
loader.Write(adminMedalData)
|
||||
loader.Close()
|
||||
@@ -176,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()
|
||||
|
||||
@@ -306,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 {
|
||||
@@ -322,7 +332,6 @@ func main() {
|
||||
} else {
|
||||
fmt.Println("Got message when the tab does not exist!")
|
||||
}
|
||||
//}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -335,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)
|
||||
@@ -363,7 +372,9 @@ func main() {
|
||||
}
|
||||
|
||||
userdevices.Store(user, typed_unit)
|
||||
lockedJIDs[user] = true
|
||||
}
|
||||
time.Sleep(1 * time.Second)
|
||||
})
|
||||
|
||||
c, err := xmpp.NewClient(&config, router, func(err error) {
|
||||
|
||||
BIN
rsrc_windows_amd64.syso
Normal file
BIN
rsrc_windows_amd64.syso
Normal file
Binary file not shown.
Reference in New Issue
Block a user