Changeset 7976


Ignore:
Timestamp:
Mar 1, 2009, 12:11:53 AM (13 years ago)
Author:
charles
Message:

(trunk gtk) add "sort by size" to the main window's list of torrents

Location:
trunk/gtk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/gtk/actions.c

    r7911 r7976  
    4545static GtkRadioActionEntry sort_radio_entries[] =
    4646{
    47     { "sort-by-activity", NULL,      N_( "Sort by _Activity" ),        NULL,
    48       NULL, 0 },
    49     { "sort-by-name",     NULL,        N_( "Sort by _Name" ),     NULL,
    50       NULL, 1 },
    51     { "sort-by-progress", NULL,        N_( "Sort by _Progress" ), NULL,
    52       NULL, 2 },
    53     { "sort-by-ratio",    NULL,        N_( "Sort by _Ratio" ),    NULL,
    54       NULL, 3 },
    55     { "sort-by-state",    NULL,        N_( "Sort by _State" ),    NULL,
    56       NULL, 4 },
    57     { "sort-by-tracker",  NULL,        N_( "Sort by _Tracker" ),  NULL,
    58       NULL, 5 },
    59     { "sort-by-age",      NULL,        N_( "Sort by A_ge" ),      NULL,
    60       NULL, 6 },
    61     { "sort-by-eta",      NULL,        N_( "Sort by _ETA" ),      NULL,
    62       NULL, 7 }
     47    { "sort-by-activity", NULL, N_( "Sort by _Activity" ), NULL, NULL, 0 },
     48    { "sort-by-name",     NULL, N_( "Sort by _Name" ),     NULL, NULL, 1 },
     49    { "sort-by-progress", NULL, N_( "Sort by _Progress" ), NULL, NULL, 2 },
     50    { "sort-by-ratio",    NULL, N_( "Sort by _Ratio" ),    NULL, NULL, 3 },
     51    { "sort-by-state",    NULL, N_( "Sort by _State" ),    NULL, NULL, 4 },
     52    { "sort-by-tracker",  NULL, N_( "Sort by _Tracker" ),  NULL, NULL, 5 },
     53    { "sort-by-age",      NULL, N_( "Sort by A_ge" ),      NULL, NULL, 6 },
     54    { "sort-by-eta",      NULL, N_( "Sort by _ETA" ),      NULL, NULL, 7 },
     55    { "sort-by-size",     NULL, N_( "Sort by Si_ze" ),     NULL, NULL, 8 }
    6356};
    6457
  • trunk/gtk/tr-core.c

    r7902 r7976  
    351351
    352352static int
    353 compareByAge( GtkTreeModel *             model,
    354               GtkTreeIter *              a,
    355               GtkTreeIter *              b,
    356               gpointer         user_data UNUSED )
     353compareByAge( GtkTreeModel * model,
     354              GtkTreeIter  * a,
     355              GtkTreeIter  * b,
     356              gpointer       user_data UNUSED )
    357357{
    358358    tr_torrent *ta, *tb;
     
    365365
    366366static int
     367compareBySize( GtkTreeModel * model,
     368               GtkTreeIter  * a,
     369               GtkTreeIter  * b,
     370               gpointer       user_data UNUSED )
     371{
     372    tr_torrent *t;
     373    const tr_info *ia, *ib;
     374
     375    gtk_tree_model_get( model, a, MC_TORRENT_RAW, &t, -1 );
     376    ia = tr_torrentInfo( t );
     377    gtk_tree_model_get( model, b, MC_TORRENT_RAW, &t, -1 );
     378    ib = tr_torrentInfo( t );
     379
     380    if( ia->totalSize < ib->totalSize ) return 1;
     381    if( ia->totalSize > ib->totalSize ) return -1;
     382    return 0;
     383}
     384
     385static int
    367386compareByProgress( GtkTreeModel *             model,
    368387                   GtkTreeIter *              a,
     
    370389                   gpointer         user_data UNUSED )
    371390{
    372     int            ret;
    373     tr_torrent *   ta, *tb;
     391    int ret;
     392    tr_torrent * t;
    374393    const tr_stat *sa, *sb;
    375394
    376     gtk_tree_model_get( model, a, MC_TORRENT_RAW, &ta, -1 );
    377     gtk_tree_model_get( model, b, MC_TORRENT_RAW, &tb, -1 );
    378     sa = tr_torrentStatCached( ta );
    379     sb = tr_torrentStatCached( tb );
     395    gtk_tree_model_get( model, a, MC_TORRENT_RAW, &t, -1 );
     396    sa = tr_torrentStatCached( t );
     397    gtk_tree_model_get( model, b, MC_TORRENT_RAW, &t, -1 );
     398    sb = tr_torrentStatCached( t );
    380399    ret = compareDouble( sa->percentDone, sb->percentDone );
    381400    if( !ret )
     
    420439
    421440static int
    422 compareByTracker( GtkTreeModel *             model,
    423                   GtkTreeIter *              a,
    424                   GtkTreeIter *              b,
    425                   gpointer         user_data UNUSED )
     441compareByTracker( GtkTreeModel * model,
     442                  GtkTreeIter  * a,
     443                  GtkTreeIter  * b,
     444                  gpointer       user_data UNUSED )
    426445{
    427446    const tr_torrent *ta, *tb;
     
    459478    else if( !strcmp( mode, "sort-by-tracker" ) )
    460479        sort_func = compareByTracker;
    461     else
    462     {
     480    else if( !strcmp( mode, "sort-by-size" ) )
     481        sort_func = compareBySize;
     482    else {
    463483        sort_func = compareByName;
    464484        type = isReversed ? GTK_SORT_DESCENDING : GTK_SORT_ASCENDING;
  • trunk/gtk/ui.h

    r7911 r7976  
    3636    "      <menuitem action='sort-by-activity'/>\n"
    3737    "      <menuitem action='sort-by-age'/>\n"
     38    "      <menuitem action='sort-by-eta'/>\n"
    3839    "      <menuitem action='sort-by-name'/>\n"
    3940    "      <menuitem action='sort-by-progress'/>\n"
    40     "      <menuitem action='sort-by-eta'/>\n"
    4141    "      <menuitem action='sort-by-ratio'/>\n"
     42    "      <menuitem action='sort-by-size'/>\n"
    4243    "      <menuitem action='sort-by-state'/>\n"
    4344    "      <menuitem action='sort-by-tracker'/>\n"
Note: See TracChangeset for help on using the changeset viewer.