diff options
-rw-r--r-- | extensions/deviceicon/network.py | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/extensions/deviceicon/network.py b/extensions/deviceicon/network.py index 234b06b..c70db70 100644 --- a/extensions/deviceicon/network.py +++ b/extensions/deviceicon/network.py @@ -364,11 +364,10 @@ class GsmPalette(Palette): self.error_description_label.set_text(message) self.error_description_label.show() - def update_connection_time(self, connection_time=None): - if connection_time is not None: - formatted_time = connection_time.strftime('%H:%M:%S') - else: - formatted_time = '00:00:00' + def update_connection_time(self, connection_time=0): + """Set the time we have been connected for, in seconds""" + formatted_time = time.strftime('%H:%M:%S', + time.gmtime(connection_time)) text = _('Connected for %s') % (formatted_time, ) self.props.secondary_text = glib.markup_escape_text(text) @@ -888,8 +887,8 @@ class GsmDeviceView(TrayIcon): connection = network.find_gsm_connection() if connection is not None: connection.set_connected() - self._connection_timestamp = time.time() - \ - connection.get_settings().connection.timestamp + settings = connection.get_settings() + self._connection_timestamp = settings.connection.timestamp self._connection_time_handler = gobject.timeout_add_seconds( \ 1, self.__connection_timecount_cb) self._palette.update_connection_time() @@ -932,9 +931,7 @@ class GsmDeviceView(TrayIcon): self._palette.update_stats(in_bytes, out_bytes) def __connection_timecount_cb(self): - self._connection_timestamp = self._connection_timestamp + 1 - connection_time = \ - datetime.datetime.fromtimestamp(self._connection_timestamp) + connection_time = time.time() - self._connection_timestamp self._palette.update_connection_time(connection_time) return True |