Exemple #1
0
func initWebView() *webkit.WebView {
	gtk.Init(nil)
	webview := webkit.NewWebView()
	webview.Connect("load-error", func() {
		fmt.Printf("Load Error: %s\n", webview.GetUri())
	})
	webview.Connect("onload-event", func() {
		fmt.Printf("Onload Event: %s\n", webview.GetUri())
	})
	webview.Connect("resource-load-finished", func(wv interface{}) {
		fmt.Printf("Resource Load Finished: %v\n", wv)
	})
	webview.Connect("load-committed", func() {
		//entry.SetText(webview.GetUri())
		fmt.Printf("Load Committed: %s\n", webview.GetUri())
	})
	webview.Connect("load-finished", func() {
		//entry.SetText(webview.GetUri())
		fmt.Printf("Load Finished: %s\n", webview.GetUri())
		//time.Sleep(time.Second)
		title := webview.GetTitle()
		webview.ExecuteScript("document.title=document.documentElement.innerHTML")
		str := webview.GetTitle()
		webview.ExecuteScript("document.title=" + title)
		fmt.Printf("Html: %s\n", str)
		gtk.MainQuit()
	})

	webview.LoadHtmlString(HTML_STRING, ".")
	gtk.Main()
	return webview
}
Exemple #2
0
func main() {
	gtk.Init(nil)
	webview := webkit.NewWebView()
	/*
		webview.Connect("load-error", func() {
	        fmt.Printf("Load Error: %s\n", webview.GetUri())
		})
		webview.Connect("onload-event", func() {
	        fmt.Printf("Onload Event: %s\n", webview.GetUri())
		})
		webview.Connect("resource-load-finished", func(wv interface{}) {
	        fmt.Printf("Resource Load Finished: %v\n", wv)
		})
		webview.Connect("load-committed", func() {
	        fmt.Printf("Load Committed: %s\n", webview.GetUri())
		})
	    webview.Connect("load-changed", func() {
	        fmt.Printf("Load Changed: %s\n", webview.GetUri())
		})

	*/
	webview.Connect("load-finished", func() {
		fmt.Printf("Load Finished: %s\n", webview.GetUri())
		//time.Sleep(3 * time.Second)
		fmt.Printf("%s\n", getHtml(webview))
	})
	/*
	   var d int = 0
	   for _,s := range sigs {
	       webview.Connect(s, func() {
	           fmt.Printf("%s finished\n", s)
	           if d > 0 {
	               c <- s
	           }
	           d++
	       })
	   }
	*/
	//go webview.LoadString("<html><DIV>Fooe</DIV></html>", "text/html", "utf-8", "")
	webview.LoadUri("http://google.com")
	//fmt.Printf("FFFFFFFFFFFFFF%s\n", getHtml(webview))
	gtk.Main()
	//go gtk.Main()
	//doit(webview)
}