Skip to content

Commit 493c3a1

Browse files
authored
Merge pull request #13 from ErikKalkoken/next-version
Improve dialogs and add new switch widget
2 parents 4c27233 + efbe35a commit 493c3a1

File tree

9 files changed

+28
-5
lines changed

9 files changed

+28
-5
lines changed

FyneApp.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Website = "https://github.com/ErikKalkoken/janice"
44
Icon = "icon.png"
55
Name = "Janice"
66
ID = "io.github.erikkalkoken.janice"
7-
Version = "0.6.0"
7+
Version = "0.6.1"
88
Build = 1
99

1010
[Release]

go.mod

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

55
require (
66
fyne.io/fyne/v2 v2.5.2
7-
github.com/ErikKalkoken/fyne-kx v0.0.0-20241025174815-e140dbe057e4
7+
github.com/ErikKalkoken/fyne-kx v0.1.0
88
github.com/dweymouth/fyne-tooltip v0.2.1
99
github.com/hashicorp/go-version v1.7.0
1010
github.com/jarcoal/httpmock v1.3.1
@@ -18,7 +18,7 @@ require (
1818
github.com/BurntSushi/toml v1.4.0 // indirect
1919
github.com/davecgh/go-spew v1.1.1 // indirect
2020
github.com/fredbi/uri v1.1.0 // indirect
21-
github.com/fsnotify/fsnotify v1.7.0 // indirect
21+
github.com/fsnotify/fsnotify v1.8.0 // indirect
2222
github.com/fyne-io/gl-js v0.0.0-20230506162202-1fdaa286a934 // indirect
2323
github.com/fyne-io/glfw-js v0.0.0-20240101223322-6e1efdc71b7a // indirect
2424
github.com/fyne-io/image v0.0.0-20240417123036-dc0ee9e7c964 // indirect

go.sum

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ github.com/BurntSushi/toml v1.4.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2
4747
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
4848
github.com/ErikKalkoken/fyne-kx v0.0.0-20241025174815-e140dbe057e4 h1:7JZ55BPANlRZtMeHevNiFRtLhGYrTenLyoNpQJisGaQ=
4949
github.com/ErikKalkoken/fyne-kx v0.0.0-20241025174815-e140dbe057e4/go.mod h1:N/YVe+viCUiSOr2TziRV7s9iEOlIfS/n/s5r5LiPcXg=
50+
github.com/ErikKalkoken/fyne-kx v0.1.0 h1:vJ7ja3DnIAR/wDSatFcJbqcMqlv8F4Zz8O87mw8uTjU=
51+
github.com/ErikKalkoken/fyne-kx v0.1.0/go.mod h1:N/YVe+viCUiSOr2TziRV7s9iEOlIfS/n/s5r5LiPcXg=
5052
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
5153
github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o=
5254
github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY=
@@ -84,6 +86,8 @@ github.com/fredbi/uri v1.1.0/go.mod h1:aYTUoAXBOq7BLfVJ8GnKmfcuURosB1xyHDIfWeC/i
8486
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
8587
github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA=
8688
github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM=
89+
github.com/fsnotify/fsnotify v1.8.0 h1:dAwr6QBTBZIkG8roQaJjGof0pp0EeF+tNV7YBP3F/8M=
90+
github.com/fsnotify/fsnotify v1.8.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0=
8791
github.com/fyne-io/gl-js v0.0.0-20230506162202-1fdaa286a934 h1:dZC5aKobSN07hf71oMivxUmAofFja5GrfPK2rBlttX4=
8892
github.com/fyne-io/gl-js v0.0.0-20230506162202-1fdaa286a934/go.mod h1:d4clgH0/GrRwWjRzJJQXxT/h1TyuNSfF/X64zb/3Ggg=
8993
github.com/fyne-io/glfw-js v0.0.0-20240101223322-6e1efdc71b7a h1:ybgRdYvAHTn93HW79bLiBiJwVL4jVeyGQRZMgImoeWs=

internal/jsondocument/jsondocument.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,9 @@ func (j *JSONDocument) Value(uid widget.TreeNodeID) Node {
148148
func (j *JSONDocument) Load(ctx context.Context, reader fyne.URIReadCloser, progressInfo binding.Untyped) error {
149149
j.progressInfo = progressInfo
150150
data, err := j.load(ctx, reader)
151+
if errors.Is(err, context.Canceled) {
152+
err = ErrCallerCanceled
153+
}
151154
if err != nil {
152155
return err
153156
}

internal/ui/about.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import (
77
"fyne.io/fyne/v2/container"
88
"fyne.io/fyne/v2/dialog"
99
"fyne.io/fyne/v2/widget"
10+
11+
kxdialog "github.com/ErikKalkoken/fyne-kx/dialog"
1012
)
1113

1214
func (u *UI) showAboutDialog() {
@@ -26,5 +28,6 @@ func (u *UI) showAboutDialog() {
2628
widget.NewHyperlink("Website", x),
2729
)
2830
d := dialog.NewCustom("About", "OK", c, u.window)
31+
kxdialog.AddDialogKeyHandler(d, u.window)
2932
d.Show()
3033
}

internal/ui/menu.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import (
1010
"fyne.io/fyne/v2/dialog"
1111
"fyne.io/fyne/v2/driver/desktop"
1212
"fyne.io/fyne/v2/storage"
13+
kxdialog "github.com/ErikKalkoken/fyne-kx/dialog"
14+
1315
"github.com/ErikKalkoken/janice/internal/jsondocument"
1416
)
1517

@@ -71,6 +73,7 @@ func (u *UI) makeMenu() *fyne.MainMenu {
7173
return
7274
}
7375
}, u.window)
76+
kxdialog.AddDialogKeyHandler(d, u.window)
7477
d.Show()
7578
}),
7679
fyne.NewMenuItem("Export Selection To Clipboard", func() {
@@ -149,6 +152,7 @@ func (u *UI) fileOpen() {
149152
}
150153
u.loadDocument(reader)
151154
}, u.window)
155+
kxdialog.AddDialogKeyHandler(d, u.window)
152156
d.Show()
153157
filterEnabled := u.app.Preferences().BoolWithFallback(settingExtensionFilter, settingExtensionDefault)
154158
if filterEnabled {

internal/ui/searchbar.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"fyne.io/fyne/v2/layout"
1313
"fyne.io/fyne/v2/theme"
1414
"fyne.io/fyne/v2/widget"
15+
kxdialog "github.com/ErikKalkoken/fyne-kx/dialog"
1516
ttwidget "github.com/dweymouth/fyne-tooltip/widget"
1617

1718
"github.com/ErikKalkoken/janice/internal/jsondocument"
@@ -132,6 +133,7 @@ func (f *searchBarFrame) doSearch() {
132133
cancel()
133134
})
134135
d := dialog.NewCustomWithoutButtons("Search", container.NewVBox(c, b), f.u.window)
136+
kxdialog.AddDialogKeyHandler(d, f.u.window)
135137
d.Show()
136138
d.SetOnClosed(func() {
137139
cancel()
@@ -164,6 +166,7 @@ func (f *searchBarFrame) doSearch() {
164166
fmt.Sprintf("No %s found matching %s", searchType, search),
165167
f.u.window,
166168
)
169+
kxdialog.AddDialogKeyHandler(d, f.u.window)
167170
d2.Show()
168171
return
169172
} else if err != nil {

internal/ui/settings.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package ui
33
import (
44
"fyne.io/fyne/v2/dialog"
55
"fyne.io/fyne/v2/widget"
6+
kxdialog "github.com/ErikKalkoken/fyne-kx/dialog"
67
kxwidget "github.com/ErikKalkoken/fyne-kx/widget"
78
)
89

@@ -26,13 +27,13 @@ func (u *UI) showSettingsDialog() {
2627
}
2728

2829
// apply file filter
29-
extFilter := kxwidget.NewToggle(func(v bool) {
30+
extFilter := kxwidget.NewSwitch(func(v bool) {
3031
u.app.Preferences().SetBool(settingExtensionFilter, v)
3132
})
3233
y := u.app.Preferences().BoolWithFallback(settingExtensionFilter, settingExtensionDefault)
3334
extFilter.SetState(y)
3435

35-
notifyUpdates := kxwidget.NewToggle(func(v bool) {
36+
notifyUpdates := kxwidget.NewSwitch(func(v bool) {
3637
u.app.Preferences().SetBool(settingNotifyUpdates, v)
3738
})
3839
z := u.app.Preferences().BoolWithFallback(settingNotifyUpdates, settingNotifyUpdatesDefault)
@@ -44,5 +45,6 @@ func (u *UI) showSettingsDialog() {
4445
{Text: "Notify about updates", Widget: notifyUpdates, HintText: "Wether to notify when an update is available (requires restart)"},
4546
}
4647
d := dialog.NewCustom("Settings", "Close", widget.NewForm(items...), u.window)
48+
kxdialog.AddDialogKeyHandler(d, u.window)
4749
d.Show()
4850
}

internal/ui/ui.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ import (
2020
"golang.org/x/text/language"
2121
"golang.org/x/text/message"
2222

23+
kxdialog "github.com/ErikKalkoken/fyne-kx/dialog"
24+
2325
"github.com/ErikKalkoken/janice/internal/jsondocument"
2426
)
2527

@@ -207,6 +209,7 @@ func (u *UI) showErrorDialog(message string, err error) {
207209
slog.Error(message, "err", err)
208210
}
209211
d := dialog.NewInformation("Error", message, u.window)
212+
kxdialog.AddDialogKeyHandler(d, u.window)
210213
d.Show()
211214
}
212215

@@ -286,6 +289,7 @@ func (u *UI) loadDocument(reader fyne.URIReadCloser) {
286289
d2.SetOnClosed(func() {
287290
cancel()
288291
})
292+
kxdialog.AddDialogKeyHandler(d2, u.window)
289293
d2.Show()
290294
go func() {
291295
doc := jsondocument.New()

0 commit comments

Comments
 (0)