Skip to content

Commit 6bc937c

Browse files
authored
Merge pull request #6 from ErikKalkoken/add-tooltips
Add tooltips
2 parents 1ab3fd5 + 707d6ee commit 6bc937c

File tree

10 files changed

+65
-40
lines changed

10 files changed

+65
-40
lines changed

FyneApp.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@ Website = "https://github.com/ErikKalkoken/janice"
44
Icon = "icon.png"
55
Name = "Janice"
66
ID = "io.github.erikkalkoken.janice"
7-
Version = "0.2.3"
7+
Version = "0.3.0"
88
Build = 1
99

1010
[Release]
1111
BuildName = "janice"
12-
Summary = "A desktop app for viewing large JSON files"
1312
Description = "<p>A desktop app for viewing large JSON files. Please see website for details.</p>"
1413
License = "MIT"
1514
Screenshots = "https://cdn.imgpile.com/f/0IrYBjJ_xl.png"
@@ -18,5 +17,5 @@ Website = "https://github.com/ErikKalkoken/janice"
1817
[LinuxAndBSD]
1918
GenericName = "JSON viewer"
2019
Categories = ["Utility"]
21-
Comment = "View large JSON files"
20+
Comment = "A desktop app for viewing large JSON files"
2221
Keywords = ["json", "viewer"]

go.mod

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ go 1.22.4
44

