Don't allow empty nick names and if it happens consider

the profile invalid.
This commit is contained in:
Marco Pesenti Gritti 2006-09-26 22:52:45 +02:00
parent 72d43fde28
commit 7443ee4c8b
2 changed files with 12 additions and 5 deletions

View File

@ -26,7 +26,8 @@ class Session:
def _check_profile(self): def _check_profile(self):
profile = conf.get_profile() profile = conf.get_profile()
if profile.get_nick_name() == None: name = profile.get_nick_name()
if not name or not len(name):
dialog = FirstTimeDialog() dialog = FirstTimeDialog()
dialog.run() dialog.run()
profile.save() profile.save()

View File

@ -14,13 +14,19 @@ class FirstTimeDialog(gtk.Dialog):
label.show() label.show()
self._entry = gtk.Entry() self._entry = gtk.Entry()
self._entry.connect('changed', self._entry_changed_cb)
self.vbox.pack_start(self._entry) self.vbox.pack_start(self._entry)
self._entry.show() self._entry.show()
button = gtk.Button(None, gtk.STOCK_OK) self._ok = gtk.Button(None, gtk.STOCK_OK)
self.vbox.pack_start(button) self._ok.set_sensitive(False)
button.connect('clicked', self.__ok_button_clicked_cb) self.vbox.pack_start(self._ok)
button.show() self._ok.connect('clicked', self.__ok_button_clicked_cb)
self._ok.show()
def _entry_changed_cb(self, entry):
valid = (len(entry.get_text()) > 0)
self._ok.set_sensitive(valid)
def __ok_button_clicked_cb(self, button): def __ok_button_clicked_cb(self, button):
profile = conf.get_profile() profile = conf.get_profile()