diff options
author | Yann Leboulanger <asterix@lagaule.org> | 2006-03-08 18:56:49 +0300 |
---|---|---|
committer | Yann Leboulanger <asterix@lagaule.org> | 2006-03-08 18:56:49 +0300 |
commit | 549872473ce7897e4fda4ff0aacca5b278f536d2 (patch) | |
tree | c84ebd58225544fcba3bd02573a4b8995562c06c /src/gtkgui_helpers.py | |
parent | e8f33c7c9c10a0c1d0a89080502ecff05e26dc6b (diff) |
cleaner code
Diffstat (limited to 'src/gtkgui_helpers.py')
-rw-r--r-- | src/gtkgui_helpers.py | 14 |
1 files 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 |