示例#1
0
class WidgetClass(BaseWidgetClass):
    def __init__(self, group):
        BaseWidgetClass.__init__(self, group)
        ######
        sizeGroup = gtk.SizeGroup(gtk.SIZE_GROUP_HORIZONTAL)
        ######
        hbox = gtk.HBox()
        label = gtk.Label(_('Scale'))
        label.set_alignment(0, 0.5)
        sizeGroup.add_widget(label)
        pack(hbox, label)
        self.scaleCombo = common.Scale10PowerComboBox()
        pack(hbox, self.scaleCombo)
        pack(self, hbox)
        ####
        hbox = gtk.HBox()
        label = gtk.Label(_('Start'))
        label.set_alignment(0, 0.5)
        sizeGroup.add_widget(label)
        pack(hbox, label)
        self.startSpin = IntSpinButton(-maxStartEnd, maxStartEnd)
        pack(hbox, self.startSpin)
        pack(self, hbox)
        ####
        hbox = gtk.HBox()
        label = gtk.Label(_('End'))
        label.set_alignment(0, 0.5)
        sizeGroup.add_widget(label)
        pack(hbox, label)
        self.endSpin = IntSpinButton(-maxStartEnd, maxStartEnd)
        pack(hbox, self.endSpin)
        pack(self, hbox)

    def updateWidget(self):
        BaseWidgetClass.updateWidget(self)
        self.scaleCombo.set_value(self.group.scale)
        self.startSpin.set_value(self.group.getStartValue())
        self.endSpin.set_value(self.group.getEndValue())

    def updateVars(self):
        BaseWidgetClass.updateVars(self)
        self.group.scale = self.scaleCombo.get_value()
        self.group.setStartValue(self.startSpin.get_value())
        self.group.setEndValue(self.endSpin.get_value())
示例#2
0
class WidgetClass(BaseWidgetClass):
    def __init__(self, group):
        BaseWidgetClass.__init__(self, group)
        ######
        sizeGroup = gtk.SizeGroup(gtk.SIZE_GROUP_HORIZONTAL)
        ######
        hbox = gtk.HBox()
        label = gtk.Label(_('Scale'))
        label.set_alignment(0, 0.5)
        sizeGroup.add_widget(label)
        pack(hbox, label)
        self.scaleCombo = common.Scale10PowerComboBox()
        pack(hbox, self.scaleCombo)
        pack(self, hbox)
        ####
        hbox = gtk.HBox()
        label = gtk.Label(_('Start'))
        label.set_alignment(0, 0.5)
        sizeGroup.add_widget(label)
        pack(hbox, label)
        self.startSpin = IntSpinButton(-maxStartEnd, maxStartEnd)
        pack(hbox, self.startSpin)
        pack(self, hbox)
        ####
        hbox = gtk.HBox()
        label = gtk.Label(_('End'))
        label.set_alignment(0, 0.5)
        sizeGroup.add_widget(label)
        pack(hbox, label)
        self.endSpin = IntSpinButton(-maxStartEnd, maxStartEnd)
        pack(hbox, self.endSpin)
        pack(self, hbox)
    def updateWidget(self):
        BaseWidgetClass.updateWidget(self)
        self.scaleCombo.set_value(self.group.scale)
        self.startSpin.set_value(self.group.getStartValue())
        self.endSpin.set_value(self.group.getEndValue())
    def updateVars(self):
        BaseWidgetClass.updateVars(self)
        self.group.scale = self.scaleCombo.get_value()
        self.group.setStartValue(self.startSpin.get_value())
        self.group.setEndValue(self.endSpin.get_value())
示例#3
0
class WidthHeightPrefItem(PrefItem):
    def __init__(self, module, varName, _max):
        _min = 0
        self.module = module
        self.varName = varName
        ###
        self.widthItem = IntSpinButton(_min, _max)
        self.heightItem = IntSpinButton(_min, _max)
        ###
        hbox = self._widget = gtk.HBox()
        pack(hbox, gtk.Label(_('Width')+':'))
        pack(hbox, self.widthItem)
        pack(hbox, gtk.Label('  '))
        pack(hbox, gtk.Label(_('Height')+':'))
        pack(hbox, self.heightItem)
    def get(self):
        return (
            int(self.widthItem.get_value()),
            int(self.heightItem.get_value()),
        )
    def set(self, value):
        w, h = value
        self.widthItem.set_value(w)
        self.heightItem.set_value(h)
示例#4
0
class WidthHeightPrefItem(PrefItem):
	def __init__(self, module, varName, _max):
		_min = 0
		self.module = module
		self.varName = varName
		###
		self.widthItem = IntSpinButton(_min, _max)
		self.heightItem = IntSpinButton(_min, _max)
		###
		hbox = self._widget = gtk.HBox()
		pack(hbox, gtk.Label(_('Width')+':'))
		pack(hbox, self.widthItem)
		pack(hbox, gtk.Label('  '))
		pack(hbox, gtk.Label(_('Height')+':'))
		pack(hbox, self.heightItem)
	def get(self):
		return (
			int(self.widthItem.get_value()),
			int(self.heightItem.get_value()),
		)
	def set(self, value):
		w, h = value
		self.widthItem.set_value(w)
		self.heightItem.set_value(h)
