Beispiel #1
0
	def changeMode(self, mode):
		self.mode = mode
		if ui.boldYmLabel:
			self.label.set_label(
				"<b>%s</b>" % getMonthName(
					self.mode,
					self.active + 1,
				)
			)
		else:
			self.label.set_label(
				getMonthName(
					self.mode,
					self.active + 1,
				),
			)
		for i in range(12):
			if ui.monthRMenuNum:
				s = "%s: %s" % (
					self.getItemStr(i),
					getMonthName(self.mode, i + 1),
				)
			else:
				s = getMonthName(self.mode, i + 1)
			if i == self.active:
				s = self.getActiveStr(s)
			self.menuLabels[i].set_label(s)
Beispiel #2
0
	def setActive(self, active):
		# (Performance) update menu here, or make menu entirly
		# before popup?
		s = getMonthName(self.mode, active + 1)
		s2 = getMonthName(self.mode, self.active + 1)
		if self.menuLabels:
			if ui.monthRMenuNum:
				self.menuLabels[self.active].set_label(
					"%s: %s" % (
						self.getItemStr(self.active),
						s2,
					)
				)
				self.menuLabels[active].set_label(
					self.getActiveStr("%s: %s" % (
						self.getItemStr(active),
						s,
					)),
				)
			else:
				self.menuLabels[self.active].set_label(s2)
				self.menuLabels[active].set_label(self.getActiveStr(s))
		if ui.boldYmLabel:
			self.label.set_label("<b>%s</b>" % s)
		else:
			self.label.set_label(s)
		self.active = active
Beispiel #3
0
	def getText(self, year, month, day):
		yearlyData = self.yearlyData
		if not yearlyData:
			return ""
		mode = self.mode
		#if mode!=calTypes.primary:
		#	year, month, day = convert(year, month, day, calTypes.primary, mode)
		text = ""
		item = yearlyData[month - 1]
		if len(item) > day - 1:
			text = item[day - 1]
		if self.show_date and text:
			text = "%s %s: %s" % (
				_(day),
				getMonthName(mode, month),
				text,
			)
		if len(yearlyData) > 12:
			text2 = yearlyData[12].get((year, month, day), "")
			if text2:
				if text:
					text += "\n"
				if self.show_date:
					text2 = "%s %s %s: %s" % (
						_(day),
						getMonthName(mode, month, year),
						_(year),
						text2,
					)
				text += text2
		return text
Beispiel #4
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 html file "%s"'%path)
     i = self.combo.get_active()
     months = []
     module = calTypes.primaryModule()
     if i==0:
         s = getCurrentMonthStatus()
         months = [s]
         title = '%s %s'%(locale_man.getMonthName(calTypes.primary, s.month, s.year), _(s.year))
     elif i==1:
         for i in range(1, 13):
             months.append(getMonthStatus(ui.cell.year, i))
         title = '%s %s'%(_('Calendar'), _(ui.cell.year))
     elif i==2:
         y0, m0 = self.ymBox0.get_value()
         y1, m1 = self.ymBox1.get_value()
         for ym in range(y0*12+m0-1, y1*12+m1):
             y, m = divmod(ym, 12)
             m += 1
             months.append(getMonthStatus(y, m))
         title = _('Calendar')
     exportToHtml(path, months, title)
     self.get_window().set_cursor(gdk.Cursor.new(gdk.CursorType.LEFT_PTR))
     self.hide()
Beispiel #5
0
	def _save(self, path):
		comboItem = self.combo.get_active()
		months = []
		module = calTypes.primaryModule()
		if comboItem == 0:
			s = getCurrentMonthStatus()
			months = [s]
			title = "%s %s" % (
				locale_man.getMonthName(
					calTypes.primary,
					s.month,
					s.year,
				),
				_(s.year),
			)
		elif comboItem == 1:
			for i in range(1, 13):
				months.append(getMonthStatus(ui.cell.year, i))
			title = "%s %s" % (_("Calendar"), _(ui.cell.year))
		elif comboItem == 2:
			y0, m0 = self.ymBox0.get_value()
			y1, m1 = self.ymBox1.get_value()
			for ym in range(y0 * 12 + m0 - 1, y1 * 12 + m1):
				y, m = divmod(ym, 12)
				m += 1
				months.append(getMonthStatus(y, m))
			title = _("Calendar")
		exportToHtml(path, months, title)
		self.hide()
