[hamster-applet] added menu, dropped toolbar, revamped date range selection. some bits could be broken at the moment



commit f44ca320d1bfbac0b5a38c7dfa64cafd6aa9c726
Author: Toms Bauģis <toms baugis gmail com>
Date:   Fri Jun 11 18:53:05 2010 +0100

    added menu, dropped toolbar, revamped date range selection. some bits could be broken at the moment

 data/overview.ui        |  696 +++++++++++++++++++++++++++++++++++------------
 src/hamster/overview.py |  214 +++++++++------
 2 files changed, 649 insertions(+), 261 deletions(-)
---
diff --git a/data/overview.ui b/data/overview.ui
index 1ac68a6..c0f98ba 100644
--- a/data/overview.ui
+++ b/data/overview.ui
@@ -1,53 +1,184 @@
-<?xml version="1.0"?>
+<?xml version="1.0" encoding="UTF-8"?>
 <interface>
   <requires lib="gtk+" version="2.16"/>
   <!-- interface-naming-policy project-wide -->
   <!-- interface-local-resource-path /home/toms/cvs/hamster/data/art -->
-  <object class="GtkWindow" id="tabs_window">
-    <property name="title" translatable="yes">Overview â?? Hamster</property>
-    <property name="default_width">800</property>
-    <property name="default_height">600</property>
-    <signal name="configure_event" handler="on_tabs_window_configure_event"/>
-    <signal name="delete_event" handler="on_tabs_window_deleted"/>
+  <object class="GtkWindow" id="range_popup">
+    <property name="border_width">12</property>
+    <property name="resizable">False</property>
+    <property name="window_position">mouse</property>
+    <property name="destroy_with_parent">True</property>
+    <property name="skip_taskbar_hint">True</property>
+    <property name="skip_pager_hint">True</property>
+    <property name="decorated">False</property>
     <child>
-      <object class="GtkVBox" id="vbox1">
+      <object class="GtkVBox" id="vbox3">
         <property name="visible">True</property>
-        <property name="orientation">vertical</property>
+        <property name="spacing">8</property>
         <child>
-          <object class="GtkToolbar" id="toolbar1">
+          <object class="GtkButton" id="day_range">
             <property name="visible">True</property>
-            <property name="show_arrow">False</property>
+            <property name="can_focus">True</property>
+            <property name="receives_default">True</property>
+            <property name="related_action">day</property>
+            <property name="use_action_appearance">False</property>
+            <property name="relief">none</property>
             <child>
-              <object class="GtkToolItem" id="range_pick">
+              <object class="GtkHBox" id="hbox6">
                 <property name="visible">True</property>
+                <property name="spacing">8</property>
+                <child>
+                  <object class="GtkLabel" id="label2">
+                    <property name="width_request">100</property>
+                    <property name="visible">True</property>
+                    <property name="xalign">1</property>
+                    <property name="label" translatable="yes">Day:</property>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="position">0</property>
+                  </packing>
+                </child>
                 <child>
-                  <placeholder/>
+                  <object class="GtkLabel" id="day_preview">
+                    <property name="visible">True</property>
+                    <property name="xalign">0</property>
+                    <property name="label">Jun 17</property>
+                  </object>
+                  <packing>
+                    <property name="position">1</property>
+                  </packing>
                 </child>
               </object>
-              <packing>
-                <property name="expand">False</property>
-              </packing>
             </child>
+          </object>
+          <packing>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkButton" id="week_range">
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <property name="receives_default">True</property>
+            <property name="related_action">week</property>
+            <property name="use_action_appearance">False</property>
+            <property name="relief">none</property>
             <child>
-              <object class="GtkToolItem" id="date_ranges">
+              <object class="GtkHBox" id="hbox7">
                 <property name="visible">True</property>
+                <property name="spacing">8</property>
                 <child>
-                  <object class="GtkHBox" id="hbox1">
+                  <object class="GtkLabel" id="label4">
+                    <property name="width_request">100</property>
                     <property name="visible">True</property>
