go-gtk icon indicating copy to clipboard operation
go-gtk copied to clipboard

return from event(signal handler)

Open sg3des opened this issue 8 years ago • 7 comments

return value from signal handlers, it is work?

example:

somebody.Connect("signal", callback)

func callback(ctx *glib.CallbackContext) interface{} {
    \* some code *\
    return something
}

thx!

sg3des avatar Feb 17 '17 08:02 sg3des

What is your expected? Which widget or event do you mean?

mattn avatar Feb 17 '17 10:02 mattn

for example here: WebKitWebView-create-web-view

this signal handler should be return a new instance of webview

sg3des avatar Feb 17 '17 10:02 sg3des

Currently, go-gtk suppor only bool return value.

https://github.com/mattn/go-gtk/blob/master/glib/glib.go#L813-L814

But I can fix this in feature.

mattn avatar Feb 17 '17 10:02 mattn

Yes, I saw it, just wanted to be sure... I will try to to complete it, thx you.

sg3des avatar Feb 17 '17 11:02 sg3des

i am don't know how to fix this without changing too much of code, in my opinion, easier to add separate function, something like: ConnectCreateWebView for type webview in go-webkit package... but this is not correct way.

P.S. this condition does nothing: https://github.com/mattn/go-gtk/blob/master/glib/glib.go.h#L133-L138

sg3des avatar Feb 18 '17 08:02 sg3des

Maybe last change will be something good for you.

mattn avatar Feb 18 '17 14:02 mattn

Great! Thx!

I think the getWebView function, package go-webkit should be public (ex: GetWebView), to be able to return C type of WebView from signal handler. example: https://github.com/sg3des/vegevoice/blob/master/browser_tabs.go#L84-L87

or is there another way?

sg3des avatar Feb 18 '17 17:02 sg3des