// Copyright (c) 2014 Josh Rickmar.
// Use of this source code is governed by an ISC
// license that can be found in the LICENSE file.

package main

import (
	"runtime"

	"github.com/conformal/gotk3/gtk"
	"github.com/jrick/go-webkit2/wk2"
)

const HomePage HTMLPageDescription = "https://www.duckduckgo.com/lite"

const (
	defaultWinWidth  = 1024
	defaultWinHeight = 768
)

// RunGUI initializes GTK, creates the toplevel window and all child widgets,
// opens the pages for the default session, and runs the Glib main event loop.
// This function blocks until the toplevel window is destroyed and the event
// loop exits.
func RunGUI() {
	gtk.Init(nil)

	window, _ := gtk.WindowNew(gtk.WINDOW_TOPLEVEL)
	window.Connect("destroy", func() {
		gtk.MainQuit()
	})
	window.SetDefaultGeometry(defaultWinWidth, defaultWinHeight)
	window.Show()

	wc := wk2.DefaultWebContext()
	wc.SetProcessModel(wk2.ProcessModelMultipleSecondaryProcesses)

	session := []PageDescription{HomePage}
	pm := NewPageManager(session)
	window.Add(pm)
	pm.Show()

	gtk.Main()
}

func main() {
	runtime.GOMAXPROCS(runtime.NumCPU())
	RunProfiler("localhost:7070")
	RunGUI()
}

// Copyright (c) 2014 Josh Rickmar.
// Use of this source code is governed by an ISC
// license that can be found in the LICENSE file.

package main

import (
	"github.com/conformal/gotk3/gtk"
	"runtime"
)

const HomePage HTMLPageDescription = "https://www.duckduckgo.com/lite"

const (
	defaultWinWidth  = 1024
	defaultWinHeight = 768
)

// RunGUI initializes GTK, creates the toplevel window and all child widgets,
// opens the pages for the default session, and runs the Glib main event loop.
// This function blocks until the toplevel window is destroyed and the event
// loop exits.
func RunGUI() {
	gtk.Init(nil)

	window, _ := gtk.WindowNew(gtk.WINDOW_TOPLEVEL)
	window.Connect("destroy", func() {
		gtk.MainQuit()
	})
	window.SetDefaultGeometry(defaultWinWidth, defaultWinHeight)
	window.Show()

	session := []PageDescription{HomePage}

	pm := NewPageManager(session)
	window.Add(pm)
	pm.Show()

	gtk.Main()
}

func main() {
	runtime.GOMAXPROCS(runtime.NumCPU())
	RunProfiler("localhost:7070")
	RunGUI()
}

--- 
+++ 
@@ -5,8 +5,10 @@
 package main
 
 import (
+	"runtime"
+
 	"github.com/conformal/gotk3/gtk"
-	"runtime"
+	"github.com/jrick/go-webkit2/wk2"
 )
 
 const HomePage HTMLPageDescription = "https://www.duckduckgo.com/lite"
@@ -30,8 +32,10 @@
 	window.SetDefaultGeometry(defaultWinWidth, defaultWinHeight)
 	window.Show()
 
+	wc := wk2.DefaultWebContext()
+	wc.SetProcessModel(wk2.ProcessModelMultipleSecondaryProcesses)
+
 	session := []PageDescription{HomePage}
-
 	pm := NewPageManager(session)
 	window.Add(pm)
 	pm.Show()
Use multiple WebKit web processes.

A new feature for WebKit2GTK+ 2.4, we can now specify to use multiple
webkit web processes rather than all webviews sharing the same
process.

If a tab's web process is not shared with any other's (although
currently unimplemented, this may happen when a tab is opened by
another webview, either through javascript or middle-clicking a
hyperlink), killing or crashing that web process only results in one
broken tab rather than crashing the entire browser (WebKit1) or
breaking every tab (WebKit2GTK+ <= 2.2).
