Author: andar

Revision: 5716

Log:
        Pretty up the Proxy preference page by dynamically showing/hiding 
fields as needed

Diff:
Modified: trunk/deluge/ui/gtkui/glade/preferences_dialog.glade
===================================================================
--- trunk/deluge/ui/gtkui/glade/preferences_dialog.glade        2009-09-05 
19:32:01 UTC (rev 5715)
+++ trunk/deluge/ui/gtkui/glade/preferences_dialog.glade        2009-09-07 
20:47:51 UTC (rev 5716)
@@ -3179,7 +3179,7 @@
                                             <property 
name="n_columns">2</property>
                                             <property 
name="column_spacing">5</property>
                                             <child>
-                                              <widget class="GtkLabel" 
id="label61">
+                                              <widget class="GtkLabel" 
id="label_proxy_password_peer">
                                                 <property 
name="visible">True</property>
                                                 <property 
name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | 
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
                                                 <property 
name="xalign">0</property>
@@ -3207,7 +3207,7 @@
                                               </packing>
                                             </child>
                                             <child>
-                                              <widget class="GtkLabel" 
id="label60">
+                                              <widget class="GtkLabel" 
id="label_proxy_server_peer">
                                                 <property 
name="visible">True</property>
                                                 <property 
name="xalign">0</property>
                                                 <property name="label" 
translatable="yes">Host:</property>
@@ -3232,7 +3232,7 @@
                                               </packing>
                                             </child>
                                             <child>
-                                              <widget class="GtkLabel" 
id="label73">
+                                              <widget class="GtkLabel" 
id="label_proxy_port_peer">
                                                 <property 
name="visible">True</property>
                                                 <property 
name="xalign">0</property>
                                                 <property name="label" 
translatable="yes">Port:</property>
@@ -3290,11 +3290,13 @@
 Socksv5 W/ Auth
 HTTP
 HTTP W/ Auth</property>
+                                                <signal name="changed" 
handler="on_combo_proxy_type_changed"/>
                                               </widget>
                                               <packing>
                                                 <property 
name="left_attach">1</property>
                                                 <property 
name="right_attach">2</property>
                                                 <property 
name="x_options">GTK_FILL</property>
+                                                <property 
name="y_options"></property>
                                               </packing>
                                             </child>
                                             <child>
@@ -3306,10 +3308,11 @@
                                               </widget>
                                               <packing>
                                                 <property 
name="x_options">GTK_FILL</property>
+                                                <property 
name="y_options"></property>
                                               </packing>
                                             </child>
                                             <child>
-                                              <widget class="GtkLabel" 
id="label62">
+                                              <widget class="GtkLabel" 
id="label_proxy_username_peer">
                                                 <property 
name="visible">True</property>
                                                 <property 
name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | 
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
                                                 <property 
name="xalign">0</property>
@@ -3337,6 +3340,8 @@
                                     </child>
                                   </widget>
                                   <packing>
+                                    <property name="expand">False</property>
+                                    <property name="fill">False</property>
                                     <property name="position">0</property>
                                   </packing>
                                 </child>
@@ -3358,7 +3363,7 @@
                                             <property 
name="n_columns">2</property>
                                             <property 
name="column_spacing">5</property>
                                             <child>
-                                              <widget class="GtkLabel" 
id="label88">
+                                              <widget class="GtkLabel" 
id="label_proxy_password_web_seed">
                                                 <property 
name="visible">True</property>
                                                 <property 
name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | 
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
                                                 <property 
name="xalign">0</property>
@@ -3386,7 +3391,7 @@
                                               </packing>
                                             </child>
                                             <child>
-                                              <widget class="GtkLabel" 
id="label89">
+                                              <widget class="GtkLabel" 
id="label_proxy_server_web_seed">
                                                 <property 
name="visible">True</property>
                                                 <property 
name="xalign">0</property>
                                                 <property name="label" 
translatable="yes">Host:</property>
@@ -3411,7 +3416,7 @@
                                               </packing>
                                             </child>
                                             <child>
-                                              <widget class="GtkLabel" 
id="label90">
+                                              <widget class="GtkLabel" 
id="label_proxy_port_web_seed">
                                                 <property 
name="visible">True</property>
                                                 <property 
name="xalign">0</property>
                                                 <property name="label" 
translatable="yes">Port:</property>
@@ -3469,11 +3474,13 @@
 Socksv5 W/ Auth
 HTTP
 HTTP W/ Auth</property>
+                                                <signal name="changed" 
handler="on_combo_proxy_type_changed"/>
                                               </widget>
                                               <packing>
                                                 <property 
name="left_attach">1</property>
                                                 <property 
