From 8f5e46a4eaa6f4522237c5df1ee9955ff81c2a79 Mon Sep 17 00:00:00 2001 From: Martijn Voncken Date: Sun, 3 Aug 2008 20:05:57 +0000 Subject: [PATCH] more label options --- deluge/plugins/label/label/core.py | 30 ++- .../label/label/data/label_options.glade | 205 ++++++++++++++---- deluge/plugins/label/label/gtkui/sidebar.py | 19 +- 3 files changed, 194 insertions(+), 60 deletions(-) diff --git a/deluge/plugins/label/label/core.py b/deluge/plugins/label/label/core.py index 27d1b8ac7..aed97c7fe 100644 --- a/deluge/plugins/label/label/core.py +++ b/deluge/plugins/label/label/core.py @@ -65,7 +65,8 @@ OPTIONS_DEFAULTS = { "max_upload_slots":-1, "prioritize_first_last":False, "apply_max":False, - "move_completed_to":"", + "move_completed":False, + "move_completed_path":"", "apply_queue":False, "is_auto_managed":False, "stop_at_ratio":False, @@ -183,7 +184,7 @@ class Core(CorePluginBase): if self.config["hide_zero_hits"]: for state in set(KNOWN_STATES): - log.debug(states.keys()) + #log.debug(states.keys()) if states[state] == 0 : #del states[state] state_order.remove(state) @@ -214,10 +215,13 @@ class Core(CorePluginBase): else: no_label +=1 + #show all labels,even if hide-zero-hits is true + """ if self.config["hide_zero_hits"]: for label , count in list(labels.iteritems()): if count == 0: del labels[label] + """ return [(NO_LABEL, no_label)] + [(label_id, labels[label_id]) for label_id in sorted(labels.keys())] @@ -272,7 +276,7 @@ class Core(CorePluginBase): CheckInput(label_id, _("Empty Label")) CheckInput(not (label_id in self.labels) , _("Label already exists")) - self.labels[label_id] = OPTIONS_DEFAULTS + self.labels[label_id] = dict(OPTIONS_DEFAULTS) log.debug("this is the file!") def export_remove(self, label_id): @@ -286,12 +290,22 @@ class Core(CorePluginBase): options = self.labels[label_id] torrent = self.torrents[torrent_id] - torrent.set_max_download_speed(options["max_download_speed"]) - torrent.set_max_upload_speed(options["max_upload_speed"]) - torrent.set_max_connections(options["max_connections"]) - torrent.set_max_upload_slots(options["max_upload_slots"]) - torrent.set_prioritize_first_last(options["prioritize_first_last"]) + if options["apply_max"]: + torrent.set_max_download_speed(options["max_download_speed"]) + torrent.set_max_upload_speed(options["max_upload_speed"]) + torrent.set_max_connections(options["max_connections"]) + torrent.set_max_upload_slots(options["max_upload_slots"]) + torrent.set_prioritize_first_last(options["prioritize_first_last"]) + if options["apply_queue"]: + torrent.set_auto_managed(options['is_auto_managed']) + torrent.set_stop_at_ratio(options['stop_at_ratio']) + torrent.set_stop_ratio(options['stop_ratio']) + torrent.set_remove_at_ratio(options['remove_at_ratio']) + + if options["move_completed"]: + #todo... + pass def export_set_options(self, label_id, options_dict , apply = False): """update the label options diff --git a/deluge/plugins/label/label/data/label_options.glade b/deluge/plugins/label/label/data/label_options.glade index 592fba759..63d3ead7e 100644 --- a/deluge/plugins/label/label/data/label_options.glade +++ b/deluge/plugins/label/label/data/label_options.glade @@ -1,6 +1,6 @@ - + 5 @@ -48,13 +48,20 @@ - + + 30 + True + + + 1 + 2 + True True - Apply max settings: + Apply per torrent max settings: 0 True @@ -267,17 +274,30 @@ + + + True - warning : not effective yet - 3 + 1 + 2 6 7 + + + 30 + True + + + 1 + 2 + + True @@ -295,6 +315,7 @@ True True 2 1 100 1 10 10 + 2 2 @@ -387,23 +408,99 @@ - + True + 7 + 2 - + + + + + + + + + + + + + + 30 + True + + + 1 + 2 + + + + + + + True + + + 1 + 2 + 5 + 6 + + + + + True + + + 1 + 2 + 4 + 5 + + + + + True + + + 1 + 2 + 3 + 4 + + + + + True + + + 1 + 2 + 2 + 3 + + + + + True + + + 1 + 2 + 1 + 2 + + + + True True Move completed to: 0 True - - - - True - - 1 + 2 @@ -412,31 +509,9 @@ warning : not effective yet - 2 - - - - - True - - - 3 - - - - - True - - - 4 - - - - - True - - - 5 + 2 + 6 + 7 @@ -445,7 +520,7 @@ - + True Location @@ -455,6 +530,58 @@ False + + + True + + + True + Automatically apply label: + + + False + + + + + True + True + tracker1.org +tracker2.com +this doesn't do anything yet, be patient. + + + + 1 + + + + + True + <i>(1 line per tracker)</i> + True + + + False + 2 + + + + + 3 + + + + + True + Trackers + + + tab + 3 + False + + 1 diff --git a/deluge/plugins/label/label/gtkui/sidebar.py b/deluge/plugins/label/label/gtkui/sidebar.py index faff66e24..01c2917ed 100644 --- a/deluge/plugins/label/label/gtkui/sidebar.py +++ b/deluge/plugins/label/label/gtkui/sidebar.py @@ -120,12 +120,12 @@ class AddDialog(object): class OptionsDialog(object): spin_ids = ["max_download_speed","max_upload_speed","max_upload_slots","max_connections","stop_ratio"] - chk_ids = ["apply_max","apply_queue","stop_at_ratio","apply_queue","remove_at_ratio","chk_move_completed_to"] + chk_ids = ["apply_max","apply_queue","stop_at_ratio","apply_queue","remove_at_ratio","move_completed","is_auto_managed"] sensitive_groups = { #keys must be checkboxes , value-list is to be enabled on checked. "apply_max": ["max_download_speed","max_upload_speed","max_upload_slots","max_connections"], "apply_queue":["is_auto_managed","remove_at_ratio","stop_at_ratio","stop_ratio"], #"stop_at_ratio":["stop_at_ratio","remove_at_ratio"], #nested from apply_queue, will probably cause bugs. - "chk_move_completed_to":["move_completed_to"] + "move_completed":["move_completed_path"] } def __init__(self): @@ -151,30 +151,24 @@ class OptionsDialog(object): def load_options(self, options): log.debug(options.keys()) - options["chk_move_completed_to"] = bool(options["move_completed_to"]) + for id in self.spin_ids: self.glade.get_widget(id).set_value(options[id]) for id in self.chk_ids: self.glade.get_widget(id).set_active(bool(options[id])) - - if options["move_completed_to"]: - self.glade.get_widget("move_completed_to").set_filename(options["move_completed_to"]) + self.glade.get_widget("move_completed_path").set_filename(options["move_completed_path"]) self.apply_sensitivity() def on_ok(self, event=None): "save options.." options = {} + for id in self.spin_ids: options[id] = self.glade.get_widget(id).get_value() for id in self.chk_ids: options[id] = self.glade.get_widget(id).get_active() - - if options["chk_move_completed_to"]: - options["move_completed_to"] = self.glade.get_widget("move_completed_to").get_filename() - else: - options["move_completed_to"] = None - del options["chk_move_completed_to"] #not mapped. + options["move_completed_path"] = self.glade.get_widget("move_completed_path").get_filename() aclient.label_set_options(None, self.label, options) @@ -185,7 +179,6 @@ class OptionsDialog(object): for chk_id , sensitive_list in self.sensitive_groups.iteritems(): sens = self.glade.get_widget(chk_id).get_active() for widget_id in sensitive_list: - log.debug(widget_id) self.glade.get_widget(widget_id).set_sensitive(sens)