예제 #1
0
	def setValues(self, values):
		return self.set_text(
			textNumEncode(
				numRangesEncode(values, ", "),
				changeSpecialChars=False,
			)
		)
예제 #2
0
	def treeviewCursorChanged(self, selection=None):
		path = self.treev.get_cursor()[0]
		## update eventInfoBox
		#print('treeviewCursorChanged', path)
		if not self.syncing:
			text = ''
			if path:
				if len(path)==1:
					group, = self.getObjsByPath(path)
					if group.name == 'trash':
						text = _('contains %s events')%_(len(group))
					else:
						text = _('contains %s events and %s occurences')%(
							_(len(group)),
							_(group.occurCount),
						) + _(',') + ' ' + _('Group ID: %s')%_(group.id)
					modified = group.modified
				elif len(path)==2:
					group, event = self.getObjsByPath(path)
					text = _('Event ID: %s')%_(event.id)
					modified = event.modified
				text += '%s %s: %s'%(
					_(','),
					_('Last Modified'),
					locale_man.textNumEncode(core.epochDateTimeEncode(modified)),
				)
			try:
				sbar = self.sbar
			except AttributeError:
				pass
			else:
				message_id = self.sbar.push(0, text)
		return True
예제 #3
0
 def onDateChange(self, *a, **kw):
     from scal3.season import getSeasonNamePercentFromJd
     CustomizableCalObj.onDateChange(self, *a, **kw)
     name, frac = getSeasonNamePercentFromJd(ui.cell.jd)
     if rtl:
         percent = '%d%%' % (frac * 100)
     else:
         percent = '%%%d' % (frac * 100)
     self.set_text(
         _(name) + ' - ' + textNumEncode(
             percent,
             changeDot=True,
         ))
     self.set_fraction(frac)
예제 #4
0
파일: seasonPBar.py 프로젝트: ilius/starcal
 def onDateChange(self, *a, **kw):
     from scal3.season import getSeasonNamePercentFromJd
     CustomizableCalObj.onDateChange(self, *a, **kw)
     name, frac = getSeasonNamePercentFromJd(
         ui.cell.jd, ui.seasonPBar_southernHemisphere)
     if rtl:
         percent = "%d%%" % (frac * 100)
     else:
         percent = "%%%d" % (frac * 100)
     self.set_text(
         _(name) + " - " + textNumEncode(
             percent,
             changeDot=True,
         ))
     self.set_fraction(frac)
예제 #5
0
	def onDateChange(self, *a, **kw):
		from scal3.season import getSeasonNamePercentFromJd
		CustomizableCalObj.onDateChange(self, *a, **kw)
		name, frac = getSeasonNamePercentFromJd(ui.cell.jd)
		if rtl:
			percent = '%d%%'%(frac*100)
		else:
			percent = '%%%d'%(frac*100)
		self.set_text(
			_(name) +
			' - ' +
			textNumEncode(
				percent,
				changeDot=True,
			)
		)
		self.set_fraction(frac)
예제 #6
0
파일: seasonPBar.py 프로젝트: ilius/starcal
	def onDateChange(self, *a, **kw):
		from scal3.season import getSeasonNamePercentFromJd
		CustomizableCalObj.onDateChange(self, *a, **kw)
		name, frac = getSeasonNamePercentFromJd(ui.cell.jd, ui.seasonPBar_southernHemisphere)
		if rtl:
			percent = "%d%%" % (frac * 100)
		else:
			percent = "%%%d" % (frac * 100)
		self.set_text(
			_(name) +
			" - " +
			textNumEncode(
				percent,
				changeDot=True,
			)
		)
		self.set_fraction(frac)
예제 #7
0
    def onDateChange(self, *a, **kw):
        CustomizableCalObj.onDateChange(self, *a, **kw)

        year = ui.cell.year
        jd0 = core.primary_to_jd(year, 1, 1)
        jd1 = ui.cell.jd
        jd2 = core.primary_to_jd(year + 1, 1, 1)
        length = jd2 - jd0
        past = jd1 - jd0
        fraction = float(past) / length
        percent = "%%%d" % (fraction * 100)
        self.set_text(
            textNumEncode(
                percent,
                changeDot=True,
            ) + "   =   " + "%s%s / %s%s" %
            (_(past), _(" days"), _(length), _(" days")))
        self.set_fraction(fraction)
