602 | | # Disable the focus dialog checkbox if the show dialog isn't active. |
603 | | if widget == self.glade.get_widget("chk_show_dialog"): |
604 | | self.glade.get_widget("chk_focus_dialog").set_sensitive(value) |
605 | | |
606 | | # Disable the port spinners if random ports is selected. |
607 | | if widget == self.glade.get_widget("chk_random_port"): |
608 | | log.debug("chk_random_port set to: %s", value) |
609 | | self.glade.get_widget("spin_port_min").set_sensitive(not value) |
610 | | self.glade.get_widget("spin_port_max").set_sensitive(not value) |
611 | | |
612 | | # Disable all the tray options if tray is not used. |
613 | | if widget == self.glade.get_widget("chk_use_tray"): |
614 | | self.glade.get_widget("chk_min_on_close").set_sensitive(value) |
615 | | self.glade.get_widget("chk_start_in_tray").set_sensitive(value) |
616 | | self.glade.get_widget("chk_lock_tray").set_sensitive(value) |
617 | | if value == True: |
618 | | lock = self.glade.get_widget("chk_lock_tray").get_active() |
619 | | self.glade.get_widget("txt_tray_password").set_sensitive(lock) |
620 | | self.glade.get_widget("password_label").set_sensitive(lock) |
621 | | else: |
622 | | self.glade.get_widget("txt_tray_password").set_sensitive(value) |
623 | | self.glade.get_widget("password_label").set_sensitive(value) |
624 | | |
625 | | if widget == self.glade.get_widget("chk_lock_tray"): |
626 | | self.glade.get_widget("txt_tray_password").set_sensitive(value) |
627 | | self.glade.get_widget("password_label").set_sensitive(value) |
628 | | |
629 | | # Disable the file manager combo box if custom is selected. |
630 | | if widget == self.glade.get_widget("radio_open_folder_custom"): |
631 | | self.glade.get_widget("combo_file_manager").set_sensitive(not value) |
632 | | self.glade.get_widget("txt_open_folder_location").set_sensitive( |
633 | | value) |
634 | | |
| 602 | dependents = { |
| 603 | "chk_show_dialog": {"chk_focus_dialog": True}, |
| 604 | "chk_random_port": {"spin_port_min": False, |
| 605 | "spin_port_max": False}, |
| 606 | "chk_use_tray": {"chk_min_on_close": True, |
| 607 | "chk_start_in_tray": True, |
| 608 | "chk_lock_tray": True}, |
| 609 | "chk_lock_tray": {"txt_tray_password": True, |
| 610 | "password_label": True}, |
| 611 | "radio_open_folder_custom": {"combo_file_manager": False, |
| 612 | "txt_open_folder_location": True}, |
| 613 | "chk_move_completed" : {"move_completed_path_button" : True}, |
| 614 | "chk_copy_torrent_file" : {"torrent_files_button" : True}, |
| 615 | "chk_autoadd" : {"folder_autoadd" : True}, |
| 616 | "chk_seed_ratio" : {"spin_share_ratio": True, |
| 617 | "chk_remove_ratio" : True} |
| 618 | } |
| 619 | |
| 620 | def update_dependent_widgets(name, value): |
| 621 | dependency = dependents[name] |
| 622 | for dep in dependency.keys(): |
| 623 | depwidget = self.glade.get_widget(dep) |
| 624 | sensitive = [not value, value][dependency[dep]] |
| 625 | depwidget.set_sensitive(sensitive) |
| 626 | if dep in dependents: |
| 627 | update_dependent_widgets(dep, depwidget.get_active() and sensitive) |
| 628 | |
| 629 | for key in dependents.keys(): |
| 630 | if widget != self.glade.get_widget(key): |
| 631 | continue |
| 632 | update_dependent_widgets(key, value) |
| 633 | |