hamster-applet r818 - trunk/hamster
- From: tbaugis svn gnome org
- To: svn-commits-list gnome org
- Subject: hamster-applet r818 - trunk/hamster
- Date: Sat, 28 Feb 2009 18:37:37 +0000 (UTC)
Author: tbaugis
Date: Sat Feb 28 18:37:36 2009
New Revision: 818
URL: http://svn.gnome.org/viewvc/hamster-applet?rev=818&view=rev
Log:
sort out category in dropdown - handle unsorted and
none categories, show category in the text input
fixes bug 573351
Modified:
trunk/hamster/applet.py
trunk/hamster/db.py
trunk/hamster/edit_activity.py
trunk/hamster/stuff.py
Modified: trunk/hamster/applet.py
==============================================================================
--- trunk/hamster/applet.py (original)
+++ trunk/hamster/applet.py Sat Feb 28 18:37:36 2009
@@ -465,7 +465,10 @@
self.activities.clear()
all_activities = storage.get_autocomplete_activities()
for activity in all_activities:
- activity_category = "%s %s" % (activity['name'], activity['category'])
+ activity_category = activity['name']
+ if activity['category']:
+ activity_category += "@%s" % activity['category']
+
self.activities.append([activity['name'],
activity['category'],
activity_category])
@@ -479,7 +482,10 @@
categorized_activities = storage.get_sorted_activities()
for activity in categorized_activities:
- activity_category = "%s %s" % (activity['name'], activity['category'])
+ activity_category = activity['name']
+ if activity['category']:
+ activity_category += "@%s" % activity['category']
+
item = store.append([activity['name'],
activity['category'],
activity_category])
@@ -525,9 +531,6 @@
self.load_day() # reload day each time before showing to avoid outdated last activity
self.update_label() #update also label, otherwise we can get 1 minute difference in durations (due to timers refreshed once a minute)
- if self.last_activity: #reset value of current_activity input, maybe we have some leftovers there
- self.glade.get_widget('current_activity').set_text(self.last_activity['name'])
-
label_geom = self.button.get_allocation()
window_geom = self.window.get_allocation()
@@ -545,8 +548,13 @@
self.window.move(x, y)
+
if self.last_activity and self.last_activity["end_time"] == None:
- self.activity_list.child.set_text(self.last_activity["name"])
+ label = self.last_activity['name']
+ if self.last_activity['category'] != _("Unsorted"):
+ label += "@%s" % self.last_activity['category']
+ self.activity_list.child.set_text(label)
+
self.activity_list.child.select_region(0, -1)
else:
self.activity_list.child.set_text('')
Modified: trunk/hamster/db.py
==============================================================================
--- trunk/hamster/db.py (original)
+++ trunk/hamster/db.py Sat Feb 28 18:37:36 2009
@@ -178,12 +178,14 @@
a.start_time AS start_time,
a.end_time AS end_time,
a.description as description,
- b.name AS name, b.id as activity_id
+ b.name AS name, b.id as activity_id,
+ coalesce(c.name, ?) as category, coalesce(c.id, -1) as category_id
FROM facts a
LEFT JOIN activities b ON a.activity_id = b.id
+ LEFT JOIN categories c on b.category_id = c.id
WHERE a.id = ?
"""
- return self.fetchone(query, (id, ))
+ return self.fetchone(query, (_("Unsorted"), id))
def __get_last_activity(self):
query = """
Modified: trunk/hamster/edit_activity.py
==============================================================================
--- trunk/hamster/edit_activity.py (original)
+++ trunk/hamster/edit_activity.py Sat Feb 28 18:37:36 2009
@@ -365,8 +365,11 @@
start_date, end_date = None, None
if fact_id:
fact = storage.get_fact(fact_id)
- print fact
- self.get_widget('activity_text').set_text(fact["name"])
+
+ label = fact['name']
+ if fact['category'] != _("Unsorted"):
+ label += "@%s" % fact['category']
+ self.get_widget('activity_text').set_text(label)
start_date = fact["start_time"]
end_date = fact["end_time"]
@@ -555,7 +558,9 @@
self.activities.clear()
all_activities = storage.get_autocomplete_activities()
for activity in all_activities:
- activity_category = "%s %s" % (activity['name'], activity['category'])
+ activity_category = activity['name']
+ if activity['category']:
+ activity_category += "@%s" % activity['category']
self.activities.append([activity['name'],
activity['category'],
activity_category])
@@ -569,7 +574,9 @@
categorized_activities = storage.get_sorted_activities()
for activity in categorized_activities:
- activity_category = "%s %s" % (activity['name'], activity['category'])
+ activity_category = activity['name']
+ if activity['category']:
+ activity_category += "@%s" % activity['category']
item = store.append([activity['name'],
activity['category'],
activity_category])
Modified: trunk/hamster/stuff.py
==============================================================================
--- trunk/hamster/stuff.py (original)
+++ trunk/hamster/stuff.py Sat Feb 28 18:37:36 2009
@@ -64,7 +64,7 @@
def format_activity(name, category, description, pad_description = False):
"returns pango markup for activity with category and description"
text = name
- if category:
+ if category and category != _("Unsorted"):
text += """ - <span color="%s" size="x-small">%s</span>""" % (insensitive_color, category)
if description:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]