deskbar-applet r2110 - in trunk: . deskbar/handlers



Author: sebp
Date: Sun Apr 13 13:15:14 2008
New Revision: 2110
URL: http://svn.gnome.org/viewvc/deskbar-applet?rev=2110&view=rev

Log:
Adjust priorities of matches that the results are displayed in the same order as provided by yahoo and not alphabetically.

Modified:
   trunk/ChangeLog
   trunk/deskbar/handlers/yahoo.py

Modified: trunk/deskbar/handlers/yahoo.py
==============================================================================
--- trunk/deskbar/handlers/yahoo.py	(original)
+++ trunk/deskbar/handlers/yahoo.py	Sun Apr 13 13:15:14 2008
@@ -112,15 +112,17 @@
             stream.close()
         
         LOGGER.debug('Got yahoo answer for: %s', qstring)
-            
-        for result in handler.get_results():
+         
+        num_results = len(handler.get_results())
+        for i, result in enumerate(handler.get_results()):
+            result_prio = self.get_priority() + num_results - i
             result_title = strip_html(result["title"])
             result_summary = result["summary"]
             if result_summary != None:
                 result_summary = strip_html(result_summary)
             matches.append(YahooMatch(name=result_title, url=result["clickurl"],
                                       summary=result_summary,
-                                      priority=self.get_priority()))
+                                      priority=result_prio))
             
         LOGGER.debug("Returning yahoo answer for: %s", qstring)
         self._emit_query_ready(qstring, matches)
@@ -273,8 +275,10 @@
         finally:
             stream.close()
             
-        for suggestion in handler.get_suggestions():
-            matches.append( YahooSearchForMatch(term=suggestion, priority=self.get_priority()) )
+        num_results = len(handler.get_suggestions())
+        for i, suggestion in enumerate(handler.get_suggestions()):
+            prio = self.get_priority() + num_results - i
+            matches.append( YahooSearchForMatch(term=suggestion, priority=prio) )
             
         self._emit_query_ready(qstring, matches)
         



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