Fixup tooltips. Still not working for the home page case, since
the active device logic is pretty broken.
This commit is contained in:
parent
b26ddc64ba
commit
66f26e4b8b
@ -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
|
||||
|
@ -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):
|
||||
|
@ -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
|
||||
|
@ -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:
|
||||
|
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user