Changeset 11358


Ignore:
Timestamp:
Oct 29, 2010, 4:19:37 AM (11 years ago)
Author:
charles
Message:

(trunk gtk) disable preferences proxy tab

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gtk/tr-prefs.c

    r11253 r11358  
    869869    refreshRPCSensitivity( page );
    870870    hig_workarea_finish( t, &row );
    871     return t;
    872 }
    873 
    874 /****
    875 *****  Proxy Tab
    876 ****/
    877 
    878 struct ProxyPage
    879 {
    880     GSList *  proxy_widgets;
    881     GSList *  proxy_auth_widgets;
    882 };
    883 
    884 static void
    885 refreshProxySensitivity( struct ProxyPage * p )
    886 {
    887     GSList *       l;
    888     const gboolean proxy_enabled = pref_flag_get( TR_PREFS_KEY_PROXY_ENABLED );
    889     const gboolean proxy_auth_enabled = pref_flag_get( TR_PREFS_KEY_PROXY_AUTH_ENABLED );
    890 
    891     for( l = p->proxy_widgets; l != NULL; l = l->next )
    892         gtk_widget_set_sensitive( GTK_WIDGET( l->data ), proxy_enabled );
    893 
    894     for( l = p->proxy_auth_widgets; l != NULL; l = l->next )
    895         gtk_widget_set_sensitive( GTK_WIDGET( l->data ),
    896                                   proxy_enabled && proxy_auth_enabled );
    897 }
    898 
    899 static void
    900 onProxyToggled( GtkToggleButton * tb UNUSED,
    901                 gpointer             user_data )
    902 {
    903     refreshProxySensitivity( user_data );
    904 }
    905 
    906 static void
    907 proxyPageFree( gpointer gpage )
    908 {
    909     struct ProxyPage * page = gpage;
    910 
    911     g_slist_free( page->proxy_widgets );
    912     g_slist_free( page->proxy_auth_widgets );
    913     g_free( page );
    914 }
    915 
    916 static GtkWidget*
    917 proxy_combo_box_new( GObject * core, const char * key )
    918 {
    919     GtkWidget * w =  gtr_combo_box_new_enum( "HTTP",   TR_PROXY_HTTP,
    920                                              "SOCKS4", TR_PROXY_SOCKS4,
    921                                              "SOCKS5", TR_PROXY_SOCKS5,
    922                                              NULL );
    923     gtr_combo_box_set_active_enum( GTK_COMBO_BOX( w ), pref_int_get( key ) );
    924     g_object_set_data_full( G_OBJECT( w ), PREF_KEY, tr_strdup( key ), g_free );
    925     g_signal_connect( w, "changed", G_CALLBACK( onIntComboChanged ), core );
    926     return w;
    927 }
    928 
    929 static GtkWidget*
    930 trackerPage( GObject * core )
    931 {
    932     int                row = 0;
    933     const char *       s;
    934     GtkWidget *        t;
    935     GtkWidget *        w;
    936     struct ProxyPage * page = tr_new0( struct ProxyPage, 1 );
    937 
    938     t = hig_workarea_create( );
    939     hig_workarea_add_section_title ( t, &row, _( "Tracker" ) );
    940 
    941     s = _( "Connect to tracker via a pro_xy" );
    942     w = new_check_button( s, TR_PREFS_KEY_PROXY_ENABLED, core );
    943     g_signal_connect( w, "toggled", G_CALLBACK( onProxyToggled ), page );
    944     hig_workarea_add_wide_control( t, &row, w );
    945 
    946     s = _( "Proxy _server:" );
    947     w = new_entry( TR_PREFS_KEY_PROXY, core );
    948     page->proxy_widgets = g_slist_append( page->proxy_widgets, w );
    949     w = hig_workarea_add_row( t, &row, s, w, NULL );
    950     page->proxy_widgets = g_slist_append( page->proxy_widgets, w );
    951 
    952     w = new_spin_button( TR_PREFS_KEY_PROXY_PORT, core, 0, USHRT_MAX, 1 );
    953     page->proxy_widgets = g_slist_append( page->proxy_widgets, w );
    954     w = hig_workarea_add_row( t, &row, _( "Proxy _port:" ), w, NULL );
    955     page->proxy_widgets = g_slist_append( page->proxy_widgets, w );
    956 
    957     s = _( "Proxy _type:" );
    958     w = proxy_combo_box_new( core, TR_PREFS_KEY_PROXY_TYPE );
    959     page->proxy_widgets = g_slist_append( page->proxy_widgets, w );
    960     w = hig_workarea_add_row( t, &row, s, w, NULL );
    961     page->proxy_widgets = g_slist_append( page->proxy_widgets, w );
    962 
    963     s = _( "Use _authentication" );
    964     w = new_check_button( s, TR_PREFS_KEY_PROXY_AUTH_ENABLED, core );
    965     g_signal_connect( w, "toggled", G_CALLBACK( onProxyToggled ), page );
    966     hig_workarea_add_wide_control( t, &row, w );
    967     page->proxy_widgets = g_slist_append( page->proxy_widgets, w );
    968 
    969     s = _( "_Username:" );
    970     w = new_entry( TR_PREFS_KEY_PROXY_USERNAME, core );
    971     page->proxy_auth_widgets = g_slist_append( page->proxy_auth_widgets, w );
    972     w = hig_workarea_add_row( t, &row, s, w, NULL );
    973     page->proxy_auth_widgets = g_slist_append( page->proxy_auth_widgets, w );
    974 
    975     s = _( "Pass_word:" );
    976     w = new_entry( TR_PREFS_KEY_PROXY_PASSWORD, core );
    977     gtk_entry_set_visibility( GTK_ENTRY( w ), FALSE );
    978     page->proxy_auth_widgets = g_slist_append( page->proxy_auth_widgets, w );
    979     w = hig_workarea_add_row( t, &row, s, w, NULL );
    980     page->proxy_auth_widgets = g_slist_append( page->proxy_auth_widgets, w );
    981 
    982     hig_workarea_finish( t, &row );
    983     g_object_set_data_full( G_OBJECT( t ), "page", page, proxyPageFree );
    984 
    985     refreshProxySensitivity( page );
    986871    return t;
    987872}
     
    13471232                              webPage( core ),
    13481233                              gtk_label_new ( _( "Web" ) ) );
    1349     gtk_notebook_append_page( GTK_NOTEBOOK( n ),
    1350                               trackerPage( core ),
    1351                               gtk_label_new ( _( "Proxy" ) ) );
    13521234
    13531235    g_signal_connect( d, "response", G_CALLBACK( response_cb ), core );
Note: See TracChangeset for help on using the changeset viewer.