Пример #1
0
 def __init__(self, saveIcsFunc, defaultFileName):
     self.saveIcsFunc = saveIcsFunc
     gtk.Dialog.__init__(self, title=_('Export to %s')%'iCalendar', parent=None)
     self.set_has_separator(False)
     ########
     hbox = gtk.HBox(spacing=2)
     hbox.pack_start(gtk.Label(_('From')+' '), 0, 0)
     self.startDateInput = DateButton()
     hbox.pack_start(self.startDateInput, 0, 0)
     hbox.pack_start(gtk.Label(' '+_('To')+' '), 0, 0)
     self.endDateInput = DateButton()
     hbox.pack_start(self.endDateInput, 0, 0)
     self.vbox.pack_start(hbox, 0, 0)
     ####
     (year, month, day) = ui.todayCell.dates[core.primaryMode]
     self.startDateInput.set_value((year, 1, 1))
     self.endDateInput.set_value((year+1, 1, 1))
     ########
     self.fcw = gtk.FileChooserWidget(action=gtk.FILE_CHOOSER_ACTION_SAVE)
     self.vbox.pack_start(self.fcw, 1, 1)
     self.vbox.show_all()
     ##
     dialog_add_button(self, gtk.STOCK_CANCEL, _('_Cancel'), 1, self.onDelete)
     dialog_add_button(self, gtk.STOCK_SAVE, _('_Save'), 2, self.save)
     ##
     self.connect('delete-event', self.onDelete)
     try:
         self.fcw.set_current_folder(core.deskDir)
     except AttributeError:## PyGTK < 2.4
         pass
     if not defaultFileName.endswith('.ics'):
         defaultFileName += '.ics'
     self.fcw.set_current_name(defaultFileName)
Пример #2
0
class GroupWidget(BaseGroupWidget):
    def __init__(self, group):
        BaseGroupWidget.__init__(self, group)
        ####
        hbox = gtk.HBox()
        label = gtk.Label(_('Start'))
        label.set_alignment(0, 0.5)
        hbox.pack_start(label, 0, 0)
        self.sizeGroup.add_widget(label)
        self.startDateInput = DateButton()
        hbox.pack_start(self.startDateInput, 0, 0)
        self.pack_start(hbox, 0, 0)
        ###
        hbox = gtk.HBox()
        label = gtk.Label(_('End'))
        label.set_alignment(0, 0.5)
        hbox.pack_start(label, 0, 0)
        self.sizeGroup.add_widget(label)
        self.endDateInput = DateButton()
        hbox.pack_start(self.endDateInput, 0, 0)
        self.pack_start(hbox, 0, 0)
    def updateWidget(self):
        BaseGroupWidget.updateWidget(self)
        self.startDateInput.set_value(jd_to(self.group.startJd, self.group.mode))
        self.endDateInput.set_value(jd_to(self.group.endJd, self.group.mode))
    def updateVars(self):
        BaseGroupWidget.updateVars(self)
        self.group.startJd = self.startDateInput.get_jd(self.group.mode)
        self.group.endJd = self.endDateInput.get_jd(self.group.mode)
    def modeComboChanged(self, obj=None):
        newMode = self.modeCombo.get_active()
        self.startDateInput.changeMode(self.group.mode, newMode)
        self.endDateInput.changeMode(self.group.mode, newMode)
        self.group.mode = newMode
Пример #3
0
class EventWidget(common.EventWidget):
    def __init__(self, event):
        common.EventWidget.__init__(self, event)
        ###
        hbox = gtk.HBox()
        pack(hbox, gtk.Label(_("Date")))
        self.dateInput = DateButton()
        pack(hbox, self.dateInput)
        pack(self, hbox)
        #############
        # self.filesBox = common.FilesBox(self.event)
        # pack(self, self.filesBox)

    def updateWidget(self):
        common.EventWidget.updateWidget(self)
        self.dateInput.set_value(self.event.getDate())

    def updateVars(self):
        common.EventWidget.updateVars(self)
        self.event.setDate(*self.dateInput.get_value())

    def modeComboChanged(self, obj=None):  ## overwrite method from common.EventWidget
        newMode = self.modeCombo.get_active()
        self.dateInput.changeMode(self.event.mode, newMode)
        self.event.mode = newMode
Пример #4
0
 def __init__(self, event):## FIXME
     common.EventWidget.__init__(self, event)
     ######
     sizeGroup = gtk.SizeGroup(gtk.SIZE_GROUP_HORIZONTAL)
     ######
     try:
         seperated = event.parent.showSeperatedYmdInputs
     except AttributeError:
         seperated = False
     if seperated:
         self.startDateInput = YearMonthDayBox()
         self.endDateInput = YearMonthDayBox()
     else:
         self.startDateInput = DateButton()
         self.endDateInput = DateButton()
     ######
     hbox = gtk.HBox()
     label = gtk.Label(_('Start')+': ')
     label.set_alignment(0, 0.5)
     sizeGroup.add_widget(label)
     hbox.pack_start(label, 0, 0)
     hbox.pack_start(self.startDateInput, 0, 0)
     self.pack_start(hbox, 0, 0)
     ######
     hbox = gtk.HBox()
     label = gtk.Label(_('End')+': ')
     label.set_alignment(0, 0.5)
     sizeGroup.add_widget(label)
     hbox.pack_start(label, 0, 0)
     hbox.pack_start(self.endDateInput, 0, 0)
     self.pack_start(hbox, 0, 0)
Пример #5
0
 def __init__(self, event):## FIXME
     common.EventWidget.__init__(self, event)
     ######
     sizeGroup = gtk.SizeGroup(gtk.SIZE_GROUP_HORIZONTAL)
     ######
     hbox = gtk.HBox()
     label = gtk.Label(_('Start'))
     label.set_alignment(0, 0.5)
     sizeGroup.add_widget(label)
     hbox.pack_start(label, 0, 0)
     self.startDateInput = DateButton()
     hbox.pack_start(self.startDateInput, 0, 0)
     ###
     hbox.pack_start(gtk.Label(''), 1, 1)
     self.pack_start(hbox, 0, 0)
     ######
     hbox = gtk.HBox()
     label = gtk.Label(_('Repeat Every '))
     label.set_alignment(0, 0.5)
     sizeGroup.add_widget(label)
     hbox.pack_start(label, 0, 0)
     self.weeksSpin = IntSpinButton(1, 99999)
     hbox.pack_start(self.weeksSpin, 0, 0)
     hbox.pack_start(gtk.Label('  '+_(' Weeks')), 0, 0)
     ###
     hbox.pack_start(gtk.Label(''), 1, 1)
     self.pack_start(hbox, 0, 0)
     ######
     hbox = gtk.HBox()
     label = gtk.Label(_('End'))
     label.set_alignment(0, 0.5)
     sizeGroup.add_widget(label)
     hbox.pack_start(label, 0, 0)
     self.endDateInput = DateButton()
     hbox.pack_start(self.endDateInput, 0, 0)
     ###
     hbox.pack_start(gtk.Label(''), 1, 1)
     self.pack_start(hbox, 0, 0)
     #########
     hbox = gtk.HBox()
     label = gtk.Label(_('Time'))
     label.set_alignment(0, 0.5)
     sizeGroup.add_widget(label)
     hbox.pack_start(label, 0, 0)
     ##
     self.dayTimeStartInput = HourMinuteButton()
     self.dayTimeEndInput = HourMinuteButton()
     ##
     hbox.pack_start(self.dayTimeStartInput, 0, 0)
     hbox.pack_start(gtk.Label(' ' + _('to') + ' '), 0, 0)
     hbox.pack_start(self.dayTimeEndInput, 0, 0)
     self.pack_start(hbox, 0, 0)
Пример #6
0
class EventWidget(common.EventWidget):
    def __init__(self, event):  ## FIXME
        common.EventWidget.__init__(self, event)
        ######
        sizeGroup = gtk.SizeGroup(gtk.SIZE_GROUP_HORIZONTAL)
        ######
        try:
            seperated = event.parent.showSeperatedYmdInputs
        except AttributeError:
            seperated = False
        if seperated:
            self.startDateInput = YearMonthDayBox()
            self.endDateInput = YearMonthDayBox()
        else:
            self.startDateInput = DateButton()
            self.endDateInput = DateButton()
        ######
        hbox = gtk.HBox()
        label = gtk.Label(_("Start") + ": ")
        label.set_alignment(0, 0.5)
        sizeGroup.add_widget(label)
        pack(hbox, label)
        pack(hbox, self.startDateInput)
        pack(self, hbox)
        ######
        hbox = gtk.HBox()
        label = gtk.Label(_("End") + ": ")
        label.set_alignment(0, 0.5)
        sizeGroup.add_widget(label)
        pack(hbox, label)
        pack(hbox, self.endDateInput)
        pack(self, hbox)
        #############
        # self.filesBox = common.FilesBox(self.event)
        # pack(self, self.filesBox)

    def updateWidget(self):
        common.EventWidget.updateWidget(self)
        self.startDateInput.set_value(self.event["start"].date)
        self.endDateInput.set_value(self.event["end"].date)

    def updateVars(self):  ## FIXME
        common.EventWidget.updateVars(self)
        self.event["start"].setDate(self.startDateInput.get_value())
        self.event["end"].setDate(self.endDateInput.get_value())

    def modeComboChanged(self, obj=None):  ## overwrite method from common.EventWidget
        newMode = self.modeCombo.get_active()
        self.startDateInput.changeMode(self.event.mode, newMode)
        self.endDateInput.changeMode(self.event.mode, newMode)
        self.event.mode = newMode
