We are implementing it with Mozilla for now (though would love to have an alternative in WebKit as well, code welcome) and after some time using gtkmozembed, Marco decided that we would be better off with something lighter (read less buggy), with less amount of C code and with easy access to PyXPCOM. Then hulahop was born.
This is the simplest snippet that will bring you an embedded instance of mozilla into your pygtk app:
from hulahop.webview import WebView
w = gtk.Window()
v = WebView()
But that isn't anything that gtkmozembed cannot do, so if you add the following snippet just before the call to gtk.main(), you will get something more interesting ;)
from xpcom.components import interfaces
_com_interfaces_ = interfaces.nsIWebProgressListener
def onStateChange(self, webProgress, request, stateFlags, status):
if not (stateFlags & interfaces.nsIWebProgressListener.STATE_IS_NETWORK and \
stateFlags & interfaces.nsIWebProgressListener.STATE_STOP):
images = v.dom_window.document.documentElement.getElementsByTagName('IMG')
for i in range(images.length):
image = images.item(i)
image.height *= 3
image.width /= 3
listener = ProgressListener()
wrapped_listener = xpcom.server.WrapObject(listener,
As you can see, with hulahop you have ready access to most mozilla internals, in the example above we are manipulating the document DOM, but you can also access network stuff, security, user events, etc
Right now, those snippets will work only on Fedora 10 unless you build your own stuff. But as in the abiword case, people are already working on packaging hulahop for all the major distros.
And what about the future? I would love to see more applications to provide their canvases as proper gtk widgets and moving them to libraries. The ones on the top of my list are gnumeric and inkscape, any suggestion?
Let's build a GTK+ shell around it and call it Galeon! =)
Thanks a lot! I got userscripts working.
Post a Comment