Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/src/view/devices/network/wireless.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/view/devices/network/wireless.py')
-rw-r--r--src/view/devices/network/wireless.py71
1 files changed, 59 insertions, 12 deletions
diff --git a/src/view/devices/network/wireless.py b/src/view/devices/network/wireless.py
index a339928..f95f5c4 100644
--- a/src/view/devices/network/wireless.py
+++ b/src/view/devices/network/wireless.py
@@ -20,26 +20,40 @@ from gettext import gettext as _
import gtk
from sugar.graphics.icon import get_icon_state
-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.network import wireless
from model.devices import device
from hardware import hardwaremanager
from hardware import nmclient
from view.frame.frameinvoker import FrameWidgetInvoker
+from view.pulsingicon import PulsingIcon
_ICON_NAME = 'network-wireless'
-class DeviceView(TrayIcon):
+IP_ADDRESS_TEXT_TEMPLATE = _("IP address: %s")
+
+class DeviceView(ToolButton):
FRAME_POSITION_RELATIVE = 300
def __init__(self, model):
- TrayIcon.__init__(self, icon_name=_ICON_NAME)
+ ToolButton.__init__(self)
self._model = model
+ self._icon = PulsingIcon()
+ self._icon.props.icon_name = _ICON_NAME
+ 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._inactive_color = XoColor("%s,%s" % (
+ style.COLOR_INACTIVE_STROKE.get_html(),
+ style.COLOR_INACTIVE_FILL.get_html()))
+
meshdev = None
network_manager = hardwaremanager.get_network_manager()
for dev in network_manager.get_devices():
@@ -56,11 +70,16 @@ class DeviceView(TrayIcon):
self.palette.set_frequency(self._model.props.frequency)
model.connect('notify::name', self._name_changed_cb)
+ model.connect('notify::ip-address', self._ip_address_changed_cb)
model.connect('notify::strength', self._strength_changed_cb)
model.connect('notify::state', self._state_changed_cb)
self._update_icon()
self._update_state()
+ self._update_ip_address()
+
+ self.set_icon_widget(self._icon)
+ self._icon.show()
def _get_palette_primary_text(self):
if self._model.props.state == device.STATE_INACTIVE:
@@ -74,8 +93,12 @@ class DeviceView(TrayIcon):
self.palette.set_frequency(self._model.props.frequency)
self._counter += 1
+ def _ip_address_changed_cb(self, model, pspec):
+ self._update_ip_address()
+
def _name_changed_cb(self, model, pspec):
self.palette.set_primary_text(self._get_palette_primary_text())
+ self._update_state()
def _state_changed_cb(self, model, pspec):
self._update_state()
@@ -87,21 +110,24 @@ class DeviceView(TrayIcon):
strength = 0
icon_name = get_icon_state(_ICON_NAME, strength)
if icon_name:
- self.icon.props.icon_name = icon_name
+ self._icon.props.icon_name = icon_name
def _update_state(self):
# FIXME Change icon colors once we have real icons
state = self._model.props.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()
+ fill = style.COLOR_INACTIVE_FILL.get_svg()
+ stroke = style.COLOR_INACTIVE_STROKE.get_svg()
elif state == device.STATE_ACTIVATED:
(stroke, fill) = self._model.get_active_network_colors()
- self.icon.props.stroke_color = stroke
- self.icon.props.fill_color = fill
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()
+ fill = style.COLOR_INACTIVE_FILL.get_svg()
+ stroke = style.COLOR_INACTIVE_STROKE.get_svg()
+ self._icon.props.base_color = XoColor("%s,%s" % (stroke, fill))
+
+ def _update_ip_address(self):
+ self.palette.set_ip_address(self._model.props.ip_address)
class WirelessPalette(Palette):
def __init__(self, primary_text, meshdev):
@@ -109,11 +135,26 @@ class WirelessPalette(Palette):
self._meshdev = meshdev
self._chan_label = gtk.Label()
+ self._chan_label.props.xalign = 0.0
self._chan_label.show()
+ self._ip_address_label = gtk.Label()
+
vbox = gtk.VBox()
- vbox.pack_start(self._chan_label)
- vbox.show()
+
+ 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.pack_start(_padded(self._chan_label))
+ vbox.pack_start(_padded(self._ip_address_label))
+ vbox.show_all()
if meshdev:
disconnect_item = gtk.MenuItem(_('Disconnect...'))
@@ -136,3 +177,9 @@ class WirelessPalette(Palette):
chan = 0
self._chan_label.set_text("%s: %d" % (_("Channel"), chan))
+ 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)