This file is indexed.

/usr/lib/python2.7/dist-packages/tryton/common/cellrendererbinary.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
#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 gobject
import pango

BUTTON_BORDER = 10
BUTTON_SPACING = 2


class CellRendererBinary(gtk.GenericCellRenderer):
    __gproperties__ = {
        'visible': (gobject.TYPE_BOOLEAN, 'Visible', 'Visible', True,
            gobject.PARAM_READWRITE),
        'editable': (gobject.TYPE_BOOLEAN, 'Editable', 'Editable', False,
            gobject.PARAM_READWRITE),
        'size': (gobject.TYPE_STRING, 'Size', 'Size', '',
            gobject.PARAM_READWRITE),
    }
    __gsignals__ = {
        'new': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,
            (gobject.TYPE_STRING,)),
        'open': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,
            (gobject.TYPE_STRING,)),
        'save': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,
            (gobject.TYPE_STRING,)),
        'clear': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,
            (gobject.TYPE_STRING,)),
    }

    def __init__(self, use_filename):
        self.__gobject_init__()
        self.visible = True
        self.editable = False
        self.set_property('mode', gtk.CELL_RENDERER_MODE_EDITABLE)
        self.use_filename = use_filename
        if use_filename:
            self.buttons = ('new', 'open', 'save', 'clear')
        else:
            self.buttons = ('new', 'save', 'clear')
        self.clicking = ''
        self.images = {}
        widget = gtk.Button()
        for key, stock_name in (
                ('new', 'tryton-find'),
                ('open', 'tryton-open'),
                ('save', 'tryton-save-as'),
                ('clear', 'tryton-clear')):
            # hack to get gtk.gdk.Image from stock icon
            img_sensitive = widget.render_icon(stock_name,
                gtk.ICON_SIZE_SMALL_TOOLBAR)
            img_insensitive = img_sensitive.copy()
            img_sensitive.saturate_and_pixelate(img_insensitive, 0, False)
            width = img_sensitive.get_width()
            height = img_sensitive.get_height()
            self.images[key] = (img_sensitive, img_insensitive, width, height)

    def do_set_property(self, pspec, value):
        setattr(self, pspec.name, value)

    def do_get_property(self, pspec):
        return getattr(self, pspec.name)

    def button_width(self):
        return (sum(width for _, _, width, _ in self.images.itervalues())
            + (2 * (BUTTON_BORDER + BUTTON_SPACING) * len(self.buttons))
            - 2 * BUTTON_SPACING)

    def on_get_size(self, widget, cell_area=None):
        if cell_area is None:
            return (0, 0, 30, 18)
        else:
            return (cell_area.x, cell_area.y,
                cell_area.width, cell_area.height)

    def on_start_editing(self, event, widget, path, background_area,
            cell_area, flags):
        if event is None:
            return
        button_width = self.button_width()

        for index, button_name in enumerate(self.buttons):
            _, _, pxbf_width, _ = self.images[button_name]
            x_offset = (cell_area.width - button_width
                + (pxbf_width + (2 * BUTTON_BORDER) + BUTTON_SPACING) * index)
            x_button = cell_area.x + x_offset
            if x_button < event.x < (x_button + pxbf_width
                    + (2 * BUTTON_BORDER)):
                break
        else:
            button_name = None
        if not self.visible or not button_name:
            return
        if not self.editable and button_name in ('new', 'clear'):
            return
        if not self.size and button_name == 'save':
            return
        if event.type == gtk.gdk.BUTTON_PRESS:
            self.clicking = button_name
            self.emit(button_name, path)

            def timeout(self, widget):
                self.clicking = ''
                widget.queue_draw()
            gobject.timeout_add(60, timeout, self, widget)

    def on_render(self, window, widget, background_area, cell_area,
            expose_area, flags):
        if not self.visible:
            return
        # Handle Pixmap window as pygtk failed
        if type(window) == gtk.gdk.Pixmap:
            return

        button_width = self.button_width()

        # display size
        layout = widget.create_pango_layout(self.size)
        layout.set_font_description(widget.style.font_desc)
        w, h = layout.get_size()
        x = int(cell_area.x + cell_area.width - button_width - w / pango.SCALE
            - BUTTON_SPACING)
        y = int(cell_area.y + (cell_area.height - h / pango.SCALE) / 2)
        layout.set_width(((cell_area.width / 2) - 2) * pango.SCALE)
        state = gtk.STATE_NORMAL
        if flags & gtk.CELL_RENDERER_SELECTED:
            state = gtk.STATE_ACTIVE
        if x >= cell_area.x:
            widget.style.paint_layout(window, state, True, expose_area,
                widget, "cellrendererbinary", x, y, layout)

        # display buttons
        for index, button_name in enumerate(self.buttons):
            state = gtk.STATE_NORMAL
            shadow = gtk.SHADOW_OUT
            pxbf_sens, pxbf_insens, pxbf_width, pxbf_height = \
                self.images[button_name]
            if (self.clicking == button_name
                    and flags & gtk.CELL_RENDERER_SELECTED):
                state = gtk.STATE_ACTIVE
                shadow = gtk.SHADOW_IN
            if (not self.editable and button_name in ('new', 'clear')
                    or not self.size and button_name in ('open', 'save')):
                state = gtk.STATE_INSENSITIVE
                pixbuf = pxbf_insens
            else:
                pixbuf = pxbf_sens
            x_offset = (cell_area.width - button_width
                + (pxbf_width + (2 * BUTTON_BORDER) + BUTTON_SPACING) * index)
            if x_offset < 0:
                continue
            widget.style.paint_box(window, state, shadow,
                None, widget, "button", cell_area.x + x_offset, cell_area.y,
                pxbf_width + (2 * BUTTON_BORDER), cell_area.height)
            window.draw_pixbuf(widget.style.black_gc,
                pixbuf, 0, 0,
                cell_area.x + x_offset + BUTTON_BORDER,
                cell_area.y + (cell_area.height - pxbf_height) / 2)

gobject.type_register(CellRendererBinary)