[hamster-applet/gnome-2-26] fix utf-8 trouble in autocomplete and avoid None category. Fixes bug 583851



commit 5b3a839fffb89401b02dabc7ed1c7487051d3d6e
Author: Toms Bauģis <toms baugis gmail com>
Date:   Tue Jun 16 15:38:52 2009 +0100

    fix utf-8 trouble in autocomplete and avoid None category. Fixes bug 583851

 hamster/applet.py |   26 +++++++++++++-------------
 1 files changed, 13 insertions(+), 13 deletions(-)
---
diff --git a/hamster/applet.py b/hamster/applet.py
index 9ff2a73..8effd1d 100755
--- a/hamster/applet.py
+++ b/hamster/applet.py
@@ -346,6 +346,9 @@ class HamsterApplet(object):
         completion = gtk.EntryCompletion()
         completion.set_model(self.activities)
 
+        completion.set_text_column(2)
+        completion.clear()
+
         activity_cell = gtk.CellRendererText()
         completion.pack_start(activity_cell, True)
         completion.add_attribute(activity_cell, 'text', 0)
@@ -354,16 +357,6 @@ class HamsterApplet(object):
         category_cell = CategoryCell()  
         completion.pack_start(category_cell, False)
         completion.add_attribute(category_cell, 'text', 1)
-
-
-        def match_func(completion, key, iter):
-            model = completion.get_model()
-            text = model.get_value(iter, 2)
-            if text and text.startswith(key):
-                return True
-            return False
-
-        completion.set_match_func(match_func)
         completion.set_minimum_key_length(1)
         completion.set_inline_completion(True)
 
@@ -484,13 +477,16 @@ class HamsterApplet(object):
         #first populate the autocomplete - contains all entries in lowercase
         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])
 
-
         #now populate the menu - contains only categorized entries
         store = self.activity_list.get_model()
         store.clear()
@@ -499,11 +495,15 @@ class HamsterApplet(object):
         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])
 
+
         # finally add TODO tasks from evolution to both lists
         tasks = hamster.eds.get_eds_tasks()
         for activity in tasks:



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]