[gnome-games/sudoku-tube] Sort contacts in contact selector



commit adc87cfef6a17ee34126c3341ae168735587fa02
Author: Zhang Sen <zh jesse gmail com>
Date:   Mon Aug 17 10:10:00 2009 +0800

    Sort contacts in contact selector

 gnome-sudoku/src/lib/contact_selector.py |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)
---
diff --git a/gnome-sudoku/src/lib/contact_selector.py b/gnome-sudoku/src/lib/contact_selector.py
index 0c83a44..6e2c01d 100644
--- a/gnome-sudoku/src/lib/contact_selector.py
+++ b/gnome-sudoku/src/lib/contact_selector.py
@@ -225,6 +225,8 @@ class ContactSelector(gtk.ComboBox):
 
     def __init__(self):
         list_store = ContactListStore()
+        list_store.set_sort_func(1, self._sort_contacts)
+        list_store.set_sort_column_id(1, gtk.SORT_ASCENDING)
         online_model_filter = list_store.filter_new()
         online_model_filter.set_visible_func(self._filter_online_contacts)
 
@@ -243,6 +245,14 @@ class ContactSelector(gtk.ComboBox):
         else:
             return False
 
+    def _sort_contacts(self, model, iter1, iter2):
+        contact1 = self._get_contact(model, iter1)
+        contact2 = self._get_contact(model, iter2)
+        if contact1 is not None and contact2 is not None:
+            return ((contact1.presence[0], contact1.alias) >
+                    (contact2.presence[0], contact2.alias))
+        return 0
+
     def _setup_view(self):
         """Setup the CellRenderers to display
 



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