On Wed, Feb 1, 2012 at 5:46 AM, lkcl luke <[email protected]> wrote:
> On Wed, Feb 1, 2012 at 10:53 AM, C Anthony Risinger <[email protected]> wrote:
>>
>>  i got distracted the last day or
>> so enhancing pywebkitgtk with various things i'll detail to others in
>> another post,
>
>  cool!
>
>  hmm, i should add you to the gnu project, then.

oh, i meant the bits specific to pyjd, not pythonwebkit itself --
though i'm happy to add those 5 patches we discussed previously (all
are safe, and already in trunk, so not necessary if you are updating
to latest WebKit).

pywebkitgtk pyjd engine received a couple updates that have been
bothering me ...

bug:

) properly destroy TOPLEVEL window and exit mainloop safely
i was connecting to the wrong shutdown event before (destroy), even
though it technically worked ... i think.  changed to use
`delete-event` which is earlier, and can properly tear down the window
-- pywebkitgtk engine should no longer have any warnings or exceptions
from pressing the `X` (Ctrl^c still does, of course) ... if it does,
lmk.

) apply same-origin-ish policy to file URIs
i've enabled `enable-file-access-from-file-uris` internal webkit
option which should allow file:// URIs to work properly; a webserver
*shouldn't* be strictly needed anymore.  we coooould use
`enable-universal-file-access-from-file-uris` to effectively disable
same-origin policy, but doesn't seem useful to me ... unless someone
has a use case (cross-domain XHR, etc).

cosmetic:

) sync GTK title with HTML <title>
the GTK window will now display the <title> of the document, and
should also work if the title is updated.

) scan <head> for icon-like uris for use as a GTK window icon
this one is kind of cool -- when the callback for `icon-loaded`
(favicon) fires, i also scan the rest of the <head> in search of
anything that looks like it could be an icon (CSS selectors):

    head link[rel~=icon][href]
    head link[rel|=apple-touch-icon][href]
    head meta[itemprop=image][content]

... and attempt to load each of them.  i then choose the largest one
for use as the window icon (alt-tab, minimized, etc).  it's a little
naive ATM -- no cache [needed?], no "good enough" threshold, probably
busted for file:// URIs [fixable], one-pass only -- but it works well.
 WebKit offers network callbacks that could possibly be used to
inspect/hijack the data simpler/realtime, not sure whats possible
there. if no icons are found, fallback to themes `gtk-dialog-question`
(a large `are you sure?` icon) instead of the nasty `OMG! NOT
FOUND!!!1` icon.

... if you want to try, just update pyjd to HEAD, or just replace the
`pyjd/pywebkitgtknew.py` file on your system with the one from HEAD.

i am returning to mail app for now, but i've also been thinking of
ways to hint to pyjs that pyjd is running, and thus prevent the app
from loading twice.  i have a couple ideas already i'll be playing
with (), but am soliciting for them as well. i could disable JS
altogether, but that isn't a real solution. thoughts?

-- 

C Anthony

Reply via email to