aboutsummaryrefslogtreecommitdiffstats
path: root/gtk/progress_dlg.c
diff options
context:
space:
mode:
authorUlf Lamping <ulf.lamping@web.de>2004-01-02 13:27:00 +0000
committerUlf Lamping <ulf.lamping@web.de>2004-01-02 13:27:00 +0000
commit976b0a3be32b6883844b3ea444746905a8e4ad5c (patch)
tree89457a8b238b714d030217522012ecd302a79113 /gtk/progress_dlg.c
parent5a0a6d9cd1c68abe23420f8f4664274177b92f4a (diff)
From Didier: don't update the progress bar more often than every 100ms
svn path=/trunk/; revision=9522
Diffstat (limited to 'gtk/progress_dlg.c')
-rw-r--r--gtk/progress_dlg.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/gtk/progress_dlg.c b/gtk/progress_dlg.c
index e56dc8c36d..35b4189673 100644
--- a/gtk/progress_dlg.c
+++ b/gtk/progress_dlg.c
@@ -1,7 +1,7 @@
/* progress_dlg.c
* Routines for progress-bar (modal) dialog
*
- * $Id: progress_dlg.c,v 1.18 2003/12/23 00:16:46 ulfl Exp $
+ * $Id: progress_dlg.c,v 1.19 2004/01/02 13:27:00 ulfl Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -26,6 +26,8 @@
# include "config.h"
#endif
+#include <string.h>
+
#include <gtk/gtk.h>
#include "gtkglobals.h"
#include "dlg_utils.h"
@@ -43,6 +45,8 @@ static void stop_cb(GtkWidget *w, gpointer data);
struct progdlg {
GtkWidget *dlg_w; /* top-level window widget */
GTimeVal start_time;
+ GTimeVal last_time; /* last time it was updated */
+
GtkLabel *status_lb;
GtkLabel *elapsed_lb;
GtkLabel *time_left_lb;
@@ -215,6 +219,7 @@ create_progress_dlg(const gchar *task_title, const gchar *item_title,
dlg->dlg_w = dlg_w;
g_get_current_time(&dlg->start_time);
+ memset(&dlg->last_time, 0, sizeof(dlg->last_time));
return dlg;
}
@@ -333,12 +338,21 @@ update_progress_dlg(progdlg_t *dlg, gfloat percentage, gchar *status)
/* calculate some timing values */
g_get_current_time(&time_now);
+
+ delta_time = (time_now.tv_sec - dlg->last_time.tv_sec) * 1e6 +
+ time_now.tv_usec - dlg->last_time.tv_usec;
+
+ /* after the first time don't update more than every 100ms */
+ if (dlg->last_time.tv_sec && delta_time < 100*1000)
+ return;
+ dlg->last_time = time_now;
delta_time = (time_now.tv_sec - dlg->start_time.tv_sec) * 1e6 +
time_now.tv_usec - dlg->start_time.tv_usec;
+
ul_percentage = (gulong) (percentage * 100);
ul_elapsed = (gulong) (delta_time / 1000 / 1000);
-
+
/* update labels */
g_snprintf(tmp, sizeof(tmp), "%lu%% of %s", ul_percentage, dlg->title);
gtk_window_set_title(GTK_WINDOW(dlg_w), tmp);