/usr/lib/python2.7/dist-packages/tryton/gui/window/view_form/view/form_gtk/state_widget.py is in tryton-client 3.4.0-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 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | #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
class StateMixin(object):
def __init__(self, *args, **kwargs):
self.attrs = kwargs.pop('attrs')
super(StateMixin, self).__init__(*args, **kwargs)
def state_set(self, record):
if record:
state_changes = record.expr_eval(self.attrs.get('states', {}))
else:
state_changes = {}
if state_changes.get('invisible', self.attrs.get('invisible')):
self.hide()
else:
self.show()
class Label(StateMixin, gtk.Label):
def state_set(self, record):
super(Label, self).state_set(record)
if not self.attrs.get('string', True) and 'name' in self.attrs:
if record:
field = record.group.fields[self.attrs['name']]
text = field.get_client(record) or ''
else:
text = ''
self.set_text(text)
class VBox(StateMixin, gtk.VBox):
pass
class Image(StateMixin, gtk.Image):
pass
class Frame(StateMixin, gtk.Frame):
def __init__(self, label=None, attrs=None):
if not label: # label must be None to have no label widget
label = None
super(Frame, self).__init__(label=label, attrs=attrs)
if not label:
self.set_shadow_type(gtk.SHADOW_NONE)
self.set_border_width(0)
class ScrolledWindow(StateMixin, gtk.ScrolledWindow):
pass
class Notebook(StateMixin, gtk.Notebook):
def state_set(self, record):
super(Notebook, self).state_set(record)
if record:
state_changes = record.expr_eval(self.attrs.get('states', {}))
else:
state_changes = {}
if state_changes.get('readonly', self.attrs.get('readonly')):
for widgets in self.widgets.itervalues():
for widget in widgets:
widget._readonly_set(True)
widget.color_set('readonly')
class Alignment(gtk.Alignment):
def __init__(self, widget, attrs):
super(Alignment, self).__init__(
float(attrs.get('xalign', 0.0)),
float(attrs.get('yalign', 0.5)),
float(attrs.get('xexpand', 1.0)),
float(attrs.get('yexpand', 1.0)))
self.add(widget)
widget.connect('show', lambda *a: self.show())
widget.connect('hide', lambda *a: self.hide())
|