misc fixes

This commit is contained in:
Goffi 2010-07-03 12:01:01 +08:00
commit 66a6d7599c

View file

@ -63,35 +63,31 @@ class ProfileManager(urwid.WidgetWrap):
profiles.sort()
self.list_profile.changeValues(profiles)
def __showPopUp(self, pop_up_widget):
display_widget = urwid.Overlay(pop_up_widget, self.main_widget, 'center', ('relative', 40), 'middle', ('relative', 40))
self._set_w(display_widget)
def cancelDialog(self, button):
self._set_w(self.main_widget)
self.host.removePopUp()
def newProfile(self, button, edit):
self._set_w(self.main_widget)
name = edit.get_edit_text()
self.host.bridge.createProfile(name)
self.__refillProfiles()
self.list_profile.selectValue(name)
self.host.removePopUp()
def deleteProfile(self, button):
self._set_w(self.main_widget)
profile_name = self.list_profile.getValue()
if profile_name:
self.host.bridge.deleteProfile(profile_name)
self.__refillProfiles()
self.host.removePopUp()
def onNewProfile(self, e):
pop_up_widget = InputDialog(_("New profile"), _("Please enter a new profile name"), cancel_cb=self.cancelDialog, ok_cb=self.newProfile)
self.__showPopUp(pop_up_widget)
self.host.showPopUp(pop_up_widget)
def onDeleteProfile(self, e):
pop_up_widget = ConfirmDialog(_("Are you sure you want to delete the profile %s ?") % self.list_profile.getValue(), no_cb=self.cancelDialog, yes_cb=self.deleteProfile)
self.__showPopUp(pop_up_widget)
self.host.showPopUp(pop_up_widget)
def onProfileChange(self, list_wid):
profile_name = list_wid.getValue()
@ -105,10 +101,10 @@ class ProfileManager(urwid.WidgetWrap):
profile_name = self.list_profile.getValue()
if not profile_name:
pop_up_widget = Alert(_('No profile selected'), _('You need to create and select a profile before connecting'), ok_cb=self.cancelDialog)
self.__showPopUp(pop_up_widget)
self.host.showPopUp(pop_up_widget)
elif profile_name[0] == '@':
pop_up_widget = Alert(_('Bad profile name'), _("A profile name can't start with a @"), ok_cb=self.cancelDialog)
self.__showPopUp(pop_up_widget)
self.host.showPopUp(pop_up_widget)
else:
profile = self.host.bridge.getProfileName(profile_name)
assert(profile)