mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-03 22:50:59 +08:00
Handle no tray icons
This commit is contained in:
parent
25f464c177
commit
e18ba0eb81
@ -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 ) {
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user