Skip to content
Snippets Groups Projects
Commit 8ab275e8 authored by nkour's avatar nkour
Browse files

comments never hurt; fix DeprecationWarning on passing float to scale_simple;...

comments never hurt; fix DeprecationWarning on passing float to scale_simple; do not show bigger avatar if avatar is not bigger
parent 6df1018f
No related branches found
No related tags found
No related merge requests found
......@@ -127,14 +127,33 @@ def on_drag_data_received(self, widget, context, x, y, selection,
contact, path)
def on_avatar_eventbox_enter_notify_event(self, widget, event):
'''we enter the eventbox area'''
# wait for 0.5 sec in case we leave earlier
self.show_bigger_avatar_timeout_id = gobject.timeout_add(500,
self.show_bigger_avatar, widget)
'''we enter the eventbox area so we under conditions add a timeout
to show a bigger avatar after 0.5 sec'''
jid = self.get_active_jid()
avatar_pixbuf = self.plugin.avatar_pixbufs[jid]
avatar_w = avatar_pixbuf.get_width()
avatar_h = avatar_pixbuf.get_height()
print avatar_w, avatar_h
scaled_buf = self.xmls[jid].get_widget('avatar_image').get_pixbuf()
scaled_buf_w = scaled_buf.get_width()
scaled_buf_h = scaled_buf.get_height()
print scaled_buf_w, scaled_buf_h
# do we have something bigger to show?
if avatar_w > scaled_buf_w or avatar_h > scaled_buf_h:
print 'SHOW BIGGER'
# wait for 0.5 sec in case we leave earlier
self.show_bigger_avatar_timeout_id = gobject.timeout_add(500,
self.show_bigger_avatar, widget)
def on_avatar_eventbox_leave_notify_event(self, widget, event):
'''we left the eventbox area'''
gobject.source_remove(self.show_bigger_avatar_timeout_id)
'''we left the eventbox area that holds the avatar img'''
# did we add a timeout? if yes remove it
if self.show_bigger_avatar_timeout_id is not None:
gobject.source_remove(self.show_bigger_avatar_timeout_id)
def show_bigger_avatar(self, widget):
'''resizes the avatar, if needed, so it has at max half the screen size
......@@ -143,8 +162,8 @@ def show_bigger_avatar(self, widget):
avatar_pixbuf = self.plugin.avatar_pixbufs[jid]
screen_w = gtk.gdk.screen_width()
screen_h = gtk.gdk.screen_height()
avatar_w = avatar_pixbuf.get_property('width')
avatar_h = avatar_pixbuf.get_property('height')
avatar_w = avatar_pixbuf.get_width()
avatar_h = avatar_pixbuf.get_height()
half_scr_w = screen_w / 2
half_scr_h = screen_h / 2
if avatar_w > half_scr_w:
......@@ -255,7 +274,9 @@ def show_avatar(self, jid, resource):
scaled_buf = None
else:
pixbuf = self.plugin.avatar_pixbufs[jid]
# compute width / height of the avatar without distorting it
# 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')
......@@ -263,7 +284,7 @@ def show_avatar(self, jid, resource):
else:
h = gajim.config.get('avatar_height')
w = int(h*ratio)
scaled_buf = pixbuf.scale_simple(w, h, gtk.gdk.INTERP_HYPER)
scaled_buf = pixbuf.scale_simple(int(w), int(h), gtk.gdk.INTERP_HYPER)
image = xml.get_widget('avatar_image')
image.set_from_pixbuf(scaled_buf)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment