Ejemplo n.º 1
0
    def keypress(self, size, key):
        """ Handle keypresses. """
        prev_focus = self.get_focus()[1]
        key = ComboBox.keypress(self, size, key)
        if key == ' ':
            if self.get_focus()[1] == len(self.list) - 1:
                dialog = InputDialog(
                    ('header', _('Add a new wired profile')),
                    7, 30
                )
                exitcode, name = dialog.run(ui, self.parent)
                if exitcode == 0:
                    name = name.strip()
                    if not name:
                        error(ui, self.parent, 'Invalid profile name')
                        self.set_focus(prev_focus)
                        return key

                    wired.CreateWiredNetworkProfile(name, False)
                    self.set_list(wired.GetWiredProfileList())
                    self.rebuild_combobox()
                self.set_focus(prev_focus)
            else:
                wired.ReadWiredNetworkProfile(self.get_selected_profile())
        if key == 'delete':
            if len(self.theList) == 1:
                error(
                    self.ui,
                    self.parent,
                    _('wicd-curses does not support deleting the last wired '
                    'profile.  Try renaming it ("F2")')
                )
                return key
            wired.DeleteWiredNetworkProfile(self.get_selected_profile())
            # Return to the top of the list if something is deleted.

            if wired.GetDefaultWiredNetwork() is not None:
                self.set_focus(
                    self.theList.index(wired.GetDefaultWiredNetwork())
                )
            else:
                prev_focus -= 1
                self.set_focus(prev_focus)
            self.set_list(wired.GetWiredProfileList())
            self.rebuild_combobox()
        if key == 'f2':
            dialog = InputDialog(
                ('header', _('Rename wired profile')),
                7, 30,
                edit_text=unicode(self.get_selected_profile())
            )
            exitcode, name = dialog.run(ui, self.parent)
            if exitcode == 0:
                # Save the new one, then kill the old one
                wired.SaveWiredNetworkProfile(name)
                wired.DeleteWiredNetworkProfile(self.get_selected_profile())
                self.set_list(wired.GetWiredProfileList())
                self.set_focus(self.theList.index(name))
                self.rebuild_combobox()
        return key
Ejemplo n.º 2
0
    def keypress(self, size, key):
        """ Handle keypresses. """
        prev_focus = self.get_focus()[1]
        key = ComboBox.keypress(self, size, key)
        if key == ' ':
            if self.get_focus()[1] == len(self.list) - 1:
                dialog = InputDialog(
                    ('header', _('Add a new wired profile')),
                    7, 30
                )
                exitcode, name = dialog.run(ui, self.parent)
                if exitcode == 0:
                    name = name.strip()
                    if not name:
                        error(ui, self.parent, 'Invalid profile name')
                        self.set_focus(prev_focus)
                        return key

                    wired.CreateWiredNetworkProfile(name, False)
                    self.set_list(wired.GetWiredProfileList())
                    self.rebuild_combobox()
                self.set_focus(prev_focus)
            else:
                wired.ReadWiredNetworkProfile(self.get_selected_profile())
        if key == 'delete':
            if len(self.theList) == 1:
                error(
                    self.ui,
                    self.parent,
                    _('wicd-curses does not support deleting the last wired '
                    'profile.  Try renaming it ("F2")')
                )
                return key
            wired.DeleteWiredNetworkProfile(self.get_selected_profile())
            # Return to the top of the list if something is deleted.

            if wired.GetDefaultWiredNetwork() is not None:
                self.set_focus(
                    self.theList.index(wired.GetDefaultWiredNetwork())
                )
            else:
                prev_focus -= 1
                self.set_focus(prev_focus)
            self.set_list(wired.GetWiredProfileList())
            self.rebuild_combobox()
        if key == 'f2':
            dialog = InputDialog(
                ('header', _('Rename wired profile')),
                7, 30,
                edit_text=unicode(self.get_selected_profile())
            )
            exitcode, name = dialog.run(ui, self.parent)
            if exitcode == 0:
                # Save the new one, then kill the old one
                wired.SaveWiredNetworkProfile(name)
                wired.DeleteWiredNetworkProfile(self.get_selected_profile())
                self.set_list(wired.GetWiredProfileList())
                self.set_focus(self.theList.index(name))
                self.rebuild_combobox()
        return key
Ejemplo n.º 3
0
 def raise_hidden_network_dialog(self):
     """ Show hidden network dialog. """
     dialog = InputDialog(("header", _("Select Hidden Network ESSID")), 7, 30, _("Scan"))
     exitcode, hidden = dialog.run(ui, self.frame)
     if exitcode != -1:
         # That dialog will sit there for a while if I don't get rid of it
         self.update_ui()
         wireless.SetHiddenNetworkESSID(misc.noneToString(hidden))
         wireless.Scan(False)
     wireless.SetHiddenNetworkESSID("")
Ejemplo n.º 4
0
 def raise_hidden_network_dialog(self):
     """ Show hidden network dialog. """
     dialog = InputDialog(('header', _('Select Hidden Network ESSID')), 7,
                          30, _('Scan'))
     exitcode, hidden = dialog.run(ui, self.frame)
     if exitcode != -1:
         # That dialog will sit there for a while if I don't get rid of it
         self.update_ui()
         wireless.SetHiddenNetworkESSID(misc.noneToString(hidden))
         wireless.Scan(False)
     wireless.SetHiddenNetworkESSID("")