-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
681 lines (602 loc) · 21.6 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
package main
import (
"fmt"
"image/color"
"log"
"net/url"
"os"
"os/exec"
"os/signal"
"path/filepath"
"sync"
customdialog "owlcms-launcher/dialog" // Alias our custom dialog package
"owlcms-launcher/downloadUtils"
"owlcms-launcher/javacheck"
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/app"
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/dialog"
"fyne.io/fyne/v2/layout"
"fyne.io/fyne/v2/theme"
"fyne.io/fyne/v2/widget"
"github.com/Masterminds/semver/v3"
)
var (
owlcmsInstallDir = getInstallDir()
currentProcess *exec.Cmd
currentVersion string // Add to track current version
statusLabel *widget.Label
stopButton *widget.Button
versionContainer *fyne.Container
stopContainer *fyne.Container
singleOrMultiVersionLabel *widget.Label // New label for single or multi version update
downloadContainer *fyne.Container // New global to track the same container
downloadsShown bool // New global to track whether downloads are shown
urlLink *widget.Hyperlink // Add this new variable
)
func init() {
javacheck.InitJavaCheck(owlcmsInstallDir)
}
type myTheme struct {
fyne.Theme
}
func newMyTheme() *myTheme {
return &myTheme{Theme: theme.LightTheme()}
}
func (m myTheme) Color(name fyne.ThemeColorName, variant fyne.ThemeVariant) color.Color {
if name == theme.ColorNameBackground {
return color.White
}
if name == theme.ColorNameForeground {
return color.Black
}
if name == theme.ColorNameShadow {
return color.NRGBA{R: 0, G: 0, B: 0, A: 40}
}
return m.Theme.Color(name, variant)
}
func getInstallDir() string {
switch downloadUtils.GetGoos() {
case "windows":
return filepath.Join(os.Getenv("APPDATA"), "owlcms")
case "darwin":
return filepath.Join(os.Getenv("HOME"), "Library", "Application Support", "owlcms")
case "linux":
return filepath.Join(os.Getenv("HOME"), ".local", "share", "owlcms")
default:
return "./owlcms"
}
}
func checkJava(statusLabel *widget.Label) error {
statusLabel.SetText("Checking for the Java language runtime.")
statusLabel.Refresh()
statusLabel.Show()
stopButton.Hide()
stopContainer.Show()
versionContainer.Hide()
downloadContainer.Hide()
err := javacheck.CheckJava(statusLabel)
if err != nil {
dialog.ShowError(fmt.Errorf("could not install a Java runtime: %w", err), fyne.CurrentApp().Driver().AllWindows()[0])
statusLabel.SetText("Could not install a Java runtime.")
statusLabel.Refresh()
return err
}
statusLabel.Hide() // Hide the status label if Java check is successful
return nil
}
func goBackToMainScreen() {
// Implement the logic to go back to the main screen
// This might involve setting the visibility of certain UI elements
// or navigating to a different screen in your application.
stopButton.Hide()
stopContainer.Hide()
downloadContainer.Show()
versionContainer.Show()
}
func computeVersionScrollHeight(numVersions int) float32 {
minHeight := 0 // minimum height
rowHeight := 50 // approximate height per row
return float32(minHeight + (rowHeight * min(numVersions, 4)))
}
func removeAllVersions() {
entries, err := os.ReadDir(owlcmsInstallDir)
if err != nil {
log.Printf("Failed to read owlcms directory: %v\n", err)
dialog.ShowError(fmt.Errorf("failed to read owlcms directory: %w", err), fyne.CurrentApp().Driver().AllWindows()[0])
return
}
for _, entry := range entries {
if entry.IsDir() {
_, err := semver.NewVersion(entry.Name())
if err == nil {
dirPath := filepath.Join(owlcmsInstallDir, entry.Name())
if err := os.RemoveAll(dirPath); err != nil {
log.Printf("failed to remove directory %s: %v\n", dirPath, err)
dialog.ShowError(fmt.Errorf("failed to remove directory %s: %w", dirPath, err), fyne.CurrentApp().Driver().AllWindows()[0])
return
}
}
}
}
log.Println("All versions removed successfully")
dialog.ShowInformation("Success", "All versions removed successfully", fyne.CurrentApp().Driver().AllWindows()[0])
getAllInstalledVersions()
updateTitle.ParseMarkdown("All Versions Removed.")
downloadButtonTitle.SetText("Click here to install a version.")
downloadButtonTitle.Refresh()
updateTitle.Refresh()
recomputeVersionList(fyne.CurrentApp().Driver().AllWindows()[0])
singleOrMultiVersionLabel.Hide() // Hide the singleOrMultiVersionLabel
}
func uninstallAll() {
dialog.ShowConfirm("Confirm Uninstall", "This will remove all the data and configurations currently stored and exit the program.\nIf you proceed, this cannot be undone. Restarting the program will create new data.", func(confirm bool) {
if confirm {
err := os.RemoveAll(owlcmsInstallDir)
if err != nil {
log.Printf("Failed to remove all data: %v\n", err)
dialog.ShowError(fmt.Errorf("failed to remove all data: %w", err), fyne.CurrentApp().Driver().AllWindows()[0])
} else {
log.Println("All data removed successfully")
dialog.ShowInformation("Success", "All data removed successfully", fyne.CurrentApp().Driver().AllWindows()[0])
fyne.CurrentApp().Quit()
}
}
}, fyne.CurrentApp().Driver().AllWindows()[0])
}
func removeJava() {
javaDir := filepath.Join(owlcmsInstallDir, "java17")
err := os.RemoveAll(javaDir)
if err != nil {
log.Printf("Failed to remove Java: %v\n", err)
dialog.ShowError(fmt.Errorf("failed to remove Java: %w", err), fyne.CurrentApp().Driver().AllWindows()[0])
} else {
log.Println("Java removed successfully")
dialog.ShowInformation("Success", "Java removed successfully", fyne.CurrentApp().Driver().AllWindows()[0])
}
}
func main() {
log.SetFlags(log.LstdFlags | log.Lshortfile)
log.Println("Starting OWLCMS Launcher")
a := app.NewWithID("app.owlcms.owlcms-launcher")
a.Settings().SetTheme(newMyTheme())
w := a.NewWindow("OWLCMS Control Panel")
w.Resize(fyne.NewSize(800, 400)) // Set window size immediately
// Create stop button and status label
stopButton = widget.NewButton("Stop", nil)
stopButton.Importance = widget.HighImportance // Make the stop button important
statusLabel = widget.NewLabel("")
statusLabel.Wrapping = fyne.TextWrapWord // Allow status messages to wrap
// Create containers
downloadContainer = container.NewVBox()
versionContainer = container.NewVBox()
// Create URL hyperlink
urlLink = widget.NewHyperlink("", nil)
urlLink.Hide()
stopContainer = container.NewVBox(stopButton, statusLabel, urlLink)
// Initialize download titles
updateTitle = widget.NewRichTextFromMarkdown("") // Initialize as RichText for Markdown
downloadButtonTitle = widget.NewHyperlink("Click here to install additional versions.", nil) // New title for download button
downloadButtonTitle.OnTapped = func() {
if !downloadsShown {
ShowDownloadables()
} else {
HideDownloadables()
}
}
singleOrMultiVersionLabel = widget.NewLabel("")
// Configure stop button behavior
stopButton.OnTapped = func() {
log.Println("Stop button tapped")
stopProcess(currentProcess, currentVersion, stopButton, downloadContainer, versionContainer, statusLabel, w)
}
stopButton.Hide()
stopContainer.Hide()
mainContent := container.NewVBox(
// widget.NewLabelWithStyle("OWLCMS Launcher", fyne.TextAlignCenter, fyne.TextStyle{Bold: true}),
stopContainer,
versionContainer,
downloadContainer, // Use downloadGroup here
)
w.SetContent(mainContent) // Set content before hiding
w.Canvas().Refresh(mainContent)
go func() {
// Hide all containers at startup
hideAllContainers := func() {
stopContainer.Hide()
versionContainer.Hide()
downloadContainer.Hide()
mainContent.Refresh()
}
hideAllContainers()
// Check Java first, show feedback immediately
javaLoc, err := javacheck.FindLocalJava()
internetAvailable := CheckForInternet()
if err != nil || javaLoc == "" {
if !internetAvailable {
content := container.New(layout.NewCenterLayout(),
widget.NewLabel("Java is not installed and there is no internet connection.\nPlease connect and restart the program."))
dialog := dialog.NewCustom("No Internet Connection", "Exit", content, w)
dialog.SetOnClosed(func() {
a.Quit()
})
dialog.Show()
return
}
// Show Java download status immediately
statusLabel.SetText("Java runtime not found. Starting download...")
statusLabel.Show()
statusLabel.Refresh()
if err := checkJava(statusLabel); err != nil {
log.Printf("Failed to fetch Java: %v\n", err)
// dialog.ShowError(fmt.Errorf("failed to fetch Java: %w", err), w)
return
}
}
// Get releases if internet is available
if internetAvailable {
releases, err := fetchReleases()
if err == nil {
allReleases = releases
}
} else {
allReleases = []string{}
}
numVersions := len(getAllInstalledVersions())
if numVersions == 0 && !internetAvailable {
w.SetContent(mainContent)
d := dialog.NewInformation("No Internet Connection", "You must be connected to the internet to fetch a version of the program.\nPlease connect and restart the program", w)
d.Resize(fyne.NewSize(400, 200))
d.SetDismissText("Exit")
d.Show()
d.SetOnClosed(func() {
a.Driver().Quit()
})
return
}
// Initialize version list
recomputeVersionList(w)
// Create release dropdown for downloads
releaseSelect, releaseDropdown := createReleaseDropdown(w)
updateTitle.Hide()
releaseDropdown.Hide() // Hide the dropdown initially
// Create checkbox for showing prereleases
prereleaseCheckbox = widget.NewCheck("Show Prereleases", func(checked bool) {
showPrereleases = checked
populateReleaseSelect(releaseSelect) // Repopulate the dropdown when the checkbox is changed
})
prereleaseCheckbox.Hide() // Hide the checkbox initially
if len(allReleases) > 0 {
downloadContainer.Objects = []fyne.CanvasObject{
updateTitle,
singleOrMultiVersionLabel,
downloadButtonTitle,
releaseDropdown,
prereleaseCheckbox,
}
} else {
downloadContainer.Objects = []fyne.CanvasObject{
widget.NewLabel("You are not connected to the Internet. Available updates cannot be shown."),
}
}
// Create menu items
fileMenu := fyne.NewMenu("File",
fyne.NewMenuItem("Remove All Versions", func() {
removeAllVersions()
}),
fyne.NewMenuItem("Remove Java", func() {
removeJava()
}),
fyne.NewMenuItem("Remove All Stored Data and Configurations", func() {
uninstallAll()
}),
fyne.NewMenuItem("Open Installation Directory", func() {
if err := openFileExplorer(owlcmsInstallDir); err != nil {
dialog.ShowError(fmt.Errorf("failed to open installation directory: %w", err), w)
}
}),
)
killMenu := fyne.NewMenu("Processes",
fyne.NewMenuItem("Kill Already Running Process", func() {
if err := killLockingProcess(); err != nil {
dialog.ShowError(fmt.Errorf("failed to kill already running process: %w", err), w)
} else {
dialog.ShowInformation("Success", "Successfully killed the already running process", w)
}
}),
)
helpMenu := fyne.NewMenu("Help",
fyne.NewMenuItem("Documentation", func() {
linkURL, _ := url.Parse("https://owlcms.github.io/owlcms4-prerelease/#/LocalControlPanel")
link := widget.NewHyperlink("Control Panel Documentation", linkURL)
dialog.ShowCustom("Documentation", "Close", link, w)
}),
fyne.NewMenuItem("Check for Updates", func() {
checkForUpdates(w)
}),
fyne.NewMenuItem("About", func() {
dialog.ShowInformation("About", "OWLCMS Launcher version "+launcherVersion, w)
}),
)
menu := fyne.NewMainMenu(fileMenu, killMenu, helpMenu)
w.SetMainMenu(menu)
mainContent.Resize(fyne.NewSize(800, 400))
w.SetContent(mainContent)
w.Resize(fyne.NewSize(800, 400))
w.Canvas().Refresh(mainContent)
populateReleaseSelect(releaseSelect) // Populate the dropdown with the releases
updateTitle.Show()
releaseDropdown.Hide()
prereleaseCheckbox.Hide() // Show the checkbox once releases are fetched
log.Printf("Fetched %d releases\n", len(allReleases)) // Use allReleases instead of releases
// If no version is installed, get the latest stable version
if len(getAllInstalledVersions()) == 0 {
for _, release := range allReleases {
if !containsPreReleaseTag(release) {
// Automatically download and install the latest stable version
downloadAndInstallVersion(release, w)
break
}
}
}
// Check if a more recent version is available
checkForNewerVersion()
downloadContainer.Refresh()
downloadContainer.Show()
mainContent.Refresh()
w.SetContent(mainContent)
w.Canvas().Refresh(mainContent)
w.SetCloseIntercept(func() {
if currentProcess != nil {
confirmDialog := dialog.NewConfirm(
"Confirm Exit",
"The server is running. This will stop the owlcms server for all the users. Are you sure you want to exit?",
func(confirm bool) {
if !confirm {
log.Println("Closing OWLCMS Launcher")
stopProcess(currentProcess, currentVersion, stopButton, downloadContainer, versionContainer, statusLabel, w)
w.Close()
}
},
w,
)
confirmDialog.SetConfirmText("Don't Stop owlcms")
confirmDialog.SetDismissText("Stop owlcms and Exit")
confirmDialog.Show()
} else {
w.Close()
}
})
log.Println("setup done.")
statusLabel.Hide()
}()
// Set up channel to listen for interrupt signals BEFORE ShowAndRun
sigChan := make(chan os.Signal, 1)
signal.Notify(sigChan, os.Interrupt)
var wg sync.WaitGroup
// Goroutine to handle interrupt signal
go func() {
<-sigChan
log.Println("Interrupt signal caught, stopping Java process...")
wg.Add(1)
go func() {
defer wg.Done()
stopProcess(currentProcess, currentVersion, stopButton, downloadContainer, versionContainer, statusLabel, w)
}()
wg.Wait()
log.Println("Exiting Control Panel...")
os.Exit(0)
}()
log.Println("Showing OWLCMS Launcher")
w.ShowAndRun()
}
func HideDownloadables() {
downloadsShown = false
releaseDropdown.Hide()
prereleaseCheckbox.Hide()
downloadContainer.Refresh()
}
func ShowDownloadables() {
downloadsShown = true
releaseDropdown.Show()
prereleaseCheckbox.Show()
downloadContainer.Refresh()
}
func downloadAndInstallVersion(version string, w fyne.Window) {
var urlPrefix string
if containsPreReleaseTag(version) {
urlPrefix = "https://github.com/owlcms/owlcms4-prerelease/releases/download"
} else {
urlPrefix = "https://github.com/owlcms/owlcms4/releases/download"
}
fileName := fmt.Sprintf("owlcms_%s.zip", version)
zipURL := fmt.Sprintf("%s/%s/%s", urlPrefix, version, fileName)
// Ensure the owlcms directory exists
owlcmsDir := owlcmsInstallDir
if _, err := os.Stat(owlcmsDir); os.IsNotExist(err) {
if err := os.MkdirAll(owlcmsDir, 0755); err != nil {
dialog.ShowError(fmt.Errorf("creating owlcms directory: %w", err), w)
return
}
}
zipPath := filepath.Join(owlcmsDir, fileName)
extractPath := filepath.Join(owlcmsDir, version)
// Create a cancel channel
cancel := make(chan bool)
progressDialog, progressBar := customdialog.NewDownloadDialog(
fmt.Sprintf("Downloading OWLCMS %s", version),
w,
cancel)
progressDialog.Show()
go func() {
// Download the ZIP file using downloadUtils
log.Printf("Starting download from URL: %s\n", zipURL)
progressCallback := func(downloaded, total int64) {
if total > 0 {
percentage := float64(downloaded) / float64(total)
progressBar.SetValue(percentage)
}
}
err := downloadUtils.DownloadArchive(zipURL, zipPath, progressCallback, cancel)
if err != nil {
if err.Error() == "download cancelled" {
// Handle cancellation
log.Println("Download cancelled by user")
// Clean up the incomplete zip file
os.Remove(zipPath)
return
}
progressDialog.Hide()
dialog.ShowError(fmt.Errorf("download failed: %w", err), w)
return
}
// Extract the ZIP file to version-specific subdirectory
log.Printf("Extracting ZIP file to: %s\n", extractPath)
err = downloadUtils.ExtractZip(zipPath, extractPath)
if err != nil {
progressDialog.Hide()
dialog.ShowError(fmt.Errorf("extraction failed: %w", err), w)
return
}
// Log when extraction is done
log.Println("Extraction completed")
// Log before closing the dialog
log.Println("Closing progress dialog")
// Hide progress dialog
progressDialog.Hide()
// Show success panel with installation details
message := fmt.Sprintf(
"Successfully installed OWLCMS version %s\n\n"+
"Location: %s\n\n"+
"The program files have been extracted to the above directory.",
version, extractPath)
dialog.ShowInformation("Installation Complete", message, w)
HideDownloadables()
// Recompute the version list
recomputeVersionList(w)
// Recompute the downloadTitle
checkForNewerVersion()
}()
}
func min(a, b int) int {
if a < b {
return a
}
return b
}
func checkForNewerVersion() {
latestInstalled := findLatestInstalled()
// Set the single or multi version label
updateExplanation()
if latestInstalled != "" {
latestStable, _ := semver.NewVersion("0.0.0")
latestInstalledVersion, err := semver.NewVersion(latestInstalled)
if err == nil {
log.Printf("Latest installed version: %s\n", latestInstalledVersion)
for _, release := range allReleases {
releaseVersion, err := semver.NewVersion(release)
if err == nil {
if releaseVersion.GreaterThan(latestInstalledVersion) {
log.Printf("Found newer version: %s\n", releaseVersion)
var releaseURL string
if containsPreReleaseTag(release) {
releaseURL = fmt.Sprintf("https://github.com/owlcms/owlcms4-prerelease/releases/tag/%s", release)
if containsPreReleaseTag(latestInstalled) {
updateTitle.ParseMarkdown(fmt.Sprintf("**A more recent prerelease version %s is available.** [Release Notes](%s)", releaseVersion, releaseURL))
updateTitle.Refresh()
updateTitle.Show()
return
}
} else {
releaseURL = fmt.Sprintf("https://github.com/owlcms/owlcms4/releases/tag/%s", release)
updateTitle.ParseMarkdown(fmt.Sprintf("**A more recent stable version %s is available.** [Release Notes](%s)", releaseVersion, releaseURL))
updateTitle.Refresh()
updateTitle.Show()
return
}
}
if (releaseVersion.GreaterThan(latestStable)) && !containsPreReleaseTag(release) {
latestStable = releaseVersion
}
}
}
updateTitle.Show()
downloadButtonTitle.Show()
var releaseURL string
if containsPreReleaseTag(latestInstalled) {
stableURL := fmt.Sprintf("https://github.com/owlcms/owlcms4/releases/tag/%s", latestStable)
prereleaseURL := fmt.Sprintf("https://github.com/owlcms/owlcms4-prerelease/releases/tag/%s", latestInstalled)
updateTitle.ParseMarkdown(fmt.Sprintf(
`**The latest installed version is pre-release %s** [Release Notes](%s)
The latest stable version is %s. [Release Notes](%s)`,
latestInstalled, prereleaseURL, latestStable, stableURL))
} else {
releaseURL = fmt.Sprintf("https://github.com/owlcms/owlcms4/releases/tag/%s", latestInstalled)
updateTitle.ParseMarkdown(fmt.Sprintf("**The latest stable version is installed.** [Release Notes](%s)", releaseURL))
}
updateTitle.Refresh()
downloadButtonTitle.Refresh()
if releaseDropdown != nil {
releaseDropdown.Hide()
}
if prereleaseCheckbox != nil {
prereleaseCheckbox.Hide()
}
updateTitle.Show()
downloadButtonTitle.Show()
if downloadContainer != nil {
downloadContainer.Refresh()
}
}
} else {
updateTitle.ParseMarkdown("**No version installed. Select a version to download below.**")
updateTitle.Refresh()
updateTitle.Show()
if downloadContainer != nil {
downloadContainer.Refresh()
}
}
}
func updateExplanation() {
if len(allReleases) == 0 {
downloadContainer.Objects = []fyne.CanvasObject{
widget.NewLabel("You are not connected to the Internet. Available updates cannot be shown."),
}
downloadContainer.Show()
downloadContainer.Refresh()
return
}
log.Printf("len(allReleases) = %d\n", len(allReleases))
x := getAllInstalledVersions()
log.Printf("Updating explanation %d\n", len(x))
if len(x) == 0 {
downloadContainer.Remove(singleOrMultiVersionLabel)
downloadContainer.Refresh()
} else if len(x) == 1 {
latestStable, stableErr := getMostRecentStableRelease()
latestPrerelease, preErr := getMostRecentPrerelease()
// Remove the label from the container first
downloadContainer.Remove(singleOrMultiVersionLabel)
if containsPreReleaseTag(x[0]) {
if preErr == nil && x[0] == latestPrerelease {
// It's the latest prerelease; do not re-insert the label
} else {
// Not the latest; re-insert singleOrMultiVersionLabel as second item
downloadContainer.Objects = append(downloadContainer.Objects[:1], append([]fyne.CanvasObject{singleOrMultiVersionLabel}, downloadContainer.Objects[1:]...)...)
singleOrMultiVersionLabel.SetText("Use the Update button above to install the latest version. The current database will be copied to the new version, as well as local changes made to the configuration since the previous installation.")
}
} else {
if stableErr == nil && x[0] == latestStable {
// It's the latest stable; do not re-insert the label
} else {
downloadContainer.Objects = append(downloadContainer.Objects[:1], append([]fyne.CanvasObject{singleOrMultiVersionLabel}, downloadContainer.Objects[1:]...)...)
singleOrMultiVersionLabel.SetText("Use the Update button above to install the latest version. The current database will be copied to the new version, as well as local changes made to the configuration since the previous installation.")
}
}
} else {
singleOrMultiVersionLabel.SetText("You have several versions installed. Use the Import button if you wish to copy the database and local configuration changes from a previous version.")
}
singleOrMultiVersionLabel.Wrapping = fyne.TextWrapWord
singleOrMultiVersionLabel.Show()
singleOrMultiVersionLabel.Refresh()
}