hamster-applet r731 - in trunk: data hamster



Author: tbaugis
Date: Mon Feb 16 11:05:23 2009
New Revision: 731
URL: http://svn.gnome.org/viewvc/hamster-applet?rev=731&view=rev

Log:
don't show blank charts if there is no data - instead show "no data for this interval

Modified:
   trunk/data/stats.glade
   trunk/hamster/charting.py
   trunk/hamster/stats.py

Modified: trunk/data/stats.glade
==============================================================================
--- trunk/data/stats.glade	(original)
+++ trunk/data/stats.glade	Mon Feb 16 11:05:23 2009
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
 <!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
-<!--Generated with glade3 3.4.5 on Sun Feb 15 11:58:42 2009 -->
+<!--Generated with glade3 3.4.5 on Mon Feb 16 11:04:36 2009 -->
 <glade-interface>
   <widget class="GtkWindow" id="stats_window">
     <property name="width_request">600</property>
@@ -240,88 +240,101 @@
                       <widget class="GtkEventBox" id="graph_frame">
                         <property name="visible">True</property>
                         <child>
-                          <widget class="GtkVBox" id="frame66">
-                            <property name="width_request">390</property>
+                          <widget class="GtkVBox" id="vbox4">
                             <property name="visible">True</property>
-                            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                            <property name="border_width">4</property>
-                            <property name="spacing">24</property>
-                            <property name="homogeneous">True</property>
                             <child>
-                              <widget class="GtkFrame" id="fram1">
+                              <widget class="GtkVBox" id="graphs">
+                                <property name="width_request">390</property>
                                 <property name="visible">True</property>
                                 <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                <property name="label_xalign">0</property>
-                                <property name="shadow_type">GTK_SHADOW_NONE</property>
+                                <property name="border_width">4</property>
+                                <property name="spacing">24</property>
+                                <property name="homogeneous">True</property>
                                 <child>
-                                  <widget class="GtkHBox" id="hbox1">
+                                  <widget class="GtkFrame" id="fram1">
                                     <property name="visible">True</property>
-                                    <property name="border_width">9</property>
-                                    <property name="spacing">36</property>
+                                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                    <property name="label_xalign">0</property>
+                                    <property name="shadow_type">GTK_SHADOW_NONE</property>
                                     <child>
-                                      <widget class="GtkEventBox" id="totals_by_category">
-                                        <property name="width_request">50</property>
+                                      <widget class="GtkHBox" id="hbox1">
                                         <property name="visible">True</property>
+                                        <property name="border_width">9</property>
+                                        <property name="spacing">36</property>
                                         <child>
-                                          <placeholder/>
+                                          <widget class="GtkEventBox" id="totals_by_category">
+                                            <property name="width_request">50</property>
+                                            <property name="visible">True</property>
+                                            <child>
+                                              <placeholder/>
+                                            </child>
+                                          </widget>
+                                          <packing>
+                                            <property name="expand">False</property>
+                                          </packing>
+                                        </child>
+                                        <child>
+                                          <widget class="GtkEventBox" id="totals_by_day">
+                                            <property name="visible">True</property>
+                                            <child>
+                                              <placeholder/>
+                                            </child>
+                                          </widget>
+                                          <packing>
+                                            <property name="position">1</property>
+                                          </packing>
                                         </child>
                                       </widget>
-                                      <packing>
-                                        <property name="expand">False</property>
-                                      </packing>
                                     </child>
                                     <child>
-                                      <widget class="GtkEventBox" id="totals_by_day">
+                                      <widget class="GtkLabel" id="dayview_caption">
                                         <property name="visible">True</property>
-                                        <child>
-                                          <placeholder/>
-                                        </child>
+                                        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                        <property name="label" translatable="yes">Week</property>
+                                        <property name="use_markup">True</property>
                                       </widget>
                                       <packing>
-                                        <property name="position">1</property>
+                                        <property name="type">label_item</property>
                                       </packing>
                                     </child>
                                   </widget>
                                 </child>
                                 <child>