+                    <property name="xalign">1</property>
+                    <property name="label" translatable="yes">Week:</property>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="position">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkLabel" id="week_preview">
+                    <property name="visible">True</property>
+                    <property name="xalign">0</property>
+                    <property name="label">Jun 14 - 20, 2010</property>
+                  </object>
+                  <packing>
+                    <property name="position">1</property>
+                  </packing>
+                </child>
+              </object>
+            </child>
+          </object>
+          <packing>
+            <property name="position">1</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkButton" id="month_range">
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <property name="receives_default">True</property>
+            <property name="related_action">month</property>
+            <property name="use_action_appearance">False</property>
+            <property name="relief">none</property>
+            <child>
+              <object class="GtkHBox" id="hbox8">
+                <property name="visible">True</property>
+                <property name="spacing">8</property>
+                <child>
+                  <object class="GtkLabel" id="label6">
+                    <property name="width_request">100</property>
+                    <property name="visible">True</property>
+                    <property name="xalign">1</property>
+                    <property name="label" translatable="yes">Month:</property>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="position">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkLabel" id="month_preview">
+                    <property name="visible">True</property>
+                    <property name="xalign">0</property>
+                    <property name="label">Jun 1-30, 2010</property>
+                  </object>
+                  <packing>
+                    <property name="position">1</property>
+                  </packing>
+                </child>
+              </object>
+            </child>
+          </object>
+          <packing>
+            <property name="position">2</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkAlignment" id="alignment6">
+            <property name="visible">True</property>
+            <property name="left_padding">4</property>
+            <child>
+              <object class="GtkHBox" id="hbox9">
+                <property name="visible">True</property>
+                <property name="spacing">8</property>
+                <child>
+                  <object class="GtkLabel" id="label8">
+                    <property name="width_request">100</property>
+                    <property name="visible">True</property>
+                    <property name="xalign">1</property>
+                    <property name="yalign">0</property>
+                    <property name="ypad">7</property>
+                    <property name="label" translatable="yes">Range:</property>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="position">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkVBox" id="vbox4">
+                    <property name="visible">True</property>
+                    <property name="spacing">5</property>
                     <child>
-                      <object class="GtkHBox" id="preset_range">
+                      <object class="GtkHBox" id="hbox2">
                         <property name="visible">True</property>
+                        <property name="spacing">12</property>
                         <child>
-                          <object class="GtkButton" id="prev">
+                          <object class="GtkAlignment" id="range_start_box">
                             <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_prev_clicked"/>
                             <child>
-                              <object class="GtkImage" id="image1">
+                              <object class="GtkCalendar" id="start_calendar">
                                 <property name="visible">True</property>
-                                <property name="stock">gtk-go-back</property>
+                                <property name="can_focus">True</property>
+                                <property name="year">2010</property>
+                                <property name="month">5</property>
+                                <property name="day">11</property>
+                                <signal name="day-selected-double-click" handler="on_manual_range_apply_clicked" swapped="no"/>
                               </object>
                             </child>
                           </object>
@@ -56,34 +187,27 @@
                           </packing>
                         </child>
                         <child>
-                          <object class="GtkButton" id="home">
+                          <object class="GtkLabel" id="label1">
                             <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_home_clicked"/>
-                            <child>
-                              <object class="GtkImage" id="image2">
-                                <property name="visible">True</property>
-                                <property name="stock">gtk-home</property>
-                              </object>
-                            </child>
+                            <property name="yalign">0</property>
+                            <property name="ypad">7</property>
+                            <property name="label" translatable="yes">to</property>
                           </object>
                           <packing>
                             <property name="position">1</property>
                           </packing>
                         </child>
                         <child>
-                          <object class="GtkButton" id="next">
+                          <object class="GtkAlignment" id="range_end_box">
                             <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_next_clicked"/>
                             <child>
-                              <object class="GtkImage" id="image3">
+                              <object class="GtkCalendar" id="end_calendar">
                                 <property name="visible">True</property>
-                                <property name="stock">gtk-go-forward</property>
+                                <property name="can_focus">True</property>
+                                <property name="year">2010</property>
+                                <property name="month">5</property>
+                                <property name="day">11</property>
+                                <signal name="day-selected-double-click" handler="on_manual_range_apply_clicked" swapped="no"/>
                               </object>
                             </child>
                           </object>
@@ -97,47 +221,26 @@
                       </packing>
                     </child>
                     <child>
-                      <object class="GtkAlignment" id="range_box">
-                        <property name="no_show_all">True</property>
-                        <property name="top_padding">3</property>
-                        <property name="bottom_padding">3</property>
-                        <property name="left_padding">6</property>
+                      <object class="GtkHButtonBox" id="hbuttonbox1">
+                        <property name="visible">True</property>
+                        <property name="layout_style">end</property>
+                        <child>
+                          <placeholder/>
+                        </child>
                         <child>
-                          <object class="GtkHBox" id="hbox2">
+                          <object class="GtkButton" id="manual_range_apply">
+                            <property name="label" translatable="yes">Apply</property>
                             <property name="visible">True</property>
-                            <property name="spacing">4</property>
-                            <child>
-                              <object class="GtkAlignment" id="range_start_box">
-                                <property name="visible">True</property>
-                                <child>
-                                  <placeholder/>
-                                </child>
-                              </object>
-                              <packing>
-                                <property name="position">0</property>
-                              </packing>
-                            </child>
-                            <child>
-                              <object class="GtkLabel" id="label1">
-                                <property name="visible">True</property>
-                                <property name="label" translatable="yes">to</property>
-                              </object>
-                              <packing>
-                                <property name="position">1</property>
-                              </packing>
-                            </child>
-                            <child>
-                              <object class="GtkAlignment" id="range_end_box">
-                                <property name="visible">True</property>
-                                <child>
-                                  <placeholder/>
-                                </child>
-                              </object>
-                              <packing>
-                                <property name="position">2</property>
-                              </packing>
-                            </child>
+                            <property name="can_focus">True</property>
+                            <property name="receives_default">True</property>
+                            <property name="use_action_appearance">False</property>
+                            <signal name="clicked" handler="on_manual_range_apply_clicked" swapped="no"/>
                           </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">False</property>
