From: Mark D. <the...@us...> - 2005-10-31 05:52:30
|
Update of /cvsroot/gaim/gaim/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21902/src Modified Files: gtkft.c Log Message: sf patch #1292363, from John Eckerdal Don't update the file transfer dialog more than once per second (it made stuff use a lot of CPU) Index: gtkft.c =================================================================== RCS file: /cvsroot/gaim/gaim/src/gtkft.c,v retrieving revision 1.72 retrieving revision 1.73 diff -u -d -p -r1.72 -r1.73 --- gtkft.c 29 Oct 2005 21:11:07 -0000 1.72 +++ gtkft.c 31 Oct 2005 05:52:19 -0000 1.73 @@ -85,6 +85,7 @@ typedef struct { GtkTreeIter iter; time_t start_time; + time_t last_updated_time; time_t end_time; gboolean in_list; @@ -877,6 +878,7 @@ gaim_gtkxfer_dialog_add_xfer(GaimGtkXfer gaim_gtkxfer_dialog_show(dialog); data->start_time = time(NULL); + data->last_updated_time = 0; data->end_time = -1; type = gaim_xfer_get_type(xfer); @@ -1004,6 +1006,7 @@ gaim_gtkxfer_dialog_update_xfer(GaimGtkX GaimGtkXferUiData *data; char *size_str, *remaining_str; GtkTreeSelection *selection; + time_t current_time; g_return_if_fail(dialog != NULL); g_return_if_fail(xfer != NULL); @@ -1014,6 +1017,15 @@ gaim_gtkxfer_dialog_update_xfer(GaimGtkX if (data->in_list == FALSE) return; + current_time = time(NULL); + if (((current_time - data->last_updated_time) == 0) && + (!gaim_xfer_is_completed(xfer))) + { + /* Don't update the window more than once per second */ + return; + } + data->last_updated_time = current_time; + size_str = gaim_str_size_to_units(gaim_xfer_get_size(xfer)); remaining_str = gaim_str_size_to_units(gaim_xfer_get_bytes_remaining(xfer)); @@ -1023,7 +1035,8 @@ gaim_gtkxfer_dialog_update_xfer(GaimGtkX COLUMN_REMAINING, remaining_str, -1); - if (gaim_xfer_is_completed(xfer)) { + if (gaim_xfer_is_completed(xfer)) + { GdkPixbuf *pixbuf; pixbuf = gtk_widget_render_icon(dialog->window, @@ -1036,7 +1049,7 @@ gaim_gtkxfer_dialog_update_xfer(GaimGtkX -1); g_object_unref(pixbuf); - } + } selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(xfer_dialog->tree)); |