-                                  <widget class="GtkLabel" id="dayview_caption">
+                                  <widget class="GtkFrame" id="frame39">
                                     <property name="visible">True</property>
                                     <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                    <property name="label" translatable="yes">Week</property>
-                                    <property name="use_markup">True</property>
+                                    <property name="label_xalign">0</property>
+                                    <property name="shadow_type">GTK_SHADOW_NONE</property>
+                                    <child>
+                                      <widget class="GtkEventBox" id="totals_by_activity">
+                                        <property name="visible">True</property>
+                                        <property name="border_width">12</property>
+                                        <child>
+                                          <placeholder/>
+                                        </child>
+                                      </widget>
+                                    </child>
+                                    <child>
+                                      <widget class="GtkLabel" id="label3">
+                                        <property name="visible">True</property>
+                                        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                        <property name="label" translatable="yes">Activity</property>
+                                        <property name="use_markup">True</property>
+                                      </widget>
+                                      <packing>
+                                        <property name="type">label_item</property>
+                                      </packing>
+                                    </child>
                                   </widget>
                                   <packing>
-                                    <property name="type">label_item</property>
+                                    <property name="position">1</property>
                                   </packing>
                                 </child>
                               </widget>
                             </child>
                             <child>
-                              <widget class="GtkFrame" id="frame39">
-                                <property name="visible">True</property>
-                                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                <property name="label_xalign">0</property>
-                                <property name="shadow_type">GTK_SHADOW_NONE</property>
-                                <child>
-                                  <widget class="GtkEventBox" id="totals_by_activity">
-                                    <property name="visible">True</property>
-                                    <property name="border_width">12</property>
-                                    <child>
-                                      <placeholder/>
-                                    </child>
-                                  </widget>
-                                </child>
-                                <child>
-                                  <widget class="GtkLabel" id="label3">
-                                    <property name="visible">True</property>
-                                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                    <property name="label" translatable="yes">Activity</property>
-                                    <property name="use_markup">True</property>
-                                  </widget>
-                                  <packing>
-                                    <property name="type">label_item</property>
-                                  </packing>
-                                </child>
+                              <widget class="GtkLabel" id="no_data_label">
+                                <property name="label" translatable="yes">No data for this interval</property>
                               </widget>
                               <packing>
                                 <property name="position">1</property>
@@ -342,7 +355,7 @@
                     <child>
                       <widget class="GtkLabel" id="totals">
                         <property name="visible">True</property>
-                        <property name="label" translatable="yes">Something: 20:00, Food: 12:13</property>
+                        <property name="label">Something: 20:00, Food: 12:13</property>
                       </widget>
                     </child>
                   </widget>

Modified: trunk/hamster/charting.py
==============================================================================
--- trunk/hamster/charting.py	(original)
+++ trunk/hamster/charting.py	Mon Feb 16 11:05:23 2009
@@ -213,6 +213,7 @@
 
     def plot(self, keys, data, series_keys = None):
         """Draw chart with given data"""
+        self.show()
         
         self.data = data
 
@@ -267,6 +268,7 @@
         else:
             self.factors = self.new_factors
             self._invalidate()
+            
 
         
     def _smoothstep(self, v, start, end):

Modified: trunk/hamster/stats.py
==============================================================================
--- trunk/hamster/stats.py	(original)
+++ trunk/hamster/stats.py	Mon Feb 16 11:05:23 2009
@@ -347,6 +347,15 @@
         
         
         fact_list = storage.get_facts(self.start_date, self.end_date)
+        
+        if not fact_list:
+            self.get_widget("graphs").hide()
+            self.get_widget("no_data_label").show()
+            return 
+        else:
+            self.get_widget("graphs").show()
+            self.get_widget("no_data_label").hide()
+            
 
         all_days = [self.start_date + dt.timedelta(i)
                     for i in range((self.end_date - self.start_date).days  + 1)]        
@@ -549,5 +558,5 @@
         self.window.destroy()
     
     def show(self):
-        self.window.show_all()
+        self.window.show()
 



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