def int_sort_func(model, iter1, iter2, column): try: val1 = int(model.get_value(iter1, column)) except Exception: val1 = 0 try: val2 = int(model.get_value(iter2, column)) except Exception: val2 = 0 return cmp(val1, val2)
def float_sort_func(model, iter1, iter2, column): try: val1 = float(model.get_value(iter1, column)) except Exception: val1 = 0.0 try: val2 = float(model.get_value(iter2, column)) except Exception: val2 = 0.0 return cmp(val1, val2)
def progress_sort_func(self, model, iter1, iter2, column): # We want 0% to be always below anything else, # so we have to look up whether we are ascending or descending ascending = True if model.get_sort_column_id()[1] == gtk.SortType.DESCENDING: ascending = False val1 = self.get_status_index(model.get_value(iter1, column)) val2 = self.get_status_index(model.get_value(iter2, column)) if val1 == 0 and val2 == 0: return 0 if val1 == 0: return -1 + (ascending * 2) if val2 == 0: return 1 - (ascending * 2) return cmp(val1, val2)
def status_sort_func(self, model, iter1, iter2, column): val1 = self.get_status_index(model.get_value(iter1, column)) val2 = self.get_status_index(model.get_value(iter2, column)) return cmp(val1, val2)