Skip to content

Commit 877a7e5

Browse files
authored
Merge pull request #26 from ErikKalkoken/upgrade-fyne-26
chore: migrate to Fyne 2.6
2 parents 7afda85 + d7c4f0d commit 877a7e5

File tree

9 files changed

+108
-83
lines changed

9 files changed

+108
-83
lines changed

FyneApp.toml

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,24 @@
11
Website = "https://github.com/ErikKalkoken/janice"
22

33
[Details]
4-
Icon = "icon.png"
5-
Name = "Janice"
6-
ID = "io.github.erikkalkoken.janice"
7-
Version = "0.7.1"
8-
Build = 0
4+
Icon = "icon.png"
5+
Name = "Janice"
6+
ID = "io.github.erikkalkoken.janice"
7+
Version = "0.8.0"
8+
Build = 0
99

1010
[Release]
11-
BuildName = "janice"
12-
ContentRating = "oars-1.1"
13-
Description = "<p>A desktop app for viewing large JSON files. Please see website for details.</p>"
14-
License = "MIT"
15-
Screenshots = "https://cdn.imgpile.com/f/0IrYBjJ_xl.png"
11+
BuildName = "janice"
12+
ContentRating = "oars-1.1"
13+
Description = "<p>A desktop app for viewing large JSON files. Please see website for details.</p>"
14+
License = "MIT"
15+
Screenshots = "https://cdn.imgpile.com/f/0IrYBjJ_xl.png"
1616

1717
[LinuxAndBSD]
18-
GenericName = "JSON viewer"
19-
Categories = ["Utility"]
20-
Comment = "A desktop app for viewing large JSON files"
21-
Keywords = ["json", "viewer"]
18+
GenericName = "JSON viewer"
19+
Categories = ["Utility"]
20+
Comment = "A desktop app for viewing large JSON files"
21+
Keywords = ["json", "viewer"]
22+
23+
[Migrations]
24+
fyneDo = true

go.mod

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,10 @@ go 1.24
44

55
toolchain go1.24.1
66

