forked from cztomczak/cef2go
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathmain_darwin.go
51 lines (41 loc) · 1.23 KB
/
main_darwin.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// Copyright (c) 2014 The cef2go authors. All rights reserved.
// License: BSD 3-clause.
// Website: https://github.com/CzarekTomczak/cef2go
package main
import (
"cef"
"cocoa"
"github.com/op/go-logging"
"os"
)
var log = logging.MustGetLogger("cef2go")
func main() {
// Executable's directory
exeDir := cocoa.GetExecutableDir()
// CEF subprocesses.
cef.ExecuteProcess(nil)
// Initialize CEF.
settings := cef.Settings{}
settings.CachePath = exeDir + "/webcache" // Set to empty to disable
settings.LogSeverity = cef.LOGSEVERITY_DEFAULT // LOGSEVERITY_VERBOSE
settings.LogFile = exeDir + "/debug.log"
//settings.LocalesDirPath = cwd + "/cef.framework/Resources"
//settings.ResourcesDirPath = cwd + "/cef.framework/Resources"
cef.Initialize(settings)
// Create Window using Cocoa API.
cocoa.InitializeApp()
window := cocoa.CreateWindow("cef2go example", 1024, 768)
cocoa.ConnectDestroySignal(window, OnDestroyWindow)
cocoa.ActivateApp()
// Create browser.
browserSettings := cef.BrowserSettings{}
url := "file://" + exeDir + "/example.html"
cef.CreateBrowser(window, browserSettings, url)
// CEF loop and shutdown.
cef.RunMessageLoop()
cef.Shutdown()
os.Exit(0)
}
func OnDestroyWindow() {
cef.QuitMessageLoop()
}