Hello all,
Submitted for your perusal, as the outcome of my Google Summer of Code
efforts hitherto:
http://www.thinkollab.net/socghop/Wx-WebKit-0.01.tar.gz
The first (somewhat) working draft of a shiny new module. It's for
putting a browser in your Wx apps... with a few temporary caveats.
First, it doesn't work on Windows, because wxWebKit only compiles with
MSVC at the moment. So Strawberry's right out, and my ActivePerl install
is GCC-built too. I'm not sure if all AP versions are (I think they used
to be MSVC?) but there you go. We're going to start work on porting to
GCC / MinGW, but I don't know how long that'll take.
Also, there's a bug that's only in the Gtk layer at the moment which
makes it pretty unusable on Linux too <:-P You can fire it up and
half-load some pages, but that's about it. You can see what it's trying
to do. This bug has already been fixed, only the fix hasn't been pushed
to trunk yet. It should be in the /scons branch of the wxWebKit git repo
if you have the skillz and inclination to apply it yourself (although
sneakily, the new build system is in fact waf, not scons.)
Building the wxWebKit binaries was a steep learning curve for me
personally; it might be a lot easier for people who know what they're
doing, but I've put up a Linux (Ubuntu 9.04) binary for those who want
the least possible faffing about (75MB tarball mind):
http://www.thinkollab.com/socghop/wxwebkit_linuxBinary.tar.gz
Now, if anyone's still with me, there are a number of things that I'm
still working on / need help with:
1) General coding style of /Wx/DemoModules/wxWebKit.pm, suitability /
readability / completeness of the pod, etc.
2) Testing on Mac / BSD.
...and in a more technical vein...
3) For some reason, when I tried to change sub OnAddressBarEnter to also
call SetFocus on the Wx::WebView object, it crashed with the error:
"Can't locate object method "SetFocus" via package "Wx::WebView" at
blib/lib/Wx/DemoModules/wxWebKit.pm line 275." (you'll see I have the
line still there commented out). I went and looked through the .pm and
.xs files of a number of controls in the Wx core package and couldn't
see anything special or explicit that enabled them to use functions
inherited from wxWindow. wxWebView is a public wxWindow as well. Anyone
know what I'm missing here?
4) The general wxWebKit API class is called wxWebView, so that's what I
ran through h2xs and that's what I started hacking on at the beginning.
I always thought that it'd be more convenient for users of the module to
call Wx::WebKit->new, so this morning I tried to change it to that. I
changed the package name in WebKit.xs, and every occurrence of 'WebView'
I could find in Wx/WebKit.pm and Wx/DemoModules/wxWebKit.pm. test.pl
seemed to load fine, but when I input a URL and OnAddressBarEnter
eventually called $browser->LoadURL, the app crashed with the error
"variable is not of type Wx::WebView at ..." and the line number of the
call. I grep'd through my sources and couldn't find 'WebView' outside of
the .c and .xs files, as I thought it had to be, since that's the C++
class name it's calling, so I couldn't figure what else to change (I did
try changing it in the .xs out of desperation, you can guess how well
that worked). When I grep'd for that error message in the Wx sources I
found it in four different places in helpers.cpp, at least one of which
was very near by something marked 'magic'. I've tried hard to get the
inner wisdom of Wx but... it's a jungle in there. If anyone could shed
some light on this one too I'd be very grateful.
5) I haven't figured how to expose wxWebView's special events yet. I'm
going to look at Wx::ActiveX for how to do that; hopefully I'll
understand what's going on, if not I'll hit it with a wrench for a while
before giving up and asking here again.
So, if anyone can help with any of the above, I'd be very much obliged.
Big thanks to Mattia and the wxperl-users list for all your help so far.
ta for now,
-- Ryan
p.s. I've called this a 'new' module, and labelled my effort 0.01 - you
might know there's already a Wx::WebKit module on CPAN that dates back
to 2006 and only works on Mac (it'd be nifty if someone could confirm
that it still works?) I haven't been in direct contact with the module's
maintainers yet, but if my one works on Mac at the minute then it should
be as functional as the existing one. Mac users please let me know.