save/load toggled files state
This commit is contained in:
parent
7f00fa4599
commit
1e35cca89f
|
@ -297,9 +297,15 @@ class DelugeGTK:
|
||||||
# Now for the File tab
|
# Now for the File tab
|
||||||
self.file_store.clear()
|
self.file_store.clear()
|
||||||
all_files = self.manager.get_torrent_file_info(unique_id)
|
all_files = self.manager.get_torrent_file_info(unique_id)
|
||||||
|
file_filter = self.manager.get_file_filter(unique_id)
|
||||||
|
if file_filter is None:
|
||||||
|
file_filter = [True] * len(all_files)
|
||||||
|
assert(len(all_files) == len(file_filter))
|
||||||
|
i=0
|
||||||
for f in all_files:
|
for f in all_files:
|
||||||
self.file_store.append([f['path'], dcommon.fsize(f['size']),
|
self.file_store.append([file_filter[i], f['path'], dcommon.fsize(f['size']),
|
||||||
f['offset'], '%.2f%%'%f['progress'], True])
|
f['offset'], '%.2f%%'%f['progress']])
|
||||||
|
i=i+1
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@ -341,26 +347,26 @@ class DelugeGTK:
|
||||||
|
|
||||||
def build_file_tab(self):
|
def build_file_tab(self):
|
||||||
self.file_view = self.wtree.get_widget("file_view")
|
self.file_view = self.wtree.get_widget("file_view")
|
||||||
self.file_store = gtk.ListStore(str, str, str, str, bool)
|
self.file_store = gtk.ListStore(bool, str, str, str, str)
|
||||||
self.file_view.set_model(self.file_store)
|
self.file_view.set_model(self.file_store)
|
||||||
|
|
||||||
filename_col = dgtk.add_text_column(self.file_view, _("Filename"), 0)
|
dgtk.add_toggle_column(self.file_view, _("Download"), 0, toggled_signal=self.file_toggled)
|
||||||
dgtk.add_text_column(self.file_view, _("Size"), 1)
|
dgtk.add_text_column(self.file_view, _("Filename"), 1).set_expand(True)
|
||||||
dgtk.add_text_column(self.file_view, _("Offset"), 2)
|
dgtk.add_text_column(self.file_view, _("Size"), 2)
|
||||||
dgtk.add_text_column(self.file_view, _("Progress"), 3)
|
dgtk.add_text_column(self.file_view, _("Offset"), 3)
|
||||||
dgtk.add_toggle_column(self.file_view, _("Download"), 4)
|
dgtk.add_text_column(self.file_view, _("Progress"), 4)
|
||||||
|
|
||||||
filename_col.set_expand(True)
|
|
||||||
|
|
||||||
def file_toggled(self, renderer, path):
|
def file_toggled(self, renderer, path):
|
||||||
file_iter = self.file_store.get_iter_from_string(path)
|
file_iter = self.file_store.get_iter_from_string(path)
|
||||||
value = not renderer.get_active()
|
value = not renderer.get_active()
|
||||||
self.file_store.set_value(file_iter, 4, value)
|
self.file_store.set_value(file_iter, 0, value)
|
||||||
file_filter = []
|
file_filter = []
|
||||||
itr = self.file_store.get_iter_first()
|
itr = self.file_store.get_iter_first()
|
||||||
while itr is not None:
|
while itr is not None:
|
||||||
file_filter.append(self.file_store.get_value(itr, 4))
|
file_filter.append(self.file_store.get_value(itr, 0))
|
||||||
itr = self.file_store.iter_next(itr)
|
itr = self.file_store.iter_next(itr)
|
||||||
|
print file_filter
|
||||||
self.manager.set_file_filter(self.get_selected_torrent(), file_filter)
|
self.manager.set_file_filter(self.get_selected_torrent(), file_filter)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue