set a text in avatar button instead of a fake avatar when no avatar is set in profile window. For #1840
This commit is contained in:
parent
3420ddaffa
commit
050afed553
Binary file not shown.
Before Width: | Height: | Size: 594 B |
|
@ -67,6 +67,9 @@ class ProfileWindow:
|
||||||
self.avatar_mime_type = None
|
self.avatar_mime_type = None
|
||||||
self.avatar_encoded = None
|
self.avatar_encoded = None
|
||||||
|
|
||||||
|
# Create Image for avatar button
|
||||||
|
image = gtk.Image()
|
||||||
|
self.xml.get_widget('PHOTO_button').set_image(image)
|
||||||
self.xml.signal_autoconnect(self)
|
self.xml.signal_autoconnect(self)
|
||||||
self.window.show_all()
|
self.window.show_all()
|
||||||
|
|
||||||
|
@ -79,8 +82,10 @@ class ProfileWindow:
|
||||||
|
|
||||||
def on_clear_button_clicked(self, widget):
|
def on_clear_button_clicked(self, widget):
|
||||||
# empty the image
|
# empty the image
|
||||||
self.xml.get_widget('PHOTO_image').set_from_icon_name('stock_person',
|
button = self.xml.get_widget('PHOTO_button')
|
||||||
gtk.ICON_SIZE_DIALOG)
|
image = button.get_image()
|
||||||
|
image.set_from_pixbuf(None)
|
||||||
|
button.set_label(_('Click to set your avatar'))
|
||||||
self.avatar_encoded = None
|
self.avatar_encoded = None
|
||||||
self.avatar_mime_type = None
|
self.avatar_mime_type = None
|
||||||
|
|
||||||
|
@ -124,8 +129,10 @@ class ProfileWindow:
|
||||||
pixbuf = gtkgui_helpers.get_pixbuf_from_data(data)
|
pixbuf = gtkgui_helpers.get_pixbuf_from_data(data)
|
||||||
# rescale it
|
# rescale it
|
||||||
pixbuf = gtkgui_helpers.get_scaled_pixbuf(pixbuf, 'vcard')
|
pixbuf = gtkgui_helpers.get_scaled_pixbuf(pixbuf, 'vcard')
|
||||||
image = self.xml.get_widget('PHOTO_image')
|
button = self.xml.get_widget('PHOTO_button')
|
||||||
|
image = button.get_image()
|
||||||
image.set_from_pixbuf(pixbuf)
|
image.set_from_pixbuf(pixbuf)
|
||||||
|
button.set_label('')
|
||||||
self.avatar_encoded = base64.encodestring(data)
|
self.avatar_encoded = base64.encodestring(data)
|
||||||
# returns None if unknown type
|
# returns None if unknown type
|
||||||
self.avatar_mime_type = mimetypes.guess_type(path_to_file)[0]
|
self.avatar_mime_type = mimetypes.guess_type(path_to_file)[0]
|
||||||
|
@ -162,18 +169,23 @@ class ProfileWindow:
|
||||||
def set_values(self, vcard):
|
def set_values(self, vcard):
|
||||||
if not 'PHOTO' in vcard:
|
if not 'PHOTO' in vcard:
|
||||||
# set default image
|
# set default image
|
||||||
image = self.xml.get_widget('PHOTO_image')
|
button = self.xml.get_widget('PHOTO_button')
|
||||||
image.set_from_icon_name('stock_person', gtk.ICON_SIZE_DIALOG)
|
image = button.get_image()
|
||||||
|
image.set_from_pixbuf(None)
|
||||||
|
button.set_label(_('Click to set your avatar'))
|
||||||
for i in vcard.keys():
|
for i in vcard.keys():
|
||||||
if i == 'PHOTO':
|
if i == 'PHOTO':
|
||||||
pixbuf, self.avatar_encoded, self.avatar_mime_type = \
|
pixbuf, self.avatar_encoded, self.avatar_mime_type = \
|
||||||
get_avatar_pixbuf_encoded_mime(vcard[i])
|
get_avatar_pixbuf_encoded_mime(vcard[i])
|
||||||
image = self.xml.get_widget('PHOTO_image')
|
button = self.xml.get_widget('PHOTO_button')
|
||||||
|
image = button.get_image()
|
||||||
if not pixbuf:
|
if not pixbuf:
|
||||||
image.set_from_icon_name('stock_person', gtk.ICON_SIZE_DIALOG)
|
image.set_from_pixbuf(None)
|
||||||
|
button.set_label(_('Click to set your avatar'))
|
||||||
continue
|
continue
|
||||||
pixbuf = gtkgui_helpers.get_scaled_pixbuf(pixbuf, 'vcard')
|
pixbuf = gtkgui_helpers.get_scaled_pixbuf(pixbuf, 'vcard')
|
||||||
image.set_from_pixbuf(pixbuf)
|
image.set_from_pixbuf(pixbuf)
|
||||||
|
button.set_label('')
|
||||||
continue
|
continue
|
||||||
if i == 'ADR' or i == 'TEL' or i == 'EMAIL':
|
if i == 'ADR' or i == 'TEL' or i == 'EMAIL':
|
||||||
for entry in vcard[i]:
|
for entry in vcard[i]:
|
||||||
|
@ -275,8 +287,10 @@ class ProfileWindow:
|
||||||
for e in entries:
|
for e in entries:
|
||||||
self.xml.get_widget(e + '_entry').set_text('')
|
self.xml.get_widget(e + '_entry').set_text('')
|
||||||
self.xml.get_widget('DESC_textview').get_buffer().set_text('')
|
self.xml.get_widget('DESC_textview').get_buffer().set_text('')
|
||||||
self.xml.get_widget('PHOTO_image').set_from_icon_name('stock_person',
|
button = self.xml.get_widget('PHOTO_button')
|
||||||
gtk.ICON_SIZE_DIALOG)
|
image = button.get_image()
|
||||||
|
image.set_from_pixbuf(None)
|
||||||
|
button.set_label(_('Click to set your avatar'))
|
||||||
gajim.connections[self.account].request_vcard(self.jid)
|
gajim.connections[self.account].request_vcard(self.jid)
|
||||||
else:
|
else:
|
||||||
dialogs.ErrorDialog(_('You are not connected to the server'),
|
dialogs.ErrorDialog(_('You are not connected to the server'),
|
||||||
|
|
Loading…
Reference in New Issue