Changeset 6068


Ignore:
Timestamp:
Jun 6, 2008, 11:48:17 PM (14 years ago)
Author:
charles
Message:

(gtk) work on the proxy prefs UI a little more.

File:
1 edited

Legend:

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

    r6065 r6068  
    890890}
    891891
     892struct ProxyPage
     893{
     894    GSList * proxy_widgets;
     895    GSList * proxy_auth_widgets;
     896};
     897
     898static void
     899refreshProxySensitivity( struct ProxyPage * p )
     900{
     901    GSList * l;
     902    const gboolean proxy_enabled = pref_flag_get( PREF_KEY_PROXY_SERVER_ENABLED );
     903    const gboolean proxy_auth_enabled = pref_flag_get( PREF_KEY_PROXY_AUTH_ENABLED );
     904
     905    for( l=p->proxy_widgets; l!=NULL; l=l->next )
     906        gtk_widget_set_sensitive( GTK_WIDGET( l->data ), proxy_enabled );
     907
     908    for( l=p->proxy_auth_widgets; l!=NULL; l=l->next )
     909        gtk_widget_set_sensitive( GTK_WIDGET( l->data ),
     910                                  proxy_enabled && proxy_auth_enabled);
     911}
     912
     913static void
     914onProxyToggled( GtkToggleButton * tb UNUSED, gpointer user_data )
     915{
     916    refreshProxySensitivity( user_data );
     917}
     918
     919static void
     920proxyPageFree( gpointer gpage )
     921{
     922    struct ProxyPage * page = gpage;
     923    g_slist_free( page->proxy_widgets );
     924    g_slist_free( page->proxy_auth_widgets );
     925    g_free( page );
     926}
     927
    892928static GtkWidget*
    893929networkPage( GObject * core )
     
    897933    GtkWidget * t;
    898934    GtkWidget * w, * w2;
     935    struct ProxyPage * page = tr_new0( struct ProxyPage, 1 );
    899936
    900937    t = hig_workarea_create( );
     
    929966        w = new_check_button( s, PREF_KEY_PROXY_SERVER_ENABLED, core );
    930967        w2 = new_entry( PREF_KEY_PROXY_SERVER, core );
     968        page->proxy_widgets = g_slist_append( page->proxy_widgets, w2 );
     969        g_signal_connect( w, "toggled", G_CALLBACK(onProxyToggled), page );
    931970        hig_workarea_add_row_w( t, &row, w, w2, NULL );
    932971
    933972        s = _( "My proxy requires _authentication" );
    934973        w = new_check_button( s, PREF_KEY_PROXY_AUTH_ENABLED, core );
     974        page->proxy_widgets = g_slist_append( page->proxy_widgets, w );
     975        g_signal_connect( w, "toggled", G_CALLBACK(onProxyToggled), page );
    935976        hig_workarea_add_wide_control( t, &row, w );
    936977
    937978        w = new_entry( PREF_KEY_PROXY_USERNAME, core );
    938         hig_workarea_add_row( t, &row, _( "_Username:" ), w, NULL );
     979        page->proxy_auth_widgets = g_slist_append( page->proxy_auth_widgets, w );
     980        w = hig_workarea_add_row( t, &row, _( "_Username:" ), w, NULL );
     981        page->proxy_auth_widgets = g_slist_append( page->proxy_auth_widgets, w );
    939982
    940983        w = new_entry( PREF_KEY_PROXY_PASSWORD, core );
    941984        gtk_entry_set_visibility( GTK_ENTRY( w ), FALSE );
    942         hig_workarea_add_row( t, &row, _( "_Password:" ), w, NULL );
     985        page->proxy_auth_widgets = g_slist_append( page->proxy_auth_widgets, w );
     986        w = hig_workarea_add_row( t, &row, _( "_Password:" ), w, NULL );
     987        page->proxy_auth_widgets = g_slist_append( page->proxy_auth_widgets, w );
    943988
    944989    hig_workarea_finish( t, &row );
     990    g_object_set_data_full( G_OBJECT( t ), "page", page, proxyPageFree );
     991
     992    refreshProxySensitivity( page );
    945993    return t;
    946994}
Note: See TracChangeset for help on using the changeset viewer.