desiredratio persistence

This commit is contained in:
Marcos Pinto 2007-08-29 00:53:00 +00:00
parent 42d36e54de
commit e274a60373
2 changed files with 14 additions and 0 deletions

View File

@ -54,6 +54,18 @@ class DesiredRatio:
self.callback_ids.append(self.interface.torrent_menu.connect_after("realize", self.torrent_menu_show)) self.callback_ids.append(self.interface.torrent_menu.connect_after("realize", self.torrent_menu_show))
self.callback_ids.append(self.interface.torrent_menu.connect("show", self.torrent_menu_show)) self.callback_ids.append(self.interface.torrent_menu.connect("show", self.torrent_menu_show))
self.callback_ids.append(self.interface.torrent_menu.connect("hide", self.torrent_menu_hide)) self.callback_ids.append(self.interface.torrent_menu.connect("hide", self.torrent_menu_hide))
for torrent in self.core.get_queue():
unique_ID = self.core.get_torrent_unique_id(torrent)
try:
if self.core.unique_IDs[unique_ID].desired_ratio != 1.0:
value = float(self.core.unique_IDs[unique_ID].desired_ratio)
self.core.set_ratio(unique_ID, value)
self.set_ratios[unique_ID] = value
if value not in self.config.get("ratios") and value >= 1:
self.config.get("ratios").insert(0, value)
self.config.get("ratios").pop()
except AttributeError:
pass
def torrent_menu_show(self, widget, data=None): def torrent_menu_show(self, widget, data=None):
# Get the selected torrent # Get the selected torrent
@ -123,6 +135,7 @@ class DesiredRatio:
# Set the ratio in the core and remember the setting # Set the ratio in the core and remember the setting
self.core.set_ratio(self.unique_ID, value) self.core.set_ratio(self.unique_ID, value)
self.set_ratios[self.unique_ID] = value self.set_ratios[self.unique_ID] = value
self.core.unique_IDs[self.unique_ID].desired_ratio = value
# Update the ratios list if necessary # Update the ratios list if necessary
if value not in self.config.get("ratios") and value >= 1: if value not in self.config.get("ratios") and value >= 1:

View File

@ -164,6 +164,7 @@ class torrent_info:
self.upload_rate_limit = 0 self.upload_rate_limit = 0
self.download_rate_limit = 0 self.download_rate_limit = 0
self.webseed_urls = [] self.webseed_urls = []
self.desired_ratio = 1.0
self.delete_me = False # set this to true, to delete it on next sync self.delete_me = False # set this to true, to delete it on next sync