From 0db021d210df1ff68ba0ae1c5d8d8207f90589af Mon Sep 17 00:00:00 2001 From: Julio Biason Date: Sat, 12 Dec 2009 19:52:15 -0200 Subject: [PATCH] Disable auto-refresh on error; show something in case of net operations fail --- mitterlib/ui/ui_pygtk.py | 39 +++++++++++++++++++++++++++++++++------ 1 file changed, 33 insertions(+), 6 deletions(-) diff --git a/mitterlib/ui/ui_pygtk.py b/mitterlib/ui/ui_pygtk.py index 85e3fac..d696a7f 100644 --- a/mitterlib/ui/ui_pygtk.py +++ b/mitterlib/ui/ui_pygtk.py @@ -624,12 +624,6 @@ class Interface(object): 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 def _clear_reply(self): @@ -910,12 +904,30 @@ class Interface(object): store.prepend([message]) store.sort_column_changed() self._grid.queue_draw() + + # once our update went fine, we can queue the next one. This avoids + # any problems if case there is an exception. + + 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 def _exception_get_messages(self, widget, exception): """Function called if the retrival of current messages returns an exception.""" _log.debug(str(exception)) + error_win = gtk.MessageDialog(parent=self._main_window, + type=gtk.MESSAGE_ERROR, + message_format='Error retrieving current messages. ' \ + 'Auto-refresh disabled. Use the "Refresh" option ' \ + 'to re-enable it.', + buttons=gtk.BUTTONS_OK) + error_win.run() + error_win.hide() + self._update_statusbar('Auto-update disabled') return ### image download function @@ -966,6 +978,13 @@ class Interface(object): # TODO: Need the check the type of exception we got. _log.debug('Update error') _log.debug(str(exception)) + error_win = gtk.MessageDialog(parent=self._main_window, + type=gtk.MESSAGE_ERROR, + message_format='Error updating your status. Please ' \ + 'try again.', + buttons=gtk.BUTTONS_OK) + error_win.run() + error_win.hide() return ### Results for the delete message call @@ -995,6 +1014,14 @@ class Interface(object): """Called when the message cannot be reposted.""" _log.debug('Repost error.') _log.debug(str(exception)) + + error_win = gtk.MessageDialog(parent=self._main_window, + type=gtk.MESSAGE_ERROR, + message_format='Error reposting message. Please ' \ + 'try again.', + buttons=gtk.BUTTONS_OK) + error_win.run() + error_win.hide() return # ------------------------------------------------------------