Merge branch 'master' of deluge-torrent.org:deluge

This commit is contained in:
Damien Churchill 2011-04-21 10:41:15 +01:00
commit 387b746fae
2 changed files with 24 additions and 0 deletions

View File

@ -607,3 +607,21 @@ class ListView:
def on_keypress_search_by_name(self, model, columnn, key, iter):
TORRENT_NAME_COL = 5
return not model[iter][TORRENT_NAME_COL].lower().startswith(key.lower())
def restore_columns_order_from_state(self):
columns = self.treeview.get_columns()
def find_column(header):
for column in columns:
if column.get_title() == header:
return column
for col_state in self.state:
column_at_position = columns[col_state.position]
if col_state.name == column_at_position.get_title():
# It's in the right position
continue
column = find_column(col_state.name)
self.treeview.move_column_after(column, column_at_position)
# Get columns again to keep reordering since positions have changed
columns = self.treeview.get_columns()
self.create_new_liststore()

View File

@ -245,6 +245,7 @@ class TorrentView(listview.ListView, component.Component):
self.add_text_column(_("Save Path"), status_field=["save_path"])
self.add_text_column(_("Owner"), status_field=["owner"])
self.add_bool_column(_("Public"), status_field=["public"])
self.restore_columns_order_from_state()
# Set filter to None for now
self.filter = None
@ -264,6 +265,7 @@ class TorrentView(listview.ListView, component.Component):
self.treeview.connect("drag-drop", self.on_drag_drop)
self.treeview.connect("key-press-event", self.on_key_press_event)
self.treeview.connect("columns-changed", self.on_columns_changed_event)
client.register_event_handler("TorrentStateChangedEvent", self.on_torrentstatechanged_event)
client.register_event_handler("TorrentAddedEvent", self.on_torrentadded_event)
@ -521,6 +523,10 @@ class TorrentView(listview.ListView, component.Component):
def on_drag_drop(self, widget, drag_context, x, y, timestamp):
widget.stop_emission("drag-drop")
def on_columns_changed_event(self, treeview):
log.debug("Treeview Columns Changed")
self.save_state()
def on_torrentadded_event(self, torrent_id, from_state):
self.add_row(torrent_id)
self.mark_dirty(torrent_id)