示例#5
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(_('Scale'))
		label.set_alignment(0, 0.5)
		sizeGroup.add_widget(label)
		pack(hbox, label)
		self.scaleCombo = common.Scale10PowerComboBox()
		pack(hbox, self.scaleCombo)
		pack(self, hbox)
		####
		hbox = gtk.HBox()
		label = gtk.Label(_('Start'))
		label.set_alignment(0, 0.5)
		sizeGroup.add_widget(label)
		pack(hbox, label)
		self.startSpin = IntSpinButton(-maxStart, maxStart)
		self.startSpin.connect('changed', self.startSpinChanged)
		pack(hbox, self.startSpin)
		pack(self, hbox)
		####
		hbox = gtk.HBox()
		self.endRelCombo = gtk.combo_box_new_text()
		for item in ('Duration', 'End'):
			self.endRelCombo.append_text(_(item))
		self.endRelCombo.connect('changed', self.endRelComboChanged)
		sizeGroup.add_widget(self.endRelCombo)
		pack(hbox, self.endRelCombo)
		self.endSpin = IntSpinButton(-maxDur, maxDur)
		pack(hbox, self.endSpin)
		pack(self, hbox)
		####
		self.endRelComboChanged()
	def endRelComboChanged(self, combo=None):
		rel = self.endRelCombo.get_active()
		start = self.startSpin.get_value()
		end = self.endSpin.get_value()
		if rel==0:## reletive(duration)
			self.endSpin.set_range(1, maxStart)
			self.endSpin.set_value(max(1, end-start))
		elif rel==1:## absolute(end)
			self.endSpin.set_range(start+1, maxStart)
			self.endSpin.set_value(max(start+1, start+end))
	def startSpinChanged(self, spin=None):
		if self.endRelCombo.get_active() == 1:## absolute(end)
			self.endSpin.set_range(self.startSpin.get_value()+1, maxStart)
	def updateWidget(self):
		common.WidgetClass.updateWidget(self)
		self.scaleCombo.set_value(self.event.scale)
		self.startSpin.set_value(self.event.start)
		self.endRelCombo.set_active(0 if self.event.endRel else 1)
		self.endSpin.set_value(self.event.end)
	def updateVars(self):## FIXME
		common.WidgetClass.updateVars(self)
		self.event.scale = self.scaleCombo.get_value()
		self.event.start = self.startSpin.get_value()
		self.event.endRel = (self.endRelCombo.get_active()==0)
		self.event.end = self.endSpin.get_value()
