app: properly disconnect from the old shell in gimp_tool_dialog_set_shell()

Also clean up the function a bit.