def update_label(self):
     if self.last_activity and self.last_activity.end_time is None:
         delta = dt.datetime.now() - self.last_activity.start_time
         duration = delta.seconds / 60
         label = "%s %s" % (self.last_activity.activity,
                            stuff.format_duration(duration, False))
         self.button.set_text(self.last_activity.activity,
                              stuff.format_duration(duration, False))
     else:
         label = "%s" % _(u"No activity")
         self.button.set_text(label, None)
Exemple #2
0
 def update_label(self):
     if self.last_activity and self.last_activity.end_time is None:
         delta = dt.datetime.now() - self.last_activity.start_time
         duration = delta.seconds /  60
         label = "%s %s" % (self.last_activity.activity,
                            stuff.format_duration(duration, False))
         self.button.set_text(self.last_activity.activity,
                              stuff.format_duration(duration, False))
     else:
         label = "%s" % _(u"No activity")
         self.button.set_text(label, None)
Exemple #3
0
    def _write_fact(self, report, fact):
        # no having end time is fine
        end_time_str, end_time_iso_str = "", ""
        if fact.end_time:
            end_time_str = fact.end_time.strftime('%H:%M')
            end_time_iso_str = fact.end_time.isoformat()

        category = ""
        if fact.category != _("Unsorted"):  #do not print "unsorted" in list
            category = fact.category

        data = dict(
            date=fact.date.strftime(
                # date column format for each row in HTML report
                # Using python datetime formatting syntax. See:
                # http://docs.python.org/library/time.html#time.strftime
                C_("html report", "%b %d, %Y")),
            date_iso=fact.date.isoformat(),
            activity=fact.activity,
            category=category,
            tags=fact.tags,
            start=fact.start_time.strftime('%H:%M'),
            start_iso=fact.start_time.isoformat(),
            end=end_time_str,
            end_iso=end_time_iso_str,
            duration=stuff.format_duration(fact.delta) or "",
            duration_minutes="%d" % (stuff.duration_minutes(fact.delta)),
            duration_decimal="%.2f" %
            (stuff.duration_minutes(fact.delta) / 60.0),
            description=fact.description or "")
        self.fact_rows.append(
            Template(self.fact_row_template).safe_substitute(data))
    def set_last_activity(self):
        activity = self.last_activity
        #sets all the labels and everything as necessary
        self.get_widget("stop_tracking").set_sensitive(activity != None)

        if activity:
            self.get_widget("switch_activity").show()
            self.get_widget("start_tracking").hide()

            delta = dt.datetime.now() - activity.start_time
            duration = delta.seconds / 60

            if activity.category != _("Unsorted"):
                self.get_widget("last_activity_name").set_text(
                    "%s - %s" % (activity.activity, activity.category))
            else:
                self.get_widget("last_activity_name").set_text(
                    activity.activity)

            self.get_widget("last_activity_duration").set_text(
                stuff.format_duration(duration) or _("Just started"))
            self.get_widget("last_activity_description").set_text(
                activity.description or "")
            self.get_widget("activity_info_box").show()

            self.tag_box.draw(activity.tags)
        else:
            self.get_widget("switch_activity").hide()
            self.get_widget("start_tracking").show()

            self.get_widget("last_activity_name").set_text(_("No activity"))

            self.get_widget("activity_info_box").hide()
            self.tag_box.draw([])
Exemple #5
0
    def set_last_activity(self):
        activity = self.last_activity
        #sets all the labels and everything as necessary
        self.get_widget("stop_tracking").set_sensitive(activity != None)


        if activity:
            self.get_widget("switch_activity").show()
            self.get_widget("start_tracking").hide()

            delta = dt.datetime.now() - activity.start_time
            duration = delta.seconds /  60

            if activity.category != _("Unsorted"):
                self.get_widget("last_activity_name").set_text("%s - %s" % (activity.activity, activity.category))
            else:
                self.get_widget("last_activity_name").set_text(activity.activity)


            self.get_widget("last_activity_duration").set_text(stuff.format_duration(duration) or _("Just started"))
            self.get_widget("last_activity_description").set_text(activity.description or "")
            self.get_widget("activity_info_box").show()

            self.tag_box.draw(activity.tags)
        else:
            self.get_widget("switch_activity").hide()
            self.get_widget("start_tracking").show()

            self.get_widget("last_activity_name").set_text(_("No activity"))

            self.get_widget("activity_info_box").hide()
            self.tag_box.draw([])
Exemple #6
0
    def _write_fact(self, fact):
        # no having end time is fine
        end_time_str, end_time_iso_str = "", ""
        if fact.end_time:
            end_time_str = fact.end_time.strftime('%H:%M')
            end_time_iso_str = fact.end_time.isoformat()

        category = ""
        if fact.category != _("Unsorted"): #do not print "unsorted" in list
            category = fact.category


        data = dict(
            date = fact.date.strftime(
                   # date column format for each row in HTML report
                   # Using python datetime formatting syntax. See:
                   # http://docs.python.org/library/time.html#time.strftime
                   C_("html report","%b %d, %Y")),
            date_iso = fact.date.isoformat(),
            activity = fact.activity,
            category = category,
            tags = fact.tags,
            start = fact.start_time.strftime('%H:%M'),
            start_iso = fact.start_time.isoformat(),
            end = end_time_str,
            end_iso = end_time_iso_str,
            duration = stuff.format_duration(fact.delta) or "",
            duration_minutes = "%d" % (stuff.duration_minutes(fact.delta)),
            duration_decimal = "%.2f" % (stuff.duration_minutes(fact.delta) / 60.0),
            description = fact.description or ""
        )
        self.fact_rows.append(Template(self.fact_row_template).safe_substitute(data))