-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor all app code into app package.
Create flexible new app.New() which can help detect the correct scenario, such as CI tests. Completed with a refactor of desktop to driver/efl, leaving behind the old desktop/NewApp() function
- Loading branch information
1 parent
2aa98f9
commit fdbb239
Showing
28 changed files
with
146 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package app | ||
|
||
import ( | ||
"github.com/fyne-io/fyne" | ||
) | ||
|
||
type fyneApp struct { | ||
driver fyne.Driver | ||
} | ||
|
||
func (app *fyneApp) NewWindow(title string) fyne.Window { | ||
return app.driver.CreateWindow(title) | ||
} | ||
|
||
func (app *fyneApp) Run() { | ||
app.driver.Run() | ||
} | ||
|
||
func (app *fyneApp) Quit() { | ||
app.driver.Quit() | ||
} | ||
|
||
func (app *fyneApp) applyTheme(fyne.Settings) { | ||
for _, window := range app.driver.AllWindows() { | ||
content := window.Content() | ||
|
||
switch themed := content.(type) { | ||
case fyne.ThemedObject: | ||
themed.ApplyTheme() | ||
window.Canvas().Refresh(content) | ||
} | ||
} | ||
} | ||
|
||
// NewAppWithDriver initialises a new Fyne application using the specified driver | ||
// and returns a handle to that App. | ||
// As this package has no default driver one must be provided. | ||
// Helpers are available - see desktop.NewApp() and test.NewApp(). | ||
func NewAppWithDriver(d fyne.Driver) fyne.App { | ||
newApp := &fyneApp{} | ||
newApp.driver = d | ||
fyne.SetDriver(d) | ||
|
||
listener := make(chan fyne.Settings) | ||
fyne.GetSettings().AddChangeListener(listener) | ||
go func() { | ||
for { | ||
settings := <-listener | ||
newApp.applyTheme(settings) | ||
} | ||
}() | ||
|
||
return newApp | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
|
||
// +build openbsd freebsd netbsd | ||
|
||
package fyne | ||
package app | ||
|
||
import "os/exec" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// +build ci | ||
|
||
package app | ||
|
||
import ( | ||
"github.com/fyne-io/fyne" | ||
"github.com/fyne-io/fyne/test" | ||
) | ||
|
||
// New returns a new app instance using the test (headless) driver. | ||
func New() fyne.App { | ||
return NewAppWithDriver(test.NewTestDriver()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
// +build !ci | ||
|
||
package fyne | ||
package app | ||
|
||
import "os/exec" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// +build !ci,!gl | ||
|
||
package app | ||
|
||
import "github.com/fyne-io/fyne" | ||
import "github.com/fyne-io/fyne/driver/efl" | ||
|
||
// New returns a new app instance using the EFL driver. | ||
func New() fyne.App { | ||
return NewAppWithDriver(efl.NewEFLDriver()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
// +build !ci | ||
|
||
package fyne | ||
package app | ||
|
||
import "os/exec" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
// +build ci !linux,!darwin,!windows,!freebsd,!openbsd,!netbsd | ||
|
||
package fyne | ||
package app | ||
|
||
import "log" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
// +build !ci | ||
|
||
package fyne | ||
package app | ||
|
||
import "os/exec" | ||
|
||
|
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,18 @@ | ||
// +build !ci | ||
|
||
// Package desktop provides a full implementation of the Fyne APIs for desktop | ||
// applications. This supports Windows, Mac OS X and Linux using the EFL (Evas) | ||
// render pipeline. | ||
// Package desktop is a legacy package which provided a an EFL based driver. | ||
// This supports Windows, Mac OS X and Linux using the EFL (Evas) render pipeline. | ||
// The replacement app package should be used by calling app.New() to create a new desktop application. | ||
package desktop | ||
|
||
import "log" | ||
|
||
import "github.com/fyne-io/fyne" | ||
import "github.com/fyne-io/fyne/app" | ||
import "github.com/fyne-io/fyne/driver/efl" | ||
|
||
// NewApp returns a new app instance using the desktop (EFL) driver. | ||
func NewApp() fyne.App { | ||
return fyne.NewAppWithDriver(NewEFLDriver()) | ||
log.Println("desktop.NewApp() is deprecated - please use app.New()") | ||
return app.NewAppWithDriver(efl.NewEFLDriver()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
// +build !ci | ||
|
||
package desktop | ||
package efl | ||
|
||
// #cgo pkg-config: eina evas ecore-evas | ||
// #include <Eina.h> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
// +build !ci | ||
|
||
package desktop | ||
package efl | ||
|
||
/* | ||
#cgo pkg-config: ecore-evas ecore-input | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
// +build !ci | ||
|
||
package desktop | ||
package efl | ||
|
||
func oSEngineName() string { | ||
return "opengl_cocoa" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
// +build !ci | ||
|
||
package desktop | ||
package efl | ||
|
||
func oSEngineName() string { | ||
return "software_gdi" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
// +build !ci | ||
|
||
package desktop | ||
package efl | ||
|
||
// #cgo pkg-config: ecore evas | ||
// #include <Ecore.h> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.