diff --git a/assets.go b/assets.go index 96c71f8..bfdd96e 100644 --- a/assets.go +++ b/assets.go @@ -83,6 +83,10 @@ var hourglassB64 string = base64.StdEncoding.EncodeToString(hourglassBytes) var connectBytes []byte var connectB64 string = base64.StdEncoding.EncodeToString(connectBytes) +//go:embed assets/comment.png +var commentBytes []byte +var commentB64 string = base64.StdEncoding.EncodeToString(commentBytes) + func init() { loader := gdkpixbuf.NewPixbufLoader() @@ -235,4 +239,13 @@ func init() { loader.Close() clientAssets["connect"] = gdk.NewTextureForPixbuf(loader.Pixbuf()) + + + loader = gdkpixbuf.NewPixbufLoader() + + commentData, _ := base64.StdEncoding.DecodeString(commentB64) + loader.Write(commentData) + loader.Close() + + clientAssets["comment"] = gdk.NewTextureForPixbuf(loader.Pixbuf()) } diff --git a/assets/comment.png b/assets/comment.png new file mode 100644 index 0000000..7bc9233 Binary files /dev/null and b/assets/comment.png differ diff --git a/main.go b/main.go index 255354f..11b70b9 100644 --- a/main.go +++ b/main.go @@ -7,10 +7,10 @@ import ( "context" "fmt" "github.com/diamondburned/gotk4/pkg/gdk/v4" + "github.com/diamondburned/gotk4/pkg/gdkpixbuf/v2" "github.com/diamondburned/gotk4/pkg/gio/v2" "github.com/diamondburned/gotk4/pkg/glib/v2" "github.com/diamondburned/gotk4/pkg/gtk/v4" - "github.com/diamondburned/gotk4/pkg/gdkpixbuf/v2" "github.com/gen2brain/beeep" "github.com/go-analyze/charts" "path/filepath" @@ -34,6 +34,10 @@ var empty_dialog *gtk.Image var connectionStatus *gtk.Label var connectionIcon *gtk.Image + +var mStatus *gtk.Label +var mIcon *gtk.Image + var pingStatus *gtk.Label // var msgs *gtk.ListBox @@ -111,9 +115,9 @@ func main() { TransportConfiguration: xmpp.TransportConfiguration{ Address: loadedConfig.Server, }, - Jid: loadedConfig.Username + "/lambda." + str, - Credential: xmpp.Password(loadedConfig.Password), - Insecure: loadedConfig.Insecure, + Jid: loadedConfig.Username + "/lambda." + str, + Credential: xmpp.Password(loadedConfig.Password), + Insecure: loadedConfig.Insecure, // StreamLogger: os.Stdout, StreamManagementEnable: true, } @@ -193,7 +197,8 @@ func main() { } */ - originator := jid.MustParse(m.From).Bare().String() + originator := JidMustParse(m.From).Bare() + mStatus.SetText(originator) glib.IdleAdd(func() { //uiQueue <- func() { @@ -308,11 +313,14 @@ func main() { if ok { userdevices.Store(user, userUnit{}) - b := gtk.NewButtonWithLabel(user) - b.ConnectClicked(func() { - b.AddCSSClass("accent") + b := gtk.NewLabel(user) + gesture1 := gtk.NewGestureClick() + gesture1.SetButton(1) + gesture1.Connect("pressed", func() { switchToTab(user, &window.Window) }) + + b.AddController(gesture1) menu.Append(b) } } @@ -375,6 +383,7 @@ func main() { } }() connectionStatus.SetText(fmt.Sprintf("Connected as %s", JidMustParse(clientroot.Session.BindJid).Bare())) + connectionStatus.SetTooltipText(fmt.Sprintf("Binded JID: %s\nUsing TLS: %t", clientroot.Session.BindJid, clientroot.Session.TlsEnabled)) connectionIcon.SetFromPaintable(clientAssets["connect"]) // Join rooms in bookmarks if loadedConfig.JoinBookmarks { @@ -411,11 +420,14 @@ func main() { } createTab(jid, true) - b := gtk.NewButtonWithLabel(jid) - b.ConnectClicked(func() { - b.AddCSSClass("accent") + b := gtk.NewLabel(jid) + gesture1 := gtk.NewGestureClick() + gesture1.SetButton(1) + gesture1.Connect("pressed", func() { switchToTab(jid, &window.Window) }) + + b.AddController(gesture1) menu.Append(b) } }() @@ -604,11 +616,14 @@ func activate(app *gtk.Application) { } createTab(t, true) - b := gtk.NewButtonWithLabel(t) - b.ConnectClicked(func() { - b.AddCSSClass("accent") + b := gtk.NewLabel(t) + gesture1 := gtk.NewGestureClick() + gesture1.SetButton(1) + gesture1.Connect("pressed", func() { switchToTab(t, &window.Window) }) + + b.AddController(gesture1) menu.Append(b) } win.SetVisible(false) @@ -650,6 +665,7 @@ func activate(app *gtk.Application) { cBox := gtk.NewBox(gtk.OrientationHorizontal, 0) connectionIcon = gtk.NewImageFromPaintable((clientAssets["disconnect"])) + connectionIcon.AddCSSClass("icon") connectionStatus = gtk.NewLabel("Disconnected") cBox.Append(connectionIcon) @@ -657,6 +673,25 @@ func activate(app *gtk.Application) { statBar.Append(cBox) + mBox := gtk.NewBox(gtk.OrientationHorizontal, 0) + + gesture1 := gtk.NewGestureClick() + gesture1.SetButton(1) + gesture1.Connect("pressed", func() { + current = mStatus.Text() + switchToTab(current, &window.Window) + }) + + mIcon = gtk.NewImageFromPaintable((clientAssets["comment"])) + mIcon.AddCSSClass("icon") + mStatus = gtk.NewLabel("-") + mStatus.AddController(gesture1) + + cBox.Append(mIcon) + cBox.Append(mStatus) + + statBar.Append(mBox) + pBox := gtk.NewBox(gtk.OrientationHorizontal, 0) pBox.SetTooltipText("Ping between you and your XMPP server\nRight-click to see graph") gesture := gtk.NewGestureClick() @@ -715,7 +750,9 @@ func activate(app *gtk.Application) { pBox.Append(pingStatus) statBar.Append(pBox) - box.Append(statBar) + scrollerStatBar := gtk.NewScrolledWindow() + scrollerStatBar.SetChild(statBar) + box.Append(scrollerStatBar) // scroller.SetChild(empty_dialog) scroller.SetChild(empty_dialog)