name="right_attach">2</property>
                                                 <property 
name="x_options">GTK_FILL</property>
+                                                <property 
name="y_options"></property>
                                               </packing>
                                             </child>
                                             <child>
@@ -3485,10 +3492,11 @@
                                               </widget>
                                               <packing>
                                                 <property 
name="x_options">GTK_FILL</property>
+                                                <property 
name="y_options"></property>
                                               </packing>
                                             </child>
                                             <child>
-                                              <widget class="GtkLabel" 
id="label92">
+                                              <widget class="GtkLabel" 
id="label_proxy_username_web_seed">
                                                 <property 
name="visible">True</property>
                                                 <property 
name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | 
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
                                                 <property 
name="xalign">0</property>
@@ -3516,6 +3524,8 @@
                                     </child>
                                   </widget>
                                   <packing>
+                                    <property name="expand">False</property>
+                                    <property name="fill">False</property>
                                     <property name="position">1</property>
                                   </packing>
                                 </child>
@@ -3537,7 +3547,7 @@
                                             <property 
name="n_columns">2</property>
                                             <property 
name="column_spacing">5</property>
                                             <child>
-                                              <widget class="GtkLabel" 
id="label94">
+                                              <widget class="GtkLabel" 
id="label_proxy_password_tracker">
                                                 <property 
name="visible">True</property>
                                                 <property 
name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | 
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
                                                 <property 
name="xalign">0</property>
@@ -3565,7 +3575,7 @@
                                               </packing>
                                             </child>
                                             <child>
-                                              <widget class="GtkLabel" 
id="label95">
+                                              <widget class="GtkLabel" 
id="label_proxy_server_tracker">
                                                 <property 
name="visible">True</property>
                                                 <property 
name="xalign">0</property>
                                                 <property name="label" 
translatable="yes">Host:</property>
@@ -3590,7 +3600,7 @@
                                               </packing>
                                             </child>
                                             <child>
-                                              <widget class="GtkLabel" 
id="label96">
+                                              <widget class="GtkLabel" 
id="label_proxy_port_tracker">
                                                 <property 
name="visible">True</property>
                                                 <property 
name="xalign">0</property>
                                                 <property name="label" 
translatable="yes">Port:</property>
@@ -3648,11 +3658,13 @@
 Socksv5 W/ Auth
 HTTP
 HTTP W/ Auth</property>
+                                                <signal name="changed" 
handler="on_combo_proxy_type_changed"/>
                                               </widget>
                                               <packing>
                                                 <property 
name="left_attach">1</property>
                                                 <property 
name="right_attach">2</property>
                                                 <property 
name="x_options">GTK_FILL</property>
+                                                <property 
name="y_options"></property>
                                               </packing>
                                             </child>
                                             <child>
@@ -3664,10 +3676,11 @@
                                               </widget>
                                               <packing>
                                                 <property 
name="x_options">GTK_FILL</property>
+                                                <property 
name="y_options"></property>
                                               </packing>
                                             </child>
                                             <child>
-                                              <widget class="GtkLabel" 
id="label98">
+                                              <widget class="GtkLabel" 
id="label_proxy_username_tracker">
                                                 <property 
name="visible">True</property>
                                                 <property 
name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | 
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
                                                 <property 
name="xalign">0</property>
@@ -3695,6 +3708,8 @@
                                     </child>
                                   </widget>
                                   <packing>
+                                    <property name="expand">False</property>
+                                    <property name="fill">False</property>
                                     <property name="position">2</property>
                                   </packing>
                                 </child>
@@ -3716,7 +3731,7 @@
                                             <property 
name="n_columns">2</property>
                                             <property 
name="column_spacing">5</property>
                                             <child>
-                                              <widget class="GtkLabel" 
id="label100">
+                                              <widget class="GtkLabel" 
id="label_proxy_password_dht">
                                                 <property 
name="visible">True</property>
                                                 <property 
name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | 
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
                                                 <property 
name="xalign">0</property>
@@ -3726,6 +3741,7 @@
                                                 <property 
name="top_attach">2</property>
                                                 <property 
name="bottom_attach">3</property>
                                                 <property 
name="x_options">GTK_FILL</property>
+                                                <property 
name="y_options"></property>
                                               </packing>
                                             </child>
                                             <child>
@@ -3744,7 +3760,7 @@
                                               </packing>
                                             </child>
                                             <child>
-                                              <widget class="GtkLabel" 
id="label101">
+                                              <widget class="GtkLabel" 
id="label_proxy_server_dht">
                                                 <property 
name="visible">True</property>
                                                 <property 
