Changeset 5666 for trunk/gtk/stats.c


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

add statistics "reset" button

File:
1 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) );
Note: See TracChangeset for help on using the changeset viewer.