#981: add tr_stat.dateAdded to libT; add "sort by age" to gtk+ client

This commit is contained in:
Charles Kerr
2008-06-02 04:41:55 +00:00
parent f3a974c40e
commit 5db4ca7fa3
11 changed files with 77 additions and 16 deletions

View File

@@ -210,6 +210,14 @@ compareRatio( double a, double b )
return compareDouble( a, b );
}
static int
compareTime( time_t a, time_t b )
{
if( a < b ) return -1;
if( a > b ) return 1;
return 0;
}
static int
compareByRatio( GtkTreeModel * model,
GtkTreeIter * a,
@@ -270,6 +278,19 @@ compareByName( GtkTreeModel * model,
return ret;
}
static int
compareByAge( GtkTreeModel * model,
GtkTreeIter * a,
GtkTreeIter * b,
gpointer user_data UNUSED )
{
tr_torrent *ta, *tb;
gtk_tree_model_get( model, a, MC_TORRENT_RAW, &ta, -1 );
gtk_tree_model_get( model, b, MC_TORRENT_RAW, &tb, -1 );
return compareTime( tr_torrentStatCached(ta)->addedDate,
tr_torrentStatCached(tb)->addedDate );
}
static int
compareByProgress( GtkTreeModel * model,
GtkTreeIter * a,
@@ -332,6 +353,8 @@ setSort( TrCore * core, const char * mode, gboolean isReversed )
if( !strcmp( mode, "sort-by-activity" ) )
sort_func = compareByActivity;
else if( !strcmp( mode, "sort-by-age" ) )
sort_func = compareByAge;
else if( !strcmp( mode, "sort-by-progress" ) )
sort_func = compareByProgress;
else if( !strcmp( mode, "sort-by-ratio" ) )