[hamster-applet] adapting to theme colors (whoa)
- From: Toms Baugis <tbaugis src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [hamster-applet] adapting to theme colors (whoa)
- Date: Thu, 14 Jan 2010 19:27:07 +0000 (UTC)
commit e517659b7b548e647e0980191b5be8958d6b7413
Author: Toms Bauģis <toms baugis gmail com>
Date: Thu Jan 14 19:14:27 2010 +0000
adapting to theme colors (whoa)
data/stats_reports.ui | 1 +
data/stats_stats.ui | 247 ++++++++++++++++++++----------------------
hamster/charting.py | 113 +++++++++++++++----
hamster/stats_reports.py | 19 +---
hamster/stats_stats.py | 38 ++-----
hamster/widgets/timechart.py | 32 ++++--
6 files changed, 250 insertions(+), 200 deletions(-)
---
diff --git a/data/stats_reports.ui b/data/stats_reports.ui
index 7a32827..b14a879 100644
--- a/data/stats_reports.ui
+++ b/data/stats_reports.ui
@@ -50,6 +50,7 @@
<object class="GtkViewport" id="viewport1">
<property name="visible">True</property>
<property name="resize_mode">queue</property>
+ <property name="shadow_type">none</property>
<child>
<object class="GtkEventBox" id="reports_box">
<property name="visible">True</property>
diff --git a/data/stats_stats.ui b/data/stats_stats.ui
index 60d10e6..0a44675 100644
--- a/data/stats_stats.ui
+++ b/data/stats_stats.ui
@@ -4,20 +4,18 @@
<!-- interface-naming-policy project-wide -->
<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="border_width">10</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"/>
<child>
<object class="GtkVBox" id="stats_box">
<property name="visible">True</property>
- <property name="border_width">12</property>
<property name="orientation">vertical</property>
- <property name="spacing">12</property>
+ <property name="spacing">24</property>
<child>
<object class="GtkAlignment" id="alignment3">
<property name="visible">True</property>
@@ -73,200 +71,189 @@
</packing>
</child>
<child>
- <object class="GtkFrame" id="frame2">
+ <object class="GtkEventBox" id="explore_frame">
<property name="visible">True</property>
- <property name="label_xalign">0</property>
<child>
- <object class="GtkEventBox" id="explore_frame">
+ <object class="GtkAlignment" id="alignment7">
<property name="visible">True</property>
+ <property name="left_padding">5</property>
+ <property name="right_padding">5</property>
<child>
- <object class="GtkAlignment" id="alignment7">
+ <object class="GtkVBox" id="vbox3">
<property name="visible">True</property>
- <property name="top_padding">12</property>
- <property name="bottom_padding">12</property>
- <property name="left_padding">12</property>
- <property name="right_padding">12</property>
+ <property name="orientation">vertical</property>
<child>
- <object class="GtkVBox" id="vbox3">
+ <object class="GtkVBox" id="statistics_box">
<property name="visible">True</property>
<property name="orientation">vertical</property>
+ <property name="spacing">24</property>
<child>
- <object class="GtkVBox" id="statistics_box">
+ <object class="GtkAlignment" id="explore_everything">
+ <property name="height_request">70</property>
<property name="visible">True</property>
- <property name="orientation">vertical</property>
- <property name="spacing">12</property>
<child>
- <object class="GtkAlignment" id="explore_everything">
- <property name="height_request">70</property>
- <property name="visible">True</property>
- <child>
- <placeholder/>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="position">0</property>
- </packing>
+ <placeholder/>
</child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkHBox" id="vbox77">
+ <property name="visible">True</property>
<child>
- <object class="GtkHBox" id="vbox77">
+ <object class="GtkVBox" id="vbox5">
<property name="visible">True</property>
+ <property name="orientation">vertical</property>
<child>
- <object class="GtkVBox" id="vbox5">
+ <object class="GtkHBox" id="hbox5">
<property name="visible">True</property>
- <property name="orientation">vertical</property>
+ <property name="homogeneous">True</property>
<child>
- <object class="GtkHBox" id="hbox5">
+ <object class="GtkLabel" id="label7">
<property name="visible">True</property>
- <property name="homogeneous">True</property>
- <child>
- <object class="GtkLabel" id="label7">
- <property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="ypad">8</property>
- <property name="label" translatable="yes">Starts and ends</property>
- <attributes>
- <attribute name="weight" value="bold"/>
- </attributes>
- </object>
- <packing>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="label8">
- <property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">Totals</property>
- <attributes>
- <attribute name="weight" value="bold"/>
- </attributes>
- </object>
- <packing>
- <property name="position">1</property>
- </packing>
- </child>
+ <property name="xalign">0</property>
+ <property name="ypad">8</property>
+ <property name="label" translatable="yes">Starts and ends</property>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ </attributes>
</object>
<packing>
- <property name="expand">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
- <object class="GtkHBox" id="hbox3">
- <property name="height_request">160</property>
+ <object class="GtkLabel" id="label8">
<property name="visible">True</property>
- <property name="homogeneous">True</property>
- <child>
- <object class="GtkAlignment" id="explore_weekday_starts_ends">
- <property name="visible">True</property>
- <child>
- <placeholder/>
- </child>
- </object>
- <packing>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkAlignment" id="explore_weekday_totals">
- <property name="visible">True</property>
- <child>
- <placeholder/>
- </child>
- </object>
- <packing>
- <property name="position">1</property>
- </packing>
- </child>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Totals</property>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ </attributes>
</object>
<packing>
- <property name="expand">False</property>
<property name="position">1</property>
</packing>
</child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkHBox" id="hbox3">
+ <property name="height_request">160</property>
+ <property name="visible">True</property>
+ <property name="homogeneous">True</property>
<child>
- <object class="GtkHBox" id="hbox4">
- <property name="height_request">100</property>
+ <object class="GtkAlignment" id="explore_weekday_starts_ends">
<property name="visible">True</property>
- <property name="homogeneous">True</property>
<child>
- <object class="GtkAlignment" id="explore_category_starts_ends">
- <property name="visible">True</property>
- <child>
- <placeholder/>
- </child>
- </object>
- <packing>
- <property name="position">0</property>
- </packing>
+ <placeholder/>
</child>
+ </object>
+ <packing>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkAlignment" id="explore_weekday_totals">
+ <property name="visible">True</property>
<child>
- <object class="GtkAlignment" id="explore_category_totals">
- <property name="visible">True</property>
- <child>
- <placeholder/>
- </child>
- </object>
- <packing>
- <property name="position">1</property>
- </packing>
+ <placeholder/>
</child>
</object>
<packing>
- <property name="position">2</property>
+ <property name="position">1</property>
</packing>
</child>
</object>
<packing>
- <property name="position">0</property>
+ <property name="expand">False</property>
+ <property name="position">1</property>
</packing>
</child>
<child>
- <object class="GtkAlignment" id="explore_summary">
- <property name="width_request">200</property>
+ <object class="GtkHBox" id="hbox4">
+ <property name="height_request">100</property>
<property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="yalign">0</property>
- <property name="top_padding">32</property>
- <property name="left_padding">30</property>
+ <property name="homogeneous">True</property>
<child>
- <placeholder/>
+ <object class="GtkAlignment" id="explore_category_starts_ends">
+ <property name="visible">True</property>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ <packing>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkAlignment" id="explore_category_totals">
+ <property name="visible">True</property>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ <packing>
+ <property name="position">1</property>
+ </packing>
</child>
</object>
<packing>
- <property name="expand">False</property>
- <property name="position">1</property>
+ <property name="position">2</property>
</packing>
</child>
</object>
<packing>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkAlignment" id="explore_summary">
+ <property name="width_request">200</property>
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0</property>
+ <property name="top_padding">32</property>
+ <property name="left_padding">30</property>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="not_enough_records_label">
- <property name="label">Text we say when there is not enough data</property>
- <property name="wrap">True</property>
- </object>
- <packing>
<property name="position">1</property>
</packing>
</child>
</object>
+ <packing>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="not_enough_records_label">
+ <property name="label">Text we say when there is not enough data</property>
+ <property name="wrap">True</property>
+ </object>
+ <packing>
+ <property name="position">1</property>
+ </packing>
</child>
</object>
</child>
</object>
</child>
- <child type="label_item">
- <placeholder/>
- </child>
</object>
<packing>
<property name="position">1</property>
diff --git a/hamster/charting.py b/hamster/charting.py
index cdbf11a..d94a9d8 100644
--- a/hamster/charting.py
+++ b/hamster/charting.py
@@ -326,8 +326,16 @@ class BarChart(Chart):
(self.graph_width - x) / float(max(1, len(self.keys) - i - 1)))
+ # now for the text - we want reduced contrast for relaxed visuals
+ fg_color = self.get_style().fg[gtk.STATE_NORMAL].to_string()
+ if self.colors.is_light(fg_color):
+ label_color = self.colors.darker(fg_color, 80)
+ else:
+ label_color = self.colors.darker(fg_color, -80)
+
+
for key, bar, data in zip(self.keys, self.bars, self.data):
- self.set_color(graphics.Colors.aluminium[5]);
+ self.set_color(label_color);
self.layout.set_text(key)
label_w, label_h = self.layout.get_pixel_size()
@@ -341,7 +349,16 @@ class BarChart(Chart):
bar_start = 0
- base_color = self.bar_base_color or (220, 220, 220)
+
+ # determine bar color
+ base_color = self.bar_base_color
+ if not base_color: #yay, we can be theme friendly!
+ bg_color = self.get_style().bg[gtk.STATE_NORMAL].to_string()
+ if self.colors.is_light(bg_color):
+ base_color = self.colors.darker(bg_color, 40)
+ else:
+ base_color = self.colors.darker(bg_color, -40)
+ tick_color = self.colors.darker(bg_color, -60)
if self.stack_keys:
remaining_fractions, remaining_pixels = 1, max_bar_size
@@ -392,15 +409,20 @@ class BarChart(Chart):
label_y)
# we are in the bar so make sure that the font color is distinguishable
- if colorsys.rgb_to_hls(*graphics.Colors.rgb(last_color))[1] < 150:
- self.set_color(graphics.Colors.almost_white)
+ if self.colors.is_light(last_color):
+ self.set_color(label_color)
else:
- self.set_color(graphics.Colors.aluminium[5])
+ self.set_color(self.colors.almost_white)
context.show_layout(self.layout)
#white grid and scale values
+ if self.background:
+ grid_color = self.background
+ else:
+ grid_color = self.get_style().bg[gtk.STATE_NORMAL].to_string()
+
self.layout.set_width(-1)
if self.grid_stride and self.max_value:
# if grid stride is less than 1 then we consider it to be percentage
@@ -418,10 +440,10 @@ class BarChart(Chart):
label_w, label_h = self.layout.get_pixel_size()
context.move_to(legend_width - label_w - 8,
y - label_h / 2)
- self.set_color(graphics.Colors.aluminium[4])
+ self.set_color(self.colors.aluminium[4])
context.show_layout(self.layout)
- self.set_color("#ffffff")
+ self.set_color(grid_color)
self.context.move_to(legend_width, y)
self.context.line_to(self.width, y)
@@ -429,7 +451,7 @@ class BarChart(Chart):
#stack keys
if self.show_stack_labels:
#put series keys
- self.set_color(graphics.Colors.aluminium[5]);
+ self.set_color(label_color);
y = self.graph_height
label_y = None
@@ -540,6 +562,26 @@ class HorizontalBarChart(Chart):
self.layout.set_width(legend_width * pango.SCALE)
+ # determine bar color
+ base_color = self.bar_base_color
+ if not base_color: #yay, we can be theme friendly!
+ bg_color = self.get_style().bg[gtk.STATE_NORMAL].to_string()
+ if self.colors.is_light(bg_color):
+ base_color = self.colors.darker(bg_color, 40)
+ else:
+ base_color = self.colors.darker(bg_color, -40)
+ tick_color = self.colors.darker(bg_color, -60)
+ last_color = base_color
+
+
+ # now for the text - we want reduced contrast for relaxed visuals
+ fg_color = self.get_style().fg[gtk.STATE_NORMAL].to_string()
+ if self.colors.is_light(fg_color):
+ label_color = self.colors.darker(fg_color, 80)
+ else:
+ label_color = self.colors.darker(fg_color, -80)
+
+
for i, label in enumerate(keys):
if self.interactive:
self.register_mouse_region(0,
@@ -552,13 +594,10 @@ class HorizontalBarChart(Chart):
self.layout.set_text(label)
label_w, label_h = self.layout.get_pixel_size()
- self.set_color(graphics.Colors.aluminium[5])
+ self.set_color(label_color)
context.move_to(0, positions[label][0] + (positions[label][1] - label_h) / 2)
context.show_layout(self.layout)
- base_color = self.bar_base_color or (220, 220, 220)
-
- last_color = (255,255,255)
if self.stack_keys:
bar_start = 0
@@ -585,7 +624,7 @@ class HorizontalBarChart(Chart):
if i in self.bars_selected:
last_color = self.get_style().bg[gtk.STATE_SELECTED].to_string()
elif i == self.mouse_bar:
- last_color = self.get_style().bg[gtk.STATE_PRELIGHT].to_string()
+ last_color = self.get_style().base[gtk.STATE_PRELIGHT].to_string()
else:
last_color = self.key_colors.get(self.keys[i]) or base_color
@@ -595,7 +634,11 @@ class HorizontalBarChart(Chart):
positions[label][1],
last_color)
- # values on bars
+
+
+
+
+ # value labels
if self.stack_keys:
total_value = sum(self.data[i])
else:
@@ -608,16 +651,16 @@ class HorizontalBarChart(Chart):
vertical_padding = max((positions[label][1] - label_h) / 2.0, 1)
if bar_start - vertical_padding < label_w:
label_x = self.graph_x + bar_start + vertical_padding
- self.set_color(graphics.Colors.aluminium[5])
+ self.set_color(label_color)
else:
if i in self.bars_selected:
self.set_color(self.get_style().fg[gtk.STATE_SELECTED].to_string())
else:
# we are in the bar so make sure that the font color is distinguishable
- if colorsys.rgb_to_hls(*graphics.Colors.rgb(last_color))[1] < 150:
- self.set_color(graphics.Colors.almost_white)
+ if self.colors.is_light(last_color):
+ self.set_color(label_color)
else:
- self.set_color(graphics.Colors.aluminium[5])
+ self.set_color(self.colors.almost_white)
label_x = self.graph_x + bar_start - label_w - vertical_padding
@@ -692,6 +735,15 @@ class HorizontalDayChart(Chart):
max_bar_size = self.graph_width - 15
+
+ # now for the text - we want reduced contrast for relaxed visuals
+ fg_color = self.get_style().fg[gtk.STATE_NORMAL].to_string()
+ if self.colors.is_light(fg_color):
+ label_color = self.colors.darker(fg_color, 80)
+ else:
+ label_color = self.colors.darker(fg_color, -80)
+
+
self.layout.set_alignment(pango.ALIGN_RIGHT)
self.layout.set_ellipsize(pango.ELLIPSIZE_END)
@@ -700,8 +752,18 @@ class HorizontalDayChart(Chart):
factor = max_bar_size / float(end_hour - start_hour)
+ # determine bar color
+ base_color = self.bar_base_color
+ if not base_color: #yay, we can be theme friendly!
+ bg_color = self.get_style().bg[gtk.STATE_NORMAL].to_string()
+ if self.colors.is_light(bg_color):
+ base_color = self.colors.darker(bg_color, 40)
+ else:
+ base_color = self.colors.darker(bg_color, -40)
+ tick_color = self.colors.darker(bg_color, -60)
+
for i, label in enumerate(keys):
- self.set_color(graphics.Colors.aluminium[5])
+ self.set_color(label_color)
self.layout.set_text(label)
label_w, label_h = self.layout.get_pixel_size()
@@ -709,8 +771,6 @@ class HorizontalDayChart(Chart):
context.move_to(0, positions[label][0] + (positions[label][1] - label_h) / 2)
context.show_layout(self.layout)
- base_color = self.bar_base_color or [220, 220, 220]
-
if isinstance(self.data[i], list) == False:
self.data[i] = [self.data[i]]
@@ -731,6 +791,13 @@ class HorizontalDayChart(Chart):
pace = ((end_hour - start_hour) / 3) / 60 * 60
last_position = positions[keys[-1]]
+
+
+ if self.background:
+ grid_color = self.background
+ else:
+ grid_color = self.get_style().bg[gtk.STATE_NORMAL].to_string()
+
for i in range(start_hour + 60, end_hour, pace):
x = round((i - start_hour) * factor)
@@ -741,11 +808,11 @@ class HorizontalDayChart(Chart):
context.move_to(self.graph_x + x - label_w / 2,
last_position[0] + last_position[1] + 4)
- self.set_color(graphics.Colors.aluminium[4])
+ self.set_color(self.colors.aluminium[4])
context.show_layout(self.layout)
- self.set_color((255, 255, 255))
+ self.set_color(grid_color)
self.context.move_to(round(self.graph_x + x) + 0.5, self.graph_y)
self.context.line_to(round(self.graph_x + x) + 0.5,
last_position[0] + last_position[1])
diff --git a/hamster/stats_reports.py b/hamster/stats_reports.py
index a4deabd..1d6820e 100644
--- a/hamster/stats_reports.py
+++ b/hamster/stats_reports.py
@@ -47,15 +47,10 @@ class ReportsBox(gtk.VBox):
self.start_date, self.end_date = None, None
#graphs
- self.background = (0.975, 0.975, 0.975)
- self.get_widget("reports_box").modify_bg(gtk.STATE_NORMAL,
- gtk.gdk.Color(*[int(b*65536.0) for b in self.background]))
-
x_offset = 100 # align all graphs to the left edge
- self.category_chart = charting.HorizontalBarChart(background = self.background,
- max_bar_width = 20,
+ self.category_chart = charting.HorizontalBarChart(max_bar_width = 20,
legend_width = x_offset,
value_format = "%.1f",
interactive = True)
@@ -65,8 +60,7 @@ class ReportsBox(gtk.VBox):
self.get_widget("totals_by_category").add(self.category_chart);
- self.activity_chart = charting.HorizontalBarChart(background = self.background,
- max_bar_width = 20,
+ self.activity_chart = charting.HorizontalBarChart(max_bar_width = 20,
legend_width = x_offset,
value_format = "%.1f",
interactive = True)
@@ -76,11 +70,10 @@ class ReportsBox(gtk.VBox):
self.get_widget("totals_by_activity").add(self.activity_chart);
- self.tag_chart = charting.HorizontalBarChart(background = self.background,
- max_bar_width = 20,
- legend_width = x_offset,
- value_format = "%.1f",
- interactive = True)
+ self.tag_chart = charting.HorizontalBarChart(max_bar_width = 20,
+ legend_width = x_offset,
+ value_format = "%.1f",
+ interactive = True)
self.tag_chart.connect("bar-clicked", self.on_tag_clicked)
self.selected_tags = []
self.tag_sums = None
diff --git a/hamster/stats_stats.py b/hamster/stats_stats.py
index 44f2aaa..72c058b 100644
--- a/hamster/stats_stats.py
+++ b/hamster/stats_stats.py
@@ -35,16 +35,6 @@ from configuration import runtime
from hamster.i18n import C_
-class TimeChartWithBackground(widgets.TimeChart):
- def __init__(self):
- widgets.TimeChart.__init__(self)
- self.bar_color = (220, 220, 220)
-
- def on_expose(self):
- self.fill_area(0, 0, self.width, self.height, (0.975, 0.975, 0.975))
- widgets.TimeChart.on_expose(self)
-
-
class StatsViewer(object):
def __init__(self, parent = None):
self._gui = stuff.load_ui_file("stats_stats.ui")
@@ -53,14 +43,9 @@ class StatsViewer(object):
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,
- gtk.gdk.Color(*[int(b*65536.0) for b in self.background]))
-
self.stat_facts = None
- self.timechart = TimeChartWithBackground()
+ self.timechart = widgets.TimeChart()
self.get_widget("explore_everything").add(self.timechart)
self.get_widget("explore_everything").show_all()
@@ -106,7 +91,6 @@ class StatsViewer(object):
self.chart_category_totals = charting.HorizontalBarChart(value_format = "%.1f",
bars_beveled = False,
- background = self.background,
max_bar_width = 20,
legend_width = 70)
self.get_widget("explore_category_totals").add(self.chart_category_totals)
@@ -114,31 +98,29 @@ class StatsViewer(object):
self.chart_weekday_totals = charting.HorizontalBarChart(value_format = "%.1f",
bars_beveled = False,
- background = self.background,
max_bar_width = 20,
legend_width = 70)
self.get_widget("explore_weekday_totals").add(self.chart_weekday_totals)
self.chart_weekday_starts_ends = charting.HorizontalDayChart(bars_beveled = False,
animate = False,
- background = self.background,
max_bar_width = 20,
legend_width = 70)
self.get_widget("explore_weekday_starts_ends").add(self.chart_weekday_starts_ends)
self.chart_category_starts_ends = charting.HorizontalDayChart(bars_beveled = False,
animate = False,
- background = self.background,
max_bar_width = 20,
legend_width = 70)
self.get_widget("explore_category_starts_ends").add(self.chart_category_starts_ends)
+
+
#ah, just want summary look just like all the other text on the page
class CairoText(graphics.Area):
- def __init__(self, background = None, fontsize = 10):
+ def __init__(self, fontsize = 10):
graphics.Area.__init__(self)
- self.background = background
self.text = ""
self.fontsize = fontsize
@@ -147,8 +129,12 @@ class StatsViewer(object):
self.redraw_canvas()
def on_expose(self):
- if self.background:
- self.fill_area(0, 0, self.width, self.height, self.background)
+ # now for the text - we want reduced contrast for relaxed visuals
+ fg_color = self.get_style().fg[gtk.STATE_NORMAL].to_string()
+ if self.colors.is_light(fg_color):
+ label_color = self.colors.darker(fg_color, 80)
+ else:
+ label_color = self.colors.darker(fg_color, -80)
default_font = pango.FontDescription(gtk.Style().font_desc.to_string())
default_font.set_size(self.fontsize * pango.SCALE)
@@ -159,11 +145,11 @@ class StatsViewer(object):
self.layout.set_width((self.width) * pango.SCALE)
self.context.move_to(0,0)
- self.set_color(charting.graphics.Colors.aluminium[5])
+ self.set_color(label_color)
self.context.show_layout(self.layout)
- self.explore_summary = CairoText(self.background)
+ self.explore_summary = CairoText()
self.get_widget("explore_summary").add(self.explore_summary)
self.get_widget("explore_summary").show_all()
diff --git a/hamster/widgets/timechart.py b/hamster/widgets/timechart.py
index 311e586..25eb657 100644
--- a/hamster/widgets/timechart.py
+++ b/hamster/widgets/timechart.py
@@ -47,9 +47,7 @@ class TimeChart(graphics.Area):
self.minor_tick = None
self.tick_totals = []
-
- self.bar_color = "#ccc"
-
+
def draw(self, facts, start_date, end_date):
self.facts = facts
@@ -114,6 +112,24 @@ class TimeChart(graphics.Area):
def on_expose(self):
+ # figure out colors
+ bg_color = self.get_style().bg[gtk.STATE_NORMAL].to_string()
+ if self.colors.is_light(bg_color):
+ bar_color = self.colors.darker(bg_color, 40)
+ tick_color = self.colors.darker(bg_color, 60)
+ else:
+ bar_color = self.colors.darker(bg_color, -40)
+ tick_color = self.colors.darker(bg_color, -60)
+
+ # now for the text - we want reduced contrast for relaxed visuals
+ fg_color = self.get_style().fg[gtk.STATE_NORMAL].to_string()
+ if self.colors.is_light(fg_color):
+ label_color = self.colors.darker(fg_color, 80)
+ else:
+ label_color = self.colors.darker(fg_color, -80)
+
+
+
self.context.set_line_width(1)
# major ticks
@@ -177,13 +193,13 @@ class TimeChart(graphics.Area):
current_time = self.start_time + major_step
while current_time < self.end_time:
if current_time in ticks:
- line(exes[current_time][0] - 2, "#bbb")
+ line(exes[current_time][0] - 2, tick_color)
else:
if self.minor_tick <= WEEK and current_time.day == 1: # month change
- somewhere_in_middle(current_time, "#bbb")
+ somewhere_in_middle(current_time, tick_color)
# year change
elif current_time.timetuple().tm_yday == 1: # year change
- somewhere_in_middle(current_time, "#f00")
+ somewhere_in_middle(current_time, tick_color)
current_time += major_step
@@ -194,7 +210,7 @@ class TimeChart(graphics.Area):
bar_size = max(round(self.height * total * 0.8), 1)
x, bar_width = exes[current_time]
- self.set_color(self.bar_color)
+ self.set_color(bar_color)
# rounded corners
self.draw_rect(x, self.height - bar_size, bar_width - 1, bar_size, 3)
@@ -229,7 +245,7 @@ class TimeChart(graphics.Area):
x, bar_width = exes[current_time]
- self.set_color("#666")
+ self.set_color(label_color)
self.layout.set_width(int((self.width - x) * pango.SCALE))
self.layout.set_markup(current_time.strftime(step_format))
self.context.move_to(x + 2, 0)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]