From 3bcbde67522991c7b9154c36de9f08126bcb5ffe Mon Sep 17 00:00:00 2001 From: Yann Leboulanger Date: Fri, 9 Nov 2007 18:22:23 +0000 Subject: [PATCH] improve AvatarChooserDialog --- src/dialogs.py | 2 ++ src/profile_window.py | 16 ++++++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/dialogs.py b/src/dialogs.py index 4d114ab93..4660eac24 100644 --- a/src/dialogs.py +++ b/src/dialogs.py @@ -2775,6 +2775,8 @@ class ImageChooserDialog(FileChooserDialog): on_response_ok = (on_ok, on_response_ok), on_response_cancel = on_response_cancel) + self.connect('destroy', on_response_cancel) + filter = gtk.FileFilter() filter.set_name(_('All files')) filter.add_pattern('*') diff --git a/src/profile_window.py b/src/profile_window.py index 0bc896f5e..8fa581d49 100644 --- a/src/profile_window.py +++ b/src/profile_window.py @@ -47,6 +47,7 @@ class ProfileWindow: self.account = account self.jid = gajim.get_jid_from_account(account) + self.dialog = None self.avatar_mime_type = None self.avatar_encoded = None self.message_id = self.statusbar.push(self.context_id, @@ -75,6 +76,8 @@ class ProfileWindow: if self.remove_statusbar_timeout_id is not None: gobject.source_remove(self.remove_statusbar_timeout_id) del gajim.interface.instances[self.account]['profile'] + if self.dialog: # Image chooser dialog + self.dialog.destroy() def on_profile_window_key_press_event(self, widget, event): if event.keyval == gtk.keysyms.Escape: @@ -137,6 +140,7 @@ class ProfileWindow: dialogs.ErrorDialog(_('Could not load image')) return self.dialog.destroy() + self.dialog = None button = self.xml.get_widget('PHOTO_button') image = button.get_image() image.set_from_pixbuf(pixbuf) @@ -154,10 +158,18 @@ class ProfileWindow: def on_clear(widget): self.dialog.destroy() + self.dialog = None self.on_clear_button_clicked(widget) - self.dialog = dialogs.AvatarChooserDialog(on_response_ok = on_ok, - on_response_clear = on_clear) + def on_cancel(widget): + self.dialog.destroy() + self.dialog = None + + if self.dialog: + self.dialog.present() + else: + self.dialog = dialogs.AvatarChooserDialog(on_response_ok = on_ok, + on_response_cancel = on_cancel, on_response_clear = on_clear) def on_PHOTO_button_press_event(self, widget, event): '''If right-clicked, show popup'''