Ticket #1652: 1652.patch

File 1652.patch, 6.4 KB (added by erikos, 14 years ago)

diff with fixed issues

  • extensions/deviceicon/network.py

    diff --git a/extensions/deviceicon/network.py b/extensions/deviceicon/network.py
    index 04b38fd..3bb3ad6 100644
    a b class GsmPalette(Palette): 
    222222                                 gobject.TYPE_NONE, ([])),
    223223    }
    224224
    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 
    235225    def __init__(self):
    236226
    237227        Palette.__init__(self, label=_('Wireless modem'))
    class GsmPalette(Palette): 
    247237
    248238        self.info_box = gtk.VBox()
    249239
    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)
    253243        self.info_box.pack_start(label_alignment)
    254         self._data_label.show()
     244        self.data_label.show()
    255245        label_alignment.show()
    256246
    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)
    260251        self.info_box.pack_start(label_alignment)
    261         self._conn_time_label.show()
     252        self.connection_time_label.show()
    262253        label_alignment.show()
    263254
    264255        self.info_box.show()
    265256        self.set_content(self.info_box)
    266257
     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
    267268    def set_state(self, state):
    268269        self._current_state = state
    269270        self._update_label_and_text()
    class WirelessDeviceView(ToolButton): 
    532533        # truncate the nick and use a regex to drop any partial characters
    533534        # at the end
    534535        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)
    536538
    537539        connection_name = format % nick
    538540        connection_name += color_suffix
    class GsmDeviceView(TrayIcon): 
    811813            connection = network.find_gsm_connection()
    812814            if connection is not None:
    813815                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)
    816820                self._update_stats(0, 0)
    817                 self._update_connectiontime()               
     821                self._update_connection_time()               
    818822                self._palette.info_box.show()
    819823
    820824        if state is network.DEVICE_STATE_DISCONNECTED:
    class GsmDeviceView(TrayIcon): 
    842846                                         signal_name='StateChanged',
    843847                                         path=self._device.object_path,
    844848                                         dbus_interface=_NM_DEVICE_IFACE)
    845        
     849
    846850    def __ppp_stats_changed_cb(self, in_bytes, out_bytes):
    847851        self._update_stats(in_bytes, out_bytes)
    848852
    849853    def _update_stats(self, in_bytes, out_bytes):
    850854        in_kbytes = in_bytes / 1024
    851855        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)
    853858
    854859    def __connection_timecount_cb(self):
    855860        self._connection_timestamp = self._connection_timestamp + 1
    856861        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)
    858869
    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    
    863870class WirelessDeviceObserver(object):
    864871    def __init__(self, device, tray, device_type):
    865872        self._device = device
  • src/jarabe/model/network.py

    diff --git a/src/jarabe/model/network.py b/src/jarabe/model/network.py
    index 00db4e7..4c1d536 100644
    a b class Ppp(object): 
    197197        pass
    198198
    199199    def get_dict(self):
    200       ppp = {}
    201       return ppp
     200        ppp = {}
     201        return ppp
    202202
    203203class Gsm(object):
    204204    def __init__(self):
    class NMSettingsConnection(dbus.service.Object): 
    351351
    352352    def set_connected(self):
    353353        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())
    355355        else:
    356356            if not self._settings.connection.autoconnect:
    357357                self._settings.connection.autoconnect = True