From 58c5a4d007acc23f62f9636c45e1b63af3c487f9 Mon Sep 17 00:00:00 2001
Message-Id: <58c5a4d007acc23f62f9636c45e1b63af3c487f9.1278054601.git.andresambrois@gmail.com>
In-Reply-To: <cover.1278054601.git.andresambrois@gmail.com>
References: <cover.1278054601.git.andresambrois@gmail.com>
From: =?UTF-8?q?Andr=C3=A9s=20Ambrois?= <andresambrois@gmail.com>
Date: Sun, 23 May 2010 04:07:20 -0300
Subject: [PATCH v2 06/10] Display the sorting property in the last column.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

update_with_query() is called when the query is modified in the toolbox.
Get the name of the property and set the sort_column cell renderer accordingly.

Signed-off-by: Andrés Ambrois <andresambrois@gmail.com>
---
 src/jarabe/journal/listview.py |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/src/jarabe/journal/listview.py b/src/jarabe/journal/listview.py
index 375a8ee..deffe84 100644
--- a/src/jarabe/journal/listview.py
+++ b/src/jarabe/journal/listview.py
@@ -252,11 +252,16 @@ class BaseListView(gtk.Bin):
 
     def update_with_query(self, query_dict):
         logging.debug('ListView.update_with_query')
+        if 'order_by' not in query_dict:
+            query_dict['order_by'] = ['+timestamp']
+        if query_dict['order_by'] != self._query.get('order_by'):
+            property = query_dict['order_by'][0][1:]
+            cell_text = self.sort_column.get_cell_renderers()[0]
+            self.sort_column.set_attributes(cell_text,
+                text=getattr(ListModel, 'COLUMN_' + property.upper(),
+                             ListModel.COLUMN_TIMESTAMP))
         self._query = query_dict
 
-        if 'order_by' not in self._query:
-            self._query['order_by'] = ['+timestamp']
-
         self.refresh()
 
     def refresh(self):
-- 
1.7.0.4

