This file is indexed.

/usr/lib/python2.7/dist-packages/tryton/gui/window/view_form/view/form_gtk/char.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
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
#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 gettext

import gobject
import gtk
from .widget import Widget, TranslateMixin
from tryton.common import Tooltips
from tryton.common.entry_position import manage_entry_position
from tryton.common.selection import PopdownMixin, selection_shortcuts

_ = gettext.gettext


class Char(Widget, TranslateMixin, PopdownMixin):
    "Char"

    def __init__(self, view, attrs):
        super(Char, self).__init__(view, attrs)

        self.widget = gtk.HBox()
        self.autocomplete = bool(attrs.get('autocomplete'))
        if self.autocomplete:
            self.entry = gtk.ComboBoxEntry()
            selection_shortcuts(self.entry)
            focus_entry = self.entry.get_child()
            self.set_popdown([], self.entry)
            self.entry.connect('changed', self.changed)
        else:
            self.entry = gtk.Entry()
            focus_entry = self.entry

        focus_entry.set_property('activates_default', True)
        focus_entry.connect('activate', self.sig_activate)
        focus_entry.connect('focus-out-event', lambda x, y: self._focus_out())
        focus_entry.connect('key-press-event', self.send_modified)
        manage_entry_position(focus_entry)
        expand, fill = True, True
        if attrs.get('size'):
            expand, fill = False, False
        self.widget.pack_start(self.entry, expand=expand, fill=fill)

        self.button = None
        if attrs.get('translate'):
            self.entry.set_icon_from_stock(gtk.ENTRY_ICON_SECONDARY,
                'tryton-locale')
            self.entry.connect('icon-press', self.translate)

    def translate_widget(self):
        entry = gtk.Entry()
        entry.set_property('activates_default', True)
        if self.record:
            field_size = self.record.expr_eval(self.attrs.get('size'))
            entry.set_width_chars(field_size or -1)
            entry.set_max_length(field_size or 0)
        return entry

    @staticmethod
    def translate_widget_set(widget, value):
        widget.set_text(value or '')

    @staticmethod
    def translate_widget_get(widget):
        return widget.get_text()

    @staticmethod
    def translate_widget_set_readonly(widget, value):
        widget.set_editable(not value)
        widget.props.sensitive = not value

    def changed(self, combobox):
        def focus_out():
            if combobox.props.window:
                self._focus_out()
        # Only when changed from pop list
        if not combobox.get_child().has_focus():
            # Must be deferred because it triggers a display of the form
            gobject.idle_add(focus_out)

    def _color_widget(self):
        if self.autocomplete:
            return self.entry.get_child()
        return self.entry

    @property
    def modified(self):
        if self.record and self.field:
            entry = self.entry.get_child() if self.autocomplete else self.entry
            value = entry.get_text() or ''
            return self.field.get_client(self.record) != value
        return False

    def set_value(self, record, field):
        entry = self.entry.get_child() if self.autocomplete else self.entry
        value = entry.get_text() or ''
        return field.set_client(record, value)

    def get_value(self):
        entry = self.entry.get_child() if self.autocomplete else self.entry
        return entry.get_text()

    def display(self, record, field):
        super(Char, self).display(record, field)
        if self.autocomplete:
            if record:
                selection = record.autocompletion.get(self.field_name, [])
            else:
                selection = []
            self.set_popdown([(x, x) for x in selection], self.entry)

        # Set size
        if self.autocomplete:
            size_entry = self.entry.get_child()
        else:
            size_entry = self.entry
        if record:
            field_size = record.expr_eval(self.attrs.get('size'))
            size_entry.set_width_chars(field_size or -1)
            size_entry.set_max_length(field_size or 0)
        else:
            size_entry.set_width_chars(-1)
            size_entry.set_max_length(0)

        if not field:
            value = ''
        else:
            value = field.get_client(record)

        if not self.autocomplete:
            self.entry.set_text(value)
        else:
            self.entry.handler_block_by_func(self.changed)
            if not self.set_popdown_value(self.entry, value) or not value:
                self.entry.get_child().set_text(value)
            self.entry.handler_unblock_by_func(self.changed)

    def _readonly_set(self, value):
        sensitivity = {True: gtk.SENSITIVITY_OFF, False: gtk.SENSITIVITY_AUTO}
        super(Char, self)._readonly_set(value)
        if self.autocomplete:
            self.entry.get_child().set_editable(not value)
            self.entry.set_button_sensitivity(sensitivity[value])
        else:
            self.entry.set_editable(not value)
        if self.button:
            self.button.set_sensitive(not value)
        if value:
            self.widget.set_focus_chain([])
        else:
            self.widget.set_focus_chain([self.entry])


class Password(Char):

    def __init__(self, view, attrs):
        super(Password, self).__init__(view, attrs)
        self.entry.props.visibility = False

        self.visibility_checkbox = gtk.CheckButton()
        self.visibility_checkbox.connect('toggled', self.toggle_visibility)
        Tooltips().set_tip(self.visibility_checkbox, _('Show plain text'))
        self.widget.pack_start(self.visibility_checkbox, expand=False)

    def _readonly_set(self, value):
        super(Char, self)._readonly_set(value)
        self.entry.set_editable(not value)
        self.visibility_checkbox.props.visible = not value
        if value:
            self.widget.set_focus_chain([])
        else:
            self.widget.set_focus_chain([self.entry, self.visibility_checkbox])

    def toggle_visibility(self, button):
        self.entry.props.visibility = not self.entry.props.visibility