+                            <property name="position">1</property>
+                          </packing>
                         </child>
                       </object>
                       <packing>
@@ -145,114 +248,144 @@
                       </packing>
                     </child>
                   </object>
+                  <packing>
+                    <property name="position">1</property>
+                  </packing>
                 </child>
               </object>
-              <packing>
-                <property name="expand">False</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkSeparatorToolItem" id="toolbutton1">
-                <property name="visible">True</property>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="homogeneous">True</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkToolButton" id="add">
-                <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">Add</property>
-                <property name="stock_id">gtk-add</property>
-                <signal name="clicked" handler="on_add_clicked"/>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="homogeneous">True</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkToolButton" id="remove">
-                <property name="visible">True</property>
-                <property name="sensitive">False</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">Remove</property>
-                <property name="stock_id">gtk-remove</property>
-                <signal name="clicked" handler="on_remove_clicked"/>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="homogeneous">True</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkToolButton" id="edit">
-                <property name="visible">True</property>
-                <property name="sensitive">False</property>
-                <property name="label" translatable="yes">Edit</property>
-                <property name="stock_id">gtk-edit</property>
-                <signal name="clicked" handler="on_edit_clicked"/>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="homogeneous">True</property>
-              </packing>
             </child>
+          </object>
+          <packing>
+            <property name="position">3</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+  </object>
+  <object class="GtkActionGroup" id="view">
+    <child>
+      <object class="GtkAction" id="day">
+        <property name="label" translatable="yes">Day</property>
+        <signal name="activate" handler="on_day_activate" swapped="no"/>
+      </object>
+    </child>
+    <child>
+      <object class="GtkAction" id="week">
+        <property name="label" translatable="yes">Week</property>
+        <signal name="activate" handler="on_week_activate" swapped="no"/>
+      </object>
+    </child>
+    <child>
+      <object class="GtkAction" id="month">
+        <property name="label" translatable="yes">Month</property>
+        <signal name="activate" handler="on_month_activate" swapped="no"/>
+      </object>
+    </child>
+  </object>
+  <object class="GtkWindow" id="tabs_window">
+    <property name="title" translatable="yes">Overview â?? Hamster</property>
+    <property name="default_width">800</property>
+    <property name="default_height">600</property>
+    <signal name="configure-event" handler="on_tabs_window_configure_event" swapped="no"/>
+    <signal name="delete-event" handler="on_tabs_window_deleted" swapped="no"/>
+    <child>
+      <object class="GtkVBox" id="vbox1">
+        <property name="visible">True</property>
+        <child>
+          <object class="GtkMenuBar" id="menubar1">
+            <property name="visible">True</property>
             <child>
-              <object class="GtkSeparatorToolItem" id="toolbutton2">
+              <object class="GtkMenuItem" id="menuitem1">
                 <property name="visible">True</property>
+                <property name="label" translatable="yes">_Overview</property>
+                <property name="use_underline">True</property>
+                <child type="submenu">
+                  <object class="GtkMenu" id="menu1">
+                    <property name="visible">True</property>
+                    <child>
+                      <object class="GtkMenuItem" id="report_button">
+                        <property name="visible">True</property>
+                        <property name="label" translatable="yes">Export data...</property>
+                        <property name="use_underline">True</property>
+                      </object>
+                    </child>
+                    <child>
+                      <object class="GtkImageMenuItem" id="imagemenuitem5">
+                        <property name="label">gtk-close</property>
+                        <property name="visible">True</property>
+                        <property name="use_underline">True</property>
+                        <property name="use_stock">True</property>
+                      </object>
+                    </child>
+                  </object>
+                </child>
               </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="homogeneous">True</property>
-              </packing>
             </child>
             <child>
-              <object class="GtkToolButton" id="report_button">
+              <object class="GtkMenuItem" id="menuitem14">
                 <property name="visible">True</property>
-                <property name="is_important">True</property>
-                <property name="label" translatable="yes">Save Report</property>
+                <property name="label" translatable="yes">Activity</property>
                 <property name="use_underline">True</property>
-                <property name="stock_id">gtk-save</property>
-                <signal name="clicked" handler="on_report_button_clicked"/>
+                <child type="submenu">
+                  <object class="GtkMenu" id="menu5">
+                    <property name="visible">True</property>
+                    <child>
+                      <object class="GtkMenuItem" id="menu_edit">
+                        <property name="visible">True</property>
+                        <property name="related_action">edit</property>
+                      </object>
+                    </child>
+                    <child>
+                      <object class="GtkMenuItem" id="menu_remove">
+                        <property name="visible">True</property>
+                        <property name="related_action">remove</property>
+                      </object>
+                    </child>
+                    <child>
+                      <object class="GtkSeparatorMenuItem" id="menuitem2">
+                        <property name="visible">True</property>
+                        <property name="use_action_appearance">False</property>
+                      </object>
+                    </child>
+                    <child>
+                      <object class="GtkMenuItem" id="menu_add">
+                        <property name="visible">True</property>
+                        <property name="related_action">add</property>
+                      </object>
+                    </child>
+                  </object>
+                </child>
               </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="homogeneous">True</property>