7-
exclude github.com/dweymouth/fyne-tooltip v0.3.0
8-
97
require (
10-
fyne.io/fyne/v2 v2.5.5
11-
github.com/ErikKalkoken/fyne-kx v0.4.1
12-
github.com/dweymouth/fyne-tooltip v0.2.1
8+
fyne.io/fyne/v2 v2.6.0
9+
github.com/ErikKalkoken/fyne-kx v0.5.0
10+
github.com/dweymouth/fyne-tooltip v0.3.1
1311
github.com/hashicorp/go-version v1.7.0
1412
github.com/jarcoal/httpmock v1.4.0
1513
github.com/json-iterator/go v1.1.12
@@ -26,11 +24,14 @@ require (
2624
github.com/fyne-io/gl-js v0.1.0 // indirect
2725
github.com/fyne-io/glfw-js v0.2.0 // indirect
2826
github.com/fyne-io/image v0.1.1 // indirect
27+
github.com/fyne-io/oksvg v0.1.0 // indirect
2928
github.com/go-gl/gl v0.0.0-20231021071112-07e5d0ea2e71 // indirect
3029
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20250301202403-da16c1255728 // indirect
3130
github.com/go-text/render v0.2.0 // indirect
3231
github.com/go-text/typesetting v0.3.0 // indirect
3332
github.com/godbus/dbus/v5 v5.1.0 // indirect
33+
github.com/hack-pad/go-indexeddb v0.3.2 // indirect
34+
github.com/hack-pad/safejs v0.1.1 // indirect
3435
github.com/jeandeaual/go-locale v0.0.0-20241217141322-fcc2cadd6f08 // indirect
3536
github.com/jsummers/gobmp v0.0.0-20230614200233-a9de23ed2e25 // indirect
3637
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
@@ -41,9 +42,8 @@ require (
4142
github.com/rymdport/portal v0.4.1 // indirect
4243
github.com/srwiley/oksvg v0.0.0-20221011165216-be6e8873101c // indirect
4344
github.com/srwiley/rasterx v0.0.0-20220730225603-2ab79fcdd4ef // indirect
44-
github.com/yuin/goldmark v1.7.8 // indirect
45+
github.com/yuin/goldmark v1.7.10 // indirect
4546
golang.org/x/image v0.26.0 // indirect
46-
golang.org/x/mobile v0.0.0-20250408133729-978277e7eaf7 // indirect
4747
golang.org/x/net v0.39.0 // indirect
4848
golang.org/x/sys v0.32.0 // indirect
4949
gopkg.in/yaml.v3 v3.0.1 // indirect

go.sum

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
1-
fyne.io/fyne/v2 v2.5.5 h1:IhS8Vf1EtSHS94/i41D9Rh4s1rG1habkGN/oISA0kTU=
2-
fyne.io/fyne/v2 v2.5.5/go.mod h1:0GOXKqyvNwk3DLmsFu9v0oYM0ZcD1ysGnlHCerKoAmo=
1+
fyne.io/fyne/v2 v2.6.0 h1:Rywo9yKYN4qvNuvkRuLF+zxhJYWbIFM+m4N4KV4p1pQ=
2+
fyne.io/fyne/v2 v2.6.0/go.mod h1:YZt7SksjvrSNJCwbWFV32WON3mE1Sr7L41D29qMZ/lU=
33
fyne.io/systray v1.11.0 h1:D9HISlxSkx+jHSniMBR6fCFOUjk1x/OOOJLa9lJYAKg=
44
fyne.io/systray v1.11.0/go.mod h1:RVwqP9nYMo7h5zViCBHri2FgjXF7H2cub7MAq4NSoLs=
55
github.com/BurntSushi/toml v1.5.0 h1:W5quZX/G/csjUnuI8SUYlsHs9M38FC7znL0lIO+DvMg=
66
github.com/BurntSushi/toml v1.5.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
77
github.com/ErikKalkoken/fyne-kx v0.4.1 h1:hn3xQVPMZ3LYlXWQs3k/w5++2NrMWS6+dtbpD/QtfNY=
88
github.com/ErikKalkoken/fyne-kx v0.4.1/go.mod h1:u6ze+0ey4IDE3dTDSwI57HQBWDXJSxoUejFJF1G3Avs=
9+
github.com/ErikKalkoken/fyne-kx v0.5.0 h1:HcGXR1ISL1zSeZ87Fi2rXB+wM+7GGpCteUBBJzP/30A=
10+
github.com/ErikKalkoken/fyne-kx v0.5.0/go.mod h1:QINA4rAyddbeO1hsGXpHzFhRdbN3L3nDYbymn9zOBjo=
911
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
1012
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
1113
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
12-
github.com/dweymouth/fyne-tooltip v0.2.1 h1:I+uOIcDcSCvK2ydKina4oehIsR9PrmfyesmT1uxOW9A=
13-
github.com/dweymouth/fyne-tooltip v0.2.1/go.mod h1:zEgy7p9tSVIuy2GufFbOCoK3Q04zhyDPOotlU4G3Ma4=
14+
github.com/dweymouth/fyne-tooltip v0.3.1 h1:QnDMfo2eGM1kT8bGnpreUeSdsVa9H/CXUl0OvUssgqQ=
15+
github.com/dweymouth/fyne-tooltip v0.3.1/go.mod h1:jXYbY561DTIXXqkauzltI3o/hsVaQd2KY8Ry2FXy7Xk=
1416
github.com/felixge/fgprof v0.9.3 h1:VvyZxILNuCiUCSXtPtYmmtGvb65nqXh2QFWc0Wpf2/g=
1517
github.com/felixge/fgprof v0.9.3/go.mod h1:RdbpDgzqYVh/T9fPELJyV7EYJuHB55UTEULNun8eiPw=
1618
github.com/fredbi/uri v1.1.0 h1:OqLpTXtyRg9ABReqvDGdJPqZUxs8cyBDOMXBbskCaB8=
@@ -23,6 +25,8 @@ github.com/fyne-io/glfw-js v0.2.0 h1:8GUZtN2aCoTPNqgRDxK5+kn9OURINhBEBc7M4O1KrmM
2325
github.com/fyne-io/glfw-js v0.2.0/go.mod h1:Ri6te7rdZtBgBpxLW19uBpp3Dl6K9K/bRaYdJ22G8Jk=
2426
github.com/fyne-io/image v0.1.1 h1:WH0z4H7qfvNUw5l4p3bC1q70sa5+YWVt6HCj7y4VNyA=
2527
github.com/fyne-io/image v0.1.1/go.mod h1:xrfYBh6yspc+KjkgdZU/ifUC9sPA5Iv7WYUBzQKK7JM=
28+
github.com/fyne-io/oksvg v0.1.0 h1:7EUKk3HV3Y2E+qypp3nWqMXD7mum0hCw2KEGhI1fnBw=
29+
github.com/fyne-io/oksvg v0.1.0/go.mod h1:dJ9oEkPiWhnTFNCmRgEze+YNprJF7YRbpjgpWS4kzoI=
2630
github.com/go-gl/gl v0.0.0-20231021071112-07e5d0ea2e71 h1:5BVwOaUSBTlVZowGO6VZGw2H/zl9nrd3eCZfYV+NfQA=
2731
github.com/go-gl/gl v0.0.0-20231021071112-07e5d0ea2e71/go.mod h1:9YTyiznxEY1fVinfM7RvRcjRHbw2xLBJ3AAGIT0I4Nw=
2832
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20250301202403-da16c1255728 h1:RkGhqHxEVAvPM0/R+8g7XRwQnHatO0KAuVcwHo8q9W8=
@@ -38,6 +42,10 @@ github.com/godbus/dbus/v5 v5.1.0/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5x
3842
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
3943
github.com/google/pprof v0.0.0-20211214055906-6f57359322fd h1:1FjCyPC+syAzJ5/2S8fqdZK1R22vvA0J7JZKcuOIQ7Y=
4044
github.com/google/pprof v0.0.0-20211214055906-6f57359322fd/go.mod h1:KgnwoLYCZ8IQu3XUZ8Nc/bM9CCZFOyjUNOSygVozoDg=
45+
github.com/hack-pad/go-indexeddb v0.3.2 h1:DTqeJJYc1usa45Q5r52t01KhvlSN02+Oq+tQbSBI91A=
46+
github.com/hack-pad/go-indexeddb v0.3.2/go.mod h1:QvfTevpDVlkfomY498LhstjwbPW6QC4VC/lxYb0Kom0=
47+
github.com/hack-pad/safejs v0.1.1 h1:d5qPO0iQ7h2oVtpzGnLExE+Wn9AtytxIfltcS2b9KD8=
48+
github.com/hack-pad/safejs v0.1.1/go.mod h1:HdS+bKF1NrE72VoXZeWzxFOVQVUSqZJAG0xNCnb+Tio=
4149
github.com/hashicorp/go-version v1.7.0 h1:5tqGy27NaOTB8yJKUZELlFAS/LTKJkrmONwQKeRZfjY=
4250
github.com/hashicorp/go-version v1.7.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
4351
github.com/jarcoal/httpmock v1.4.0 h1:BvhqnH0JAYbNudL2GMJKgOHe2CtKlzJ/5rWKyp+hc2k=
@@ -77,12 +85,10 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+
7785
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
7886
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
7987
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
80-
github.com/yuin/goldmark v1.7.8 h1:iERMLn0/QJeHFhxSt3p6PeN9mGnvIKSpG9YYorDMnic=
81-
github.com/yuin/goldmark v1.7.8/go.mod h1:uzxRWxtg69N339t3louHJ7+O03ezfj6PlliRlaOzY1E=
88+
github.com/yuin/goldmark v1.7.10 h1:S+LrtBjRmqMac2UdtB6yyCEJm+UILZ2fefI4p7o0QpI=
89+
github.com/yuin/goldmark v1.7.10/go.mod h1:ip/1k0VRfGynBgxOz0yCqHrbZXhcjxyuS66Brc7iBKg=
8290
golang.org/x/image v0.26.0 h1:4XjIFEZWQmCZi6Wv8BoxsDhRU3RVnLX04dToTDAEPlY=
8391
golang.org/x/image v0.26.0/go.mod h1:lcxbMFAovzpnJxzXS3nyL83K27tmqtKzIJpctK8YO5c=
84-
golang.org/x/mobile v0.0.0-20250408133729-978277e7eaf7 h1:8MGTx39304caZ/OMsjPfuxUoDGI2tRas92F5x97tIYc=
85-
golang.org/x/mobile v0.0.0-20250408133729-978277e7eaf7/go.mod h1:ftACcHgQ7vaOnQbHOHvXt9Y6bEPHrs5Ovk67ClwrPJA=
8692
golang.org/x/net v0.39.0 h1:ZCu7HMWDxpXpaiKdhzIfaltL9Lp31x/3fCP11bc6/fY=
8793
golang.org/x/net v0.39.0/go.mod h1:X7NRbYVEA+ewNkCNyJ513WmMdQ3BineSwVtN2zD/d+E=
8894
golang.org/x/sys v0.32.0 h1:s77OFDvIQeibCmezSnk/q6iAfkdiQaJi4VzroCFrN20=

internal/jsondocument/jsondocument_internal_test.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@ import (
88
"strings"
99
"testing"
1010

11+
"fyne.io/fyne/v2/test"
1112
"github.com/stretchr/testify/assert"
1213
)
1314

1415
func TestLoadFile(t *testing.T) {
1516
ctx := context.Background()
16-
j := New()
17+
test.NewTempApp(t) // calling Fyne features requires a Fyne app to exist
1718
t.Run("should return load and unmarshaled data from stream", func(t *testing.T) {
1819
// given
1920
data := map[string]any{"alpha": "two"}
@@ -22,6 +23,7 @@ func TestLoadFile(t *testing.T) {
2223
t.Fatal(err)
2324
}
2425
r := MakeURIReadCloser(bytes.NewReader(dat), "test")
26+
j := New()
2527
// when
2628
got, err := j.load(ctx, r)
2729
// then
@@ -33,6 +35,7 @@ func TestLoadFile(t *testing.T) {
3335
t.Run("should return error when stream can not be unmarshaled", func(t *testing.T) {
3436
// given
3537
r := MakeURIReadCloser(strings.NewReader("invalid JSON"), "test")
38+
j := New()
3639
// when
3740
_, err := j.load(ctx, r)
3841
// then
@@ -41,7 +44,8 @@ func TestLoadFile(t *testing.T) {
4144
}
4245

4346
func TestAddNode(t *testing.T) {
44-
ctx := context.TODO()
47+
ctx := context.Background()
48+
test.NewTempApp(t) // calling Fyne features requires a Fyne app to exist
4549
t.Run("can add root node", func(t *testing.T) {
4650
j := New()
4751
j.initialize(10)

internal/ui/detail.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func newDetail(u *UI) *detail {
3030
}
3131
w.ExtendBaseWidget(w)
3232
w.copyValueClipboard = ttwidget.NewButtonWithIcon("", theme.ContentCopyIcon(), func() {
33-
u.window.Clipboard().SetContent(w.valueRaw)
33+
u.app.Clipboard().SetContent(w.valueRaw)
3434
})
3535
w.copyValueClipboard.SetToolTip("Copy value to clipboard")
3636
w.copyValueClipboard.Disable()

internal/ui/searchbar.go

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,10 @@ func (w *searchBar) doSearch() {
136136
typ = jsondocument.SearchKeyword
137137
search = strings.ToLower(search)
138138
if search != "true" && search != "false" && search != "null" {
139-
d.Hide()
140-
w.u.showErrorDialog("Allowed keywords are: true, false, null", nil)
139+
fyne.Do(func() {
140+
d.Hide()
141+
w.u.showErrorDialog("Allowed keywords are: true, false, null", nil)
142+
})
141143
return
142144
}
143145
case searchTypeString:
@@ -146,23 +148,25 @@ func (w *searchBar) doSearch() {
146148
typ = jsondocument.SearchNumber
147149
}
148150
uid, err := w.u.document.Search(ctx, w.u.selection.selectedUID, search, typ)
149-
d.Hide()
150-
if errors.Is(err, jsondocument.ErrCallerCanceled) {
151-
return
152-
} else if errors.Is(err, jsondocument.ErrNotFound) {
153-
d2 := dialog.NewInformation(
154-
"No match",
155-
fmt.Sprintf("No %s found matching %s", searchType, search),
156-
w.u.window,
157-
)
158-
kxdialog.AddDialogKeyHandler(d, w.u.window)
159-
d2.Show()
160-
return
161-
} else if err != nil {
162-
w.u.showErrorDialog("Search failed", err)
163-
return
164-
}
165-
w.u.tree.scrollTo(uid)
151+
fyne.Do(func() {
152+
d.Hide()
153+
if errors.Is(err, jsondocument.ErrCallerCanceled) {
154+
return
155+
} else if errors.Is(err, jsondocument.ErrNotFound) {
156+
d2 := dialog.NewInformation(
157+
"No match",
158+
fmt.Sprintf("No %s found matching %s", searchType, search),
159+
w.u.window,
160+
)
161+
kxdialog.AddDialogKeyHandler(d, w.u.window)
162+
d2.Show()
163+
return
164+
} else if err != nil {
165+
w.u.showErrorDialog("Search failed", err)
166+
return
167+
}
168+
w.u.tree.scrollTo(uid)
169+
})
166170
}()
167171
}
168172

internal/ui/selection.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func newSelection(u *UI) *selection {
3636
w.jumpToSelection.Disable()
3737
w.copyKeyClipboard = ttwidget.NewButtonWithIcon("", theme.ContentCopyIcon(), func() {
3838
n := u.document.Value(w.selectedUID)
39-
u.window.Clipboard().SetContent(n.Key)
39+
u.app.Clipboard().SetContent(n.Key)
4040
})
4141
w.copyKeyClipboard.SetToolTip("Copy key to clipboard")
4242
w.copyKeyClipboard.Disable()

internal/ui/statusbar.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,10 @@ func newStatusBar(u *UI) *statusBar {
5252
if !isNewer {
5353
return
5454
}
55-
w.updateLink.SetToolTip(fmt.Sprintf("Newer version %s available for download", latest))
56-
w.updateLink.Show()
55+
fyne.Do(func() {
56+
w.updateLink.SetToolTip(fmt.Sprintf("Newer version %s available for download", latest))
57+
w.updateLink.Show()
58+
})
5759
}()
5860
}
5961
return w

internal/ui/ui.go

Lines changed: 35 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -268,33 +268,39 @@ func (u *UI) loadDocument(reader fyne.URIReadCloser) {
268268
go func() {
269269
doc := jsondocument.New()
270270
if err := doc.Load(ctx, reader, progressInfo); err != nil {
271-
d2.Hide()
271+
fyne.Do(func() {
272+
d2.Hide()
273+
})
272274
if errors.Is(err, jsondocument.ErrCallerCanceled) {
273275
return
274276
}
275-
u.showErrorDialog(fmt.Sprintf("Failed to open document: %s", reader.URI()), err)
277+
fyne.Do(func() {
278+
u.showErrorDialog(fmt.Sprintf("Failed to open document: %s", reader.URI()), err)
279+
})
276280
return
277281
}
278-
u.document = doc
279-
u.statusBar.set(u.document.Size())
280-
u.welcomeMessage.Hide()
281-
u.toogleHasDocument(true)
282-
if doc.Size() > 1000 {
283-
u.viewExpandAll.Disabled = true
284-
} else {
285-
u.viewExpandAll.Disabled = false
286-
}
287-
u.window.MainMenu().Refresh()
288-
u.tree.Refresh()
289-
uri := reader.URI()
290-
if uri.Scheme() == "file" {
291-
u.addRecentFile(uri)
292-
}
293-
u.setTitle(uri.Name())
294-
u.currentFile = uri
295-
u.selection.reset()
296-
u.detail.reset()
297-
d2.Hide()
282+
fyne.Do(func() {
283+
u.document = doc
284+
u.statusBar.set(u.document.Size())
285+
u.welcomeMessage.Hide()
286+
u.toogleHasDocument(true)
287+
if doc.Size() > 1000 {
288+
u.viewExpandAll.Disabled = true
289+
} else {
290+
u.viewExpandAll.Disabled = false
291+
}
292+
u.window.MainMenu().Refresh()
293+
u.tree.Refresh()
294+
uri := reader.URI()
295+
if uri.Scheme() == "file" {
296+
u.addRecentFile(uri)
297+
}
298+
u.setTitle(uri.Name())
299+
u.currentFile = uri
300+
u.selection.reset()
301+
u.detail.reset()
302+
d2.Hide()
303+
})
298304
}()
299305
}
300306

@@ -303,7 +309,7 @@ func (u *UI) toogleHasDocument(enabled bool) {
303309
u.searchBar.enable()
304310
u.fileExportClipboard.Disabled = false
305311
u.fileExportFile.Disabled = u.selection.selectedUID == ""
306-
u.fileNew.Disabled = u.selection.selectedUID == ""
312+
u.fileNew.Disabled = false
307313
u.fileReload.Disabled = false
308314
u.goBottom.Disabled = false
309315
u.goSelection.Disabled = false
@@ -411,6 +417,10 @@ func (u *UI) showSettingsDialog() {
411417

412418
func (u *UI) makeMenu() *fyne.MainMenu {
413419
// File menu
420+
u.fileNew = fyne.NewMenuItem("New", u.newFile)
421+
u.fileNew.Shortcut = &desktop.CustomShortcut{KeyName: fyne.KeyN, Modifier: fyne.KeyModifierControl}
422+
u.window.Canvas().AddShortcut(addShortcutFromMenuItem(u.fileNew))
423+
414424
u.fileOpenRecent = fyne.NewMenuItem("Open Recent", nil)
415425
u.fileOpenRecent.ChildMenu = fyne.NewMenu("")
416426

@@ -426,10 +436,6 @@ func (u *UI) makeMenu() *fyne.MainMenu {
426436
fileOpenItem.Shortcut = &desktop.CustomShortcut{KeyName: fyne.KeyO, Modifier: fyne.KeyModifierControl}
427437
u.window.Canvas().AddShortcut(addShortcutFromMenuItem(fileOpenItem))
428438

429-
u.fileNew = fyne.NewMenuItem("New", u.newFile)
430-
u.fileNew.Shortcut = &desktop.CustomShortcut{KeyName: fyne.KeyN, Modifier: fyne.KeyModifierControl}
431-
u.window.Canvas().AddShortcut(addShortcutFromMenuItem(u.fileNew))
432-
433439
u.fileExportFile = fyne.NewMenuItem("Export Selection To File...", func() {
434440
byt, err := u.extractSelection()
435441
if err != nil {
@@ -458,15 +464,15 @@ func (u *UI) makeMenu() *fyne.MainMenu {
458464
if err != nil {
459465
u.showErrorDialog("Failed to extract selection", err)
460466
}
461-
u.window.Clipboard().SetContent(string(byt))
467+
u.app.Clipboard().SetContent(string(byt))
462468
})
463469
fileMenu := fyne.NewMenu("File",
464470
u.fileNew,
465471
fyne.NewMenuItemSeparator(),
466472
fileOpenItem,
467473
u.fileOpenRecent,
468474
fyne.NewMenuItem("Open From Clipboard", func() {
469-
r := strings.NewReader(u.window.Clipboard().Content())
475+
r := strings.NewReader(u.app.Clipboard().Content())
470476
reader := jsondocument.MakeURIReadCloser(r, "CLIPBOARD")
471477
u.loadDocument(reader)
472478
}),

0 commit comments

Comments
 (0)