Rest in peace Dolly Patron
This commit is contained in:
+105
-62
@@ -81,12 +81,29 @@ func generateMessageWidget(p stanza.Packet, blocked bool, target string) (gtk.Wi
|
||||
return gtk.NewLabel("Unsupported message."), true
|
||||
}
|
||||
|
||||
readmarker := Marker{}
|
||||
ok = m.Get(&readmarker)
|
||||
if ok {
|
||||
b := gtk.NewBox(gtk.OrientationHorizontal, 0)
|
||||
b.Append(gtk.NewLabel(fmt.Sprintf("%s%s", JidMustParse(m.From).Resource, loadedLocale["readWidget"])))
|
||||
return b, true
|
||||
sid := StanzaID{}
|
||||
m.Get(&sid)
|
||||
|
||||
ocu := OccupantID{}
|
||||
m.Get(&ocu)
|
||||
|
||||
store_label := false
|
||||
var msg *abMessage
|
||||
tab, ok := tabs.Load(target)
|
||||
typed_tab, ok2 := tab.(*chatTab)
|
||||
if ok && ok2 {
|
||||
store_label = true
|
||||
msg, ok = typed_tab.msg_refsID[m.Id]
|
||||
if !ok {
|
||||
msg = new(abMessage)
|
||||
typed_tab.msg_refsID[m.Id] = msg
|
||||
}
|
||||
|
||||
msg.ocu_id = ocu.ID
|
||||
|
||||
if sid.ID != "" {
|
||||
typed_tab.msg_refsOSID[sid.ID] = msg
|
||||
}
|
||||
}
|
||||
|
||||
composing := stanza.StateComposing{}
|
||||
@@ -108,19 +125,6 @@ func generateMessageWidget(p stanza.Packet, blocked bool, target string) (gtk.Wi
|
||||
return error_box, true
|
||||
}
|
||||
|
||||
store_label := false
|
||||
tab, ok := tabs.Load(target)
|
||||
if ok {
|
||||
store_label = true
|
||||
}
|
||||
typed_tab := tab.(*chatTab)
|
||||
|
||||
sid := StanzaID{}
|
||||
m.Get(&sid)
|
||||
|
||||
ocu := OccupantID{}
|
||||
|
||||
m.Get(&ocu)
|
||||
id := JidMustParse(m.From).Resource
|
||||
|
||||
name := id
|
||||
@@ -179,7 +183,7 @@ func generateMessageWidget(p stanza.Packet, blocked bool, target string) (gtk.Wi
|
||||
<reaction>%s</reaction>
|
||||
</reactions>
|
||||
</message>
|
||||
`, m.To, jid.MustParse(m.From).Bare().String(), uuid.New().String(), m.Type, sid.ID, v))
|
||||
`, m.To, jid.MustParse(m.From).Bare().String(), uuid.NewString(), m.Type, sid.ID, v))
|
||||
})
|
||||
reactions.Append(like)
|
||||
}
|
||||
@@ -198,7 +202,7 @@ func generateMessageWidget(p stanza.Packet, blocked bool, target string) (gtk.Wi
|
||||
<reaction>%s</reaction>
|
||||
</reactions>
|
||||
</message>
|
||||
`, m.To, jid.MustParse(m.From).Bare().String(), uuid.New().String(), m.Type, sid.ID, custom.Text()))
|
||||
`, m.To, jid.MustParse(m.From).Bare().String(), uuid.NewString(), m.Type, sid.ID, custom.Text()))
|
||||
})
|
||||
rc_box.Append(custom)
|
||||
rc_box.Append(enter_custom)
|
||||
@@ -234,6 +238,26 @@ func generateMessageWidget(p stanza.Packet, blocked bool, target string) (gtk.Wi
|
||||
|
||||
rc_box.Append(vp)
|
||||
|
||||
live_edit := gtk.NewButtonWithLabel("Live edit")
|
||||
live_edit.ConnectClicked(func() {
|
||||
en := gtk.NewEntry()
|
||||
en.ConnectChanged(func() {
|
||||
client.SendRaw(fmt.Sprintf("<message id='%s' to='%s' type='%s'><body>%s</body><replace id='%s' xmlns='urn:xmpp:message-correct:0'/></message>",
|
||||
uuid.NewString(),
|
||||
target,
|
||||
m.Type,
|
||||
en.Text(),
|
||||
m.Id,
|
||||
))
|
||||
})
|
||||
|
||||
win := gtk.NewWindow()
|
||||
win.SetChild(en)
|
||||
win.SetVisible(true)
|
||||
})
|
||||
|
||||
rc_box.Append(live_edit)
|
||||
|
||||
popover.SetChild(rc_box)
|
||||
rect := gdk.NewRectangle(x, y, 1, 1)
|
||||
popover.SetPointingTo(&rect)
|
||||
@@ -273,18 +297,8 @@ func generateMessageWidget(p stanza.Packet, blocked bool, target string) (gtk.Wi
|
||||
|
||||
// TODO: Decouple this from widget generation
|
||||
if store_label {
|
||||
msg, ok := typed_tab.msg_refsID[m.Id]
|
||||
if !ok {
|
||||
msg = new(abMessage)
|
||||
typed_tab.msg_refsID[m.Id] = msg
|
||||
}
|
||||
|
||||
msg.label_ref = mlabel
|
||||
msg.ocu_id = ocu.ID
|
||||
|
||||
if sid.ID != "" {
|
||||
typed_tab.msg_refsOSID[sid.ID] = msg
|
||||
}
|
||||
}
|
||||
} else {
|
||||
authorBox := gtk.NewBox(gtk.OrientationHorizontal, 10)
|
||||
@@ -312,10 +326,11 @@ func generateMessageWidget(p stanza.Packet, blocked bool, target string) (gtk.Wi
|
||||
}
|
||||
|
||||
im := gtk.NewImage()
|
||||
im.SetFromPaintable(clientAssetsLoad("DefaultAvatar"))
|
||||
// im := gtk.NewImageFromPaintable(clientAssetsLoad("DefaultAvatar"))
|
||||
go createIdenticon(m.From, false, im)
|
||||
// im.SetFromPaintable(clientAssetsLoad("DefaultAvatar"))
|
||||
im.SetPixelSize(40)
|
||||
im.AddCSSClass("author_img")
|
||||
// createIdenticon(m.From, false, im)
|
||||
authorBox.Append(im)
|
||||
if can_generate {
|
||||
pres := mmmm.(stanza.Presence)
|
||||
@@ -325,14 +340,38 @@ func generateMessageWidget(p stanza.Packet, blocked bool, target string) (gtk.Wi
|
||||
go getAvatar(m.From, vu.Photo, im)
|
||||
}
|
||||
} else {
|
||||
createIdenticon(m.From, false, im)
|
||||
go createIdenticon(m.From, false, im)
|
||||
}
|
||||
} else if m.Type == stanza.MessageTypeChat {
|
||||
al.SetText(al.Text() + loadedLocale["whispers"])
|
||||
}
|
||||
|
||||
color_ind := gtk.NewLabel("")
|
||||
|
||||
ycbcr := xmpp_color.String(id, 255, loadedConfig.CVD)
|
||||
r, g, b, _ := ycbcr.RGBA()
|
||||
hexcolor := fmt.Sprintf("#%02x%02x%02x", r, g, b)
|
||||
|
||||
color_ind.SetMarkup(fmt.Sprintf("<span foreground='%s'>|</span>", hexcolor))
|
||||
|
||||
authorBox.Append(color_ind)
|
||||
authorBox.Append(al)
|
||||
|
||||
oob := stanza.OOB{}
|
||||
ok = m.Get(&oob)
|
||||
if ok {
|
||||
// media := newPictureFromWeb(oob.URL)
|
||||
// media.SetCanShrink(false)
|
||||
// mainBox.Append(media)
|
||||
// media.AddCSSClass("chat_image")
|
||||
mbtn := gtk.NewButtonWithLabel("🖼️")
|
||||
// mbtn.SetChild(newImageFromWeb(oob.URL))
|
||||
mbtn.ConnectClicked(func() {
|
||||
gopen.Open(oob.URL)
|
||||
})
|
||||
authorBox.Append(mbtn)
|
||||
}
|
||||
|
||||
if m.Thread != "" {
|
||||
im := gtk.NewImage()
|
||||
createIdenticon(m.Thread, true, im)
|
||||
@@ -346,6 +385,33 @@ func generateMessageWidget(p stanza.Packet, blocked bool, target string) (gtk.Wi
|
||||
authorBox.Append(gtk.NewLabel("🎮"))
|
||||
}
|
||||
|
||||
stamp_label := gtk.NewLabel("")
|
||||
stamp_label.SetHExpand(true)
|
||||
stamp_label.SetHAlign(gtk.AlignEnd)
|
||||
stamp_label.AddCSSClass("visitor")
|
||||
|
||||
stamp_label.SetText(time.Now().Format("03:04 PM"))
|
||||
stamp_label.SetTooltipText(time.Now().Format("2006-01-02 15:04:05"))
|
||||
|
||||
stamp := new(Delayed_Stamp)
|
||||
ok = m.Get(stamp)
|
||||
|
||||
if ok {
|
||||
stamped_time, err := stamp.GetStamp()
|
||||
if err == nil {
|
||||
stamped_time := *stamped_time
|
||||
loc := time.Now().Location()
|
||||
|
||||
stamped_time = stamped_time.In(loc)
|
||||
str := stamped_time.Format("03:04 PM")
|
||||
str_full := stamped_time.Format("2006-01-02 15:04:05")
|
||||
stamp_label.SetText(str)
|
||||
stamp_label.SetTooltipText(str_full)
|
||||
}
|
||||
}
|
||||
|
||||
authorBox.Append(stamp_label)
|
||||
|
||||
body := m.Body
|
||||
body = XEPToPango(body, false)
|
||||
|
||||
@@ -361,40 +427,15 @@ func generateMessageWidget(p stanza.Packet, blocked bool, target string) (gtk.Wi
|
||||
|
||||
// TODO: Decouple this from widget generation
|
||||
if store_label {
|
||||
msg, ok := typed_tab.msg_refsID[m.Id]
|
||||
if !ok {
|
||||
msg = new(abMessage)
|
||||
typed_tab.msg_refsID[m.Id] = msg
|
||||
}
|
||||
|
||||
msg.label_ref = mlabel
|
||||
msg.ocu_id = ocu.ID
|
||||
|
||||
if sid.ID != "" {
|
||||
typed_tab.msg_refsOSID[sid.ID] = msg
|
||||
}
|
||||
msg.read_indicator = gtk.NewBox(gtk.OrientationHorizontal, padding)
|
||||
authorBox.Append(msg.read_indicator)
|
||||
}
|
||||
|
||||
contentBox.Append(mlabel)
|
||||
|
||||
mainBox.Append(authorBox)
|
||||
mainBox.Append(contentBox)
|
||||
|
||||
oob := stanza.OOB{}
|
||||
ok = m.Get(&oob)
|
||||
if ok {
|
||||
// media := newPictureFromWeb(oob.URL)
|
||||
// media.SetCanShrink(false)
|
||||
// mainBox.Append(media)
|
||||
// media.AddCSSClass("chat_image")
|
||||
mbtn := gtk.NewButtonWithLabel("🖼️")
|
||||
// mbtn.SetChild(newImageFromWeb(oob.URL))
|
||||
mbtn.ConnectClicked(func() {
|
||||
gopen.Open(oob.URL)
|
||||
})
|
||||
authorBox.Append(mbtn)
|
||||
}
|
||||
|
||||
if m.Subject != "" {
|
||||
subjectlabel := gtk.NewLabel(m.Subject)
|
||||
subjectlabel.SetWrap(true)
|
||||
@@ -460,6 +501,8 @@ func getVAdjustment(scrolledWindow *gtk.ScrolledWindow) *gtk.Adjustment {
|
||||
}
|
||||
|
||||
func getAvatar(j, hash string, i *gtk.Image) { // TODO: This function probably shouldn't be here, and should probably be in xmpp-helpers or somewhere similar.
|
||||
time.Sleep(200 * time.Millisecond)
|
||||
hash = strings.ReplaceAll(hash, "/", "-")
|
||||
oghash := hash
|
||||
p, err := ensureCache()
|
||||
if err != nil {
|
||||
@@ -492,7 +535,7 @@ func getAvatar(j, hash string, i *gtk.Image) { // TODO: This function probably s
|
||||
Type: "get",
|
||||
From: clientroot.Session.BindJid,
|
||||
To: j,
|
||||
Id: uuid.New().String(),
|
||||
Id: uuid.NewString(),
|
||||
Lang: "en",
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user