-              </packing>
             </child>
             <child>
-              <object class="GtkToolItem" id="toolbutton7">
+              <object class="GtkMenuItem" id="menu_view">
                 <property name="visible">True</property>
-                <child>
-                  <object class="GtkAlignment" id="alignment1">
+                <property name="label" translatable="yes">_View</property>
+                <property name="use_underline">True</property>
+                <child type="submenu">
+                  <object class="GtkMenu" id="menu4">
                     <property name="visible">True</property>
-                    <property name="top_padding">3</property>
-                    <property name="bottom_padding">3</property>
-                    <property name="left_padding">6</property>
-                    <property name="right_padding">6</property>
                     <child>
-                      <object class="GtkEntry" id="search">
+                      <object class="GtkMenuItem" id="menu_view_day">
+                        <property name="visible">True</property>
+                        <property name="related_action">day</property>
+                      </object>
+                    </child>
+                    <child>
+                      <object class="GtkMenuItem" id="menu_view_week">
                         <property name="visible">True</property>
-                        <property name="can_focus">True</property>
-                        <property name="invisible_char">&#x2022;</property>
-                        <property name="primary_icon_stock">gtk-find</property>
-                        <property name="secondary_icon_stock">gtk-clear</property>
-                        <property name="secondary_icon_activatable">True</property>
-                        <property name="primary_icon_sensitive">True</property>
-                        <signal name="changed" handler="on_search_changed"/>
-                        <signal name="icon_press" handler="on_search_icon_press"/>
-                        <signal name="activate" handler="on_search_activate"/>
+                        <property name="related_action">week</property>
+                      </object>
+                    </child>
+                    <child>
+                      <object class="GtkMenuItem" id="menu_view_month">
+                        <property name="visible">True</property>
+                        <property name="related_action">month</property>
                       </object>
                     </child>
                   </object>
                 </child>
               </object>
-              <packing>
-                <property name="expand">True</property>
-              </packing>
             </child>
           </object>
           <packing>
@@ -269,17 +402,154 @@
             <child>
               <object class="GtkVBox" id="vbox2">
                 <property name="visible">True</property>
-                <property name="orientation">vertical</property>
                 <property name="spacing">10</property>
                 <child>
-                  <object class="GtkLabel" id="range_title">
+                  <object class="GtkHBox" id="hbox3">
                     <property name="visible">True</property>
-                    <property name="xalign">0</property>
-                    <property name="label">Range</property>
-                    <attributes>
-                      <attribute name="weight" value="bold"/>
-                      <attribute name="size" value="15000"/>
-                    </attributes>
+                    <child>
+                      <object class="GtkHBox" id="hbox4">
+                        <property name="visible">True</property>
+                        <child>
+                          <object class="GtkButton" id="button_prev">
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="receives_default">True</property>
+                            <property name="related_action">prev</property>
+                            <property name="relief">none</property>
+                            <child>
+                              <object class="GtkImage" id="image1">
+                                <property name="visible">True</property>
+                                <property name="stock">gtk-go-back</property>
+                              </object>
+                            </child>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="position">0</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkButton" id="button_home">
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="receives_default">True</property>
+                            <property name="related_action">home</property>
+                            <property name="relief">none</property>
+                            <child>
+                              <object class="GtkImage" id="image2">
+                                <property name="visible">True</property>
+                                <property name="stock">gtk-home</property>
+                              </object>
+                            </child>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="position">1</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkButton" id="button_next">
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="receives_default">True</property>
+                            <property name="related_action">next</property>
+                            <property name="relief">none</property>
+                            <child>
+                              <object class="GtkImage" id="image3">
+                                <property name="visible">True</property>
+                                <property name="stock">gtk-go-forward</property>
+                              </object>
+                            </child>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="position">2</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkToggleButton" id="date_pick">
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="receives_default">True</property>
+                            <property name="use_action_appearance">False</property>
+                            <signal name="toggled" handler="on_date_pick_toggled" swapped="no"/>
+                            <child>
+                              <object class="GtkAlignment" id="alignment4">
+                                <property name="visible">True</property>
+                                <child>
+                                  <object class="GtkHBox" id="hbox1">
+                                    <property name="visible">True</property>
+                                    <property name="spacing">3</property>
+                                    <child>
+                                      <object class="GtkAlignment" id="alignment5">
+                                        <property name="visible">True</property>
+                                        <property name="top_padding">2</property>
+                                        <property name="bottom_padding">2</property>
+                                        <property name="left_padding">2</property>
+                                        <property name="right_padding">2</property>
+                                        <child>
+                                          <object class="GtkLabel" id="range_title">
+                                            <property name="visible">True</property>
+                                            <property name="xalign">0</property>
+                                            <property name="label">Range</property>
+                                            <attributes>
+                                              <attribute name="weight" value="bold"/>
+                                              <attribute name="size" value="15000"/>
+                                            </attributes>
+                                          </object>
+                                        </child>
+                                      </object>
+                                      <packing>
+                                        <property name="position">0</property>
+                                      </packing>
+                                    </child>
+                                    <child>
+                                      <placeholder/>
+                                    </child>
+                                    <child>
+                                      <placeholder/>
+                                    </child>
+                                  </object>
+                                </child>
+                              </object>
+                            </child>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="position">3</property>
+                          </packing>
+                        </child>
+                      </object>
+                      <packing>
+                        <property name="position">0</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkAlignment" id="alignment1">
+                        <property name="width_request">250</property>
+                        <property name="visible">True</property>
+                        <property name="top_padding">3</property>
+                        <property name="bottom_padding">3</property>
+                        <property name="left_padding">6</property>
+                        <property name="right_padding">6</property>
+                        <child>
+                          <object class="GtkEntry" id="search">
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="invisible_char">â?¢</property>
+                            <property name="primary_icon_stock">gtk-find</property>
+                            <property name="secondary_icon_stock">gtk-clear</property>
+                            <property name="secondary_icon_activatable">True</property>
+                            <signal name="changed" handler="on_search_changed" swapped="no"/>
+                            <signal name="icon-press" handler="on_search_icon_press" swapped="no"/>
+                            <signal name="activate" handler="on_search_activate" swapped="no"/>
+                          </object>
+                        </child>
+                      </object>
+                      <packing>
+                        <property name="position">1</property>
+                      </packing>
+                    </child>
                   </object>
                   <packing>
                     <property name="position">0</property>
