From 24a0ccee0a03008baed7163bf0a86f56195fda5c Mon Sep 17 00:00:00 2001 From: Marcos Pinto Date: Tue, 16 Dec 2008 02:49:06 +0000 Subject: [PATCH] make test active port use internal graphic instead of launching browser --- ChangeLog | 1 + deluge/core/core.py | 12 +++++++ .../ui/gtkui/glade/connection_manager.glade | 1 - .../ui/gtkui/glade/preferences_dialog.glade | 33 +++++++++++++------ deluge/ui/gtkui/preferences.py | 10 +++--- 5 files changed, 42 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index feb4e2cac..8a6a7b731 100644 --- a/ChangeLog +++ b/ChangeLog @@ -31,6 +31,7 @@ Deluge 1.1.0 - "" (In Development) * Add protocol traffic statusbar item * Rework the Remove Torrent Dialog to only have 2 options, remove data and remove from session. * Add "Install Plugin" and "Rescan Plugins" buttons to the Plugins preferences + * Make active port test use internal graphic instead of launching browser WebUi: * Lots of smaller tweaks. diff --git a/deluge/core/core.py b/deluge/core/core.py index 2200f6a9d..ffee119a5 100644 --- a/deluge/core/core.py +++ b/deluge/core/core.py @@ -790,3 +790,15 @@ class Core( def export_glob(self, path): return glob.glob(path) + + def export_test_listen_port(self): + """ Checks if active port is open """ + import urllib + port = self.export_get_listen_port() + try: + status = urllib.urlopen("http://deluge-torrent.org/test_port.php?port=%s" % port).read() + except IOError: + log.debug("Network error while trying to check status of port %s", port) + return 0 + else: + return int(status) diff --git a/deluge/ui/gtkui/glade/connection_manager.glade b/deluge/ui/gtkui/glade/connection_manager.glade index 6b64417cf..c4eed5fac 100644 --- a/deluge/ui/gtkui/glade/connection_manager.glade +++ b/deluge/ui/gtkui/glade/connection_manager.glade @@ -1,6 +1,5 @@ - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK 5 diff --git a/deluge/ui/gtkui/glade/preferences_dialog.glade b/deluge/ui/gtkui/glade/preferences_dialog.glade index 4fe37998a..eac444ea7 100644 --- a/deluge/ui/gtkui/glade/preferences_dialog.glade +++ b/deluge/ui/gtkui/glade/preferences_dialog.glade @@ -1,6 +1,4 @@ - - - + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK @@ -449,8 +447,8 @@ page 6 - tab False + tab @@ -645,6 +643,21 @@ 4 + + + True + 5 + + + True + + + + + False + 5 + + 5 @@ -1147,9 +1160,9 @@ Disabled page 7 - tab 1 False + tab @@ -1639,9 +1652,9 @@ Disabled page 8 - tab 2 False + tab @@ -2009,9 +2022,9 @@ Disabled page 10 - tab 3 False + tab @@ -2203,9 +2216,9 @@ Disabled page 11 - tab 4 False + tab @@ -2424,9 +2437,9 @@ Disabled page 11 - tab 5 False + tab @@ -2883,9 +2896,9 @@ Disabled page 12 - tab 6 False + tab diff --git a/deluge/ui/gtkui/preferences.py b/deluge/ui/gtkui/preferences.py index 6210a9c1b..8413a4323 100644 --- a/deluge/ui/gtkui/preferences.py +++ b/deluge/ui/gtkui/preferences.py @@ -790,10 +790,12 @@ class Preferences(component.Component): def on_test_port_clicked(self, data): log.debug("on_test_port_clicked") - def on_get_listen_port(port): - deluge.common.open_url_in_browser( - "http://deluge-torrent.org/test-port.php?port=%s" % port) - client.get_listen_port(on_get_listen_port) + def on_get_test(status): + if status: + self.glade.get_widget("port_img").set_from_stock(gtk.STOCK_YES, 4).show() + else: + self.glade.get_widget("port_img").set_from_stock(gtk.STOCK_DIALOG_WARNING, 4).show() + client.test_listen_port(on_get_test) client.force_call() def on_plugin_toggled(self, renderer, path):