hamster-applet r610 - trunk/hamster
- From: tbaugis svn gnome org
- To: svn-commits-list gnome org
- Subject: hamster-applet r610 - trunk/hamster
- Date: Sun, 26 Oct 2008 16:13:19 +0000 (UTC)
Author: tbaugis
Date: Sun Oct 26 16:13:19 2008
New Revision: 610
URL: http://svn.gnome.org/viewvc/hamster-applet?rev=610&view=rev
Log:
showing category in drop-down, will move out into separate widget
though. related to bug 529132
Modified:
trunk/hamster/add_custom_fact.py
trunk/hamster/applet.py
trunk/hamster/db.py
trunk/hamster/stuff.py
Modified: trunk/hamster/add_custom_fact.py
==============================================================================
--- trunk/hamster/add_custom_fact.py (original)
+++ trunk/hamster/add_custom_fact.py Sun Oct 26 16:13:19 2008
@@ -26,6 +26,8 @@
import gobject
from hamster import dispatcher, storage, SHARED_DATA_DIR
+from hamster.stuff import *
+
import hamster.eds
import time
@@ -36,20 +38,28 @@
class CustomFactController:
def __init__(self, fact_date = None, fact_id = None):
- self.wTree = gtk.glade.XML(os.path.join(SHARED_DATA_DIR, GLADE_FILE))
+ self.glade = gtk.glade.XML(os.path.join(SHARED_DATA_DIR, GLADE_FILE))
self.window = self.get_widget('custom_fact_window')
- # load window of activity switcher and todays view
- self.items = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_INT)
- self.activities = gtk.ListStore(gobject.TYPE_STRING)
- self.completion = gtk.EntryCompletion()
- self.completion.set_model(self.activities)
- self.completion.set_text_column(0)
- self.completion.set_minimum_key_length(1)
- activity_list = self.wTree.get_widget('activity-list')
- activity_list.set_model(self.items)
- activity_list.set_text_column(0)
- activity_list.child.set_completion(self.completion)
+ # set up drop down menu
+ self.activity_list = self.glade.get_widget('activity-list')
+ self.activity_list.set_model(gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_INT))
+ category_cell = CategoryCell()
+ self.activity_list.pack_start(category_cell, False)
+ self.activity_list.add_attribute(category_cell, 'text', 1)
+ self.activity_list.set_text_column(0)
+
+ # set up autocompletition
+ self.activities = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING)
+ completion = gtk.EntryCompletion()
+ completion.set_model(self.activities)
+ completion.set_text_column(0)
+ completion.set_minimum_key_length(1)
+ category_cell = CategoryCell()
+ completion.pack_start(category_cell, False)
+ completion.add_attribute(category_cell, 'text', 1)
+
+ self.activity_list.child.set_completion(completion)
self.hours = gtk.ListStore(gobject.TYPE_STRING)
@@ -96,13 +106,13 @@
self.get_widget('duration_mins').set_value(for_minutes)
- self.wTree.signal_autoconnect(self)
+ self.glade.signal_autoconnect(self)
def refresh_menu(self):
all_activities = storage.get_activities()
self.activities.clear()
for activity in all_activities:
- self.activities.append([activity['name']])
+ self.activities.append([activity['name'], activity['category']])
activity_list = self.get_widget('activity-list')
store = activity_list.get_model()
@@ -114,7 +124,7 @@
today = datetime.date.today()
for activity in activities:
- item = store.append([activity['name'], activity['id']])
+ item = store.append([activity['name'], activity['category'], activity['id']])
tasks = hamster.eds.get_eds_tasks()
for activity in tasks:
@@ -125,7 +135,7 @@
def get_widget(self, name):
""" skip one variable (huh) """
- return self.wTree.get_widget(name)
+ return self.glade.get_widget(name)
def show(self):
self.window.show()
Modified: trunk/hamster/applet.py
==============================================================================
--- trunk/hamster/applet.py (original)
+++ trunk/hamster/applet.py Sun Oct 26 16:13:19 2008
@@ -181,18 +181,27 @@
# load window of activity switcher and todays view
self.glade = gtk.glade.XML(os.path.join(SHARED_DATA_DIR, "menu.glade"))
self.window = self.glade.get_widget('hamster-window')
+
+
# set up drop down menu
self.activity_list = self.glade.get_widget('activity-list')
- self.activity_list.set_model(gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_INT))
+ self.activity_list.set_model(gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_INT))
+ category_cell = CategoryCell()
+ self.activity_list.pack_start(category_cell, False)
+ self.activity_list.add_attribute(category_cell, 'text', 1)
self.activity_list.set_text_column(0)
- # set up autocompletition for the drop-down menu
- self.activities = gtk.ListStore(gobject.TYPE_STRING)
+ # set up autocompletition
+ self.activities = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING)
completion = gtk.EntryCompletion()
completion.set_model(self.activities)
completion.set_text_column(0)
completion.set_minimum_key_length(1)
+ category_cell = CategoryCell()
+ completion.pack_start(category_cell, False)
+ completion.add_attribute(category_cell, 'text', 1)
+
self.activity_list.child.set_completion(completion)
# init today's tree
@@ -379,7 +388,7 @@
self.activities.clear()
all_activities = storage.get_activities()
for activity in all_activities:
- self.activities.append([activity['name']])
+ self.activities.append([activity['name'], activity['category']])
#now populate the menu - contains only categorized entries
@@ -390,7 +399,7 @@
categorized_activities = storage.get_sorted_activities()
for activity in categorized_activities:
- item = store.append([activity['name'], activity['id']])
+ item = store.append([activity['name'], activity['category'], activity['id']])
# finally add TODO tasks from evolution to both lists
tasks = hamster.eds.get_eds_tasks()
Modified: trunk/hamster/db.py
==============================================================================
--- trunk/hamster/db.py (original)
+++ trunk/hamster/db.py Sun Oct 26 16:13:19 2008
@@ -272,7 +272,7 @@
def __get_sorted_activities(self):
"""returns list of acitivities that have categories"""
query = """
- SELECT a.*, b.category_order
+ SELECT a.*, b.name as category, b.category_order
FROM activities a
LEFT JOIN categories b on coalesce(b.id, -1) = a.category_id
WHERE a.category_id > -1
@@ -287,26 +287,28 @@
otherwise - by activity_order"""
if category_id:
query = """
- SELECT *
- FROM activities
+ SELECT a.*, b.name as category
+ FROM activities a
+ LEFT JOIN categories b on coalesce(b.id, -1) = a.category_id
WHERE category_id = ?
AND deleted is null
"""
# unsorted entries we sort by name - others by ID
if category_id == -1:
- query += "ORDER BY lower(name)"
+ query += "ORDER BY lower(a.name)"
else:
- query += "ORDER BY activity_order"
+ query += "ORDER BY a.activity_order"
activities = self.fetchall(query, (category_id, ))
else:
query = """
- SELECT *
- FROM activities
+ SELECT a.*, b.name as category
+ FROM activities a
+ LEFT JOIN categories b on coalesce(b.id, -1) = a.category_id
WHERE deleted is null
- ORDER BY lower(name)
+ ORDER BY lower(a.name)
"""
activities = self.fetchall(query)
Modified: trunk/hamster/stuff.py
==============================================================================
--- trunk/hamster/stuff.py (original)
+++ trunk/hamster/stuff.py Sun Oct 26 16:13:19 2008
@@ -23,9 +23,21 @@
import gtk
from hamster import storage
+import pango
from pango import ELLIPSIZE_END
+
import datetime as dt
+class CategoryCell(gtk.CellRendererText):
+ def __init__(self):
+ gtk.CellRendererText.__init__(self)
+ self.set_property('alignment', pango.ALIGN_RIGHT)
+
+ insensitive_color = gtk.Label().style.fg[gtk.STATE_INSENSITIVE]
+ self.set_property('foreground-gdk', insensitive_color)
+ 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)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]