Changeset 5994


Ignore:
Timestamp:
Jun 2, 2008, 4:41:55 AM (14 years ago)
Author:
charles
Message:

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

Location:
trunk
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/gtk/actions.c

    r5832 r5994  
    5050  { "sort-by-ratio",      NULL, N_("Sort by _Ratio"),      NULL, NULL, 3 },
    5151  { "sort-by-state",      NULL, N_("Sort by _State"),      NULL, NULL, 4 },
    52   { "sort-by-tracker",    NULL, N_("Sort by _Tracker"),    NULL, NULL, 5 }
     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 }
    5354};
    5455
  • trunk/gtk/hig.c

    r5036 r5994  
    3535
    3636void
     37hig_workarea_add_section_title_widget( GtkWidget * t,
     38                                       int       * row,
     39                                       GtkWidget * w )
     40{
     41    gtk_table_attach( GTK_TABLE( t ), w, 0, 2, *row, *row+1, ~0, 0, 0, 0 );
     42    ++*row;
     43}
     44
     45void
    3746hig_workarea_add_section_title( GtkWidget   * t,
    3847                                int         * row,
     
    4655    gtk_misc_set_alignment( GTK_MISC( l ), 0.0f, 0.5f );
    4756    gtk_label_set_use_markup( GTK_LABEL( l ), TRUE );
    48     gtk_table_attach( GTK_TABLE( t ), l, 0, 2, *row, *row+1, ~0, 0, 0, 0 );
    49     ++*row;
     57    hig_workarea_add_section_title_widget( t, row, l );
    5058}
    5159
  • trunk/gtk/hig.h

    r5036 r5994  
    2525void hig_workarea_add_section_divider( GtkWidget   * table,
    2626                                       int         * row );
     27
     28void hig_workarea_add_section_title_widget( GtkWidget * t,
     29                                            int       * row,
     30                                            GtkWidget * w );
    2731
    2832void hig_workarea_add_section_title( GtkWidget   * table,
  • trunk/gtk/makemeta-ui.c

    r5991 r5994  
    212212
    213213    if( !filename )
    214         g_snprintf( buf, sizeof( buf ), _( "No files selected" ) );
     214        g_snprintf( buf, sizeof( buf ), _( "No source selected" ) );
    215215    else
    216216        g_snprintf( buf, sizeof(buf), "%s.torrent (%d%%)", filename, 0 );
     
    219219
    220220    if( !filename )
    221         g_snprintf( buf, sizeof( buf ), _( "<i>No files selected</i>" ) );
     221        g_snprintf( buf, sizeof( buf ), _( "<i>No source selected</i>" ) );
    222222    else {
    223223        tr_strlsize( sizeStr, builder->totalSize, sizeof(sizeStr) );
     
    306306{
    307307    int row = 0;
    308     GtkWidget *d, *t, *w, *h, *h2, *v, *focusMe;
     308    GtkWidget *d, *t, *w, *h, *h2, *v, *focusMe, *extras;
    309309    GtkBox * main_vbox;
    310310    MakeMetaUI * ui = g_new0 ( MakeMetaUI, 1 );
     
    314314                                     parent,
    315315                                     GTK_DIALOG_DESTROY_WITH_PARENT,
    316                                      GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
    317316                                     GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
    318317                                     GTK_STOCK_NEW, GTK_RESPONSE_ACCEPT,
     318                                     GTK_STOCK_STOP, GTK_RESPONSE_CANCEL,
    319319                                     NULL );
    320320    g_signal_connect( d, "response", G_CALLBACK(response_cb), ui );
     
    335335        h2 = gtk_hbox_new( FALSE, GUI_PAD_SMALL );
    336336        w = ui->size_lb = gtk_label_new (NULL);
    337         gtk_label_set_markup ( GTK_LABEL(w), _( "<i>No files selected</i>" ) );
     337        gtk_label_set_markup ( GTK_LABEL(w), _( "<i>No source selected</i>" ) );
    338338        gtk_box_pack_start( GTK_BOX(h2), w, FALSE, FALSE, GUI_PAD_SMALL );
    339339        w = ui->pieces_lb = gtk_label_new (NULL);
     
    363363
    364364    hig_workarea_add_section_divider( t, &row );
    365     hig_workarea_add_section_title( t, &row, _( "Options" ) );
    366 
     365    w = extras = gtk_expander_new_with_mnemonic( _( "<b>E_xtras</b>" ) );
     366    gtk_expander_set_use_markup( GTK_EXPANDER( w ), TRUE );
     367    hig_workarea_add_section_title_widget( t, &row, w );
     368
     369        {
     370        int row2 = 0;
     371        GtkWidget * t2 = hig_workarea_create( );
    367372        w = ui->comment_entry = gtk_entry_new( );
    368         hig_workarea_add_row (t, &row, _( "Commen_t:" ), w, NULL );
    369 
    370         w = hig_workarea_add_wide_checkbutton( t, &row, _( "_Private torrent" ), FALSE );
     373        hig_workarea_add_row( t2, &row2, _( "Commen_t:" ), w, NULL );
     374        w = hig_workarea_add_wide_checkbutton( t2, &row2, _( "_Private torrent" ), FALSE );
    371375        ui->private_check = w;
    372  
     376        hig_workarea_finish( t2, &row2 );
     377        gtk_container_add( GTK_CONTAINER( extras ), t2 );
     378        }
    373379
    374380    hig_workarea_finish( t, &row );
     
    380386   
    381387        ui->progressbar = gtk_progress_bar_new( );
    382         gtk_progress_bar_set_text( GTK_PROGRESS_BAR( ui->progressbar), _( "No files selected" ) );
     388        gtk_progress_bar_set_text( GTK_PROGRESS_BAR( ui->progressbar), _( "No source selected" ) );
    383389        gtk_container_add( GTK_CONTAINER( w ), ui->progressbar );
    384390
    385     gtk_box_pack_start( main_vbox, w, FALSE, FALSE, GUI_PAD_BIG );
     391    gtk_box_pack_start( main_vbox, w, FALSE, FALSE, 0 );
    386392
    387393    gtk_window_set_default_size( GTK_WINDOW(d), 500, 0 );
  • trunk/gtk/tr-core.c

    r5975 r5994  
    212212
    213213static int
     214compareTime( time_t a, time_t b )
     215{
     216    if( a < b ) return -1;
     217    if( a > b ) return 1;
     218    return 0;
     219}
     220
     221static int
    214222compareByRatio( GtkTreeModel * model,
    215223                GtkTreeIter  * a,
     
    269277    g_free( ca );
    270278    return ret;
     279}
     280
     281static int
     282compareByAge( GtkTreeModel   * model,
     283              GtkTreeIter    * a,
     284              GtkTreeIter    * b,
     285              gpointer         user_data UNUSED )
     286{
     287    tr_torrent *ta, *tb;
     288    gtk_tree_model_get( model, a, MC_TORRENT_RAW, &ta, -1 );
     289    gtk_tree_model_get( model, b, MC_TORRENT_RAW, &tb, -1 );
     290    return compareTime( tr_torrentStatCached(ta)->addedDate,
     291                        tr_torrentStatCached(tb)->addedDate );
    271292}
    272293
     
    333354    if( !strcmp( mode, "sort-by-activity" ) )
    334355        sort_func = compareByActivity;
     356    else if( !strcmp( mode, "sort-by-age" ) )
     357        sort_func = compareByAge;
    335358    else if( !strcmp( mode, "sort-by-progress" ) )
    336359        sort_func = compareByProgress;
  • trunk/gtk/ui.h

    r5760 r5994  
    3333"      <separator/>\n"
    3434"      <menuitem action='sort-by-activity'/>\n"
     35"      <menuitem action='sort-by-age'/>\n"
    3536"      <menuitem action='sort-by-name'/>\n"
    3637"      <menuitem action='sort-by-progress'/>\n"
  • trunk/libtransmission/resume.c

    r5959 r5994  
    3636#define KEY_SPEEDLIMIT   "speed-limit"
    3737#define KEY_UPLOADED     "uploaded"
     38#define KEY_ADDED_DATE   "added-date"
    3839
    3940#define KEY_SPEEDLIMIT_DOWN_SPEED "down-speed"
     
    360361    tr_bencDictAddInt( &top, KEY_PAUSED,
    361362                             tor->isRunning ? 0 : 1 );
     363    tr_bencDictAddInt( &top, KEY_ADDED_DATE,
     364                             tor->addedDate );
    362365    savePeers( &top, tor );
    363366    savePriorities( &top, tor );
     
    436439        tor->isRunning = i ? 0 : 1;
    437440        fieldsLoaded |= TR_FR_RUN;
     441    }
     442
     443    if( ( fieldsToLoad & TR_FR_ADDED_DATE )
     444        && tr_bencDictFindInt( &top, KEY_ADDED_DATE, &i ) ) {
     445        tor->addedDate = i;
     446        fieldsLoaded |= TR_FR_ADDED_DATE;
    438447    }
    439448
  • trunk/libtransmission/resume.h

    r5959 r5994  
    2626  TR_FR_RUN           = (1<<8),
    2727  TR_FR_DOWNLOAD_DIR  = (1<<9),
    28   TR_FR_MAX_PEERS     = (1<<10)
     28  TR_FR_MAX_PEERS     = (1<<10),
     29  TR_FR_ADDED_DATE    = (1<<11)
    2930};
    3031
  • trunk/libtransmission/torrent.c

    r5987 r5994  
    475475    tor->checkedPieces = tr_bitfieldNew( tor->info.pieceCount );
    476476    tr_torrentUncheck( tor );
     477
     478    tor->addedDate = time( NULL ); /* this is a default value to be
     479                                      overwritten by the resume file */
    477480    loaded = tr_torrentLoadResume( tor, ~0, ctor );
    478481   
     
    737740    s->startDate = tor->startDate;
    738741    s->activityDate = tor->activityDate;
     742    s->addedDate = tor->addedDate;
    739743
    740744    s->corruptEver     = tor->corruptCur    + tor->corruptPrev;
  • trunk/libtransmission/torrent.h

    r5924 r5994  
    160160    uint64_t                   corruptPrev;
    161161
     162    time_t                     addedDate;
    162163    time_t                     startDate;
    163164    time_t                     activityDate;
  • trunk/libtransmission/transmission.h

    r5988 r5994  
    12141214    /** TR_RATIO_INF, TR_RATIO_NA, or a regular ratio */
    12151215    float ratio;
     1216
     1217    /** When the torrent was first added. */
     1218    time_t addedDate;
    12161219   
    12171220    /** When the torrent was last started. */
Note: See TracChangeset for help on using the changeset viewer.