示例#6
0
文件: base.py 项目: ilius/starcal2
class BaseWidgetClass(gtk.VBox):
    def __init__(self, group):
        from scal2.ui_gtk.mywidgets.cal_type_combo import CalTypeCombo
        gtk.VBox.__init__(self)
        self.group = group
        ########
        self.sizeGroup = gtk.SizeGroup(gtk.SIZE_GROUP_HORIZONTAL)
        #####
        hbox = gtk.HBox()
        label = gtk.Label(_('Title'))
        label.set_alignment(0, 0.5)
        pack(hbox, label)
        self.sizeGroup.add_widget(label)
        self.titleEntry = gtk.Entry()
        pack(hbox, self.titleEntry, 1, 1)
        pack(self, hbox)
        #####
        hbox = gtk.HBox()
        label = gtk.Label(_('Color'))
        label.set_alignment(0, 0.5)
        pack(hbox, label)
        self.sizeGroup.add_widget(label)
        self.colorButton = MyColorButton()
        self.colorButton.set_use_alpha(True)  ## FIXME
        pack(hbox, self.colorButton)
        pack(self, hbox)
        #####
        hbox = gtk.HBox()
        label = gtk.Label(_('Default Icon'))  ## FIXME
        label.set_alignment(0, 0.5)
        pack(hbox, label)
        self.sizeGroup.add_widget(label)
        self.iconSelect = IconSelectButton()
        pack(hbox, self.iconSelect)
        pack(self, hbox)
        #####
        hbox = gtk.HBox()
        label = gtk.Label(_('Default Calendar Type'))
        label.set_alignment(0, 0.5)
        pack(hbox, label)
        self.sizeGroup.add_widget(label)
        combo = CalTypeCombo()
        pack(hbox, combo)
        pack(hbox, gtk.Label(''), 1, 1)
        self.modeCombo = combo
        pack(self, hbox)
        #####
        hbox = gtk.HBox()
        label = gtk.Label(_('Show in Calendar'))
        label.set_alignment(0, 0.5)
        pack(hbox, label)
        self.sizeGroup.add_widget(label)
        self.showInDCalCheck = gtk.CheckButton(_('Day'))
        self.showInWCalCheck = gtk.CheckButton(_('Week'))
        self.showInMCalCheck = gtk.CheckButton(_('Month'))
        pack(hbox, self.showInDCalCheck)
        pack(hbox, gtk.Label(''), 1, 1)
        pack(hbox, self.showInWCalCheck)
        pack(hbox, gtk.Label(''), 1, 1)
        pack(hbox, self.showInMCalCheck)
        pack(hbox, gtk.Label(''), 1, 1)
        pack(self, hbox)
        #####
        hbox = gtk.HBox()
        label = gtk.Label(_('Show in'))
        label.set_alignment(0, 0.5)
        pack(hbox, label)
        self.sizeGroup.add_widget(label)
        self.showInTimeLineCheck = gtk.CheckButton(_('Time Line'))
        self.showInStatusIconCheck = gtk.CheckButton(_('Status Icon'))
        pack(hbox, self.showInTimeLineCheck)
        pack(hbox, gtk.Label(''), 1, 1)
        pack(hbox, self.showInStatusIconCheck)
        pack(hbox, gtk.Label(''), 1, 1)
        pack(self, hbox)
        #####
        hbox = gtk.HBox()
        label = gtk.Label(_('Event Cache Size'))
        label.set_alignment(0, 0.5)
        pack(hbox, label)
        self.sizeGroup.add_widget(label)
        self.cacheSizeSpin = IntSpinButton(0, 9999)
        pack(hbox, self.cacheSizeSpin)
        pack(self, hbox)
        #####
        hbox = gtk.HBox()
        label = gtk.Label(_('Event Text Seperator'))
        label.set_alignment(0, 0.5)
        pack(hbox, label)
        self.sizeGroup.add_widget(label)
        self.sepInput = TextFrame()
        pack(hbox, self.sepInput, 1, 1)
        pack(self, hbox)
        set_tooltip(
            hbox,
            _('Using to seperate Summary and Description when displaying event'
              ))
        #####
        #hbox = gtk.HBox()
        #label = gtk.Label(_('Show Full Event Description'))
        #label.set_alignment(0, 0.5)
        #pack(hbox, label)
        #self.sizeGroup.add_widget(label)
        #self.showFullEventDescCheck = gtk.CheckButton('')
        #pack(hbox, self.showFullEventDescCheck, 1, 1)
        #pack(self, hbox)
        ###
        self.modeCombo.connect(
            'changed',
            self.modeComboChanged)  ## right place? before updateWidget? FIXME

    def updateWidget(self):
        self.titleEntry.set_text(self.group.title)
        self.colorButton.set_color(self.group.color)
        self.iconSelect.set_filename(self.group.icon)
        self.modeCombo.set_active(self.group.mode)
        self.showInDCalCheck.set_active(self.group.showInDCal)
        self.showInWCalCheck.set_active(self.group.showInWCal)
        self.showInMCalCheck.set_active(self.group.showInMCal)
        self.showInTimeLineCheck.set_active(self.group.showInTimeLine)
        self.showInStatusIconCheck.set_active(self.group.showInStatusIcon)
        self.cacheSizeSpin.set_value(self.group.eventCacheSize)
        self.sepInput.set_text(self.group.eventTextSep)
        #self.showFullEventDescCheck.set_active(self.group.showFullEventDesc)
    def updateVars(self):
        self.group.title = self.titleEntry.get_text()
        self.group.color = self.colorButton.get_color()
        self.group.icon = self.iconSelect.get_filename()
        self.group.mode = self.modeCombo.get_active()
        self.group.showInDCal = self.showInDCalCheck.get_active()
        self.group.showInWCal = self.showInWCalCheck.get_active()
        self.group.showInMCal = self.showInMCalCheck.get_active()
        self.group.showInTimeLine = self.showInTimeLineCheck.get_active()
        self.group.showInStatusIcon = self.showInStatusIconCheck.get_active()
        self.group.eventCacheSize = int(self.cacheSizeSpin.get_value())
        self.group.eventTextSep = self.sepInput.get_text()
        #self.group.showFullEventDesc = self.showFullEventDescCheck.get_active()
    def modeComboChanged(self, obj=None):
        pass
