[hamster-applet] fixes Bug 589077 - legend is now resizing to 1/4 of the graph up to max 200 pixels



commit 0c6f426d4d1f7fbaa1bf4eed3f09e431f5d82020
Author: Toms Bauģis <toms baugis gmail com>
Date:   Tue Jul 21 11:20:11 2009 +0300

    fixes Bug 589077 - legend is now resizing to 1/4 of the graph up to max 200 pixels

 data/stats.ui    |    3 ++-
 hamster/stats.py |    7 +++++++
 2 files changed, 9 insertions(+), 1 deletions(-)
---
diff --git a/data/stats.ui b/data/stats.ui
index 6af8dc0..784ae67 100644
--- a/data/stats.ui
+++ b/data/stats.ui
@@ -13,6 +13,7 @@
     <property name="default_height">600</property>
     <property name="icon_name">hamster-applet</property>
     <signal name="key_press_event" handler="on_window_key_pressed"/>
+    <signal name="size_allocate" handler="on_stats_window_size_allocate"/>
     <signal name="delete_event" handler="on_close"/>
     <child>
       <object class="GtkAlignment" id="alignment1">
@@ -253,6 +254,7 @@
                         <child>
                           <object class="GtkEventBox" id="graph_frame">
                             <property name="visible">True</property>
+                            <signal name="size_allocate" handler="on_graph_frame_size_allocate"/>
                             <child>
                               <object class="GtkVBox" id="vbox4">
                                 <property name="visible">True</property>
@@ -279,7 +281,6 @@
                                             <property name="spacing">36</property>
                                             <child>
                                               <object class="GtkEventBox" id="totals_by_category">
-                                                <property name="width_request">130</property>
                                                 <property name="visible">True</property>
                                                 <child>
                                                   <placeholder/>
diff --git a/hamster/stats.py b/hamster/stats.py
index 2ce8f98..40694e4 100644
--- a/hamster/stats.py
+++ b/hamster/stats.py
@@ -796,6 +796,13 @@ than 15 minutes you seem to be a busy bee." % ("<b>%d</b>" % short_percent))
         
         self.fact_tree.set_model(self.fact_store)
     
+    def on_graph_frame_size_allocate(self, widget, new_size):
+        w = min(new_size.width / 4, 200)
+        
+        self.activity_chart.legend_width = w
+        self.category_chart.legend_width = w
+        self.get_widget("totals_by_category").set_size_request(w + 40, -1)
+    
     def fill_tree(self, facts):
         day_dict = {}
         for day, facts in groupby(facts, lambda fact: fact["date"]):



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