Another infrequent commit

So I made a minor improvement to JuK yesterday (in the 3.5 branch, I’m still seeing how it applies to KDE 4). Basically the “Add to JuK Collection” action that is added to Konqueror when selecting music files didn’t work. And, not only did it not work, but if you selected 20 different files and tried to add them to JuK, your taskbar would fill up with 20 different buttons as DCOP was run 20 times simultaneously trying to add the files at once.

Implementing the fix led me to discover a feature of the dcop command line tool that I was not aware of. Let’s say that you wanted to call a function that had different variants with the same name. This is something I ran into with JuK, as the openFile() command I’d be using has 4 different variants, allowing you to add one or multiple files, into either the Collection List or a specific playlist.

The easy part is telling dcop which function to use. In my case, I wanted openFile(QStringList). So my dcop command line looked something like dcop juk Collection 'openFile(QStringList)' <i>files</i>.

But the command wouldn’t work, complaining that there were not enough arguments. A brief Google search didn’t lead me to any help either, so I started digging in the source code for the dcop command line client. Eventually I discovered that when the dcop client is reading in a QStringList, it expects it to be specially marked out. You can use brackets for this purpose. So my (working) command line was dcop juk Collection 'openFile(QStringList)' [ <i>files</i> ].

Converting this into the service menu was easy enough. Aaron Seigo’s service menu tutorial covers basically everything you need to know. The problem that caused 20+ taskbar entries when selecting multiple files is from the original service menu entry using the %u field (which says pass one URL at a time) instead of the %U field (which means to pass all URLs at once to the application). So the final service menu entry was this: Exec=dcop juk Collection 'openFile(QStringList)' [ %U ].

Noting the change in the KDE 3.5 changelog was much easier than last time when I had to do so. Now we have a fancy XML file that we add entries into, and the appropriate PHP page is automagically generated, with all the fancy hyperlinks as appropriate. It’s actually pretty nice, so good job Carsten!