Community
Participate
Working Groups
I dont know if the invocation of Browserfunctions is not supported yet for GTK+ 3.* However what i tried to accomplish is to use the SWT Browser widget to have a bidirectional communication between java and javascript. On Windows 7 i can simply create a browserfunction and call it from JScript. On Ubuntu 16.04, using GTK+3.0.18, the same code can not invoke any functions, that are registered as a Browserfunction. If somebody could provide me with a working example (and possibly the steps that i need to setup my Ubuntu for it) this would be great. I also would not mind using any SWT version, but so far it did not work with 4.4 and 3.105 (which is bundled in my current eclipse) Thanks Markus
(In reply to Markus Krug from comment #0) > I dont know if the invocation of Browserfunctions is not supported yet for > GTK+ 3.* > > However what i tried to accomplish is to use the SWT Browser widget to have > a bidirectional communication between java and javascript. > > On Windows 7 i can simply create a browserfunction and call it from JScript. > > On Ubuntu 16.04, using GTK+3.0.18, the same code can not invoke any > functions, that are registered as a Browserfunction. > > If somebody could provide me with a working example (and possibly the steps > that i need to setup my Ubuntu for it) this would be great. I also would not > mind using any SWT version, but so far it did not work with 4.4 and 3.105 > (which is bundled in my current eclipse) > > Thanks > Markus Hello Markus, It's supported on Gtk2/3. I'm currently working on improving this business as well. As things stand, Gtk has Webkit1 and Webkit2 as a backend. BrowserFunction works fully in Webkit1. We are in the process of porting to Webkit2 thou. (sort of like Gtk2->Gtk3 port). It currently works mostly in Webkit2 but java can't provide a return value back to javascript when BrowserFunction is called, but I'm working on finishing that. (see related). This snippet demonstrates how to use BrowserFunction: http://git.eclipse.org/c/platform/eclipse.platform.swt.git/tree/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet307.java It should work on Webkit1. Half of it works on Webkit2. To run webkit2: export SWT_WEBKI2=1 ./eclipse You should ideally use newest builds as it has most webkit2 related fixes: http://download.eclipse.org/eclipse/downloads/ I think you're referring to Gtk3 3.18 not Gtk3.0.18. But to get exact version, you can run a snippet with the following environmental variable: SWT_LIB_VERSIONS=1 It will then print gtk and webkit version.
Was the above snippet helpful? If not, what happens when you run the snippet?
Btw, ubuntu is linux not unix. Did you mean linux?
Hi Leo, thanks for the quick answer :). I tried the snippet on windows and it works perfectly fine (as expected). Going to my 16.04 Ubuntu yielded : "Can`t find variable: theJavaFunction" setting the Variable did not change anything Setting the Environmental Variable did not print anything as well (i assume because i am using SWT 3.105 and i think it was added with 4.7, but the GTK is at version 3.18.9) Is there a maven repository with the current version of SWT? Also: Yeah i tried currenlty only have an Ubuntu 16.04 with a UI available for testing
Okay i found a maven repository for the newer versions, i am now using SWT version 4.7M3. I still cant get the versions printed. The error which is thrown now is "Cant find variable: external"
Maven builds are kinda old I think. Try the newest integration build: http://download.eclipse.org/eclipse/downloads/ Like click on something like: I20170821-2000 There somewhere you can find the swt.jar. I've only added SWT_LIB_VERSIONS=1 like a month ago, so it won't work on older SWT builds. SWT 3.1 is very old. Can you try with the SWT from the integration builds above and see if you're more sucessfull? Btw, is webkit / webkitgtk libs installed on your system?
Okay thank you, i did what you said and got my Versions: GTK 3.18.9 and WebkitGTK:2.16.0. Im also no longer getting an exception, and also receive the call in my java function (but as you said no return value). Is there an easy way, starting form here that would make the snippet work entirely?
(In reply to Markus Krug from comment #7) > Okay thank you, > i did what you said and got my Versions: > > GTK 3.18.9 and WebkitGTK:2.16.0. > > Im also no longer getting an exception, and also receive the call in my java > function (but as you said no return value). > > Is there an easy way, starting form here that would make the snippet work > entirely? For webkit1 it should work out of the box. (i.e, export SWT_WEBKIT2=0), for webkit2, I'm currently working on implementing the return value support. (see related bug). Does it work on webkit1 for you, or only on webkit2?
Hi there is no difference for me, if i set the env. variable or not
(In reply to Markus Krug from comment #9) > Hi there is no difference for me, if i set the env. variable or not A possibility is that you have only one webkit version installed on your system thus it automatically falls back to it no matter what you set via the env. variable. Can you post the webkitgtk packages versions on your system?
Webkit2 browser functions are in master now and you haven't responded in months. I'm marking the bug as resolved but please reopen if you still face the issue with latest builds.