diff -ur gnome-bluetooth-0.5.1/obex/gnome-obex-send.c gnome-bluetooth-0.5.1a/obex/gnome-obex-send.c --- gnome-bluetooth-0.5.1/obex/gnome-obex-send.c 2004-06-04 19:28:00.000000000 +0100 +++ gnome-bluetooth-0.5.1a/obex/gnome-obex-send.c 2004-10-25 00:36:00.937169868 +0100 @@ -46,6 +46,8 @@ GnomeProgram *prog; gchar *data; gchar *error; + GTimer *xfer_timer; + gsize xfer_size; } MyApp; #define GLADE_FILE DATA_DIR "/gnome-obex-send.glade" @@ -94,9 +96,18 @@ { GladeXML *xml=app->xml; GtkWidget *bar; + + gchar *rate_string; + gdouble rate = 0; + gdouble frac = btctl_obex_client_progress (app->obex); bar = glade_xml_get_widget (xml, "progressbar1"); gtk_progress_bar_set_fraction( GTK_PROGRESS_BAR (bar), frac); + if (g_timer_elapsed(app->xfer_timer, 0) > 0) + rate = (frac * app->xfer_size) / g_timer_elapsed(app->xfer_timer, 0) / 1024; + rate_string = g_strdup_printf(" %.2f KB/s", rate); + gtk_progress_bar_set_text(GTK_PROGRESS_BAR(bar), rate_string); + g_free(rate_string); } static void @@ -152,6 +163,7 @@ bname = g_path_get_basename (fname); label = glade_xml_get_widget (app->xml, "filename_label"); gtk_label_set_text (GTK_LABEL (label), bname); + app->xfer_size = len; btctl_obex_client_push_data (app->obex, bname, app->data, len); /* TODO: check error return here from command submit */ @@ -175,7 +187,10 @@ connected_callback (BtctlObexClient *bo, gchar * bdaddr, gpointer data) { /* OBEX connect has succeeded, so start sending */ - g_idle_add ((GSourceFunc) send_one, data); + MyApp *app = (MyApp *)data; + g_timer_reset(app->xfer_timer); + g_timer_start(app->xfer_timer); + g_idle_add ((GSourceFunc) send_one, data); } static void @@ -242,6 +257,8 @@ app = g_new0 (MyApp, 1); + app->xfer_timer = g_timer_new(); + bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); @@ -307,6 +324,9 @@ g_object_unref (app->obex); } + if (app->xfer_timer) + g_timer_destroy(app->xfer_timer); + if (app->data) g_free (app->data);