mirror of
https://github.com/netbirdio/systray.git
synced 2026-05-22 17:08:41 -07:00
Updated darwin implementation to meet new API
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
extern void systray_ready();
|
||||
extern void systray_on_exit();
|
||||
extern void systray_menu_item_selected(int menu_id);
|
||||
int nativeLoop(void);
|
||||
int nativeLoop(char* title, int width, int height);
|
||||
|
||||
void setIcon(const char* iconBytes, int length);
|
||||
void setMenuItemIcon(const char* iconBytes, int length, int menuId);
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
NSWindowController *windowController = nil;
|
||||
WKWebView *webView = nil;
|
||||
|
||||
void doConfigureAppWindow(char* title, int width, int height)
|
||||
void configureAppWindow(char* title, int width, int height)
|
||||
{
|
||||
if (windowController != nil) {
|
||||
// already configured, ignore
|
||||
@@ -49,13 +49,6 @@ void doConfigureAppWindow(char* title, int width, int height)
|
||||
free(title);
|
||||
}
|
||||
|
||||
void configureAppWindow(char* title, int width, int height)
|
||||
{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
doConfigureAppWindow(title, width, height);
|
||||
});
|
||||
}
|
||||
|
||||
void doShowAppWindow(char* url)
|
||||
{
|
||||
if (windowController == nil) {
|
||||
|
||||
+6
-1
@@ -187,9 +187,14 @@
|
||||
|
||||
@end
|
||||
|
||||
int nativeLoop(void) {
|
||||
void configureAppWindow(char* title, int width, int height);
|
||||
|
||||
int nativeLoop(char* title, int width, int height) {
|
||||
AppDelegate *delegate = [[AppDelegate alloc] init];
|
||||
[[NSApplication sharedApplication] setDelegate:delegate];
|
||||
if (strcmp(title, "") != 0) {
|
||||
configureAppWindow(title, width, height);
|
||||
}
|
||||
[NSApp run];
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -16,19 +16,14 @@ import (
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
func nativeLoop() {
|
||||
C.nativeLoop()
|
||||
func nativeLoop(title string, width int, height int) {
|
||||
C.nativeLoop(C.CString(title), C.int(width), C.int(height))
|
||||
}
|
||||
|
||||
func quit() {
|
||||
C.quit()
|
||||
}
|
||||
|
||||
// EnableAppWindow enables a single application window for this app.
|
||||
func EnableAppWindow(title string, width int, height int) {
|
||||
C.configureAppWindow(C.CString(title), C.int(width), C.int(height))
|
||||
}
|
||||
|
||||
// ShowAppWindow shows the given URL in the application window. Only works if
|
||||
// configureAppWindow has been called first.
|
||||
func ShowAppWindow(url string) {
|
||||
|
||||
Reference in New Issue
Block a user