[hamster-applet] size matters trophy



commit 85f542df274db2c5ff796f511b71ed04142500fd
Author: Toms Bauģis <toms baugis gmail com>
Date:   Fri Aug 20 10:33:56 2010 +0100

    size matters trophy

 src/hamster/preferences.py |   27 +++++++++++++++++----------
 1 files changed, 17 insertions(+), 10 deletions(-)
---
diff --git a/src/hamster/preferences.py b/src/hamster/preferences.py
index c1a3612..9a80587 100755
--- a/src/hamster/preferences.py
+++ b/src/hamster/preferences.py
@@ -85,7 +85,7 @@ appearances = ["text", "icon", "both"]
 
 from configuration import runtime, conf
 import widgets
-import storage, stuff
+import storage, stuff, trophies
 
 class PreferencesEditor:
     TARGETS = [
@@ -410,21 +410,28 @@ class PreferencesEditor:
         id = model[path][0]
         category_id = model[path][2]
 
-
-        # avoid two activities in same category with same name
         activities = runtime.storage.get_category_activities(category_id)
+        prev = None
         for activity in activities:
-            if id != activity['id'] and activity['name'].lower() == new_text.lower():
-                if id == -1: # that was a new activity
-                    self.activity_store.remove(model.get_iter(path))
-                self.select_activity(activity['id'])
-                return False
-
+            if id == activity['id']:
+                prev = activity['name']
+            else:
+                # avoid two activities in same category with same name
+                if activity['name'].lower() == new_text.lower():
+                    if id == -1: # that was a new activity
+                        self.activity_store.remove(model.get_iter(path))
+                    self.select_activity(activity['id'])
+                    return False
 
         if id == -1: #new activity -> add
             model[path][0] = runtime.storage.add_activity(new_text.decode("utf-8"), category_id)
         else: #existing activity -> update
-            runtime.storage.update_activity(id, new_text.decode("utf-8"), category_id)
+            new = new_text.decode("utf-8")
+            runtime.storage.update_activity(id, new, category_id)
+            # size matters - when editing activity name just changed the case (bar -> Bar)
+            if prev != new and prev.lower() == new.lower():
+                trophies.unlock("size_matters")
+
         model[path][1] = new_text
         return True
 



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