[bronger] show user defined avatar in tooltip too. fixes #2967

This commit is contained in:
Yann Leboulanger 2007-04-22 18:21:30 +00:00
parent 42b1a1fff8
commit ca7ff635d9
2 changed files with 32 additions and 19 deletions

View File

@ -942,3 +942,20 @@ def get_accounts_info():
accounts.append({'name': account, 'status_line': single_line,
'show': status, 'message': message})
return accounts
def get_avatar_path(prefix):
'''Returns the filename of the avatar, distinguishes between user- and
contact-provided one. Returns None if no avatar was found at all.
prefix is the path to the requested avatar just before the ".png" or
".jpeg".'''
# First, scan for a local, user-set avatar
for type_ in ('jpeg', 'png'):
file_ = prefix + '_local.' + type_
if os.path.exists(file_):
return file_
# If none available, scan for a contact-provided avatar
for type_ in ('jpeg', 'png'):
file_ = prefix + '.' + type_
if os.path.exists(file_):
return file_
return None

View File

@ -321,15 +321,13 @@ class GCTooltip(BaseTooltip):
# Add avatar
puny_name = helpers.sanitize_filename(contact.name)
puny_room = helpers.sanitize_filename(contact.room_jid)
for type_ in ('jpeg', 'png'):
file = os.path.join(gajim.AVATAR_PATH, puny_room,
puny_name + '.' + type_)
if os.path.exists(file):
self.avatar_image.set_from_file(file)
pix = self.avatar_image.get_pixbuf()
pix = gtkgui_helpers.get_scaled_pixbuf(pix, 'tooltip')
self.avatar_image.set_from_pixbuf(pix)
break
file = helpers.get_avatar_path(os.path.join(gajim.AVATAR_PATH, puny_room,
puny_name))
if file:
self.avatar_image.set_from_file(file)
pix = self.avatar_image.get_pixbuf()
pix = gtkgui_helpers.get_scaled_pixbuf(pix, 'tooltip')
self.avatar_image.set_from_pixbuf(pix)
else:
self.avatar_image.set_from_pixbuf(None)
while properties:
@ -392,16 +390,14 @@ class RosterTooltip(NotificationAreaTooltip):
puny_jid = helpers.sanitize_filename(prim_contact.jid)
table_size = 3
for type_ in ('jpeg', 'png'):
file = os.path.join(gajim.AVATAR_PATH, puny_jid + '.' + type_)
if os.path.exists(file):
self.avatar_image.set_from_file(file)
pix = self.avatar_image.get_pixbuf()
pix = gtkgui_helpers.get_scaled_pixbuf(pix, 'tooltip')
self.avatar_image.set_from_pixbuf(pix)
table_size = 4
break
file = helpers.get_avatar_path(os.path.join(gajim.AVATAR_PATH, puny_jid))
if file:
self.avatar_image.set_from_file(file)
pix = self.avatar_image.get_pixbuf()
pix = gtkgui_helpers.get_scaled_pixbuf(pix, 'tooltip')
self.avatar_image.set_from_pixbuf(pix)
table_size = 4
else:
self.avatar_image.set_from_pixbuf(None)
vcard_table = gtk.Table(table_size, 1)