diff --git a/shell/hardware/nmclient.py b/shell/hardware/nmclient.py index 910b6829..8eaab2f9 100644 --- a/shell/hardware/nmclient.py +++ b/shell/hardware/nmclient.py @@ -75,6 +75,8 @@ class Network(gobject.GObject): 'init-failed' : (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, ([])), 'strength-changed': (gobject.SIGNAL_RUN_FIRST, + gobject.TYPE_NONE, ([])), + 'essid-changed' : (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, ([])) } @@ -109,6 +111,7 @@ class Network(gobject.GObject): self._ssid, self._mode, self._strength)) self.emit('strength-changed') + self.emit('essid-changed') def _update_error_cb(self, err): logging.debug("Net(%s): failed to update. (%s)" % (self._op, err)) @@ -142,6 +145,8 @@ class Device(gobject.GObject): 'strength-changed': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, ([gobject.TYPE_PYOBJECT])), + 'essid-changed': (gobject.SIGNAL_RUN_FIRST, + gobject.TYPE_NONE, ([])), 'network-appeared': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, ([gobject.TYPE_PYOBJECT])), @@ -273,6 +278,7 @@ class Device(gobject.GObject): for (op, net) in self._networks.items(): if net.get_ssid() == ssid: self._active_net = op + self.emit('essid-changed') def get_type(self): return self._type diff --git a/shell/model/MeshModel.py b/shell/model/MeshModel.py index 2e4b912b..30358c72 100644 --- a/shell/model/MeshModel.py +++ b/shell/model/MeshModel.py @@ -24,6 +24,8 @@ from hardware import hardwaremanager class AccessPointModel(gobject.GObject): __gproperties__ = { + 'name' : (str, None, None, None, + gobject.PARAM_READABLE), 'strength' : (int, None, None, 0, 100, 0, gobject.PARAM_READABLE) } @@ -35,16 +37,18 @@ class AccessPointModel(gobject.GObject): self._nm_network.connect('strength-changed', self._strength_changed_cb) + self._nm_network.connect('essid-changed', + self._essid_changed_cb) def _strength_changed_cb(self, nm_network): self.notify('strength') + def _essid_changed_cb(self, nm_network): + self.notify('name') + def get_id(self): return self._nm_network.get_op() - def get_name(self): - return self._nm_network.get_ssid() - def get_nm_device(self): return self._nm_device @@ -54,6 +58,8 @@ class AccessPointModel(gobject.GObject): def do_get_property(self, pspec): if pspec.name == 'strength': return self._nm_network.get_strength() + elif pspec.name == 'name': + return self._nm_network.get_ssid() class ActivityModel: def __init__(self, activity, bundle, service): diff --git a/shell/model/devices/wirelessnetwork.py b/shell/model/devices/wirelessnetwork.py index 6cd7c577..45bc5fe5 100644 --- a/shell/model/devices/wirelessnetwork.py +++ b/shell/model/devices/wirelessnetwork.py @@ -4,6 +4,8 @@ from model.devices import device class Device(device.Device): __gproperties__ = { + 'name' : (str, None, None, None, + gobject.PARAM_READABLE), 'strength' : (int, None, None, 0, 100, 0, gobject.PARAM_READABLE) } @@ -14,23 +16,27 @@ class Device(device.Device): self._nm_device.connect('strength-changed', self._strength_changed_cb) + self._nm_device.connect('essid-changed', + self._essid_changed_cb) def _strength_changed_cb(self, nm_device, strength): self.notify('strength') + def _essid_changed_cb(self, nm_device): + self.notify('name') + def do_get_property(self, pspec): if pspec.name == 'strength': return self._nm_device.get_strength() + elif pspec.name == 'name': + active_net = self._nm_device.get_active_network() + if active_net: + return active_net.get_ssid() + else: + return None def get_type(self): return 'wirelessnetwork' def get_id(self): return self._nm_device.get_op() - - def get_name(self): - active_net = self._nm_device.get_active_network() - if active_net: - return active_net.get_ssid() - else: - return None diff --git a/shell/view/devices/wirelessnetwork.py b/shell/view/devices/wirelessnetwork.py index 19eba5c1..4a9e3780 100644 --- a/shell/view/devices/wirelessnetwork.py +++ b/shell/view/devices/wirelessnetwork.py @@ -5,14 +5,21 @@ class DeviceView(deviceview.DeviceView): deviceview.DeviceView.__init__(self, model) self._model = model + model.connect('notify::name', self._name_changed_cb) model.connect('notify::strength', self._strength_changed_cb) - self.props.tooltip = model.get_name() + self._update_name() self._update_icon() def _strength_changed_cb(self, model, pspec): self._update_icon() + def _name_changed_cb(self, model, pspec): + self._update_name() + + def _update_name(self): + self.props.tooltip = self._model.props.name + def _update_icon(self): strength = self._model.props.strength if strength < 21: diff --git a/shell/view/home/MeshBox.py b/shell/view/home/MeshBox.py index 6dcfb0c1..7b5e5da4 100644 --- a/shell/view/home/MeshBox.py +++ b/shell/view/home/MeshBox.py @@ -27,18 +27,23 @@ from view.BuddyIcon import BuddyIcon class AccessPointView(CanvasIcon): def __init__(self, model): - CanvasIcon.__init__(self, tooltip=model.get_name()) + CanvasIcon.__init__(self) self._model = model self.connect('activated', self._activate_cb) model.connect('notify::strength', self._strength_changed_cb) + model.connect('notify::name', self._name_changed_cb) self._update_icon() + self._update_name() def _strength_changed_cb(self, model, pspec): self._update_icon() + def _name_changed_cb(self, model, pspec): + self._update_name() + def _activate_cb(self, icon): network_manager = hardwaremanager.get_network_manager() @@ -47,6 +52,9 @@ class AccessPointView(CanvasIcon): network_manager.set_active_device(device, network) + def _update_name(self): + self.props.tooltip = self._model.props.name + def _update_icon(self): strength = self._model.props.strength if strength < 21: