Ejemplo n.º 1
0
 def save(self, widget=None):
     while gtk.events_pending():
         gtk.main_iteration_do(False)
     path = self.fcw.get_filename()
     if path in (None, ''):
         return
     print('Exporting to ics file "%s"'%path)
     self.waitingDo(
         self._save,
         path,
         core.primary_to_jd(*self.startDateInput.get_value()),
         core.primary_to_jd(*self.endDateInput.get_value()),
     )
Ejemplo n.º 2
0
 def save(self, widget=None):
     while gtk.events_pending():
         gtk.main_iteration_do(False)
     path = self.fcw.get_filename()
     if path in (None, ''):
         return
     print('Exporting to ics file "%s"' % path)
     self.waitingDo(
         self._save,
         path,
         core.primary_to_jd(*self.startDateInput.get_value()),
         core.primary_to_jd(*self.endDateInput.get_value()),
     )
Ejemplo n.º 3
0
 def save(self, widget=None):
     self.get_window().set_cursor(gdk.Cursor.new(gdk.CursorType.WATCH))
     while gtk.events_pending():
         gtk.main_iteration_do(False)
     path = self.fcw.get_filename()
     if path in (None, ''):
         return
     print('Exporting to ics file "%s"'%path)
     self.saveIcsFunc(
         path,
         core.primary_to_jd(*self.startDateInput.get_value()),
         core.primary_to_jd(*self.endDateInput.get_value()),
     )
     self.get_window().set_cursor(gdk.Cursor.new(gdk.CursorType.LEFT_PTR))
     self.destroy()
Ejemplo n.º 4
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)
Ejemplo n.º 5
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)
Ejemplo n.º 6
0
class CellCache:
	def __init__(self):
		self.jdCells = {} ## a mapping from julan_day to Cell instance
		self.plugins = {}
		self.weekEvents = {}
	def clear(self):
		global cell, todayCell
		self.jdCells = {}
		self.weekEvents = {}
		cell = self.getCell(cell.jd)
		todayCell = self.getCell(todayCell.jd)
	def registerPlugin(self, name, setParamsCallable, getCellGroupCallable):
		"""
			setParamsCallable(cell): cell.attr1 = value1 ....
			getCellGroupCallable(cellCache, *args): return cell_group
				call cellCache.getCell(jd) inside getCellGroupFunc
		"""
		self.plugins[name] = (
			setParamsCallable,
			getCellGroupCallable,
		)
		for localCell in self.jdCells.values():
			setParamsCallable(localCell)
	def getCell(self, jd):
		try:
			return self.jdCells[jd]
		except KeyError:
			return self.buildCell(jd)
	def getTmpCell(self, jd):## don't keep, no eventsData, no plugin params
		try:
			return self.jdCells[jd]
		except KeyError:
			return Cell(jd)
	getCellByDate = lambda self, y, m, d: self.getCell(core.primary_to_jd(y, m, d))
	getTodayCell = lambda self: self.getCell(core.getCurrentJd())
	def buildCell(self, jd):
		localCell = Cell(jd)
		for pluginData in self.plugins.values():
			pluginData[0](localCell)
		self.jdCells[jd] = localCell
		cleanCacheDict(self.jdCells, maxDayCacheSize, jd)
		return localCell
	getCellGroup = lambda self, pluginName, *args:\
		self.plugins[pluginName][1](self, *args)
	def getWeekData(self, absWeekNumber):
		cells = self.getCellGroup('WeekCal', absWeekNumber)
		try:
			wEventData = self.weekEvents[absWeekNumber]
		except KeyError:
			wEventData = event_lib.getWeekOccurrenceData(absWeekNumber, eventGroups)
			cleanCacheDict(self.weekEvents, maxWeekCacheSize, absWeekNumber)
			self.weekEvents[absWeekNumber] = wEventData
		return cells, wEventData
Ejemplo n.º 7
0
 def __init__(self, cellCache, year, month):
     self.year = year
     self.month = month
     self.monthLen = getMonthLen(year, month, calTypes.primary)
     self.offset = getWeekDay(year, month, 1)  ## month start offset
     initJd = core.primary_to_jd(year, month, 1)
     self.weekNum = [getWeekNumberByJd(initJd + i * 7) for i in range(6)]
     #########
     startJd, endJd = core.getJdRangeForMonth(year, month, calTypes.primary)
     tableStartJd = startJd - self.offset
     #####
     list.__init__(self, [[
         cellCache.getCell(tableStartJd + yPos * 7 + xPos)
         for xPos in range(7)
     ] for yPos in range(6)])
Ejemplo n.º 8
0
	def __init__(self, cellCache, year, month):
		self.year = year
		self.month = month
		self.monthLen = getMonthLen(year, month, calTypes.primary)
		self.offset = getWeekDay(year, month, 1)## month start offset
		initJd = core.primary_to_jd(year, month, 1)
		self.weekNum = [getWeekNumberByJd(initJd + i*7) for i in range(6)]
		#########
		startJd, endJd = core.getJdRangeForMonth(year, month, calTypes.primary)
		tableStartJd = startJd - self.offset
		#####
		list.__init__(self, [
			[
				cellCache.getCell(
					tableStartJd + yPos*7 + xPos
				) for xPos in range(7)
			] for yPos in range(6)
		])
Ejemplo n.º 9
0
Archivo: ui.py Proyecto: ilius/starcal
	def getCellByDate(self, y, m, d):
		return self.getCell(core.primary_to_jd(y, m, d))
Ejemplo n.º 10
0
	def getCellByDate(self, y, m, d):
		return self.getCell(core.primary_to_jd(y, m, d))