diff --git a/deluge/core/core.py b/deluge/core/core.py index f5bda969d..6048be343 100644 --- a/deluge/core/core.py +++ b/deluge/core/core.py @@ -89,14 +89,24 @@ class Core(dbus.service.Object): version.append(int(value)) fingerprint = lt.fingerprint("DE", *version) - # Setup the libtorrent session and listen on the configured ports + # Start the libtorrent session log.debug("Starting libtorrent session..") self.session = lt.session(fingerprint) - log.debug("Listening on %i-%i", self.config.get("listen_ports")[0], - self.config.get("listen_ports")[1]) - self.session.listen_on(self.config.get("listen_ports")[0], - self.config.get("listen_ports")[1]) + # Set the listening ports + if self.config.get("random_port"): + import random + randrange = lambda: random.randrange(49152, 65535) + ports = [randrange(), randrange()] + ports.sort() + log.debug("Listening on %i-%i", ports[0], ports[1]) + self.session.listen_on(ports[0], ports[1]) + else: + listen_ports = self.config.get("listen_ports") + log.debug("Listening on %i-%i", listen_ports[0], + listen_ports[1]) + self.session.listen_on(listen_ports[0], + listen_ports[1]) # Start the TorrentManager self.torrents = TorrentManager(self.session) diff --git a/deluge/ui/gtkui/glade/preferences_dialog.glade b/deluge/ui/gtkui/glade/preferences_dialog.glade index 7e436bcee..9c96608a6 100644 --- a/deluge/ui/gtkui/glade/preferences_dialog.glade +++ b/deluge/ui/gtkui/glade/preferences_dialog.glade @@ -1,6 +1,6 @@ - + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK @@ -127,7 +127,7 @@ True True radio_ask_save - + False @@ -470,6 +470,7 @@ Use Random Ports 0 True + False @@ -881,40 +882,71 @@ Full Stream 2 15 - + True - True - The maximum upload slots for all torrents. Set -1 for unlimited. - 1 - -1 -1 9000 1 10 10 - 1 - True - True + The maximum upload speed for all torrents. Set -1 for unlimited. + 0 + Maximum Upload Speed (KiB/s): + + + 2 + 3 + GTK_FILL + + + + + True + The maximum number of connections allowed. Set -1 for unlimited. + 0 + Maximum Connections: + + + GTK_FILL + + + + + True + The maximum upload speed for all torrents. Set -1 for unlimited. + 0 + Maximum Upload Slots: - 1 - 2 3 4 GTK_FILL - + True True - The maximum upload speed for all torrents. Set -1 for unlimited. + The maximum number of connections allowed. Set -1 for unlimited. + 4 1 -1 -1 9000 1 10 10 1 - 1 + True True + GTK_UPDATE_IF_VALID 1 2 - 2 - 3 + GTK_FILL + + + + + True + The maximum download speed for all torrents. Set -1 for unlimited. + 0 + Maximum Download Speed (KiB/s): + + + 1 + 2 GTK_FILL @@ -939,74 +971,43 @@ Full Stream - + True - The maximum download speed for all torrents. Set -1 for unlimited. - 0 - Maximum Download Speed (KiB/s): + True + The maximum upload speed for all torrents. Set -1 for unlimited. + 1 + -1 -1 9000 1 10 10 + 1 + 1 + True - 1 - 2 + 1 + 2 + 2 + 3 GTK_FILL - + True True - The maximum number of connections allowed. Set -1 for unlimited. - 4 + The maximum upload slots for all torrents. Set -1 for unlimited. 1 -1 -1 9000 1 10 10 1 True True - GTK_UPDATE_IF_VALID 1 2 - GTK_FILL - - - - - True - The maximum upload speed for all torrents. Set -1 for unlimited. - 0 - Maximum Upload Slots: - - 3 4 GTK_FILL - - - True - The maximum number of connections allowed. Set -1 for unlimited. - 0 - Maximum Connections: - - - GTK_FILL - - - - - True - The maximum upload speed for all torrents. Set -1 for unlimited. - 0 - Maximum Upload Speed (KiB/s): - - - 2 - 3 - GTK_FILL - - @@ -1050,24 +1051,29 @@ Full Stream 2 15 - + True - True - The maximum upload slots per torrent. Set -1 for unlimited. - 1 - -1 -1 9000 1 10 10 - 1 - True - True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 0 + Maximum Upload Slots: - 1 - 2 1 2 GTK_FILL + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 0 + Maximum Connections: + + + GTK_FILL + + True @@ -1085,24 +1091,19 @@ Full Stream - + True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 0 - Maximum Connections: - - - GTK_FILL - - - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 0 - Maximum Upload Slots: + True + The maximum upload slots per torrent. Set -1 for unlimited. + 1 + -1 -1 9000 1 10 10 + 1 + True + True + 1 + 2 1 2 GTK_FILL @@ -1351,31 +1352,14 @@ Full Stream 2 10 - + True True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - Open folder with: - 0 - True - True - - - GTK_FILL - - - - - True - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - Custom: - 0 - True - True - radio_open_folder_stock + 1 + 2 1 2 GTK_FILL @@ -1405,19 +1389,36 @@ Thunar - + True True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + Custom: + 0 + True + True + radio_open_folder_stock - 1 - 2 1 2 GTK_FILL + + + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + Open folder with: + 0 + True + True + + + GTK_FILL + + diff --git a/deluge/ui/gtkui/preferences.py b/deluge/ui/gtkui/preferences.py index 355a68bfc..3f1d0af5d 100644 --- a/deluge/ui/gtkui/preferences.py +++ b/deluge/ui/gtkui/preferences.py @@ -72,7 +72,7 @@ class Preferences: "on_button_ok_clicked": self.on_button_ok_clicked, "on_button_apply_clicked": self.on_button_apply_clicked, "on_button_cancel_clicked": self.on_button_cancel_clicked, - "on_radio_save_all_to_toggled": self.on_toggle + "on_toggle": self.on_toggle }) def add_page(self, name, widget): @@ -229,7 +229,12 @@ class Preferences: value = widget.get_active() if widget == self.glade.get_widget('radio_save_all_to'): self.glade.get_widget('download_path_button').set_sensitive(value) - + + self.glade.get_widget('spin_port_min').set_sensitive( + not self.glade.get_widget('chk_random_port').get_active()) + self.glade.get_widget('spin_port_max').set_sensitive( + not self.glade.get_widget('chk_random_port').get_active()) + def on_button_ok_clicked(self, data): log.debug("on_button_ok_clicked") self.set_config()