Changeset 8118


Ignore:
Timestamp:
Mar 30, 2009, 5:25:35 PM (13 years ago)
Author:
charles
Message:

(trunk) add a did-the-user-do-this flag to the "alt speed toggled" callback

Location:
trunk
Files:
5 edited

Legend:

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

    r8102 r8118  
    544544
    545545static void
    546 onAltSpeedToggled( tr_session * s UNUSED, tr_bool b UNUSED, void * p )
     546onAltSpeedToggled( tr_session * s UNUSED, tr_bool isEnabled UNUSED, tr_bool byUser UNUSED, void * p )
    547547{
    548548    g_idle_add( onAltSpeedToggledIdle, p );
  • trunk/libtransmission/session.c

    r8108 r8118  
    471471}
    472472
     473static void useAltSpeed( tr_session * session, tr_bool enabled, tr_bool byUser );
     474static void useAltSpeedTime( tr_session * session, tr_bool enabled, tr_bool byUser );
     475
    473476static void
    474477tr_sessionInitImpl( void * vdata )
     
    477480    int64_t j;
    478481    double  d;
    479     tr_bool useAltSpeedTime;
    480482    tr_bool found;
    481483    tr_bool boolVal;
     
    654656    found = tr_bencDictFindBool( &settings, TR_PREFS_KEY_ALT_SPEED_TIME_ENABLED, &boolVal );
    655657    assert( found );
    656     useAltSpeedTime = boolVal;
    657     tr_sessionUseAltSpeedTime( session, useAltSpeedTime );
    658 
    659     if( !useAltSpeedTime )
     658    useAltSpeedTime( session, boolVal, FALSE );
     659
     660    if( !boolVal )
    660661    {
    661662        found = tr_bencDictFindBool( &settings, TR_PREFS_KEY_ALT_SPEED_ENABLED, &boolVal );
    662663        assert( found );
    663         tr_sessionUseAltSpeed( session, boolVal );
     664        useAltSpeed( session, boolVal, FALSE );
    664665    }
    665666    else
    666         tr_sessionUseAltSpeed( session, isAltTime( session ) );
     667        useAltSpeed( session, isAltTime( session ), FALSE );
    667668
    668669    /**
     
    914915
    915916    if( session->altCallback != NULL )
    916         (*session->altCallback)( session, session->altSpeedEnabled, session->altCallbackUserData );
     917        (*session->altCallback)( session, session->altSpeedEnabled, session->altSpeedChangedByUser, session->altCallbackUserData );
    917918}
    918919
     
    954955        if( currentMinute == session->altSpeedTimeBegin )
    955956        {
    956             tr_sessionUseAltSpeed( session, TRUE );
     957            useAltSpeed( session, TRUE, FALSE );
    957958        }
    958959        else if( currentMinute == session->altSpeedTimeEnd )
    959960        {
    960             tr_sessionUseAltSpeed( session, FALSE );
     961            useAltSpeed( session, FALSE, FALSE );
    961962        }
    962963    }
     
    10371038
    10381039void
     1040useAltSpeedTime( tr_session * session, tr_bool enabled, tr_bool byUser )
     1041{
     1042    assert( tr_isSession( session ) );
     1043    assert( tr_isBool( enabled ) );
     1044    assert( tr_isBool( byUser ) );
     1045
     1046    if( session->altSpeedTimeEnabled != enabled )
     1047    {
     1048        const tr_bool isAlt = isAltTime( session );
     1049
     1050        session->altSpeedTimeEnabled = enabled;
     1051
     1052        if( enabled && session->altSpeedEnabled != isAlt )
     1053            useAltSpeed( session, isAlt, byUser );
     1054    }
     1055}
     1056void
    10391057tr_sessionUseAltSpeedTime( tr_session * s, tr_bool b )
    10401058{
    1041     assert( tr_isSession( s ) );
    1042     assert( tr_isBool( b ) );
    1043 
    1044     if( s->altSpeedTimeEnabled != b )
    1045     {
    1046         const tr_bool isAlt = isAltTime( s );
    1047 
    1048         s->altSpeedTimeEnabled = b;
    1049 
    1050         if( b && s->altSpeedEnabled != isAlt )
    1051             tr_sessionUseAltSpeed( s, isAlt );
    1052     }
     1059    useAltSpeedTime( s, b, TRUE );
    10531060}
    10541061
     
    10721079
    10731080        if( tr_sessionUsesAltSpeedTime( s ) )
    1074             tr_sessionUseAltSpeed( s, isAltTime( s ) );
     1081            useAltSpeed( s, isAltTime( s ), TRUE );
    10751082    }
    10761083}
     
    10951102
    10961103        if( tr_sessionUsesAltSpeedTime( s ) )
    1097             tr_sessionUseAltSpeed( s, isAltTime( s ) );
     1104            useAltSpeed( s, isAltTime( s ), TRUE );
    10981105    }
    10991106}
     
    11081115
    11091116void
    1110 tr_sessionUseAltSpeed( tr_session * s, tr_bool b )
     1117useAltSpeed( tr_session * s, tr_bool enabled, tr_bool byUser )
    11111118{
    11121119    assert( tr_isSession( s ) );
    1113     assert( tr_isBool( b ) );
    1114 
    1115     if( s->altSpeedEnabled != b)
    1116     {
    1117         s->altSpeedEnabled = b;
     1120    assert( tr_isBool( enabled ) );
     1121    assert( tr_isBool( byUser ) );
     1122
     1123    if( s->altSpeedEnabled != enabled)
     1124    {
     1125        s->altSpeedEnabled = enabled;
     1126        s->altSpeedChangedByUser = byUser;
    11181127   
    11191128        tr_runInEventThread( s, altSpeedToggled, s );
    11201129    }
     1130}
     1131void
     1132tr_sessionUseAltSpeed( tr_session * session, tr_bool enabled )
     1133{
     1134    useAltSpeed( session, enabled, TRUE );
    11211135}
    11221136
  • trunk/libtransmission/session.h

    r8097 r8118  
    7979    int                          altSpeedTimeEnd;
    8080    tr_bool                      altSpeedTimeEnabled;
     81    tr_bool                      altSpeedChangedByUser;
    8182
    8283    tr_altSpeedFunc            * altCallback;
  • trunk/libtransmission/transmission.h

    r8097 r8118  
    589589int      tr_sessionGetAltSpeedEnd     ( const tr_session * );
    590590
    591 typedef void ( tr_altSpeedFunc )      ( tr_session *, tr_bool active, void * );
     591typedef void ( tr_altSpeedFunc )      ( tr_session *, tr_bool active, tr_bool userDriven, void * );
    592592void     tr_sessionClearAltSpeedFunc  ( tr_session * );
    593593void     tr_sessionSetAltSpeedFunc    ( tr_session *, tr_altSpeedFunc *, void * );
  • trunk/macosx/Controller.m

    r8109 r8118  
    144144#define DONATE_URL  @"http://www.transmissionbt.com/donate.php"
    145145
    146 static void altSpeedToggledCallback(tr_session * handle UNUSED, tr_bool active, void * controller)
     146static void altSpeedToggledCallback(tr_session * handle UNUSED, tr_bool active, tr_bool byUser, void * controller)
    147147{
    148148    [(Controller *)controller performSelectorOnMainThread: @selector(altSpeedToggledCallbackIsLimited:)
Note: See TracChangeset for help on using the changeset viewer.