[Sugar-devel] [PATCH v2 sugar] Finish port of palettes in network device icon

Manuel Quiñones manuq at laptop.org
Tue Sep 25 14:46:47 EDT 2012


What I did to test without a modem (proper testing encuraged):

--- a/extensions/deviceicon/network.py
+++ b/extensions/deviceicon/network.py
@@ -1052,19 +1052,8 @@ class NetworkManagerObserver(object):
         nm_device = self._bus.get_object(network.NM_SERVICE, device_op)
         props = dbus.Interface(nm_device, dbus.PROPERTIES_IFACE)

-        device_type = props.Get(network.NM_DEVICE_IFACE, 'DeviceType')
-        if device_type == network.NM_DEVICE_TYPE_ETHERNET:
-            device = WiredDeviceObserver(nm_device, self._tray)
-            self._devices[device_op] = device
-        elif device_type == network.NM_DEVICE_TYPE_WIFI:
-            device = WirelessDeviceObserver(nm_device, self._tray)
-            self._devices[device_op] = device
-        elif device_type == network.NM_DEVICE_TYPE_OLPC_MESH:
-            device = MeshDeviceObserver(nm_device, self._tray)
-            self._devices[device_op] = device
-        elif device_type == network.NM_DEVICE_TYPE_MODEM:
-            device = GsmDeviceObserver(nm_device, self._tray)
-            self._devices[device_op] = device
+        device = GsmDeviceObserver(nm_device, self._tray)
+        self._devices[device_op] = device

     def __device_added_cb(self, device_op):
         self._check_device(device_op)


2012/9/25 Manuel Quiñones <manuq at laptop.org>:
> Started in aaa963cf with the port of wireless.  The pending one was
> GsmPalette.  WiredPalette doesn't need to be changed, it doesn't pack
> MenuItems, just sets the content with set_content, is all
> informational.  And device type OLPC mesh uses the same palette as
> wireless, already ported.
>
> - use PaletteMenuItem instead of MenuItem
> - fixed the calls to set_label of the menu item
> - use update_state instead of unexistent set_state
>
> This needs to be properly tested with a modem connection.
>
> Signed-off-by: Manuel Quiñones <manuq at laptop.org>
> ---
>  extensions/deviceicon/network.py | 21 +++++++++++----------
>  1 file changed, 11 insertions(+), 10 deletions(-)
>
> diff --git a/extensions/deviceicon/network.py b/extensions/deviceicon/network.py
> index b4a5393..bc929ee 100644
> --- a/extensions/deviceicon/network.py
> +++ b/extensions/deviceicon/network.py
> @@ -210,13 +210,13 @@ class GsmPalette(Palette):
>          self._current_state = None
>          self._failed_connection = False
>
> -        self._toggle_state_item = MenuItem('')
> +        self.info_box = Gtk.VBox()
> +
> +        self._toggle_state_item = PaletteMenuItem('')
>          self._toggle_state_item.connect('activate', self.__toggle_state_cb)
> -        self.menu.append(self._toggle_state_item)
> +        self.info_box.pack_start(self._toggle_state_item, True, True, 0)
>          self._toggle_state_item.show()
>
> -        self.info_box = Gtk.VBox()
> -
>          self.error_title_label = Gtk.Label(label="")
>          self.error_title_label.set_alignment(0, 0.5)
>          self.error_title_label.set_line_wrap(True)
> @@ -253,7 +253,7 @@ class GsmPalette(Palette):
>          self.info_box.show()
>          self.set_content(self.info_box)
>
> -        self.set_state(_GSM_STATE_NOT_READY)
> +        self.update_state(_GSM_STATE_NOT_READY)
>
>      def _add_widget_with_padding(self, child, xalign=0, yalign=0.5):
>          alignment = Gtk.Alignment.new(xalign=xalign, yalign=yalign,
> @@ -271,13 +271,13 @@ class GsmPalette(Palette):
>
>      def _update_label_and_text(self, reason=0):
>          if self._current_state == _GSM_STATE_NOT_READY:
> -            self._toggle_state_item.get_child().set_label('...')
> +            self._toggle_state_item.set_label('...')
>              label = glib.markup_escape_text(_('Please wait...'))
>              self.props.secondary_text = label
>
>          elif self._current_state == _GSM_STATE_DISCONNECTED:
>              if not self._failed_connection:
> -                self._toggle_state_item.get_child().set_label(_('Connect'))
> +                self._toggle_state_item.set_label(_('Connect'))
>              label = glib.markup_escape_text(_('Disconnected'))
>              self.props.secondary_text = label
>              icon = Icon(icon_name='dialog-ok', \
> @@ -285,7 +285,7 @@ class GsmPalette(Palette):
>              self._toggle_state_item.set_image(icon)
>
>          elif self._current_state == _GSM_STATE_CONNECTING:
> -            self._toggle_state_item.get_child().set_label(_('Cancel'))
> +            self._toggle_state_item.set_label(_('Cancel'))
>              label = glib.markup_escape_text(_('Connecting...'))
>              self.props.secondary_text = label
>              icon = Icon(icon_name='dialog-cancel', \
> @@ -294,7 +294,7 @@ class GsmPalette(Palette):
>
>          elif self._current_state == _GSM_STATE_CONNECTED:
>              self._failed_connection = False
> -            self._toggle_state_item.get_child().set_label(_('Disconnect'))
> +            self._toggle_state_item.set_label(_('Disconnect'))
>              self.update_connection_time()
>              icon = Icon(icon_name='media-eject', \
>                              icon_size=Gtk.IconSize.MENU)
> @@ -325,7 +325,7 @@ class GsmPalette(Palette):
>      def add_alert(self, error, suggestion):
>          self._failed_connection = True
>          action = _('Try connection again')
> -        self._toggle_state_item.get_child().set_label(action)
> +        self._toggle_state_item.set_label(action)
>
>          title = _('Error: %s') % error
>          self.error_title_label.set_markup('<b>%s</b>' % title)
> @@ -730,6 +730,7 @@ class GsmDeviceView(TrayIcon):
>
>      def __init__(self, device):
>          self._connection_time_handler = None
> +
>          self._connection_timestamp = 0
>
>          client = GConf.Client.get_default()
> --
> 1.7.11.4
>



-- 
.. manuq ..


More information about the Sugar-devel mailing list