예제 #8
0
파일: yearPBar.py 프로젝트: ilius/starcal
	def onDateChange(self, *a, **kw):
		CustomizableCalObj.onDateChange(self, *a, **kw)

		year = ui.cell.year
		jd0 = core.primary_to_jd(year, 1, 1)
		jd1 = ui.cell.jd
		jd2 = core.primary_to_jd(year+1, 1, 1)
		length = jd2 - jd0
		past = jd1 - jd0
		fraction = float(past) / length
		percent = "%%%d" % (fraction * 100)
		self.set_text(
			textNumEncode(
				percent,
				changeDot=True,
			) +
			"   =   " +
			"%s%s / %s%s" %(_(past), _(" days"), _(length), _(" days"))
		)
		self.set_fraction(fraction)
예제 #9
0
def formatYear(y, prettyPower=False):
    if abs(y) < 10**4:  ## FIXME
        y_st = _(y)
    else:
        #y_st = textNumEncode('%.0E'%y, changeDot=True)## FIXME
        fac, pw = getNum10FactPow(y)
        if not prettyPower or abs(fac) >= 100:  ## FIXME
            y_e = '%E' % y
            for i in range(10):
                y_e = y_e.replace('0E', 'E')
            y_e = y_e.replace('.E', 'E')
            y_st = textNumEncode(y_e, changeDot=True)
        else:
            sign = ('-' if fac < 0 else '')
            fac = abs(fac)
            if fac == 1:
                fac_s = ''
            else:
                fac_s = '%s×' % _(fac)
            pw_s = _(10) + 'ˆ' + _(pw)
            ## pw_s = _(10) + '<span rise="5" size="small">' + _(pw) + '</span>'## Pango Markup Language
            y_st = sign + fac_s + pw_s
    return addLRM(y_st)
예제 #10
0
def formatYear(y, prettyPower=False):
    if abs(y) < 10 ** 4:## FIXME
        y_st = _(y)
    else:
        #y_st = textNumEncode('%.0E'%y, changeDot=True)## FIXME
        fac, pw = getNum10FactPow(y)
        if not prettyPower or abs(fac) >= 100:## FIXME
            y_e = '%E'%y
            for i in range(10):
                y_e = y_e.replace('0E', 'E')
            y_e = y_e.replace('.E', 'E')
            y_st = textNumEncode(y_e, changeDot=True)
        else:
            sign = ('-' if fac < 0 else '')
            fac = abs(fac)
            if fac == 1:
                fac_s = ''
            else:
                fac_s = '%s×'%_(fac)
            pw_s = _(10) + 'ˆ' + _(pw)
            ## pw_s = _(10) + '<span rise="5" size="small">' + _(pw) + '</span>'## Pango Markup Language
            y_st = sign + fac_s + pw_s
    return addLRM(y_st)
예제 #11
0
파일: manager.py 프로젝트: ilius/starcal
	def treeviewCursorChanged(self, selection=None):
		path = self.treev.get_cursor()[0]
		## update eventInfoBox
		#print("treeviewCursorChanged", path)
		if not self.syncing:
			text = ""
			if path:
				if len(path) == 1:
					group, = self.getObjsByPath(path)
					if group.name == "trash":
						text = _("contains %s events") % _(len(group))
					else:
						text = _("contains %s events and %s occurences") % (
							_(len(group)),
							_(group.occurCount),
						) + _(",") + " " + _("Group ID: %s") % _(group.id)
					modified = group.modified
					print("group, id =", group.id, "uuid =", group.uuid)
				elif len(path) == 2:
					group, event = self.getObjsByPath(path)
					text = _("Event ID: %s") % _(event.id)
					modified = event.modified
					print("event, id =", event.id, "uuid =", event.uuid)
				text += "%s %s: %s" % (
					_(","),
					_("Last Modified"),
					locale_man.textNumEncode(
						core.epochDateTimeEncode(modified),
					),
				)
			try:
				sbar = self.sbar
			except AttributeError:
				pass
			else:
				message_id = self.sbar.push(0, text)
		return True
