class YearMonthDayBox(gtk.HBox): def __init__(self): gtk.HBox.__init__(self, spacing=4) self.mode = calTypes.primary #### pack(self, gtk.Label(_('Year'))) self.spinY = YearSpinButton() pack(self, self.spinY) #### pack(self, gtk.Label(_('Month'))) comboMonth = gtk.ComboBoxText() module = calTypes[self.mode] for i in range(12): comboMonth.append_text(_(module.getMonthName(i+1, None)))## year=None means all months comboMonth.set_active(0) pack(self, comboMonth) self.comboMonth = comboMonth #### pack(self, gtk.Label(_('Day'))) self.spinD = DaySpinButton() pack(self, self.spinD) self.comboMonthConn = comboMonth.connect('changed', self.comboMonthChanged) self.spinY.connect('changed', self.comboMonthChanged) def set_mode(self, mode): self.comboMonth.disconnect(self.comboMonthConn) self.mode = mode module = calTypes[mode] combo = self.comboMonth combo.remove_all() for i in range(12): combo.append_text(_(module.getMonthName(i+1))) self.spinD.set_range(1, module.maxMonthLen) self.comboMonthConn = self.comboMonth.connect('changed', self.comboMonthChanged) def changeMode(self, mode, newMode):## FIXME naming standard? self.set_mode(newMode) def set_value(self, date): y, m, d = date self.spinY.set_value(y) self.comboMonth.set_active(m-1) self.spinD.set_value(d) get_value = lambda self: ( self.spinY.get_value(), self.comboMonth.get_active() + 1, self.spinD.get_value(), ) def comboMonthChanged(self, widget=None): monthIndex = self.comboMonth.get_active() if monthIndex == -1: return self.spinD.set_range(1, getMonthLen( self.spinY.get_value(), monthIndex + 1, self.mode, ))
class WidgetClass(common.WidgetClass): def __init__(self, event):## FIXME event.setJd(ui.cell.jd) common.WidgetClass.__init__(self, event) ###### sizeGroup = gtk.SizeGroup(gtk.SizeGroupMode.HORIZONTAL) ###### hbox = gtk.HBox() label = gtk.Label(_('Start')) label.set_alignment(0, 0.5) sizeGroup.add_widget(label) pack(hbox, label) self.startDateInput = DateButton() pack(hbox, self.startDateInput) ### pack(hbox, gtk.Label(''), 1, 1) pack(self, hbox) ###### hbox = gtk.HBox() label = gtk.Label(_('End')) label.set_alignment(0, 0.5) sizeGroup.add_widget(label) pack(hbox, label) self.endDateInput = DateButton() pack(hbox, self.endDateInput) ### pack(hbox, gtk.Label(''), 1, 1) pack(self, hbox) ###### hbox = gtk.HBox() label = gtk.Label(_('Day of Month')) label.set_alignment(0, 0.5) sizeGroup.add_widget(label) pack(hbox, label) self.daySpin = DaySpinButton() pack(hbox, self.daySpin) ### pack(hbox, gtk.Label(''), 1, 1) pack(self, hbox) ######### hbox = gtk.HBox() label = gtk.Label(_('Time')) label.set_alignment(0, 0.5) sizeGroup.add_widget(label) pack(hbox, label) ## self.dayTimeStartInput = HourMinuteButton() self.dayTimeEndInput = HourMinuteButton() ## pack(hbox, self.dayTimeStartInput) pack(hbox, gtk.Label(' ' + _('to') + ' ')) pack(hbox, self.dayTimeEndInput) pack(self, hbox) ############# #self.notificationBox = common.NotificationBox(event) #pack(self, self.notificationBox) ############# #self.filesBox = common.FilesBox(self.event) #pack(self, self.filesBox) def updateWidget(self):## FIXME common.WidgetClass.updateWidget(self) mode = self.event.mode ### self.startDateInput.set_value(jd_to(self.event.getStartJd(), mode)) self.endDateInput.set_value(jd_to(self.event.getEndJd(), mode)) ### self.daySpin.set_value(self.event.getDay()) ### timeRangeRule = self.event['dayTimeRange'] self.dayTimeStartInput.set_value(timeRangeRule.dayTimeStart) self.dayTimeEndInput.set_value(timeRangeRule.dayTimeEnd) def updateVars(self):## FIXME common.WidgetClass.updateVars(self) self.event['start'].setDate(self.startDateInput.get_value()) self.event['end'].setDate(self.endDateInput.get_value()) self.event.setDay(self.daySpin.get_value()) ### self.event['dayTimeRange'].setRange( self.dayTimeStartInput.get_value(), self.dayTimeEndInput.get_value(), ) def modeComboChanged(self, obj=None):## overwrite method from common.WidgetClass newMode = self.modeCombo.get_active() self.startDateInput.changeMode(self.event.mode, newMode) self.endDateInput.changeMode(self.event.mode, newMode) self.event.mode = newMode
class WidgetClass(common.WidgetClass): def __init__(self, event):## FIXME common.WidgetClass.__init__(self, event) ################ hbox = gtk.HBox() pack(hbox, gtk.Label(_('Month'))) self.monthCombo = MonthComboBox() self.monthCombo.build(event.mode) pack(hbox, self.monthCombo) pack(hbox, gtk.Label(''), 1, 1) #pack(self, hbox) ### #hbox = gtk.HBox() pack(hbox, gtk.Label(_('Day'))) self.daySpin = DaySpinButton() pack(hbox, self.daySpin) pack(hbox, gtk.Label(''), 1, 1) pack(self, hbox) ### hbox = gtk.HBox() self.startYearCheck = gtk.CheckButton(_('Start Year')) pack(hbox, self.startYearCheck) self.startYearSpin = YearSpinButton() pack(hbox, self.startYearSpin) pack(hbox, gtk.Label(''), 1, 1) pack(self, hbox) self.startYearCheck.connect('clicked', self.startYearCheckClicked) #### self.notificationBox = common.NotificationBox(event) pack(self, self.notificationBox) #### #self.filesBox = common.FilesBox(self.event) #pack(self, self.filesBox) startYearCheckClicked = lambda self, obj=None: self.startYearSpin.set_sensitive(self.startYearCheck.get_active()) def updateWidget(self):## FIXME common.WidgetClass.updateWidget(self) self.monthCombo.setValue(self.event.getMonth()) self.daySpin.set_value(self.event.getDay()) try: startRule = self.event['start'] except: self.startYearCheck.set_active(False) self.startYearSpin.set_value(self.event.getSuggestedStartYear()) else: self.startYearCheck.set_active(True) self.startYearSpin.set_value(startRule.date[0]) self.startYearCheckClicked() def updateVars(self):## FIXME common.WidgetClass.updateVars(self) self.event.setMonth(self.monthCombo.getValue()) self.event.setDay(int(self.daySpin.get_value())) if self.startYearCheck.get_active(): startRule = self.event.getAddRule('start') startRule.date = (self.startYearSpin.get_value(), 1, 1) else: try: del self.event['start'] except KeyError: pass def modeComboChanged(self, obj=None):## overwrite method from common.WidgetClass newMode = self.modeCombo.get_active() module = calTypes[newMode] monthCombo = self.monthCombo month = monthCombo.getValue() monthCombo.build(newMode) y2, m2, d2 = convert( int(self.startYearSpin.get_value()), month, int(self.daySpin.get_value()), self.event.mode, newMode, ) self.startYearSpin.set_value(y2) monthCombo.setValue(m2) self.daySpin.set_value(d2) self.event.mode = newMode
class WidgetClass(common.WidgetClass): def __init__(self, event): ## FIXME common.WidgetClass.__init__(self, event) ################ hbox = gtk.HBox() pack(hbox, gtk.Label(_("Month"))) self.monthCombo = MonthComboBox() self.monthCombo.build(event.mode) pack(hbox, self.monthCombo) pack(hbox, gtk.Label(""), 1, 1) #pack(self, hbox) ### #hbox = gtk.HBox() pack(hbox, gtk.Label(_("Day"))) self.daySpin = DaySpinButton() pack(hbox, self.daySpin) pack(hbox, gtk.Label(""), 1, 1) pack(self, hbox) ### hbox = gtk.HBox() self.startYearCheck = gtk.CheckButton(_("Start Year")) pack(hbox, self.startYearCheck) self.startYearSpin = YearSpinButton() pack(hbox, self.startYearSpin) pack(hbox, gtk.Label(""), 1, 1) pack(self, hbox) self.startYearCheck.connect("clicked", self.startYearCheckClicked) #### self.notificationBox = common.NotificationBox(event) pack(self, self.notificationBox) #### #self.filesBox = common.FilesBox(self.event) #pack(self, self.filesBox) def startYearCheckClicked(self, obj=None): return self.startYearSpin.set_sensitive( self.startYearCheck.get_active()) def updateWidget(self): ## FIXME common.WidgetClass.updateWidget(self) self.monthCombo.setValue(self.event.getMonth()) self.daySpin.set_value(self.event.getDay()) startRule, ok = self.event["start"] if ok: self.startYearCheck.set_active(True) self.startYearSpin.set_value(startRule.date[0]) else: self.startYearCheck.set_active(False) self.startYearSpin.set_value(self.event.getSuggestedStartYear()) self.startYearCheckClicked() def updateVars(self): ## FIXME common.WidgetClass.updateVars(self) self.event.setMonth(self.monthCombo.getValue()) self.event.setDay(int(self.daySpin.get_value())) if self.startYearCheck.get_active(): startRule = self.event.getAddRule("start") startRule.date = (self.startYearSpin.get_value(), 1, 1) else: if "start" in self.event: del self.event["start"] def modeComboChanged(self, obj=None): # overwrite method from common.WidgetClass newMode = self.modeCombo.get_active() module, ok = calTypes[newMode] if not ok: raise RuntimeError("cal type %r not found" % mode) monthCombo = self.monthCombo month = monthCombo.getValue() monthCombo.build(newMode) y2, m2, d2 = convert( int(self.startYearSpin.get_value()), month, int(self.daySpin.get_value()), self.event.mode, newMode, ) self.startYearSpin.set_value(y2) monthCombo.setValue(m2) self.daySpin.set_value(d2) self.event.mode = newMode
class YearMonthDayBox(gtk.HBox): def __init__(self): gtk.HBox.__init__(self, spacing=4) self.mode = calTypes.primary #### pack(self, gtk.Label(_("Year"))) self.spinY = YearSpinButton() pack(self, self.spinY) #### pack(self, gtk.Label(_("Month"))) comboMonth = gtk.ComboBoxText() module, ok = calTypes[self.mode] if not ok: raise RuntimeError("cal type %r not found" % self.mode) for i in range(12): comboMonth.append_text(_(module.getMonthName( i + 1, None, # year=None means all months ))) comboMonth.set_active(0) pack(self, comboMonth) self.comboMonth = comboMonth #### pack(self, gtk.Label(_("Day"))) self.spinD = DaySpinButton() pack(self, self.spinD) self.comboMonthConn = comboMonth.connect( "changed", self.comboMonthChanged, ) self.spinY.connect("changed", self.comboMonthChanged) def set_mode(self, mode): self.comboMonth.disconnect(self.comboMonthConn) self.mode = mode module, ok = calTypes[mode] if not ok: raise RuntimeError("cal type %r not found" % mode) combo = self.comboMonth combo.remove_all() for i in range(12): combo.append_text(_(module.getMonthName(i + 1))) self.spinD.set_range(1, module.maxMonthLen) self.comboMonthConn = self.comboMonth.connect( "changed", self.comboMonthChanged, ) def changeMode(self, mode, newMode):## FIXME naming standard? self.set_mode(newMode) def set_value(self, date): y, m, d = date self.spinY.set_value(y) self.comboMonth.set_active(m - 1) self.spinD.set_value(d) def get_value(self): return ( self.spinY.get_value(), self.comboMonth.get_active() + 1, self.spinD.get_value(), ) def comboMonthChanged(self, widget=None): monthIndex = self.comboMonth.get_active() if monthIndex == -1: return self.spinD.set_range(1, getMonthLen( self.spinY.get_value(), monthIndex + 1, self.mode, ))
class WidgetClass(common.WidgetClass): def __init__(self, event):## FIXME event.setJd(ui.cell.jd) common.WidgetClass.__init__(self, event) ###### sizeGroup = gtk.SizeGroup(gtk.SizeGroupMode.HORIZONTAL) ###### hbox = gtk.HBox() label = gtk.Label(_("Start")) label.set_alignment(0, 0.5) sizeGroup.add_widget(label) pack(hbox, label) self.startDateInput = DateButton() pack(hbox, self.startDateInput) ### pack(hbox, gtk.Label(""), 1, 1) pack(self, hbox) ###### hbox = gtk.HBox() label = gtk.Label(_("End")) label.set_alignment(0, 0.5) sizeGroup.add_widget(label) pack(hbox, label) self.endDateInput = DateButton() pack(hbox, self.endDateInput) ### pack(hbox, gtk.Label(""), 1, 1) pack(self, hbox) ###### hbox = gtk.HBox() label = gtk.Label(_("Day of Month")) label.set_alignment(0, 0.5) sizeGroup.add_widget(label) pack(hbox, label) self.daySpin = DaySpinButton() pack(hbox, self.daySpin) ### pack(hbox, gtk.Label(""), 1, 1) pack(self, hbox) ######### hbox = gtk.HBox() label = gtk.Label(_("Time")) label.set_alignment(0, 0.5) sizeGroup.add_widget(label) pack(hbox, label) ## self.dayTimeStartInput = HourMinuteButton() self.dayTimeEndInput = HourMinuteButton() ## pack(hbox, self.dayTimeStartInput) pack(hbox, gtk.Label(" " + _("to") + " ")) pack(hbox, self.dayTimeEndInput) pack(self, hbox) ############# #self.notificationBox = common.NotificationBox(event) #pack(self, self.notificationBox) ############# #self.filesBox = common.FilesBox(self.event) #pack(self, self.filesBox) def updateWidget(self):## FIXME common.WidgetClass.updateWidget(self) mode = self.event.mode ### self.startDateInput.set_value(jd_to(self.event.getStartJd(), mode)) self.endDateInput.set_value(jd_to(self.event.getEndJd(), mode)) ### self.daySpin.set_value(self.event.getDay()) ### dayTimeRange, ok = self.event["dayTimeRange"] if not ok: raise RuntimeError("no dayTimeRange rule") self.dayTimeStartInput.set_value(dayTimeRange.dayTimeStart) self.dayTimeEndInput.set_value(dayTimeRange.dayTimeEnd) def updateVars(self):## FIXME common.WidgetClass.updateVars(self) ## start, ok = self.event["start"] if not ok: raise RuntimeError("no start rule") start.setDate(self.startDateInput.get_value()) ## end, ok = self.event["end"] if not ok: raise RuntimeError("no end rule") end.setDate(self.endDateInput.get_value()) ## self.event.setDay(self.daySpin.get_value()) ### dayTimeRange, ok = self.event["dayTimeRange"] if not ok: raise RuntimeError("no dayTimeRange rule") dayTimeRange.setRange( self.dayTimeStartInput.get_value(), self.dayTimeEndInput.get_value(), ) def modeComboChanged(self, obj=None): # overwrite method from common.WidgetClass newMode = self.modeCombo.get_active() self.startDateInput.changeMode(self.event.mode, newMode) self.endDateInput.changeMode(self.event.mode, newMode) self.event.mode = newMode
class WidgetClass(common.WidgetClass): def __init__(self, event): ## FIXME common.WidgetClass.__init__(self, event) ################ hbox = gtk.HBox() pack(hbox, gtk.Label(_('Month'))) self.monthCombo = MonthComboBox() self.monthCombo.build(event.mode) pack(hbox, self.monthCombo) pack(hbox, gtk.Label(''), 1, 1) #pack(self, hbox) ### #hbox = gtk.HBox() pack(hbox, gtk.Label(_('Day'))) self.daySpin = DaySpinButton() pack(hbox, self.daySpin) pack(hbox, gtk.Label(''), 1, 1) pack(self, hbox) ### hbox = gtk.HBox() self.startYearCheck = gtk.CheckButton(_('Start Year')) pack(hbox, self.startYearCheck) self.startYearSpin = YearSpinButton() pack(hbox, self.startYearSpin) pack(hbox, gtk.Label(''), 1, 1) pack(self, hbox) self.startYearCheck.connect('clicked', self.startYearCheckClicked) #### self.notificationBox = common.NotificationBox(event) pack(self, self.notificationBox) #### #self.filesBox = common.FilesBox(self.event) #pack(self, self.filesBox) startYearCheckClicked = lambda self, obj=None: self.startYearSpin.set_sensitive( self.startYearCheck.get_active()) def updateWidget(self): ## FIXME common.WidgetClass.updateWidget(self) self.monthCombo.setValue(self.event.getMonth()) self.daySpin.set_value(self.event.getDay()) try: startRule = self.event['start'] except: self.startYearCheck.set_active(False) self.startYearSpin.set_value(self.event.getSuggestedStartYear()) else: self.startYearCheck.set_active(True) self.startYearSpin.set_value(startRule.date[0]) self.startYearCheckClicked() def updateVars(self): ## FIXME common.WidgetClass.updateVars(self) self.event.setMonth(self.monthCombo.getValue()) self.event.setDay(int(self.daySpin.get_value())) if self.startYearCheck.get_active(): startRule = self.event.getAddRule('start') startRule.date = (self.startYearSpin.get_value(), 1, 1) else: try: del self.event['start'] except KeyError: pass def modeComboChanged(self, obj=None ): ## overwrite method from common.WidgetClass newMode = self.modeCombo.get_active() module = calTypes[newMode] monthCombo = self.monthCombo month = monthCombo.getValue() monthCombo.build(newMode) y2, m2, d2 = convert( int(self.startYearSpin.get_value()), month, int(self.daySpin.get_value()), self.event.mode, newMode, ) self.startYearSpin.set_value(y2) monthCombo.setValue(m2) self.daySpin.set_value(d2) self.event.mode = newMode
class YearMonthDayBox(gtk.HBox): def __init__(self): gtk.HBox.__init__(self, spacing=4) self.mode = calTypes.primary #### pack(self, gtk.Label(_('Year'))) self.spinY = YearSpinButton() pack(self, self.spinY) #### pack(self, gtk.Label(_('Month'))) comboMonth = gtk.ComboBoxText() module = calTypes[self.mode] for i in range(12): comboMonth.append_text(_(module.getMonthName( i + 1, None))) ## year=None means all months comboMonth.set_active(0) pack(self, comboMonth) self.comboMonth = comboMonth #### pack(self, gtk.Label(_('Day'))) self.spinD = DaySpinButton() pack(self, self.spinD) self.comboMonthConn = comboMonth.connect('changed', self.comboMonthChanged) self.spinY.connect('changed', self.comboMonthChanged) def set_mode(self, mode): self.comboMonth.disconnect(self.comboMonthConn) self.mode = mode module = calTypes[mode] combo = self.comboMonth combo.remove_all() for i in range(12): combo.append_text(_(module.getMonthName(i + 1))) self.spinD.set_range(1, module.maxMonthLen) self.comboMonthConn = self.comboMonth.connect('changed', self.comboMonthChanged) def changeMode(self, mode, newMode): ## FIXME naming standard? self.set_mode(newMode) def set_value(self, date): y, m, d = date self.spinY.set_value(y) self.comboMonth.set_active(m - 1) self.spinD.set_value(d) get_value = lambda self: ( self.spinY.get_value(), self.comboMonth.get_active() + 1, self.spinD.get_value(), ) def comboMonthChanged(self, widget=None): monthIndex = self.comboMonth.get_active() if monthIndex == -1: return self.spinD.set_range( 1, getMonthLen( self.spinY.get_value(), monthIndex + 1, self.mode, ))