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 != "" {
|
if mu.MucUserItem.JID != "" {
|
||||||
profile_box.Append(gtk.NewLabel(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() {
|
go func() {
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import (
|
|||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/diamondburned/gotk4/pkg/gtk/v4"
|
"github.com/diamondburned/gotk4/pkg/gtk/v4"
|
||||||
|
"github.com/diamondburned/gotk4/pkg/gdk/v4"
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/jacoblockett/sanitizefilename"
|
"github.com/jacoblockett/sanitizefilename"
|
||||||
"github.com/jasonlovesdoggo/gopen"
|
"github.com/jasonlovesdoggo/gopen"
|
||||||
@@ -59,17 +60,21 @@ func generateMessageWidget(p stanza.Packet) gtk.Widgetter {
|
|||||||
gesture := gtk.NewGestureClick()
|
gesture := gtk.NewGestureClick()
|
||||||
gesture.SetButton(3) // Right click
|
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{"👍", "👎", "♥️", "🤣", "😭"}
|
reaction := []string{"👍", "👎", "♥️", "🤣", "😭"}
|
||||||
for _, v := range reaction {
|
for _, v := range reaction {
|
||||||
like := gtk.NewButton()
|
like := gtk.NewButton()
|
||||||
like.SetLabel(v)
|
like.SetLabel(v)
|
||||||
like.SetHExpand(true)
|
like.SetHExpand(true)
|
||||||
like.ConnectClicked(func() {
|
like.ConnectClicked(func() {
|
||||||
fmt.Println("licked")
|
fmt.Println("licked") // TODO: Implement proper support for reactions via extension
|
||||||
client.SendRaw(fmt.Sprintf(`
|
client.SendRaw(fmt.Sprintf(`
|
||||||
<message from='%s' to='%s' id='%s' type='%s'>
|
<message from='%s' to='%s' id='%s' type='%s'>
|
||||||
<reactions id='%s' xmlns='urn:xmpp:reactions:0'>
|
<reactions id='%s' xmlns='urn:xmpp:reactions:0'>
|
||||||
@@ -81,14 +86,30 @@ func generateMessageWidget(p stanza.Packet) gtk.Widgetter {
|
|||||||
reactions.Append(like)
|
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) {
|
gesture.Connect("pressed", func(n_press, x, y int) {
|
||||||
if !vis {
|
rect := gdk.NewRectangle(x, y, 1, 1)
|
||||||
vis = true
|
popover.SetPointingTo(&rect)
|
||||||
reactions.SetVisible(true)
|
popover.Popup()
|
||||||
} else {
|
|
||||||
vis = false
|
|
||||||
reactions.SetVisible(false)
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
mainBox.AddController(gesture)
|
mainBox.AddController(gesture)
|
||||||
@@ -111,6 +132,9 @@ func generateMessageWidget(p stanza.Packet) gtk.Widgetter {
|
|||||||
|
|
||||||
// authorBox.Append(im)
|
// authorBox.Append(im)
|
||||||
|
|
||||||
|
al := gtk.NewLabel(jid.MustParse(m.From).Resourcepart())
|
||||||
|
al.AddCSSClass("author")
|
||||||
|
|
||||||
if m.Type == stanza.MessageTypeGroupchat {
|
if m.Type == stanza.MessageTypeGroupchat {
|
||||||
mo, _ := mucmembers.Load(jid.MustParse(m.From).Bare().String())
|
mo, _ := mucmembers.Load(jid.MustParse(m.From).Bare().String())
|
||||||
mm := mo.(mucUnit)
|
mm := mo.(mucUnit)
|
||||||
@@ -138,10 +162,10 @@ func generateMessageWidget(p stanza.Packet) gtk.Widgetter {
|
|||||||
im.AddCSSClass("author_img")
|
im.AddCSSClass("author_img")
|
||||||
authorBox.Append(im)
|
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)
|
authorBox.Append(al)
|
||||||
mlabel := gtk.NewLabel(m.Body)
|
mlabel := gtk.NewLabel(m.Body)
|
||||||
|
|||||||
@@ -26,25 +26,31 @@ func dropToSignInPage(err error) {
|
|||||||
insecure_box := gtk.NewBox(gtk.OrientationHorizontal, 0)
|
insecure_box := gtk.NewBox(gtk.OrientationHorizontal, 0)
|
||||||
|
|
||||||
server_label := gtk.NewLabel("Server: ")
|
server_label := gtk.NewLabel("Server: ")
|
||||||
username_label := gtk.NewLabel("Username: ")
|
username_label := gtk.NewLabel("JID: ")
|
||||||
password_label := gtk.NewLabel("Password: ")
|
password_label := gtk.NewLabel("Password: ")
|
||||||
nickname_label := gtk.NewLabel("Nickname: ")
|
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 := gtk.NewEntry()
|
||||||
server_entry.SetHAlign(gtk.AlignEnd)
|
server_entry.SetHAlign(gtk.AlignEnd)
|
||||||
|
server_entry.SetHExpand(true)
|
||||||
|
|
||||||
username_entry := gtk.NewEntry()
|
username_entry := gtk.NewEntry()
|
||||||
username_entry.SetHAlign(gtk.AlignEnd)
|
username_entry.SetHAlign(gtk.AlignEnd)
|
||||||
|
username_entry.SetHExpand(true)
|
||||||
|
|
||||||
password_entry := gtk.NewPasswordEntry()
|
password_entry := gtk.NewPasswordEntry()
|
||||||
password_entry.SetHAlign(gtk.AlignEnd)
|
password_entry.SetHAlign(gtk.AlignEnd)
|
||||||
|
password_entry.SetHExpand(true)
|
||||||
|
|
||||||
nickname_entry := gtk.NewEntry()
|
nickname_entry := gtk.NewEntry()
|
||||||
nickname_entry.SetHAlign(gtk.AlignEnd)
|
nickname_entry.SetHAlign(gtk.AlignEnd)
|
||||||
|
nickname_entry.SetHExpand(true)
|
||||||
|
|
||||||
insecure_check := gtk.NewCheckButton()
|
insecure_check := gtk.NewCheckButton()
|
||||||
insecure_check.SetHAlign(gtk.AlignEnd)
|
insecure_check.SetHAlign(gtk.AlignEnd)
|
||||||
|
insecure_check.SetHExpand(true)
|
||||||
|
|
||||||
|
|
||||||
server_box.Append(server_label)
|
server_box.Append(server_label)
|
||||||
|
|||||||
8
main.go
8
main.go
@@ -174,7 +174,7 @@ func main() {
|
|||||||
originator := jid.MustParse(m.From).Bare().String()
|
originator := jid.MustParse(m.From).Bare().String()
|
||||||
|
|
||||||
glib.IdleAdd(func() {
|
glib.IdleAdd(func() {
|
||||||
uiQueue <- func() {
|
//uiQueue <- func() {
|
||||||
b := gtk.NewBox(gtk.OrientationVertical, 0)
|
b := gtk.NewBox(gtk.OrientationVertical, 0)
|
||||||
ba, ok := generateMessageWidget(p).(*gtk.Box)
|
ba, ok := generateMessageWidget(p).(*gtk.Box)
|
||||||
if ok {
|
if ok {
|
||||||
@@ -190,7 +190,7 @@ func main() {
|
|||||||
} else {
|
} else {
|
||||||
fmt.Println("Got message when the tab does not exist!")
|
fmt.Println("Got message when the tab does not exist!")
|
||||||
}
|
}
|
||||||
}
|
//}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -230,7 +230,7 @@ func main() {
|
|||||||
} else {
|
} else {
|
||||||
typed_unit.Members.Delete(ocu.ID)
|
typed_unit.Members.Delete(ocu.ID)
|
||||||
glib.IdleAdd(func() {
|
glib.IdleAdd(func() {
|
||||||
uiQueue <- func() {
|
//uiQueue <- func() {
|
||||||
b := gtk.NewLabel("")
|
b := gtk.NewLabel("")
|
||||||
ba, ok := generatePresenceWidget(p).(*gtk.Label)
|
ba, ok := generatePresenceWidget(p).(*gtk.Label)
|
||||||
if ok {
|
if ok {
|
||||||
@@ -246,7 +246,7 @@ func main() {
|
|||||||
} else {
|
} else {
|
||||||
fmt.Println("Got message when the tab does not exist!")
|
fmt.Println("Got message when the tab does not exist!")
|
||||||
}
|
}
|
||||||
}
|
//}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user