Beispiel #1
0
class WidgetClass(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()
Beispiel #2
0
class WidgetClass(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()
Beispiel #3
0
class WidgetClass(gtk.HBox):
    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)
    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))
Beispiel #4
0
class WidgetClass(gtk.HBox):
	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)
	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):
		if mode == self.rule.getMode():
			return
		self.updateVars()
		self.rule.changeMode(mode)
		self.updateWidget()
Beispiel #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:'))
        pack(hbox, self.label_cur)
        pack(self.vbox, hbox)
        #########
        hbox = gtk.HBox()
        self.radioMan = gtk.RadioButton(None, _('Set _Manully:'), True)
        self.radioMan.connect('clicked', self.radioManClicked)
        pack(hbox, self.radioMan)
        pack(self.vbox, hbox)
        ######
        vb = gtk.VBox()
        sg = gtk.SizeGroup(gtk.SIZE_GROUP_HORIZONTAL)
        ###
        hbox = gtk.HBox()
        ##
        l = gtk.Label('')
        l.set_property('width-request', self.xpad)
        pack(hbox, l)
        ##
        self.ckeckbEditTime = gtk.CheckButton(_('Edit Time'))
        self.editTime = False
        self.ckeckbEditTime.connect('clicked', self.ckeckbEditTimeClicked)
        pack(hbox, self.ckeckbEditTime)
        sg.add_widget(self.ckeckbEditTime)
        self.timeInput = TimeButton() ## ??????? options
        pack(hbox, self.timeInput)
        pack(vb, hbox)
        ###
        hbox = gtk.HBox()
        ##
        l = gtk.Label('')
        l.set_property('width-request', self.xpad)
        pack(hbox, l)
        ##
        self.ckeckbEditDate = gtk.CheckButton(_('Edit Date'))
        self.editDate = False
        self.ckeckbEditDate.connect('clicked', self.ckeckbEditDateClicked)
        pack(hbox, self.ckeckbEditDate)
        sg.add_widget(self.ckeckbEditDate)
        self.dateInput = DateButton() ## ??????? options
        pack(hbox, self.dateInput)
        pack(vb, hbox)
        ###
        pack(self.vbox, 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)
        pack(hbox, self.radioNtp)
        pack(self.vbox, hbox)
        ###
        hbox = gtk.HBox()
        ##
        l = gtk.Label('')
        l.set_property('width-request', self.xpad)
        pack(hbox, l)
        ##
        pack(hbox, gtk.Label(_('Server:')+' '))
        combo = gtk.combo_box_entry_new_text()
        combo.get_child().connect('changed', self.updateSetButtonSensitive)
        pack(hbox, combo, 1, 1)
        self.ntpServerEntry = combo.get_child()
        for s in ui.ntpServers:
            combo.append_text(s)
        combo.set_active(0)
        self.hboxNtp = hbox
        pack(self.vbox, hbox)
        ######
        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 = now()%1
        timeout_add(iceil(1000*(1-dt)), self.updateTimes)
        #print('updateTimes', dt)
        lt = 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 = 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)#??????????
Beispiel #6
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:'))
		pack(hbox, self.label_cur)
		pack(self.vbox, hbox)
		#########
		hbox = gtk.HBox()
		self.radioMan = gtk.RadioButton(None, _('Set _Manully:'), True)
		self.radioMan.connect('clicked', self.radioManClicked)
		pack(hbox, self.radioMan)
		pack(self.vbox, hbox)
		######
		vb = gtk.VBox()
		sg = gtk.SizeGroup(gtk.SIZE_GROUP_HORIZONTAL)
		###
		hbox = gtk.HBox()
		##
		l = gtk.Label('')
		l.set_property('width-request', self.xpad)
		pack(hbox, l)
		##
		self.ckeckbEditTime = gtk.CheckButton(_('Edit Time'))
		self.editTime = False
		self.ckeckbEditTime.connect('clicked', self.ckeckbEditTimeClicked)
		pack(hbox, self.ckeckbEditTime)
		sg.add_widget(self.ckeckbEditTime)
		self.timeInput = TimeButton() ## ??????? options
		pack(hbox, self.timeInput)
		pack(vb, hbox)
		###
		hbox = gtk.HBox()
		##
		l = gtk.Label('')
		l.set_property('width-request', self.xpad)
		pack(hbox, l)
		##
		self.ckeckbEditDate = gtk.CheckButton(_('Edit Date'))
		self.editDate = False
		self.ckeckbEditDate.connect('clicked', self.ckeckbEditDateClicked)
		pack(hbox, self.ckeckbEditDate)
		sg.add_widget(self.ckeckbEditDate)
		self.dateInput = DateButton() ## ??????? options
		pack(hbox, self.dateInput)
		pack(vb, hbox)
		###
		pack(self.vbox, 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)
		pack(hbox, self.radioNtp)
		pack(self.vbox, hbox)
		###
		hbox = gtk.HBox()
		##
		l = gtk.Label('')
		l.set_property('width-request', self.xpad)
		pack(hbox, l)
		##
		pack(hbox, gtk.Label(_('Server:')+' '))
		combo = gtk.combo_box_entry_new_text()
		combo.get_child().connect('changed', self.updateSetButtonSensitive)
		pack(hbox, combo, 1, 1)
		self.ntpServerEntry = combo.get_child()
		for s in ui.ntpServers:
			combo.append_text(s)
		combo.set_active(0)
		self.hboxNtp = hbox
		pack(self.vbox, hbox)
		######
		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 = now()%1
		timeout_add(iceil(1000*(1-dt)), self.updateTimes)
		#print('updateTimes', dt)
		lt = 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 = 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)#??????????
Beispiel #7
0
class WidgetClass(common.WidgetClass):
    def __init__(self, event):  ## FIXME
        common.WidgetClass.__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.WidgetClass.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.WidgetClass.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.WidgetClass
        newMode = self.modeCombo.get_active()
        self.startDateInput.changeMode(self.event.mode, newMode)
        self.endDateInput.changeMode(self.event.mode, newMode)
        self.event.mode = newMode
Beispiel #8
0
class WidgetClass(common.WidgetClass):
    def __init__(self, event):## FIXME
        common.WidgetClass.__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.WidgetClass.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.WidgetClass.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.WidgetClass
        newMode = self.modeCombo.get_active()
        self.startDateInput.changeMode(self.event.mode, newMode)
        self.endDateInput.changeMode(self.event.mode, newMode)
        self.event.mode = newMode