示例#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(''), 1, 1)
        pack(self, hbox)
        ######
        hbox = gtk.HBox()
        label = gtk.Label(_('Repeat Every '))
        label.set_alignment(0, 0.5)
        sizeGroup.add_widget(label)
        pack(hbox, label)
        self.weeksSpin = IntSpinButton(1, 99999)
        pack(hbox, self.weeksSpin)
        pack(hbox, gtk.Label('  '+_(' Weeks')))
        ###
        pack(hbox, gtk.Label(''), 1, 1)
        pack(self, hbox)
        ######
        hbox = gtk.HBox()
        label = gtk.Label(_('End'))
        label.set_alignment(0, 0.5)
        sizeGroup.add_widget(label)
        pack(hbox, label)
        self.endDateInput = DateButton()
        pack(hbox, self.endDateInput)
        ###
        pack(hbox, gtk.Label(''), 1, 1)
        pack(self, hbox)
        #########
        hbox = gtk.HBox()
        label = gtk.Label(_('Time'))
        label.set_alignment(0, 0.5)
        sizeGroup.add_widget(label)
        pack(hbox, label)
        ##
        self.dayTimeStartInput = HourMinuteButton()
        self.dayTimeEndInput = HourMinuteButton()
        ##
        pack(hbox, self.dayTimeStartInput)
        pack(hbox, gtk.Label(' ' + _('to') + ' '))
        pack(hbox, self.dayTimeEndInput)
        pack(self, hbox)
        #############
        #self.notificationBox = common.NotificationBox(event)
        #pack(self, self.notificationBox)
        #############
        #self.filesBox = common.FilesBox(self.event)
        #pack(self, self.filesBox)
    def updateWidget(self):## FIXME
        common.WidgetClass.updateWidget(self)
        mode = self.event.mode
        ###
        self.startDateInput.set_value(jd_to(self.event.getStartJd(), mode))
        self.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.WidgetClass.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.WidgetClass
        newMode = self.modeCombo.get_active()
        self.startDateInput.changeMode(self.event.mode, newMode)
        self.endDateInput.changeMode(self.event.mode, newMode)
        self.event.mode = newMode
示例#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(_('Scale'))
        label.set_alignment(0, 0.5)
        sizeGroup.add_widget(label)
        pack(hbox, label)
        self.scaleCombo = common.Scale10PowerComboBox()
        pack(hbox, self.scaleCombo)
        pack(self, hbox)
        ####
        hbox = gtk.HBox()
        label = gtk.Label(_('Start'))
        label.set_alignment(0, 0.5)
        sizeGroup.add_widget(label)
        pack(hbox, label)
        self.startSpin = IntSpinButton(-maxStart, maxStart)
        self.startSpin.connect('changed', self.startSpinChanged)
        pack(hbox, self.startSpin)
        pack(self, hbox)
        ####
        hbox = gtk.HBox()
        self.endRelCombo = gtk.combo_box_new_text()
        for item in ('Duration', 'End'):
            self.endRelCombo.append_text(_(item))
        self.endRelCombo.connect('changed', self.endRelComboChanged)
        sizeGroup.add_widget(self.endRelCombo)
        pack(hbox, self.endRelCombo)
        self.endSpin = IntSpinButton(-maxDur, maxDur)
        pack(hbox, self.endSpin)
        pack(self, hbox)
        ####
        self.endRelComboChanged()
    def endRelComboChanged(self, combo=None):
        rel = self.endRelCombo.get_active()
        start = self.startSpin.get_value()
        end = self.endSpin.get_value()
        if rel==0:## reletive(duration)
            self.endSpin.set_range(1, maxStart)
            self.endSpin.set_value(max(1, end-start))
        elif rel==1:## absolute(end)
            self.endSpin.set_range(start+1, maxStart)
            self.endSpin.set_value(max(start+1, start+end))
    def startSpinChanged(self, spin=None):
        if self.endRelCombo.get_active() == 1:## absolute(end)
            self.endSpin.set_range(self.startSpin.get_value()+1, maxStart)
    def updateWidget(self):
        common.WidgetClass.updateWidget(self)
        self.scaleCombo.set_value(self.event.scale)
        self.startSpin.set_value(self.event.start)
        self.endRelCombo.set_active(0 if self.event.endRel else 1)
        self.endSpin.set_value(self.event.end)
    def updateVars(self):## FIXME
        common.WidgetClass.updateVars(self)
        self.event.scale = self.scaleCombo.get_value()
        self.event.start = self.startSpin.get_value()
        self.event.endRel = (self.endRelCombo.get_active()==0)
        self.event.end = self.endSpin.get_value()
