[hamster-applet] moved configuration reading out of the widget so it can be reused easier
- From: Toms Baugis <tbaugis src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [hamster-applet] moved configuration reading out of the widget so it can be reused easier
- Date: Wed, 20 Jan 2010 02:07:24 +0000 (UTC)
commit ff90ea4ebeee9eb904416ea9c821cb4cde473c01
Author: Toms Bauģis <toms baugis gmail com>
Date: Wed Jan 20 02:03:23 2010 +0000
moved configuration reading out of the widget so it can be reused easier
hamster/overview.py | 12 +++++++-----
hamster/stats.py | 6 +++++-
hamster/widgets/timechart.py | 20 +++++++-------------
3 files changed, 19 insertions(+), 19 deletions(-)
---
diff --git a/hamster/overview.py b/hamster/overview.py
index 0ec569b..01e8805 100644
--- a/hamster/overview.py
+++ b/hamster/overview.py
@@ -99,6 +99,8 @@ class Overview(object):
self.get_widget("range_end_box").add(self.end_date_input)
self.timechart = widgets.TimeChart()
+ self.timechart.day_start = self.day_start
+
self.get_widget("by_day_box").add(self.timechart)
self._gui.connect_signals(self)
@@ -184,8 +186,9 @@ class Overview(object):
key, value = data
if key == "day_start_minutes":
self.day_start = dt.time(value / 60, value % 60)
+ self.timechart.day_start = self.day_start
self.search()
-
+
def on_fact_selection_changed(self, tree):
""" enables and disables action buttons depending on selected item """
fact = tree.get_selected_fact()
@@ -328,7 +331,7 @@ class Overview(object):
selected_date = fact
else:
selected_date = fact["date"]
-
+
dialogs.edit.show(fact_date = selected_date)
def on_remove_clicked(self, button):
@@ -357,13 +360,13 @@ class Overview(object):
# properly saving window state and position
maximized = self.window.get_window().get_state() & gtk.gdk.WINDOW_STATE_MAXIMIZED
conf.set("overview_window_maximized", maximized)
-
+
# make sure to remember dimensions only when in normal state
if maximized == False and not self.window.get_window().get_state() & gtk.gdk.WINDOW_STATE_ICONIFIED:
x, y = self.window.get_position()
w, h = self.window.get_size()
conf.set("overview_window_box", [x, y, w, h])
-
+
if not self.parent:
gtk.main_quit()
@@ -373,4 +376,3 @@ class Overview(object):
def show(self):
self.window.show()
-
diff --git a/hamster/stats.py b/hamster/stats.py
index 61f3bb0..fd19482 100644
--- a/hamster/stats.py
+++ b/hamster/stats.py
@@ -31,7 +31,7 @@ import gtk, gobject
import pango
import stuff, charting, graphics, widgets
-from configuration import runtime
+from configuration import runtime, conf
from hamster.i18n import C_
@@ -45,7 +45,11 @@ class Stats(object):
self.stat_facts = None
+ day_start = conf.get("day_start_minutes")
+ day_start = dt.time(day_start / 60, day_start % 60)
self.timechart = widgets.TimeChart()
+ self.timechart.day_start = day_start
+
self.get_widget("explore_everything").add(self.timechart)
self.get_widget("explore_everything").show_all()
diff --git a/hamster/widgets/timechart.py b/hamster/widgets/timechart.py
index e223503..27fcf42 100644
--- a/hamster/widgets/timechart.py
+++ b/hamster/widgets/timechart.py
@@ -21,8 +21,6 @@ import gtk, pango
from .hamster import graphics, stuff
-from .hamster.configuration import conf
-
import datetime as dt
import calendar
@@ -40,14 +38,14 @@ class TimeChart(graphics.Area):
graphics.Area.__init__(self)
self.start_time, self.end_time = None, None
self.facts = []
- self.day_start = conf.get("day_start_minutes")
- self.day_start = dt.time(self.day_start / 60, self.day_start % 60)
+
+ self.day_start = dt.time() # ability to start day at another hour
self.first_weekday = stuff.locale_first_weekday()
self.minor_tick = None
self.tick_totals = []
-
+
def draw(self, facts, start_date, end_date):
self.facts = facts
@@ -202,7 +200,7 @@ class TimeChart(graphics.Area):
somewhere_in_middle(current_time, tick_color)
current_time += major_step
-
+
# the bars
@@ -211,13 +209,13 @@ class TimeChart(graphics.Area):
x, bar_width = exes[current_time]
self.set_color(bar_color)
-
+
# rounded corners
self.draw_rect(x, self.height - bar_size, bar_width - 1, bar_size, 3)
# straighten out bottom rounded corners
- self.context.rectangle(x, self.height - min(bar_size, 2), bar_width - 1, min(bar_size, 2))
-
+ self.context.rectangle(x, self.height - min(bar_size, 2), bar_width - 1, min(bar_size, 2))
+
self.context.fill()
@@ -304,7 +302,3 @@ class TimeChart(graphics.Area):
hours = [hour / float(max_hour or 1) for hour in hours]
self.tick_totals = zip(fractions, hours)
-
-
-
-
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]