How to use the vcard.get_avatar_pixbuf_encoded_mime function in vcard

To help you get started, we’ve selected a few vcard examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sgala / gajim / src / profile_window.py View on Github external
def set_values(self, vcard_):
		button = self.xml.get_widget('PHOTO_button')
		image = button.get_image()
		text_button = self.xml.get_widget('NOPHOTO_button')
		if not 'PHOTO' in vcard_:
			# set default image
			image.set_from_pixbuf(None)
			button.hide()
			text_button.show()
		for i in vcard_.keys():
			if i == 'PHOTO':
				pixbuf, self.avatar_encoded, self.avatar_mime_type = \
					vcard.get_avatar_pixbuf_encoded_mime(vcard_[i])
				if not pixbuf:
					image.set_from_pixbuf(None)
					button.hide()
					text_button.show()
					continue
				pixbuf = gtkgui_helpers.get_scaled_pixbuf(pixbuf, 'vcard')
				image.set_from_pixbuf(pixbuf)
				button.show()
				text_button.hide()
				continue
			if i == 'ADR' or i == 'TEL' or i == 'EMAIL':
				for entry in vcard_[i]:
					add_on = '_HOME'
					if 'WORK' in entry:
						add_on = '_WORK'
					for j in entry.keys():
github sgala / gajim / src / gtkgui_helpers.py View on Github external
if os.path.isfile(local_avatar_path):
				avatar_file = open(local_avatar_path, 'rb')
				avatar_data = avatar_file.read()
				avatar_file.close()
				return get_pixbuf_from_data(avatar_data)

	if not os.path.isfile(path):
		return 'ask'

	vcard_dict = gajim.connections.values()[0].get_cached_vcard(fjid,
		is_fake_jid)
	if not vcard_dict: # This can happen if cached vcard is too old
		return 'ask'
	if not vcard_dict.has_key('PHOTO'):
		return None
	pixbuf = vcard.get_avatar_pixbuf_encoded_mime(vcard_dict['PHOTO'])[0]
	return pixbuf