Changeset 5666


Ignore:
Timestamp:
Apr 22, 2008, 2:07:42 PM (15 years ago)
Author:
charles
Message:

add statistics "reset" button

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/gtk/stats.c

    r5313 r5666  
    1616#include "stats.h"
    1717#include "tr-core.h"
     18
     19enum
     20{
     21    TR_RESPONSE_CLEAR = 1
     22};
    1823
    1924struct stat_ui
     
    7378
    7479static void
    75 dialogResponse( GtkDialog * dialog, gint response UNUSED, gpointer unused UNUSED )
     80dialogResponse( GtkDialog * dialog, gint response, gpointer gdata )
    7681{
    77     g_source_remove( GPOINTER_TO_UINT( g_object_get_data( G_OBJECT(dialog), "TrTimer" ) ) );
    78     gtk_widget_destroy( GTK_WIDGET( dialog ) );
     82    struct stat_ui * ui = gdata;
     83
     84    if( response == TR_RESPONSE_CLEAR )
     85    {
     86        tr_handle * handle = tr_core_handle( ui->core );
     87        tr_clearSessionStats( handle );
     88        updateStats( ui );
     89    }
     90
     91    if( response == GTK_RESPONSE_CLOSE )
     92    {
     93        g_source_remove( GPOINTER_TO_UINT( g_object_get_data( G_OBJECT(dialog), "TrTimer" ) ) );
     94        gtk_widget_destroy( GTK_WIDGET( dialog ) );
     95    }
    7996}
    8097
     
    92109                                     parent,
    93110                                     GTK_DIALOG_DESTROY_WITH_PARENT,
     111                                     GTK_STOCK_CLEAR, TR_RESPONSE_CLEAR,
    94112                                     GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
    95113                                     NULL );
     
    124142    updateStats( ui );
    125143    g_object_set_data_full( G_OBJECT(d), "data", ui, g_free );
    126     g_signal_connect( d, "response", G_CALLBACK(dialogResponse), NULL );
     144    g_signal_connect( d, "response", G_CALLBACK(dialogResponse), ui );
    127145    i = g_timeout_add( 1000, updateStats, ui );
    128146    g_object_set_data( G_OBJECT(d), "TrTimer", GUINT_TO_POINTER(i) );
  • trunk/libtransmission/stats.c

    r5643 r5666  
    1010 * $Id$
    1111 */
    12 
    13 #include <string.h> /* memset */
    1412
    1513#include "transmission.h"
     
    163161}
    164162
     163void
     164tr_clearSessionStats( tr_handle * handle )
     165{
     166    tr_session_stats zero;
     167    zero.uploadedBytes = 0;
     168    zero.downloadedBytes = 0;
     169    zero.ratio = TR_RATIO_NA;
     170    zero.filesAdded = 0;
     171    zero.sessionCount = 0;
     172    zero.secondsActive = 0;
     173    handle->sessionStats->single = handle->sessionStats->old = zero;
     174
     175    handle->sessionStats->startTime = time( NULL );
     176}
     177
    165178/**
    166179***
  • trunk/libtransmission/transmission.h

    r5600 r5666  
    135135                                   tr_session_stats  * setme );
    136136
     137void tr_clearSessionStats( tr_handle * handle );
     138
    137139
    138140/**
Note: See TracChangeset for help on using the changeset viewer.