[hamster-applet] not coloring the show stats label and showing total hours tracked per interval (bug 597640)



commit a9ceaac3bcba8e0ecf2ea57b0b952d99afdaad05
Author: Toms Bauģis <toms baugis gmail com>
Date:   Sat Jan 23 18:33:40 2010 +0000

    not coloring the show stats label and showing total hours tracked per interval (bug 597640)

 data/overview_totals.ui        |   50 ++++++++++++++++++++++++++++++---------
 src/hamster/overview_totals.py |   24 ++++++++++--------
 2 files changed, 51 insertions(+), 23 deletions(-)
---
diff --git a/data/overview_totals.ui b/data/overview_totals.ui
index 169612b..2da6ccc 100644
--- a/data/overview_totals.ui
+++ b/data/overview_totals.ui
@@ -9,29 +9,55 @@
         <property name="border_width">12</property>
         <property name="orientation">vertical</property>
         <child>
-          <object class="GtkAlignment" id="alignment4">
+          <object class="GtkHBox" id="hbox1">
             <property name="visible">True</property>
-            <property name="xalign">1</property>
-            <property name="xscale">0</property>
+            <property name="spacing">10</property>
             <child>
-              <object class="GtkButton" id="statistics_button">
+              <object class="GtkAlignment" id="alignment5">
                 <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">True</property>
-                <property name="relief">none</property>
-                <signal name="clicked" handler="on_statistics_button_clicked"/>
+                <property name="xalign">1</property>
+                <property name="xscale">0</property>
                 <child>
-                  <object class="GtkLabel" id="label4">
+                  <object class="GtkLabel" id="total_hours">
                     <property name="visible">True</property>
-                    <property name="label" translatable="yes">Show Statistics</property>
+                    <property name="label">Total hours</property>
                     <attributes>
-                      <attribute name="underline" value="True"/>
                       <attribute name="size" value="10000"/>
-                      <attribute name="foreground" value="#00001154ffff"/>
                     </attributes>
                   </object>
                 </child>
               </object>
+              <packing>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkAlignment" id="alignment4">
+                <property name="visible">True</property>
+                <property name="xalign">1</property>
+                <property name="xscale">0</property>
+                <child>
+                  <object class="GtkButton" id="statistics_button">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">True</property>
+                    <signal name="clicked" handler="on_statistics_button_clicked"/>
+                    <child>
+                      <object class="GtkLabel" id="statistics_button_label">
+                        <property name="visible">True</property>
+                        <property name="label" translatable="yes">Show Statistics</property>
+                        <attributes>
+                          <attribute name="size" value="10000"/>
+                        </attributes>
+                      </object>
+                    </child>
+                  </object>
+                </child>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="position">1</property>
+              </packing>
             </child>
           </object>
           <packing>
diff --git a/src/hamster/overview_totals.py b/src/hamster/overview_totals.py
index dd92849..d40b074 100644
--- a/src/hamster/overview_totals.py
+++ b/src/hamster/overview_totals.py
@@ -23,9 +23,6 @@ import time
 import webbrowser
 from itertools import groupby
 
-import pygtk
-pygtk.require('2.0')
-
 from gettext import ngettext
 
 import os
@@ -80,7 +77,6 @@ class TotalsBox(gtk.VBox):
 
         self.get_widget("totals_by_tag").add(self.tag_chart);
 
-
         self._gui.connect_signals(self)
 
         self.report_chooser = None
@@ -128,14 +124,17 @@ class TotalsBox(gtk.VBox):
 
         self.do_graph()
 
+
     def do_graph(self):
         if self.facts:
             self.get_widget("no_data_label").hide()
             self.get_widget("charts").show()
+            self.get_widget("total_hours").show()
             self.do_charts()
         else:
             self.get_widget("no_data_label").show()
             self.get_widget("charts").hide()
+            self.get_widget("total_hours").hide()
 
 
     def do_charts(self):
@@ -145,6 +144,10 @@ class TotalsBox(gtk.VBox):
         import copy
         facts = copy.deepcopy(self.facts)
 
+        total_hours = sum([stuff.duration_minutes(fact["delta"]) for fact in facts])
+        total_label = _("%s hours tracked total") % ("%.1f" % (total_hours / 60.0))
+        self.get_widget("total_hours").set_text(total_label)
+
         for fact in facts:
             if self.selected_categories and fact["category"] not in self.selected_categories:
                 fact["delta"] = dt.timedelta()
@@ -159,8 +162,8 @@ class TotalsBox(gtk.VBox):
         category_sums = stuff.totals(facts,
                                      lambda fact: (fact["category"]),
                                      lambda fact: fact["delta"].seconds + fact["delta"].days * 24 * 60 * 60)
-        for sum in category_sums:
-            category_sums[sum] = category_sums[sum] / 60 / 60.0
+        for entry in category_sums:
+            category_sums[entry] = category_sums[entry] / 60 / 60.0
 
         if category_sums:
             if self.category_sums:
@@ -176,8 +179,8 @@ class TotalsBox(gtk.VBox):
         activity_sums = stuff.totals(facts,
                                      lambda fact: (fact["name"]),
                                      lambda fact: fact["delta"].seconds + fact["delta"].days * 24 * 60 * 60)
-        for sum in activity_sums:
-            activity_sums[sum] = activity_sums[sum] / 60 / 60.0
+        for entry in activity_sums:
+            activity_sums[entry] = activity_sums[entry] / 60 / 60.0
 
         if self.activity_sums:
             activity_sums = [(key, activity_sums[key]) for key in self.activity_sums[0]]
@@ -194,8 +197,8 @@ class TotalsBox(gtk.VBox):
                 tag_sums.setdefault(tag, 0)
                 tag_sums[tag] += fact["delta"].seconds + fact["delta"].days * 24 * 60 * 60
 
-        for sum in tag_sums:
-            tag_sums[sum] = tag_sums[sum] / 60 / 60.0
+        for entry in tag_sums:
+            tag_sums[entry] = tag_sums[entry] / 60 / 60.0
 
         if tag_sums:
             if self.tag_sums:
@@ -254,4 +257,3 @@ if __name__ == "__main__":
 
 
     gtk.main()
-



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]