Mercurial > pidgin
comparison src/gtkft.c @ 4519:599d350fce4e
[gaim-migrate @ 4797]
This should work better when the speed is set sometime during a transfer
rather than before it.
committer: Tailor Script <tailor@pidgin.im>
author | Christian Hammond <chipx86@chipx86.com> |
---|---|
date | Tue, 04 Feb 2003 19:06:58 +0000 |
parents | a2b2cce63fb8 |
children | 0626ec2f2feb |
comparison
equal
deleted
inserted
replaced
4518:a6be92358df3 | 4519:599d350fce4e |
---|---|
513 double kbps = 0.0; | 513 double kbps = 0.0; |
514 time_t elapsed; | 514 time_t elapsed; |
515 int secs_remaining; | 515 int secs_remaining; |
516 | 516 |
517 data = (struct gaim_gtkxfer_ui_data *)xfer->ui_data; | 517 data = (struct gaim_gtkxfer_ui_data *)xfer->ui_data; |
518 | |
519 now = time(NULL); | |
520 kb_sent = gaim_xfer_get_bytes_sent(xfer) / 1024.0; | |
521 elapsed = (now - data->start_time); | |
522 kbps = (elapsed > 0 ? (kb_sent / elapsed) : 0); | |
523 | |
524 g_snprintf(speed_buf, sizeof(speed_buf), | |
525 _("%.2f KB/s"), kbps); | |
518 | 526 |
519 if (gaim_xfer_get_size(xfer) == 0) { | 527 if (gaim_xfer_get_size(xfer) == 0) { |
520 *speed_buf = '\0'; | |
521 strncpy(estimate_buf, _("Unknown"), sizeof(estimate_buf)); | 528 strncpy(estimate_buf, _("Unknown"), sizeof(estimate_buf)); |
522 } | 529 } |
523 else { | 530 else { |
524 now = time(NULL); | 531 kb_rem = gaim_xfer_get_bytes_remaining(xfer) / 1024.0; |
525 kb_rem = gaim_xfer_get_bytes_remaining(xfer) / 1024.0; | |
526 kb_sent = gaim_xfer_get_bytes_sent(xfer) / 1024.0; | |
527 elapsed = (now - data->start_time); | |
528 kbps = (elapsed > 0 ? (kb_sent / elapsed) : 0); | |
529 | |
530 secs_remaining = (int)(kb_rem / kbps); | 532 secs_remaining = (int)(kb_rem / kbps); |
531 | 533 |
532 if (secs_remaining <= 0) { | 534 if (secs_remaining <= 0) { |
533 GdkPixbuf *pixbuf = NULL; | 535 GdkPixbuf *pixbuf = NULL; |
534 | 536 |
550 int m = (secs_remaining % 3600) / 60; | 552 int m = (secs_remaining % 3600) / 60; |
551 int s = secs_remaining % 60; | 553 int s = secs_remaining % 60; |
552 | 554 |
553 g_snprintf(estimate_buf, sizeof(estimate_buf), | 555 g_snprintf(estimate_buf, sizeof(estimate_buf), |
554 _("%d:%02d:%02d"), h, m, s); | 556 _("%d:%02d:%02d"), h, m, s); |
555 g_snprintf(speed_buf, sizeof(speed_buf), | |
556 _("%.2f KB/s"), kbps); | |
557 } | 557 } |
558 } | 558 } |
559 | 559 |
560 gtk_list_store_set(xfer_dialog->model, &data->iter, | 560 gtk_list_store_set(xfer_dialog->model, &data->iter, |
561 COLUMN_REMAINING, gaim_xfer_get_bytes_remaining(xfer), | 561 COLUMN_REMAINING, gaim_xfer_get_bytes_remaining(xfer), |
562 COLUMN_PROGRESS, percent, | 562 COLUMN_PROGRESS, percent, |
563 COLUMN_ESTIMATE, estimate_buf, | 563 COLUMN_ESTIMATE, estimate_buf, |
564 COLUMN_SPEED, speed_buf, | 564 COLUMN_SPEED, speed_buf, |
565 COLUMN_SIZE, gaim_xfer_get_size(xfer), | |
565 -1); | 566 -1); |
566 } | 567 } |
567 | 568 |
568 static void | 569 static void |
569 gaim_gtkxfer_cancel(struct gaim_xfer *xfer) | 570 gaim_gtkxfer_cancel(struct gaim_xfer *xfer) |