This patch makes the indentation of this function hard to read. Would it be better to just reformat this function to be like the reset of the file.
I didn't think we were supposed to change the formatting of existing code.
Then again, this function pretty much needs a complete rewrite so we can implement a selection dialog.