14 Aug 2008 dobey   » (Master)

Recent Hacks

Today, I ended up getting a few hacks committed to SVN, and got a mostly working patch against leafpad together, to make it use GIO for file I/O. I fixed Beef to check the Last-Modified header using a HEAD request, for subscribed feeds, and got rid of the previous check to see if an update should be pulled. The previous method was just a timeout that checked against the last timestamp the update loop was run, to see if a specific feed needed to be updated. It worked okay, until I started subscribing to more feeds, and having the daemon restart, as all the feeds would just end up having very close timestamps for their last update time. Now, Beef compares the Last-Modified header, and stores that value instead. Recently, I had also ported Beef over to GIO, from gnome-vfs, for the case where embedded content might be pulled from a different protocol than HTTP(S). I also got rid of gnome-vfs in gtkhtml2's testgtkhtml program, replacing it with libsoup and GIO, at the same time. Today, though, I also committed the changes to make Encompass use GIO instead of gnome-vfs for loading data on protocols other than HTTP(S). This was a bit more work than the previous two patches, as I was using gnome_vfs_get_mime_type() to check the MIME type for URIs, so that I didn't end up streaming an exe into the HTML view. But GIO/glib doesn't have an exact replica of that functionality, so I had to end up writing a method using libsoup to check the content type. It works by requesting the first 1024 bytes of data from the server, and using that for the magic comparison with the GConentType API. It also checks the Content-Type header, and falls back to application/octet-stream on error. It's nice to click on a PDF and have it just open right up in Evince. I also haven't got the code together yet, but it will be extremely simple to pop up a dialog for RSS/ATOM feeds, so that the user can just subscribe to them.

As far as leafpad goes, I like very much how lightweight it is, and really wanted to be able to just click on patch files in the browser, and have them open right up in it. But, leafpad wasn't using GIO or gnome-vfs. And the text/plain handler that does support opening from URIs, which gets called, happened to be OpenOffice.org. Quite a bit much for just opening a small text file. I also don't seem to be able to find where the source repository for leafpad is, if there even is one. So, I took to using the tarball to create the patch. It's not a complete patch, but it does get the job done. I can open files remotely, and save to remote as well, though there does seem to be an issue with saving large files. I think there might be a bug in GIO (my sftp mount disappears off my desktop), but I'm not sure exactly, and haven't spent any time debugging it really. But here's a screenshot of www.gnome.org opened in leafpad using GIO:


Syndicated 2008-08-14 02:10:10 from dobey's blog

Latest blog entries     Older blog entries

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!