This file is indexed.

/usr/share/pyshared/freevo/gui/Scrollbar.py is in python-freevo 1.9.2b2-4.2.

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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
# -*- coding: iso-8859-1 -*-
# -----------------------------------------------------------------------
# Scrollbar.py - A scrollbar to use with any RegionScroller.
# -----------------------------------------------------------------------
# $Id: Scrollbar.py 11905 2011-11-14 21:54:46Z adam $
#
# Notes:
# Todo:
#
# -----------------------------------------------------------------------
# Freevo - A Home Theater PC framework
# Copyright (C) 2003 Krister Lagerstrom, et al.
# Please see the file freevo/Docs/CREDITS for a complete list of authors.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MER-
# CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# -----------------------------------------------------------------------
import logging
logger = logging.getLogger("freevo.gui.Scrollbar")


import config

from GUIObject import *
from Color     import *
from Border    import *


class Scrollbar(GUIObject):
    """
    left      x coordinate. Integer
    top       y coordinate. Integer
    width     Integer
    height    Integer
    bg_color  Background color (Color)
    fg_color  Foreground color (Color)
    """


    def __init__(self, parent, orientation, thickness=10, left=None, top=None,
                 width=None, height=None, bg_color=None, fg_color=None,
                 border=None, bd_color=None, bd_width=1):

        if orientation != "vertical" and orientation != "horizontal":
            raise TypeError, 'orientation'

        GUIObject.__init__(self, left, top, width, height)

        self.orientation = orientation
        self.bg_color    = bg_color
        self.fg_color    = fg_color
        self.thickness   = thickness
        self.border      = border
        self.bd_color    = bd_color
        self.bd_width    = bd_width

        if not self.bg_color:
            if self.skin_info_widget.rectangle.bgcolor:
                self.bg_color = Color(self.skin_info_widget.rectangle.bgcolor)
            else:
                self.bg_color = Color(self.osd.default_bg_color)

        if not self.fg_color:
            if self.skin_info_widget.font.color:
                self.fg_color = Color(self.skin_info_widget.font.color)
            else:
                self.fg_color = Color(self.osd.default_fg_color)

        if not self.bd_color:
            if self.skin_info_widget.rectangle.color:
                self.bd_color = Color(self.skin_info_widget.rectangle.color)
            else:
                self.bd_color = Color(self.osd.default_fg_color)

        if not self.border:
            self.border = Border(self, Border.BORDER_FLAT,
                                 self.bd_color, self.bd_width)


    def set_handle_position(self, pos):
        self.handle_position = pos


    def get_handle_rect(self):
        (a, b, c) = self.parent.get_view_percent(self.orientation)

        _debug_('SB: a,b,c = %s,%s,%s' % (a, b, c), 2)

        if a == 100 or b == 100 or c == 100:
            return self.get_rect()

        if self.orientation == 'vertical':
            fg_width = self.width
            fg_height = b * self.height / 100
            # fg_x = self.left
            fg_x = 0
            # fg_y = self.top + (a * self.height / 100)
            fg_y = (a * self.height / 100)
        else:
            fg_width = b * self.width / 100
            fg_height = self.height
            # fg_x = self.left + (a * self.width / 100)
            fg_x = (a * self.width / 100)
            # fg_y = self.top
            fg_y = 0

        _debug_('SB: handle_rect = %s,%s,%s,%s' % (fg_x, fg_y, fg_width, fg_height), 2)
        return (fg_x, fg_y, fg_width, fg_height)


    def get_handle_size(self):
        (a, b, c, d) = self.get_handle_rect()
        # print 'SB: get_handle_size: c,d="%s,%s"' % (c, d)
        return (c, d)


    def get_handle_coords(self):
        (a, b, c, d) = self.get_handle_rect()
        # print 'SB: get_handle_coords: a,b="%s,%s"' % (a, b)
        return (a, b)


    def calculate_position(self):

        if self.orientation == 'vertical':
            self.width = self.thickness
            self.height = self.parent.height
            if self.parent.show_h_scrollbar:
                self.height = self.height - self.parent.h_scrollbar.thickness
            self.left = self.parent.width - self.width
            # self.top = self.parent.top
            self.top = 0
        else:
            self.width = self.parent.width
            if self.parent.show_v_scrollbar:
                self.width = self.width - self.parent.v_scrollbar.thickness
            self.height = self.thickness
            # self.left = self.parent.left
            self.left = 0
            self.top = self.parent.height - self.height

        if isinstance(self.border, Border):
            # self.border.set_position(self.left, self.top)
            self.border.set_position(0, 0)
            self.border.width = self.width
            self.border.height = self.height

        if config.DEBUG > 1:
            print 'SB: parent_rect = %s,%s,%s,%s' % (self.parent.left, self.parent.top,
                                                     self.parent.width, self.parent.height)
            print 'SB: self_rect = %s,%s,%s,%s' % (self.left, self.top, self.width,
                                                   self.height)


    def _draw(self):
        """
        The actual internal draw function.

        """
        # if not self.width or not self.height:
        #     raise TypeError, 'Not all needed variables set.'

        self.calculate_position()

        bg_c = self.bg_color.get_color_sdl()
        bg_a = self.bg_color.get_alpha()

        self.surface = self.osd.Surface(self.get_size(), 0, 32)
        self.surface.fill(bg_c)
        self.surface.set_alpha(bg_a)

        fg_c = self.fg_color.get_color_sdl()
        _debug_('SB: fg_c = %s,%s,%s,%s' % fg_c, 2)
        fg_a = self.fg_color.get_alpha()

        fg_box = self.osd.Surface(self.get_handle_size(), 0, 32)
        fg_box.fill(fg_c)
        fg_box.set_alpha(fg_a)

        self.surface.blit(fg_box, self.get_handle_coords())
        if self.border:
            self.border.draw()

        _debug_('SB::_draw: pos=%s,%s' % (self.left, self.top), 2)
        self.blit_parent()