I used to edit the GPX-files by hand, but that meant that I had to run the GPX-file through the GPS Visualizer multiple times to see what would become of it. I was very pleased when I found Viking, an open-source GPX-editor that draws the tracklogs and waypoints on top of a map layer. That way, you get a preview of what it would look like superimposed on a Google Map -- and editing tracks is very easy.
One of the things Viking can do is merge track logs if the end of one and the start of the second are within a specified time frame of one another. When you walk into a shop and the GPS receiver loses its fix, it will start a new track log when it reacquires a fix -- and if you want those two tracks to be combined, that feature works quite well.
However, Viking will greedily add the next track if that is within the time frame too, and the next, and so on. Sometimes, you don't want that -- sure, you can split tracks again with Viking, but why should I first add everything together and then re-create the previous situation? So I wanted to be able to add two specific tracks together.
So I downloaded the source from the subversion repository and had a look. It's all written in C, with the interface and many, many data-structures done through the GTK library (the foundation under such things like Gnome, the default Ubuntu desktop environment). I used GTK widgets in my own programs, but those are the Python bindings -- in C, there are such things like allocations, pointers and freeing memory to think of. Less... elegant, somehow.
Anyway, grepping through the source showed me where the context-menu for layers was. With a bit of fiddling, I added my own option (people who know my style of code won't be surprised to find that this option was titled 'PIPCO') and my own callback function. From that, I expanded into creating a new dialog, populating a list with the names of all the tracks (but not the one that was currently selected) and merging the current track with the selected track. All by using the existing code as an example, along with the GTK online reference manuals. By the end of the evening, it was working as I had intended.
Which pleases me more than it probably should. At work, I try to do as little programming as possible, because I'm trying to be more of a manager than a programmer. But at home, I get to fix things. :)
I submitted my patch this morning. Haven't heard back from the developers yet, but I expect that it will be included without too much problems. Open source FTW.