@@ -318,7 +588,7 @@
                 <property name="can_focus">True</property>
                 <property name="tab_hborder">8</property>
                 <property name="tab_vborder">4</property>
-                <signal name="switch_page" handler="on_window_tabs_switch_page" after="yes"/>
+                <signal name="switch-page" handler="on_window_tabs_switch_page" after="yes" swapped="no"/>
                 <child>
                   <object class="GtkAlignment" id="overview_tab">
                     <property name="visible">True</property>
@@ -367,4 +637,76 @@
       </object>
     </child>
   </object>
+  <object class="GtkActionGroup" id="activity">
+    <child>
+      <object class="GtkAction" id="remove">
+        <property name="label" translatable="yes">Remove</property>
+        <property name="stock_id">gtk-remove</property>
+        <property name="sensitive">False</property>
+        <signal name="activate" handler="on_remove_activate" swapped="no"/>
+      </object>
+    </child>
+    <child>
+      <object class="GtkAction" id="add">
+        <property name="label">Add new</property>
+        <property name="stock_id">gtk-add</property>
+        <signal name="activate" handler="on_add_activate" swapped="no"/>
+      </object>
+    </child>
+    <child>
+      <object class="GtkAction" id="edit">
+        <property name="label" translatable="yes">Edit</property>
+        <property name="stock_id">gtk-edit</property>
+        <property name="sensitive">False</property>
+        <signal name="activate" handler="on_edit_activate" swapped="no"/>
+      </object>
+    </child>
+  </object>
+  <object class="GtkMenu" id="fact_tree_popup">
+    <property name="visible">True</property>
+    <child>
+      <object class="GtkMenuItem" id="popup_edit">
+        <property name="visible">True</property>
+        <property name="related_action">edit</property>
+      </object>
+    </child>
+    <child>
+      <object class="GtkMenuItem" id="popup_remove">
+        <property name="visible">True</property>
+        <property name="related_action">remove</property>
+      </object>
+    </child>
+    <child>
+      <object class="GtkSeparatorMenuItem" id="menuitem10">
+        <property name="visible">True</property>
+        <property name="use_action_appearance">False</property>
+      </object>
+    </child>
+    <child>
+      <object class="GtkMenuItem" id="popup_add">
+        <property name="visible">True</property>
+        <property name="related_action">add</property>
+      </object>
+    </child>
+  </object>
+  <object class="GtkActionGroup" id="go">
+    <child>
+      <object class="GtkAction" id="next">
+        <property name="stock_id">gtk-go-forward</property>
+        <signal name="activate" handler="on_next_activate" swapped="no"/>
+      </object>
+    </child>
+    <child>
+      <object class="GtkAction" id="home">
+        <property name="stock_id">gtk-home</property>
+        <signal name="activate" handler="on_home_activate" swapped="no"/>
+      </object>
+    </child>
+    <child>
+      <object class="GtkAction" id="prev">
+        <property name="stock_id">gtk-go-back</property>
+        <signal name="activate" handler="on_prev_activate" swapped="no"/>
+      </object>
+    </child>
+  </object>
 </interface>
