Correctly handle a timeout source life cycle within a function
Using a static variable for the source id is not enough here, because the source is destroyed when the timeout handler returns FALSE, but the static id isn't reset. Hence, this causes a GLib-CRITICAL when trying to remove an already removed source on next function call.
This commit fixes this issue, by keeping an approach localized to the timeout function, and based on the source status.
Steps to trigger the GLib-CRITICAL:
- open the prefs dialog
- check/uncheck "Position menu at mouse pointer"
- close the prefs dialog
(xfce4-clipman:39749): GLib-CRITICAL **: 01:00:02.069: Source ID 273 was not found when attempting to remove it
Edited by Gaël Bonithon