This file is indexed.

/usr/share/pyshared/pycocumalib/CalendarWindow.py is in pycocuma 0.4.5-6-7.

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
198
199
200
201
202
203
"""
Calendar Toplevel Window
"""
#  Copyright (C) 2004  Henning Jacobs <henning@srcco.de>
#
#  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.
#
#  $Id: CalendarWindow.py 82 2004-07-11 13:01:44Z henning $

import sys
import os
import string
from Tkinter import *
import tkMessageBox
import Pmw
import debug
import broadcaster
import broker
import time

class CalendarWindow:

    from JournalListWidget import JournalListWidget
    from JournalEditWidget import JournalEditWidget
    
    def __init__(self, model, tkroot=None):
        if not tkroot:
            tkroot = Tk()
            tkroot.withdraw()
        self.tkroot = tkroot
        self.model = model
        # Handle to DateStart Mapping:
        self._journaldates = {}
        
        self.createWidgets()
        self.centerWindow()
    
        self.registerAtBroadcaster()
        self.onJournalsOpen()
    
    def registerAtBroadcaster(self):
        "Register our Callback Handlers"
        broadcaster.Register(self.onJournalsOpen,
            source='Journals', title='Opened')
        broadcaster.Register(self.onJournalsClose,
            source='Journals', title='Closed')
        broadcaster.Register(self.onJournalNew,
            source='Journal', title='Added')
        broadcaster.Register(self.onJournalDel,
            source='Journal', title='Deleted')
        broadcaster.Register(self.onJournalSave,
            source='Journal', title='Saved')
        # Broadcasted by JournalWindow:    
        broadcaster.Register(self.onJournalOpen,
            source='Journal', title='Opened')
    
    def createWidgets(self):
        "create the top level window"
        top = self.top = Toplevel(self.tkroot, class_='CalendarWindow')
        top.protocol('WM_DELETE_WINDOW', self.close)
        top.title('Calendar')
        top.iconname('PyCoCuMa')
        try:
            #os.chdir(os.path.dirname(sys.argv[0]))
            if sys.platform == "win32":
                top.iconbitmap("pycocuma.ico")
            else:
                top.iconbitmap("@pycocuma.xbm")
                top.iconmask("@pycocuma_mask.xbm")
        except:
            debug.echo("Could not set TopLevel window icon")
        
        top.withdraw()

        from CalendarWidget import CalendarWidget
        
        self.monthdisp = CalendarWidget(top,
            selectcommand=self._daySelect,
            dblclickcommand=self._dayDblClick)
        self.monthdisp.grid()

    def centerWindow(self, relx=0.5, rely=0.3):
        "Center the Main Window on Screen"
        widget = self.top
        master = self.tkroot
        widget.update_idletasks() # Actualize geometry information
        if master.winfo_ismapped():
            m_width = master.winfo_width()
            m_height = master.winfo_height()
            m_x = master.winfo_rootx()
            m_y = master.winfo_rooty()
        else:
            m_width = master.winfo_screenwidth()
            m_height = master.winfo_screenheight()
            m_x = m_y = 0
        w_width = widget.winfo_reqwidth()
        w_height = widget.winfo_reqheight()
        x = m_x + (m_width - w_width) * relx
        y = m_y + (m_height - w_height) * rely
        if x+w_width > master.winfo_screenwidth():
            x = master.winfo_screenwidth() - w_width
        elif x < 0:
            x = 0
        if y+w_height > master.winfo_screenheight():
            y = master.winfo_screenheight() - w_height
        elif y < 0:
            y = 0
        widget.geometry("+%d+%d" % (x, y))
        widget.deiconify() # Become visible at the desired location

    def _daySelect(self, date, createnew=0):
        # This variable prevents a looping callback:
        self._indayselectcallback = 1
        datadict = {'date':date}
        if createnew: datadict['createnew'] = createnew
        broadcaster.Broadcast('Calendar', 'Date Selected', data=datadict)
        self._indayselectcallback = 0
        
    def _dayDblClick(self, date):
        self.top.event_generate('<<view-journal>>')
        if self.monthdisp.getmarks().has_key(date):
            self._daySelect(date, createnew=0)
        else:
            # Create New Journal Entry for a free day
            self._daySelect(date, createnew=1)
    
    
    def onJournalsOpen(self):
        "Callback, triggered on Broadcast"
        handles = self.model.ListJournalHandles()
        # take only the first 10 chars from dtstart, remainder could be time:
        dates = map(lambda x: x[:10],
            self.model.QueryJournalAttributes(handles, 'DateStart'))
        self._journaldates = dict(zip(handles, dates))
        self.monthdisp.setmarks(dict(zip(dates,[None]*len(dates))))
        
    def onJournalsClose(self):
        "Callback, triggered on Broadcast"
        self.monthdisp.setmarks({})

    _indayselectcallback = 0
    def onJournalOpen(self):
        "Callback, triggered on Broadcast by JournalWindow"
        if not self._indayselectcallback:
            # dtstart may include time, we take only the first 10 characters:
            year, month, day = tuple(map(int,
                broadcaster.CurrentData()['dtstart'][:10].split('-')))
            self.monthdisp.setmonth(year, month)
            self.monthdisp.setday(day)
     
    def onJournalNew(self):
        "Callback, registered at Broadcaster"
        handle = broadcaster.CurrentData()['handle']
        date = broadcaster.CurrentData()['dtstart'][:10]
        self._journaldates[handle] = date
        self.monthdisp.getmarks()[date] = 1
        self.monthdisp.update()
        
    def onJournalDel(self):
        "Callback, registered at Broadcaster"
        handle = broadcaster.CurrentData()['handle']
        date = self._journaldates[handle]
        del self._journaldates[handle]
        del self.monthdisp.getmarks()[date]
        self.monthdisp.update()
        
    def onJournalSave(self):
        "Callback, registered at Broadcaster"
        handle = broadcaster.CurrentData()['handle']
        # Maybe the entry's date changed:
        # we take only the first 10 chars, because dtstart may include time:
        date = self.model.QueryJournalAttributes([handle], 'DateStart')[0][:10]
        # this mapping is for onDel only:
        olddate = self._journaldates[handle]
        if olddate != date:
            self._journaldates[handle] = date
            del self.monthdisp.getmarks()[olddate]
            self.monthdisp.getmarks()[date] = 1
            self.monthdisp.update()
        
    def close(self, event=None):
        self.top.withdraw()
    
    def window(self):
        "Returns Tk's TopLevel Widget"
        return self.top
    
    def withdraw(self):
        "Withdraw: Forward to TopLevel Method"
        self.top.withdraw()
    
    def deiconify(self):
        "DeIconify: Forward to TopLevel Method"
        self.top.deiconify()

    def show(self):
        self.top.deiconify()
        self.top.lift()
        self.top.focus_set()