| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- //go:build !ci && !ios && !js && !wasm && !test_web_driver
- // +build !ci,!ios,!js,!wasm,!test_web_driver
- package app
- /*
- #cgo CFLAGS: -x objective-c
- #cgo LDFLAGS: -framework Foundation
- #include <AppKit/AppKit.h>
- bool isBundled();
- bool isDarkMode();
- void watchTheme();
- */
- import "C"
- import (
- "net/url"
- "os"
- "path/filepath"
- "fyne.io/fyne/v2"
- "fyne.io/fyne/v2/theme"
- )
- // SetSystemTrayMenu creates a system tray item and attaches the specified menu.
- // By default this will use the application icon.
- func (a *fyneApp) SetSystemTrayMenu(menu *fyne.Menu) {
- if desk, ok := a.Driver().(systrayDriver); ok {
- desk.SetSystemTrayMenu(menu)
- }
- }
- // SetSystemTrayIcon sets a custom image for the system tray icon.
- // You should have previously called `SetSystemTrayMenu` to initialise the menu icon.
- func (a *fyneApp) SetSystemTrayIcon(icon fyne.Resource) {
- a.Driver().(systrayDriver).SetSystemTrayIcon(icon)
- }
- func defaultVariant() fyne.ThemeVariant {
- if C.isDarkMode() {
- return theme.VariantDark
- }
- return theme.VariantLight
- }
- func rootConfigDir() string {
- homeDir, _ := os.UserHomeDir()
- desktopConfig := filepath.Join(filepath.Join(homeDir, "Library"), "Preferences")
- return filepath.Join(desktopConfig, "fyne")
- }
- func (a *fyneApp) OpenURL(url *url.URL) error {
- cmd := a.exec("open", url.String())
- cmd.Stdin, cmd.Stdout, cmd.Stderr = os.Stdin, os.Stdout, os.Stderr
- return cmd.Run()
- }
- //export themeChanged
- func themeChanged() {
- fyne.CurrentApp().Settings().(*settings).setupTheme()
- }
- func watchTheme() {
- C.watchTheme()
- }
|