github.com/ckxng/wakeup@v0.0.0-20190105202853-90356a5f5a15/src/main_linux.go (about) 1 // Copyright (c) 2014 The cef2go authors. All rights reserved. 2 // License: BSD 3-clause. 3 // Website: https://github.com/CzarekTomczak/cef2go 4 5 package main 6 7 import ( 8 "cef" 9 "gtk" 10 "os" 11 "log" 12 ) 13 14 var Logger *log.Logger = log.New(os.Stdout, "[main] ", log.Lshortfile) 15 16 func main() { 17 // TODO: It should be executable's directory used 18 // rather than working directory. 19 cwd, _ := os.Getwd() 20 21 // CEF subprocesses. 22 cef.ExecuteProcess(nil) 23 24 // CEF initialize. 25 settings := cef.Settings{} 26 settings.CachePath = cwd + "/webcache" // Set to empty to disable 27 settings.LogSeverity = cef.LOGSEVERITY_DEFAULT // LOGSEVERITY_VERBOSE 28 settings.LogFile = cwd + "/debug.log" 29 cef.Initialize(settings) 30 31 // Create GTK window. 32 gtk.Initialize() 33 window := gtk.CreateWindow("cef2go example", 1024, 768) 34 gtk.ConnectDestroySignal(window, OnDestroyWindow) 35 36 // Create browser. 37 browserSettings := cef.BrowserSettings{} 38 url := "file://" + cwd + "/example.html" 39 cef.CreateBrowser(window, browserSettings, url) 40 41 // CEF loop and shutdown. 42 cef.RunMessageLoop() 43 cef.Shutdown() 44 os.Exit(0) 45 } 46 47 func OnDestroyWindow() { 48 cef.QuitMessageLoop() 49 }