diff --git a/extensions/deviceicon/network.py b/extensions/deviceicon/network.py
index 04b38fd..3bb3ad6 100644
a
|
b
|
class GsmPalette(Palette): |
222 | 222 | gobject.TYPE_NONE, ([])), |
223 | 223 | } |
224 | 224 | |
225 | | def _add_widget_with_padding(self, child, xalign=0, yalign=0.5): |
226 | | alignment = gtk.Alignment(xalign=xalign, yalign=yalign, |
227 | | xscale=1, yscale=0.33) |
228 | | alignment.set_padding(style.DEFAULT_SPACING, |
229 | | style.DEFAULT_SPACING, |
230 | | style.DEFAULT_SPACING, |
231 | | style.DEFAULT_SPACING) |
232 | | alignment.add(child) |
233 | | return alignment |
234 | | |
235 | 225 | def __init__(self): |
236 | 226 | |
237 | 227 | Palette.__init__(self, label=_('Wireless modem')) |
… |
… |
class GsmPalette(Palette): |
247 | 237 | |
248 | 238 | self.info_box = gtk.VBox() |
249 | 239 | |
250 | | self._data_label = gtk.Label() |
251 | | self._data_label.props.xalign = 0.0 |
252 | | label_alignment = self._add_widget_with_padding(self._data_label) |
| 240 | self.data_label = gtk.Label() |
| 241 | self.data_label.props.xalign = 0.0 |
| 242 | label_alignment = self._add_widget_with_padding(self.data_label) |
253 | 243 | self.info_box.pack_start(label_alignment) |
254 | | self._data_label.show() |
| 244 | self.data_label.show() |
255 | 245 | label_alignment.show() |
256 | 246 | |
257 | | self._conn_time_label = gtk.Label() |
258 | | self._conn_time_label.props.xalign = 0.0 |
259 | | label_alignment = self._add_widget_with_padding(self._conn_time_label) |
| 247 | self.connection_time_label = gtk.Label() |
| 248 | self.connection_time_label.props.xalign = 0.0 |
| 249 | label_alignment = self._add_widget_with_padding( \ |
| 250 | self.connection_time_label) |
260 | 251 | self.info_box.pack_start(label_alignment) |
261 | | self._conn_time_label.show() |
| 252 | self.connection_time_label.show() |
262 | 253 | label_alignment.show() |
263 | 254 | |
264 | 255 | self.info_box.show() |
265 | 256 | self.set_content(self.info_box) |
266 | 257 | |
| 258 | def _add_widget_with_padding(self, child, xalign=0, yalign=0.5): |
| 259 | alignment = gtk.Alignment(xalign=xalign, yalign=yalign, |
| 260 | xscale=1, yscale=0.33) |
| 261 | alignment.set_padding(style.DEFAULT_SPACING, |
| 262 | style.DEFAULT_SPACING, |
| 263 | style.DEFAULT_SPACING, |
| 264 | style.DEFAULT_SPACING) |
| 265 | alignment.add(child) |
| 266 | return alignment |
| 267 | |
267 | 268 | def set_state(self, state): |
268 | 269 | self._current_state = state |
269 | 270 | self._update_label_and_text() |
… |
… |
class WirelessDeviceView(ToolButton): |
532 | 533 | # truncate the nick and use a regex to drop any partial characters |
533 | 534 | # at the end |
534 | 535 | nick = nick.encode('utf-8')[:name_limit] |
535 | | nick = re.sub("([\xf6-\xf7][\x80-\xbf]{0,2}|[\xe0-\xef][\x80-\xbf]{0,1}|[\xc0-\xdf])$", '', nick) |
| 536 | pattern = "([\xf6-\xf7][\x80-\xbf]{0,2}|[\xe0-\xef][\x80-\xbf]{0,1}|[\xc0-\xdf])$" |
| 537 | nick = re.sub(pattern, '', nick) |
536 | 538 | |
537 | 539 | connection_name = format % nick |
538 | 540 | connection_name += color_suffix |
… |
… |
class GsmDeviceView(TrayIcon): |
811 | 813 | connection = network.find_gsm_connection() |
812 | 814 | if connection is not None: |
813 | 815 | connection.set_connected() |
814 | | self._connection_timestamp = time.time() - connection.get_settings().connection.timestamp |
815 | | self._connection_time_handler = gobject.timeout_add(1000, self.__connection_timecount_cb) |
| 816 | self._connection_timestamp = time.time() - \ |
| 817 | connection.get_settings().connection.timestamp |
| 818 | self._connection_time_handler = gobject.timeout_add( \ |
| 819 | 1000, self.__connection_timecount_cb) |
816 | 820 | self._update_stats(0, 0) |
817 | | self._update_connectiontime() |
| 821 | self._update_connection_time() |
818 | 822 | self._palette.info_box.show() |
819 | 823 | |
820 | 824 | if state is network.DEVICE_STATE_DISCONNECTED: |
… |
… |
class GsmDeviceView(TrayIcon): |
842 | 846 | signal_name='StateChanged', |
843 | 847 | path=self._device.object_path, |
844 | 848 | dbus_interface=_NM_DEVICE_IFACE) |
845 | | |
| 849 | |
846 | 850 | def __ppp_stats_changed_cb(self, in_bytes, out_bytes): |
847 | 851 | self._update_stats(in_bytes, out_bytes) |
848 | 852 | |
849 | 853 | def _update_stats(self, in_bytes, out_bytes): |
850 | 854 | in_kbytes = in_bytes / 1024 |
851 | 855 | out_kbytes = out_bytes / 1024 |
852 | | self._palette._data_label.set_text(_("Data sent %d kb / received %d kb") % (out_kbytes ,in_kbytes)) |
| 856 | text = _("Data sent %d kb / received %d kb") % (out_kbytes, in_kbytes) |
| 857 | self._palette.data_label.set_text(text) |
853 | 858 | |
854 | 859 | def __connection_timecount_cb(self): |
855 | 860 | self._connection_timestamp = self._connection_timestamp + 1 |
856 | 861 | self._update_connectiontime() |
857 | | return True |
| 862 | return True |
| 863 | |
| 864 | def _update_connection_time(self): |
| 865 | connection_time = datetime.datetime.fromtimestamp( \ |
| 866 | self._connection_timestamp) |
| 867 | text = _("Connection time ") + connection_time.strftime('%H : %M : %S') |
| 868 | self._palette.connection_time_label.set_text(text) |
858 | 869 | |
859 | | def _update_connectiontime(self): |
860 | | connection_time = datetime.datetime.fromtimestamp(self._connection_timestamp) |
861 | | self._palette._conn_time_label.set_text(_("Connection time ") + connection_time.strftime('%H : %M : %S')) |
862 | | |
863 | 870 | class WirelessDeviceObserver(object): |
864 | 871 | def __init__(self, device, tray, device_type): |
865 | 872 | self._device = device |
diff --git a/src/jarabe/model/network.py b/src/jarabe/model/network.py
index 00db4e7..4c1d536 100644
a
|
b
|
class Ppp(object): |
197 | 197 | pass |
198 | 198 | |
199 | 199 | def get_dict(self): |
200 | | ppp = {} |
201 | | return ppp |
| 200 | ppp = {} |
| 201 | return ppp |
202 | 202 | |
203 | 203 | class Gsm(object): |
204 | 204 | def __init__(self): |
… |
… |
class NMSettingsConnection(dbus.service.Object): |
351 | 351 | |
352 | 352 | def set_connected(self): |
353 | 353 | if self._settings.connection.type == NM_CONNECTION_TYPE_GSM: |
354 | | self._settings.connection.timestamp = int(time.time()) |
| 354 | self._settings.connection.timestamp = int(time.time()) |
355 | 355 | else: |
356 | 356 | if not self._settings.connection.autoconnect: |
357 | 357 | self._settings.connection.autoconnect = True |