/usr/share/pyshared/tryton/common/cellrendererinteger.py is in tryton-client 2.2.1-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 | #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 gobject
from cellrenderertext import CellRendererText
import locale
class CellRendererInteger(CellRendererText):
def on_start_editing(self, event, widget, path, background_area,
cell_area, flags):
editable = super(CellRendererInteger, self).on_start_editing(event,
widget, path, background_area, cell_area, flags)
editable.set_alignment(1.0)
editable.connect('insert_text', self.sig_insert_text)
return editable
def sig_insert_text(self, entry, new_text, new_text_length, position):
value = entry.get_text()
position = entry.get_position()
new_value = value[:position] + new_text + value[position:]
if new_value == '-':
return
try:
locale.atoi(new_value)
except ValueError:
entry.stop_emission('insert-text')
gobject.type_register(CellRendererInteger)
|