[hamster-applet] statistics button
- From: Toms Baugis <tbaugis src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [hamster-applet] statistics button
- Date: Sat, 2 Jan 2010 19:45:01 +0000 (UTC)
commit ac44f7b9a3d12102c7ceb0d44fdc461493ac7ec2
Author: Toms Bauģis <toms baugis gmail com>
Date: Sat Jan 2 19:43:37 2010 +0000
statistics button
data/stats_reports.ui | 35 +++++++++++++++++++++++++++++++++--
data/stats_stats.ui | 3 +++
hamster/applet.py | 2 +-
hamster/configuration.py | 7 ++++++-
hamster/hamster-applet.py | 5 ++++-
hamster/stats_overview.py | 4 ++--
hamster/stats_reports.py | 5 ++++-
hamster/stats_stats.py | 38 ++++++++++++++++++++------------------
8 files changed, 73 insertions(+), 26 deletions(-)
---
diff --git a/data/stats_reports.ui b/data/stats_reports.ui
index 51f7db0..7a32827 100644
--- a/data/stats_reports.ui
+++ b/data/stats_reports.ui
@@ -10,9 +10,40 @@
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<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>
+ <property name="relief">none</property>
+ <signal name="clicked" handler="on_statistics_button_clicked"/>
+ <child>
+ <object class="GtkLabel" id="label4">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Show Statistics</property>
+ <attributes>
+ <attribute name="underline" value="True"/>
+ <attribute name="size" value="10000"/>
+ <attribute name="foreground" value="#00001154ffff"/>
+ </attributes>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
<object class="GtkScrolledWindow" id="scrolledwindow1">
<property name="visible">True</property>
- <property name="can_focus">True</property>
+ <property name="can_focus">False</property>
<property name="hscrollbar_policy">never</property>
<property name="vscrollbar_policy">automatic</property>
<child>
@@ -176,7 +207,7 @@
</child>
</object>
<packing>
- <property name="position">0</property>
+ <property name="position">1</property>
</packing>
</child>
</object>
diff --git a/data/stats_stats.ui b/data/stats_stats.ui
index 6f9cf44..c595fdb 100644
--- a/data/stats_stats.ui
+++ b/data/stats_stats.ui
@@ -5,7 +5,10 @@
<object class="GtkWindow" id="stats_window">
<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">12</property>
+ <property name="title" translatable="yes">Statistics</property>
<property name="window_position">center</property>
+ <property name="default_width">800</property>
+ <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="delete_event" handler="on_close"/>
diff --git a/hamster/applet.py b/hamster/applet.py
index b7039ba..be44601 100755
--- a/hamster/applet.py
+++ b/hamster/applet.py
@@ -551,7 +551,7 @@ class HamsterApplet(object):
"""button events"""
def on_overview(self, menu_item):
runtime.dispatcher.dispatch('panel_visible', False)
- dialogs.stats.show(self.applet)
+ dialogs.overview.show(self.applet)
def show_overview(self, menu_item, verb):
return self.on_overview(menu_item)
diff --git a/hamster/configuration.py b/hamster/configuration.py
index 629d8f7..b2d0618 100644
--- a/hamster/configuration.py
+++ b/hamster/configuration.py
@@ -146,9 +146,14 @@ class Dialogs(Singleton):
return CustomFactController
self.edit = OneWindow(get_edit_class)
- def get_stats_class():
+ def get_overview_class():
from stats import StatsViewer
return StatsViewer
+ self.overview = OneWindow(get_overview_class)
+
+ def get_stats_class():
+ from stats_stats import StatsViewer
+ return StatsViewer
self.stats = OneWindow(get_stats_class)
def get_about_class():
diff --git a/hamster/hamster-applet.py b/hamster/hamster-applet.py
index ad6f0da..3d426b9 100755
--- a/hamster/hamster-applet.py
+++ b/hamster/hamster-applet.py
@@ -114,7 +114,10 @@ if __name__ == "__main__":
if options.start_window or options.standalone:
gobject.set_application_name("hamster-applet")
- if options.start_window == "stats":
+ if options.start_window.startswith("over"):
+ dialogs.overview.show()
+
+ elif options.start_window == "stats":
dialogs.stats.show()
elif options.start_window == "edit":
diff --git a/hamster/stats_overview.py b/hamster/stats_overview.py
index b5a47a0..70af8bd 100644
--- a/hamster/stats_overview.py
+++ b/hamster/stats_overview.py
@@ -44,7 +44,7 @@ from hamster.i18n import C_
class OverviewBox(gtk.VBox):
def __init__(self):
gtk.VBox.__init__(self)
- self.set_border_width(12)
+ self.set_border_width(6)
scroll = gtk.ScrolledWindow()
scroll.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
@@ -142,7 +142,7 @@ class OverviewBox(gtk.VBox):
def on_facts_row_activated(self, tree, path, column):
selection = tree.get_selection()
(model, iter) = selection.get_selected()
- custom_fact = dialogs.edit.show(self.window, fact_id = model[iter][0])
+ custom_fact = dialogs.edit.show(self, fact_id = model[iter][0])
def on_facts_keys(self, tree, event):
if (event.keyval == gtk.keysyms.Delete):
diff --git a/hamster/stats_reports.py b/hamster/stats_reports.py
index 644a479..b326dd4 100644
--- a/hamster/stats_reports.py
+++ b/hamster/stats_reports.py
@@ -33,7 +33,7 @@ import gtk, gobject
import stuff, widgets
import charting, reports
-from configuration import runtime, GconfStore
+from configuration import runtime, GconfStore, dialogs
from hamster.i18n import C_
@@ -232,6 +232,9 @@ class ReportsBox(gtk.VBox):
def on_day_start_changed(self, event, new_minutes):
self.do_graph()
+
+ def on_statistics_button_clicked(self, button):
+ dialogs.stats.show(self)
diff --git a/hamster/stats_stats.py b/hamster/stats_stats.py
index 4c90a26..c895b60 100644
--- a/hamster/stats_stats.py
+++ b/hamster/stats_stats.py
@@ -36,12 +36,14 @@ from configuration import runtime
from hamster.i18n import C_
-class StatsBox(gtk.VBox):
- def __init__(self):
- gtk.VBox.__init__(self)
-
+class StatsViewer(object):
+ def __init__(self, parent = None):
self._gui = stuff.load_ui_file("stats_stats.ui")
- self.get_widget("stats_box").reparent(self) #mine!
+ self.report_chooser = None
+ self.window = self.get_widget("stats_window")
+
+ self.parent = parent# determine if app should shut down on close
+
self.background = (0.975, 0.975, 0.975)
self.get_widget("explore_frame").modify_bg(gtk.STATE_NORMAL,
@@ -57,6 +59,8 @@ class StatsBox(gtk.VBox):
runtime.dispatcher.add_handler('day_updated', self.after_fact_update)
self.init_stats()
+ self.window.show_all()
+ self.stats()
@@ -159,14 +163,14 @@ class StatsBox(gtk.VBox):
if not facts or (facts[-1]["start_time"] - facts[0]["start_time"]) < dt.timedelta(days=6):
self.get_widget("statistics_box").hide()
- self.get_widget("explore_controls").hide()
+ #self.get_widget("explore_controls").hide()
label = self.get_widget("not_enough_records_label")
if not facts:
label.set_text(_("""There is no data to generate statistics yet.
A week of usage would be nice!"""))
else:
- label.set_text(_("Still collecting data â?? check back after a week has passed!"))
+ label.set_text(_("Collecting data â?? check back after a week has passed!"))
label.show()
return
@@ -408,16 +412,14 @@ than 15 minutes you seem to be a busy bee." % ("<b>%d</b>" % short_percent))
return self._gui.get_object(name)
+ def close_window(self):
+ if not self.parent:
+ gtk.main_quit()
+ else:
+ self.window.destroy()
+ return False
+
+
if __name__ == "__main__":
- gtk.window_set_default_icon_name("hamster-applet")
-
- window = gtk.Window()
- window.set_title("Hamster - statistics")
- window.set_size_request(800, 600)
-
- stats_box = StatsBox()
- window.add(stats_box)
-
- window.show_all()
- stats_box.stats()
+ stats_viewer = StatsViewer()
gtk.main()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]