This file is indexed.

/usr/share/pyshared/tryton/gui/window/view_form/view/form_gtk/calendar.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
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
85
86
87
88
89
90
91
92
93
94
95
96
#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
import gettext

from interface import WidgetInterface
from tryton.common.date_widget import DateEntry
from tryton.translate import date_format

_ = gettext.gettext


class Calendar(WidgetInterface):
    "Calendar"

    def __init__(self, field_name, model_name, attrs=None):
        super(Calendar, self).__init__(field_name, model_name, attrs=attrs)

        self.widget = gtk.HBox()
        self.entry = DateEntry('')
        self.entry.set_property('activates_default', True)
        self.entry.connect('key_press_event', self.sig_key_press)
        self.entry.connect('activate', self.sig_activate)
        self.entry.connect('focus-out-event', lambda x, y: self._focus_out())
        self.widget.pack_start(self.entry, expand=False, fill=False)

    def _color_widget(self):
        return self.entry

    def _readonly_set(self, value):
        self.entry.set_editable(not value)
        if value:
            self.widget.set_focus_chain([])
        else:
            self.widget.set_focus_chain([self.entry])

    @property
    def modified(self):
        if self.record and self.field:
            value = self.entry.compute_date(self.entry.get_text())
            return self.field.get_client(self.record) != value
        return False

    def sig_key_press(self, widget, event):
        self.send_modified()

    def grab_focus(self):
        return self.entry.grab_focus()

    def set_value(self, record, field):
        field.set_client(record, self.entry.get_text())
        return True

    def get_value(self):
        return self.entry.date_get(set_text=False)

    def get_format(self, record, field):
        return date_format()

    def display(self, record, field):
        if not field:
            self.entry.set_format('')
            self.entry.clear()
            return False
        self.entry.set_format(self.get_format(record, field))
        super(Calendar, self).display(record, field)
        value = field.get_client(record)
        if not value:
            self.entry.clear()
        else:
            if len(value) > self.entry.get_width_chars():
                self.entry.set_width_chars(len(value))
            self.entry.set_text(value)
        return True


class DateTime(Calendar):
    "DateTime"

    def __init__(self, field_name, model_name, attrs=None):
        super(DateTime, self).__init__(field_name, model_name, attrs=attrs)

    def get_format(self, record, field):
        return date_format() + ' ' + field.time_format(record)


class Time(Calendar):
    "Time"

    def __init__(self, field_name, model_name, attrs=None):
        super(Time, self).__init__(field_name, model_name, attrs=attrs)
        if hasattr(self.entry, 'set_icon_from_stock'):
            self.entry.set_icon_from_stock(gtk.ENTRY_ICON_SECONDARY, None)

    def get_format(self, record, field):
        return field.time_format(record)