[hamster-applet] moved the fact tree out to a widget
- From: Toms Baugis <tbaugis src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [hamster-applet] moved the fact tree out to a widget
- Date: Sat, 5 Dec 2009 19:23:45 +0000 (UTC)
commit cda1fa54f90a3a2af781cfdc96857c7dd6ba233c
Author: Toms Bauģis <toms baugis gmail com>
Date: Sat Dec 5 19:18:37 2009 +0000
moved the fact tree out to a widget
data/applet.ui | 14 +---------
hamster/applet.py | 67 ++++++++--------------------------------------------
2 files changed, 13 insertions(+), 68 deletions(-)
---
diff --git a/data/applet.ui b/data/applet.ui
index c9756c2..989971b 100644
--- a/data/applet.ui
+++ b/data/applet.ui
@@ -272,7 +272,7 @@
<property name="expanded">True</property>
<property name="use_underline">True</property>
<child>
- <object class="GtkScrolledWindow" id="todays_scroll">
+ <object class="GtkScrolledWindow" id="today_box">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
@@ -280,17 +280,7 @@
<property name="vscrollbar_policy">never</property>
<property name="shadow_type">in</property>
<child>
- <object class="GtkTreeView" id="today">
- <property name="visible">True</property>
- <property name="can_focus">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="headers_visible">False</property>
- <property name="enable_search">False</property>
- <property name="tooltip_column">1</property>
- <signal name="key_press_event" handler="on_todays_keys"/>
- <signal name="row_activated" handler="on_today_row_activated"/>
- <signal name="button_release_event" handler="on_today_release_event"/>
- </object>
+ <placeholder/>
</child>
</object>
</child>
diff --git a/hamster/applet.py b/hamster/applet.py
index 5bf21b6..920feef 100755
--- a/hamster/applet.py
+++ b/hamster/applet.py
@@ -241,9 +241,9 @@ class HamsterApplet(object):
self.tag_box = widgets.TagBox(interactive = False)
self.get_widget("tag_box").add(self.tag_box)
+ self.treeview = widgets.FactTree()
- # init today's tree
- self.setup_activity_tree()
+ self.get_widget("today_box").add(self.treeview)
# DBus Setup
try:
@@ -298,37 +298,6 @@ class HamsterApplet(object):
self.on_notify_interval_changed(None, self.config.get_notify_interval())
-
- def setup_activity_tree(self):
- self.treeview = self._gui.get_object('today')
- # ID, Time, Name, Duration, Date, Description, Category
- self.treeview.set_model(gtk.ListStore(int, str, str, str, str, str, str, gobject.TYPE_PYOBJECT))
-
- self.treeview.append_column(gtk.TreeViewColumn("Time",
- gtk.CellRendererText(),
- text=2))
-
- self.treeview.append_column(stuff.ActivityColumn(name=1,
- description=5,
- category=6))
-
-
- tag_cell = widgets.TagCellRenderer()
- self.treeview.append_column(gtk.TreeViewColumn(_("Tags"), tag_cell, data=7))
-
-
- duration_cell = gtk.CellRendererText()
- duration_cell.set_property("xalign", 1)
- timeColumn = gtk.TreeViewColumn(_("Duration"), duration_cell, text=3)
- self.treeview.append_column(timeColumn)
-
- edit_cell = gtk.CellRendererPixbuf()
- edit_cell.set_property("stock_id", "gtk-edit")
- edit_cell.set_property("mode", gtk.CELL_RENDERER_MODE_ACTIVATABLE)
- self.edit_column = gtk.TreeViewColumn("", edit_cell)
- self.treeview.append_column(self.edit_column)
-
-
"""UI functions"""
def refresh_hamster(self):
"""refresh hamster every x secs - load today, check last activity etc."""
@@ -423,44 +392,30 @@ class HamsterApplet(object):
self.last_activity = runtime.storage.get_last_activity()
- fact_store = self.treeview.get_model()
- fact_store.clear()
+ self.treeview.clear()
+
facts = runtime.storage.get_facts(today)
if len(facts) > 10:
- self._gui.get_object("todays_scroll").set_size_request(-1, 250)
- self._gui.get_object("todays_scroll").set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_ALWAYS)
+ self._gui.get_object("today_box").set_size_request(-1, 250)
+ self._gui.get_object("today_box").set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_ALWAYS)
else:
- self._gui.get_object("todays_scroll").set_size_request(-1, -1)
- self._gui.get_object("todays_scroll").set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_NEVER)
+ self._gui.get_object("today_box").set_size_request(-1, -1)
+ self._gui.get_object("today_box").set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_NEVER)
by_category = {}
for fact in facts:
duration = 24 * 60 * fact["delta"].days + fact["delta"].seconds / 60
by_category[fact['category']] = \
by_category.setdefault(fact['category'], 0) + duration
-
- if fact["end_time"]:
- fact_time = "%s - %s " % (fact["start_time"].strftime("%H:%M"),
- fact["end_time"].strftime("%H:%M"))
- else:
- fact_time = fact["start_time"].strftime("%H:%M ")
-
- fact_store.append([fact['id'],
- stuff.escape_pango(fact['name']),
- fact_time,
- "%s" % stuff.format_duration(duration),
- "",
- stuff.escape_pango(fact["description"]),
- stuff.escape_pango(fact["category"]),
- fact])
+ self.treeview.add_fact(fact)
if not facts:
- self._gui.get_object("todays_scroll").hide()
+ self._gui.get_object("today_box").hide()
self._gui.get_object("fact_totals").set_text(_("No records today"))
else:
- self._gui.get_object("todays_scroll").show()
+ self._gui.get_object("today_box").show()
total_strings = []
for category in by_category:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]