diff --git a/v2/internal/ffenestri/ffenestri_darwin.c b/v2/internal/ffenestri/ffenestri_darwin.c index 38740edf2..167b8605e 100644 --- a/v2/internal/ffenestri/ffenestri_darwin.c +++ b/v2/internal/ffenestri/ffenestri_darwin.c @@ -684,10 +684,6 @@ void closeWindow(id self, SEL cmd, id sender) { app->sendMessageToBackend("WC"); } -void willFinishLaunching(id self, SEL cmd, id sender) { - struct Application *app = (struct Application *) objc_getAssociatedObject(self, "application"); -} - bool isDarkMode(struct Application *app) { id userDefaults = msg(c("NSUserDefaults"), s("standardUserDefaults")); const char *mode = cstr(msg(userDefaults, s("stringForKey:"), str("AppleInterfaceStyle"))); @@ -703,19 +699,25 @@ void ExecJS(struct Application *app, const char *js) { ); } +void willFinishLaunching(id self, SEL cmd, id sender) { + struct Application *app = (struct Application *) objc_getAssociatedObject(self, "application"); + messageFromWindowCallback("Ej{\"name\":\"wails:launched\",\"data\":[]}"); +} + void emitThemeChange(struct Application *app) { bool currentThemeIsDark = isDarkMode(app); if (currentThemeIsDark) { - messageFromWindowCallback("ETT"); + messageFromWindowCallback("Ej{\"name\":\"wails:system:themechange\",\"data\":[true]}"); } else { - messageFromWindowCallback("ETF"); + messageFromWindowCallback("Ej{\"name\":\"wails:system:themechange\",\"data\":[false]}"); } } void themeChanged(id self, SEL cmd, id sender) { struct Application *app = (struct Application *)objc_getAssociatedObject( self, "application"); - bool currentThemeIsDark = isDarkMode(app); +// emitThemeChange(app); + bool currentThemeIsDark = isDarkMode(app); if ( currentThemeIsDark ) { ExecJS(app, "window.wails.Events.Emit( 'wails:system:themechange', true );"); } else { @@ -2571,7 +2573,7 @@ void Run(struct Application *app, int argc, char **argv) { // Emit theme change event to notify of current system them -// emitThemeChange(app); + emitThemeChange(app); // If we want the webview to be transparent... if( app->webviewIsTranparent == 1 ) { diff --git a/v2/pkg/commands/build/desktop_darwin.go b/v2/pkg/commands/build/desktop_darwin.go index 42940bf9f..f65badec1 100644 --- a/v2/pkg/commands/build/desktop_darwin.go +++ b/v2/pkg/commands/build/desktop_darwin.go @@ -5,6 +5,7 @@ package build import ( "fmt" "github.com/leaanthony/slicer" + "github.com/wailsapp/wails/v2/internal/fs" "io/ioutil" "log" "path/filepath" @@ -27,13 +28,14 @@ func (d *DesktopBuilder) processTrayIcons(assetDir string, options *Options) err // Get all the tray icon filenames trayIconDirectory := filepath.Join(options.ProjectData.Path, "trayicons") - trayIconFilenames, err := filepath.Glob(trayIconDirectory + "/*.png") - - if err != nil { - log.Fatal(err) - return err + var trayIconFilenames []string + if fs.DirExists(trayIconDirectory) { + trayIconFilenames, err = filepath.Glob(trayIconDirectory + "/*.png") + if err != nil { + log.Fatal(err) + return err + } } - // Setup target targetFilename := "trayicons" targetFile := filepath.Join(assetDir, targetFilename+".c") @@ -88,7 +90,10 @@ func (d *DesktopBuilder) processTrayIcons(assetDir string, options *Options) err // Write out main trayIcons data cdata.WriteString("const unsigned char *trayIcons[] = { ") cdata.WriteString(variableList.Join(", ")) - cdata.WriteString(", 0x00 };\n") + if len(trayIconFilenames) > 0 { + cdata.WriteString(", ") + } + cdata.WriteString("0x00 };\n") err = ioutil.WriteFile(targetFile, []byte(cdata.String()), 0600) if err != nil {