diff --git a/src/hamster/overview.py b/src/hamster/overview.py
index 3e69736..dc90ec0 100644
--- a/src/hamster/overview.py
+++ b/src/hamster/overview.py
@@ -72,41 +72,12 @@ class Overview(object):
         self.fact_tree = self.overview.fact_tree # TODO - this is upside down, should maybe get the overview tab over here
         self.fact_tree.connect("cursor-changed", self.on_fact_selection_changed)
 
+        self.fact_tree.connect("button-press-event", self.on_fact_tree_button_press)
+
         self.reports = TotalsBox()
         self.get_widget("reports_tab").add(self.reports)
 
-        self.range_combo = gtk.combo_box_new_text()
-        self.ranges = {}
-        
-        def add_range_option(key, label):
-            """
-            Insert a new item in the range combo and map its index into the
-            ranges dictionary.
-            """
-            self.range_combo.append_text(label)
-            index = self.range_combo.get_model().iter_n_children(None)-1
-            self.ranges[key] = index
-
-        add_range_option("day", _("Day"))
-        add_range_option("week", _("Week"))
-        add_range_option("month", _("Month"))
-        add_range_option("custom", _("Date Range"))
-        
-        self.range_combo.set_active(self.ranges["week"])
-        self.range_combo.connect("changed", self.on_range_combo_changed)
-
-
-
-        self.get_widget("range_pick").add(self.range_combo)
-
-
-        self.start_date_input = widgets.DateInput(self.start_date)
-        self.start_date_input.connect("date-entered", self.on_start_date_entered)
-        self.get_widget("range_start_box").add(self.start_date_input)
-
-        self.end_date_input = widgets.DateInput(self.end_date)
-        self.end_date_input.connect("date-entered", self.on_end_date_entered)
-        self.get_widget("range_end_box").add(self.end_date_input)
+        self.current_range = "week"
 
         self.timechart = widgets.TimeChart()
         self.timechart.day_start = self.day_start
@@ -119,6 +90,9 @@ class Overview(object):
 
         conf.connect('conf-changed', self.on_conf_change)
 
+        #self.get_widget("hbox1").pack_start(gtk.VSeparator())
+        self.get_widget("hbox1").pack_start(gtk.Arrow(gtk.ARROW_DOWN, gtk.SHADOW_ETCHED_IN))
+
         if conf.get("overview_window_maximized"):
             self.window.maximize()
         else:
@@ -135,13 +109,23 @@ class Overview(object):
         self.search()
 
 
+    def on_fact_tree_button_press(self, treeview, event):
+        if event.button == 3:
+            x = int(event.x)
+            y = int(event.y)
+            time = event.time
+            pthinfo = treeview.get_path_at_pos(x, y)
+            if pthinfo is not None:
+                path, col, cellx, celly = pthinfo
+                treeview.grab_focus()
+                treeview.set_cursor( path, col, 0)
+                self.get_widget("fact_tree_popup").popup( None, None, None, event.button, time)
+            return True
+
     def search(self):
         if self.start_date > self.end_date: # make sure the end is always after beginning
             self.start_date, self.end_date = self.end_date, self.start_date
 
-        self.start_date_input.set_date(self.start_date)
-        self.end_date_input.set_date(self.end_date)
-
         search_terms = self.get_widget("search").get_text().decode("utf8", "replace")
         self.facts = runtime.storage.get_facts(self.start_date, self.end_date, search_terms)
 
@@ -161,38 +145,41 @@ class Overview(object):
             self.overview.search(self.start_date, self.end_date, self.facts)
 
     def set_title(self):
-        start_date, end_date = self.start_date, self.end_date
+        self.title = self.format_range(self.start_date, self.end_date)
+        self.window.set_title(self.title.decode("utf-8"))
+        self.get_widget("range_title").set_text(self.title)
+
+
+    def format_range(self, start_date, end_date):
         dates_dict = stuff.dateDict(start_date, "start_")
         dates_dict.update(stuff.dateDict(end_date, "end_"))
 
         if start_date == end_date:
+            # Overview label if looking on single day
             # date format for overview label when only single day is visible
             # Using python datetime formatting syntax. See:
             # http://docs.python.org/library/time.html#time.strftime
-            start_date_str = start_date.strftime(_("%B %d, %Y"))
-            # Overview label if looking on single day
-            self.title = start_date_str
+            title = start_date.strftime(_("%B %d, %Y"))
         elif start_date.year != end_date.year:
             # overview label if start and end years don't match
             # letter after prefixes (start_, end_) is the one of
             # standard python date formatting ones- you can use all of them
             # see http://docs.python.org/library/time.html#time.strftime
