This file is indexed.

/usr/lib/python2.7/dist-packages/PythonCard/components/list.py is in python-pythoncard 0.8.2-5.

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
"""
__version__ = "$Revision: 1.29 $"
__date__ = "$Date: 2005/12/25 13:44:50 $"
"""

import wx
from PythonCard import event, widget

class ContainerMixin:
    def _getSelection(self):
        return self.GetSelection()

    def _setSelection(self, index):
        self.SetSelection(index)

    def _getStringSelection(self):
        return self.GetStringSelection()

    def _setStringSelection(self, s):
        # an arg of None or empty string will remove the selection
        if s is None or s == '':
            self.SetSelection(-1)
        else:
            self.SetStringSelection(s)

    selection = property(_getSelection, _setSelection)
    stringSelection = property(_getStringSelection, _setStringSelection)


class ListSelectEvent(event.SelectEvent):
    name = 'select'
    binding = wx.EVT_LISTBOX
    id = wx.wxEVT_COMMAND_LISTBOX_SELECTED

# can only have one CommandTypeEvent per component
class ListMouseDoubleClickEvent(event.Event):
    name = 'mouseDoubleClick'
    binding = wx.EVT_LISTBOX_DCLICK
    id = wx.wxEVT_COMMAND_LISTBOX_DOUBLECLICKED

ListEvents = (ListSelectEvent, ListMouseDoubleClickEvent)


class ListSpec(widget.WidgetSpec):
    def __init__(self):
##        events = [event.SelectEvent]
        # KEA 2004-05-03
        # how do we cleanly remove the MouseDoubleClickEvent
        # which the subclass is automatically going to add?
        events = list(ListEvents)
        attributes = { 
            'items' : { 'presence' : 'optional', 'default' : [] },
            'stringSelection' : { 'presence' : 'optional', 'default' : None } 
        }
        widget.WidgetSpec.__init__( self, 'List', 'Widget', events, attributes )
        # KEA 2004-09-04
        # this isn't particularly clean, but it does remove the extra event class
        # and since events unlike attributes don't get any further processing
        # in the spec this should be okay 
        self._events.remove(event.MouseDoubleClickEvent)


class List(widget.Widget, wx.ListBox, ContainerMixin):
    """
    A list that only allows a single item to be selected.
    """
    
    _spec = ListSpec()

    def __init__(self, aParent, aResource):
        wx.ListBox.__init__(
            self,
            aParent, 
            widget.makeNewId(aResource.id), 
            aResource.position, 
            aResource.size, 
            aResource.items,
            style = wx.LB_SINGLE | wx.NO_FULL_REPAINT_ON_RESIZE | wx.CLIP_SIBLINGS,
            name = aResource.name
        )

        widget.Widget.__init__(self, aParent, aResource)

        if aResource.stringSelection:
            self._setStringSelection(aResource.stringSelection)

        self._bindEvents(self._spec._events)

    def _getItems(self):
        items = []
        for i in range(self.GetCount()):
            items.append(self.GetString(i))
        return items

    def _setItems( self, aList ) :
        self.Set(aList)

    def append(self, aString):
        self.Append(aString)

    def appendItems(self, aList):
        self.AppendItems(aList)

    def clear( self ) :
        self.Clear()

    def delete( self, aPosition ) :
        self.Delete( aPosition )

    def findString( self, aString ) :
        return self.FindString( aString )

    def getString( self, aPosition ) :
        return self.GetString( aPosition )

    def insertItems( self, aList, aPosition ) :
        self.InsertItems( aList, aPosition )

    def getCount(self):
        return self.GetCount()

    # KEA was getSelected
    def isSelected(self, aPosition):
        """Determines whether an item is selected.
        aPosition is the zero-based item index
        Returns True if the given item is selected, False otherwise.
        """
        return self.IsSelected(aPosition)

    def setString( self, n, aString ) :
        self.SetString( n, aString )

    items = property(_getItems, _setItems)


import sys
from PythonCard import registry
registry.Registry.getInstance().register(sys.modules[__name__].List)