can we pretend that airplanes in the night sky are like shooting stars

This commit is contained in:
2026-08-20 11:01:25 +01:00
parent 58ae55e061
commit 2717137270
10 changed files with 195 additions and 92 deletions
+86 -63
View File
@@ -1,6 +1,10 @@
package main
import (
"log"
"net/http"
_ "net/http/pprof"
"os"
"strings"
"sync"
@@ -69,8 +73,6 @@ var styleCSS string
var client xmpp.Sender
var clientroot *xmpp.Client
var uiQueue = make(chan func(), 100)
var window *gtk.ApplicationWindow
// stores members of mucs
@@ -88,20 +90,13 @@ var Roster = make(map[string]bool)
func init() {
beeep.AppName = loadedLocale["appName"]
go func() {
for fn := range uiQueue {
glib.IdleAdd(func() bool {
fn()
return false
})
time.Sleep(10 * time.Millisecond) // Small delay between updates
}
}()
}
func main() {
go func() {
log.Println(http.ListenAndServe("localhost:6060", nil))
}()
pingTimes = append(pingTimes, []float64{})
p, err := ensureConfig()
if err != nil {
@@ -278,6 +273,9 @@ func main() {
}
}
sid := new(StanzaID)
m.Get(sid)
originator := JidMustParse(m.From).Bare()
glib.IdleAdd(func() {
@@ -364,6 +362,35 @@ func main() {
}
}
// The same, however with retractions
retraction := new(Retraction)
ok = m.Get(retraction)
if ok {
tab, ok := tabs.Load(originator)
if ok {
typed_tab := tab.(*chatTab)
/*
to_retract := ""
refs := typed_tab.msg_refsID
// If it is a DM, then we use regular message ID. If it is a MUC, we use stanza id
to_retract = sid.ID
if typed_tab.isMuc && sid != nil {
to_retract = sid.ID
refs = typed_tab.msg_refsOSID
}
*/
msg, ok := typed_tab.msg_refsOSID[retraction.ID]
if ok {
lab := msg.label_ref
glib.IdleAdd(func() {
GenerateRetraction(lab, *retraction)
})
}
}
}
glib.IdleAdd(func() {
b := gtk.NewBox(gtk.OrientationVertical, 0)
@@ -534,6 +561,7 @@ func main() {
gStatus.SetText(fmt.Sprintf("%d goroutines", goroutines))
})
}()
go func() {
// Ping
pingStatus.AddCSSClass("pending")
@@ -658,17 +686,8 @@ func main() {
box.Append(im)
box.Append(b)
// TODO: Use PEP avatar and do not use JID as hash
go getAvatar(jid, jid, im)
/*
go func() {
new_im := getAvatar(jid, jid) // TODO: Use PEP avatar and do not use JID as hash
glib.IdleAdd(func() {
new_im.SetPixelSize(40)
box.Prepend(new_im)
})
}()
*/
box.AddController(gesture1)
menu.Append(box)
@@ -757,15 +776,6 @@ func main() {
box.Prepend(im)
go getAvatar(jid, jid, im)
/*
go func() {
new_im := getAvatar(jid, jid)
glib.IdleAdd(func() {
new_im.SetPixelSize(40)
box.Prepend(new_im)
})
}()
*/
box.AddController(gesture1)
box.AddController(gesture2)
@@ -779,6 +789,41 @@ func main() {
}
}
// Local bookmarks
for jid, nick := range loadedConfig.LocalBookmarks {
joinMuc(client, clientroot.Session.BindJid, jid, nick, "")
createTab(jid, true, jid)
glib.IdleAdd(func() {
box := gtk.NewBox(gtk.OrientationHorizontal, 10)
b := gtk.NewLabel(jid)
gesture1 := gtk.NewGestureClick()
gesture1.SetButton(1)
gesture1.Connect("pressed", func() {
switchToTab(jid, &window.Window)
})
gesture2 := gtk.NewGestureClick()
gesture2.SetButton(3)
gesture2.Connect("pressed", func() {
removeTab(jid, &window.Window)
box.SetVisible(false)
})
im := gtk.NewImage()
im.SetPixelSize(40)
box.Append(b)
box.Prepend(im)
go getAvatar(jid, jid, im)
box.AddController(gesture1)
box.AddController(gesture2)
menu.Append(box)
menu.Append(gtk.NewSeparator(gtk.OrientationHorizontal))
})
}
}
})
@@ -794,7 +839,7 @@ func main() {
}
}
app := gtk.NewApplication("net.sunglocto.lambda", gio.ApplicationFlagsNone)
app := gtk.NewApplication("net.sunglocto.lambda", gio.ApplicationDefaultFlags)
app.ConnectActivate(func() {
activate(app)
go conc()
@@ -886,22 +931,16 @@ func activate(app *gtk.Application) {
about_window := gtk.NewWindow()
about_window.SetTransientFor(&window.Window)
about_window.SetTitle(fmt.Sprintf("%s %s", "About", loadedLocale["appName"]))
a.SetProgramName("Lambda")
a.SetVersion(lambda_version)
a.SetProgramName(loadedLocale["appName"])
a.SetVersion(fmt.Sprintf("Version %s", lambda_version))
a.SetComments("yet another XMPP client")
a.SetAuthors([]string{"Sunglocto"})
a.SetLicense("GPL3")
a.SetAuthors([]string{"Sunglocto", "Hydrogen", "Kuyuhi"})
a.SetLicenseType(gtk.LicenseGPL30)
a.SetLogo(clientAssetsLoad("logo"))
a.SetWebsite("https://forge.sunglocto.net/sunglocto/lambda")
a.SetWebsiteLabel("Website")
/*
a.ConnectResponse(func() {
about_window.SetVisible(false)
})
*/
about_window.SetChild(a)
about_window.SetDefaultSize(400, 300)
about_window.SetVisible(true)
a.SetVisible(true)
})
destroymucAction := gio.NewSimpleAction("destroymuc", nil)
@@ -969,7 +1008,6 @@ func activate(app *gtk.Application) {
if mu.MucUserItem.Affiliation != "owner" {
box.Append(gtk.NewLabel(loadedLocale["destroyMUCNotOwnerWarning"]))
}
// return false
}
}
} else {
@@ -1042,7 +1080,7 @@ func activate(app *gtk.Application) {
box.Append(bookmark_box)
btn := gtk.NewButtonWithLabel(loadedLocale["submit"])
btn.SetVAlign(gtk.AlignBaseline)
btn.SetVAlign(gtk.AlignBaselineFill)
box.Append(btn)
@@ -1332,11 +1370,7 @@ func activate(app *gtk.Application) {
opt.Title = charts.TitleOption{
Text: loadedLocale["pingGraphTitle"],
}
/*
opt.XAxis.Labels = []string{
// The 7 labels here match to the 7 values above
"Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun",
}*/
opt.Legend = charts.LegendOption{
SeriesNames: []string{
loadedLocale["pingGraphYAxis"],
@@ -1383,17 +1417,6 @@ func activate(app *gtk.Application) {
pBox.Append(pingStatus)
statBar.Append(pBox)
/*
sBox := gtk.NewBox(gtk.OrientationHorizontal, 0)
sIcon = gtk.NewImageFromPaintable(clientAssets["car"])
sIcon.AddCSSClass("icon")
sStatus = gtk.NewLabel("-")
sBox.Append(sIcon)
sBox.Append(sStatus)
sStatus.SetTooltipText(loadedLocale["throughputTooltip"])
statBar.Append(sBox)
*/
scrollerStatBar := gtk.NewScrolledWindow()
scrollerStatBar.SetChild(statBar)
box.Append(scrollerStatBar)