From b4f266457f0bc81e154b61c5518954c2bc26d793 Mon Sep 17 00:00:00 2001 From: Calum Lind Date: Fri, 17 May 2013 17:01:48 +0100 Subject: [PATCH] GTKUI: Remove add_row and use add_rows instead --- deluge/ui/gtkui/torrentview.py | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/deluge/ui/gtkui/torrentview.py b/deluge/ui/gtkui/torrentview.py index c1a6ae4b0..d5064d880 100644 --- a/deluge/ui/gtkui/torrentview.py +++ b/deluge/ui/gtkui/torrentview.py @@ -608,30 +608,16 @@ class TorrentView(listview.ListView, component.Component): return gobject.idle_add(self.update_view) - def add_rows(self, state): - """Adds all the torrents from state to self.liststore""" + def add_rows(self, torrent_ids): + """Accepts a list of torrent_ids to add to self.liststore""" torrent_id_column = self.columns["torrent_id"].column_indices[0] dirty_column = self.columns["dirty"].column_indices[0] filter_column = self.columns["filter"].column_indices[0] - for i, torrent_id in enumerate(state): + for torrent_id in torrent_ids: # Insert a new row to the liststore row = self.liststore.append() self.liststore.set(row, torrent_id_column, torrent_id, dirty_column, True, filter_column, True) - def add_row(self, torrent_id, update=True): - """Adds a new torrent row to the treeview""" - # Make sure this torrent isn't already in the list - for row in self.liststore: - if row[self.columns["torrent_id"].column_indices[0]] == torrent_id: - # Row already in the list - return - # Insert a new row to the liststore - row = self.liststore.append() - # Store the torrent id - self.liststore.set_value(row, self.columns["torrent_id"].column_indices[0], torrent_id) - if update: - self.update() - def remove_row(self, torrent_id): """Removes a row with torrent_id""" for row in self.liststore: @@ -739,8 +725,8 @@ class TorrentView(listview.ListView, component.Component): def on_torrentadded_event(self, torrent_id, from_state): if not from_state: - self.add_row(torrent_id) - self.mark_dirty(torrent_id) + self.add_rows([torrent_id]) + self.update() def on_torrentremoved_event(self, torrent_id): self.remove_row(torrent_id)