save avatar from our own vcard
This commit is contained in:
parent
22e2341ba9
commit
5b019e9341
2 changed files with 10 additions and 3 deletions
|
@ -691,10 +691,9 @@ default_name = ''):
|
||||||
# Get pixbuf
|
# Get pixbuf
|
||||||
pixbuf = None
|
pixbuf = None
|
||||||
is_fake = False
|
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
|
is_fake = True
|
||||||
pixbuf = get_avatar_pixbuf_from_cache(jid, is_fake)
|
pixbuf = get_avatar_pixbuf_from_cache(jid, is_fake)
|
||||||
|
|
||||||
ext = file_path.split('.')[-1]
|
ext = file_path.split('.')[-1]
|
||||||
type_ = ''
|
type_ = ''
|
||||||
if not ext:
|
if not ext:
|
||||||
|
@ -710,6 +709,7 @@ default_name = ''):
|
||||||
try:
|
try:
|
||||||
pixbuf.save(file_path, type_)
|
pixbuf.save(file_path, type_)
|
||||||
except:
|
except:
|
||||||
|
#XXX Check for permissions
|
||||||
os.remove(file_path)
|
os.remove(file_path)
|
||||||
new_file_path = '.'.join(file_path.split('.')[:-1]) + '.jpeg'
|
new_file_path = '.'.join(file_path.split('.')[:-1]) + '.jpeg'
|
||||||
dialog2 = dialogs.ConfirmationDialog(_('Extension not supported'),
|
dialog2 = dialogs.ConfirmationDialog(_('Extension not supported'),
|
||||||
|
|
|
@ -216,11 +216,18 @@ class VcardWindow:
|
||||||
def on_PHOTO_eventbox_button_press_event(self, widget, event):
|
def on_PHOTO_eventbox_button_press_event(self, widget, event):
|
||||||
'''If right-clicked, show popup'''
|
'''If right-clicked, show popup'''
|
||||||
if event.button == 3: # right click
|
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()
|
menu = gtk.Menu()
|
||||||
menuitem = gtk.ImageMenuItem(gtk.STOCK_SAVE_AS)
|
menuitem = gtk.ImageMenuItem(gtk.STOCK_SAVE_AS)
|
||||||
menuitem.connect('activate',
|
menuitem.connect('activate',
|
||||||
gtkgui_helpers.on_avatar_save_as_menuitem_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.append(menuitem)
|
||||||
menu.show_all()
|
menu.show_all()
|
||||||
menu.connect('selection-done', lambda w:w.destroy())
|
menu.connect('selection-done', lambda w:w.destroy())
|
||||||
|
|
Loading…
Add table
Reference in a new issue