Hopefully, final fix for #1786:

We now make sure that a state file exists when trying to restore an order from it.
The best effort to restore the previous order is made, though, in some cases, since we're matching against names which are translatable, a match might not be found, in that case, continue the effort though skip the non matching column name. On next load, everything should be fine since the state file will include the, now in use, translation.
This commit is contained in:
Pedro Algarvio 2011-04-21 20:55:01 +01:00
commit 49d5ed6bde

View file

@ -609,6 +609,9 @@ class ListView:
return not model[iter][TORRENT_NAME_COL].lower().startswith(key.lower()) return not model[iter][TORRENT_NAME_COL].lower().startswith(key.lower())
def restore_columns_order_from_state(self): def restore_columns_order_from_state(self):
if self.state is None:
# No state file exists, so, no reordering can be done
return
columns = self.treeview.get_columns() columns = self.treeview.get_columns()
def find_column(header): def find_column(header):
for column in columns: for column in columns:
@ -629,6 +632,14 @@ class ListView:
# It's in the right position # It's in the right position
continue continue
column = find_column(col_state.name) column = find_column(col_state.name)
if not column:
log.debug("Could not find column matching \"%s\" on state." %
col_state.name)
# The cases where I've found that the column could not be found
# is when not using the english locale, ie, the default one, or
# when changing locales between runs.
# On the next load, all should be fine
continue
self.treeview.move_column_after(column, column_at_position) self.treeview.move_column_after(column, column_at_position)
# Get columns again to keep reordering since positions have changed # Get columns again to keep reordering since positions have changed
columns = self.treeview.get_columns() columns = self.treeview.get_columns()