示例#9
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(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.WidgetClass.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.WidgetClass.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.WidgetClass
        newMode = self.modeCombo.get_active()
        self.startDateInput.changeMode(self.event.mode, newMode)
        self.endDateInput.changeMode(self.event.mode, newMode)
        self.event.mode = newMode
示例#10
0
class CustomizableToolbar(gtk.Toolbar, CustomizableCalObj):
    _name = 'toolbar'
    desc = _('Toolbar')
    styleList = (
        ## Gnome's naming is not exactly the best here
        ## And Gnome's order of options is also different from Gtk's enum
        'Icon',## 'icons', 'Icons only'
        'Text',## 'text', 'Text only'
        'Text below Icon',## 'both', 'Text below items'
        'Text beside Icon',## 'both-horiz', 'Text beside items'
    )
    defaultItems = []
    defaultItemsDict = {}
    def __init__(self, funcOwner, vertical=False, onPressContinue=False):
        from scal2.ui_gtk.mywidgets.multi_spin.integer import IntSpinButton
        gtk.Toolbar.__init__(self)
        self.funcOwner = funcOwner
        self.set_orientation(gtk.ORIENTATION_VERTICAL if vertical else gtk.ORIENTATION_HORIZONTAL)
        self.add_events(gdk.POINTER_MOTION_MASK)
        self.onPressContinue = onPressContinue
        ###
        optionsWidget = gtk.VBox()
        ##
        hbox = gtk.HBox()
        pack(hbox, gtk.Label(_('Style')))
        self.styleCombo = gtk.combo_box_new_text()
        for item in self.styleList:
            self.styleCombo.append_text(_(item))
        pack(hbox, self.styleCombo)
        pack(optionsWidget, hbox)
        ##
        hbox = gtk.HBox()
        pack(hbox, gtk.Label(_('Icon Size')))
        self.iconSizeCombo = gtk.combo_box_new_text()
        for (i, item) in enumerate(ud.iconSizeList):
            self.iconSizeCombo.append_text(_(item[0]))
        pack(hbox, self.iconSizeCombo)
        pack(optionsWidget, hbox)
        self.iconSizeHbox = hbox
        ##
        hbox = gtk.HBox()
        pack(hbox, gtk.Label(_('Buttons Border')))
        self.buttonsBorderSpin = IntSpinButton(0, 99)
        pack(hbox, self.buttonsBorderSpin)
        pack(optionsWidget, hbox)
        ##
        self.initVars(optionsWidget=optionsWidget)
        self.iconSizeCombo.connect('changed', self.iconSizeComboChanged)
        self.styleCombo.connect('changed', self.styleComboChanged)
        self.buttonsBorderSpin.connect('changed', self.buttonsBorderSpinChanged)
        #self.styleComboChanged()
        ##
        #print('toolbar state', self.get_state()## STATE_NORMAL)
        #self.set_state(gtk.STATE_ACTIVE)## FIXME
        #self.set_property('border-width', 0)
        #style = self.get_style()
        #style.border_width = 10
        #self.set_style(style)
    getIconSizeName = lambda self: ud.iconSizeList[self.iconSizeCombo.get_active()][0]
    setIconSizeName = lambda self, size_name: self.set_icon_size(ud.iconSizeDict[size_name])
    ## gtk.Toolbar.set_icon_size was previously Deprecated, but it's not Deprecated now!!
    def setButtonsBorder(self, bb):
        for item in self.items:
            item.set_border_width(bb)
    def iconSizeComboChanged(self, combo=None):
        self.setIconSizeName(self.getIconSizeName())
    def styleComboChanged(self, combo=None):
        style = self.styleCombo.get_active()
        self.set_style(style)
        #self.showHide()## FIXME
        self.iconSizeHbox.set_sensitive(style!=1)
    def buttonsBorderSpinChanged(self, spin=None):
        self.setButtonsBorder(self.buttonsBorderSpin.get_value())
    def moveItemUp(self, i):
        button = self.items[i]
        self.remove(button)
        self.insert(button, i-1)
        self.items.insert(i-1, self.items.pop(i))
    #def insertItem(self, item, pos):
    #    CustomizableCalObj.insertItem(self, pos, item)
    #    gtk.Toolbar.insert(self, item, pos)
    #    item.show()
    def appendItem(self, item):
        CustomizableCalObj.appendItem(self, item)
        gtk.Toolbar.insert(self, item, -1)
        if item.enable:
            item.show()
    getData = lambda self: {
        'items': self.getItemsData(),
        'iconSize': self.getIconSizeName(),
        'style': self.styleList[self.styleCombo.get_active()],
        'buttonsBorder': self.buttonsBorderSpin.get_value(),
    }
    def setupItemSignals(self, item):
        if item.method:
            if isinstance(item.method, str):
                func = getattr(self.funcOwner, item.method)
            else:
                func = item.method
            if self.onPressContinue:
                child = item.get_child()
                child.connect('button-press-event', lambda obj, ev: self.itemPress(func))
                child.connect('button-release-event', self.itemRelease)
            else:
                item.connect('clicked', func)
    def setData(self, data):
        for (name, enable) in data['items']:
            try:
                item = self.defaultItemsDict[name]
            except KeyError:
                myRaise()
            else:
                item.enable = enable
                self.setupItemSignals(item)
                self.appendItem(item)
        ###
        iconSize = data['iconSize']
        for (i, item) in enumerate(ud.iconSizeList):
            if item[0]==iconSize:
                self.iconSizeCombo.set_active(i)
        self.setIconSizeName(iconSize)
        ###
        styleNum = self.styleList.index(data['style'])
        self.styleCombo.set_active(styleNum)
        self.set_style(styleNum)
        ###
        bb = data.get('buttonsBorder', 0)
        self.buttonsBorderSpin.set_value(bb)
        self.setButtonsBorder(bb)
        ###
    def itemPress(self, func):
        self.lastPressTime = now()
        self.remain = True
        func()
        gobject.timeout_add(ui.timeout_initial, self.itemPressRemain, func)
    def itemPressRemain(self, func):
        if self.remain and now()-self.lastPressTime>=ui.timeout_repeat/1000.0:
            func()
            gobject.timeout_add(ui.timeout_repeat, self.itemPressRemain, func)
    def itemRelease(self, widget, event=None):
        self.remain = False
示例#11
0
class CustomizableToolbar(gtk.Toolbar, CustomizableCalObj):
    _name = 'toolbar'
    desc = _('Toolbar')
    styleList = (
        ## Gnome's naming is not exactly the best here
        ## And Gnome's order of options is also different from Gtk's enum
        'Icon',  ## 'icons', 'Icons only'
        'Text',  ## 'text', 'Text only'
        'Text below Icon',  ## 'both', 'Text below items'
        'Text beside Icon',  ## 'both-horiz', 'Text beside items'
    )
    defaultItems = []
    defaultItemsDict = {}

    def __init__(self, funcOwner, vertical=False, onPressContinue=False):
        from scal2.ui_gtk.mywidgets.multi_spin.integer import IntSpinButton
        gtk.Toolbar.__init__(self)
        self.funcOwner = funcOwner
        self.set_orientation(gtk.ORIENTATION_VERTICAL if vertical else gtk.
                             ORIENTATION_HORIZONTAL)
        self.add_events(gdk.POINTER_MOTION_MASK)
        self.onPressContinue = onPressContinue
        ###
        optionsWidget = gtk.VBox()
        ##
        hbox = gtk.HBox()
        pack(hbox, gtk.Label(_('Style')))
        self.styleCombo = gtk.combo_box_new_text()
        for item in self.styleList:
            self.styleCombo.append_text(_(item))
        pack(hbox, self.styleCombo)
        pack(optionsWidget, hbox)
        ##
        hbox = gtk.HBox()
        pack(hbox, gtk.Label(_('Icon Size')))
        self.iconSizeCombo = gtk.combo_box_new_text()
        for (i, item) in enumerate(ud.iconSizeList):
            self.iconSizeCombo.append_text(_(item[0]))
        pack(hbox, self.iconSizeCombo)
        pack(optionsWidget, hbox)
        self.iconSizeHbox = hbox
        ##
        hbox = gtk.HBox()
        pack(hbox, gtk.Label(_('Buttons Border')))
        self.buttonsBorderSpin = IntSpinButton(0, 99)
        pack(hbox, self.buttonsBorderSpin)
        pack(optionsWidget, hbox)
        ##
        self.initVars(optionsWidget=optionsWidget)
        self.iconSizeCombo.connect('changed', self.iconSizeComboChanged)
        self.styleCombo.connect('changed', self.styleComboChanged)
        self.buttonsBorderSpin.connect('changed',
                                       self.buttonsBorderSpinChanged)
        #self.styleComboChanged()
        ##
        #print('toolbar state', self.get_state()## STATE_NORMAL)
        #self.set_state(gtk.STATE_ACTIVE)## FIXME
        #self.set_property('border-width', 0)
        #style = self.get_style()
        #style.border_width = 10
        #self.set_style(style)

    getIconSizeName = lambda self: ud.iconSizeList[self.iconSizeCombo.
                                                   get_active()][0]
    setIconSizeName = lambda self, size_name: self.set_icon_size(
        ud.iconSizeDict[size_name])

    ## gtk.Toolbar.set_icon_size was previously Deprecated, but it's not Deprecated now!!
    def setButtonsBorder(self, bb):
        for item in self.items:
            item.set_border_width(bb)

    def iconSizeComboChanged(self, combo=None):
        self.setIconSizeName(self.getIconSizeName())

    def styleComboChanged(self, combo=None):
        style = self.styleCombo.get_active()
        self.set_style(style)
        #self.showHide()## FIXME
        self.iconSizeHbox.set_sensitive(style != 1)

    def buttonsBorderSpinChanged(self, spin=None):
        self.setButtonsBorder(self.buttonsBorderSpin.get_value())

    def moveItemUp(self, i):
        button = self.items[i]
        self.remove(button)
        self.insert(button, i - 1)
        self.items.insert(i - 1, self.items.pop(i))

    #def insertItem(self, item, pos):
    #	CustomizableCalObj.insertItem(self, pos, item)
    #	gtk.Toolbar.insert(self, item, pos)
    #	item.show()
    def appendItem(self, item):
        CustomizableCalObj.appendItem(self, item)
        gtk.Toolbar.insert(self, item, -1)
        if item.enable:
            item.show()

    getData = lambda self: {
        'items': self.getItemsData(),
        'iconSize': self.getIconSizeName(),
        'style': self.styleList[self.styleCombo.get_active()],
        'buttonsBorder': self.buttonsBorderSpin.get_value(),
    }

    def setupItemSignals(self, item):
        if item.method:
            if isinstance(item.method, str):
                func = getattr(self.funcOwner, item.method)
            else:
                func = item.method
            if self.onPressContinue:
                child = item.get_child()
                child.connect('button-press-event',
                              lambda obj, ev: self.itemPress(func))
                child.connect('button-release-event', self.itemRelease)
            else:
                item.connect('clicked', func)

    def setData(self, data):
        for (name, enable) in data['items']:
            try:
                item = self.defaultItemsDict[name]
            except KeyError:
                myRaise()
            else:
                item.enable = enable
                self.setupItemSignals(item)
                self.appendItem(item)
        ###
        iconSize = data['iconSize']
        for (i, item) in enumerate(ud.iconSizeList):
            if item[0] == iconSize:
                self.iconSizeCombo.set_active(i)
        self.setIconSizeName(iconSize)
        ###
        styleNum = self.styleList.index(data['style'])
        self.styleCombo.set_active(styleNum)
        self.set_style(styleNum)
        ###
        bb = data.get('buttonsBorder', 0)
        self.buttonsBorderSpin.set_value(bb)
        self.setButtonsBorder(bb)
        ###
    def itemPress(self, func):
        self.lastPressTime = now()
        self.remain = True
        func()
        gobject.timeout_add(ui.timeout_initial, self.itemPressRemain, func)

    def itemPressRemain(self, func):
        if self.remain and now(
        ) - self.lastPressTime >= ui.timeout_repeat / 1000.0:
            func()
            gobject.timeout_add(ui.timeout_repeat, self.itemPressRemain, func)

    def itemRelease(self, widget, event=None):
        self.remain = False
示例#12
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(''), 1, 1)
        pack(self, hbox)
        ######
        hbox = gtk.HBox()
        label = gtk.Label(_('Repeat Every '))
        label.set_alignment(0, 0.5)
        sizeGroup.add_widget(label)
        pack(hbox, label)
        self.weeksSpin = IntSpinButton(1, 99999)
        pack(hbox, self.weeksSpin)
        pack(hbox, gtk.Label('  ' + _(' Weeks')))
        ###
        pack(hbox, gtk.Label(''), 1, 1)
        pack(self, hbox)
        ######
        hbox = gtk.HBox()
        label = gtk.Label(_('End'))
        label.set_alignment(0, 0.5)
        sizeGroup.add_widget(label)
        pack(hbox, label)
        self.endDateInput = DateButton()
        pack(hbox, self.endDateInput)
        ###
        pack(hbox, gtk.Label(''), 1, 1)
        pack(self, hbox)
        #########
        hbox = gtk.HBox()
        label = gtk.Label(_('Time'))
        label.set_alignment(0, 0.5)
        sizeGroup.add_widget(label)
        pack(hbox, label)
        ##
        self.dayTimeStartInput = HourMinuteButton()
        self.dayTimeEndInput = HourMinuteButton()
        ##
        pack(hbox, self.dayTimeStartInput)
        pack(hbox, gtk.Label(' ' + _('to') + ' '))
        pack(hbox, self.dayTimeEndInput)
        pack(self, hbox)
        #############
        #self.notificationBox = common.NotificationBox(event)
        #pack(self, self.notificationBox)
        #############
        #self.filesBox = common.FilesBox(self.event)
        #pack(self, self.filesBox)
    def updateWidget(self):  ## FIXME
        common.WidgetClass.updateWidget(self)
        mode = self.event.mode
        ###
        self.startDateInput.set_value(jd_to(self.event.getStartJd(), mode))
        self.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.WidgetClass.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.WidgetClass
        newMode = self.modeCombo.get_active()
        self.startDateInput.changeMode(self.event.mode, newMode)
        self.endDateInput.changeMode(self.event.mode, newMode)
        self.event.mode = newMode
