mirror of
https://github.com/transmission/transmission
synced 2025-01-03 13:35:36 +00:00
add statistics "reset" button
This commit is contained in:
parent
e87906e5a6
commit
0c1599608d
3 changed files with 39 additions and 6 deletions
22
gtk/stats.c
22
gtk/stats.c
|
@ -16,6 +16,11 @@
|
|||
#include "stats.h"
|
||||
#include "tr-core.h"
|
||||
|
||||
enum
|
||||
{
|
||||
TR_RESPONSE_CLEAR = 1
|
||||
};
|
||||
|
||||
struct stat_ui
|
||||
{
|
||||
GtkWidget * one_up_lb;
|
||||
|
@ -72,10 +77,22 @@ updateStats( gpointer gdata )
|
|||
}
|
||||
|
||||
static void
|
||||
dialogResponse( GtkDialog * dialog, gint response UNUSED, gpointer unused UNUSED )
|
||||
dialogResponse( GtkDialog * dialog, gint response, gpointer gdata )
|
||||
{
|
||||
struct stat_ui * ui = gdata;
|
||||
|
||||
if( response == TR_RESPONSE_CLEAR )
|
||||
{
|
||||
tr_handle * handle = tr_core_handle( ui->core );
|
||||
tr_clearSessionStats( handle );
|
||||
updateStats( ui );
|
||||
}
|
||||
|
||||
if( response == GTK_RESPONSE_CLOSE )
|
||||
{
|
||||
g_source_remove( GPOINTER_TO_UINT( g_object_get_data( G_OBJECT(dialog), "TrTimer" ) ) );
|
||||
gtk_widget_destroy( GTK_WIDGET( dialog ) );
|
||||
}
|
||||
}
|
||||
|
||||
GtkWidget*
|
||||
|
@ -91,6 +108,7 @@ stats_dialog_create( GtkWindow * parent, TrCore * core )
|
|||
d = gtk_dialog_new_with_buttons( _("Statistics"),
|
||||
parent,
|
||||
GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||
GTK_STOCK_CLEAR, TR_RESPONSE_CLEAR,
|
||||
GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
|
||||
NULL );
|
||||
t = hig_workarea_create( );
|
||||
|
@ -123,7 +141,7 @@ stats_dialog_create( GtkWindow * parent, TrCore * core )
|
|||
|
||||
updateStats( ui );
|
||||
g_object_set_data_full( G_OBJECT(d), "data", ui, g_free );
|
||||
g_signal_connect( d, "response", G_CALLBACK(dialogResponse), NULL );
|
||||
g_signal_connect( d, "response", G_CALLBACK(dialogResponse), ui );
|
||||
i = g_timeout_add( 1000, updateStats, ui );
|
||||
g_object_set_data( G_OBJECT(d), "TrTimer", GUINT_TO_POINTER(i) );
|
||||
return d;
|
||||
|
|
|
@ -10,8 +10,6 @@
|
|||
* $Id$
|
||||
*/
|
||||
|
||||
#include <string.h> /* memset */
|
||||
|
||||
#include "transmission.h"
|
||||
#include "bencode.h"
|
||||
#include "platform.h" /* tr_getConfigDir() */
|
||||
|
@ -162,6 +160,21 @@ tr_getCumulativeSessionStats( const tr_handle * handle,
|
|||
addStats( setme, &getStats(handle)->old, ¤t );
|
||||
}
|
||||
|
||||
void
|
||||
tr_clearSessionStats( tr_handle * handle )
|
||||
{
|
||||
tr_session_stats zero;
|
||||
zero.uploadedBytes = 0;
|
||||
zero.downloadedBytes = 0;
|
||||
zero.ratio = TR_RATIO_NA;
|
||||
zero.filesAdded = 0;
|
||||
zero.sessionCount = 0;
|
||||
zero.secondsActive = 0;
|
||||
handle->sessionStats->single = handle->sessionStats->old = zero;
|
||||
|
||||
handle->sessionStats->startTime = time( NULL );
|
||||
}
|
||||
|
||||
/**
|
||||
***
|
||||
**/
|
||||
|
|
|
@ -134,6 +134,8 @@ void tr_getSessionStats( const tr_handle * handle,
|
|||
void tr_getCumulativeSessionStats( const tr_handle * handle,
|
||||
tr_session_stats * setme );
|
||||
|
||||
void tr_clearSessionStats( tr_handle * handle );
|
||||
|
||||
|
||||
/**
|
||||
***
|
||||
|
|
Loading…
Reference in a new issue