Working on calendar signals

svn: r9623
This commit is contained in:
Doug Blank 2007-12-29 12:36:28 +00:00
parent 0fb8fad4ee
commit 50440b7839
2 changed files with 17 additions and 2 deletions

View File

@ -250,7 +250,7 @@ class Gadget(object):
text = text.replace(chr(10), "\\n") text = text.replace(chr(10), "\\n")
self.gui.data.append(text) self.gui.data.append(text)
def update(self, *handles): def update(self, *args):
if self._idle_id != 0: if self._idle_id != 0:
if debug: print "%s interrupt!" % self.gui.title if debug: print "%s interrupt!" % self.gui.title
self.interrupt() self.interrupt()

View File

@ -30,7 +30,7 @@ import string
# ) # )
# There are a number of arguments that you can provide, including: # There are a number of arguments that you can provide, including:
# name, height, content, title, expand, state # name, height, content, title, expand, state, data
# Here is a Gadget object. It has a number of method possibilities: # Here is a Gadget object. It has a number of method possibilities:
# init- run once, on construction # init- run once, on construction
@ -46,12 +46,27 @@ class CalendarGadget(Gadget):
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.calendar.connect('month-changed', self.refresh)
db_signals = ['event-add',
'event-update',
'event-delete',
'event-rebuild',
]
for signal in db_signals:
self.dbstate.db.connect(signal, lambda *args: self.run_update(signal, *args))
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.birthdays = True
self.dates = {} self.dates = {}
def db_changed(self):
self.update()
def run_update(self, signal, *args):
print "signal:", signal
self.update()
def refresh(self, *obj): def refresh(self, *obj):
self.gui.calendar.freeze() self.gui.calendar.freeze()
self.gui.calendar.clear_marks() self.gui.calendar.clear_marks()