bigboard r7322 - trunk/bigboard/stocks/apps



Author: otaylor
Date: Tue Apr 29 22:19:04 2008
New Revision: 7322
URL: http://svn.gnome.org/viewvc/bigboard?rev=7322&view=rev

Log:
- For pinnedApplications use alphabetical sort rather than
  sort-by-global-application-usage
- For topApplications (user's most used applications) use
  order sent by server (which orders by usage by the user)
  rather than sort-by-global-application-usage


Modified:
   trunk/bigboard/stocks/apps/AppsStock.py

Modified: trunk/bigboard/stocks/apps/AppsStock.py
==============================================================================
--- trunk/bigboard/stocks/apps/AppsStock.py	(original)
+++ trunk/bigboard/stocks/apps/AppsStock.py	Tue Apr 29 22:19:04 2008
@@ -154,6 +154,9 @@
 
         return result
 
+    def __cmp_application_name(self, a, b):
+        return cmp(a.get_name(), b.get_name())
+
     def __cmp_application_usage(self, a, b):
         # note the "-" in front of the cmp to sort descending
         return - cmp(a.get_usage_count(), b.get_usage_count())
@@ -165,17 +168,22 @@
         apps_in_set = []
 
         if self.__repo.get_app_usage_enabled():
-            pinned_apps = self.__repo.get_pinned_apps()
-            pinned_apps.sort(self.__cmp_application_usage)
-
+            # Pinned apps are returned as an unordered set, we need
+            # to sort them ourselves.
+            pinned_apps = list(self.__repo.get_pinned_apps())
+            pinned_apps.sort(self.__cmp_application_name)
+
+            # Server returns a list sorted by the user's usage, keep that
+            # ordering unchanged. (Note that the user's usage is not the
+            # same as applicatin.get_usage_count() which is a global usage
+            # across the user's usage.)
             my_top_apps = self.__repo.get_my_top_apps()
-            my_top_apps.sort(self.__cmp_application_usage)
         else:
             pinned_apps = []
             my_top_apps = []
 
         global_top_apps = self.__repo.get_global_top_apps()
-        global_top_apps.sort(self.__cmp_application_usage)
+        global_top_apps.sort(self.__cmp_application_name)
 
         for app in (pinned_apps + my_top_apps + global_top_apps):
             if app not in apps_in_set:



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