From 1f931c337f75cc8fff3ca2da7b72682ba9f67c95 Mon Sep 17 00:00:00 2001 From: Nikos Kouremenos Date: Mon, 18 Jul 2005 11:03:53 +0000 Subject: [PATCH] [dkirov] changepassword should not traceback on error [I modified it to use exceptions] --- src/config.py | 7 ++++++- src/dialogs.py | 11 ++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/config.py b/src/config.py index 7a11c5307..77f4814d7 100644 --- a/src/config.py +++ b/src/config.py @@ -1263,7 +1263,12 @@ _('To change the account name, it must be disconnected.')).get_response() self.window.destroy() def on_change_password_button_clicked(self, widget): - dialog = dialogs.ChangePasswordDialog(self.plugin, self.account) + try: + dialog = dialogs.ChangePasswordDialog(self.plugin, self.account) + except RuntimeError: + #if we showed ErrorDialog, there will not be 'self.dialog' + return + new_password = dialog.run() if new_password != -1: gajim.connections[self.account].change_password(new_password, \ diff --git a/src/dialogs.py b/src/dialogs.py index 74ab24113..87584710b 100644 --- a/src/dialogs.py +++ b/src/dialogs.py @@ -500,19 +500,23 @@ class RosterTooltip(gtk.Window): hbox.set_border_width(6) self.add(hbox) self.image = gtk.Image() - #self.image.set_alignment(0, 0) + self.image.set_alignment(0.5, 0.05) + hbox.pack_start(self.image, False, False) contents = gtk.VBox() contents.set_spacing(10) hbox.pack_start(contents) + self.account = gtk.Label() self.account.set_line_wrap(True) self.account.set_alignment(0, 0) self.account.set_selectable(False) contents.pack_start(self.account) + self.timeout = 0 self.prefered_position = [0, 0] self.path = None + self.set_events(gtk.gdk.POINTER_MOTION_MASK) self.connect_after('expose_event', self.expose) self.connect('size-request', self.size_request) @@ -822,10 +826,11 @@ class NewMessageDialog: class ChangePasswordDialog: def __init__(self, plugin, account): - if gajim.connections[account].connected < 2: + # 'account' can be None if we are about to create our first one + if not account or gajim.connections[account].connected < 2: ErrorDialog(_('You are not connected to the server'), _('Without a connection, you can not change your password.')).get_response() - return + raise RuntimeError, 'You are not connected to the server' self.plugin = plugin self.account = account self.xml = gtk.glade.XML(GTKGUI_GLADE, 'change_password_dialog', APP)