add Destroy room button, show error notification on presence error and show disabled lambda icon when not focused on any chat
This commit is contained in:
59
main.go
59
main.go
@@ -11,6 +11,7 @@ import (
|
||||
"github.com/diamondburned/gotk4/pkg/gio/v2"
|
||||
"github.com/diamondburned/gotk4/pkg/glib/v2"
|
||||
"github.com/diamondburned/gotk4/pkg/gtk/v4"
|
||||
"github.com/gen2brain/beeep"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/BurntSushi/toml"
|
||||
@@ -29,7 +30,7 @@ import (
|
||||
|
||||
var loadedConfig lambdaConfig
|
||||
|
||||
var empty_dialog *gtk.Label
|
||||
var empty_dialog *gtk.Image
|
||||
|
||||
// var msgs *gtk.ListBox
|
||||
var content *gtk.Widgetter
|
||||
@@ -89,6 +90,15 @@ 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)
|
||||
|
||||
//go:embed assets/group.png
|
||||
var groupBytes []byte
|
||||
var groupB64 string = base64.StdEncoding.EncodeToString(groupBytes)
|
||||
|
||||
var clientAssets map[string]gdk.Paintabler = make(map[string]gdk.Paintabler)
|
||||
var lockedJIDs map[string]bool = make(map[string]bool)
|
||||
|
||||
@@ -165,6 +175,23 @@ func init() {
|
||||
loader.Close()
|
||||
|
||||
clientAssets["outcast"] = gdk.NewTextureForPixbuf(loader.Pixbuf())
|
||||
|
||||
|
||||
loader = gdkpixbuf.NewPixbufLoader()
|
||||
|
||||
disabledLogoData, _ := base64.StdEncoding.DecodeString(logoDisabledB64)
|
||||
loader.Write(disabledLogoData)
|
||||
loader.Close()
|
||||
|
||||
clientAssets["disabled_logo"] = gdk.NewTextureForPixbuf(loader.Pixbuf())
|
||||
|
||||
loader = gdkpixbuf.NewPixbufLoader()
|
||||
|
||||
groupData, _ := base64.StdEncoding.DecodeString(groupB64)
|
||||
loader.Write(groupData)
|
||||
loader.Close()
|
||||
|
||||
clientAssets["group"] = gdk.NewTextureForPixbuf(loader.Pixbuf())
|
||||
}
|
||||
|
||||
func main() {
|
||||
@@ -307,7 +334,8 @@ func main() {
|
||||
return
|
||||
}
|
||||
|
||||
if presence.Error != *new(stanza.Err) {
|
||||
if presence.Error.Reason != "" {
|
||||
beeep.Notify(fmt.Sprintf("%s : %s", presence.From, presence.Error.Reason), presence.Error.Text, cancelBytes)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -468,6 +496,7 @@ func activate(app *gtk.Application) {
|
||||
fileMenu := gio.NewMenu()
|
||||
fileMenu.Append("Join MUC", "app.join")
|
||||
fileMenu.Append("Start DM", "app.dm")
|
||||
fileMenu.Append("Destroy MUC", "app.destroymuc")
|
||||
|
||||
helpMenu := gio.NewMenu()
|
||||
helpMenu.Append("About", "app.about")
|
||||
@@ -478,6 +507,28 @@ func activate(app *gtk.Application) {
|
||||
a.SetVisible(true)
|
||||
})
|
||||
|
||||
destroymucAction := gio.NewSimpleAction("destroymuc", nil)
|
||||
destroymucAction.ConnectActivate(func(p *glib.Variant) {
|
||||
cur, ok := tabs.Load(current)
|
||||
if ok {
|
||||
cur := cur.(*chatTab)
|
||||
if cur.isMuc {
|
||||
client.SendRaw(fmt.Sprintf(`
|
||||
<iq from='%s'
|
||||
id='begone'
|
||||
to='%s'
|
||||
type='set'>
|
||||
<query xmlns='http://jabber.org/protocol/muc#owner'>
|
||||
<destroy jid='%s'>
|
||||
<reason>User requested</reason>
|
||||
</destroy>
|
||||
</query>
|
||||
</iq>
|
||||
`, clientroot.Session.BindJid, current, JidMustParse(clientroot.Session.BindJid).Bare()))
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
joinAction := gio.NewSimpleAction("join", nil)
|
||||
joinAction.ConnectActivate(func(p *glib.Variant) {
|
||||
box := gtk.NewBox(gtk.OrientationVertical, 0)
|
||||
@@ -540,6 +591,7 @@ func activate(app *gtk.Application) {
|
||||
|
||||
app.AddAction(joinAction)
|
||||
app.AddAction(aboutAction)
|
||||
app.AddAction(destroymucAction)
|
||||
|
||||
the_menu.AppendSubmenu("File", fileMenu)
|
||||
the_menu.AppendSubmenu("Help", helpMenu)
|
||||
@@ -552,7 +604,8 @@ func activate(app *gtk.Application) {
|
||||
window.Window.SetDefaultSize(500, 500)
|
||||
menu = gtk.NewBox(gtk.OrientationVertical, 0)
|
||||
|
||||
empty_dialog = gtk.NewLabel("You are not focused on any chats.")
|
||||
empty_dialog = gtk.NewImageFromPaintable(clientAssets["disabled_logo"])
|
||||
empty_dialog.SetPixelSize(100)
|
||||
empty_dialog.SetVExpand(true)
|
||||
|
||||
scroller = gtk.NewScrolledWindow()
|
||||
|
||||
Reference in New Issue
Block a user