Beispiel #6
0
	def getStatusIconTooltip(self):
		##tt = core.weekDayName[core.getWeekDay(*ddate)]
		tt = core.weekDayName[core.jwday(ui.todayCell.jd)]
		#if ui.pluginsTextStatusIcon:##?????????
		#	sep = _(",")+" "
		#else:
		sep = "\n"
		for mode in calTypes.active:
			y, m, d = ui.todayCell.dates[mode]
			tt += "%s%s %s %s" % (
				sep,
				_(d),
				locale_man.getMonthName(mode, m, y),
				_(y),
			)
		if ui.pluginsTextStatusIcon:
			text = ui.todayCell.pluginsText
			if text != "":
				tt += "\n\n%s" % text  # .replace("\t", "\n") ## FIXME
		for item in ui.todayCell.eventsData:
			if not item["showInStatusIcon"]:
				continue
			itemS = ""
			if item["time"]:
				itemS += item["time"] + " - "
			itemS += item["text"][0]
			tt += "\n\n%s" % itemS
		return tt
Beispiel #7
0
	def changeMode(self, mode):
		if mode == self.rule.getMode():
			return
		for i in range(12):
			set_tooltip(
				self.buttons[i],
				locale_man.getMonthName(mode, i + 1),
			)
Beispiel #8
0
	def build(self, mode):
		active = self.get_active()
		ls = self.get_model()
		ls.clear()
		if self.includeEvery:
			ls.append([_("Every Month")])
		for m in range(1, 13):
			ls.append([locale_man.getMonthName(mode, m)])
		if active is not None:
			self.set_active(active)
Beispiel #9
0
 def get_text(self, y, m, d):
     if self.ymd:
         if (y, m, d) in self.ymd:
             if self.show_date:
                 return '%s %s %s: %s'%(_(d), getMonthName(self.mode, m),
                     _(y), self.ymd[(y, m, d)])
             else:
                 return self.ymd[(y, m, d)]
     if self.md:
         if (m, d) in self.md:
             if self.show_date:
                 return '%s %s %s: %s'%(
                     _(d),
                     getMonthName(self.mode, m),
                     _(y),
                     self.ymd[(y, m, d)],
                 )
             else:
                 return self.md[(m, d)]
     return ''
Beispiel #10
0
	def __init__(self, rule):
		self.rule = rule
		###
		gtk.HBox.__init__(self)
		###
		self.buttons = []
		mode = self.rule.getMode()
		for i in range(12):
			b = gtk.ToggleButton(_(i+1))
			set_tooltip(b, locale_man.getMonthName(mode, i+1))
			pack(self, b)
			self.buttons.append(b)
Beispiel #11
0
 def onConfigChange(self, *a, **kw):
     CustomizableCalObj.onConfigChange(self, *a, **kw)
     #####
     for child in self.get_children():
         child.destroy()
     ###
     monthLabels = []
     mode = calTypes.primary
     ##
     box = YearLabelButtonBox(mode)
     pack(self, box)
     self.appendItem(box.label)
     ##
     pack(self, gtk.VSeparator(), 1, 1)
     ##
     box = MonthLabelButtonBox(mode)
     pack(self, box)
     self.appendItem(box.label)
     monthLabels.append(box.label)
     ####
     for i, mode in list(enumerate(calTypes.active))[1:]:
         pack(self, gtk.VSeparator(), 1, 1)
         label = YearLabel(mode)
         pack(self, label)
         self.appendItem(label)
         ###############
         label = gtk.Label("")
         label.set_property("width-request", 5)
         pack(self, label)
         ###############
         label = MonthLabel(mode)
         pack(self, label)
         monthLabels.append(label)
         self.appendItem(label)
     ####
     ## updateTextWidth
     lay = newTextLayout(self)
     for label in monthLabels:
         wm = 0
         for m in range(12):
             name = getMonthName(label.mode, m)
             if ui.boldYmLabel:
                 lay.set_markup("<b>%s</b>" % name)
             else:
                 lay.set_text(name)  ## OR lay.set_markup
             w = lay.get_pixel_size()[0]
             if w > wm:
                 wm = w
         label.set_property("width-request", wm)
     #####
     self.show_all()
     #####
     self.onDateChange()
Beispiel #12
0
 def createMenuLabels(self):
     if self.menuLabels:
         return
     for i in range(12):
         if ui.monthRMenuNum:
             text = "%s: %s" % (self.getItemStr(i), _(getMonthName(self.mode, i + 1)))
         else:
             text = _(getMonthName(self.mode, i + 1))
         if i == self.active:
             text = self.getActiveStr(text)
         item = MenuItem()
         label = item.get_child()
         label.set_label(text)
         # label.set_justify(gtk.Justification.LEFT)
         label.set_alignment(0, 0.5)
         label.set_use_markup(True)
         item.set_right_justified(True)  ##?????????
         item.connect("activate", self.itemActivate, i)
         self.menu.append(item)
         self.menuLabels.append(label)
     self.menu.show_all()
