sourcegraph / go-webkit2

WebKit API bindings (WebKitGTK+ v2) for Go
https://sourcegraph.com/github.com/sourcegraph/go-webkit2
Other
313 stars 61 forks source link

no way to convert gtk.Widget to WebView? #44

Open rocket049 opened 6 years ago

rocket049 commented 6 years ago

i can't find any way to convert a gtk.Widget object to WebView object? help!

rocket049 commented 6 years ago

I add a function in webview.go,it seems work correct.

// WidgetToWebView convert a Widget(it must be converted from WebView) back to WebView
func WidgetToWebView(widget *gtk.Widget) *WebView {
    obj := widget.Object
    p := unsafe.Pointer(widget.Native())
    return &WebView{&gtk.Widget{glib.InitiallyUnowned{obj}}, C.to_WebKitWebView((*C.GtkWidget)(p))}
}