Better fix for issue1550

Reuse image of the button instead of creating a new one
This commit is contained in:
Cédric Krier committed 2010-05-02 00:13:24 +02:00
1 parent 392c6bc241
commit 08cf8050e1
1 file changed
+1 -3
@@ -285,17 +285,15 @@ class Many2One(WidgetInterface):
self.wid_text.set_text('')
self.changed = True
return False
img = self.but_open.get_image()
current_stock = img.get_stock()[0]
res = field.get_client(record)
self.wid_text.set_text((res and str(res)) or '')
img = gtk.Image()
if res and current_stock != 'tryton-open':
img.set_from_stock('tryton-open', gtk.ICON_SIZE_SMALL_TOOLBAR)
self.but_open.set_image(img)
self.tooltips.set_tip(self.but_open, _('Open a record'))
elif not res and current_stock != 'tryton-find':
img.set_from_stock('tryton-find', gtk.ICON_SIZE_SMALL_TOOLBAR)
self.but_open.set_image(img)
self.tooltips.set_tip(self.but_open, _('Search a record'))
self.changed = True