- if selectedUnitColumn == 0:
- if not self._unit_sort_direction:
- sorted_list.sort(lambda (x, xx, xxx), (y, yy, yyy): cmp(string.lower(x), string.lower(y)))
- self._unit_sort_direction = True
- else:
- sorted_list.sort(lambda (x, xx, xxx), (y, yy, yyy): cmp(string.lower(y), string.lower(x)))
- self._unit_sort_direction = False
- elif selectedUnitColumn == 1:
- sorted_list.sort()
- if not self._value_sort_direction:
- self._value_sort_direction = True
- else:
- sorted_list.reverse()
- self._value_sort_direction = False
- else:
- if not self._units_sort_direction:
- sorted_list.sort(lambda (x, xx, xxx), (y, yy, yyy): cmp(string.lower(x), string.lower(y)))
- self._units_sort_direction = True
- else:
- sorted_list.sort(lambda (x, xx, xxx), (y, yy, yyy): cmp(string.lower(y), string.lower(x)))
- self._units_sort_direction = False
-
- #Clear out the previous list of units
- self._unitModel = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING)
- self._unitsView.set_model(self._unitModel)
-
- #colourize each row differently for easier reading
- self._unitsView.set_property('rules_hint', 1)
-
- #Clear out the description
- text_model = gtk.TextBuffer(None)
- self._unitDescription.set_buffer(text_model)
-
- if selectedUnitColumn == 0:
- for unit, value, units in sorted_list:
- iter = self._unitModel.append()
- self._unitModel.set(iter, 0, unit, 1, str(value), 2, units)
- elif selectedUnitColumn == 1:
- for value, unit, units in sorted_list:
- iter = self._unitModel.append()
- self._unitModel.set(iter, 0, unit, 1, str(value), 2, units)
- else:
- for units, value, unit in sorted_list:
- iter = self._unitModel.append()
- self._unitModel.set(iter, 0, unit, 1, str(value), 2, units)
- return
-
- def _on_click_category(self, row):
- #Clear out the previous list of units
- self._unitModel = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING)
- self._unitsView.set_model(self._unitModel)
-
- #Colourize each row alternately for easier reading
- self._unitsView.set_property('rules_hint', 1)
-
- #Clear out the description
- text_model = gtk.TextBuffer(None)
- self._unitDescription.set_buffer(text_model)
-
- #Determine the contents of the selected category row
- selected, iter = row.get_selection().get_selected()
-
- self._selected_category = self._categoryModel.get_value(iter, 0)