Exemplo n.º 1
0
Arquivo: ui.py Projeto: ilius/starcal
 def __init__(self, jd):
     self.eventsData = []
     # self.eventsDataIsSet = False ## not used
     self.pluginsText = ""
     ###
     self.jd = jd
     date = core.jd_to_primary(jd)
     self.year, self.month, self.day = date
     self.weekDay = core.jwday(jd)
     self.weekNum = core.getWeekNumber(self.year, self.month, self.day)
     # self.weekNumNeg = self.weekNum + 1 - core.getYearWeeksCount(self.year)
     self.weekNumNeg = self.weekNum - int(calTypes.primaryModule().avgYearLen / 7)
     self.holiday = self.weekDay in core.holidayWeekDays
     ###################
     self.dates = [date if mode == calTypes.primary else jd_to(jd, mode) for mode in range(len(calTypes))]
     """
     self.dates = dict([
         (
             mode, date if mode==calTypes.primary else jd_to(jd, mode)
         )
         for mode in calTypes.active
     ])
     """
     ###################
     for k in core.plugIndex:
         plug = core.allPlugList[k]
         if plug:
             try:
                 plug.update_cell(self)
             except:
                 myRaiseTback()
     ###################
     # t0 = now()
     self.eventsData = event_lib.getDayOccurrenceData(jd, eventGroups)  ## here? FIXME
