From cb50fb5eb3e7d80233851add58375346b5c47026 Mon Sep 17 00:00:00 2001 From: Andrew Resch Date: Tue, 26 Aug 2008 23:00:12 +0000 Subject: [PATCH] Fix setting file priorities on folders --- deluge/ui/gtkui/files_tab.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/deluge/ui/gtkui/files_tab.py b/deluge/ui/gtkui/files_tab.py index f53242013..8a3bb99dd 100644 --- a/deluge/ui/gtkui/files_tab.py +++ b/deluge/ui/gtkui/files_tab.py @@ -343,11 +343,22 @@ class FilesTab(Tab): def get_selected_files(self): """Returns a list of file indexes that are selected""" + def get_iter_children(itr, selected): + i = self.treestore.iter_children(itr) + while i: + selected.append(self.treestore[i][5]) + if self.treestore.iter_has_child(i): + get_selected_files(i, selected) + i = self.treestore.iter_next(i) + selected = [] paths = self.listview.get_selection().get_selected_rows()[1] for path in paths: - selected.append(self.treestore.get_value(self.treestore.get_iter(path), 5)) - + i = self.treestore.get_iter(path) + selected.append(self.treestore[i][5]) + if self.treestore.iter_has_child(i): + get_iter_children(i, selected) + return selected def _on_get_torrent_files(self, status): @@ -405,7 +416,7 @@ class FilesTab(Tab): file_priorities = [] def set_file_priority(model, path, iter, data): index = model.get_value(iter, 5) - if index in selected: + if index in selected and index != -1: file_priorities.append((index, priority)) elif index != -1: file_priorities.append((index, model.get_value(iter, 4)))