diff --git a/src/common/config.py b/src/common/config.py
index d897f92a0..c14b6921a 100644
--- a/src/common/config.py
+++ b/src/common/config.py
@@ -148,13 +148,16 @@ class Config:
'tabs_always_visible': [opt_bool, False, _('Show tab when only one conversation?')],
'tabs_border': [opt_bool, False, _('Show tab border if one conversation?')],
'tabs_close_button': [opt_bool, True, _('Show close button in tab?')],
- 'avatar_width': [opt_int, 52],
- 'avatar_height': [opt_int, 52],
+ 'chat_avatar_width': [opt_int, 52],
+ 'chat_avatar_height': [opt_int, 52],
+ 'roster_avatar_width': [opt_int, 48],
+ 'roster_avatar_height': [opt_int, 48],
'muc_highlight_words': [opt_str, '', _('A semicolon-separated list of words that will be highlighted in multi-user chat.')],
'quit_on_roster_x_button': [opt_bool, False, _('If True, quits Gajim when X button of Window Manager is clicked. This setting is taken into account only if trayicon is used.')],
'set_xmpp://_handler_everytime': [opt_bool, False, _('If True, Gajim registers for xmpp:// on each startup.')],
'show_unread_tab_icon': [opt_bool, False, _('If True, Gajim will display an icon on each tab containing unread messages. Depending on the theme, this icon may be animated.')],
'show_status_msgs_in_roster': [opt_bool, True, _('If True, Gajim will display the status message, if not empty, for every contact under the contact name in roster window')],
+ 'show_avatars_in_roster': [opt_bool, True],
}
__options_per_key = {
diff --git a/src/config.py b/src/config.py
index c96df7757..c6669ffa7 100644
--- a/src/config.py
+++ b/src/config.py
@@ -112,9 +112,14 @@ class PreferencesWindow:
st = gajim.config.get('sort_by_show')
self.xml.get_widget('sort_by_show_checkbutton').set_active(st)
+ # Display avatars in roster
+ st = gajim.config.get('show_avatars_in_roster')
+ self.xml.get_widget('show_avatars_in_roster_checkbutton').set_active(st)
+
# Display status msg under contact name in roster
st = gajim.config.get('show_status_msgs_in_roster')
self.xml.get_widget('show_status_msgs_in_roster_checkbutton').set_active(st)
+
#Use emoticons
st = gajim.config.get('useemoticons')
@@ -482,6 +487,10 @@ class PreferencesWindow:
self.on_checkbutton_toggled(widget, 'show_status_msgs_in_roster')
gajim.interface.roster.draw_roster()
+ def on_show_avatars_in_roster_checkbutton_toggled(self, widget):
+ self.on_checkbutton_toggled(widget, 'show_avatars_in_roster')
+ gajim.interface.roster.draw_roster()
+
def on_use_emoticons_checkbutton_toggled(self, widget):
self.on_checkbutton_toggled(widget, 'useemoticons',
[self.xml.get_widget('add_remove_emoticons_button')])
diff --git a/src/gtkgui.glade b/src/gtkgui.glade
index c57cbfe8a..f8153cc41 100644
--- a/src/gtkgui.glade
+++ b/src/gtkgui.glade
@@ -3363,6 +3363,27 @@ Agent JID - node
+
+
+ True
+ If checked, Gajim will display an avatar, if one is set, for every contact in roster window
+ True
+ Display avatars of contacts in roster
+ True
+ GTK_RELIEF_NORMAL
+ True
+ False
+ False
+ True
+
+
+
+ 0
+ False
+ False
+
+
+
True
diff --git a/src/gtkgui_helpers.py b/src/gtkgui_helpers.py
index 49ef6134b..11c8e5ded 100644
--- a/src/gtkgui_helpers.py
+++ b/src/gtkgui_helpers.py
@@ -398,3 +398,19 @@ def _get_fade_color(treeview, selected):
return gtk.gdk.Color((bg.red + fg.red)/2,
(bg.green + fg.green)/2,
(bg.blue + fg.blue)/2)
+
+def get_scaled_pixbuf(pixbuf, type):
+ '''returns scaled pixbuf, keeping ratio etc
+ type is either "chat" or "roster"'''
+
+ # resize to a width / height for the avatar not to have distortion
+ # (keep aspect ratio)
+ ratio = float(pixbuf.get_width()) / float(pixbuf.get_height())
+ if ratio > 1:
+ w = gajim.config.get(type + '_avatar_width')
+ h = int(w / ratio)
+ else:
+ h = gajim.config.get(type + '_avatar_height')
+ w = int(h * ratio)
+ scaled_buf = pixbuf.scale_simple(w, h, gtk.gdk.INTERP_HYPER)
+ return scaled_buf
diff --git a/src/roster_window.py b/src/roster_window.py
index 4800a355a..79c9228af 100644
--- a/src/roster_window.py
+++ b/src/roster_window.py
@@ -183,8 +183,17 @@ class RosterWindow:
if g == _('Transports'):
typestr = 'agent'
+ if gajim.config.get('show_avatars_in_roster'):
+ pixbuf = gajim.interface.get_avatar_pixbuf_from_cache(jid)
+ if pixbuf in ('ask', None):
+ scaled_pixbuf = None
+ else:
+ scaled_pixbuf = gtkgui_helpers.get_scaled_pixbuf(pixbuf, 'roster')
+
+ else:
+ scaled_pixbuf = None
model.append(iterG, [self.jabber_state_images[user.show], user.name,
- typestr, user.jid, account, False, None]) # FIXME None --> avatar
+ typestr, user.jid, account, False, scaled_pixbuf])
if gajim.groups[account][g]['expand']:
self.tree.expand_row(model.get_path(iterG), False)
diff --git a/src/tabbed_chat_window.py b/src/tabbed_chat_window.py
index 17eb627dc..996881a3b 100644
--- a/src/tabbed_chat_window.py
+++ b/src/tabbed_chat_window.py
@@ -298,7 +298,7 @@ class TabbedChatWindow(chat.Chat):
return
# we assume contact has no avatar
- scaled_buf = None
+ scaled_pixbuf = None
real_jid = gajim.get_real_jid_from_fjid(self.account, jid)
pixbuf = None
@@ -309,19 +309,11 @@ class TabbedChatWindow(chat.Chat):
gajim.connections[self.account].request_vcard(jid_with_resource)
return
if pixbuf is not None:
- # resize to a width / height for the avatar not to have distortion
- # (keep aspect ratio)
- ratio = float(pixbuf.get_width()) / float(pixbuf.get_height())
- if ratio > 1:
- w = gajim.config.get('avatar_width')
- h = int(w / ratio)
- else:
- h = gajim.config.get('avatar_height')
- w = int(h * ratio)
- scaled_buf = pixbuf.scale_simple(w, h, gtk.gdk.INTERP_HYPER)
+ scaled_pixbuf = gtkgui_helpers.get_scaled_pixbuf(pixbuf, 'chat')
+
image = xml.get_widget('avatar_image')
- image.set_from_pixbuf(scaled_buf)
+ image.set_from_pixbuf(scaled_pixbuf)
image.show_all()
def set_state_image(self, jid):