Browse Source

Sorting seems to work

master
Julio Biason 16 years ago
parent
commit
9aa415d1d4
  1. 41
      mitterlib/ui/ui_pygtk.py

41
mitterlib/ui/ui_pygtk.py

@ -279,11 +279,10 @@ class Interface(object):
def _create_grid(self): def _create_grid(self):
"""Add the displaying grid.""" """Add the displaying grid."""
# Store NetworkData objects only
grid_store = gtk.ListStore(object) grid_store = gtk.ListStore(object)
# Trying to store the NetworkData object only grid_store.set_sort_column_id(0, gtk.SORT_DESCENDING)
grid_store.set_default_sort_func(self._order_datetime)
# self.grid_store.set_sort_func(0, self._sort_by_time)
# self.grid_store.set_sort_column_id(0, gtk.SORT_DESCENDING)
self._grid = gtk.TreeView(grid_store) self._grid = gtk.TreeView(grid_store)
self._grid.set_property('headers-visible', False) self._grid.set_property('headers-visible', False)
@ -583,6 +582,23 @@ class Interface(object):
return return
def _order_datetime(self, model, iter1, iter2, user_data=None):
"""Used by the ListStore to sort the columns (in our case, "column")
by date."""
message1 = model.get_value(iter1, 0)
message2 = model.get_value(iter2, 0)
if (not message1) or \
(not message1.message_time) or \
(message1.message_time > message2.message_time):
return 1
if (not message2) or \
(not message2.message_time) or \
(message2.message_time > message1.message_time):
return -1
return 0
# ------------------------------------------------------------ # ------------------------------------------------------------
# Network related functions # Network related functions
# ------------------------------------------------------------ # ------------------------------------------------------------
@ -596,6 +612,7 @@ class Interface(object):
for message in results: for message in results:
_log.debug('Data: %s', str(message)) _log.debug('Data: %s', str(message))
store.prepend([message]) store.prepend([message])
store.sort_column_changed()
return return
def _exception_get_messages(self, widget, exception): def _exception_get_messages(self, widget, exception):
@ -631,22 +648,6 @@ class Interface(object):
self._default_pixmap = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, self._default_pixmap = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB,
has_alpha=False, bits_per_sample=8, width=48, height=48) has_alpha=False, bits_per_sample=8, width=48, height=48)
#self._systray_setup()
# self.create_settings_dialog()
# self.username_field.set_text(default_username)
# self.password_field.set_text(default_password)
# self.https_field.set_active(self.https)
# notification helper
# self.notify_broadcast = Notify('mitter').notify
# start auto refresh activity
# self._refresh_id = None
# self.set_auto_refresh()
# self.window.set_focus(self.update_text)
return return
def __call__(self): def __call__(self):

Loading…
Cancel
Save