예제 #12
0
	def treeviewCursorChanged(self, selection=None):
		path = self.treev.get_cursor()[0]
		## update eventInfoBox
		#print("treeviewCursorChanged", path)
		if not self.syncing:
			text = ""
			if path:
				if len(path) == 1:
					group, = self.getObjsByPath(path)
					if group.name == "trash":
						text = _("contains %s events") % _(len(group))
					else:
						text = _("contains %s events and %s occurences") % (
							_(len(group)),
							_(group.occurCount),
						) + _(",") + " " + _("Group ID: %s") % _(group.id)
					modified = group.modified
					print("group, id =", group.id, "uuid =", group.uuid)
				elif len(path) == 2:
					group, event = self.getObjsByPath(path)
					text = _("Event ID: %s") % _(event.id)
					modified = event.modified
					print("event, id =", event.id, "uuid =", event.uuid)
				text += "%s %s: %s" % (
					_(","),
					_("Last Modified"),
					locale_man.textNumEncode(
						core.epochDateTimeEncode(modified),
					),
				)
			try:
				sbar = self.sbar
			except AttributeError:
				pass
			else:
				message_id = self.sbar.push(0, text)
		return True
예제 #13
0
파일: timeline.py 프로젝트: ilius/starcal
def formatYear(y, prettyPower=False):
	if abs(y) < 10 ** 4:## FIXME
		y_st = _(y)
	else:
		#y_st = textNumEncode("%.0E"%y, changeDot=True)## FIXME
		fac, pw = getNum10FactPow(y)
		if not prettyPower or abs(fac) >= 100:## FIXME
			y_e = "%E" % y
			for i in range(10):
				y_e = y_e.replace("0E", "E")
			y_e = y_e.replace(".E", "E")
			y_st = textNumEncode(y_e, changeDot=True)
		else:
			sign = ("-" if fac < 0 else "")
			fac = abs(fac)
			if fac == 1:
				fac_s = ""
			else:
				fac_s = "%s×" % _(fac)
			pw_s = _(10) + "ˆ" + _(pw)
			#pw_s = _(10) + "<span rise="5" size="small">" + \
			#	_(pw) + "</span>"  # Pango Markup Language
			y_st = sign + fac_s + pw_s
	return addLRM(y_st)
예제 #14
0
def formatYear(y, prettyPower=False):
    if abs(y) < 10**4:  ## FIXME
        y_st = _(y)
    else:
        #y_st = textNumEncode("%.0E"%y, changeDot=True)## FIXME
        fac, pw = getNum10FactPow(y)
        if not prettyPower or abs(fac) >= 100:  ## FIXME
            y_e = "%E" % y
            for i in range(10):
                y_e = y_e.replace("0E", "E")
            y_e = y_e.replace(".E", "E")
            y_st = textNumEncode(y_e, changeDot=True)
        else:
            sign = ("-" if fac < 0 else "")
            fac = abs(fac)
            if fac == 1:
                fac_s = ""
            else:
                fac_s = "%s×" % _(fac)
            pw_s = _(10) + "ˆ" + _(pw)
            #pw_s = _(10) + "<span rise="5" size="small">" + \
            #	_(pw) + "</span>"  # Pango Markup Language
            y_st = sign + fac_s + pw_s
    return addLRM(y_st)
