hamster-applet r784 - trunk/hamster
- From: tbaugis svn gnome org
- To: svn-commits-list gnome org
- Subject: hamster-applet r784 - trunk/hamster
- Date: Sun, 22 Feb 2009 15:11:00 +0000 (UTC)
Author: tbaugis
Date: Sun Feb 22 15:11:00 2009
New Revision: 784
URL: http://svn.gnome.org/viewvc/hamster-applet?rev=784&view=rev
Log:
removed wildcard import of stuff and cleaned up a bit
Modified:
trunk/hamster/applet.py
trunk/hamster/edit_activity.py
trunk/hamster/stuff.py
Modified: trunk/hamster/applet.py
==============================================================================
--- trunk/hamster/applet.py (original)
+++ trunk/hamster/applet.py Sun Feb 22 15:11:00 2009
@@ -38,7 +38,7 @@
import hamster.eds
from hamster.Configuration import GconfStore
-from hamster.stuff import *
+from hamster import stuff
from hamster.KeyBinder import *
from hamster.hamsterdbus import HAMSTER_URI, HamsterDbusController
@@ -109,7 +109,7 @@
else:
label = "%s %s" % (self.activity, self.duration)
- label = escape_pango(label)
+ label = stuff.escape_pango(label)
label = '<span gravity=\"south\">' + label + '</span>'
self.label.set_markup(label)
@@ -182,19 +182,6 @@
class HamsterApplet(object):
- def name_painter(self, column, cell, model, iter):
- activity_name = model.get_value(iter, 1)
- description = model.get_value(iter, 5)
-
- text = """%s""" % activity_name
- if description:
- text+= """\n<span style="italic" size="small">%s</span>""" % (description)
-
- cell.set_property('markup', text)
-
- return
-
-
def __init__(self, applet):
self.config = GconfStore.get_instance()
@@ -214,24 +201,7 @@
self.set_dropdown()
# init today's tree
- self.treeview = self.glade.get_widget('today')
- self.treeview.set_tooltip_column(1)
-
- self.treeview.append_column(gtk.TreeViewColumn("Time", gtk.CellRendererText(), text=2))
-
- nameColumn = gtk.TreeViewColumn(_("Name"))
- nameColumn.set_expand(True)
- nameCell = gtk.CellRendererText()
- nameColumn.pack_start(nameCell, True)
- nameCell.set_property("ellipsize", pango.ELLIPSIZE_END)
- nameColumn.set_cell_data_func(nameCell, self.name_painter)
- self.treeview.append_column(nameColumn)
-
-
- edit_cell = gtk.CellRendererPixbuf()
- edit_cell.set_property("stock_id", "gtk-edit")
- self.edit_column = gtk.TreeViewColumn("", edit_cell)
- self.treeview.append_column(self.edit_column)
+ self.setup_activity_tree()
# DBus Setup
try:
@@ -307,6 +277,24 @@
dispatcher.add_handler('gconf_notify_interval_changed', self.on_notify_interval_changed)
self.on_notify_interval_changed(None, self.config.get_notify_interval())
+ def setup_activity_tree(self):
+ self.treeview = self.glade.get_widget('today')
+ self.treeview.set_tooltip_column(1)
+
+ self.treeview.append_column(gtk.TreeViewColumn("Time", gtk.CellRendererText(), text=2))
+
+ nameColumn = stuff.ActivityColumn(name=1, description=5)
+ self.treeview.append_column(nameColumn)
+
+
+ timeColumn = gtk.TreeViewColumn(_("Duration"), gtk.CellRendererText(), text=3)
+ self.treeview.append_column(timeColumn)
+
+ edit_cell = gtk.CellRendererPixbuf()
+ edit_cell.set_property("stock_id", "gtk-edit")
+ self.edit_column = gtk.TreeViewColumn("", edit_cell)
+ self.treeview.append_column(self.edit_column)
+
def on_idle_changed(self, state):
print "Idle state changed. Idle: ", state
@@ -326,7 +314,7 @@
activity_cell = gtk.CellRendererText()
self.activity_list.pack_start(activity_cell, True)
self.activity_list.add_attribute(activity_cell, 'text', 0)
- category_cell = CategoryCell()
+ category_cell = stuff.CategoryCell()
self.activity_list.pack_start(category_cell, False)
self.activity_list.add_attribute(category_cell, 'text', 1)
@@ -345,7 +333,7 @@
completion.add_attribute(activity_cell, 'text', 0)
completion.set_property("text-column", 2)
- category_cell = CategoryCell()
+ category_cell = stuff.CategoryCell()
completion.pack_start(category_cell, False)
completion.add_attribute(category_cell, 'text', 1)
@@ -409,8 +397,10 @@
if self.last_activity and self.last_activity['end_time'] == None:
delta = datetime.datetime.now() - self.last_activity['start_time']
duration = delta.seconds / 60
- label = "%s %s" % (self.last_activity['name'], format_duration(duration))
- self.button.set_text(self.last_activity['name'], format_duration(duration))
+ label = "%s %s" % (self.last_activity['name'],
+ stuff.format_duration(duration))
+ self.button.set_text(self.last_activity['name'],
+ stuff.format_duration(duration))
self.glade.get_widget('stop_tracking').set_sensitive(1);
else:
@@ -443,7 +433,7 @@
"""sets up today's tree and fills it with records
returns information about last activity"""
today = datetime.date.today()
- day = DayStore(today);
+ day = stuff.DayStore(today);
self.treeview.set_model(day.fact_store)
self.last_activity = None
@@ -460,8 +450,9 @@
total_string = ""
for total in day.totals:
- total_string += _("%(category)s: %(duration)s, ") % ({'category': total,
- 'duration': format_duration(day.totals[total])})
+ total_string += _("%(category)s: %(duration)s, ") % \
+ ({'category': total,
+ 'duration': stuff.format_duration(day.totals[total])})
total_string = total_string.rstrip(", ") # trailing slash
self.glade.get_widget("fact_totals").set_text(total_string)
Modified: trunk/hamster/edit_activity.py
==============================================================================
--- trunk/hamster/edit_activity.py (original)
+++ trunk/hamster/edit_activity.py Sun Feb 22 15:11:00 2009
@@ -26,9 +26,7 @@
import gobject
import re
-from hamster import dispatcher, storage, SHARED_DATA_DIR
-from hamster.stuff import *
-
+from hamster import dispatcher, storage, SHARED_DATA_DIR, stuff
import hamster.eds
import time
@@ -193,7 +191,7 @@
activity_cell = gtk.CellRendererText()
self.activity_list.pack_start(activity_cell, True)
self.activity_list.add_attribute(activity_cell, 'text', 0)
- category_cell = CategoryCell()
+ category_cell = stuff.CategoryCell()
self.activity_list.pack_start(category_cell, False)
self.activity_list.add_attribute(category_cell, 'text', 1)
@@ -212,7 +210,7 @@
completion.add_attribute(activity_cell, 'text', 0)
completion.set_property("text-column", 2)
- category_cell = CategoryCell()
+ category_cell = stuff.CategoryCell()
completion.pack_start(category_cell, False)
completion.add_attribute(category_cell, 'text', 1)
Modified: trunk/hamster/stuff.py
==============================================================================
--- trunk/hamster/stuff.py (original)
+++ trunk/hamster/stuff.py Sun Feb 22 15:11:00 2009
@@ -56,16 +56,30 @@
self.set_property('scale', pango.SCALE_SMALL)
self.set_property('yalign', 0.0)
-class ExpanderColumn(gtk.TreeViewColumn):
- def __init__(self, label, text):
- gtk.TreeViewColumn.__init__(self, label)
+
+
+class ActivityColumn(gtk.TreeViewColumn):
+ def activity_painter(self, column, cell, model, iter):
+ activity_name = model.get_value(iter, self.name)
+ description = model.get_value(iter, self.description)
+ text = activity_name
+
+ if description:
+ text+= """\n<span style="italic" size="small">%s</span>""" % (description)
+
+ cell.set_property('markup', text)
+
+ return
+
+ def __init__(self, name, description):
+ gtk.TreeViewColumn.__init__(self)
+ self.name, self.description = name, description
self.set_expand(True)
cell = gtk.CellRendererText()
- cell.set_property('ellipsize', ELLIPSIZE_END)
self.pack_start(cell, True)
- self.set_attributes(cell, text=text)
-
+ cell.set_property("ellipsize", pango.ELLIPSIZE_END)
+ self.set_cell_data_func(cell, self.activity_painter)
def format_duration(minutes):
if minutes == None:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]