From 7443ee4c8ba36e1867fc7f89096c34d08c1c69da Mon Sep 17 00:00:00 2001 From: Marco Pesenti Gritti Date: Tue, 26 Sep 2006 22:52:45 +0200 Subject: [PATCH] Don't allow empty nick names and if it happens consider the profile invalid. --- shell/Session.py | 3 ++- shell/view/FirstTimeDialog.py | 14 ++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/shell/Session.py b/shell/Session.py index da17cd71..6cb0f705 100644 --- a/shell/Session.py +++ b/shell/Session.py @@ -26,7 +26,8 @@ class Session: def _check_profile(self): 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.run() profile.save() diff --git a/shell/view/FirstTimeDialog.py b/shell/view/FirstTimeDialog.py index abf6bd80..62b5c8b7 100644 --- a/shell/view/FirstTimeDialog.py +++ b/shell/view/FirstTimeDialog.py @@ -14,13 +14,19 @@ class FirstTimeDialog(gtk.Dialog): label.show() self._entry = gtk.Entry() + self._entry.connect('changed', self._entry_changed_cb) self.vbox.pack_start(self._entry) self._entry.show() - button = gtk.Button(None, gtk.STOCK_OK) - self.vbox.pack_start(button) - button.connect('clicked', self.__ok_button_clicked_cb) - button.show() + self._ok = gtk.Button(None, gtk.STOCK_OK) + self._ok.set_sensitive(False) + self.vbox.pack_start(self._ok) + 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): profile = conf.get_profile()