github.com/ckxng/wakeup@v0.0.0-20190105202853-90356a5f5a15/src/main_darwin.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      "cocoa"
    10      "os"
    11      "log"
    12  )
    13  
    14  var Logger *log.Logger = log.New(os.Stdout, "[main] ", log.Lshortfile)
    15  
    16  func main() {
    17      // Executable's directory
    18      exeDir := cocoa.GetExecutableDir()
    19  
    20      // CEF subprocesses.
    21      cef.ExecuteProcess(nil)
    22  
    23      // Initialize CEF.
    24      settings := cef.Settings{}
    25      settings.CachePath = exeDir + "/webcache" // Set to empty to disable
    26      settings.LogSeverity = cef.LOGSEVERITY_DEFAULT // LOGSEVERITY_VERBOSE
    27      settings.LogFile = exeDir + "/debug.log"
    28      //settings.LocalesDirPath = cwd + "/cef.framework/Resources"
    29      //settings.ResourcesDirPath = cwd + "/cef.framework/Resources"
    30      cef.Initialize(settings)
    31  
    32      // Create Window using Cocoa API.
    33      cocoa.InitializeApp()
    34      window := cocoa.CreateWindow("cef2go example", 1024, 768)
    35      cocoa.ConnectDestroySignal(window, OnDestroyWindow)
    36      cocoa.ActivateApp()
    37  
    38      // Create browser.
    39      browserSettings := cef.BrowserSettings{}
    40      url := "file://" + exeDir + "/example.html"
    41      cef.CreateBrowser(window, browserSettings, url)
    42  
    43      // CEF loop and shutdown.
    44      cef.RunMessageLoop()
    45      cef.Shutdown()
    46      os.Exit(0)
    47  }
    48  
    49  func OnDestroyWindow() {
    50      cef.QuitMessageLoop()
    51  }