This is my attempt at cleaning up the appearance and behavior of the
palettes attached to APs in the neighborhood view.  I can't see APs in
jhbuild, so I can't test it.  It compiles, but I won't promise it
runs. Also, there are a couple of bits of info that I want to show
that I didn't know how to obtain (I didn't look very hard), as
indicated in the comments.  In other words, this patch is a starting
point, and I'd appreciate it if someone with the know-how and ability
to test it would finish it up! Thanks.

- Eben
diff --git a/src/view/home/MeshBox.py b/src/view/home/MeshBox.py
index 427e08a..0b63964 100644
--- a/src/view/home/MeshBox.py
+++ b/src/view/home/MeshBox.py
@@ -55,6 +55,7 @@ class AccessPointView(CanvasPulsingIcon):
         self._model = model
         self._meshdev = mesh_device
         self._disconnect_item = None
+        self._connect_item = None
         self._greyed_out = False
 
         self.connect('activated', self._activate_cb)
@@ -82,19 +83,26 @@ class AccessPointView(CanvasPulsingIcon):
             self.props.badge_name = "emblem-locked"
 
     def _create_palette(self):
-        p = palette.Palette(self._model.props.name, menu_after_content=True)
-        if not self._meshdev:
-            return p
+        icon_name = get_icon_state(_ICON_NAME, self._model.props.strength)
+        palette_icon = Icon(icon_name=icon_name,
+                            icon_size=style.STANDARD_ICON_SIZE)
+        p = palette.Palette(primary_text=self._model.props.name,
+                            icon=palette_icon)
+
+        self._connect_item = MenuItem(_('Connect'), 'dialog-ok')
+        self._connect_item.connect('activate', self._activate_cb)
+        p.menu.append(self._connect_item)
 
         # Only show disconnect when there's a mesh device, because mesh takes
         # priority over the normal wireless device.  NM doesn't have a "disconnect"
         # method for a device either (for various reasons) so this doesn't
-        # have a good mapping 
-        self._disconnect_item = gtk.MenuItem(_('Disconnect...'))
-        self._disconnect_item.connect('activate', self._disconnect_activate_cb)
-        p.menu.append(self._disconnect_item)
-        if self._model.props.state == accesspointmodel.STATE_CONNECTED:
-            self._disconnect_item.show()
+        # have a good mapping
+        if self._meshdev:
+            self._disconnect_item = MenuItem(_('Disconnect'), 'media-eject')
+            self._disconnect_item.connect('activate',
+                                          self._disconnect_activate_cb)
+            p.menu.append(self._disconnect_item)
+
         return p
 
     def _disconnect_activate_cb(self, menuitem):
@@ -120,25 +128,34 @@ class AccessPointView(CanvasPulsingIcon):
             network_manager.set_active_device(device, network)
 
     def _update_name(self):
-        self._palette.set_primary_text(self._model.props.name)
+        self._palette.props.primary_text = self._model.props.name
 
     def _update_icon(self):
         icon_name = get_icon_state(_ICON_NAME, self._model.props.strength)
         if icon_name:
-            self.props.icon_name = icon_name        
+            self.props.icon_name = icon_name
+            # This breaks style guidelines; we should store a reference
+            self._palette._icon.props.icon_name = icon_name
 
     def _update_state(self):
         if self._model.props.state == accesspointmodel.STATE_CONNECTING:
             if self._disconnect_item:
-                self._disconnect_item.hide()
+                self._disconnect_item.show()
+            self._connect_item.hide()
+            self._palette.props.secondary_text = _('Connecting...')
             self.props.pulsing = True
         elif self._model.props.state == accesspointmodel.STATE_CONNECTED:
             if self._disconnect_item:
                 self._disconnect_item.show()
+            self._connect_item.hide()
+            # I'm not sure how to obtain the channel number
+            self._palette.props.secondary_text = _('Channel %d') % 1
             self.props.pulsing = False
         elif self._model.props.state == accesspointmodel.STATE_NOTCONNECTED:
             if self._disconnect_item:
                 self._disconnect_item.hide()
+            self._connect_item.show()
+            self._palette.props.secondary_text = _('Channel %d') % 1
             self.props.pulsing = False
 
         if self._greyed_out:
_______________________________________________
Sugar mailing list
[email protected]
http://lists.laptop.org/listinfo/sugar

Reply via email to