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");
|
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) {
|
bool isDarkMode(struct Application *app) {
|
||||||
id userDefaults = msg(c("NSUserDefaults"), s("standardUserDefaults"));
|
id userDefaults = msg(c("NSUserDefaults"), s("standardUserDefaults"));
|
||||||
const char *mode = cstr(msg(userDefaults, s("stringForKey:"), str("AppleInterfaceStyle")));
|
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) {
|
void emitThemeChange(struct Application *app) {
|
||||||
bool currentThemeIsDark = isDarkMode(app);
|
bool currentThemeIsDark = isDarkMode(app);
|
||||||
if (currentThemeIsDark) {
|
if (currentThemeIsDark) {
|
||||||
messageFromWindowCallback("ETT");
|
messageFromWindowCallback("Ej{\"name\":\"wails:system:themechange\",\"data\":[true]}");
|
||||||
} else {
|
} else {
|
||||||
messageFromWindowCallback("ETF");
|
messageFromWindowCallback("Ej{\"name\":\"wails:system:themechange\",\"data\":[false]}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void themeChanged(id self, SEL cmd, id sender) {
|
void themeChanged(id self, SEL cmd, id sender) {
|
||||||
struct Application *app = (struct Application *)objc_getAssociatedObject(
|
struct Application *app = (struct Application *)objc_getAssociatedObject(
|
||||||
self, "application");
|
self, "application");
|
||||||
bool currentThemeIsDark = isDarkMode(app);
|
// emitThemeChange(app);
|
||||||
|
bool currentThemeIsDark = isDarkMode(app);
|
||||||
if ( currentThemeIsDark ) {
|
if ( currentThemeIsDark ) {
|
||||||
ExecJS(app, "window.wails.Events.Emit( 'wails:system:themechange', true );");
|
ExecJS(app, "window.wails.Events.Emit( 'wails:system:themechange', true );");
|
||||||
} else {
|
} else {
|
||||||
@ -2571,7 +2573,7 @@ void Run(struct Application *app, int argc, char **argv) {
|
|||||||
|
|
||||||
|
|
||||||
// Emit theme change event to notify of current system them
|
// Emit theme change event to notify of current system them
|
||||||
// emitThemeChange(app);
|
emitThemeChange(app);
|
||||||
|
|
||||||
// If we want the webview to be transparent...
|
// If we want the webview to be transparent...
|
||||||
if( app->webviewIsTranparent == 1 ) {
|
if( app->webviewIsTranparent == 1 ) {
|
||||||
|
@ -5,6 +5,7 @@ package build
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/leaanthony/slicer"
|
"github.com/leaanthony/slicer"
|
||||||
|
"github.com/wailsapp/wails/v2/internal/fs"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
@ -27,13 +28,14 @@ func (d *DesktopBuilder) processTrayIcons(assetDir string, options *Options) err
|
|||||||
|
|
||||||
// Get all the tray icon filenames
|
// Get all the tray icon filenames
|
||||||
trayIconDirectory := filepath.Join(options.ProjectData.Path, "trayicons")
|
trayIconDirectory := filepath.Join(options.ProjectData.Path, "trayicons")
|
||||||
trayIconFilenames, err := filepath.Glob(trayIconDirectory + "/*.png")
|
var trayIconFilenames []string
|
||||||
|
if fs.DirExists(trayIconDirectory) {
|
||||||
if err != nil {
|
trayIconFilenames, err = filepath.Glob(trayIconDirectory + "/*.png")
|
||||||
log.Fatal(err)
|
if err != nil {
|
||||||
return err
|
log.Fatal(err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Setup target
|
// Setup target
|
||||||
targetFilename := "trayicons"
|
targetFilename := "trayicons"
|
||||||
targetFile := filepath.Join(assetDir, targetFilename+".c")
|
targetFile := filepath.Join(assetDir, targetFilename+".c")
|
||||||
@ -88,7 +90,10 @@ func (d *DesktopBuilder) processTrayIcons(assetDir string, options *Options) err
|
|||||||
// Write out main trayIcons data
|
// Write out main trayIcons data
|
||||||
cdata.WriteString("const unsigned char *trayIcons[] = { ")
|
cdata.WriteString("const unsigned char *trayIcons[] = { ")
|
||||||
cdata.WriteString(variableList.Join(", "))
|
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)
|
err = ioutil.WriteFile(targetFile, []byte(cdata.String()), 0600)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user