mirror of
https://github.com/wailsapp/wails.git
synced 2026-03-14 14:45:49 +01:00
Refactor darwin app
This commit is contained in:
parent
311dde474c
commit
d319d51fcd
3 changed files with 19 additions and 1 deletions
|
|
@ -77,6 +77,8 @@ void SetAbout(void *inctx, const char* title, const char* description, void* ima
|
|||
void* AppendMenuItem(void* inctx, void* nsmenu, const char* label, const char* shortcutKey, int modifiers, int disabled, int checked, int menuItemID);
|
||||
void AppendSeparator(void* inMenu);
|
||||
void UpdateMenuItem(void* nsmenuitem, int checked);
|
||||
void RunMainLoop(void);
|
||||
void ReleaseContext(void *inctx);
|
||||
|
||||
NSString* safeInit(const char* input);
|
||||
|
||||
|
|
|
|||
|
|
@ -462,6 +462,14 @@ void Run(void *inctx, const char* url, int activationPolicy) {
|
|||
[_url release];
|
||||
|
||||
[app setMainMenu:ctx.applicationMenu];
|
||||
}
|
||||
|
||||
void RunMainLoop(void) {
|
||||
NSApplication *app = [NSApplication sharedApplication];
|
||||
[app run];
|
||||
}
|
||||
|
||||
void ReleaseContext(void *inctx) {
|
||||
WailsContext *ctx = (__bridge WailsContext*) inctx;
|
||||
[ctx release];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -74,6 +74,14 @@ type Frontend struct {
|
|||
trayMenusBuffer []*menu.TrayMenu
|
||||
}
|
||||
|
||||
func (f *Frontend) RunMainLoop() {
|
||||
C.RunMainLoop()
|
||||
}
|
||||
|
||||
func (f *Frontend) WindowClose() {
|
||||
C.ReleaseContext(f.mainWindow.context)
|
||||
}
|
||||
|
||||
func NewFrontend(ctx context.Context, appoptions *options.App, myLogger *logger.Logger, appBindings *binding.Bindings, dispatcher frontend.Dispatcher) *Frontend {
|
||||
result := &Frontend{
|
||||
frontendOptions: appoptions,
|
||||
|
|
@ -99,7 +107,7 @@ func NewFrontend(ctx context.Context, appoptions *options.App, myLogger *logger.
|
|||
} else {
|
||||
appBindings.DB().UpdateObfuscatedCallMap()
|
||||
}
|
||||
assets, err := assetserver.NewAssetServer(ctx, appoptions, bindings)
|
||||
assets, err := assetserver.NewAssetServer(ctx, appoptions.Assets, appoptions.AssetsHandler, bindings)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue