Exemple #1
0
static void
file_eta_prepare_for_show (char *buffer, double eta_secs, gboolean always_show)
{
    char _fmt_buff[BUF_TINY];
    if (eta_secs <= 0.5 && !always_show)
    {
        *buffer = '\0';
        return;
    }
    if (eta_secs <= 0.5)
        eta_secs = 1;
    file_frmt_time (_fmt_buff, eta_secs);
    g_snprintf (buffer, BUF_TINY, _("ETA %s"), _fmt_buff);
}
Exemple #2
0
void
file_progress_show_total (FileOpTotalContext * tctx, FileOpContext * ctx, uintmax_t copyed_bytes,
                          gboolean show_summary)
{
    char buffer[BUF_TINY];
    char buffer2[BUF_TINY];
    char buffer3[BUF_TINY];
    char buffer4[BUF_TINY];
    struct timeval tv_current;
    FileOpContextUI *ui;

    g_return_if_fail (ctx != NULL);
    g_return_if_fail (ctx->ui != NULL);

    ui = ctx->ui;

    if (ctx->progress_bytes != 0)
    {
        gauge_set_value (ui->progress_total_gauge, 1024,
                         (int) (1024 * copyed_bytes / ctx->progress_bytes));
        gauge_show (ui->progress_total_gauge, 1);
    }
    else
        gauge_show (ui->progress_total_gauge, 0);

    if (!show_summary && tctx->bps == 0)
        return;

    gettimeofday (&tv_current, NULL);
    file_frmt_time (buffer2, tv_current.tv_sec - tctx->transfer_start.tv_sec);
    file_eta_prepare_for_show (buffer3, tctx->eta_secs, TRUE);
    file_bps_prepare_for_show (buffer4, (long) tctx->bps);

    g_snprintf (buffer, BUF_TINY, _("Time: %s  %s (%s)"), buffer2, buffer3, buffer4);
    label_set_text (ui->time_label, buffer);

    size_trunc_len (buffer2, 5, tctx->copyed_bytes, 0, panels_options.kilobyte_si);
    size_trunc_len (buffer3, 5, ctx->progress_bytes, 0, panels_options.kilobyte_si);

    g_snprintf (buffer, BUF_TINY, _("Total: %s of %s"), buffer2, buffer3);

    label_set_text (ui->total_bytes_label, buffer);
}
Exemple #3
0
void
file_progress_show_total (FileOpTotalContext * tctx, file_op_context_t * ctx,
                          uintmax_t copied_bytes, gboolean show_summary)
{
    char buffer[BUF_TINY];
    char buffer2[BUF_TINY];
    char buffer3[BUF_TINY];
    file_op_context_ui_t *ui;

    if (ctx == NULL || ctx->ui == NULL)
        return;

    ui = ctx->ui;

    if (ui->progress_total_gauge != NULL)
    {
        if (ctx->progress_bytes == 0)
            gauge_show (ui->progress_total_gauge, 0);
        else
        {
            gauge_set_value (ui->progress_total_gauge, 1024,
                             (int) (1024 * copied_bytes / ctx->progress_bytes));
            gauge_show (ui->progress_total_gauge, 1);
        }
    }

    if (!show_summary && tctx->bps == 0)
        return;

    if (ui->time_label != NULL)
    {
        struct timeval tv_current;
        char buffer4[BUF_TINY];

        gettimeofday (&tv_current, NULL);
        file_frmt_time (buffer2, tv_current.tv_sec - tctx->transfer_start.tv_sec);

        if (ctx->progress_totals_computed)
        {
            file_eta_prepare_for_show (buffer3, tctx->eta_secs, TRUE);
            if (tctx->bps == 0)
                g_snprintf (buffer, BUF_TINY, _("Time: %s %s"), buffer2, buffer3);
            else
            {

                file_bps_prepare_for_show (buffer4, (long) tctx->bps);
                g_snprintf (buffer, BUF_TINY, _("Time: %s %s (%s)"), buffer2, buffer3, buffer4);
            }
        }
        else
        {
            if (tctx->bps == 0)
                g_snprintf (buffer, BUF_TINY, _("Time: %s"), buffer2);
            else
            {
                file_bps_prepare_for_show (buffer4, (long) tctx->bps);
                g_snprintf (buffer, BUF_TINY, _("Time: %s (%s)"), buffer2, buffer4);
            }
        }

        label_set_text (ui->time_label, buffer);
    }

    if (ui->total_bytes_label != NULL)
    {
        size_trunc_len (buffer2, 5, tctx->copied_bytes, 0, panels_options.kilobyte_si);
        if (!ctx->progress_totals_computed)
            g_snprintf (buffer, BUF_TINY, _(" Total: %s "), buffer2);
        else
        {
            size_trunc_len (buffer3, 5, ctx->progress_bytes, 0, panels_options.kilobyte_si);
            g_snprintf (buffer, BUF_TINY, _(" Total: %s/%s "), buffer2, buffer3);
        }

        hline_set_text (ui->total_bytes_label, buffer);
    }
}