Exemple #1
0
class RuleWidget(gtk.HBox):
    def __init__(self, rule):
        self.rule = rule
        ###
        gtk.HBox.__init__(self)
        ###
        self.startTbox = TimeButton()
        self.endTbox = TimeButton()
        pack(self, self.startTbox)
        pack(self, gtk.Label(' ' + _('to') + ' '))
        pack(self, self.endTbox)
    def updateWidget(self):
        self.startTbox.set_value(self.rule.dayTimeStart)
        self.endTbox.set_value(self.rule.dayTimeEnd)
    def updateVars(self):
        self.rule.dayTimeStart = self.startTbox.get_value()
        self.rule.dayTimeEnd = self.endTbox.get_value()
Exemple #2
0
class RuleWidget(gtk.HBox):
    def __init__(self, rule):
        self.rule = rule
        ###
        gtk.HBox.__init__(self)
        ###
        self.startTbox = TimeButton()
        self.endTbox = TimeButton()
        self.pack_start(self.startTbox, 0, 0)
        self.pack_start(gtk.Label(" " + _("to") + " "), 0, 0)
        self.pack_start(self.endTbox, 0, 0)

    def updateWidget(self):
        self.startTbox.set_value(self.rule.dayTimeStart)
        self.endTbox.set_value(self.rule.dayTimeEnd)

    def updateVars(self):
        self.rule.dayTimeStart = self.startTbox.get_value()
        self.rule.dayTimeEnd = self.endTbox.get_value()
Exemple #3
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))
Exemple #4
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
Exemple #5
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)#??????????
Exemple #6
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