/usr/share/pyshared/tryton/common/button.py is in tryton-client 3.0.2-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | #This file is part of Tryton. The COPYRIGHT file at the top level of
#this repository contains the full copyright notices and license terms.
import gtk
from tryton.common import ICONFACTORY
class Button(gtk.Button):
def __init__(self, attrs=None):
self.attrs = attrs or {}
label = attrs.get('string', '')
if '_' not in label:
label = '_' + label
super(Button, self).__init__(label=label, stock=None,
use_underline=True)
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
ICONFACTORY.register_icon(stock)
icon = gtk.Image()
icon.set_from_stock(stock, gtk.ICON_SIZE_SMALL_TOOLBAR)
self.set_image(icon)
def state_set(self, record):
if record:
states = record.expr_eval(self.attrs.get('states', {}))
else:
states = {}
if states.get('invisible', False):
self.hide()
else:
self.show()
self.set_sensitive(not states.get('readonly', False))
self._set_icon(states.get('icon', self.attrs.get('icon')))
parent = record.parent if record else None
while parent:
if parent.modified:
self.set_sensitive(False)
break
parent = parent.parent
|