Don't set image on button if it is still the same

It fixes also a strange behavior of GTK that doesn't display any images if the
icon is changed before it is realized.

issue3191
review1451002
(transplanted from 4bc44691dc89dfd7802c9d84bbb466f98038bb75)
This commit is contained in:
Cédric Krier committed 2013-11-03 20:42:34 +01:00
1 parent 89c98fd899
commit 45f4acf858
1 file changed
+5
+5
View File
@@ -17,6 +17,11 @@ class Button(gtk.Button):
self._set_icon(attrs.get('icon'))
def _set_icon(self, stock):
image = self.get_image()
if not image and not stock:
return
elif image and image.get_stock()[0] == stock:
return
if not stock:
self.set_image(gtk.Image())
return