Beispiel #13
0
    def get_text(self, year, month, day):
        yearlyData = self.yearlyData
        if not yearlyData:
            return ''
        mode = self.mode
        text = ''
        #if mode!=calTypes.primary:
        #    year, month, day = convert(year, month, day, calTypes.primary, mode)
        try:
            text = yearlyData[month-1][day-1]
        except:## KeyError or IndexError
            pass
        else:
            if self.show_date and text:
                text = '%s %s: %s'%(
                    _(day),
                    getMonthName(mode, month),
                    text,
                )
        try:
            text2 = yearlyData[12][(year, month, day)]
        except:## KeyError or IndexError
            pass
        else:
            if text:
                text += '\n'
            if self.show_date:
                text2 = '%s %s %s: %s'%(
                    _(day),
                    getMonthName(mode, month, year),
                    _(year),
                    text2,
                )

            text += text2
        return text
Beispiel #14
0
 def _save(self, path):
     comboItem = self.combo.get_active()
     months = []
     module = calTypes.primaryModule()
     if comboItem == 0:
         s = getCurrentMonthStatus()
         months = [s]
         title = '%s %s' % (locale_man.getMonthName(
             calTypes.primary, s.month, s.year), _(s.year))
     elif comboItem == 1:
         for i in range(1, 13):
             months.append(getMonthStatus(ui.cell.year, i))
         title = '%s %s' % (_('Calendar'), _(ui.cell.year))
     elif comboItem == 2:
         y0, m0 = self.ymBox0.get_value()
         y1, m1 = self.ymBox1.get_value()
         for ym in range(y0 * 12 + m0 - 1, y1 * 12 + m1):
             y, m = divmod(ym, 12)
             m += 1
             months.append(getMonthStatus(y, m))
         title = _('Calendar')
     exportToHtml(path, months, title)
     self.hide()
Beispiel #15
0
 def getStatusIconTooltip(self):
     ##tt = core.weekDayName[core.getWeekDay(*ddate)]
     tt = core.weekDayName[core.jwday(ui.todayCell.jd)]
     #if ui.pluginsTextStatusIcon:##?????????
     #    sep = _(',')+' '
     #else:
     sep = '\n'
     for mode in calTypes.active:
         y, m, d = ui.todayCell.dates[mode]
         tt += '%s%s %s %s'%(sep, _(d), locale_man.getMonthName(mode, m, y), _(y))
     if ui.pluginsTextStatusIcon:
         text = ui.todayCell.pluginsText
         if text!='':
             tt += '\n\n%s'%text ## .replace('\t', '\n') ## FIXME
     for item in ui.todayCell.eventsData:
         if not item['showInStatusIcon']:
             continue
         itemS = ''
         if item['time']:
             itemS += item['time'] + ' - '
         itemS += item['text'][0]
         tt += '\n\n%s'%itemS
     return tt
Beispiel #16
0
	def getStatusIconTooltip(self):
		##tt = core.weekDayName[core.getWeekDay(*ddate)]
		tt = core.weekDayName[core.jwday(ui.todayCell.jd)]
		#if ui.pluginsTextStatusIcon:##?????????
		#	sep = _(',')+' '
		#else:
		sep = '\n'
		for mode in calTypes.active:
			y, m, d = ui.todayCell.dates[mode]
			tt += '%s%s %s %s'%(sep, _(d), locale_man.getMonthName(mode, m, y), _(y))
		if ui.pluginsTextStatusIcon:
			text = ui.todayCell.pluginsText
			if text!='':
				tt += '\n\n%s'%text ## .replace('\t', '\n') ## FIXME
		for item in ui.todayCell.eventsData:
			if not item['showInStatusIcon']:
				continue
			itemS = ''
			if item['time']:
				itemS += item['time'] + ' - '
			itemS += item['text'][0]
			tt += '\n\n%s'%itemS
		return tt
Beispiel #17
0
	def changeMode(self, mode):
		if mode!=self.rule.getMode():
			for i in range(12):
				set_tooltip(self.buttons[i], locale_man.getMonthName(mode, i+1))