-            self.title = _(u"%(start_B)s %(start_d)s, %(start_Y)s â?? %(end_B)s %(end_d)s, %(end_Y)s") % dates_dict
+            title = _(u"%(start_B)s %(start_d)s, %(start_Y)s â?? %(end_B)s %(end_d)s, %(end_Y)s") % dates_dict
         elif start_date.month != end_date.month:
             # overview label if start and end month do not match
             # letter after prefixes (start_, end_) is the one of
             # standard python date formatting ones- you can use all of them
             # see http://docs.python.org/library/time.html#time.strftime
-            self.title = _(u"%(start_B)s %(start_d)s â?? %(end_B)s %(end_d)s, %(end_Y)s") % dates_dict
+            title = _(u"%(start_B)s %(start_d)s â?? %(end_B)s %(end_d)s, %(end_Y)s") % dates_dict
         else:
             # overview label for interval in same month
             # letter after prefixes (start_, end_) is the one of
             # standard python date formatting ones- you can use all of them
             # see http://docs.python.org/library/time.html#time.strftime
-            self.title = _(u"%(start_B)s %(start_d)s â?? %(end_d)s, %(end_Y)s") % dates_dict
-
-        self.get_widget("range_title").set_text(self.title)
+            title = _(u"%(start_B)s %(start_d)s â?? %(end_d)s, %(end_Y)s") % dates_dict
 
+        return title
 
     def on_conf_change(self, event, key, value):
         if key == "day_start_minutes":
@@ -250,35 +237,54 @@ class Overview(object):
             self.report_chooser.present()
 
 
+    def apply_range_select(self):
+        self.get_widget("range_popup").hide()
+        self.get_widget("date_pick").set_active(False)
+        self.search()
 
-    def on_range_combo_changed(self, combo):
-        idx = combo.get_active()
+    def on_day_activate(self, button):
+        self.current_range = "day"
+        self.start_date = self.view_date
+        self.end_date = self.start_date + dt.timedelta(0)
+        self.apply_range_select()
 
-        self.get_widget("preset_range").hide()
-        self.get_widget("range_box").hide()
+    def on_week_activate(self, button):
+        self.current_range = "week"
+        self.start_date, self.end_date = self.week()
+        self.apply_range_select()
 
-        if idx == self.ranges["custom"]:
-            self.get_widget("range_box").show()
-        else:
-            if idx == self.ranges["day"]:
-                self.start_date = self.view_date
-                self.end_date = self.start_date + dt.timedelta(0)
-                self.get_widget("preset_range").show()
+    def on_month_activate(self, button):
+        self.current_range = "month"
+        self.start_date, self.end_date = self.month()
+        self.apply_range_select()
 
-            elif idx == self.ranges["week"]:
-                self.start_date = self.view_date - dt.timedelta(self.view_date.weekday() + 1)
-                self.start_date = self.start_date + dt.timedelta(stuff.locale_first_weekday())
-                self.end_date = self.start_date + dt.timedelta(6)
-                self.get_widget("preset_range").show()
+    def on_manual_range_apply_clicked(self, button):
+        self.current_range = "manual"
+        cal_date = self.get_widget("start_calendar").get_date()
+        self.start_date = dt.date(cal_date[0], cal_date[1] + 1, cal_date[2])
 
-            elif idx == self.ranges["month"]:
-                self.start_date = self.view_date - dt.timedelta(self.view_date.day - 1) #set to beginning of month
-                first_weekday, days_in_month = calendar.monthrange(self.view_date.year, self.view_date.month)
-                self.end_date = self.start_date + dt.timedelta(days_in_month - 1)
-                self.get_widget("preset_range").show()
+        cal_date = self.get_widget("end_calendar").get_date()
+        self.end_date = dt.date(cal_date[0], cal_date[1] + 1, cal_date[2])
 
+        self.apply_range_select()
+
+
+
+
+    def week(self):
+        # aligns start and end date to week
+        start_date = self.view_date - dt.timedelta(self.view_date.weekday() + 1)
+        start_date = start_date + dt.timedelta(stuff.locale_first_weekday())
+        end_date = start_date + dt.timedelta(6)
+        return start_date, end_date
+
+    def month(self):
+        # aligns start and end date to month
+        start_date = self.view_date - dt.timedelta(self.view_date.day - 1) #set to beginning of month
+        first_weekday, days_in_month = calendar.monthrange(self.view_date.year, self.view_date.month)
+        end_date = start_date + dt.timedelta(days_in_month - 1)
+        return start_date, end_date
 
-            self.search()
 
     def on_tabs_window_configure_event(self, window, event):
         # this is required so that the rows would grow on resize
@@ -294,56 +300,67 @@ class Overview(object):
         self.end_date = input.get_date()
         self.search()
 
-    def _chosen_range(self):
-        return self.range_combo.get_active()
 
-    def on_prev_clicked(self, button):
-        if self._chosen_range() == self.ranges["day"]:
+    def on_prev_activate(self, action):
+        if self.current_range == "day":
             self.start_date -= dt.timedelta(1)
             self.end_date -= dt.timedelta(1)
