Subject: [PATCH] Indicate inactive state in mesh device icon

From: Daniel Drake <[email-masked]>
Date: Wed, 7 Jul 2010 10:07:12 -0600

When the mesh is not active, grey out the mesh device icon and update
the palette text.

Also remove the "Create new network" option from the mesh device
palette.
---
 extensions/deviceicon/network.py |   24 ++++++++++++++++++++----
 1 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/extensions/deviceicon/network.py b/extensions/deviceicon/network.py
index ce21605..399ef78 100644
--- a/extensions/deviceicon/network.py
+++ b/extensions/deviceicon/network.py
@@ -597,16 +597,17 @@ class OlpcMeshDeviceView(ToolButton):
         self._channel = 0
 
         self._icon = PulsingIcon(icon_name=self._ICON_NAME)
-        self._icon.props.pulse_color = xocolor.XoColor( \
+        self._inactive_color = xocolor.XoColor( \
             "%s,%s" % (style.COLOR_BUTTON_GREY.get_svg(),
                        style.COLOR_TRANSPARENT.get_svg()))
-        self._icon.props.base_color = profile.get_color()
+        self._icon.props.pulse_color = profile.get_color()
+        self._icon.props.base_color = self._inactive_color
 
         self.set_icon_widget(self._icon)
         self._icon.show()
 
         self.set_palette_invoker(FrameWidgetInvoker(self))
-        self._palette = WirelessPalette(_("Mesh Network"))
+        self._palette = WirelessPalette(_("Mesh Network"), can_create=False)
         self._palette.connect('deactivate-connection',
                               self.__deactivate_connection)
         self.set_palette(self._palette)
@@ -665,7 +666,14 @@ class OlpcMeshDeviceView(ToolButton):
             self._update_text()
 
     def _update_text(self):
-        text = _("Mesh Network") + " " + str(self._channel)
+        state = self._device_state
+        if state in (network.DEVICE_STATE_PREPARE, network.DEVICE_STATE_CONFIG,
+                     network.DEVICE_STATE_NEED_AUTH,
+                     network.DEVICE_STATE_IP_CONFIG,
+                     network.DEVICE_STATE_ACTIVATED):
+            text = _("Mesh Network") + " " + str(self._channel)
+        else:
+            text = _("Mesh Network")
         self._palette.props.primary_text = text
 
     def _update(self):
@@ -675,12 +683,20 @@ class OlpcMeshDeviceView(ToolButton):
                      network.DEVICE_STATE_CONFIG,
                      network.DEVICE_STATE_NEED_AUTH,
                      network.DEVICE_STATE_IP_CONFIG]:
+            self._icon.props.base_color = self._inactive_color
+            self._icon.props.pulse_color = profile.get_color()
             self._palette.set_connecting()
             self._icon.props.pulsing = True
         elif state == network.DEVICE_STATE_ACTIVATED:
             address = self._device_props.Get(_NM_DEVICE_IFACE, 'Ip4Address')
             self._palette.set_connected_with_channel(self._channel, address)
+            self._icon.props.base_color = profile.get_color()
             self._icon.props.pulsing = False
+        else:
+            self._icon.props.base_color = self._inactive_color
+            self._icon.props.pulsing = False
+            self._palette.set_disconnected()
+        self._update_text()
 
     def __deactivate_connection(self, palette, data=None):
         obj = self._bus.get_object(_NM_SERVICE, _NM_PATH)
-- 
1.7.1.1