De Vicenzo: A much cooler mini web browser.
It seems it was only a few days ago that I started this project. Oh, wait, yes, it was just a few days ago!
If you don't want to read that again, the idea is to see just how much code is needed to turn Qt's WebKit engine into a fully-fledged browser.
To do that, I set myself a completely arbitrary limit: 128 lines of code.
So, as of now, I declare it feature-complete.
The new features are:
Tabbed browsing (you can add/remove tabs)
Bookmarks (you can add/remove them, and choose them from a drop-down menu)
This is what already worked:
Zoom in (Ctrl++)
Zoom out (Ctrl+-)
Reset Zoom (Ctrl+=)
Find (Ctrl+F)
Hide find (Esc)
Buttons for back/forward and reload
URL entry that matches the page + autocomplete from history + smart entry (adds http://, that kind of thing)
Plugins support (including flash)
The window title shows the page title (without browser advertising ;-)
Progress bar for page loading
Statusbar that shows hovered links URL
Takes a URL on the command line, or opens http://python.org
Multiplatform (works in any place QtWebKit works)
So... how much code was needed for this? 87 LINES OF CODE
Or if you want the PEP8-compliant version, 115 LINES OF CODE.
Before anyone says it: yes, I know the rendering engine and the toolkit are huge. What I wrote is just the chrome around them, just like Arora, Rekonq, Galeon, Epiphany and a bunch of others do.
It's simple, minimalistic chrome, but it works pretty good, IMVHO.
Here it is in (buggy) action:
It's more or less feature-complete for what I expected to be achievable, but it still needs some fixes.
You can see the code at it's own home page: http://devicenzo.googlecode.com
Why Ctrl+= for Reset Zoom instead of Ctrl+0 like in every other browser? :-)
Good question :-)
You didn't write plug-in support. In fact, I did a lot of it. :)
Setting the WebSettings plugins_enabled to True doesn't count as a feature.
Does your URL entry autocomplete from bookmarks? Is it smart, or is it just dumb default Entry autocomplete behavior? Printing? Cookies? Keyring?
It completes from the WebView's URL history, so no, not default autocomplete behaviour . Right now it's buggy in that it completes only from that tab's history, but that's easy to fix, same as adding the bookmarks to the completer.
Having it complete from the web page titles is trickier.
Update: now there is a global autocompleter that also includes the bookmarks. It could be made much smarter, matching somewhere else than at the beginning of URLs, matching titles, etc, by reimplementing QStringListModel.match() but that's boring ;-)
Of course I know I did not write plug-in support, I did not claim I did either! (I am getting tired of everyone thinking they are clever by figuring out that I am using WebKit, really ;-)
Printing? Who prints things anymore? Niche feature!
It has cookies, but doesn't persiste them between sessions (should be doable).
It has no keyring support.
Well you are listing plug-in support as a feature amidst the other ones you did write. So it sort of implies that you are doing something special for it.
And people print things. Especially after checking in for a flight. Also, I always print receipts to PDF.
And persistent cookies is quite important. As is keyring password saving.
The only real way you're goign to get a totally feature full modern browser in 128 lines of Python, is if you do all the UI in JavaScript instead. :)
I specifically called that list "things that work", not "things I wrote". I don't see Safari or Chrome saying they don't have HTML4 rendering because that was already in KHTML before it was forked ;-)
I could implement printing the page to PDF in ... ok, maybe 10 more lines, and maybe another 15 for persistent cookies, so both are doable within the constraints. I will see if I have a moment later today :-)
updated: I added print to image, print to PDF is more or less the same.
Keyring support seems to be much more difficult.
Chrome/mium didn't have printing support for a while.. soo.. ;-)
I seriously underestimated Qt. Full print support is done, including previewing and printing to PDF: 2 lines ;-)
Full printing support (PDFs and real printers) and persistent cookies are now on SVN. They added about 10 lines of code :-)
Yo hace un tiempo había hecho un navegador web en Python+PyQt en 60 lineas, que tenia un par de cosas igual, por ahí podrías agregarle que cuando escribas palabras sueltas (que no tengan forma de url) en la barra de navegación, te haga la búsqueda en google derecho como hace chrome, acá tendrías ese código:
http://pastebin.com/y11LdrQU
Y está es la versión que yo había hecho, esta el código tanto para C++ y Python:
http://utopia555.blogspot.c...
Saludos!