1
0
mirror of https://github.com/gryf/wicd.git synced 2025-12-22 05:48:03 +01:00

Prevent empty or whitespace-only wired profile names in wicd-curses.

Did some code cleanup in curses/curses_misc.py
This commit is contained in:
Andrew Psaltis
2009-08-02 23:53:25 -04:00
parent 08fc68a459
commit 43ce229465
2 changed files with 22 additions and 48 deletions

View File

@@ -383,18 +383,25 @@ class WiredComboBox(ComboBox):
def keypress(self,size,key):
prev_focus = self.get_focus()[1]
key = self.__super.keypress(size,key)
if self.get_focus()[1] == len(self.list)-1:
dialog = InputDialog(('header',language["add_new_wired_profile"]),7,30)
exitcode,name = dialog.run(ui,self.parent)
if exitcode == 0:
wired.CreateWiredNetworkProfile(name,False)
self.set_list(wired.GetWiredProfileList())
self.rebuild_combobox()
self.set_focus(prev_focus)
else:
wired.ReadWiredNetworkProfile(self.get_selected_profile())
key = ComboBox.keypress(self,size,key)
if key == ' ':
if self.get_focus()[1] == len(self.list)-1:
dialog = InputDialog(('header',language["add_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:
print "updating..."
wired.ReadWiredNetworkProfile(self.get_selected_profile())
if key == 'delete':
if len(self.theList) == 1:
error(self.ui,self.parent,language["no_delete_last_profile"])