Пример #7
0
 def __init__(self, event):
     common.EventWidget.__init__(self, event)
     ###
     hbox = gtk.HBox()
     hbox.pack_start(gtk.Label(_('Date')), 0, 0)
     self.dateInput = DateButton()
     hbox.pack_start(self.dateInput, 0, 0)
     self.pack_start(hbox, 0, 0)
Пример #8
0
 def __init__(self, event):
     common.EventWidget.__init__(self, event)
     ###
     hbox = gtk.HBox()
     pack(hbox, gtk.Label(_("Date")))
     self.dateInput = DateButton()
     pack(hbox, self.dateInput)
     pack(self, hbox)
Пример #9
0
 def __init__(self, event):## FIXME
     common.EventWidget.__init__(self, event)
     ######
     sizeGroup = gtk.SizeGroup(gtk.SIZE_GROUP_HORIZONTAL)
     ######
     hbox = gtk.HBox()
     label = gtk.Label(_('Start'))
     label.set_alignment(0, 0.5)
     sizeGroup.add_widget(label)
     hbox.pack_start(label, 0, 0)
     self.startDateInput = DateButton()
     hbox.pack_start(self.startDateInput, 0, 0)
     ##
     hbox.pack_start(gtk.Label(' '+_('Time')), 0, 0)
     self.startTimeInput = TimeButton()
     hbox.pack_start(self.startTimeInput, 0, 0)
     ##
     self.pack_start(hbox, 0, 0)
     ######
     hbox = gtk.HBox()
     self.endTypeCombo = gtk.combo_box_new_text()
     for item in ('Duration', 'End'):
         self.endTypeCombo.append_text(_(item))
     self.endTypeCombo.connect('changed', self.endTypeComboChanged)
     sizeGroup.add_widget(self.endTypeCombo)
     hbox.pack_start(self.endTypeCombo, 0, 0)
     ####
     self.durationBox = common.DurationInputBox()
     hbox.pack_start(self.durationBox, 1, 1)
     ####
     self.endDateHbox = gtk.HBox()
     self.endDateInput = DateButton()
     self.endDateHbox.pack_start(self.endDateInput, 0, 0)
     ##
     self.endDateHbox.pack_start(gtk.Label(' '+_('Time')), 0, 0)
     self.endTimeInput = TimeButton()
     self.endDateHbox.pack_start(self.endTimeInput, 0, 0)
     ##
     hbox.pack_start(self.endDateHbox, 1, 1)
     ####
     hbox.pack_start(gtk.Label(''), 1, 1)
     self.pack_start(hbox, 0, 0)
     #############
     self.notificationBox = common.NotificationBox(event)
     self.pack_start(self.notificationBox, 0, 0)
Пример #10
0
 def __init__(self, event):  ## FIXME
     common.EventWidget.__init__(self, event)
     ######
     sizeGroup = gtk.SizeGroup(gtk.SIZE_GROUP_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(" " + _("Time")))
     self.startTimeInput = TimeButton()
     pack(hbox, self.startTimeInput)
     ##
     pack(self, hbox)
     ######
     hbox = gtk.HBox()
     self.endTypeCombo = gtk.combo_box_new_text()
     for item in ("Duration", "End"):
         self.endTypeCombo.append_text(_(item))
     self.endTypeCombo.connect("changed", self.endTypeComboChanged)
     sizeGroup.add_widget(self.endTypeCombo)
     pack(hbox, self.endTypeCombo)
     ####
     self.durationBox = common.DurationInputBox()
     pack(hbox, self.durationBox, 1, 1)
     ####
     self.endDateHbox = gtk.HBox()
     self.endDateInput = DateButton()
     pack(self.endDateHbox, self.endDateInput)
     ##
     pack(self.endDateHbox, gtk.Label(" " + _("Time")))
     self.endTimeInput = TimeButton()
     pack(self.endDateHbox, self.endTimeInput)
     ##
     pack(hbox, self.endDateHbox, 1, 1)
     ####
     pack(hbox, gtk.Label(""), 1, 1)
     pack(self, hbox)
     #############
     self.notificationBox = common.NotificationBox(event)
     pack(self, self.notificationBox)
Пример #11
0
 def __init__(self, group):
     BaseGroupWidget.__init__(self, group)
     ####
     hbox = gtk.HBox()
     label = gtk.Label(_('Start'))
     label.set_alignment(0, 0.5)
     hbox.pack_start(label, 0, 0)
     self.sizeGroup.add_widget(label)
     self.startDateInput = DateButton()
     hbox.pack_start(self.startDateInput, 0, 0)
     self.pack_start(hbox, 0, 0)
     ###
     hbox = gtk.HBox()
     label = gtk.Label(_('End'))
     label.set_alignment(0, 0.5)
     hbox.pack_start(label, 0, 0)
     self.sizeGroup.add_widget(label)
     self.endDateInput = DateButton()
     hbox.pack_start(self.endDateInput, 0, 0)
     self.pack_start(hbox, 0, 0)
Пример #12
0
 def __init__(self, rule):
     self.rule = rule
     ###
     gtk.HBox.__init__(self)
     ###
     self.dateInput = DateButton()
     self.pack_start(self.dateInput, 0, 0)
     ###
     self.pack_start(gtk.Label('   '+_('Time')), 0, 0)
     self.timeInput = TimeButton()
     self.pack_start(self.timeInput, 0, 0)
Пример #13
0
 def __init__(self, rule):
     self.rule = rule
     ###
     gtk.HBox.__init__(self)
     ###
     self.dateInput = DateButton()
     pack(self, self.dateInput)
     ###
     pack(self, gtk.Label('   '+_('Time')))
     self.timeInput = TimeButton()
     pack(self, self.timeInput)