-        elif self._chosen_range() == self.ranges["week"]:
+        elif self.current_range == "week":
             self.start_date -= dt.timedelta(7)
             self.end_date -= dt.timedelta(7)
-        elif self._chosen_range() == self.ranges["month"]:
+        elif self.current_range == "month":
             self.end_date = self.start_date - dt.timedelta(1)
             first_weekday, days_in_month = calendar.monthrange(self.end_date.year, self.end_date.month)
             self.start_date = self.end_date - dt.timedelta(days_in_month - 1)
+        else:
+            # manual range - just jump to the next window
+            days =  (self.end_date - self.start_date) + dt.timedelta(days = 1)
+            self.start_date = self.start_date - days
+            self.end_date = self.end_date - days
 
         self.view_date = self.start_date
         self.search()
 
-    def on_next_clicked(self, button):
-        if self._chosen_range() == self.ranges["day"]:
+    def on_next_activate(self, action):
+        if self.current_range == "day":
             self.start_date += dt.timedelta(1)
             self.end_date += dt.timedelta(1)
-        elif self._chosen_range() == self.ranges["week"]:
+        elif self.current_range == "week":
             self.start_date += dt.timedelta(7)
             self.end_date += dt.timedelta(7)
-        elif self._chosen_range() == self.ranges["month"]:
+        elif self.current_range == "month":
             self.start_date = self.end_date + dt.timedelta(1)
             first_weekday, days_in_month = calendar.monthrange(self.start_date.year, self.start_date.month)
             self.end_date = self.start_date + dt.timedelta(days_in_month - 1)
+        else:
+            # manual range - just jump to the next window
+            days =  (self.end_date - self.start_date) + dt.timedelta(days = 1)
+            self.start_date = self.start_date + days
+            self.end_date = self.end_date + days
 
         self.view_date = self.start_date
         self.search()
 
 
-    def on_home_clicked(self, button):
+    def on_home_activate(self, action):
         self.view_date = (dt.datetime.today() - dt.timedelta(hours = self.day_start.hour,
                                                         minutes = self.day_start.minute)).date()
-        if self._chosen_range() == self.ranges["day"]:
+        if self.current_range == "day":
             self.start_date = self.view_date
             self.end_date = self.start_date + dt.timedelta(0)
 
-        elif self._chosen_range() == self.ranges["week"]:
+        elif self.current_range == "week":
             self.start_date = self.view_date - dt.timedelta(self.view_date.weekday() + 1)
             self.start_date = self.start_date + dt.timedelta(stuff.locale_first_weekday())
             self.end_date = self.start_date + dt.timedelta(6)
-
-        elif self._chosen_range() == self.ranges["month"]:
+        elif self.current_range == "month":
             self.start_date = self.view_date - dt.timedelta(self.view_date.day - 1) #set to beginning of month
             first_weekday, days_in_month = calendar.monthrange(self.view_date.year, self.view_date.month)
             self.end_date = self.start_date + dt.timedelta(days_in_month - 1)
+        else:
+            days =  (self.end_date - self.start_date)
+            self.start_date = self.view_date
+            self.end_date = self.view_date + days
 
         self.search()
 
@@ -360,7 +377,7 @@ class Overview(object):
             self.reports.do_charts()
 
 
-    def on_add_clicked(self, button):
+    def on_add_activate(self, action):
         fact = self.fact_tree.get_selected_fact()
         if not fact:
             selected_date = self.start_date
@@ -371,10 +388,39 @@ class Overview(object):
 
         dialogs.edit.show(fact_date = selected_date)
 
-    def on_remove_clicked(self, button):
+    def on_remove_activate(self, button):
         self.overview.delete_selected()
 
-    def on_edit_clicked(self, button):
+
+    def on_date_pick_toggled(self, button):
+        if button.get_active():
+            popup = self.get_widget("range_popup")
+
+
+            window = button.get_window()
+            x, y = window.get_origin()
+
+            alloc = button.get_allocation()
+
+            popup.move(x + alloc.x,y + alloc.y + alloc.height)
+
+            self.get_widget("day_preview").set_text(self.format_range(self.view_date, self.view_date).decode("utf-8"))
+            self.get_widget("week_preview").set_text(self.format_range(*self.week()).decode("utf-8"))
+            self.get_widget("month_preview").set_text(self.format_range(*self.month()).decode("utf-8"))
+
+            start_cal = self.get_widget("start_calendar")
+            start_cal.select_month(self.start_date.month, self.start_date.year)
+            start_cal.select_day(self.start_date.day)
+
+            end_cal = self.get_widget("end_calendar")
+            end_cal.select_month(self.end_date.month, self.end_date.year)
+            end_cal.select_day(self.end_date.day)
+
+            popup.show_all()
+        else:
+            self.get_widget("range_popup").hide()
+
+    def on_edit_activate(self, button):
         fact = self.fact_tree.get_selected_fact()
         if not fact or isinstance(fact, dt.date):
             return



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