Beispiel #18
0
 def onDraw(self, widget=None, event=None):
     cr = self.get_window().cairo_create()
     width = float(self.get_allocation().width)
     height = float(self.get_allocation().height)
     dia = min(width, height)
     maxR = float(dia) / 2.0
     minR = self.innerCircleRatio * maxR
     x0 = (width - dia) / 2.0
     y0 = (height - dia) / 2.0
     cx = x0 + maxR
     cy = y0 + maxR
     ####
     #self.angleOffset
     #self.bgColor
     #self.wheelBgColor
     #self.lineColor
     #self.lineWidth
     #self.textColor
     ####
     cr.rectangle(0, 0, width, height)
     fillColor(cr, self.bgColor)
     ####
     calsN = len(calTypes.active)
     deltaR = (maxR - minR) / float(calsN)
     mode0 = calTypes.active[0]
     jd0 = to_jd(ui.todayCell.year, 1, 1, mode0)
     yearLen = calTypes.primaryModule().avgYearLen
     angle0 = self.angleOffset * pi / 180.0 - pi / 2.0
     avgDeltaAngle = 2 * pi / 12
     ####
     if self.todayIndicatorEnable:
         drawLineLengthAngle(
             cr,
             cx,
             cy,
             maxR,  ## FIXME
             angle0 + 2.0 * pi * (ui.todayCell.jd - jd0) / yearLen,
             self.todayIndicatorWidth,
         )
         fillColor(cr, self.todayIndicatorColor)
     ####
     drawCircle(cr, cx, cy, self.centerR)
     fillColor(cr, self.centerColor)
     ####
     drawCircleOutline(cr, cx, cy, maxR, maxR - minR)
     fillColor(cr, self.wheelBgColor)
     ####
     spinngJd = getSpringJdAfter(jd0)
     springAngle = angle0 + 2.0 * pi * (spinngJd -
                                        jd0) / yearLen  ## radians
     for index, color in enumerate((
             self.springColor,
             self.summerColor,
             self.autumnColor,
             self.winterColor,
     )):
         drawArcOutline(
             cr,
             cx,
             cy,
             maxR,
             maxR - minR,
             springAngle + index * pi / 2.0,
             springAngle + (index + 1) * pi / 2.0,
         )
         fillColor(cr, color)
     ####
     for index, mode in enumerate(calTypes.active):
         dr = index * deltaR
         r = maxR - dr
         cx0 = x0 + dr
         cy0 = y0 + dr
         ###
         drawCircleOutline(cr, cx, cy, r, self.lineWidth)
         fillColor(cr, self.lineColor)
         ####
         year0, month0, day0 = jd_to(jd0, mode)
         ym0 = year0 * 12 + (month0 - 1)
         cr.set_line_width(self.lineWidth)
         for ym in range(ym0, ym0 + 12):
             year, month = divmod(ym, 12)
             month += 1
             jd = to_jd(year, month, 1, mode)
             angle = angle0 + 2.0 * pi * (jd - jd0) / yearLen  ## radians
             #angleD = angle * 180 / pi
             #print('mode=%s, year=%s, month=%s, angleD=%.1f'%(mode, year, month, angleD))
             d = self.lineWidth
             sepX, sepY = goAngle(
                 cx,
                 cy,
                 angle,
                 r - d * 0.2,  ## FIXME
             )
             drawLineLengthAngle(
                 cr,
                 sepX,
                 sepY,
                 deltaR - d * 0.2,  ## FIXME
                 angle + pi,
                 d,
             )
             fillColor(
                 cr,
                 self.yearStartLineColor if month == 1 else self.lineColor,
             )
             ###
             layoutMaxW = (r - deltaR) * 2.0 * pi / 12.0
             layoutMaxH = deltaR
             layout = newTextLayout(
                 self,
                 text=getMonthName(mode, month, year),
                 maxSize=(layoutMaxW, layoutMaxH),
                 maximizeScale=0.6,
                 truncate=False,
             )
             layoutW, layoutH = layout.get_pixel_size()
             centerAngle = angle + avgDeltaAngle / 2.0
             lx, ly = goAngle(
                 cx,
                 cy,
                 centerAngle,
                 (r - deltaR / 3.0),
             )
             lx, ly = goAngle(
                 lx,
                 ly,
                 angle - pi / 2.0,
                 layoutW / 2.0,
             )
             lx, ly = goAngle(
                 lx,
                 ly,
                 angle,
                 layoutH / 2.0,
             )
             cr.move_to(
                 lx,
                 ly,
             )
             #cr.save()
             rotateAngle = centerAngle + pi / 2.0
             cr.rotate(rotateAngle)
             setColor(cr, self.textColor)
             show_layout(cr, layout)
             cr.rotate(-rotateAngle)
             #cr.restore()
         #####
         drawCircleOutline(cr, cx, cy, minR, self.lineWidth)
         fillColor(cr, self.lineColor)
