[bronger] show user defined avatar in tooltip too. fixes #2967
This commit is contained in:
parent
42b1a1fff8
commit
ca7ff635d9
2 changed files with 32 additions and 19 deletions
|
@ -942,3 +942,20 @@ def get_accounts_info():
|
||||||
accounts.append({'name': account, 'status_line': single_line,
|
accounts.append({'name': account, 'status_line': single_line,
|
||||||
'show': status, 'message': message})
|
'show': status, 'message': message})
|
||||||
return accounts
|
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
|
||||||
|
|
|
@ -321,15 +321,13 @@ class GCTooltip(BaseTooltip):
|
||||||
# Add avatar
|
# Add avatar
|
||||||
puny_name = helpers.sanitize_filename(contact.name)
|
puny_name = helpers.sanitize_filename(contact.name)
|
||||||
puny_room = helpers.sanitize_filename(contact.room_jid)
|
puny_room = helpers.sanitize_filename(contact.room_jid)
|
||||||
for type_ in ('jpeg', 'png'):
|
file = helpers.get_avatar_path(os.path.join(gajim.AVATAR_PATH, puny_room,
|
||||||
file = os.path.join(gajim.AVATAR_PATH, puny_room,
|
puny_name))
|
||||||
puny_name + '.' + type_)
|
if file:
|
||||||
if os.path.exists(file):
|
|
||||||
self.avatar_image.set_from_file(file)
|
self.avatar_image.set_from_file(file)
|
||||||
pix = self.avatar_image.get_pixbuf()
|
pix = self.avatar_image.get_pixbuf()
|
||||||
pix = gtkgui_helpers.get_scaled_pixbuf(pix, 'tooltip')
|
pix = gtkgui_helpers.get_scaled_pixbuf(pix, 'tooltip')
|
||||||
self.avatar_image.set_from_pixbuf(pix)
|
self.avatar_image.set_from_pixbuf(pix)
|
||||||
break
|
|
||||||
else:
|
else:
|
||||||
self.avatar_image.set_from_pixbuf(None)
|
self.avatar_image.set_from_pixbuf(None)
|
||||||
while properties:
|
while properties:
|
||||||
|
@ -393,15 +391,13 @@ class RosterTooltip(NotificationAreaTooltip):
|
||||||
puny_jid = helpers.sanitize_filename(prim_contact.jid)
|
puny_jid = helpers.sanitize_filename(prim_contact.jid)
|
||||||
table_size = 3
|
table_size = 3
|
||||||
|
|
||||||
for type_ in ('jpeg', 'png'):
|
file = helpers.get_avatar_path(os.path.join(gajim.AVATAR_PATH, puny_jid))
|
||||||
file = os.path.join(gajim.AVATAR_PATH, puny_jid + '.' + type_)
|
if file:
|
||||||
if os.path.exists(file):
|
|
||||||
self.avatar_image.set_from_file(file)
|
self.avatar_image.set_from_file(file)
|
||||||
pix = self.avatar_image.get_pixbuf()
|
pix = self.avatar_image.get_pixbuf()
|
||||||
pix = gtkgui_helpers.get_scaled_pixbuf(pix, 'tooltip')
|
pix = gtkgui_helpers.get_scaled_pixbuf(pix, 'tooltip')
|
||||||
self.avatar_image.set_from_pixbuf(pix)
|
self.avatar_image.set_from_pixbuf(pix)
|
||||||
table_size = 4
|
table_size = 4
|
||||||
break
|
|
||||||
else:
|
else:
|
||||||
self.avatar_image.set_from_pixbuf(None)
|
self.avatar_image.set_from_pixbuf(None)
|
||||||
vcard_table = gtk.Table(table_size, 1)
|
vcard_table = gtk.Table(table_size, 1)
|
||||||
|
|
Loading…
Add table
Reference in a new issue