From b3865d0a7f06d14d75dce978ac36049755c780b5 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Sun, 22 May 2011 21:56:16 +0100 Subject: [PATCH] Fix GTK UI edit trackers dialog. Fix an issue with the edit trackers dialog where editing, adding or removing trackers was not "saved" in client/daemon mode. --- deluge/ui/gtkui/edittrackersdialog.py | 46 ++++++++++++--------------- 1 file changed, 21 insertions(+), 25 deletions(-) diff --git a/deluge/ui/gtkui/edittrackersdialog.py b/deluge/ui/gtkui/edittrackersdialog.py index ba39dcbb3..0571a6c64 100644 --- a/deluge/ui/gtkui/edittrackersdialog.py +++ b/deluge/ui/gtkui/edittrackersdialog.py @@ -74,8 +74,6 @@ class EditTrackersDialog: "on_button_edit_ok_clicked": self.on_button_edit_ok_clicked, "on_button_remove_clicked": self.on_button_remove_clicked, "on_button_down_clicked": self.on_button_down_clicked, - "on_button_ok_clicked": self.on_button_ok_clicked, - "on_button_cancel_clicked": self.on_button_cancel_clicked, "on_button_add_ok_clicked": self.on_button_add_ok_clicked, "on_button_add_cancel_clicked": self.on_button_add_cancel_clicked }) @@ -103,7 +101,9 @@ class EditTrackersDialog: # Get the trackers for this torrent session = component.get("SessionProxy") - session.get_torrent_status(self.torrent_id, ["trackers"]).addCallback(self._on_get_torrent_status) + session.get_torrent_status( + self.torrent_id, ["trackers"] + ).addCallback(self._on_get_torrent_status) client.force_call() self.deferred = defer.Deferred() @@ -115,14 +115,29 @@ class EditTrackersDialog: self.dialog.destroy() def _on_response(self, widget, response): - self.deferred.callback(response) + if response == 1: + self.trackers = [] + def each(model, path, iter, data): + tracker = {} + tracker["tier"] = model.get_value(iter, 0) + tracker["url"] = model.get_value(iter, 1) + self.trackers.append(tracker) + self.liststore.foreach(each, None) + if self.old_trackers != self.trackers: + # Set the torrens trackers + client.core.set_torrent_trackers(self.torrent_id, self.trackers) + self.deferred.callback(gtk.RESPONSE_OK) + else: + self.deferred.callback(gtk.RESPONSE_CANCEL) + else: + self.deferred.callback(gtk.RESPONSE_CANCEL) self.dialog.destroy() def _on_get_torrent_status(self, status): """Display trackers dialog""" - for tracker in status["trackers"]: + self.old_trackers = list(status["trackers"]) + for tracker in self.old_trackers: self.add_tracker(tracker["tier"], tracker["url"]) - self.dialog.show() def add_tracker(self, tier, url): @@ -194,25 +209,6 @@ class EditTrackersDialog: self.liststore.set_value(selected, 0, new_tier) self.changed = True - def on_button_ok_clicked(self, widget): - log.debug("on_button_ok_clicked") - self.trackers = [] - def each(model, path, iter, data): - tracker = {} - tracker["tier"] = model.get_value(iter, 0) - tracker["url"] = model.get_value(iter, 1) - self.trackers.append(tracker) - self.liststore.foreach(each, None) - # Set the torrens trackers - client.core.set_torrent_trackers(self.torrent_id, self.trackers) - if self.changed: - self.dialog.response(gtk.RESPONSE_OK) - else: - self.dialog.response(gtk.RESPONSE_CANCEL) - - def on_button_cancel_clicked(self, widget): - log.debug("on_button_cancel_clicked") - self.dialog.response(gtk.RESPONSE_CANCEL) def on_button_add_ok_clicked(self, widget): log.debug("on_button_add_ok_clicked")