Beispiel #19
0
	def onDraw(self, widget=None, event=None):
		cr = self.get_window().cairo_create()
		width = float(self.get_allocation().width)
		height = float(self.get_allocation().height)
		dia = min(width, height)
		maxR = float(dia) / 2.0
		minR = self.innerCircleRatio * maxR
		x0 = (width - dia) / 2.0
		y0 = (height - dia) / 2.0
		cx = x0 + maxR
		cy = y0 + maxR
		####
		#self.angleOffset
		#self.bgColor
		#self.wheelBgColor
		#self.lineColor
		#self.lineWidth
		#self.textColor
		####
		cr.rectangle(0, 0, width, height)
		fillColor(cr, self.bgColor)
		####
		calsN = len(calTypes.active)
		deltaR = (maxR - minR) / float(calsN)
		mode0 = calTypes.active[0]
		jd0 = to_jd(ui.todayCell.year, 1, 1, mode0)
		yearLen = calTypes.primaryModule().avgYearLen
		angle0 = self.angleOffset * pi / 180.0 - pi/2.0
		avgDeltaAngle = 2*pi / 12
		####
		if self.todayIndicatorEnable:
			drawLineLengthAngle(
				cr,
				cx,
				cy,
				maxR,## FIXME
				angle0 + 2.0*pi*(ui.todayCell.jd - jd0)/yearLen,
				self.todayIndicatorWidth,
			)
			fillColor(cr, self.todayIndicatorColor)
		####
		drawCircle(cr, cx, cy, self.centerR)
		fillColor(cr, self.centerColor)
		####
		drawCircleOutline(cr, cx, cy, maxR, maxR-minR)
		fillColor(cr, self.wheelBgColor)
		####
		spinngJd = getSpringJdAfter(jd0)
		springAngle = angle0 + 2.0*pi*(spinngJd - jd0)/yearLen ## radians
		for index, color in enumerate((
			self.springColor,
			self.summerColor,
			self.autumnColor,
			self.winterColor,
		)):
			drawArcOutline(
				cr,
				cx,
				cy,
				maxR,
				maxR-minR,
				springAngle + index * pi/2.0,
				springAngle + (index+1) * pi/2.0,
			)
			fillColor(cr, color)
		####
		for index, mode in enumerate(calTypes.active):
			dr = index * deltaR
			r = maxR - dr
			cx0 = x0 + dr
			cy0 = y0 + dr
			###
			drawCircleOutline(cr, cx, cy, r, self.lineWidth)
			fillColor(cr, self.lineColor)
			####
			year0, month0, day0 = jd_to(jd0, mode)
			ym0 = year0*12 + (month0-1)
			cr.set_line_width(self.lineWidth)
			for ym in range(ym0, ym0 + 12):
				year, month = divmod(ym, 12) ; month += 1
				jd = to_jd(year, month, 1, mode)
				angle = angle0 + 2.0*pi*(jd - jd0)/yearLen ## radians
				#angleD = angle * 180 / pi
				#print('mode=%s, year=%s, month=%s, angleD=%.1f'%(mode, year, month, angleD))
				d = self.lineWidth
				sepX, sepY = goAngle(
					cx,
					cy,
					angle,
					r - d*0.2,## FIXME
				)
				drawLineLengthAngle(
					cr,
					sepX,
					sepY,
					deltaR - d*0.2,## FIXME
					angle + pi,
					d,
				)
				fillColor(
					cr,
					self.yearStartLineColor if month==1 else self.lineColor,
				)
				###
				layoutMaxW = (r - deltaR) * 2.0 * pi / 12.0
				layoutMaxH = deltaR
				layout = newTextLayout(
					self,
					text=getMonthName(mode, month, year),
					maxSize=(layoutMaxW, layoutMaxH),
					maximizeScale=0.6,
					truncate=False,
				)
				layoutW, layoutH = layout.get_pixel_size()
				centerAngle = angle + avgDeltaAngle/2.0
				lx, ly = goAngle(
					cx,
					cy,
					centerAngle,
					(r - deltaR/3.0),
				)
				lx, ly = goAngle(
					lx,
					ly,
					angle - pi/2.0,
					layoutW / 2.0,
				)
				lx, ly = goAngle(
					lx,
					ly,
					angle,
					layoutH / 2.0,
				)
				cr.move_to(
					lx,
					ly,
				)
				#cr.save()
				rotateAngle = centerAngle + pi/2.0
				cr.rotate(rotateAngle)
				setColor(cr, self.textColor) ; show_layout(cr, layout)    
				cr.rotate(-rotateAngle)
				#cr.restore()
			#####
			drawCircleOutline(cr, cx, cy, minR, self.lineWidth)
			fillColor(cr, self.lineColor)