예제 #15
0
class NumRangesEntry(gtk.Entry):
    def __init__(self, _min, _max, page_inc=10):
        self._min = _min
        self._max = _max
        self.digs = locale_man.digits[locale_man.langSh]
        self.page_inc = page_inc
        ####
        gtk.Entry.__init__(self)
        self.connect('key-press-event', self.keyPress)
        self.set_direction(gtk.TextDirection.LTR)
        self.set_alignment(0.5)

    def insertText(self, s, clearSeceltion=True):
        selection = self.get_selection_bounds()
        if selection and clearSeceltion:
            start, end = selection
            text = toStr(self.get_text())
            text = text[:start] + s + text[end:]
            self.set_text(text)
            self.set_position(start + len(s))
        else:
            pos = self.get_position()
            self.insert_text(s, pos)
            self.set_position(pos + len(s))

    def numPlus(self, plus):
        pos = self.get_position()
        text = toStr(self.get_text())
        n = len(text)
        commaI = text.rfind(',', 0, pos)
        if commaI == -1:
            startI = 0
        else:
            if text[commaI + 1] == ' ':
                startI = commaI + 2
            else:
                startI = commaI + 1
        nextCommaI = text.find(',', pos)
        if nextCommaI == -1:
            endI = n
        else:
            endI = nextCommaI
        dashI = text.find('-', startI, endI)
        if dashI != -1:
            #print('dashI=%r'%dashI)
            if pos < dashI:
                endI = dashI
            else:
                startI = dashI + 1
        thisNumStr = text[startI:endI]
        #print(startI, endI, thisNumStr)
        if thisNumStr:
            thisNum = numDecode(thisNumStr)
            newNum = thisNum + plus
            if not self._min <= newNum <= self._max:
                return
        else:
            if plus > 0:
                newNum = self._max
            else:
                newNum = self._min
        newNumStr = _(newNum)
        newText = text[:startI] + newNumStr + text[endI:]
        self.set_text(newText)
        #print('new end index', endI - len(thisNumStr) + len(newNumStr))
        self.set_position(pos)
        self.select_region(
            startI,
            endI - len(thisNumStr) + len(newNumStr),
        )

    def keyPress(self, obj, gevent):
        kval = gevent.keyval
        kname = gdk.keyval_name(gevent.keyval).lower()
        #print(kval, kname)
        if kname in (
                'tab',
                'escape',
                'backspace',
                'delete',
                'insert',
                'home',
                'end',
                'control_l',
                'control_r',
                'iso_next_group',
        ):
            return False
        elif kname == 'return':
            self.validate()
            return False
        elif kname == 'up':
            self.numPlus(1)
        elif kname == 'down':
            self.numPlus(-1)
        elif kname == 'page_up':
            self.numPlus(self.page_inc)
        elif kname == 'page_down':
            self.numPlus(-self.page_inc)
        elif kname == 'left':
            return False  ## FIXME
        elif kname == 'right':
            return False  ## FIXME
        #elif kname in ('braceleft', 'bracketleft'):
        #    self.insertText(u'[')
        #elif kname in ('braceright', 'bracketright'):
        #    self.insertText(u']')
        elif kname in ('comma', 'arabic_comma'):
            self.insertText(', ', False)
        elif kname == 'minus':
            pos = self.get_position()
            text = toStr(self.get_text())
            n = len(text)
            if pos == n:
                start = numDecode(text.split(',')[-1].strip())
                self.insertText('-' + _(start + 2), False)
            else:
                self.insertText('-', False)
        elif ord('0') <= kval <= ord('9'):
            self.insertText(self.digs[kval - ord('0')])
        else:
            uniVal = gdk.keyval_to_unicode(kval)
            #print('uniVal=%r'%uniVal)
            if uniVal != 0:
                ch = chr(uniVal)
                #print('ch=%r'%ch)
                if ch in self.digs:
                    self.insertText(ch)
                if gevent.get_state(
                ) & gdk.ModifierType.CONTROL_MASK:  ## Shortcuts like Ctrl + [A, C, X, V]
                    return False
            else:
                print(kval, kname)
        return True

    getValues = lambda self: numRangesDecode(textNumDecode(self.get_text()))
    setValues = lambda self, values: self.set_text(
        textNumEncode(numRangesEncode(values), changeSpecialChars=False))
    validate = lambda self: self.setValues(self.getValues())
예제 #16
0
# with this program. If not, see <http://www.gnu.org/licenses/gpl.txt>.
# Also avalable in /usr/share/common-licenses/GPL on Debian systems
# or /usr/share/licenses/common/GPL3/license.txt on ArchLinux

from scal3 import core
from scal3.date_utils import dateEncode, dateDecode
from scal3.locale_man import tr as _
from scal3.locale_man import textNumEncode, textNumDecode
from scal3 import event_lib
from scal3 import ui

from scal3.ui_gtk import *
from scal3.ui_gtk.utils import toolButtonFromStock, set_tooltip

## FIXME
encode = lambda d: textNumEncode(dateEncode(d))
decode = lambda s: dateDecode(textNumDecode(s))
validate = lambda s: encode(decode(s))

class WidgetClass(gtk.HBox):
	def __init__(self, rule):
		self.rule = rule
		gtk.HBox.__init__(self)
		###
		self.countLabel = gtk.Label('')
		pack(self, self.countLabel)
		###
		self.trees = gtk.ListStore(str)
		self.dialog = None
		###
		self.editButton = gtk.Button(_('Edit'))
예제 #17
0
def encode(d):
    return textNumEncode(dateEncode(d))