Exemplo n.º 2
0
	def __init__(self, jd):
		self.eventsData = []
		# self.eventsDataIsSet = False  # not used
		self.pluginsText = ""
		###
		self.jd = jd
		date = core.jd_to_primary(jd)
		self.year, self.month, self.day = date
		self.weekDay = core.jwday(jd)
		self.weekNum = core.getWeekNumber(self.year, self.month, self.day)
		# self.weekNumNeg = self.weekNum+1 - core.getYearWeeksCount(self.year)
		self.weekNumNeg = self.weekNum - int(
			calTypes.primaryModule().avgYearLen / 7
		)
		self.holiday = (self.weekDay in core.holidayWeekDays)
		###################
		self.dates = [
			date if mode == calTypes.primary else jd_to(jd, mode)
			for mode in range(len(calTypes))
		]
		"""
		self.dates = dict([
			(
				mode, date if mode==calTypes.primary else jd_to(jd, mode)
			)
			for mode in calTypes.active
		])
		"""
		###################
		for k in core.plugIndex:
			plug = core.allPlugList[k]
			if plug:
				try:
					plug.updateCell(self)
				except:
					myRaiseTback()
		###################
		# t0 = now()
		self.eventsData = event_lib.getDayOccurrenceData(
			jd,
			eventGroups,
		)  # here? FIXME
		"""
Exemplo n.º 3
0
 def __init__(self, showDesc=False):
     gtk.Window.__init__(self)
     self.maximize()
     self.initVars()
     ud.windowList.appendItem(self)
     ###
     self.set_title(_("Search Events"))
     self.connect("delete-event", self.closed)
     self.connect("key-press-event", self.keyPress)
     ###
     self.vbox = gtk.VBox()
     self.add(self.vbox)
     ######
     frame = TextFrame()
     frame.set_label(_("Text"))
     frame.set_border_width(5)
     pack(self.vbox, frame)
     self.textInput = frame
     ##
     hbox = gtk.HBox()
     self.textCSensCheck = gtk.CheckButton(_("Case Sensitive"))
     self.textCSensCheck.set_active(False)  ## FIXME
     pack(hbox, self.textCSensCheck)
     pack(self.vbox, hbox)
     ######
     jd = core.getCurrentJd()
     year, month, day = jd_to_primary(jd)
     ######
     hbox = gtk.HBox()
     frame = gtk.Frame()
     frame.set_label(_("Time"))
     frame.set_border_width(5)
     vboxIn = gtk.VBox()
     sgroup = gtk.SizeGroup(gtk.SizeGroupMode.HORIZONTAL)
     ####
     hboxIn = gtk.HBox()
     ##
     self.timeFromCheck = gtk.CheckButton(_("From"))
     sgroup.add_widget(self.timeFromCheck)
     pack(hboxIn, self.timeFromCheck)
     pack(hboxIn, gtk.Label("  "))
     ##
     self.timeFromInput = DateTimeButton()
     self.timeFromInput.set_value(((year, 1, 1), (0, 0, 0)))
     pack(hboxIn, self.timeFromInput)
     ##
     pack(vboxIn, hboxIn)
     ####
     hboxIn = gtk.HBox()
     ##
     self.timeToCheck = gtk.CheckButton(_("To"))
     sgroup.add_widget(self.timeToCheck)
     pack(hboxIn, self.timeToCheck)
     pack(hboxIn, gtk.Label("  "))
     ##
     self.timeToInput = DateTimeButton()
     self.timeToInput.set_value((
         (year + 1, 1, 1),
         (0, 0, 0),
     ))
     pack(hboxIn, self.timeToInput)
     ##
     pack(vboxIn, hboxIn)
     ##
     self.timeFromCheck.connect("clicked", self.updateTimeFromSensitive)
     self.timeToCheck.connect("clicked", self.updateTimeToSensitive)
     self.updateTimeFromSensitive()
     self.updateTimeToSensitive()
     ####
     vboxIn.set_border_width(5)
     frame.add(vboxIn)
     pack(hbox, frame)
     pack(hbox, gtk.Label(""), 1, 1)
     pack(self.vbox, hbox)
     ######
     hbox = gtk.HBox()
     hbox.set_border_width(5)
     self.modifiedFromCheck = gtk.CheckButton(_("Modified From"))
     pack(hbox, self.modifiedFromCheck)
     pack(hbox, gtk.Label("  "))
     self.modifiedFromInput = DateTimeButton()
     self.modifiedFromInput.set_value(((year, 1, 1), (0, 0, 0)))
     pack(hbox, self.modifiedFromInput)
     ##
     self.modifiedFromCheck.connect("clicked",
                                    self.updateModifiedFromSensitive)
     self.updateModifiedFromSensitive()
     pack(self.vbox, hbox)
     ######
     hbox = gtk.HBox()
     hbox.set_border_width(5)
     self.typeCheck = gtk.CheckButton(_("Event Type"))
     pack(hbox, self.typeCheck)
     pack(hbox, gtk.Label("  "))
     ##
     combo = gtk.ComboBoxText()
     for cls in event_lib.classes.event:
         combo.append_text(cls.desc)
     combo.set_active(0)
     pack(hbox, combo)
     self.typeCombo = combo
     ##
     self.typeCheck.connect("clicked", self.updateTypeSensitive)
     self.updateTypeSensitive()
     pack(self.vbox, hbox)
     ######
     hbox = gtk.HBox()
     hbox.set_border_width(5)
     self.groupCheck = gtk.CheckButton(_("Group"))
     pack(hbox, self.groupCheck)
     pack(hbox, gtk.Label("  "))
     self.groupCombo = SingleGroupComboBox()
     pack(hbox, self.groupCombo)
     ##
     self.groupCheck.connect("clicked", self.updateGroupSensitive)
     self.updateGroupSensitive()
     pack(self.vbox, hbox)
     ######
     bbox = gtk.HButtonBox()
     bbox.set_layout(gtk.ButtonBoxStyle.START)
     bbox.set_border_width(5)
     searchButton = gtk.Button()
     searchButton.set_label(_("_Search"))
     searchButton.set_image(
         gtk.Image.new_from_stock(
             gtk.STOCK_FIND,
             gtk.IconSize.BUTTON,
         ))
     searchButton.connect("clicked", self.searchClicked)
     bbox.add(searchButton)
     pack(self.vbox, bbox)
     ######
     treev = gtk.TreeView()
     trees = gtk.TreeStore(
         int,  # gid
         int,  # eid
         str,  # group_name
         GdkPixbuf.Pixbuf,  # icon
         str,  # summary
         str,  # description
     )
     ###
     treev.set_model(trees)
     treev.connect("button-press-event", self.treevButtonPress)
     treev.connect("row-activated", self.rowActivated)
     treev.connect("key-press-event", self.treevKeyPress)
     treev.set_headers_clickable(True)
     ###
     self.colGroup = gtk.TreeViewColumn(
         _("Group"),
         gtk.CellRendererText(),
         text=2,
     )
     self.colGroup.set_resizable(True)
     self.colGroup.set_sort_column_id(2)
     self.colGroup.set_property("expand", False)
     treev.append_column(self.colGroup)
     ###
     self.colIcon = gtk.TreeViewColumn()
     cell = gtk.CellRendererPixbuf()
     pack(self.colIcon, cell)
     self.colIcon.add_attribute(cell, "pixbuf", 3)
     #self.colIcon.set_sort_column_id(3)  # FIXME
     self.colIcon.set_property("expand", False)
     treev.append_column(self.colIcon)
     ###
     self.colSummary = gtk.TreeViewColumn(
         _("Summary"),
         gtk.CellRendererText(),
         text=4,
     )
     self.colSummary.set_resizable(True)
     self.colSummary.set_sort_column_id(4)
     self.colSummary.set_property("expand", True)  # FIXME
     treev.append_column(self.colSummary)
     ###
     self.colDesc = gtk.TreeViewColumn(
         _("Description"),
         gtk.CellRendererText(),
         text=5,
     )
     self.colDesc.set_sort_column_id(5)
     self.colDesc.set_visible(showDesc)
     self.colDesc.set_property("expand", True)  # FIXME
     treev.append_column(self.colDesc)
     ###
     trees.set_sort_func(2, self.sort_func_group)
     ######
     swin = gtk.ScrolledWindow()
     swin.set_policy(gtk.PolicyType.AUTOMATIC, gtk.PolicyType.AUTOMATIC)
     swin.add(treev)
     ####
     vbox = gtk.VBox(spacing=5)
     vbox.set_border_width(5)
     ###
     topHbox = gtk.HBox()
     self.resultLabel = gtk.Label("")
     pack(topHbox, self.resultLabel)
     pack(topHbox, gtk.Label(""), 1, 1)
     pack(vbox, topHbox)
     ####
     columnBox = gtk.HBox(spacing=5)
     pack(columnBox, gtk.Label(_("Columns") + ":    "))
     ##
     check = gtk.CheckButton(_("Group"))
     check.set_active(True)
     check.connect(
         "clicked",
         lambda w: self.colGroup.set_visible(w.get_active()),
     )
     pack(columnBox, check)
     ##
     check = gtk.CheckButton(_("Icon"))
     check.set_active(True)
     check.connect(
         "clicked",
         lambda w: self.colIcon.set_visible(w.get_active()),
     )
     pack(columnBox, check)
     ##
     check = gtk.CheckButton(_("Summary"))
     check.set_active(True)
     check.connect(
         "clicked",
         lambda w: self.colSummary.set_visible(w.get_active()),
     )
     pack(columnBox, check)
     ##
     check = gtk.CheckButton(_("Description"))
     check.set_active(showDesc)
     check.connect(
         "clicked",
         lambda w: self.colDesc.set_visible(w.get_active()),
     )
     pack(columnBox, check)
     ##
     pack(vbox, columnBox)
     ####
     pack(vbox, swin, 1, 1)
     ##
     frame = gtk.Frame()
     frame.set_label(_("Search Results"))
     frame.set_border_width(10)
     frame.add(vbox)
     ##
     pack(self.vbox, frame, 1, 1)
     ###
     bbox2 = gtk.HButtonBox()
     bbox2.set_layout(gtk.ButtonBoxStyle.END)
     bbox2.set_border_width(10)
     closeButton = gtk.Button()
     closeButton.set_label(_("_Close"))
     closeButton.set_image(
         gtk.Image.new_from_stock(
             gtk.STOCK_CLOSE,
             gtk.IconSize.BUTTON,
         ))
     closeButton.connect("clicked", self.closed)
     bbox2.add(closeButton)
     pack(self.vbox, bbox2)
     ######
     self.treev = treev
     self.trees = trees
     self.vbox.show_all()
Exemplo n.º 4
0
def calcTimeLineData(timeStart, timeWidth, pixelPerSec, borderTm):
    timeEnd = timeStart + timeWidth
    jd0 = getJdFromEpoch(timeStart)
    jd1 = getJdFromEpoch(timeEnd)
    widthDays = float(timeWidth) / dayLen
    dayPixel = dayLen * pixelPerSec  ## px
    #print('dayPixel = %s px'%dayPixel)
    getEPos = lambda epoch: (epoch - timeStart) * pixelPerSec
    getJPos = lambda jd: (getEpochFromJd(jd) - timeStart) * pixelPerSec
    ######################## Holidays
    holidays = []
    if changeHolidayBg and changeHolidayBgMinDays < widthDays < changeHolidayBgMaxDays:
        for jd in getHolidaysJdList(jd0, jd1 + 1):
            holidays.append(getJPos(jd))
    ######################## Ticks
    ticks = []
    tickEpochList = []
    minStep = minorStepMin / pixelPerSec  ## second
    #################
    year0, month0, day0 = jd_to_primary(jd0)
    year1, month1, day1 = jd_to_primary(jd1)
    ############ Year
    minStepYear = minStep // minYearLenSec  ## years ## int or iceil?
    yearPixel = minYearLenSec * pixelPerSec  ## pixels
    for (year, size) in getYearRangeTickValues(year0, year1 + 1, minStepYear):
        tmEpoch = getEpochFromDate(year, 1, 1, calTypes.primary)
        if tmEpoch in tickEpochList:
            continue
        unitSize = size * yearPixel
        label = formatYear(year) if unitSize >= majorStepMin else ''
        ticks.append(Tick(
            tmEpoch,
            getEPos(tmEpoch),
            unitSize,
            label,
        ))
        tickEpochList.append(tmEpoch)
    ############ Month
    monthPixel = avgMonthLen * pixelPerSec  ## px
    minMonthUnit = float(minStep) / avgMonthLen  ## month
    if minMonthUnit <= 3:
        for ym in range(year0 * 12 + month0 - 1,
                        year1 * 12 + month1 - 1 + 1):  ## +1 FIXME
            if ym % 3 == 0:
                monthUnit = 3
            else:
                monthUnit = 1
            if monthUnit < minMonthUnit:
                continue
            y, m = divmod(ym, 12)
            m += 1
            tmEpoch = getEpochFromDate(y, m, 1, calTypes.primary)
            if tmEpoch in tickEpochList:
                continue
            unitSize = monthPixel * monthUnit
            ticks.append(
                Tick(
                    tmEpoch,
                    getEPos(tmEpoch),
                    unitSize,
                    getMonthName(calTypes.primary, m)
                    if unitSize >= majorStepMin else '',
                ))
            tickEpochList.append(tmEpoch)
    ################
    if showWeekStart and showWeekStartMinDays < widthDays < showWeekStartMaxDays:
        wd0 = jwday(jd0)
        jdw0 = jd0 + (core.firstWeekDay - wd0) % 7
        unitSize = dayPixel * 7
        if unitSize < majorStepMin:
            label = ''
        else:
            label = core.weekDayNameAb[core.firstWeekDay]
        for jd in range(jdw0, jd1 + 1, 7):
            tmEpoch = getEpochFromJd(jd)
            ticks.append(
                Tick(
                    tmEpoch,
                    getEPos(tmEpoch),
                    unitSize,
                    label,
                    color=weekStartTickColor,
                ))
            #tickEpochList.append(tmEpoch)
    ############ Day of Month
    hasMonthName = timeWidth < 5 * dayLen
    minDayUnit = float(minStep) / dayLen  ## days
    if minDayUnit <= 15:
        for jd in range(jd0, jd1 + 1):
            tmEpoch = getEpochFromJd(jd)
            if tmEpoch in tickEpochList:
                continue
            year, month, day = jd_to_primary(jd)
            if day == 16:
                dayUnit = 15
            elif day in (6, 11, 21, 26):
                dayUnit = 5
            else:
                dayUnit = 1
            if dayUnit < minDayUnit:
                continue
            unitSize = dayPixel * dayUnit
            if unitSize < majorStepMin:
                label = ''
            elif hasMonthName:
                label = _(day) + ' ' + getMonthName(calTypes.primary, month)
            else:
                label = _(day)
            ticks.append(Tick(
                tmEpoch,
                getEPos(tmEpoch),
                unitSize,
                label,
            ))
            tickEpochList.append(tmEpoch)
    ############ Hour, Minute, Second
    for stepUnit, stepValue in unitSteps:
        stepSec = stepUnit * stepValue
        if stepSec < minStep:
            break
        unitSize = stepSec * pixelPerSec
        utcOffset = int(getUtcOffsetCurrent())
        firstEpoch = iceil(
            (timeStart + utcOffset) / stepSec) * stepSec - utcOffset
        for tmEpoch in range(firstEpoch, iceil(timeEnd), stepSec):
            if tmEpoch in tickEpochList:
                continue
            if unitSize < majorStepMin:
                label = ''
            else:
                jd, h, m, s = getJhmsFromEpoch(tmEpoch)
                if s == 0:
                    label = '%s:%s' % (
                        _(h),
                        _(m, fillZero=2),
                    )
                else:  # elif timeWidth < 60 or stepSec < 30:
                    label = addLRM('%s"' % _(s, fillZero=2))
                #else:
                #    label = '%s:%s:%s'%(
                #        _(h),
                #        _(m, fillZero=2),
                #        _(s, fillZero=2),
                #    )
            ticks.append(Tick(
                tmEpoch,
                getEPos(tmEpoch),
                unitSize,
                label,
            ))
            tickEpochList.append(tmEpoch)
    ######################## Event Boxes
    data = {
        'holidays': holidays,
        'ticks': ticks,
        'boxes': [],
    }
    ###
    data['boxes'] = calcEventBoxes(
        timeStart,
        timeEnd,
        pixelPerSec,
        borderTm,
    )
    ###
    return data
Exemplo n.º 5
0
	def __init__(self, showDesc=False):
		gtk.Window.__init__(self)
		self.maximize()
		self.initVars()
		ud.windowList.appendItem(self)
		###
		self.set_title(_("Search Events"))
		self.connect("delete-event", self.closed)
		self.connect("key-press-event", self.keyPress)
		###
		self.vbox = gtk.VBox()
		self.add(self.vbox)
		######
		frame = TextFrame()
		frame.set_label(_("Text"))
		frame.set_border_width(5)
		pack(self.vbox, frame)
		self.textInput = frame
		##
		hbox = gtk.HBox()
		self.textCSensCheck = gtk.CheckButton(_("Case Sensitive"))
		self.textCSensCheck.set_active(False) ## FIXME
		pack(hbox, self.textCSensCheck)
		pack(self.vbox, hbox)
		######
		jd = core.getCurrentJd()
		year, month, day = jd_to_primary(jd)
		######
		hbox = gtk.HBox()
		frame = gtk.Frame()
		frame.set_label(_("Time"))
		frame.set_border_width(5)
		vboxIn = gtk.VBox()
		sgroup = gtk.SizeGroup(gtk.SizeGroupMode.HORIZONTAL)
		####
		hboxIn = gtk.HBox()
		##
		self.timeFromCheck = gtk.CheckButton(_("From"))
		sgroup.add_widget(self.timeFromCheck)
		pack(hboxIn, self.timeFromCheck)
		pack(hboxIn, gtk.Label("  "))
		##
		self.timeFromInput = DateTimeButton()
		self.timeFromInput.set_value(((year, 1, 1), (0, 0, 0)))
		pack(hboxIn, self.timeFromInput)
		##
		pack(vboxIn, hboxIn)
		####
		hboxIn = gtk.HBox()
		##
		self.timeToCheck = gtk.CheckButton(_("To"))
		sgroup.add_widget(self.timeToCheck)
		pack(hboxIn, self.timeToCheck)
		pack(hboxIn, gtk.Label("  "))
		##
		self.timeToInput = DateTimeButton()
		self.timeToInput.set_value((
			(year + 1, 1, 1),
			(0, 0, 0),
		))
		pack(hboxIn, self.timeToInput)
		##
		pack(vboxIn, hboxIn)
		##
		self.timeFromCheck.connect("clicked", self.updateTimeFromSensitive)
		self.timeToCheck.connect("clicked", self.updateTimeToSensitive)
		self.updateTimeFromSensitive()
		self.updateTimeToSensitive()
		####
		vboxIn.set_border_width(5)
		frame.add(vboxIn)
		pack(hbox, frame)
		pack(hbox, gtk.Label(""), 1, 1)
		pack(self.vbox, hbox)
		######
		hbox = gtk.HBox()
		hbox.set_border_width(5)
		self.modifiedFromCheck = gtk.CheckButton(_("Modified From"))
		pack(hbox, self.modifiedFromCheck)
		pack(hbox, gtk.Label("  "))
		self.modifiedFromInput = DateTimeButton()
		self.modifiedFromInput.set_value(((year, 1, 1), (0, 0, 0)))
		pack(hbox, self.modifiedFromInput)
		##
		self.modifiedFromCheck.connect("clicked", self.updateModifiedFromSensitive)
		self.updateModifiedFromSensitive()
		pack(self.vbox, hbox)
		######
		hbox = gtk.HBox()
		hbox.set_border_width(5)
		self.typeCheck = gtk.CheckButton(_("Event Type"))
		pack(hbox, self.typeCheck)
		pack(hbox, gtk.Label("  "))
		##
		combo = gtk.ComboBoxText()
		for cls in event_lib.classes.event:
			combo.append_text(cls.desc)
		combo.set_active(0)
		pack(hbox, combo)
		self.typeCombo = combo
		##
		self.typeCheck.connect("clicked", self.updateTypeSensitive)
		self.updateTypeSensitive()
		pack(self.vbox, hbox)
		######
		hbox = gtk.HBox()
		hbox.set_border_width(5)
		self.groupCheck = gtk.CheckButton(_("Group"))
		pack(hbox, self.groupCheck)
		pack(hbox, gtk.Label("  "))
		self.groupCombo = SingleGroupComboBox()
		pack(hbox, self.groupCombo)
		##
		self.groupCheck.connect("clicked", self.updateGroupSensitive)
		self.updateGroupSensitive()
		pack(self.vbox, hbox)
		######
		bbox = gtk.HButtonBox()
		bbox.set_layout(gtk.ButtonBoxStyle.START)
		bbox.set_border_width(5)
		searchButton = gtk.Button()
		searchButton.set_label(_("_Search"))
		searchButton.set_image(gtk.Image.new_from_stock(
			gtk.STOCK_FIND,
			gtk.IconSize.BUTTON,
		))
		searchButton.connect("clicked", self.searchClicked)
		bbox.add(searchButton)
		pack(self.vbox, bbox)
		######
		treev = gtk.TreeView()
		trees = gtk.TreeStore(
			int,  # gid
			int,  # eid
			str,  # group_name
			GdkPixbuf.Pixbuf,  # icon
			str,  # summary
			str,  # description
		)
		###
		treev.set_model(trees)
		treev.connect("button-press-event", self.treevButtonPress)
		treev.connect("row-activated", self.rowActivated)
		treev.connect("key-press-event", self.treevKeyPress)
		treev.set_headers_clickable(True)
		###
		self.colGroup = gtk.TreeViewColumn(
			_("Group"),
			gtk.CellRendererText(),
			text=2,
		)
		self.colGroup.set_resizable(True)
		self.colGroup.set_sort_column_id(2)
		self.colGroup.set_property("expand", False)
		treev.append_column(self.colGroup)
		###
		self.colIcon = gtk.TreeViewColumn()
		cell = gtk.CellRendererPixbuf()
		pack(self.colIcon, cell)
		self.colIcon.add_attribute(cell, "pixbuf", 3)
		#self.colIcon.set_sort_column_id(3)  # FIXME
		self.colIcon.set_property("expand", False)
		treev.append_column(self.colIcon)
		###
		self.colSummary = gtk.TreeViewColumn(
			_("Summary"),
			gtk.CellRendererText(),
			text=4,
		)
		self.colSummary.set_resizable(True)
		self.colSummary.set_sort_column_id(4)
		self.colSummary.set_property("expand", True)  # FIXME
		treev.append_column(self.colSummary)
		###
		self.colDesc = gtk.TreeViewColumn(
			_("Description"),
			gtk.CellRendererText(),
			text=5,
		)
		self.colDesc.set_sort_column_id(5)
		self.colDesc.set_visible(showDesc)
		self.colDesc.set_property("expand", True)  # FIXME
		treev.append_column(self.colDesc)
		###
		trees.set_sort_func(2, self.sort_func_group)
		######
		swin = gtk.ScrolledWindow()
		swin.set_policy(gtk.PolicyType.AUTOMATIC, gtk.PolicyType.AUTOMATIC)
		swin.add(treev)
		####
		vbox = gtk.VBox(spacing=5)
		vbox.set_border_width(5)
		###
		topHbox = gtk.HBox()
		self.resultLabel = gtk.Label("")
		pack(topHbox, self.resultLabel)
		pack(topHbox, gtk.Label(""), 1, 1)
		pack(vbox, topHbox)
		####
		columnBox = gtk.HBox(spacing=5)
		pack(columnBox, gtk.Label(_("Columns") + ":    "))
		##
		check = gtk.CheckButton(_("Group"))
		check.set_active(True)
		check.connect(
			"clicked",
			lambda w: self.colGroup.set_visible(w.get_active()),
		)
		pack(columnBox, check)
		##
		check = gtk.CheckButton(_("Icon"))
		check.set_active(True)
		check.connect(
			"clicked",
			lambda w: self.colIcon.set_visible(w.get_active()),
		)
		pack(columnBox, check)
		##
		check = gtk.CheckButton(_("Summary"))
		check.set_active(True)
		check.connect(
			"clicked",
			lambda w: self.colSummary.set_visible(w.get_active()),
		)
		pack(columnBox, check)
		##
		check = gtk.CheckButton(_("Description"))
		check.set_active(showDesc)
		check.connect(
			"clicked",
			lambda w: self.colDesc.set_visible(w.get_active()),
		)
		pack(columnBox, check)
		##
		pack(vbox, columnBox)
		####
		pack(vbox, swin, 1, 1)
		##
		frame = gtk.Frame()
		frame.set_label(_("Search Results"))
		frame.set_border_width(10)
		frame.add(vbox)
		##
		pack(self.vbox, frame, 1, 1)
		###
		bbox2 = gtk.HButtonBox()
		bbox2.set_layout(gtk.ButtonBoxStyle.END)
		bbox2.set_border_width(10)
		closeButton = gtk.Button()
		closeButton.set_label(_("_Close"))
		closeButton.set_image(gtk.Image.new_from_stock(
			gtk.STOCK_CLOSE,
			gtk.IconSize.BUTTON,
		))
		closeButton.connect("clicked", self.closed)
		bbox2.add(closeButton)
		pack(self.vbox, bbox2)
		######
		self.treev = treev
		self.trees = trees
		self.vbox.show_all()
Exemplo n.º 6
0
def calcTimeLineData(timeStart, timeWidth, pixelPerSec, borderTm):
    timeEnd = timeStart + timeWidth
    jd0 = getJdFromEpoch(timeStart)
    jd1 = getJdFromEpoch(timeEnd)
    widthDays = float(timeWidth) / dayLen
    dayPixel = dayLen * pixelPerSec ## px
    #print('dayPixel = %s px'%dayPixel)
    getEPos = lambda epoch: (epoch-timeStart)*pixelPerSec
    getJPos = lambda jd: (getEpochFromJd(jd)-timeStart)*pixelPerSec
    ######################## Holidays
    holidays = []
    if changeHolidayBg and changeHolidayBgMinDays < widthDays < changeHolidayBgMaxDays:
        for jd in getHolidaysJdList(jd0, jd1+1):
            holidays.append(getJPos(jd))
    ######################## Ticks
    ticks = []
    tickEpochList = []
    minStep = minorStepMin / pixelPerSec ## second
    #################
    year0, month0, day0 = jd_to_primary(jd0)
    year1, month1, day1 = jd_to_primary(jd1)
    ############ Year
    minStepYear = minStep // minYearLenSec ## years ## int or iceil?
    yearPixel = minYearLenSec * pixelPerSec ## pixels
    for (year, size) in getYearRangeTickValues(year0, year1+1, minStepYear):
        tmEpoch = getEpochFromDate(year, 1, 1, calTypes.primary)
        if tmEpoch in tickEpochList:
            continue
        unitSize = size * yearPixel
        label = formatYear(year) if unitSize >= majorStepMin else ''
        ticks.append(Tick(
            tmEpoch,
            getEPos(tmEpoch),
            unitSize,
            label,
        ))
        tickEpochList.append(tmEpoch)
    ############ Month
    monthPixel = avgMonthLen * pixelPerSec ## px
    minMonthUnit = float(minStep) / avgMonthLen ## month
    if minMonthUnit <= 3:
        for ym in range(year0*12+month0-1, year1*12+month1-1+1):## +1 FIXME
            if ym%3==0:
                monthUnit = 3
            else:
                monthUnit = 1
            if monthUnit < minMonthUnit:
                continue
            y, m = divmod(ym, 12) ; m+=1
            tmEpoch = getEpochFromDate(y, m, 1, calTypes.primary)
            if tmEpoch in tickEpochList:
                continue
            unitSize = monthPixel * monthUnit
            ticks.append(Tick(
                tmEpoch,
                getEPos(tmEpoch),
                unitSize,
                getMonthName(calTypes.primary, m) if unitSize >= majorStepMin else '',
            ))
            tickEpochList.append(tmEpoch)
    ################
    if showWeekStart and showWeekStartMinDays < widthDays < showWeekStartMaxDays:
        wd0 = jwday(jd0)
        jdw0 = jd0 + (core.firstWeekDay - wd0) % 7
        unitSize = dayPixel * 7
        if unitSize < majorStepMin:
            label = ''
        else:
            label = core.weekDayNameAb[core.firstWeekDay]
        for jd in range(jdw0, jd1+1, 7):
            tmEpoch = getEpochFromJd(jd)
            ticks.append(Tick(
                tmEpoch,
                getEPos(tmEpoch),
                unitSize,
                label,
                color=weekStartTickColor,
            ))
            #tickEpochList.append(tmEpoch)
    ############ Day of Month
    hasMonthName = timeWidth < 5 * dayLen
    minDayUnit = float(minStep) / dayLen ## days
    if minDayUnit <= 15:
        for jd in range(jd0, jd1+1):
            tmEpoch = getEpochFromJd(jd)
            if tmEpoch in tickEpochList:
                continue
            year, month, day = jd_to_primary(jd)
            if day==16:
                dayUnit = 15
            elif day in (6, 11, 21, 26):
                dayUnit = 5
            else:
                dayUnit = 1
            if dayUnit < minDayUnit:
                continue
            unitSize = dayPixel*dayUnit
            if unitSize < majorStepMin:
                label = ''
            elif hasMonthName:
                label = _(day) + ' ' + getMonthName(calTypes.primary, month)
            else:
                label = _(day)
            ticks.append(Tick(
                tmEpoch,
                getEPos(tmEpoch),
                unitSize,
                label,
            ))
            tickEpochList.append(tmEpoch)
    ############ Hour, Minute, Second
    for stepUnit, stepValue in unitSteps:
        stepSec = stepUnit*stepValue
        if stepSec < minStep:
            break
        unitSize = stepSec*pixelPerSec
        utcOffset = int(getUtcOffsetCurrent())
        firstEpoch = iceil((timeStart+utcOffset) / stepSec) * stepSec - utcOffset
        for tmEpoch in range(firstEpoch, iceil(timeEnd), stepSec):
            if tmEpoch in tickEpochList:
                continue
            if unitSize < majorStepMin:
                label = ''
            else:
                jd, h, m, s = getJhmsFromEpoch(tmEpoch)
                if s==0:
                    label = '%s:%s'%(
                        _(h),
                        _(m, fillZero=2),
                    )
                else:# elif timeWidth < 60 or stepSec < 30:
                    label = addLRM('%s"'%_(s, fillZero=2))
                #else:
                #    label = '%s:%s:%s'%(
                #        _(h),
                #        _(m, fillZero=2),
                #        _(s, fillZero=2),
                #    )
            ticks.append(Tick(
                tmEpoch,
                getEPos(tmEpoch),
                unitSize,
                label,
            ))
            tickEpochList.append(tmEpoch)
    ######################## Event Boxes
    data = {
        'holidays': holidays,
        'ticks': ticks,
        'boxes': [],
    }
    ###
    data['boxes'] = calcEventBoxes(
        timeStart,
        timeEnd,
        pixelPerSec,
        borderTm,
    )
    ###
    return data