Skip to content

Commit

Permalink
Merge branch 'develop' into ctrl-backspace
Browse files Browse the repository at this point in the history
  • Loading branch information
dweymouth committed May 18, 2024
2 parents c313d1e + 6145be2 commit 2490ce9
Show file tree
Hide file tree
Showing 368 changed files with 4,294 additions and 1,991 deletions.
21 changes: 20 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
This file lists the main changes with each version of the Fyne toolkit.
More detailed release notes can be found on the [releases page](https://github.com/fyne-io/fyne/releases).

<<<<<<< HEAD
## 2.5.0 - Ongoing

### Added
Expand All @@ -16,6 +15,26 @@ More detailed release notes can be found on the [releases page](https://github.c
### Fixed


## 2.4.5 - 15 April 2024

### Fixed

* iOS files write would fail when over 16KB
* storage.Delete not supported on Android/iOS (#2120)
* layout.formLayout do not handle canvas.Text well in second column (#4665)
* Fix building with ios17.4 (#4741)
* Support template icon for system tray menu icons
* Fix recognition of missing XDG user directories (#4650)
* FileDialog.SetOnClosed not always working (#4651)
* Upgrade GLFW for performance improvements and bug fixes
* Multiple select popups can crash during background operations (#4730)
* Controlling a negative slider with the left arrow key blocks after 8 steps (#4736)
* cmd/fyne: command "get" is broken with Go 1.22 (#4684)
* Race condition during system tray menu refresh (#4697)
* Fyne release on Linux does not set Metadata().Release to true (#4711)
* RichText leaks memory when replacing segments (#4723)


## 2.4.4 - 13 February 2024

### Fixed
Expand Down
5 changes: 4 additions & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,10 @@ func New() fyne.App {
}

func makeStoreDocs(id string, s *store) *internal.Docs {
if root := s.a.storageRoot(); root != "" && id != "" {
if id == "" {
return &internal.Docs{} // an empty impl to avoid crashes
}
if root := s.a.storageRoot(); root != "" {
err := os.MkdirAll(root, 0755) // make the space before anyone can use it
if err != nil {
fyne.LogError("Failed to create app storage space", err)
Expand Down
59 changes: 56 additions & 3 deletions app/app_goxjs.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,67 @@
package app

import (
"encoding/base64"
"fmt"
"net/http"
"syscall/js"

"fyne.io/fyne/v2"
)

func (app *fyneApp) SendNotification(_ *fyne.Notification) {
// TODO #2735
fyne.LogError("Sending notification is not supported yet.", nil)
func (a *fyneApp) SendNotification(n *fyne.Notification) {
window := js.Global().Get("window")
if window.IsUndefined() {
fyne.LogError("Current browser does not support notifications.", nil)
return
}
notification := window.Get("Notification")
if window.IsUndefined() {
fyne.LogError("Current browser does not support notifications.", nil)
return
}
// check permission
permission := notification.Get("permission")
showNotification := func() {
icon := a.icon.Content()
base64Str := base64.StdEncoding.EncodeToString(icon)
mimeType := http.DetectContentType(icon)
base64Img := fmt.Sprintf("data:%s;base64,%s", mimeType, base64Str)
notification.New(n.Title, map[string]interface{}{
"body": n.Content,
"icon": base64Img,
})
fyne.LogError("done show...", nil)
}
if permission.Type() != js.TypeString || permission.String() != "granted" {
// need to request for permission
notification.Call("requestPermission", js.FuncOf(func(this js.Value, args []js.Value) interface{} {
if len(args) > 0 && args[0].Type() == js.TypeString && args[0].String() == "granted" {
showNotification()
} else {
fyne.LogError("User rejected the request for notifications.", nil)
}
return nil
}))
} else {
showNotification()
}
}

func rootConfigDir() string {
return "/data/"
}

var themeChanged = js.FuncOf(func(this js.Value, args []js.Value) interface{} {
if len(args) > 0 && args[0].Type() == js.TypeObject {
fyne.CurrentApp().Settings().(*settings).setupTheme()
}
return nil
})

func watchTheme() {
js.Global().Call("matchMedia", "(prefers-color-scheme: dark)").Call("addEventListener", "change", themeChanged)
}
func stopWatchingTheme() {
js.Global().Call("matchMedia", "(prefers-color-scheme: dark)").Call("removeEventListener", "change", themeChanged)
}
2 changes: 1 addition & 1 deletion app/app_openurl_wasm.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"syscall/js"
)

func (app *fyneApp) OpenURL(url *url.URL) error {
func (a *fyneApp) OpenURL(url *url.URL) error {
window := js.Global().Call("open", url.String(), "_blank", "")
if window.Equal(js.Null()) {
return fmt.Errorf("Unable to open a new window/tab for URL: %v.", url)
Expand Down
2 changes: 1 addition & 1 deletion app/app_openurl_web.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ import (
"net/url"
)

func (app *fyneApp) OpenURL(url *url.URL) error {
func (a *fyneApp) OpenURL(url *url.URL) error {
return errors.New("OpenURL is not supported with the test web driver.")
}
9 changes: 0 additions & 9 deletions app/app_theme_wasm.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,3 @@ func defaultVariant() fyne.ThemeVariant {
}
return theme.VariantDark
}

func init() {
if matchMedia := js.Global().Call("matchMedia", "(prefers-color-scheme: dark)"); matchMedia.Truthy() {
matchMedia.Call("addEventListener", "change", js.FuncOf(func(this js.Value, args []js.Value) any {
fyne.CurrentApp().Settings().(*settings).setupTheme()
return nil
}))
}
}
9 changes: 5 additions & 4 deletions app/app_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ import (

const notificationTemplate = `$title = "%s"
$content = "%s"
$iconPath = "file:///%s"
[Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime] > $null
$template = [Windows.UI.Notifications.ToastNotificationManager]::GetTemplateContent([Windows.UI.Notifications.ToastTemplateType]::ToastText02)
$template = [Windows.UI.Notifications.ToastNotificationManager]::GetTemplateContent([Windows.UI.Notifications.ToastTemplateType]::ToastImageAndText02)
$toastXml = [xml] $template.GetXml()
$toastXml.GetElementsByTagName("text")[0].AppendChild($toastXml.CreateTextNode($title)) > $null
$toastXml.GetElementsByTagName("text")[1].AppendChild($toastXml.CreateTextNode($content)) > $null
$toastXml.GetElementsByTagName("image")[0].SetAttribute("src", $iconPath) > $null
$xml = New-Object Windows.Data.Xml.Dom.XmlDocument
$xml.LoadXml($toastXml.OuterXml)
$toast = [Windows.UI.Notifications.ToastNotification]::new($xml)
Expand Down Expand Up @@ -71,12 +71,13 @@ var scriptNum = 0
func (a *fyneApp) SendNotification(n *fyne.Notification) {
title := escapeNotificationString(n.Title)
content := escapeNotificationString(n.Content)
iconFilePath := a.cachedIconPath()
appID := a.UniqueID()
if appID == "" || strings.Index(appID, "missing-id") == 0 {
appID = a.Metadata().Name
}

script := fmt.Sprintf(notificationTemplate, title, content, appID)
script := fmt.Sprintf(notificationTemplate, title, content, iconFilePath, appID)
go runScript("notify", script)
}

Expand Down
Loading

0 comments on commit 2490ce9

Please sign in to comment.