Save settings changes only if the user clicks "OK"

As described in Issue #34, the changes were not saved atomically when the user
clicked on "OK", but they inconsistently saved while the user was interacting
with the window. This commit fixes it, flushing values to the preferences
persistent storage only when the user clicks "OK".

fixes #34