Ticket #2264: 0001-Added-Forget-option-to-network-menu.patch

File 0001-Added-Forget-option-to-network-menu.patch, 3.3 KB (added by tch, 8 years ago)
  • src/jarabe/desktop/networkviews.py

    From cefd1a5a85afcdb759e2251b8147ccd17fa52add Mon Sep 17 00:00:00 2001
    From: Ezequiel Pereira Lopez <eze2307@gmail.com>
    Date: Mon, 1 Dec 2014 21:10:10 -0200
    Subject: [PATCH] Added 'Forget' option to network menu
    
    ---
     src/jarabe/desktop/networkviews.py | 29 +++++++++++++++++++++++++++++
     1 file changed, 29 insertions(+)
    
    diff --git a/src/jarabe/desktop/networkviews.py b/src/jarabe/desktop/networkviews.py
    index bfb7982..f6eb31a 100644
    a b class WirelessNetworkView(EventPulsingIcon): 
    139139            'activate', self.__disconnect_activate_cb)
    140140        self.menu_box.add(self._disconnect_item)
    141141
     142        self._forget_item = PaletteMenuItem(_('Forget'))
     143        icon = Icon(pixel_size=style.SMALL_ICON_SIZE,
     144                    icon_name='dialog-cancel')
     145        self._forget_item.set_image(icon)
     146        self._forget_item.connect('activate', self.__forget_activate_cb)
     147        self.menu_box.add(self._forget_item)
     148
    142149        p.set_content(self.menu_box)
    143150        self.menu_box.show_all()
    144151
    class WirelessNetworkView(EventPulsingIcon): 
    247254           state == network.NM_DEVICE_STATE_IP_CONFIG:
    248255            if self._disconnect_item:
    249256                self._disconnect_item.show()
     257            self._forget_item.hide()
    250258            self._connect_item.hide()
    251259            self._palette.props.secondary_text = _('Connecting...')
    252260            self.props.pulsing = True
    class WirelessNetworkView(EventPulsingIcon): 
    254262            network.set_connected()
    255263            if self._disconnect_item:
    256264                self._disconnect_item.show()
     265            self._forget_item.hide()
    257266            self._connect_item.hide()
    258267            self._palette.props.secondary_text = _('Connected')
    259268            self.props.pulsing = False
    class WirelessNetworkView(EventPulsingIcon): 
    261270            if self._disconnect_item:
    262271                self._disconnect_item.hide()
    263272            self._connect_item.show()
     273            if network.find_connection_by_ssid(self._ssid) is not None:
     274                self._forget_item.show()
     275            else:
     276                self._forget_item.hide()
    264277            self._palette.props.secondary_text = None
    265278            self.props.pulsing = False
    266279
    class WirelessNetworkView(EventPulsingIcon): 
    276289        ap_paths = self._access_points.keys()
    277290        network.disconnect_access_points(ap_paths)
    278291
     292    def __forget_activate_cb(self, item):
     293        connection = network.find_connection_by_ssid(self._ssid)
     294        if connection is not None:
     295            try:
     296                connection.delete()
     297                if self._flags == network.NM_802_11_AP_FLAGS_PRIVACY:
     298                    self.props.badge_name = 'emblem-locked'
     299                    self._palette_icon.props.badge_name = 'emblem-locked'
     300                else:
     301                    self.props.badge_name = None
     302                    self._palette_icon.props.badge_name = None
     303                self._forget_item.hide()
     304            except dbus.DBusException:
     305                logging.debug("Could not remove connection %s",
     306                              connection.get_id())
     307
    279308    def _add_ciphers_from_flags(self, flags, pairwise):
    280309        ciphers = []
    281310        if pairwise: