Adding calendar details
svn: r9619
This commit is contained in:
parent
7216c72509
commit
7a607fe6ff
@ -46,18 +46,45 @@ class CalendarGadget(Gadget):
|
|||||||
import gtk
|
import gtk
|
||||||
self.gui.calendar = gtk.Calendar()
|
self.gui.calendar = gtk.Calendar()
|
||||||
self.gui.calendar.connect('day-selected-double-click', self.double_click)
|
self.gui.calendar.connect('day-selected-double-click', self.double_click)
|
||||||
|
self.gui.calendar.connect('month-changed', self.refresh)
|
||||||
self.gui.scrolledwindow.remove(self.gui.textview)
|
self.gui.scrolledwindow.remove(self.gui.textview)
|
||||||
self.gui.scrolledwindow.add_with_viewport(self.gui.calendar)
|
self.gui.scrolledwindow.add_with_viewport(self.gui.calendar)
|
||||||
self.gui.calendar.show()
|
self.gui.calendar.show()
|
||||||
|
self.birthdays = True
|
||||||
|
self.dates = {}
|
||||||
|
|
||||||
|
def refresh(self, *obj):
|
||||||
|
self.gui.calendar.freeze()
|
||||||
|
self.gui.calendar.clear_marks()
|
||||||
|
year, month, day = self.gui.calendar.get_date()
|
||||||
|
for date in self.dates:
|
||||||
|
if date[1] == month - 1:
|
||||||
|
if date[2] > 0 and date[2] <= day:
|
||||||
|
self.gui.calendar.mark_day(date[2])
|
||||||
|
self.gui.calendar.thaw()
|
||||||
|
|
||||||
def background(self):
|
def background(self):
|
||||||
print "updating"
|
self.dates = {}
|
||||||
yield True
|
|
||||||
self.gui.calendar.clear_marks()
|
|
||||||
self.gui.calendar.freeze()
|
|
||||||
# for each day in events
|
# for each day in events
|
||||||
#self.calendar.mark_day(day)
|
people = self.gui.dbstate.db.get_person_handles(sort_handles=False)
|
||||||
self.gui.calendar.thaw()
|
cnt = 0
|
||||||
|
for person_handle in people:
|
||||||
|
if cnt % 350 == 0:
|
||||||
|
yield True
|
||||||
|
person = self.gui.dbstate.db.get_person_from_handle(person_handle)
|
||||||
|
birth_ref = person.get_birth_ref()
|
||||||
|
birth_date = None
|
||||||
|
if birth_ref:
|
||||||
|
birth_event = self.gui.dbstate.db.get_event_from_handle(birth_ref.ref)
|
||||||
|
birth_date = birth_event.get_date_object()
|
||||||
|
if self.birthdays and birth_date != None:
|
||||||
|
year = birth_date.get_year()
|
||||||
|
month = birth_date.get_month()
|
||||||
|
day = birth_date.get_day()
|
||||||
|
#age = self.year - year
|
||||||
|
self.dates[(year, month, day)] = 1
|
||||||
|
cnt += 1
|
||||||
|
self.refresh()
|
||||||
|
|
||||||
def double_click(self, obj):
|
def double_click(self, obj):
|
||||||
# bring up events on this day
|
# bring up events on this day
|
||||||
|
Loading…
Reference in New Issue
Block a user