From 2caee15f7f0e07b8a31cad55304e1a897aca8c08 Mon Sep 17 00:00:00 2001 From: Andrew Resch Date: Mon, 7 Sep 2009 20:47:51 +0000 Subject: [PATCH] Pretty up the Proxy preference page by dynamically showing/hiding fields as needed --- .../ui/gtkui/glade/preferences_dialog.glade | 61 +++++++++++++------ deluge/ui/gtkui/preferences.py | 30 ++++++++- 2 files changed, 70 insertions(+), 21 deletions(-) diff --git a/deluge/ui/gtkui/glade/preferences_dialog.glade b/deluge/ui/gtkui/glade/preferences_dialog.glade index 07dc6fbb9..f2d3052a9 100644 --- a/deluge/ui/gtkui/glade/preferences_dialog.glade +++ b/deluge/ui/gtkui/glade/preferences_dialog.glade @@ -3179,7 +3179,7 @@ Disabled 2 5 - + True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK 0 @@ -3207,7 +3207,7 @@ Disabled - + True 0 Host: @@ -3232,7 +3232,7 @@ Disabled - + True 0 Port: @@ -3290,11 +3290,13 @@ Socksv5 Socksv5 W/ Auth HTTP HTTP W/ Auth + 1 2 GTK_FILL + @@ -3306,10 +3308,11 @@ HTTP W/ Auth GTK_FILL + - + True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK 0 @@ -3337,6 +3340,8 @@ HTTP W/ Auth + False + False 0 @@ -3358,7 +3363,7 @@ HTTP W/ Auth 2 5 - + True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK 0 @@ -3386,7 +3391,7 @@ HTTP W/ Auth - + True 0 Host: @@ -3411,7 +3416,7 @@ HTTP W/ Auth - + True 0 Port: @@ -3469,11 +3474,13 @@ Socksv5 Socksv5 W/ Auth HTTP HTTP W/ Auth + 1 2 GTK_FILL + @@ -3485,10 +3492,11 @@ HTTP W/ Auth GTK_FILL + - + True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK 0 @@ -3516,6 +3524,8 @@ HTTP W/ Auth + False + False 1 @@ -3537,7 +3547,7 @@ HTTP W/ Auth 2 5 - + True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK 0 @@ -3565,7 +3575,7 @@ HTTP W/ Auth - + True 0 Host: @@ -3590,7 +3600,7 @@ HTTP W/ Auth - + True 0 Port: @@ -3648,11 +3658,13 @@ Socksv5 Socksv5 W/ Auth HTTP HTTP W/ Auth + 1 2 GTK_FILL + @@ -3664,10 +3676,11 @@ HTTP W/ Auth GTK_FILL + - + True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK 0 @@ -3695,6 +3708,8 @@ HTTP W/ Auth + False + False 2 @@ -3716,7 +3731,7 @@ HTTP W/ Auth 2 5 - + True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK 0 @@ -3726,6 +3741,7 @@ HTTP W/ Auth 2 3 GTK_FILL + @@ -3744,7 +3760,7 @@ HTTP W/ Auth - + True 0 Host: @@ -3753,6 +3769,7 @@ HTTP W/ Auth 3 4 GTK_FILL + @@ -3769,7 +3786,7 @@ HTTP W/ Auth - + True 0 Port: @@ -3778,6 +3795,7 @@ HTTP W/ Auth 4 5 GTK_FILL + @@ -3827,11 +3845,13 @@ Socksv5 Socksv5 W/ Auth HTTP HTTP W/ Auth + 1 2 GTK_FILL + @@ -3843,10 +3863,11 @@ HTTP W/ Auth GTK_FILL + - + True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK 0 @@ -3856,6 +3877,7 @@ HTTP W/ Auth 1 2 GTK_FILL + @@ -3874,6 +3896,8 @@ HTTP W/ Auth + False + False 3 @@ -4296,7 +4320,6 @@ HTTP W/ Auth True - vertical True @@ -4328,7 +4351,6 @@ HTTP W/ Auth True - vertical True @@ -4438,7 +4460,6 @@ HTTP W/ Auth True - vertical True @@ -4768,7 +4789,7 @@ HTTP W/ Auth start - gtk-refresh + gtk-refresh True True True diff --git a/deluge/ui/gtkui/preferences.py b/deluge/ui/gtkui/preferences.py index b63d3b9a8..4abe93b56 100644 --- a/deluge/ui/gtkui/preferences.py +++ b/deluge/ui/gtkui/preferences.py @@ -104,7 +104,8 @@ class Preferences(component.Component): "on_button_plugin_install_clicked": self._on_button_plugin_install_clicked, "on_button_rescan_plugins_clicked": self._on_button_rescan_plugins_clicked, "on_button_find_plugins_clicked": self._on_button_find_plugins_clicked, - "on_button_cache_refresh_clicked": self._on_button_cache_refresh_clicked + "on_button_cache_refresh_clicked": self._on_button_cache_refresh_clicked, + "on_combo_proxy_type_changed": self._on_combo_proxy_type_changed }) # These get updated by requests done to the core @@ -953,3 +954,30 @@ class Preferences(component.Component): def _on_button_find_plugins_clicked(self, widget): deluge.common.open_url_in_browser("http://dev.deluge-torrent.org/wiki/Plugins") + + def _on_combo_proxy_type_changed(self, widget): + name = widget.get_name().replace("combo_proxy_type_", "") + proxy_type = widget.get_model()[widget.get_active()][0] + + prefixes = ["txt_proxy_", "label_proxy_", "spin_proxy_"] + hides = [] + shows = [] + + if proxy_type == "None": + hides.extend(["password", "username", "server", "port"]) + elif proxy_type in ("Socksv4", "Socksv5", "HTTP"): + hides.extend(["password", "username"]) + shows.extend(["server", "port"]) + elif proxy_type in ("Socksv5 W/ Auth", "HTTP W/ Auth"): + shows.extend(["password", "username", "server", "port"]) + + for h in hides: + for p in prefixes: + w = self.glade.get_widget(p + h + "_" + name) + if w: + w.hide() + for s in shows: + for p in prefixes: + w = self.glade.get_widget(p + s + "_" + name) + if w: + w.show()