Changeset 6162 for trunk/gtk/tr-prefs.c


Ignore:
Timestamp:
Jun 12, 2008, 4:25:36 PM (14 years ago)
Author:
charles
Message:

unify the daemon and gtk client's config files so that you can easily swap back and forth between clients and keep the same torrents and preferences.

File:
1 edited

Legend:

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

    r6153 r6162  
    9494    pref_int_set_default    ( PREF_KEY_PORT, TR_DEFAULT_PORT );
    9595
    96     pref_flag_set_default   ( PREF_KEY_NAT, TRUE );
     96    pref_flag_set_default   ( PREF_KEY_PORT_FORWARDING, TRUE );
    9797    pref_flag_set_default   ( PREF_KEY_PEX, TR_DEFAULT_PEX_ENABLED );
    9898    pref_flag_set_default   ( PREF_KEY_ASKQUIT, TRUE );
    99     pref_flag_set_default   ( PREF_KEY_ENCRYPTED_ONLY, FALSE );
     99    pref_flag_set_default   ( PREF_KEY_ENCRYPTION, TR_ENCRYPTION_PREFERRED );
    100100
    101101    pref_int_set_default    ( PREF_KEY_MSGLEVEL, TR_MSG_INF );
     
    119119    pref_flag_set_default  ( PREF_KEY_RPC_AUTH_ENABLED, FALSE );
    120120
    121     pref_save( NULL );
     121    pref_save( );
    122122}
    123123
     
    192192{
    193193    GtkWidget * w = gtk_entry_new( );
    194     char * value = pref_string_get( key );
     194    const char * value = pref_string_get( key );
    195195    if( value )
    196196        gtk_entry_set_text( GTK_ENTRY( w ), value );
    197197    g_object_set_data_full( G_OBJECT(w), PREF_KEY, g_strdup(key), g_free );
    198198    g_signal_connect( w, "changed", G_CALLBACK(entry_changed_cb), core );
    199     g_free( value );
    200199    return w;
    201200}
     
    215214    GtkWidget * w = gtk_file_chooser_button_new( NULL,
    216215                                    GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER );
    217     char * path = pref_string_get( key );
     216    const char * path = pref_string_get( key );
    218217    g_object_set_data_full( G_OBJECT(w), PREF_KEY, g_strdup(key), g_free );
    219218    g_signal_connect( w, "selection-changed", G_CALLBACK(chosen_cb), core );
    220219    gtk_file_chooser_set_current_folder( GTK_FILE_CHOOSER(w), path );
    221     g_free( path );
    222220    return w;
    223221}
     
    497495}
    498496
     497static void
     498onEncryptionToggled( GtkToggleButton * w, gpointer core )
     499{
     500    const int val = gtk_toggle_button_get_active( w )
     501                  ? TR_ENCRYPTION_REQUIRED
     502                  : TR_ENCRYPTION_PREFERRED;
     503    tr_core_set_pref_int( TR_CORE( core ), PREF_KEY_ENCRYPTION, val );
     504}
     505
    499506static GtkWidget*
    500507peerPage( GObject * core, gboolean * alive )
     
    531538       
    532539        s = _("_Ignore unencrypted peers");
    533         w = new_check_button( s, PREF_KEY_ENCRYPTED_ONLY, core );
     540        w = gtk_check_button_new_with_mnemonic( s );
     541        gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(w),
     542                                      pref_int_get(PREF_KEY_ENCRYPTION)==TR_ENCRYPTION_REQUIRED );
     543        g_signal_connect( w, "toggled", G_CALLBACK(onEncryptionToggled), core );
    534544        hig_workarea_add_wide_control( t, &row, w );
    535545
     
    811821        /* access control list */
    812822        {
    813         char * val = pref_string_get( PREF_KEY_RPC_ACL );
     823        const char * val = pref_string_get( PREF_KEY_RPC_ACL );
    814824        GtkTreeModel * m = acl_tree_model_new( val );
    815825        GtkTreeViewColumn * c;
     
    853863        gtk_misc_set_alignment( GTK_MISC( w ), 0.0f, 0.1f );
    854864        page->widgets = g_slist_append( page->widgets, w );
    855         g_free( val );
    856865
    857866        /* permission column */
     
    972981
    973982        s = _("Use port _forwarding from my router" );
    974         w = new_check_button( s, PREF_KEY_NAT, core );
     983        w = new_check_button( s, PREF_KEY_PORT_FORWARDING, core );
    975984        hig_workarea_add_wide_control( t, &row, w );
    976985
Note: See TracChangeset for help on using the changeset viewer.