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.
This commit is contained in:
parent
79c9dd3076
commit
b3865d0a7f
|
@ -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")
|
||||
|
|
Loading…
Reference in New Issue