Skip to content

Commit

Permalink
Merge branch 'develop' into hyperlink-sizename
Browse files Browse the repository at this point in the history
  • Loading branch information
dweymouth committed May 23, 2024
2 parents bc6ea78 + 9810934 commit 1b3f3aa
Show file tree
Hide file tree
Showing 101 changed files with 1,646 additions and 393 deletions.
22 changes: 15 additions & 7 deletions app/app_xdg.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ import (
"fyne.io/fyne/v2/theme"
)

var currentVariant atomic.Uint64

func defaultVariant() fyne.ThemeVariant {
return findFreedestktopColorScheme()
return fyne.ThemeVariant(currentVariant.Load())
}

func (a *fyneApp) OpenURL(url *url.URL) error {
Expand All @@ -39,7 +41,7 @@ func (a *fyneApp) OpenURL(url *url.URL) error {
}

// fetch color variant from dbus portal desktop settings.
func findFreedestktopColorScheme() fyne.ThemeVariant {
func findFreedesktopColorScheme() fyne.ThemeVariant {
colourScheme, err := appearance.GetColorScheme()
if err != nil {
return theme.VariantDark
Expand Down Expand Up @@ -119,9 +121,15 @@ func rootConfigDir() string {
}

func watchTheme() {
go portalSettings.OnSignalSettingChanged(func(changed portalSettings.Changed) {
if changed.Namespace == "org.freedesktop.appearance" && changed.Key == "color-scheme" {
fyne.CurrentApp().Settings().(*settings).setupTheme()
}
})
go func() {
// with portal this may not be immediate, so we update a cache instead
currentVariant.Store(uint64(findFreedesktopColorScheme()))

portalSettings.OnSignalSettingChanged(func(changed portalSettings.Changed) {
if changed.Namespace == "org.freedesktop.appearance" && changed.Key == "color-scheme" {
currentVariant.Store(uint64(findFreedesktopColorScheme()))
fyne.CurrentApp().Settings().(*settings).setupTheme()
}
})
}()
}
3 changes: 1 addition & 2 deletions app/preferences_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ func TestPreferences_Save_OverwriteFast(t *testing.T) {
val["key"] = "value"
})

path := filepath.Join(os.TempDir(), "fynePrefs2.json")
defer os.Remove(path)
path := filepath.Join(t.TempDir(), "fynePrefs2.json")
p.saveToFile(path)

p.WriteValues(func(val map[string]any) {
Expand Down
1 change: 1 addition & 0 deletions canvas/image_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ func TestNewImageFromReader(t *testing.T) {
path := filepath.Join(filepath.Dir(pwd), "theme", "icons", "fyne.png")
read, err := os.Open(path)
assert.Nil(t, err)
defer read.Close()

img := canvas.NewImageFromReader(read, "fyne.png")
assert.NotNil(t, img)
Expand Down
7 changes: 7 additions & 0 deletions cmd/fyne/internal/commands/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ func NewGetter() *Getter {

// Get automates the download and install of a named GUI app package.
func (g *Getter) Get(pkg string) error {
wd, _ := os.Getwd()
defer func() {
if wd != "" {
os.Chdir(wd)
}
}()

name := filepath.Base(pkg)
path, err := os.MkdirTemp("", fmt.Sprintf("fyne-get-%s-*", name))
if err != nil {
Expand Down
4 changes: 4 additions & 0 deletions cmd/fyne_demo/tutorials/widget.go
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,10 @@ func startProgress() {
}

func stopProgress() {
if infProgress == nil {
return
}

if !infProgress.Running() {
return
}
Expand Down
3 changes: 3 additions & 0 deletions dialog/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -867,6 +867,7 @@ func getFavoriteIcons() map[string]fyne.Resource {
if runtime.GOOS == "darwin" {
return map[string]fyne.Resource{
"Documents": theme.DocumentIcon(),
"Desktop": theme.DesktopIcon(),
"Downloads": theme.DownloadIcon(),
"Music": theme.MediaMusicIcon(),
"Pictures": theme.MediaPhotoIcon(),
Expand All @@ -876,6 +877,7 @@ func getFavoriteIcons() map[string]fyne.Resource {

return map[string]fyne.Resource{
"Documents": theme.DocumentIcon(),
"Desktop": theme.DesktopIcon(),
"Downloads": theme.DownloadIcon(),
"Music": theme.MediaMusicIcon(),
"Pictures": theme.MediaPhotoIcon(),
Expand All @@ -885,6 +887,7 @@ func getFavoriteIcons() map[string]fyne.Resource {

func getFavoriteOrder() []string {
order := []string{
"Desktop",
"Documents",
"Downloads",
"Music",
Expand Down
1 change: 1 addition & 0 deletions dialog/file_xdg.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ func getFavoriteLocations() (map[string]fyne.ListableURI, error) {

favoriteNames := getFavoriteOrder()
arguments := map[string]string{
"Desktop": "DESKTOP",
"Documents": "DOCUMENTS",
"Downloads": "DOWNLOAD",
"Music": "MUSIC",
Expand Down
2 changes: 1 addition & 1 deletion internal/driver/mobile/app/android.go
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ func runInputQueue(vm, jniEnv, ctx uintptr) error {

var q *C.AInputQueue
for {
if C.ALooper_pollAll(-1, nil, nil, nil) == C.ALOOPER_POLL_WAKE {
if C.ALooper_pollOnce(-1, nil, nil, nil) == C.ALOOPER_POLL_WAKE {
select {
default:
case p := <-pending:
Expand Down
74 changes: 19 additions & 55 deletions internal/repository/file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,12 @@ func TestFileRepositoryRegistration(t *testing.T) {
}

func TestFileRepositoryExists(t *testing.T) {
dir, err := os.MkdirTemp("", "FyneInternalRepositoryFileTest")
if err != nil {
t.Fatal(err)
}
defer os.RemoveAll(dir)
dir := t.TempDir()

existsPath := path.Join(dir, "exists")
notExistsPath := path.Join(dir, "notExists")

err = os.WriteFile(existsPath, []byte{1, 2, 3, 4}, 0755)
err := os.WriteFile(existsPath, []byte{1, 2, 3, 4}, 0755)
if err != nil {
t.Fatal(err)
}
Expand All @@ -65,18 +61,13 @@ func TestFileRepositoryExists(t *testing.T) {
}

func TestFileRepositoryReader(t *testing.T) {
// Set up a temporary directory.
dir, err := os.MkdirTemp("", "FyneInternalRepositoryFileTest")
if err != nil {
t.Fatal(err)
}
defer os.RemoveAll(dir)
dir := t.TempDir()

// Create some files to test with.
fooPath := path.Join(dir, "foo")
barPath := path.Join(dir, "bar")
bazPath := path.Join(dir, "baz")
err = os.WriteFile(fooPath, []byte{}, 0755)
err := os.WriteFile(fooPath, []byte{}, 0755)
if err != nil {
t.Fatal(err)
}
Expand All @@ -100,17 +91,20 @@ func TestFileRepositoryReader(t *testing.T) {
fooData, err := io.ReadAll(fooReader)
assert.Equal(t, []byte{}, fooData)
assert.Nil(t, err)
fooReader.Close()

// Make sure we can read the file with data.
barReader, err := storage.Reader(bar)
assert.Nil(t, err)
barData, err := io.ReadAll(barReader)
assert.Equal(t, []byte{1, 2, 3}, barData)
assert.Nil(t, err)
barReader.Close()

// Make sure we get an error if the file doesn't exist.
_, err = storage.Reader(baz)
bazReader, err := storage.Reader(baz)
assert.NotNil(t, err)
bazReader.Close()

// Also test that CanRead returns the expected results.
fooCanRead, err := storage.CanRead(foo)
Expand All @@ -127,19 +121,14 @@ func TestFileRepositoryReader(t *testing.T) {
}

func TestFileRepositoryWriter(t *testing.T) {
// Set up a temporary directory.
dir, err := os.MkdirTemp("", "FyneInternalRepositoryFileTest")
if err != nil {
t.Fatal(err)
}
defer os.RemoveAll(dir)
dir := t.TempDir()

// Create some files to test with.
fooPath := path.Join(dir, "foo")
barPath := path.Join(dir, "bar")
bazPath := path.Join(dir, "baz")
spamHamPath := path.Join(dir, "spam", "ham")
err = os.WriteFile(fooPath, []byte{}, 0755)
err := os.WriteFile(fooPath, []byte{}, 0755)
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -247,18 +236,13 @@ func TestFileRepositoryWriter(t *testing.T) {
}

func TestFileRepositoryCanWrite(t *testing.T) {
// Set up a temporary directory.
dir, err := os.MkdirTemp("", "FyneInternalRepositoryFileTest")
if err != nil {
t.Fatal(err)
}
defer os.RemoveAll(dir)
dir := t.TempDir()

// Create some files to test with.
fooPath := path.Join(dir, "foo")
barPath := path.Join(dir, "bar")
bazPath := path.Join(dir, "baz")
err = os.WriteFile(fooPath, []byte{}, 0755)
err := os.WriteFile(fooPath, []byte{}, 0755)
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -365,17 +349,12 @@ func TestFileRepositoryChild(t *testing.T) {
}

func TestFileRepositoryCopy(t *testing.T) {
// Set up a temporary directory.
dir, err := os.MkdirTemp("", "FyneInternalRepositoryFileTest")
if err != nil {
t.Fatal(err)
}
defer os.RemoveAll(dir)
dir := t.TempDir()

// Create some files to test with.
fooPath := path.Join(dir, "foo")
barPath := path.Join(dir, "bar")
err = os.WriteFile(fooPath, []byte{1, 2, 3, 4, 5}, 0755)
err := os.WriteFile(fooPath, []byte{1, 2, 3, 4, 5}, 0755)
if err != nil {
t.Fatal(err)
}
Expand All @@ -396,17 +375,12 @@ func TestFileRepositoryCopy(t *testing.T) {
}

func TestFileRepositoryMove(t *testing.T) {
// Set up a temporary directory.
dir, err := os.MkdirTemp("", "FyneInternalRepositoryFileTest")
if err != nil {
t.Fatal(err)
}
defer os.RemoveAll(dir)
dir := t.TempDir()

// Create some files to test with.
fooPath := path.Join(dir, "foo")
barPath := path.Join(dir, "bar")
err = os.WriteFile(fooPath, []byte{1, 2, 3, 4, 5}, 0755)
err := os.WriteFile(fooPath, []byte{1, 2, 3, 4, 5}, 0755)
if err != nil {
t.Fatal(err)
}
Expand All @@ -429,12 +403,7 @@ func TestFileRepositoryMove(t *testing.T) {
}

func TestFileRepositoryListing(t *testing.T) {
// Set up a temporary directory.
dir, err := os.MkdirTemp("", "FyneInternalRepositoryFileTest")
if err != nil {
t.Fatal(err)
}
defer os.RemoveAll(dir)
dir := t.TempDir()

// Create some files to tests with.
fooPath := path.Join(dir, "foo")
Expand Down Expand Up @@ -466,12 +435,7 @@ func TestFileRepositoryListing(t *testing.T) {
}

func TestFileRepositoryCreateListable(t *testing.T) {
// Set up a temporary directory.
dir, err := os.MkdirTemp("", "FyneInternalRepositoryFileTest")
if err != nil {
t.Fatal(err)
}
defer os.RemoveAll(dir)
dir := t.TempDir()

f := NewFileRepository()
repository.Register("file", f)
Expand All @@ -482,7 +446,7 @@ func TestFileRepositoryCreateListable(t *testing.T) {
fooBar := storage.NewFileURI(fooBarPath)

// Creating a dir with no parent should fail
err = storage.CreateListable(fooBar)
err := storage.CreateListable(fooBar)
assert.NotNil(t, err)

// Creating foo should work though
Expand Down

0 comments on commit 1b3f3aa

Please sign in to comment.