forked from sunglocto/lambda
right-click menus alongside other changes
This commit is contained in:
@@ -121,6 +121,8 @@ func switchToTab(jid string, w *gtk.Window) {
|
||||
if mu.MucUserItem.JID != "" {
|
||||
profile_box.Append(gtk.NewLabel(mu.MucUserItem.JID))
|
||||
}
|
||||
profile_box.Append(gtk.NewLabel("Connected with role " + mu.MucUserItem.Role))
|
||||
profile_box.Append(gtk.NewLabel("Affiliated as " + mu.MucUserItem.Affiliation))
|
||||
}
|
||||
|
||||
go func() {
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"encoding/base64"
|
||||
"fmt"
|
||||
"github.com/diamondburned/gotk4/pkg/gtk/v4"
|
||||
"github.com/diamondburned/gotk4/pkg/gdk/v4"
|
||||
"github.com/google/uuid"
|
||||
"github.com/jacoblockett/sanitizefilename"
|
||||
"github.com/jasonlovesdoggo/gopen"
|
||||
@@ -59,17 +60,21 @@ func generateMessageWidget(p stanza.Packet) gtk.Widgetter {
|
||||
gesture := gtk.NewGestureClick()
|
||||
gesture.SetButton(3) // Right click
|
||||
|
||||
vis := false
|
||||
reactions := gtk.NewBox(gtk.OrientationHorizontal, 0)
|
||||
reactions.SetVisible(false)
|
||||
|
||||
popover := gtk.NewPopover()
|
||||
popover.SetParent(mainBox)
|
||||
popover.SetHasArrow(false)
|
||||
|
||||
rc_box := gtk.NewBox(gtk.OrientationVertical, 0)
|
||||
|
||||
reactions := gtk.NewBox(gtk.OrientationHorizontal, 0)
|
||||
reaction := []string{"👍", "👎", "♥️", "🤣", "😭"}
|
||||
for _, v := range reaction {
|
||||
like := gtk.NewButton()
|
||||
like.SetLabel(v)
|
||||
like.SetHExpand(true)
|
||||
like.ConnectClicked(func() {
|
||||
fmt.Println("licked")
|
||||
fmt.Println("licked") // TODO: Implement proper support for reactions via extension
|
||||
client.SendRaw(fmt.Sprintf(`
|
||||
<message from='%s' to='%s' id='%s' type='%s'>
|
||||
<reactions id='%s' xmlns='urn:xmpp:reactions:0'>
|
||||
@@ -81,14 +86,30 @@ func generateMessageWidget(p stanza.Packet) gtk.Widgetter {
|
||||
reactions.Append(like)
|
||||
}
|
||||
|
||||
rc_box.Append(reactions)
|
||||
|
||||
if m.Type == stanza.MessageTypeGroupchat {
|
||||
moderate := gtk.NewButtonWithLabel("Moderate") // TODO: Implement proper support for moderations via extension
|
||||
moderate.ConnectClicked(func() {
|
||||
client.SendRaw(fmt.Sprintf(`
|
||||
<iq type='set' to='%s' id='%s'>
|
||||
<moderate id='%s' xmlns='urn:xmpp:message-moderate:1'>
|
||||
<retract xmlns='urn:xmpp-message-retract:1'/>
|
||||
<reason>Retracted</reason>
|
||||
</moderate>
|
||||
</iq>
|
||||
`, jid.MustParse(m.From).Bare().String(), uuid.New().String(), sid.ID))
|
||||
})
|
||||
rc_box.Append(moderate)
|
||||
}
|
||||
|
||||
|
||||
popover.SetChild(rc_box)
|
||||
|
||||
gesture.Connect("pressed", func(n_press, x, y int) {
|
||||
if !vis {
|
||||
vis = true
|
||||
reactions.SetVisible(true)
|
||||
} else {
|
||||
vis = false
|
||||
reactions.SetVisible(false)
|
||||
}
|
||||
rect := gdk.NewRectangle(x, y, 1, 1)
|
||||
popover.SetPointingTo(&rect)
|
||||
popover.Popup()
|
||||
})
|
||||
|
||||
mainBox.AddController(gesture)
|
||||
@@ -111,6 +132,9 @@ func generateMessageWidget(p stanza.Packet) gtk.Widgetter {
|
||||
|
||||
// authorBox.Append(im)
|
||||
|
||||
al := gtk.NewLabel(jid.MustParse(m.From).Resourcepart())
|
||||
al.AddCSSClass("author")
|
||||
|
||||
if m.Type == stanza.MessageTypeGroupchat {
|
||||
mo, _ := mucmembers.Load(jid.MustParse(m.From).Bare().String())
|
||||
mm := mo.(mucUnit)
|
||||
@@ -138,10 +162,10 @@ func generateMessageWidget(p stanza.Packet) gtk.Widgetter {
|
||||
im.AddCSSClass("author_img")
|
||||
authorBox.Append(im)
|
||||
}
|
||||
} else if m.Type == stanza.MessageTypeChat {
|
||||
al.SetText(al.Text() + " whispers")
|
||||
}
|
||||
|
||||
al := gtk.NewLabel(jid.MustParse(m.From).Resourcepart())
|
||||
al.AddCSSClass("author")
|
||||
|
||||
authorBox.Append(al)
|
||||
mlabel := gtk.NewLabel(m.Body)
|
||||
|
||||
@@ -26,25 +26,31 @@ func dropToSignInPage(err error) {
|
||||
insecure_box := gtk.NewBox(gtk.OrientationHorizontal, 0)
|
||||
|
||||
server_label := gtk.NewLabel("Server: ")
|
||||
username_label := gtk.NewLabel("Username: ")
|
||||
username_label := gtk.NewLabel("JID: ")
|
||||
password_label := gtk.NewLabel("Password: ")
|
||||
nickname_label := gtk.NewLabel("Nickname: ")
|
||||
insecure_label := gtk.NewLabel("Insecure: ")
|
||||
insecure_label := gtk.NewLabel("Insecure: (?)")
|
||||
insecure_label.SetTooltipText("Tick this if you need to connect without TLS, usually for connecting to Tor XMPP servers")
|
||||
|
||||
server_entry := gtk.NewEntry()
|
||||
server_entry.SetHAlign(gtk.AlignEnd)
|
||||
server_entry.SetHExpand(true)
|
||||
|
||||
username_entry := gtk.NewEntry()
|
||||
username_entry.SetHAlign(gtk.AlignEnd)
|
||||
username_entry.SetHExpand(true)
|
||||
|
||||
password_entry := gtk.NewPasswordEntry()
|
||||
password_entry.SetHAlign(gtk.AlignEnd)
|
||||
password_entry.SetHExpand(true)
|
||||
|
||||
nickname_entry := gtk.NewEntry()
|
||||
nickname_entry.SetHAlign(gtk.AlignEnd)
|
||||
nickname_entry.SetHExpand(true)
|
||||
|
||||
insecure_check := gtk.NewCheckButton()
|
||||
insecure_check.SetHAlign(gtk.AlignEnd)
|
||||
insecure_check.SetHExpand(true)
|
||||
|
||||
|
||||
server_box.Append(server_label)
|
||||
|
||||
8
main.go
8
main.go
@@ -174,7 +174,7 @@ func main() {
|
||||
originator := jid.MustParse(m.From).Bare().String()
|
||||
|
||||
glib.IdleAdd(func() {
|
||||
uiQueue <- func() {
|
||||
//uiQueue <- func() {
|
||||
b := gtk.NewBox(gtk.OrientationVertical, 0)
|
||||
ba, ok := generateMessageWidget(p).(*gtk.Box)
|
||||
if ok {
|
||||
@@ -190,7 +190,7 @@ func main() {
|
||||
} else {
|
||||
fmt.Println("Got message when the tab does not exist!")
|
||||
}
|
||||
}
|
||||
//}
|
||||
})
|
||||
})
|
||||
|
||||
@@ -230,7 +230,7 @@ func main() {
|
||||
} else {
|
||||
typed_unit.Members.Delete(ocu.ID)
|
||||
glib.IdleAdd(func() {
|
||||
uiQueue <- func() {
|
||||
//uiQueue <- func() {
|
||||
b := gtk.NewLabel("")
|
||||
ba, ok := generatePresenceWidget(p).(*gtk.Label)
|
||||
if ok {
|
||||
@@ -246,7 +246,7 @@ func main() {
|
||||
} else {
|
||||
fmt.Println("Got message when the tab does not exist!")
|
||||
}
|
||||
}
|
||||
//}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user