From 549872473ce7897e4fda4ff0aacca5b278f536d2 Mon Sep 17 00:00:00 2001 From: Yann Leboulanger Date: Wed, 8 Mar 2006 15:56:49 +0000 Subject: [PATCH] cleaner code --- src/gtkgui_helpers.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/gtkgui_helpers.py b/src/gtkgui_helpers.py index 58c89f13a..01038730d 100644 --- a/src/gtkgui_helpers.py +++ b/src/gtkgui_helpers.py @@ -410,18 +410,22 @@ def get_scaled_pixbuf(pixbuf, kind): # resize to a width / height for the avatar not to have distortion # (keep aspect ratio) + width = gajim.config.get(kind + '_avatar_width') + height = gajim.config.get(kind + '_avatar_height') + # Pixbuf size + pix_width = pixbuf.get_width() + pix_height = pixbuf.get_height() # don't make avatars bigger than they are - if pixbuf.get_width() < gajim.config.get(kind + '_avatar_width') and \ - pixbuf.get_height() < gajim.config.get(kind + '_avatar_height'): + if pix_width < width and pix_height < height: return pixbuf # we don't want to make avatar bigger - ratio = float(pixbuf.get_width()) / float(pixbuf.get_height()) + ratio = float(pix_width) / float(pix_height) if ratio > 1: - w = gajim.config.get(kind + '_avatar_width') + w = width h = int(w / ratio) else: - h = gajim.config.get(kind + '_avatar_height') + h = height w = int(h * ratio) scaled_buf = pixbuf.scale_simple(w, h, gtk.gdk.INTERP_HYPER) return scaled_buf