Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/src/view/devices/network/mesh.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/view/devices/network/mesh.py')
-rw-r--r--src/view/devices/network/mesh.py63
1 files changed, 53 insertions, 10 deletions
diff --git a/src/view/devices/network/mesh.py b/src/view/devices/network/mesh.py
index 1d115e9..40746ce 100644
--- a/src/view/devices/network/mesh.py
+++ b/src/view/devices/network/mesh.py
@@ -20,24 +20,34 @@ from gettext import gettext as _
import gtk
from sugar import profile
-from sugar.graphics.tray import TrayIcon
from sugar.graphics import style
from sugar.graphics.palette import Palette
+from sugar.graphics.toolbutton import ToolButton
+from sugar.graphics.xocolor import XoColor
from model.devices import device
from model.devices.network import wireless
from hardware import hardwaremanager
+from view.devices.network.wireless import IP_ADDRESS_TEXT_TEMPLATE
from view.frame.frameinvoker import FrameWidgetInvoker
+from view.pulsingicon import PulsingIcon
-class DeviceView(TrayIcon):
+class DeviceView(ToolButton):
FRAME_POSITION_RELATIVE = 400
def __init__(self, model):
- TrayIcon.__init__(self, icon_name='network-mesh')
+ ToolButton.__init__(self)
self._model = model
+ self._icon = PulsingIcon()
+ self._icon.props.icon_name = 'network-mesh'
+ pulse_color = XoColor("%s,%s" % (style.COLOR_BUTTON_GREY.get_svg(),
+ style.COLOR_TRANSPARENT.get_svg()))
+ self._icon.props.pulse_color = pulse_color
+ self._icon.props.base_color = pulse_color # only temporarily
+
self.palette = MeshPalette(_("Mesh Network"), model)
self.set_palette(self.palette)
self.palette.props.invoker = FrameWidgetInvoker(self)
@@ -45,24 +55,38 @@ class DeviceView(TrayIcon):
model.connect('notify::state', self._state_changed_cb)
model.connect('notify::activation-stage', self._state_changed_cb)
+ model.connect('notify::ip-address', self._ip_address_changed_cb)
+
self._update_state()
+ self._update_ip_address()
+ self.set_icon_widget(self._icon)
+ self._icon.show()
+
+ def _ip_address_changed_cb(self, model, pspec):
+ self._update_ip_address()
def _state_changed_cb(self, model, pspec):
self._update_state()
+ def _update_ip_address(self):
+ self.palette.set_ip_address(self._model.props.ip_address)
+
def _update_state(self):
# FIXME Change icon colors once we have real icons
state = self._model.props.state
self.palette.update_state(state)
+ self._icon.props.pulsing = state == device.STATE_ACTIVATING
if state == device.STATE_ACTIVATING:
- self.icon.props.fill_color = style.COLOR_INACTIVE_FILL.get_svg()
- self.icon.props.stroke_color = style.COLOR_INACTIVE_STROKE.get_svg()
+ self._icon.props.base_color = \
+ XoColor("%s,%s" % (style.COLOR_INACTIVE_STROKE.get_svg(),
+ style.COLOR_INACTIVE_FILL.get_svg()))
elif state == device.STATE_ACTIVATED:
- self.icon.props.xo_color = profile.get_color()
+ self._icon.props.base_color = profile.get_color()
elif state == device.STATE_INACTIVE:
- self.icon.props.fill_color = style.COLOR_INACTIVE_FILL.get_svg()
- self.icon.props.stroke_color = style.COLOR_INACTIVE_STROKE.get_svg()
+ self._icon.props.base_color = \
+ XoColor("%s,%s" % (style.COLOR_INACTIVE_STROKE.get_svg(),
+ style.COLOR_INACTIVE_FILL.get_svg()))
if state == device.STATE_INACTIVE:
self.palette.set_primary_text(_("Mesh Network"))
@@ -80,9 +104,21 @@ class MeshPalette(Palette):
self._step_label = gtk.Label()
self._step_label.show()
+ self._ip_address_label = gtk.Label()
+ def _padded(child, xalign=0, yalign=0.5):
+ padder = gtk.Alignment(xalign=xalign, yalign=yalign,
+ xscale=1, yscale=0.33)
+ padder.set_padding(style.DEFAULT_SPACING,
+ style.DEFAULT_SPACING,
+ style.DEFAULT_SPACING,
+ style.DEFAULT_SPACING)
+ padder.add(child)
+ return padder
+
vbox = gtk.VBox()
- vbox.pack_start(self._step_label)
- vbox.show()
+ vbox.pack_start(_padded(self._step_label))
+ vbox.pack_start(_padded(self._ip_address_label))
+ vbox.show_all()
self.set_content(vbox)
@@ -104,6 +140,13 @@ class MeshPalette(Palette):
if network_manager and nm_device:
network_manager.set_active_device(nm_device)
+ def set_ip_address(self, ip_address):
+ if ip_address is not None and ip_address != "0.0.0.0":
+ ip_address_text = IP_ADDRESS_TEXT_TEMPLATE % ip_address
+ else:
+ ip_address_text = ""
+ self._ip_address_label.set_text(ip_address_text)
+
def set_mesh_step(self, step, state):
label = ""
if step == 1: