Changeset 11086 for trunk/gtk/tr-core.c


Ignore:
Timestamp:
Aug 1, 2010, 5:43:35 PM (12 years ago)
Author:
Longinus00
Message:

(trunk) #3471:Add 'finished' to filterbar

File:
1 edited

Legend:

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

    r11067 r11086  
    553553}
    554554
     555static char *
     556torrentTrackerString( tr_torrent * tor )
     557{
     558    int i;
     559    GString * str = g_string_new( "" );
     560    const tr_info * inf = tr_torrentInfo( tor );
     561
     562    for( i = 0; i < inf->trackerCount; ++i )
     563    {
     564        const tr_tracker_info * t = &inf->trackers[i];
     565        str = g_string_append( str, t->announce );
     566    }
     567
     568    return g_string_free( str, FALSE );
     569}
     570
    555571#ifdef HAVE_GIO
    556572
     
    780796                      G_TYPE_DOUBLE,    /* tr_stat.pieceUploadSpeed_KBps */
    781797                      G_TYPE_DOUBLE,    /* tr_stat.pieceDownloadSpeed_KBps */
    782                       G_TYPE_INT };     /* tr_stat.status */
     798                      G_TYPE_INT,       /* tr_stat.activity */
     799                      G_TYPE_UCHAR,     /* tr_stat.finished */
     800                      G_TYPE_CHAR,      /* tr_priority_t */
     801                      G_TYPE_STRING };  /* concatenated trackers string */
    783802
    784803    p = self->priv = G_TYPE_INSTANCE_GET_PRIVATE( self,
     
    887906    tr_torrent *    tor = tr_torrent_handle( gtor );
    888907    char *          collated = g_utf8_strdown( inf->name, -1 );
     908    char *          trackers = torrentTrackerString( tor );
    889909    GtkListStore *  store = GTK_LIST_STORE( tr_core_model( self ) );
    890910    GtkTreeIter     unused;
     
    898918                                       MC_SPEED_DOWN,    st->pieceDownloadSpeed_KBps,
    899919                                       MC_ACTIVITY,      st->activity,
     920                                       MC_FINISHED,      st->finished,
     921                                       MC_PRIORITY,      tr_torrentGetPriority( tor ),
     922                                       MC_TRACKERS,      trackers,
    900923                                       -1 );
    901924
     
    906929    g_object_unref( G_OBJECT( gtor ) );
    907930    g_free( collated );
     931    g_free( trackers );
    908932}
    909933
     
    12971321{
    12981322    int oldActivity, newActivity;
     1323    tr_bool oldFinished, newFinished;
     1324    tr_priority_t oldPriority, newPriority;
     1325    char * oldTrackers, * newTrackers;
    12991326    double oldUpSpeed, newUpSpeed;
    13001327    double oldDownSpeed, newDownSpeed;
    13011328    const tr_stat * st;
    13021329    TrTorrent * gtor;
     1330    tr_torrent * tor;
    13031331
    13041332    /* get the old states */
     
    13061334                        MC_TORRENT, &gtor,
    13071335                        MC_ACTIVITY, &oldActivity,
     1336                        MC_FINISHED, &oldFinished,
     1337                        MC_PRIORITY, &oldPriority,
     1338                        MC_TRACKERS, &oldTrackers,
    13081339                        MC_SPEED_UP, &oldUpSpeed,
    13091340                        MC_SPEED_DOWN, &oldDownSpeed,
     
    13111342
    13121343    /* get the new states */
    1313     st = tr_torrentStat( tr_torrent_handle( gtor ) );
     1344    tor = tr_torrent_handle( gtor );
     1345    st = tr_torrentStat( tor );
    13141346    newActivity = st->activity;
     1347    newFinished = st->finished;
     1348    newPriority = tr_torrentGetPriority( tor );
     1349    newTrackers = torrentTrackerString( tor );
    13151350    newUpSpeed = st->pieceUploadSpeed_KBps;
    13161351    newDownSpeed = st->pieceDownloadSpeed_KBps;
     
    13191354       so don't do it unless something's actually changed... */
    13201355    if( ( newActivity  != oldActivity  )
     1356        || ( newFinished != oldFinished )
     1357        || ( newPriority != oldPriority )
     1358        || tr_strcmp( oldTrackers, newTrackers )
    13211359        || gtr_compare_double( newUpSpeed, oldUpSpeed, 3 )
    13221360        || gtr_compare_double( newDownSpeed, oldDownSpeed, 3 ) )
     
    13241362        gtk_list_store_set( GTK_LIST_STORE( model ), iter,
    13251363                            MC_ACTIVITY, newActivity,
     1364                            MC_FINISHED, newFinished,
     1365                            MC_PRIORITY, newPriority,
     1366                            MC_TRACKERS, newTrackers,
    13261367                            MC_SPEED_UP, newUpSpeed,
    13271368                            MC_SPEED_DOWN, newDownSpeed,
     
    13311372    /* cleanup */
    13321373    g_object_unref( gtor );
     1374    g_free( newTrackers );
     1375    g_free( oldTrackers );
    13331376    return FALSE;
    13341377}
Note: See TracChangeset for help on using the changeset viewer.