name="xalign">0</property>
                                                 <property name="label" 
translatable="yes">Host:</property>
@@ -3753,6 +3769,7 @@
                                                 <property 
name="top_attach">3</property>
                                                 <property 
name="bottom_attach">4</property>
                                                 <property 
name="x_options">GTK_FILL</property>
+                                                <property 
name="y_options"></property>
                                               </packing>
                                             </child>
                                             <child>
@@ -3769,7 +3786,7 @@
                                               </packing>
                                             </child>
                                             <child>
-                                              <widget class="GtkLabel" 
id="label102">
+                                              <widget class="GtkLabel" 
id="label_proxy_port_dht">
                                                 <property 
name="visible">True</property>
                                                 <property 
name="xalign">0</property>
                                                 <property name="label" 
translatable="yes">Port:</property>
@@ -3778,6 +3795,7 @@
                                                 <property 
name="top_attach">4</property>
                                                 <property 
name="bottom_attach">5</property>
                                                 <property 
name="x_options">GTK_FILL</property>
+                                                <property 
name="y_options"></property>
                                               </packing>
                                             </child>
                                             <child>
@@ -3827,11 +3845,13 @@
 Socksv5 W/ Auth
 HTTP
 HTTP W/ Auth</property>
+                                                <signal name="changed" 
handler="on_combo_proxy_type_changed"/>
                                               </widget>
                                               <packing>
                                                 <property 
name="left_attach">1</property>
                                                 <property 
name="right_attach">2</property>
                                                 <property 
name="x_options">GTK_FILL</property>
+                                                <property 
name="y_options"></property>
                                               </packing>
                                             </child>
                                             <child>
@@ -3843,10 +3863,11 @@
                                               </widget>
                                               <packing>
                                                 <property 
name="x_options">GTK_FILL</property>
+                                                <property 
name="y_options"></property>
                                               </packing>
                                             </child>
                                             <child>
-                                              <widget class="GtkLabel" 
id="label104">
+                                              <widget class="GtkLabel" 
id="label_proxy_username_dht">
                                                 <property 
name="visible">True</property>
                                                 <property 
name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | 
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
                                                 <property 
name="xalign">0</property>
@@ -3856,6 +3877,7 @@
                                                 <property 
name="top_attach">1</property>
                                                 <property 
name="bottom_attach">2</property>
                                                 <property 
name="x_options">GTK_FILL</property>
+                                                <property 
name="y_options"></property>
                                               </packing>
                                             </child>
                                           </widget>
@@ -3874,6 +3896,8 @@
                                     </child>
                                   </widget>
                                   <packing>
+                                    <property name="expand">False</property>
+                                    <property name="fill">False</property>
                                     <property name="position">3</property>
                                   </packing>
                                 </child>
@@ -4296,7 +4320,6 @@
                         <child>
                           <widget class="GtkVBox" id="vbox30">
                             <property name="visible">True</property>
-                            <property name="orientation">vertical</property>
                             <child>
                               <widget class="GtkLabel" id="label111">
                                 <property name="visible">True</property>
@@ -4328,7 +4351,6 @@
                                 <child>
                                   <widget class="GtkVBox" id="vbox31">
                                     <property name="visible">True</property>
-                                    <property 
name="orientation">vertical</property>
                                     <child>
                                       <widget class="GtkFrame" id="frame32">
                                         <property 
name="visible">True</property>
@@ -4438,7 +4460,6 @@
                                             <child>
                                               <widget class="GtkVBox" 
id="vbox32">
                                                 <property 
name="visible">True</property>
-                                                <property 
name="orientation">vertical</property>
                                                 <child>
                                                   <widget class="GtkFrame" 
id="frame34">
                                                     <property 
name="visible">True</property>
@@ -4768,7 +4789,7 @@
                                                     <property 
name="layout_style">start</property>
                                                     <child>
                                                       <widget 
class="GtkButton" id="button_cache_refresh">
-                                                        <property name="label" 
translatable="yes">gtk-refresh</property>
+                                                        <property 
name="label">gtk-refresh</property>
                                                         <property 
name="visible">True</property>
                                                         <property 
name="can_focus">True</property>
                                                         <property 
name="receives_default">True</property>

Modified: trunk/deluge/ui/gtkui/preferences.py
===================================================================
--- trunk/deluge/ui/gtkui/preferences.py        2009-09-05 19:32:01 UTC (rev 
5715)
+++ trunk/deluge/ui/gtkui/preferences.py        2009-09-07 20:47:51 UTC (rev 
5716)
@@ -104,7 +104,8 @@
             "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 @@
 
     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()



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"deluge-commit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/deluge-commit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to