Esempio n. 1
0
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.combo_box_new_text()
        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
        for i in range(len(combo.get_model())):
            combo.remove_text(0)
        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):
        self.spinD.set_range(1, getMonthLen(
            self.spinY.get_value(),
            self.comboMonth.get_active() + 1,
            self.mode,
        ))
Esempio n. 2
0
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
Esempio n. 3
0
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.combo_box_new_text()
        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
        for i in range(len(combo.get_model())):
            combo.remove_text(0)
        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,
            ))
Esempio n. 4
0
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