示例#13
0
class BaseWidgetClass(gtk.VBox):
    def __init__(self, group):
        from scal2.ui_gtk.mywidgets.cal_type_combo import CalTypeCombo
        gtk.VBox.__init__(self)
        self.group = group
        ########
        self.sizeGroup = gtk.SizeGroup(gtk.SIZE_GROUP_HORIZONTAL)
        #####
        hbox = gtk.HBox()
        label = gtk.Label(_('Title'))
        label.set_alignment(0, 0.5)
        pack(hbox, label)
        self.sizeGroup.add_widget(label)
        self.titleEntry = gtk.Entry()
        pack(hbox, self.titleEntry, 1, 1)
        pack(self, hbox)
        #####
        hbox = gtk.HBox()
        label = gtk.Label(_('Color'))
        label.set_alignment(0, 0.5)
        pack(hbox, label)
        self.sizeGroup.add_widget(label)
        self.colorButton = MyColorButton()
        self.colorButton.set_use_alpha(True) ## FIXME
        pack(hbox, self.colorButton)
        pack(self, hbox)
        #####
        hbox = gtk.HBox()
        label = gtk.Label(_('Default Icon'))## FIXME
        label.set_alignment(0, 0.5)
        pack(hbox, label)
        self.sizeGroup.add_widget(label)
        self.iconSelect = IconSelectButton()
        pack(hbox, self.iconSelect)
        pack(self, hbox)
        #####
        hbox = gtk.HBox()
        label = gtk.Label(_('Default Calendar Type'))
        label.set_alignment(0, 0.5)
        pack(hbox, label)
        self.sizeGroup.add_widget(label)
        combo = CalTypeCombo()
        pack(hbox, combo)
        pack(hbox, gtk.Label(''), 1, 1)
        self.modeCombo = combo
        pack(self, hbox)
        #####
        hbox = gtk.HBox()
        label = gtk.Label(_('Show in Calendar'))
        label.set_alignment(0, 0.5)
        pack(hbox, label)
        self.sizeGroup.add_widget(label)
        self.showInDCalCheck = gtk.CheckButton(_('Day'))
        self.showInWCalCheck = gtk.CheckButton(_('Week'))
        self.showInMCalCheck = gtk.CheckButton(_('Month'))
        pack(hbox, self.showInDCalCheck)
        pack(hbox, gtk.Label(''), 1, 1)
        pack(hbox, self.showInWCalCheck)
        pack(hbox, gtk.Label(''), 1, 1)
        pack(hbox, self.showInMCalCheck)
        pack(hbox, gtk.Label(''), 1, 1)
        pack(self, hbox)
        #####
        hbox = gtk.HBox()
        label = gtk.Label(_('Show in'))
        label.set_alignment(0, 0.5)
        pack(hbox, label)
        self.sizeGroup.add_widget(label)
        self.showInTimeLineCheck = gtk.CheckButton(_('Time Line'))
        self.showInStatusIconCheck = gtk.CheckButton(_('Status Icon'))
        pack(hbox, self.showInTimeLineCheck)
        pack(hbox, gtk.Label(''), 1, 1)
        pack(hbox, self.showInStatusIconCheck)
        pack(hbox, gtk.Label(''), 1, 1)
        pack(self, hbox)
        #####
        hbox = gtk.HBox()
        label = gtk.Label(_('Event Cache Size'))
        label.set_alignment(0, 0.5)
        pack(hbox, label)
        self.sizeGroup.add_widget(label)
        self.cacheSizeSpin = IntSpinButton(0, 9999)
        pack(hbox, self.cacheSizeSpin)
        pack(self, hbox)
        #####
        hbox = gtk.HBox()
        label = gtk.Label(_('Event Text Seperator'))
        label.set_alignment(0, 0.5)
        pack(hbox, label)
        self.sizeGroup.add_widget(label)
        self.sepInput = TextFrame()
        pack(hbox, self.sepInput, 1, 1)
        pack(self, hbox)
        set_tooltip(hbox, _('Using to seperate Summary and Description when displaying event'))
        #####
        #hbox = gtk.HBox()
        #label = gtk.Label(_('Show Full Event Description'))
        #label.set_alignment(0, 0.5)
        #pack(hbox, label)
        #self.sizeGroup.add_widget(label)
        #self.showFullEventDescCheck = gtk.CheckButton('')
        #pack(hbox, self.showFullEventDescCheck, 1, 1)
        #pack(self, hbox)
        ###
        self.modeCombo.connect('changed', self.modeComboChanged)## right place? before updateWidget? FIXME
    def updateWidget(self):
        self.titleEntry.set_text(self.group.title)
        self.colorButton.set_color(self.group.color)
        self.iconSelect.set_filename(self.group.icon)
        self.modeCombo.set_active(self.group.mode)
        self.showInDCalCheck.set_active(self.group.showInDCal)
        self.showInWCalCheck.set_active(self.group.showInWCal)
        self.showInMCalCheck.set_active(self.group.showInMCal)
        self.showInTimeLineCheck.set_active(self.group.showInTimeLine)
        self.showInStatusIconCheck.set_active(self.group.showInStatusIcon)
        self.cacheSizeSpin.set_value(self.group.eventCacheSize)
        self.sepInput.set_text(self.group.eventTextSep)
        #self.showFullEventDescCheck.set_active(self.group.showFullEventDesc)
    def updateVars(self):
        self.group.title = self.titleEntry.get_text()
        self.group.color = self.colorButton.get_color()
        self.group.icon = self.iconSelect.get_filename()
        self.group.mode = self.modeCombo.get_active()
        self.group.showInDCal = self.showInDCalCheck.get_active()
        self.group.showInWCal = self.showInWCalCheck.get_active()
        self.group.showInMCal = self.showInMCalCheck.get_active()
        self.group.showInTimeLine = self.showInTimeLineCheck.get_active()
        self.group.showInStatusIcon = self.showInStatusIconCheck.get_active()
        self.group.eventCacheSize = int(self.cacheSizeSpin.get_value())
        self.group.eventTextSep = self.sepInput.get_text()
        #self.group.showFullEventDesc = self.showFullEventDescCheck.get_active()
    def modeComboChanged(self, obj=None):
        pass