55
require (
66
fyne.io/fyne/v2 v2.5.0
7+
github.com/dweymouth/fyne-tooltip v0.1.0
78
github.com/hashicorp/go-version v1.7.0
89
github.com/jarcoal/httpmock v1.3.1
910
github.com/json-iterator/go v1.1.12
@@ -28,7 +29,7 @@ require (
2829
github.com/gopherjs/gopherjs v1.17.2 // indirect
2930
github.com/jeandeaual/go-locale v0.0.0-20240223122105-ce5225dcaa49 // indirect
3031
github.com/jsummers/gobmp v0.0.0-20230614200233-a9de23ed2e25 // indirect
31-
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 // indirect
32+
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
3233
github.com/modern-go/reflect2 v1.0.2 // indirect
3334
github.com/nicksnyder/go-i18n/v2 v2.4.0 // indirect
3435
github.com/pmezard/go-difflib v1.0.0 // indirect
@@ -37,7 +38,7 @@ require (
3738
github.com/srwiley/rasterx v0.0.0-20220730225603-2ab79fcdd4ef // indirect
3839
github.com/yuin/goldmark v1.7.4 // indirect
3940
golang.org/x/image v0.18.0 // indirect
40-
golang.org/x/mobile v0.0.0-20240707233753-b765e5d5218f // indirect
41+
golang.org/x/mobile v0.0.0-20240716161057-1ad2df20a8b6 // indirect
4142
golang.org/x/net v0.27.0 // indirect
4243
golang.org/x/sys v0.22.0 // indirect
4344
gopkg.in/yaml.v3 v3.0.1 // indirect

go.sum

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsr
6565
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
6666
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
6767
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
68+
github.com/dweymouth/fyne-tooltip v0.1.0 h1:Qd1KU1TXop/M67pozmxEA2PMy/Jokcn7OgTcdrj4hUs=
69+
github.com/dweymouth/fyne-tooltip v0.1.0/go.mod h1:zEgy7p9tSVIuy2GufFbOCoK3Q04zhyDPOotlU4G3Ma4=
6870
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
6971
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
7072
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
@@ -233,8 +235,9 @@ github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0Qu
233235
github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
234236
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
235237
github.com/mitchellh/mapstructure v1.4.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
236-
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 h1:ZqeYNhU3OHLH3mGKHDcjJRFFRrJa6eAM5H+CtDdOsPc=
237238
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
239+
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
240+
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
238241
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
239242
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
240243
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
@@ -347,8 +350,8 @@ golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPI
347350
golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE=
348351
golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o=
349352
golang.org/x/mobile v0.0.0-20211207041440-4e6c2922fdee/go.mod h1:pe2sM7Uk+2Su1y7u/6Z8KJ24D7lepUjFZbhFOrmDfuQ=
350-
golang.org/x/mobile v0.0.0-20240707233753-b765e5d5218f h1:2Syp6WwwHOaGteLQmOlHCCXA8EyxXppdeDEyNtod9Os=
351-
golang.org/x/mobile v0.0.0-20240707233753-b765e5d5218f/go.mod h1:TCsc78+c4cqb8IKEosz2LwJ6YRNkIjMuAYeHYjchGDE=
353+
golang.org/x/mobile v0.0.0-20240716161057-1ad2df20a8b6 h1:/VlmIrkuLf2wzPjkZ8imSpckHoW7Y71h66dxbLHSpi8=
354+
golang.org/x/mobile v0.0.0-20240716161057-1ad2df20a8b6/go.mod h1:TCsc78+c4cqb8IKEosz2LwJ6YRNkIjMuAYeHYjchGDE=
352355
golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc=
353356
golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY=
354357
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=

internal/github/github.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ type githubRelease struct {
1717
TagName string `json:"tag_name"`
1818
}
1919

20-
// AvailableUpdate return the version of the latest release and reports wether the update is newer.
20+
// AvailableUpdate returns the version of the latest release and reports wether the update is newer.
2121
func AvailableUpdate(owner, repo, current string) (string, bool, error) {
2222
v1, err := version.NewVersion(current)
2323
if err != nil {

internal/ui/about.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,17 @@ import (
1010
)
1111

1212
func (u *UI) showAboutDialog() {
13-
info := u.app.Metadata()
14-
current := info.Version
15-
x, _ := url.Parse(websiteURL)
13+
data := u.app.Metadata()
14+
current := data.Version
15+
x, err := url.Parse(data.Custom["Website"])
16+
if err != nil || x.Path == "" {
17+
x, _ = url.Parse(websiteURL)
18+
}
1619
c := container.NewVBox(
1720
widget.NewRichTextFromMarkdown(
1821
fmt.Sprintf("## %s\n\n"+
1922
"**Version:** %s\n\n"+
20-
"(c) 2024 Erik Kalkoken", info.Name, current),
23+
"(c) 2024 Erik Kalkoken", data.Name, current),
2124
),
2225
widget.NewLabel("A desktop app for viewing large JSON files."),
2326
widget.NewHyperlink("Website", x),

internal/ui/searchbar.go

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import (
1212
"fyne.io/fyne/v2/layout"
1313
"fyne.io/fyne/v2/theme"
1414
"fyne.io/fyne/v2/widget"
15+
ttwidget "github.com/dweymouth/fyne-tooltip/widget"
16+
1517
"github.com/ErikKalkoken/janice/internal/jsondocument"
1618
)
1719

@@ -37,11 +39,11 @@ type searchBarFrame struct {
3739
ui *UI
3840

3941
searchEntry *widget.Entry
40-
searchButton *widget.Button
41-
searchType *widget.Select
42-
scrollBottom *widget.Button
43-
scrollTop *widget.Button
44-
collapseAll *widget.Button
42+
searchButton *ttwidget.Button
43+
searchType *ttwidget.Select
44+
scrollBottom *ttwidget.Button
45+
scrollTop *ttwidget.Button
46+
collapseAll *ttwidget.Button
4547
}
4648

4749
func (u *UI) newSearchBarFrame() *searchBarFrame {
@@ -50,31 +52,36 @@ func (u *UI) newSearchBarFrame() *searchBarFrame {
5052
searchEntry: widget.NewEntry(),
5153
}
5254
// search frame
53-
f.searchType = widget.NewSelect([]string{
55+
f.searchType = ttwidget.NewSelect([]string{
5456
searchTypeKey,
5557
searchTypeKeyword,
5658
searchTypeNumber,
5759
searchTypeString,
5860
}, nil)
5961
f.searchType.SetSelected(searchTypeKey)
62+
f.searchType.SetToolTip("Select what to search")
6063
f.searchType.Disable()
6164
f.searchEntry.SetPlaceHolder(
6265
"Enter pattern to search for...")
6366
f.searchEntry.OnSubmitted = func(s string) {
6467
f.doSearch()
6568
}
66-
f.searchButton = widget.NewButtonWithIcon("", theme.SearchIcon(), func() {
69+
f.searchButton = ttwidget.NewButtonWithIcon("", theme.SearchIcon(), func() {
6770
f.doSearch()
6871
})
69-
f.scrollBottom = widget.NewButtonWithIcon("", theme.NewThemedResource(resourceVerticalalignbottomSvg), func() {
72+
f.searchButton.SetToolTip("Search")
73+
f.scrollBottom = ttwidget.NewButtonWithIcon("", theme.NewThemedResource(resourceVerticalalignbottomSvg), func() {
7074
f.ui.treeWidget.ScrollToBottom()
7175
})
72-
f.scrollTop = widget.NewButtonWithIcon("", theme.NewThemedResource(resourceVerticalaligntopSvg), func() {
76+
f.scrollBottom.SetToolTip("Scroll to bottom")
77+
f.scrollTop = ttwidget.NewButtonWithIcon("", theme.NewThemedResource(resourceVerticalaligntopSvg), func() {
7378
f.ui.treeWidget.ScrollToTop()
7479
})
75-
f.collapseAll = widget.NewButtonWithIcon("", theme.NewThemedResource(resourceUnfoldlessSvg), func() {
80+
f.scrollTop.SetToolTip("Scroll to top")
81+
f.collapseAll = ttwidget.NewButtonWithIcon("", theme.NewThemedResource(resourceUnfoldlessSvg), func() {
7682
f.ui.treeWidget.CloseAllBranches()
7783
})
84+
f.collapseAll.SetToolTip("Collapse all")
7885
c := container.NewBorder(
7986
nil,
8087
nil,

internal/ui/selection.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import (
66
"fyne.io/fyne/v2/layout"
77
"fyne.io/fyne/v2/theme"
88
"fyne.io/fyne/v2/widget"
9+
ttwidget "github.com/dweymouth/fyne-tooltip/widget"
10+
911
"github.com/ErikKalkoken/janice/internal/jsondocument"
1012
"github.com/ErikKalkoken/janice/internal/widgets"
1113
)
@@ -17,8 +19,8 @@ type selectionFrame struct {
1719

1820
selectedUID widget.TreeNodeID
1921
selectedPath *fyne.Container
20-
jumpToSelection *widget.Button
21-
copyKeyClipboard *widget.Button
22+
jumpToSelection *ttwidget.Button
23+
copyKeyClipboard *ttwidget.Button
2224
}
2325

2426
func (u *UI) newSelectionFrame() *selectionFrame {
@@ -28,14 +30,16 @@ func (u *UI) newSelectionFrame() *selectionFrame {
2830
ui: u,
2931
selectedPath: container.New(myHBox),
3032
}
31-
f.jumpToSelection = widget.NewButtonWithIcon("", theme.NewThemedResource(resourceReadmoreSvg), func() {
33+
f.jumpToSelection = ttwidget.NewButtonWithIcon("", theme.NewThemedResource(resourceReadmoreSvg), func() {
3234
u.scrollTo(f.selectedUID)
3335
})
36+
f.jumpToSelection.SetToolTip("Jump to selection")
3437
f.jumpToSelection.Disable()
35-
f.copyKeyClipboard = widget.NewButtonWithIcon("", theme.ContentCopyIcon(), func() {
38+
f.copyKeyClipboard = ttwidget.NewButtonWithIcon("", theme.ContentCopyIcon(), func() {
3639
n := u.document.Value(f.selectedUID)
3740
u.window.Clipboard().SetContent(n.Key)
3841
})
42+
f.copyKeyClipboard.SetToolTip("Copy key to clipboard")
3943
f.copyKeyClipboard.Disable()
4044
c := container.NewBorder(
4145
nil,

internal/ui/statusbar.go

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
package ui
22

33
import (
4+
"fmt"
45
"log/slog"
56
"net/url"
67

78
"fyne.io/fyne/v2"
89
"fyne.io/fyne/v2/container"
910
"fyne.io/fyne/v2/layout"
10-
"fyne.io/fyne/v2/widget"
11-
"github.com/ErikKalkoken/janice/internal/github"
11+
ttwidget "github.com/dweymouth/fyne-tooltip/widget"
1212
"golang.org/x/text/language"
1313
"golang.org/x/text/message"
14+
15+
"github.com/ErikKalkoken/janice/internal/github"
1416
)
1517

1618
const (
@@ -23,21 +25,22 @@ type statusBarFrame struct {
2325
content *fyne.Container
2426
ui *UI
2527

26-
statusTreeSize *widget.Label
28+
elementsCount *ttwidget.Label
2729
}
2830

2931
func (u *UI) newStatusBarFrame() *statusBarFrame {
3032
f := &statusBarFrame{
31-
ui: u,
32-
statusTreeSize: widget.NewLabel(""),
33+
ui: u,
34+
elementsCount: ttwidget.NewLabel(""),
3335
}
36+
f.elementsCount.SetToolTip("Total count of elements in the JSON document")
3437
// status bar frame
35-
c := container.NewHBox(f.statusTreeSize)
38+
c := container.NewHBox(f.elementsCount)
3639
notifyUpdates := u.app.Preferences().BoolWithFallback(settingNotifyUpdates, settingNotifyUpdatesDefault)
3740
if notifyUpdates {
3841
go func() {
3942
current := u.app.Metadata().Version
40-
_, isNewer, err := github.AvailableUpdate(githubOwner, githubRepo, current)
43+
latest, isNewer, err := github.AvailableUpdate(githubOwner, githubRepo, current)
4144
if err != nil {
4245
slog.Error("Failed to fetch latest version from github", "err", err)
4346
return
@@ -47,7 +50,8 @@ func (u *UI) newStatusBarFrame() *statusBarFrame {
4750
}
4851
c.Add(layout.NewSpacer())
4952
x, _ := url.Parse(websiteURL + "/releases")
50-
l := widget.NewHyperlink("Update available", x)
53+
l := ttwidget.NewHyperlink("Update available", x)
54+
l.SetToolTip(fmt.Sprintf("Newer version %s available for download", latest))
5155
c.Add(l)
5256
}()
5357
}
@@ -56,9 +60,9 @@ func (u *UI) newStatusBarFrame() *statusBarFrame {
5660
}
5761

5862
func (f *statusBarFrame) reset() {
59-
f.statusTreeSize.SetText("")
63+
f.elementsCount.SetText("")
6064
}
6165
func (f *statusBarFrame) set(size int) {
6266
p := message.NewPrinter(language.English)
63-
f.statusTreeSize.SetText(p.Sprintf("%d elements", size))
67+
f.elementsCount.SetText(p.Sprintf("%d elements", size))
6468
}

internal/ui/ui.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
"fyne.io/fyne/v2/storage"
1717
"fyne.io/fyne/v2/theme"
1818
"fyne.io/fyne/v2/widget"
19+
fynetooltip "github.com/dweymouth/fyne-tooltip"
1920
"golang.org/x/text/language"
2021
"golang.org/x/text/message"
2122

@@ -82,7 +83,7 @@ func NewUI(app fyne.App) (*UI, error) {
8283
nil,
8384
container.NewStack(u.welcomeMessage, u.treeWidget))
8485

85-
u.window.SetContent(c)
86+
u.window.SetContent(fynetooltip.AddWindowToolTipLayer(c, u.window.Canvas()))
8687
u.window.SetMainMenu(u.makeMenu())
8788
u.toogleHasDocument(false)
8889
u.updateRecentFilesMenu()

internal/ui/value.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import (
88
"fyne.io/fyne/v2/container"
99
"fyne.io/fyne/v2/theme"
1010
"fyne.io/fyne/v2/widget"
11+
ttwidget "github.com/dweymouth/fyne-tooltip/widget"
12+
1113
"github.com/ErikKalkoken/janice/internal/jsondocument"
1214
)
1315

@@ -16,7 +18,7 @@ type valueFrame struct {
1618
content *fyne.Container
1719
ui *UI
1820

19-
copyValueClipboard *widget.Button
21+
copyValueClipboard *ttwidget.Button
2022
valueDisplay *widget.RichText
2123
valueRaw string
2224
}
@@ -27,9 +29,10 @@ func (u *UI) newValueFrame() *valueFrame {
2729
valueDisplay: widget.NewRichText(),
2830
}
2931
// value frame
30-
f.copyValueClipboard = widget.NewButtonWithIcon("", theme.ContentCopyIcon(), func() {
32+
f.copyValueClipboard = ttwidget.NewButtonWithIcon("", theme.ContentCopyIcon(), func() {
3133
u.window.Clipboard().SetContent(f.valueRaw)
3234
})
35+
f.copyValueClipboard.SetToolTip("Copy value to clipboard")
3336
f.copyValueClipboard.Disable()
3437
c := container.NewBorder(
3538
nil,

0 commit comments

Comments
 (0)