diff --git a/mitterlib/ui/ui_pygtk.py b/mitterlib/ui/ui_pygtk.py index e27dff0..bc39399 100644 --- a/mitterlib/ui/ui_pygtk.py +++ b/mitterlib/ui/ui_pygtk.py @@ -700,9 +700,23 @@ class Interface(object): def _refresh(self, widget=None): """Request a refresh. *widget* is the widget that called this function (we basically ignore it.)""" + if self._refresh_id: + # "De-queue" the next refresh + _log.debug('Dequeuing next refresh') + gobject.source_remove(self._refresh_id) + self._refresh_id = None + + # do the refresh self._threads.add_work(self._post_get_messages, self._exception_get_messages, self._connection.messages) + + # queue the next auto-refresh + interval = self._options[self.NAMESPACE]['refresh_interval'] + _log.debug('Queueing next refresh in %d minutes', interval) + self._refresh_id = gobject.timeout_add( + interval * 60 * 1000, + self._refresh, None) return ### Results from the "messages" request @@ -812,6 +826,7 @@ class Interface(object): self._threads = _ThreadManager() # queue the first fetch + self._refresh_id = None # The auto-refresh manager. self._refresh() gtk.main()