History buttons for epdfview

Jul 25, 2010 21:57


My favourite PDF reader is epdfview, it's a really simple and light-weight program, depends only on GTK2 and Poppler. It does have it's weak spots though. One such weak spot is the lack of history buttons (so that you could go back after clicking a cross-reference link for example). A few days ago I got really fed up with this and decided to add history myself.

The task turned out to be a little more complicated then I anticipated: first of all, after I actually added the buttons and made them work, I realized that when you go back or forth in history, you must also save the position on page and restore it, otherwise, it's not that much better than having no history at all; second of all, the program is done object-orientedly and the way entities communicate with each other -- is basically by notifications, when you look at epdfview's source code, it seems really well-organized and all, but when you're trying to modify it, you stumble upon this fact that, say, you can't just directly call some function to get information you want -- you have to make that other thing call you, and sometimes, there isn't a direct route between where you need the information and where it is located. But then again, maybe I'm just a bad programmer :D

Anyways, here's the modified source code: epdfview-trunk.tar.gz and a screenshot:




P.S. I should really read other people's code more often. Every time I do -- I learn some new neat trick or some good idea. This time, I learned the following trick with assert:
gassert(data && "Invalid argument: data is NULL");
When the assert is triggered, it not only will output the file name and line number where the assertion failed, it might also output a meaningful message.
Previous post Next post
Up