Пример #14
0
 def __init__(self, event):## FIXME
     common.EventWidget.__init__(self, event)
     ######
     sizeGroup = gtk.SizeGroup(gtk.SIZE_GROUP_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(self, hbox)
     ######
     hbox = gtk.HBox()
     self.endTypeCombo = gtk.combo_box_new_text()
     for item in ('Duration', 'End'):
         self.endTypeCombo.append_text(_(item))
     self.endTypeCombo.connect('changed', self.endTypeComboChanged)
     sizeGroup.add_widget(self.endTypeCombo)
     pack(hbox, self.endTypeCombo)
     ####
     self.durationBox = gtk.HBox()
     self.durationSpin = IntSpinButton(1, 999)
     pack(self.durationBox, self.durationSpin)
     pack(self.durationBox, gtk.Label(_(' days')))
     pack(hbox, self.durationBox)
     ####
     self.endDateInput = DateButton()
     pack(hbox, self.endDateInput)
     ####
     pack(hbox, gtk.Label(''), 1, 1)
     pack(self, hbox)
     #############
     self.notificationBox = common.NotificationBox(event)
     pack(self, self.notificationBox)
Пример #15
0
 def __init__(self, event):  ## FIXME
     common.EventWidget.__init__(self, event)
     ######
     sizeGroup = gtk.SizeGroup(gtk.SIZE_GROUP_HORIZONTAL)
     ######
     hbox = gtk.HBox()
     label = gtk.Label(_("Start"))
     label.set_alignment(0, 0.5)
     sizeGroup.add_widget(label)
     hbox.pack_start(label, 0, 0)
     self.startDateInput = DateButton()
     hbox.pack_start(self.startDateInput, 0, 0)
     ##
     self.pack_start(hbox, 0, 0)
     ######
     hbox = gtk.HBox()
     self.endTypeCombo = gtk.combo_box_new_text()
     for item in ("Duration", "End"):
         self.endTypeCombo.append_text(_(item))
     self.endTypeCombo.connect("changed", self.endTypeComboChanged)
     sizeGroup.add_widget(self.endTypeCombo)
     hbox.pack_start(self.endTypeCombo, 0, 0)
     ####
     self.durationBox = gtk.HBox()
     self.durationSpin = IntSpinButton(1, 999)
     self.durationBox.pack_start(self.durationSpin, 0, 0)
     self.durationBox.pack_start(gtk.Label(_(" days")), 0, 0)
     hbox.pack_start(self.durationBox, 0, 0)
     ####
     self.endDateInput = DateButton()
     hbox.pack_start(self.endDateInput, 0, 0)
     ####
     hbox.pack_start(gtk.Label(""), 1, 1)
     self.pack_start(hbox, 0, 0)
     #############
     self.notificationBox = common.NotificationBox(event)
     self.pack_start(self.notificationBox, 0, 0)
Пример #16
0
class ExportToIcsDialog(gtk.Dialog):
    def __init__(self, saveIcsFunc, defaultFileName):
        self.saveIcsFunc = saveIcsFunc
        gtk.Dialog.__init__(self, title=_('Export to %s')%'iCalendar', parent=None)
        self.set_has_separator(False)
        ########
        hbox = gtk.HBox(spacing=2)
        pack(hbox, gtk.Label(_('From')+' '))
        self.startDateInput = DateButton()
        pack(hbox, self.startDateInput)
        pack(hbox, gtk.Label(' '+_('To')+' '))
        self.endDateInput = DateButton()
        pack(hbox, self.endDateInput)
        pack(self.vbox, hbox)
        ####
        year, month, day = ui.todayCell.dates[calTypes.primary]
        self.startDateInput.set_value((year, 1, 1))
        self.endDateInput.set_value((year+1, 1, 1))
        ########
        self.fcw = gtk.FileChooserWidget(action=gtk.FILE_CHOOSER_ACTION_SAVE)
        pack(self.vbox, self.fcw, 1, 1)
        self.vbox.set_focus_child(self.fcw)## FIXME
        self.vbox.show_all()
        ##
        dialog_add_button(self, gtk.STOCK_CANCEL, _('_Cancel'), 1, self.onDelete)
        dialog_add_button(self, gtk.STOCK_SAVE, _('_Save'), 2, self.save)
        ##
        self.connect('delete-event', self.onDelete)
        self.fcw.connect('file-activated', self.save)## not working FIXME
        ##
        try:
            self.fcw.set_current_folder(core.deskDir)
        except AttributeError:## PyGTK < 2.4
            pass
        if not defaultFileName.endswith('.ics'):
            defaultFileName += '.ics'
        self.fcw.set_current_name(defaultFileName)
    def onDelete(self, widget=None, event=None):## hide(close) File Chooser Dialog
        self.destroy()
        return True
    def save(self, widget=None):
        self.get_window().set_cursor(gdk.Cursor(gdk.WATCH))
        while gtk.events_pending():
            gtk.main_iteration_do(False)
        path = self.fcw.get_filename()
        if path in (None, ''):
            return
        print('Exporting to ics file "%s"'%path)
        self.saveIcsFunc(
            path,
            core.primary_to_jd(*self.startDateInput.get_value()),
            core.primary_to_jd(*self.endDateInput.get_value()),
        )
        self.get_window().set_cursor(gdk.Cursor(gdk.LEFT_PTR))
        self.destroy()
Пример #17
0
class RuleWidget(gtk.HBox):
    def __init__(self, rule):
        self.rule = rule
        ###
        gtk.HBox.__init__(self)
        ###
        self.dateInput = DateButton()
        self.pack_start(self.dateInput, 0, 0)
        ###
        self.pack_start(gtk.Label('   '+_('Time')), 0, 0)
        self.timeInput = TimeButton()
        self.pack_start(self.timeInput, 0, 0)
    def updateWidget(self):
        self.dateInput.set_value(self.rule.date)
        self.timeInput.set_value(self.rule.time)
    def updateVars(self):
        self.rule.date = self.dateInput.get_value()
        self.rule.time = self.timeInput.get_value()
    def changeMode(self, mode):
        curMode = self.rule.getMode()
        if mode!=curMode:
            (y, m, d) = self.dateInput.get_value()
            self.dateInput.set_value(core.convert(y, m, d, curMode, mode))
Пример #18
0
class AdjusterDialog(gtk.Dialog):
    xpad = 15
    def __init__(self):
        gtk.Dialog.__init__(self)
        self.set_title(_('Adjust System Date & Time'))##????????
        self.set_icon(self.render_icon(gtk.STOCK_PREFERENCES, gtk.ICON_SIZE_BUTTON))
        #########
        self.buttonCancel = self.add_button(gtk.STOCK_CANCEL, 0)
        #self.buttonCancel.connect('clicked', lambda w: sys.exit(0))
        self.buttonSet = self.add_button(_('Set System Time'), 1)
        #self.buttonSet.connect('clicked', self.setSysTimeClicked)
        #########
        hbox = gtk.HBox()
        self.label_cur = gtk.Label(_('Current:'))
        hbox.pack_start(self.label_cur, 0, 0)
        self.vbox.pack_start(hbox, 0, 0)
        #########
        hbox = gtk.HBox()
        self.radioMan = gtk.RadioButton(None, _('Set _Manully:'), True)
        self.radioMan.connect('clicked', self.radioManClicked)
        hbox.pack_start(self.radioMan, 0, 0)
        self.vbox.pack_start(hbox, 0, 0)
        ######
        vb = gtk.VBox()
        sg = gtk.SizeGroup(gtk.SIZE_GROUP_HORIZONTAL)
        ###
        hbox = gtk.HBox()
        ##
        l = gtk.Label('')
        l.set_property('width-request', self.xpad)
        hbox.pack_start(l, 0, 0)
        ##
        self.ckeckbEditTime = gtk.CheckButton(_('Edit Time'))
        self.editTime = False
        self.ckeckbEditTime.connect('clicked', self.ckeckbEditTimeClicked)
        hbox.pack_start(self.ckeckbEditTime, 0, 0)
        sg.add_widget(self.ckeckbEditTime)
        self.timeInput = TimeButton() ## ??????? options
        hbox.pack_start(self.timeInput, 0, 0)
        vb.pack_start(hbox, 0, 0)
        ###
        hbox = gtk.HBox()
        ##
        l = gtk.Label('')
        l.set_property('width-request', self.xpad)
        hbox.pack_start(l, 0, 0)
        ##
        self.ckeckbEditDate = gtk.CheckButton(_('Edit Date'))
        self.editDate = False
        self.ckeckbEditDate.connect('clicked', self.ckeckbEditDateClicked)
        hbox.pack_start(self.ckeckbEditDate, 0, 0)
        sg.add_widget(self.ckeckbEditDate)
        self.dateInput = DateButton() ## ??????? options
        hbox.pack_start(self.dateInput, 0, 0)
        vb.pack_start(hbox, 0, 0)
        ###
        self.vbox.pack_start(vb, 0, 0, 10)#?????
        self.vboxMan = vb
        ######
        hbox = gtk.HBox()
        self.radioNtp = gtk.RadioButton(self.radioMan, _('Set from _NTP:'), True)
        self.radioNtp.connect('clicked', self.radioNtpClicked)
        hbox.pack_start(self.radioNtp, 0, 0)
        self.vbox.pack_start(hbox, 0, 0)
        ###
        hbox = gtk.HBox()
        ##
        l = gtk.Label('')
        l.set_property('width-request', self.xpad)
        hbox.pack_start(l, 0, 0)
        ##
        hbox.pack_start(gtk.Label(_('Server:')+' '), 0, 0)
        combo = gtk.combo_box_entry_new_text()
        combo.child.connect('changed', self.updateSetButtonSensitive)
        hbox.pack_start(combo, 1, 1)
        self.ntpServerEntry = combo.child
        for s in ui.ntpServers:
            combo.append_text(s)
        combo.set_active(0)
        self.hboxNtp = hbox
        self.vbox.pack_start(hbox, 0, 0)
        ######
        self.radioManClicked()
        #self.radioNtpClicked()
        self.ckeckbEditTimeClicked()
        self.ckeckbEditDateClicked()
        ######
        self.updateTimes()
        self.vbox.show_all()
    def radioManClicked(self, radio=None):
        if self.radioMan.get_active():
            self.vboxMan.set_sensitive(True)
            self.hboxNtp.set_sensitive(False)
        else:
            self.vboxMan.set_sensitive(False)
            self.hboxNtp.set_sensitive(True)
        self.updateSetButtonSensitive()
    def radioNtpClicked(self, radio=None):
        if self.radioNtp.get_active():
            self.vboxMan.set_sensitive(False)
            self.hboxNtp.set_sensitive(True)
        else:
            self.vboxMan.set_sensitive(True)
            self.hboxNtp.set_sensitive(False)
        self.updateSetButtonSensitive()
    def ckeckbEditTimeClicked(self, checkb=None):
        self.editTime = self.ckeckbEditTime.get_active()
        self.timeInput.set_sensitive(self.editTime)
        self.updateSetButtonSensitive()
    def ckeckbEditDateClicked(self, checkb=None):
        self.editDate = self.ckeckbEditDate.get_active()
        self.dateInput.set_sensitive(self.editDate)
        self.updateSetButtonSensitive()
    """def set_sys_time(self):
        if os.path.isfile('/bin/date'):
            pass##????????
        elif sys.platform == 'win32':
            import win32api
            win32api.SetSystemTime()##????????
        else:
            pass"""
    def updateTimes(self):
        dt = time.time()%1
        timeout_add(iceil(1000*(1-dt)), self.updateTimes)
        #print 'updateTimes', dt
        lt = time.localtime()
        self.label_cur.set_label(_('Current:')+' %.4d/%.2d/%.2d - %.2d:%.2d:%.2d'%lt[:6])
        if not self.editTime:
            self.timeInput.set_value(lt[3:6])
        if not self.editDate:
            self.dateInput.set_value(lt[:3])
        return False
    def updateSetButtonSensitive(self, widget=None):
        if self.radioMan.get_active():
            self.buttonSet.set_sensitive(self.editTime or self.editDate)
        elif self.radioNtp.get_active():
            self.buttonSet.set_sensitive(self.ntpServerEntry.get_text()!='')
    def setSysTimeClicked(self, widget=None):
        if self.radioMan.get_active():
            if self.editTime:
                h, m, s = self.timeInput.get_value()
                if self.editDate:
                    Y, M, D = self.dateInput.get_value()
                    cmd = ['/bin/date', '-s', '%.4d/%.2d/%.2d %.2d:%.2d:%.2d'%(Y,M,D,h,m,s)]
                else:
                    cmd = ['/bin/date', '-s', '%.2d:%.2d:%.2d'%(h, m, s)]
            else:
                if self.editDate:
                    Y, M, D = self.dateInput.get_value()
                    ##h, m, s = self.timeInput.get_value()
                    h, m, s = time.localtime()[3:6]
                    cmd = ['/bin/date', '-s', '%.4d/%.2d/%.2d %.2d:%.2d:%.2d'%(Y,M,D,h,m,s)]
                else:
                    error_exit('No change!', self)#??????????
        elif self.radioNtp.get_active():
            cmd = ['ntpdate', self.ntpServerEntry.get_text()]
            #if os.path.isfile('/usr/sbin/ntpdate'):
            #    cmd = ['/usr/sbin/ntpdate', self.ntpServerEntry.get_text()]
            #else:
            #    error_exit('Could not find command /usr/sbin/ntpdate: no such file!', self)#??????????
        else:
            error_exit('Not valid option!', self)
        inp, out, err = os.popen3(cmd)
        err_text = err.read()
        if err_text=='':
            sys.exit(0)
        else:
            error_exit(err_text, self)#??????????
Пример #19
0
class EventWidget(common.EventWidget):
    def __init__(self, event):## FIXME
        common.EventWidget.__init__(self, event)
        ######
        sizeGroup = gtk.SizeGroup(gtk.SIZE_GROUP_HORIZONTAL)
        ######
        hbox = gtk.HBox()
        label = gtk.Label(_('Start'))
        label.set_alignment(0, 0.5)
        sizeGroup.add_widget(label)
        hbox.pack_start(label, 0, 0)
        self.startDateInput = DateButton()
        hbox.pack_start(self.startDateInput, 0, 0)
        ##
        hbox.pack_start(gtk.Label(' '+_('Time')), 0, 0)
        self.startTimeInput = TimeButton()
        hbox.pack_start(self.startTimeInput, 0, 0)
        ##
        self.pack_start(hbox, 0, 0)
        ######
        hbox = gtk.HBox()
        self.endTypeCombo = gtk.combo_box_new_text()
        for item in ('Duration', 'End'):
            self.endTypeCombo.append_text(_(item))
        self.endTypeCombo.connect('changed', self.endTypeComboChanged)
        sizeGroup.add_widget(self.endTypeCombo)
        hbox.pack_start(self.endTypeCombo, 0, 0)
        ####
        self.durationBox = common.DurationInputBox()
        hbox.pack_start(self.durationBox, 1, 1)
        ####
        self.endDateHbox = gtk.HBox()
        self.endDateInput = DateButton()
        self.endDateHbox.pack_start(self.endDateInput, 0, 0)
        ##
        self.endDateHbox.pack_start(gtk.Label(' '+_('Time')), 0, 0)
        self.endTimeInput = TimeButton()
        self.endDateHbox.pack_start(self.endTimeInput, 0, 0)
        ##
        hbox.pack_start(self.endDateHbox, 1, 1)
        ####
        hbox.pack_start(gtk.Label(''), 1, 1)
        self.pack_start(hbox, 0, 0)
        #############
        self.notificationBox = common.NotificationBox(event)
        self.pack_start(self.notificationBox, 0, 0)
        #############
        #self.filesBox = common.FilesBox(self.event)
        #self.pack_start(self.filesBox, 0, 0)
    def endTypeComboChanged(self, combo=None):
        active = self.endTypeCombo.get_active()
        if active==0:## duration
            self.durationBox.show()
            self.endDateHbox.hide()
        elif active==1:## end date
            self.durationBox.hide()
            self.endDateHbox.show()
        else:
            raise RuntimeError
    def updateWidget(self):## FIXME
        common.EventWidget.updateWidget(self)
        ###
        (startDate, startTime) = self.event.getStart()
        self.startDateInput.set_value(startDate)
        self.startTimeInput.set_value(startTime)
        ###
        (endType, values) = self.event.getEnd()
        if endType=='duration':
            self.endTypeCombo.set_active(0)
            self.durationBox.setDuration(*values)
            self.endDateInput.set_value(startDate)## FIXME
            self.endTimeInput.set_value(startTime)## FIXME
        elif endType=='date':
            self.endTypeCombo.set_active(1)
            self.endDateInput.set_value(values[0])
            self.endTimeInput.set_value(values[1])
        else:
            raise RuntimeError
        self.endTypeComboChanged()
    def updateVars(self):## FIXME
        common.EventWidget.updateVars(self)
        self.event.setStart(self.startDateInput.get_value(), self.startTimeInput.get_value())
        ###
        active = self.endTypeCombo.get_active()
        if active==0:
            self.event.setEnd('duration', *self.durationBox.getDuration())
        elif active==1:
            self.event.setEnd(
                'date',
                self.endDateInput.get_value(),
                self.endTimeInput.get_value(),
            )
    def modeComboChanged(self, obj=None):## overwrite method from common.EventWidget
        newMode = self.modeCombo.get_active()
        self.startDateInput.changeMode(self.event.mode, newMode)
        self.endDateInput.changeMode(self.event.mode, newMode)
        self.event.mode = newMode
Пример #20
0
 def __init__(self):## parent FIXME
     gtk.Dialog.__init__(self)
     self.set_title(_('Tune Hijri Monthes'))
     self.connect('delete-event', self.onDeleteEvent)
     ############
     self.altMode = 0
     self.altModeDesc = 'Gregorian'
     ############
     hbox = gtk.HBox()
     self.topLabel = gtk.Label()
     hbox.pack_start(self.topLabel, 0, 0)
     self.startDateInput = DateButton()
     self.startDateInput.set_editable(False)## FIXME
     self.startDateInput.connect('changed', lambda widget: self.updateEndDates())
     hbox.pack_start(self.startDateInput, 0, 0)
     self.vbox.pack_start(hbox, 0, 0)
     ############################
     treev = gtk.TreeView()
     trees = gtk.ListStore(int, str, str, int, str)## ym, yearShown, monthShown, monthLenCombo, endDateShown
     treev.set_model(trees)
     #treev.connect('cursor-changed', self.plugTreevCursorChanged)
     #treev.connect('row-activated', self.plugTreevRActivate)
     #treev.connect('button-press-event', self.plugTreevButtonPress)
     ###
     swin = gtk.ScrolledWindow()
     swin.add(treev)
     swin.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
     ######
     cell = gtk.CellRendererText()
     col = gtk.TreeViewColumn(_('Year'), cell, text=1)
     treev.append_column(col)
     ######
     cell = gtk.CellRendererText()
     col = gtk.TreeViewColumn(_('Month'), cell, text=2)
     treev.append_column(col)
     ######
     cell = gtk.CellRendererCombo()
     mLenModel = gtk.ListStore(int)
     mLenModel.append([29])
     mLenModel.append([30])
     cell.set_property('model', mLenModel)
     #cell.set_property('has-entry', False)
     cell.set_property('editable', True)
     cell.set_property('text-column', 0)
     cell.connect('edited', self.monthLenCellEdited)
     col = gtk.TreeViewColumn(_('Month Length'), cell, text=3)
     treev.append_column(col)
     ######
     cell = gtk.CellRendererText()
     col = gtk.TreeViewColumn(_('End Date'), cell, text=4)
     treev.append_column(col)
     ######
     self.treev = treev
     self.trees = trees
     self.vbox.pack_start(swin, 1, 1)
     ######
     dialog_add_button(self, gtk.STOCK_OK, _('_OK'), gtk.RESPONSE_OK)
     dialog_add_button(self, gtk.STOCK_CANCEL, _('_Cancel'), gtk.RESPONSE_CANCEL)
     ##
     resetB = self.add_button(gtk.STOCK_UNDO, gtk.RESPONSE_NONE)
     resetB.set_label(_('_Reset to Defaults'))
     resetB.set_image(gtk.image_new_from_stock(gtk.STOCK_UNDO, gtk.ICON_SIZE_BUTTON))
     resetB.connect('clicked', self.resetToDefaults)
     ##
     self.connect('response', self.onResponse)
     #print dir(self.get_action_area())
     #self.get_action_area().set_homogeneous(False)
     ######
     self.vbox.show_all()
Пример #21
0
class EditDbDialog(gtk.Dialog):
    def __init__(self):## parent FIXME
        gtk.Dialog.__init__(self)
        self.set_title(_('Tune Hijri Monthes'))
        self.connect('delete-event', self.onDeleteEvent)
        ############
        self.altMode = 0
        self.altModeDesc = 'Gregorian'
        ############
        hbox = gtk.HBox()
        self.topLabel = gtk.Label()
        hbox.pack_start(self.topLabel, 0, 0)
        self.startDateInput = DateButton()
        self.startDateInput.set_editable(False)## FIXME
        self.startDateInput.connect('changed', lambda widget: self.updateEndDates())
        hbox.pack_start(self.startDateInput, 0, 0)
        self.vbox.pack_start(hbox, 0, 0)
        ############################
        treev = gtk.TreeView()
        trees = gtk.ListStore(int, str, str, int, str)## ym, yearShown, monthShown, monthLenCombo, endDateShown
        treev.set_model(trees)
        #treev.connect('cursor-changed', self.plugTreevCursorChanged)
        #treev.connect('row-activated', self.plugTreevRActivate)
        #treev.connect('button-press-event', self.plugTreevButtonPress)
        ###
        swin = gtk.ScrolledWindow()
        swin.add(treev)
        swin.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        ######
        cell = gtk.CellRendererText()
        col = gtk.TreeViewColumn(_('Year'), cell, text=1)
        treev.append_column(col)
        ######
        cell = gtk.CellRendererText()
        col = gtk.TreeViewColumn(_('Month'), cell, text=2)
        treev.append_column(col)
        ######
        cell = gtk.CellRendererCombo()
        mLenModel = gtk.ListStore(int)
        mLenModel.append([29])
        mLenModel.append([30])
        cell.set_property('model', mLenModel)
        #cell.set_property('has-entry', False)
        cell.set_property('editable', True)
        cell.set_property('text-column', 0)
        cell.connect('edited', self.monthLenCellEdited)
        col = gtk.TreeViewColumn(_('Month Length'), cell, text=3)
        treev.append_column(col)
        ######
        cell = gtk.CellRendererText()
        col = gtk.TreeViewColumn(_('End Date'), cell, text=4)
        treev.append_column(col)
        ######
        self.treev = treev
        self.trees = trees
        self.vbox.pack_start(swin, 1, 1)
        ######
        dialog_add_button(self, gtk.STOCK_OK, _('_OK'), gtk.RESPONSE_OK)
        dialog_add_button(self, gtk.STOCK_CANCEL, _('_Cancel'), gtk.RESPONSE_CANCEL)
        ##
        resetB = self.add_button(gtk.STOCK_UNDO, gtk.RESPONSE_NONE)
        resetB.set_label(_('_Reset to Defaults'))
        resetB.set_image(gtk.image_new_from_stock(gtk.STOCK_UNDO, gtk.ICON_SIZE_BUTTON))
        resetB.connect('clicked', self.resetToDefaults)
        ##
        self.connect('response', self.onResponse)
        #print dir(self.get_action_area())
        #self.get_action_area().set_homogeneous(False)
        ######
        self.vbox.show_all()
    def resetToDefaults(self, widget):
        if isfile(monthDb.userDbPath):
            os.remove(monthDb.userDbPath)
        monthDb.load()
        self.updateWidget()
        return True
    def updateWidget(self):
        #for index, module in enumerate(core.modules):
        #    if module.name != 'hijri':
        for item in ui.shownCals:
            mode = item['mode']
            modeDesc = moduleDescNames[mode]
            if not 'hijri' in modeDesc.lower():
                self.altMode = mode
                self.altModeDesc = modeDesc
                break
        self.topLabel.set_label(_('Start')+': '+dateLocale(*monthDb.startDate)+' '+_('Equals to')+' %s'%_(self.altModeDesc))
        self.startDateInput.set_value(jd_to(monthDb.startJd, self.altMode))
        ###########
        selectYm = getCurrentYm() - 1 ## previous month
        selectIndex = None
        self.trees.clear()
        for index, ym, mLen in monthDb.getMonthLenList():
            if ym == selectYm:
                selectIndex = index
            (year, month0) = divmod(ym, 12)
            self.trees.append([
                ym,
                _(year),
                _(monthName[month0]),
                mLen,
                '',
            ])
        self.updateEndDates()
        ########
        if selectIndex is not None:
            self.treev.scroll_to_cell(str(selectIndex))
            self.treev.set_cursor(str(selectIndex))
    def updateEndDates(self):
        (y, m, d) = self.startDateInput.get_value()
        jd0 = to_jd(y, m, d, self.altMode) - 1
        for row in self.trees:
            mLen = row[3]
            jd0 += mLen
            row[4] = dateLocale(*jd_to(jd0, self.altMode))
    def monthLenCellEdited(self, combo, path_string, new_text):
        editIndex = int(path_string)
        mLen = int(new_text)
        if not mLen in (29, 30):
            return
        mLenPrev = self.trees[editIndex][3]
        delta = mLen - mLenPrev
        if delta == 0:
            return
        n = len(self.trees)
        self.trees[editIndex][3] = mLen
        if delta==1:
            for i in range(editIndex+1, n):
                if self.trees[i][3] == 30:
                    self.trees[i][3] = 29
                    break
        elif delta==-1:
            for i in range(editIndex+1, n):
                if self.trees[i][3] == 29:
                    self.trees[i][3] = 30
                    break
        self.updateEndDates()
    def updateVars(self):
        (y, m, d) = self.startDateInput.get_value()
        monthDb.endJd = monthDb.startJd = to_jd(y, m, d, self.altMode)
        monthDb.monthLenByYm = {}
        for row in self.trees:
            ym = row[0]
            mLen = row[3]
            monthDb.monthLenByYm[ym] = mLen
            monthDb.endJd += mLen
        monthDb.save()
    def run(self):
        monthDb.load()
        self.updateWidget()
        self.treev.grab_focus()
        gtk.Dialog.run(self)
    def onResponse(self, dialog, response_id):
        if response_id==gtk.RESPONSE_OK:
            self.updateVars()
            self.destroy()
        elif response_id==gtk.RESPONSE_CANCEL:
            self.destroy()
        return True
    def onDeleteEvent(self, dialog, event):
        self.destroy()
        return True
Пример #22
0
class EventWidget(common.EventWidget):
    def __init__(self, event):## FIXME
        common.EventWidget.__init__(self, event)
        ######
        sizeGroup = gtk.SizeGroup(gtk.SIZE_GROUP_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(self, hbox)
        ######
        hbox = gtk.HBox()
        self.endTypeCombo = gtk.combo_box_new_text()
        for item in ('Duration', 'End'):
            self.endTypeCombo.append_text(_(item))
        self.endTypeCombo.connect('changed', self.endTypeComboChanged)
        sizeGroup.add_widget(self.endTypeCombo)
        pack(hbox, self.endTypeCombo)
        ####
        self.durationBox = gtk.HBox()
        self.durationSpin = IntSpinButton(1, 999)
        pack(self.durationBox, self.durationSpin)
        pack(self.durationBox, gtk.Label(_(' days')))
        pack(hbox, self.durationBox)
        ####
        self.endDateInput = DateButton()
        pack(hbox, self.endDateInput)
        ####
        pack(hbox, gtk.Label(''), 1, 1)
        pack(self, hbox)
        #############
        self.notificationBox = common.NotificationBox(event)
        pack(self, self.notificationBox)
        #############
        #self.filesBox = common.FilesBox(self.event)
        #pack(self, self.filesBox)
    def endTypeComboChanged(self, combo=None):
        active = self.endTypeCombo.get_active()
        if active==0:## duration
            self.durationBox.show()
            self.endDateInput.hide()
        elif active==1:## end date
            self.durationBox.hide()
            self.endDateInput.show()
        else:
            raise RuntimeError
    def updateWidget(self):## FIXME
        common.EventWidget.updateWidget(self)
        mode = self.event.mode
        ###
        startJd = self.event.getJd()
        self.startDateInput.set_value(jd_to(startJd, mode))
        ###
        endType, endValue = self.event.getEnd()
        if endType=='duration':
            self.endTypeCombo.set_active(0)
            self.durationSpin.set_value(endValue)
            self.endDateInput.set_value(jd_to(self.event.getEndJd(), mode))## FIXME
        elif endType=='date':
            self.endTypeCombo.set_active(1)
            self.endDateInput.set_value(endValue)
        else:
            raise RuntimeError
        self.endTypeComboChanged()
    def updateVars(self):## FIXME
        common.EventWidget.updateVars(self)
        self.event.setStartDate(self.startDateInput.get_value())
        ###
        active = self.endTypeCombo.get_active()
        if active==0:
            self.event.setEnd('duration', self.durationSpin.get_value())
        elif active==1:
            self.event.setEnd(
                'date',
                self.endDateInput.get_value(),
            )
    def modeComboChanged(self, obj=None):## overwrite method from common.EventWidget
        newMode = self.modeCombo.get_active()
        self.startDateInput.changeMode(self.event.mode, newMode)
        self.endDateInput.changeMode(self.event.mode, newMode)
        self.event.mode = newMode
Пример #23
0
class EventWidget(gtk.VBox):
    def __init__(self, event):## FIXME
        gtk.VBox.__init__(self)
        self.event = event
        assert event.parent.name == 'universityTerm' ## FIXME
        sizeGroup = gtk.SizeGroup(gtk.SIZE_GROUP_HORIZONTAL)
        #####
        if not event.parent.courses:
            showError(event.parent.noCourseError)
            raise RuntimeError('No courses added')
        self.courseIds = []
        self.courseNames = []
        combo = gtk.combo_box_new_text()
        for course in event.parent.courses:
            self.courseIds.append(course[0])
            self.courseNames.append(course[1])
            combo.append_text(course[1])
        #combo.connect('changed', self.updateSummary)
        self.courseCombo = combo
        ##
        hbox = gtk.HBox()
        label = gtk.Label(_('Course'))
        label.set_alignment(0, 0.5)
        sizeGroup.add_widget(label)
        hbox.pack_start(label, 0, 0)
        hbox.pack_start(combo, 0, 0)
        ##
        self.pack_start(hbox, 0, 0)
        #####
        hbox = gtk.HBox()
        label = gtk.Label(_('Date'))
        label.set_alignment(0, 0.5)
        sizeGroup.add_widget(label)
        hbox.pack_start(label, 0, 0)
        self.dateInput = DateButton()
        hbox.pack_start(self.dateInput, 0, 0)
        self.pack_start(hbox, 0, 0)
        #####
        hbox = gtk.HBox()
        label = gtk.Label(_('Time'))
        label.set_alignment(0, 0.5)
        sizeGroup.add_widget(label)
        hbox.pack_start(label, 0, 0)
        ##
        self.dayTimeStartCombo = HourMinuteButton()
        self.dayTimeEndCombo = HourMinuteButton()
        ##
        #self.dayTimeStartCombo.child.set_direction(gtk.TEXT_DIR_LTR)
        #self.dayTimeEndCombo.child.set_direction(gtk.TEXT_DIR_LTR)
        ##
        hbox.pack_start(self.dayTimeStartCombo, 0, 0)
        hbox.pack_start(gtk.Label(' ' + _('to') + ' '), 0, 0)
        hbox.pack_start(self.dayTimeEndCombo, 0, 0)
        self.pack_start(hbox, 0, 0)
        ###########
        #hbox = gtk.HBox()
        #label = gtk.Label(_('Summary'))
        #label.set_alignment(0, 0.5)
        #sizeGroup.add_widget(label)
        #hbox.pack_start(label, 0, 0)
        #self.summaryEntry = gtk.Entry()
        #hbox.pack_start(self.summaryEntry, 1, 1)
        #self.pack_start(hbox, 0, 0)
        #####
        hbox = gtk.HBox()
        label = gtk.Label(_('Description'))
        label.set_alignment(0, 0.5)
        sizeGroup.add_widget(label)
        hbox.pack_start(label, 0, 0)
        self.descriptionInput = TextFrame()
        hbox.pack_start(self.descriptionInput, 1, 1)
        self.pack_start(hbox, 0, 0)
        #####
        hbox = gtk.HBox()
        label = gtk.Label(_('Icon'))
        label.set_alignment(0, 0.5)
        sizeGroup.add_widget(label)
        hbox.pack_start(label, 0, 0)
        self.iconSelect = common.IconSelectButton()
        #print join(pixDir, self.icon)
        hbox.pack_start(self.iconSelect, 0, 0)
        hbox.pack_start(gtk.Label(''), 1, 1)
        self.pack_start(hbox, 0, 0)
        ######
        self.notificationBox = common.NotificationBox(event)
        self.pack_start(self.notificationBox, 0, 0)
        ######
        #self.filesBox = common.FilesBox(self.event)
        #self.pack_start(self.filesBox, 0, 0)
        ######
        self.courseCombo.set_active(0)
        #self.updateSummary()
    def focusSummary(self):
        pass
    #def updateSummary(self, widget=None):
    #    courseIndex = self.courseCombo.get_active()
    #    summary = _('%s Exam')%self.courseNames[courseIndex]
    #    self.summaryEntry.set_text(summary)
    #    self.event.summary = summary
    def updateWidget(self):## FIXME
        if self.event.courseId is None:
            pass
        else:
            self.courseCombo.set_active(self.courseIds.index(self.event.courseId))
        ##
        self.dateInput.set_value(self.event.getDate())
        ##
        timeRangeRule = self.event['dayTimeRange']
        self.dayTimeStartCombo.set_value(timeRangeRule.dayTimeStart)
        self.dayTimeEndCombo.set_value(timeRangeRule.dayTimeEnd)
        ####
        #self.summaryEntry.set_text(self.event.summary)
        self.descriptionInput.set_text(self.event.description)
        self.iconSelect.set_filename(self.event.icon)
        ####
        self.notificationBox.updateWidget()
        ####
        #self.filesBox.updateWidget()
    def updateVars(self):## FIXME
        courseIndex = self.courseCombo.get_active()
        if courseIndex is None:
            showError(_('No course is selected'), self)
            raise RuntimeError('No courses is selected')
        else:
            self.event.courseId = self.courseIds[courseIndex]
        ##
        self.event.setDate(*tuple(self.dateInput.get_value()))
        ##
        self.event['dayTimeRange'].setRange(
            self.dayTimeStartCombo.get_value(),
            self.dayTimeEndCombo.get_value(),
        )
        ####
        #self.event.summary = self.summaryEntry.get_text()
        self.event.description = self.descriptionInput.get_text()
        self.event.icon = self.iconSelect.get_filename()
        ####
        self.notificationBox.updateVars()
        self.event.updateSummary()
    def modeComboChanged(self, obj=None):## overwrite method from common.EventWidget
        newMode = self.modeCombo.get_active()
        self.dateInput.changeMode(self.event.mode, newMode)
        self.event.mode = newMode
Пример #24
0
 def __init__(self):
     gtk.Dialog.__init__(self)
     self.set_title(_('Adjust System Date & Time'))##????????
     self.set_icon(self.render_icon(gtk.STOCK_PREFERENCES, gtk.ICON_SIZE_BUTTON))
     #########
     self.buttonCancel = self.add_button(gtk.STOCK_CANCEL, 0)
     #self.buttonCancel.connect('clicked', lambda w: sys.exit(0))
     self.buttonSet = self.add_button(_('Set System Time'), 1)
     #self.buttonSet.connect('clicked', self.setSysTimeClicked)
     #########
     hbox = gtk.HBox()
     self.label_cur = gtk.Label(_('Current:'))
     hbox.pack_start(self.label_cur, 0, 0)
     self.vbox.pack_start(hbox, 0, 0)
     #########
     hbox = gtk.HBox()
     self.radioMan = gtk.RadioButton(None, _('Set _Manully:'), True)
     self.radioMan.connect('clicked', self.radioManClicked)
     hbox.pack_start(self.radioMan, 0, 0)
     self.vbox.pack_start(hbox, 0, 0)
     ######
     vb = gtk.VBox()
     sg = gtk.SizeGroup(gtk.SIZE_GROUP_HORIZONTAL)
     ###
     hbox = gtk.HBox()
     ##
     l = gtk.Label('')
     l.set_property('width-request', self.xpad)
     hbox.pack_start(l, 0, 0)
     ##
     self.ckeckbEditTime = gtk.CheckButton(_('Edit Time'))
     self.editTime = False
     self.ckeckbEditTime.connect('clicked', self.ckeckbEditTimeClicked)
     hbox.pack_start(self.ckeckbEditTime, 0, 0)
     sg.add_widget(self.ckeckbEditTime)
     self.timeInput = TimeButton() ## ??????? options
     hbox.pack_start(self.timeInput, 0, 0)
     vb.pack_start(hbox, 0, 0)
     ###
     hbox = gtk.HBox()
     ##
     l = gtk.Label('')
     l.set_property('width-request', self.xpad)
     hbox.pack_start(l, 0, 0)
     ##
     self.ckeckbEditDate = gtk.CheckButton(_('Edit Date'))
     self.editDate = False
     self.ckeckbEditDate.connect('clicked', self.ckeckbEditDateClicked)
     hbox.pack_start(self.ckeckbEditDate, 0, 0)
     sg.add_widget(self.ckeckbEditDate)
     self.dateInput = DateButton() ## ??????? options
     hbox.pack_start(self.dateInput, 0, 0)
     vb.pack_start(hbox, 0, 0)
     ###
     self.vbox.pack_start(vb, 0, 0, 10)#?????
     self.vboxMan = vb
     ######
     hbox = gtk.HBox()
     self.radioNtp = gtk.RadioButton(self.radioMan, _('Set from _NTP:'), True)
     self.radioNtp.connect('clicked', self.radioNtpClicked)
     hbox.pack_start(self.radioNtp, 0, 0)
     self.vbox.pack_start(hbox, 0, 0)
     ###
     hbox = gtk.HBox()
     ##
     l = gtk.Label('')
     l.set_property('width-request', self.xpad)
     hbox.pack_start(l, 0, 0)
     ##
     hbox.pack_start(gtk.Label(_('Server:')+' '), 0, 0)
     combo = gtk.combo_box_entry_new_text()
     combo.child.connect('changed', self.updateSetButtonSensitive)
     hbox.pack_start(combo, 1, 1)
     self.ntpServerEntry = combo.child
     for s in ui.ntpServers:
         combo.append_text(s)
     combo.set_active(0)
     self.hboxNtp = hbox
     self.vbox.pack_start(hbox, 0, 0)
     ######
     self.radioManClicked()
     #self.radioNtpClicked()
     self.ckeckbEditTimeClicked()
     self.ckeckbEditDateClicked()
     ######
     self.updateTimes()
     self.vbox.show_all()
Пример #25
0
 def __init__(self, event):## FIXME
     gtk.VBox.__init__(self)
     self.event = event
     assert event.parent.name == 'universityTerm' ## FIXME
     sizeGroup = gtk.SizeGroup(gtk.SIZE_GROUP_HORIZONTAL)
     #####
     if not event.parent.courses:
         showError(event.parent.noCourseError)
         raise RuntimeError('No courses added')
     self.courseIds = []
     self.courseNames = []
     combo = gtk.combo_box_new_text()
     for course in event.parent.courses:
         self.courseIds.append(course[0])
         self.courseNames.append(course[1])
         combo.append_text(course[1])
     #combo.connect('changed', self.updateSummary)
     self.courseCombo = combo
     ##
     hbox = gtk.HBox()
     label = gtk.Label(_('Course'))
     label.set_alignment(0, 0.5)
     sizeGroup.add_widget(label)
     hbox.pack_start(label, 0, 0)
     hbox.pack_start(combo, 0, 0)
     ##
     self.pack_start(hbox, 0, 0)
     #####
     hbox = gtk.HBox()
     label = gtk.Label(_('Date'))
     label.set_alignment(0, 0.5)
     sizeGroup.add_widget(label)
     hbox.pack_start(label, 0, 0)
     self.dateInput = DateButton()
     hbox.pack_start(self.dateInput, 0, 0)
     self.pack_start(hbox, 0, 0)
     #####
     hbox = gtk.HBox()
     label = gtk.Label(_('Time'))
     label.set_alignment(0, 0.5)
     sizeGroup.add_widget(label)
     hbox.pack_start(label, 0, 0)
     ##
     self.dayTimeStartCombo = HourMinuteButton()
     self.dayTimeEndCombo = HourMinuteButton()
     ##
     #self.dayTimeStartCombo.child.set_direction(gtk.TEXT_DIR_LTR)
     #self.dayTimeEndCombo.child.set_direction(gtk.TEXT_DIR_LTR)
     ##
     hbox.pack_start(self.dayTimeStartCombo, 0, 0)
     hbox.pack_start(gtk.Label(' ' + _('to') + ' '), 0, 0)
     hbox.pack_start(self.dayTimeEndCombo, 0, 0)
     self.pack_start(hbox, 0, 0)
     ###########
     #hbox = gtk.HBox()
     #label = gtk.Label(_('Summary'))
     #label.set_alignment(0, 0.5)
     #sizeGroup.add_widget(label)
     #hbox.pack_start(label, 0, 0)
     #self.summaryEntry = gtk.Entry()
     #hbox.pack_start(self.summaryEntry, 1, 1)
     #self.pack_start(hbox, 0, 0)
     #####
     hbox = gtk.HBox()
     label = gtk.Label(_('Description'))
     label.set_alignment(0, 0.5)
     sizeGroup.add_widget(label)
     hbox.pack_start(label, 0, 0)
     self.descriptionInput = TextFrame()
     hbox.pack_start(self.descriptionInput, 1, 1)
     self.pack_start(hbox, 0, 0)
     #####
     hbox = gtk.HBox()
     label = gtk.Label(_('Icon'))
     label.set_alignment(0, 0.5)
     sizeGroup.add_widget(label)
     hbox.pack_start(label, 0, 0)
     self.iconSelect = common.IconSelectButton()
     #print join(pixDir, self.icon)
     hbox.pack_start(self.iconSelect, 0, 0)
     hbox.pack_start(gtk.Label(''), 1, 1)
     self.pack_start(hbox, 0, 0)
     ######
     self.notificationBox = common.NotificationBox(event)
     self.pack_start(self.notificationBox, 0, 0)
     ######
     #self.filesBox = common.FilesBox(self.event)
     #self.pack_start(self.filesBox, 0, 0)
     ######
     self.courseCombo.set_active(0)
Пример #26
0
class EventWidget(common.EventWidget):
    def __init__(self, event):  ## FIXME
        common.EventWidget.__init__(self, event)
        ######
        sizeGroup = gtk.SizeGroup(gtk.SIZE_GROUP_HORIZONTAL)
        ######
        hbox = gtk.HBox()
        label = gtk.Label(_("Start"))
        label.set_alignment(0, 0.5)
        sizeGroup.add_widget(label)
        hbox.pack_start(label, 0, 0)
        self.startDateInput = DateButton()
        hbox.pack_start(self.startDateInput, 0, 0)
        ##
        self.pack_start(hbox, 0, 0)
        ######
        hbox = gtk.HBox()
        self.endTypeCombo = gtk.combo_box_new_text()
        for item in ("Duration", "End"):
            self.endTypeCombo.append_text(_(item))
        self.endTypeCombo.connect("changed", self.endTypeComboChanged)
        sizeGroup.add_widget(self.endTypeCombo)
        hbox.pack_start(self.endTypeCombo, 0, 0)
        ####
        self.durationBox = gtk.HBox()
        self.durationSpin = IntSpinButton(1, 999)
        self.durationBox.pack_start(self.durationSpin, 0, 0)
        self.durationBox.pack_start(gtk.Label(_(" days")), 0, 0)
        hbox.pack_start(self.durationBox, 0, 0)
        ####
        self.endDateInput = DateButton()
        hbox.pack_start(self.endDateInput, 0, 0)
        ####
        hbox.pack_start(gtk.Label(""), 1, 1)
        self.pack_start(hbox, 0, 0)
        #############
        self.notificationBox = common.NotificationBox(event)
        self.pack_start(self.notificationBox, 0, 0)
        #############
        # self.filesBox = common.FilesBox(self.event)
        # self.pack_start(self.filesBox, 0, 0)

    def endTypeComboChanged(self, combo=None):
        active = self.endTypeCombo.get_active()
        if active == 0:  ## duration
            self.durationBox.show()
            self.endDateInput.hide()
        elif active == 1:  ## end date
            self.durationBox.hide()
            self.endDateInput.show()
        else:
            raise RuntimeError

    def updateWidget(self):  ## FIXME
        common.EventWidget.updateWidget(self)
        mode = self.event.mode
        ###
        startJd = self.event.getJd()
        self.startDateInput.set_value(jd_to(startJd, mode))
        ###
        (endType, endValue) = self.event.getEnd()
        if endType == "duration":
            self.endTypeCombo.set_active(0)
            self.durationSpin.set_value(endValue)
            self.endDateInput.set_value(jd_to(self.event.getEndJd(), mode))  ## FIXME
        elif endType == "date":
            self.endTypeCombo.set_active(1)
            self.endDateInput.set_value(endValue)
        else:
            raise RuntimeError
        self.endTypeComboChanged()

    def updateVars(self):  ## FIXME
        common.EventWidget.updateVars(self)
        self.event.setStartDate(self.startDateInput.get_value())
        ###
        active = self.endTypeCombo.get_active()
        if active == 0:
            self.event.setEnd("duration", self.durationSpin.get_value())
        elif active == 1:
            self.event.setEnd("date", self.endDateInput.get_value())

    def modeComboChanged(self, obj=None):  ## overwrite method from common.EventWidget
        newMode = self.modeCombo.get_active()
        self.startDateInput.changeMode(self.event.mode, newMode)
        self.endDateInput.changeMode(self.event.mode, newMode)
        self.event.mode = newMode
Пример #27
0
class EventWidget(common.EventWidget):
    def __init__(self, event):## FIXME
        common.EventWidget.__init__(self, event)
        ######
        sizeGroup = gtk.SizeGroup(gtk.SIZE_GROUP_HORIZONTAL)
        ######
        hbox = gtk.HBox()
        label = gtk.Label(_('Start'))
        label.set_alignment(0, 0.5)
        sizeGroup.add_widget(label)
        hbox.pack_start(label, 0, 0)
        self.startDateInput = DateButton()
        hbox.pack_start(self.startDateInput, 0, 0)
        ###
        hbox.pack_start(gtk.Label(''), 1, 1)
        self.pack_start(hbox, 0, 0)
        ######
        hbox = gtk.HBox()
        label = gtk.Label(_('Repeat Every '))
        label.set_alignment(0, 0.5)
        sizeGroup.add_widget(label)
        hbox.pack_start(label, 0, 0)
        self.weeksSpin = IntSpinButton(1, 99999)
        hbox.pack_start(self.weeksSpin, 0, 0)
        hbox.pack_start(gtk.Label('  '+_(' Weeks')), 0, 0)
        ###
        hbox.pack_start(gtk.Label(''), 1, 1)
        self.pack_start(hbox, 0, 0)
        ######
        hbox = gtk.HBox()
        label = gtk.Label(_('End'))
        label.set_alignment(0, 0.5)
        sizeGroup.add_widget(label)
        hbox.pack_start(label, 0, 0)
        self.endDateInput = DateButton()
        hbox.pack_start(self.endDateInput, 0, 0)
        ###
        hbox.pack_start(gtk.Label(''), 1, 1)
        self.pack_start(hbox, 0, 0)
        #########
        hbox = gtk.HBox()
        label = gtk.Label(_('Time'))
        label.set_alignment(0, 0.5)
        sizeGroup.add_widget(label)
        hbox.pack_start(label, 0, 0)
        ##
        self.dayTimeStartInput = HourMinuteButton()
        self.dayTimeEndInput = HourMinuteButton()
        ##
        hbox.pack_start(self.dayTimeStartInput, 0, 0)
        hbox.pack_start(gtk.Label(' ' + _('to') + ' '), 0, 0)
        hbox.pack_start(self.dayTimeEndInput, 0, 0)
        self.pack_start(hbox, 0, 0)
        #############
        #self.notificationBox = common.NotificationBox(event)
        #self.pack_start(self.notificationBox, 0, 0)
        #############
        #self.filesBox = common.FilesBox(self.event)
        #self.pack_start(self.filesBox, 0, 0)
    def updateWidget(self):## FIXME
        common.EventWidget.updateWidget(self)
        mode = self.event.mode
        ###
        self.startDateInput.set_value(jd_to(self.event.getStartJd(), mode))
        self.weeksSpin.set_value(self.event['cycleWeeks'].weeks)
        self.endDateInput.set_value(jd_to(self.event.getEndJd(), mode))
        ###
        timeRangeRule = self.event['dayTimeRange']
        self.dayTimeStartInput.set_value(timeRangeRule.dayTimeStart)
        self.dayTimeEndInput.set_value(timeRangeRule.dayTimeEnd)
    def updateVars(self):## FIXME
        common.EventWidget.updateVars(self)
        self.event['start'].setDate(self.startDateInput.get_value())
        self.event['end'].setDate(self.endDateInput.get_value())
        self.event['cycleWeeks'].setData(self.weeksSpin.get_value())
        ###
        self.event['dayTimeRange'].setRange(
            self.dayTimeStartInput.get_value(),
            self.dayTimeEndInput.get_value(),
        )
    def modeComboChanged(self, obj=None):## overwrite method from common.EventWidget
        newMode = self.modeCombo.get_active()
        self.startDateInput.changeMode(self.event.mode, newMode)
        self.endDateInput.changeMode(self.event.mode, newMode)
        self.event.mode = newMode
Пример #28
0
class EventWidget(common.EventWidget):
    def __init__(self, event):  ## FIXME
        common.EventWidget.__init__(self, event)
        ######
        sizeGroup = gtk.SizeGroup(gtk.SIZE_GROUP_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(" " + _("Time")))
        self.startTimeInput = TimeButton()
        pack(hbox, self.startTimeInput)
        ##
        pack(self, hbox)
        ######
        hbox = gtk.HBox()
        self.endTypeCombo = gtk.combo_box_new_text()
        for item in ("Duration", "End"):
            self.endTypeCombo.append_text(_(item))
        self.endTypeCombo.connect("changed", self.endTypeComboChanged)
        sizeGroup.add_widget(self.endTypeCombo)
        pack(hbox, self.endTypeCombo)
        ####
        self.durationBox = common.DurationInputBox()
        pack(hbox, self.durationBox, 1, 1)
        ####
        self.endDateHbox = gtk.HBox()
        self.endDateInput = DateButton()
        pack(self.endDateHbox, self.endDateInput)
        ##
        pack(self.endDateHbox, gtk.Label(" " + _("Time")))
        self.endTimeInput = TimeButton()
        pack(self.endDateHbox, self.endTimeInput)
        ##
        pack(hbox, self.endDateHbox, 1, 1)
        ####
        pack(hbox, gtk.Label(""), 1, 1)
        pack(self, hbox)
        #############
        self.notificationBox = common.NotificationBox(event)
        pack(self, self.notificationBox)
        #############
        # self.filesBox = common.FilesBox(self.event)
        # pack(self, self.filesBox)

    def endTypeComboChanged(self, combo=None):
        active = self.endTypeCombo.get_active()
        if active == 0:  ## duration
            self.durationBox.show()
            self.endDateHbox.hide()
        elif active == 1:  ## end date
            self.durationBox.hide()
            self.endDateHbox.show()
        else:
            raise RuntimeError

    def updateWidget(self):  ## FIXME
        common.EventWidget.updateWidget(self)
        ###
        startDate, startTime = self.event.getStart()
        self.startDateInput.set_value(startDate)
        self.startTimeInput.set_value(startTime)
        ###
        endType, values = self.event.getEnd()
        if endType == "duration":
            self.endTypeCombo.set_active(0)
            self.durationBox.setDuration(*values)
            self.endDateInput.set_value(startDate)  ## FIXME
            self.endTimeInput.set_value(startTime)  ## FIXME
        elif endType == "date":
            self.endTypeCombo.set_active(1)
            self.endDateInput.set_value(values[0])
            self.endTimeInput.set_value(values[1])
        else:
            raise RuntimeError
        self.endTypeComboChanged()

    def updateVars(self):  ## FIXME
        common.EventWidget.updateVars(self)
        self.event.setStart(self.startDateInput.get_value(), self.startTimeInput.get_value())
        ###
        active = self.endTypeCombo.get_active()
        if active == 0:
            self.event.setEnd("duration", *self.durationBox.getDuration())
        elif active == 1:
            self.event.setEnd("date", self.endDateInput.get_value(), self.endTimeInput.get_value())

    def modeComboChanged(self, obj=None):  ## overwrite method from common.EventWidget
        newMode = self.modeCombo.get_active()
        self.startDateInput.changeMode(self.event.mode, newMode)
        self.endDateInput.changeMode(self.event.mode, newMode)
        self.event.mode = newMode
Пример #29
0
 def __init__(self, rule):
     self.rule = rule
     DateButton.__init__(self)