Compare commits
10 Commits
3.1i
...
3aa8054dc0
| Author | SHA1 | Date | |
|---|---|---|---|
| 3aa8054dc0 | |||
| ad9a0ea9a8 | |||
| de40a5dec8 | |||
| 78c7f0175d | |||
| 7bab52f033 | |||
| 652fd3ea19 | |||
| 536ce4cae6 | |||
| 202e3ba6b1 | |||
| 7f01f38436 | |||
| 4afe2de35d |
@@ -112,7 +112,7 @@ go build -tags wayland .
|
||||
## εγκατάσταση
|
||||
(installation)
|
||||
|
||||
pi currently has no consolidated way of installing it. There is an [Arch User Repository package available](https://aur.archlinux.org/pi-im), which is maintained by [snit](https://isekai.rocks/~snit).
|
||||
pi currently has no consolidated way of installing it. There is an [Arch User Repository package available](https://aur.archlinux.org/packages/pi-im), which is maintained by [snit](https://isekai.rocks/~snit).
|
||||
|
||||
## υποστήριξη
|
||||
(support)
|
||||
|
||||
98
main.go
98
main.go
@@ -3,9 +3,12 @@ package main
|
||||
import (
|
||||
//core - required
|
||||
"context"
|
||||
_ "embed"
|
||||
"encoding/xml"
|
||||
"errors"
|
||||
"fmt"
|
||||
_ "image/jpeg"
|
||||
_ "image/png"
|
||||
"io"
|
||||
"log"
|
||||
"math/rand/v2"
|
||||
@@ -13,9 +16,6 @@ import (
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
_ "embed"
|
||||
_ "image/png"
|
||||
_ "image/jpeg"
|
||||
|
||||
// gui - required
|
||||
"fyne.io/fyne/v2"
|
||||
@@ -27,25 +27,24 @@ import (
|
||||
"fyne.io/fyne/v2/storage"
|
||||
"fyne.io/fyne/v2/theme"
|
||||
"fyne.io/fyne/v2/widget"
|
||||
extraWidgets "fyne.io/x/fyne/widget"
|
||||
"github.com/makeworld-the-better-one/go-isemoji"
|
||||
"github.com/rrivera/identicon"
|
||||
"github.com/shreve/musicwand/pkg/mpris"
|
||||
|
||||
// xmpp - required
|
||||
oasisSdk "github.com/sunglocto/oasis-sdk"
|
||||
"mellium.im/xmpp/bookmarks"
|
||||
"mellium.im/xmpp/jid"
|
||||
"mellium.im/xmpp/muc"
|
||||
"mellium.im/xmpp/stanza"
|
||||
"mellium.im/xmpp/pubsub"
|
||||
oasisSdk "github.com/sunglocto/oasis-sdk"
|
||||
"mellium.im/xmpp/stanza"
|
||||
// TODO: integrated theme switcher
|
||||
)
|
||||
|
||||
//go:embed pi.png
|
||||
var iconBytes []byte
|
||||
|
||||
var version string = "3.1i"
|
||||
var version string = "3.14i"
|
||||
var statBar widget.Label
|
||||
var chatInfo fyne.Container
|
||||
var chatSidebar fyne.Container
|
||||
@@ -174,7 +173,7 @@ func CreateUITab(chatJidStr string) ChatTabUI {
|
||||
content.Wrapping = fyne.TextWrapWord
|
||||
content.Selectable = true
|
||||
content.Importance = widget.MediumImportance
|
||||
//content.SizeName = fyne.ThemeSizeName(theme.SizeNameText)
|
||||
content.SizeName = fyne.ThemeSizeName(theme.SizeNameText)
|
||||
icon := theme.FileVideoIcon()
|
||||
replytext := widget.NewLabel(">fallback reply text")
|
||||
replytext.Hide()
|
||||
@@ -218,6 +217,7 @@ func CreateUITab(chatJidStr string) ChatTabUI {
|
||||
if ok {
|
||||
author.SetText("Ignored user")
|
||||
content.SetText("This user is ignored due to: " + reason)
|
||||
content.Importance = widget.LowImportance
|
||||
return // message is from blocked user
|
||||
}
|
||||
}
|
||||
@@ -236,6 +236,8 @@ func CreateUITab(chatJidStr string) ChatTabUI {
|
||||
|
||||
if chatTabs[chatJidStr].Messages[i].Important {
|
||||
content.Importance = widget.DangerImportance
|
||||
} else {
|
||||
content.Importance = widget.MediumImportance
|
||||
}
|
||||
btn.Hidden = true // Hide by default
|
||||
msgContent := chatTabs[chatJidStr].Messages[i].Content
|
||||
@@ -310,9 +312,13 @@ func CreateUITab(chatJidStr string) ChatTabUI {
|
||||
|
||||
sl := strings.Split(msgContent, " ")
|
||||
|
||||
content.SizeName = fyne.ThemeSizeName(theme.SizeNameText)
|
||||
if len(sl) == 1 && isemoji.IsEmoji(sl[0]) {
|
||||
content.SizeName = fyne.ThemeSizeName(theme.SizeNameHeadingText)
|
||||
content.Refresh()
|
||||
} else {
|
||||
content.SizeName = fyne.ThemeSizeName(theme.SizeNameText)
|
||||
content.Refresh()
|
||||
}
|
||||
|
||||
if sl[0] == "/me" {
|
||||
@@ -797,6 +803,7 @@ func main() {
|
||||
}, w)
|
||||
})
|
||||
w.Resize(fyne.NewSize(500, 500))
|
||||
w.SetIcon(res)
|
||||
|
||||
entry := NewCustomMultiLineEntry()
|
||||
entry.SetPlaceHolder("Say something, you know you want to.\nCtrl+Enter for newline")
|
||||
@@ -1170,7 +1177,7 @@ func main() {
|
||||
|
||||
setNick = widget.NewButton("Set nick", func() {
|
||||
go func() {
|
||||
fyne.Do(func() {setNick.Disable()})
|
||||
fyne.Do(func() { setNick.Disable() })
|
||||
newNick := nickEntry.Text
|
||||
bookmark.Nick = newNick
|
||||
err := client.PublishBookmark(bookmark, context.TODO())
|
||||
@@ -1182,7 +1189,7 @@ func main() {
|
||||
return
|
||||
}
|
||||
client.RefreshBookmarks(false)
|
||||
fyne.Do(func() {setNick.Enable()})
|
||||
fyne.Do(func() { setNick.Enable() })
|
||||
}()
|
||||
})
|
||||
|
||||
@@ -1206,14 +1213,7 @@ func main() {
|
||||
|
||||
joinARoom := fyne.NewMenuItem("connect to a room", func() {
|
||||
dialog.ShowEntryDialog("connect to a room", "JID:", func(s string) {
|
||||
i := resourcePiloadingGif
|
||||
gif, err := extraWidgets.NewAnimatedGifFromResource(i)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
gif.Start()
|
||||
gif.Show()
|
||||
d := dialog.NewCustom("Please wait", "Close", gif, w)
|
||||
d := dialog.NewCustom("Please wait", "Close", widget.NewLabel("Connecting to "+s), w)
|
||||
d.Show()
|
||||
go func() {
|
||||
myjid, err := jid.Parse(s)
|
||||
@@ -1242,14 +1242,7 @@ func main() {
|
||||
|
||||
beginADM := fyne.NewMenuItem("start a DM", func() {
|
||||
dialog.ShowEntryDialog("Start a DM", "JID:", func(s string) {
|
||||
i := resourcePiloadingGif
|
||||
gif, err := extraWidgets.NewAnimatedGifFromResource(i)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
gif.Start()
|
||||
gif.Show()
|
||||
d := dialog.NewCustom("Please wait", "Close", gif, w)
|
||||
d := dialog.NewCustom("Please wait", "Close", widget.NewLabel("Opening a DM with " + s), w)
|
||||
d.Show()
|
||||
go func() {
|
||||
myjid, err := jid.Parse(s)
|
||||
@@ -1408,6 +1401,32 @@ func main() {
|
||||
client.MarkAsRead(&m)
|
||||
})
|
||||
|
||||
rec := fyne.NewMenuItem("retract selected message", func() {
|
||||
selectedScroller, ok := AppTabs.Selected().Content.(*widget.List)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
var activeMucJid string
|
||||
for jid, tabData := range UITabs {
|
||||
if tabData.Scroller == selectedScroller {
|
||||
activeMucJid = jid
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if !chatTabs[activeMucJid].isMuc {
|
||||
return // TODO: For 1:1 DMs we use OccupantID for the ID and send message type 'chat'
|
||||
}
|
||||
|
||||
id := chatTabs[activeMucJid].Messages[selectedId].Raw.StanzaID.ID
|
||||
msg := fmt.Sprintf("<message type='groupchat' to='%s' id='retract-message-1'><retract id='%s' xmlns='urn:xmpp:message-retract:1'/><fallback xmlns='urn:xmpp:fallback:0' for='urn:xmpp:message-retract:1' /><body>This user retracted a previous message, but it's unsupported by your client.</body><store xmlns='urn:xmpp:hints'/></message>", activeMucJid, id)
|
||||
fmt.Println(msg)
|
||||
err := client.Session.Send(context.TODO(), xml.NewDecoder(strings.NewReader(msg)))
|
||||
if err != nil {
|
||||
dialog.ShowError(err, w)
|
||||
}
|
||||
})
|
||||
|
||||
bia := fyne.NewMenuItem("toggle replying to message", func() {
|
||||
replying = !replying
|
||||
})
|
||||
@@ -1517,7 +1536,7 @@ func main() {
|
||||
dialog.ShowCustom("Message", "Close", pre, w)
|
||||
})
|
||||
|
||||
menu_messageoptions := fyne.NewMenu("Γ", bit, bia, bic, red, blck)
|
||||
menu_messageoptions := fyne.NewMenu("Γ", bit, bia, bic, rec, red, blck)
|
||||
ma := fyne.NewMainMenu(menu_help, menu_changeroom, menu_configureview, menu_messageoptions, menu_jokes)
|
||||
w.SetMainMenu(ma)
|
||||
|
||||
@@ -1573,7 +1592,19 @@ func main() {
|
||||
}
|
||||
}
|
||||
|
||||
AppTabs.OnUnselected = func(ti *container.TabItem) {
|
||||
fmt.Println("hiding")
|
||||
selectedScroller, ok := AppTabs.Selected().Content.(*widget.List)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
selectedScroller.Hidden = true
|
||||
}
|
||||
|
||||
var MainSplit *container.Split
|
||||
|
||||
AppTabs.OnSelected = func(ti *container.TabItem) {
|
||||
fmt.Println("showing")
|
||||
chatSidebar.Resize(chatSidebar.Size())
|
||||
if AppTabs.Selected() == AppTabs.Items[0] {
|
||||
chatSidebar.Hidden = true
|
||||
@@ -1584,6 +1615,8 @@ func main() {
|
||||
return
|
||||
}
|
||||
|
||||
selectedScroller.Hidden = false
|
||||
|
||||
var activeChatJid string
|
||||
for jid, tabData := range UITabs {
|
||||
if tabData.Scroller == selectedScroller {
|
||||
@@ -1601,7 +1634,7 @@ func main() {
|
||||
nameLabel.Truncation = fyne.TextTruncateEllipsis
|
||||
memberLabel := widget.NewLabel(fmt.Sprintf("%d members ", len(tab.Members)))
|
||||
memberLabel.Truncation = fyne.TextTruncateEllipsis
|
||||
box := container.NewVBox(nameLabel, )
|
||||
box := container.NewVBox(nameLabel)
|
||||
chatSidebar.Objects = []fyne.CanvasObject{}
|
||||
|
||||
for name, p := range tab.Members {
|
||||
@@ -1649,19 +1682,22 @@ func main() {
|
||||
|
||||
}
|
||||
chatSidebar = *container.NewGridWithColumns(1, container.NewVScroll(box))
|
||||
} else {
|
||||
if activeChatJid == config.Login.User {
|
||||
chatSidebar = *container.NewVBox(widget.NewRichTextFromMarkdown("# " + activeChatJid), widget.NewLabel("Hey, that's you!"))
|
||||
} else {
|
||||
chatSidebar = *container.NewVBox(widget.NewRichTextFromMarkdown("# " + activeChatJid))
|
||||
}
|
||||
}
|
||||
chatSidebar.Hidden = false
|
||||
chatSidebar.Refresh()
|
||||
chatSidebar.Resize(chatSidebar.Size())
|
||||
|
||||
MainSplit.Resize(MainSplit.Size())
|
||||
}
|
||||
|
||||
chatSidebar.Hidden = false
|
||||
statBar.SetText("")
|
||||
chatInfo = *container.NewHBox(widget.NewLabel(""))
|
||||
MainSplit := container.NewHSplit(AppTabs, &chatSidebar)
|
||||
MainSplit = container.NewHSplit(AppTabs, &chatSidebar)
|
||||
DownSplit := container.NewHSplit(entry, container.NewGridWithRows(1, sendbtn, replybtn))
|
||||
|
||||
BigSplit := container.NewVSplit(MainSplit, DownSplit)
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user