From 5b019e9341da408bd3af0e5d09450069171eee32 Mon Sep 17 00:00:00 2001 From: Dimitur Kirov Date: Fri, 9 Jun 2006 14:42:20 +0000 Subject: [PATCH] save avatar from our own vcard --- src/gtkgui_helpers.py | 4 ++-- src/vcard.py | 9 ++++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/gtkgui_helpers.py b/src/gtkgui_helpers.py index 35bbfbb1d..2a331082c 100644 --- a/src/gtkgui_helpers.py +++ b/src/gtkgui_helpers.py @@ -691,10 +691,9 @@ default_name = ''): # Get pixbuf pixbuf = None is_fake = False - if gajim.contacts.is_pm_from_jid(account, jid): + if account and gajim.contacts.is_pm_from_jid(account, jid): is_fake = True pixbuf = get_avatar_pixbuf_from_cache(jid, is_fake) - ext = file_path.split('.')[-1] type_ = '' if not ext: @@ -710,6 +709,7 @@ default_name = ''): try: pixbuf.save(file_path, type_) except: + #XXX Check for permissions os.remove(file_path) new_file_path = '.'.join(file_path.split('.')[:-1]) + '.jpeg' dialog2 = dialogs.ConfirmationDialog(_('Extension not supported'), diff --git a/src/vcard.py b/src/vcard.py index 38a200561..0adf43992 100644 --- a/src/vcard.py +++ b/src/vcard.py @@ -216,11 +216,18 @@ class VcardWindow: def on_PHOTO_eventbox_button_press_event(self, widget, event): '''If right-clicked, show popup''' if event.button == 3: # right click + if self.vcard: + # our own avatar + account = None + nick = gajim.config.get_per('accounts', self.account, 'name') + else: + account = self.account + nick = self.contact.name menu = gtk.Menu() menuitem = gtk.ImageMenuItem(gtk.STOCK_SAVE_AS) menuitem.connect('activate', gtkgui_helpers.on_avatar_save_as_menuitem_activate, - self.contact.jid, self.account, self.contact.name + '.jpeg') + self.jid, account, nick + '.jpeg') menu.append(menuitem) menu.show_all() menu.connect('selection-done', lambda w:w.destroy())