static FileProgressStatus
show_bar (int n, long done, long total)
{
    gauge_set_value (ProgressGauge [n], (int) total, (int) done);
    gauge_show (ProgressGauge [n], 1);
    return file_progress_check_buttons ();
}
Exemplo n.º 2
0
Arquivo: filegui.c Projeto: l-4-l/mc
void
file_progress_show (file_op_context_t * ctx, off_t done, off_t total,
                    const char *stalled_msg, gboolean force_update)
{
    file_op_context_ui_t *ui;
    char buffer[BUF_TINY];

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

    ui = ctx->ui;

    if (total == 0)
    {
    	if (!speedchart_progress)
    		gauge_show (ui->progress_file_gauge, 0);
    	else
    		speedchart_show(ui->progress_file_speedchart, 0); //ctx->bps
        return;
    }

    if (!speedchart_progress) {
    	gauge_set_value (ui->progress_file_gauge, 1024, (int) (1024 * done / total));
    	gauge_show (ui->progress_file_gauge, 1);
    } else {
    	speedchart_set_value (ui->progress_file_speedchart, 1024, (int) (1024 * done / total));
    	speedchart_show (ui->progress_file_speedchart, 1);
    }

    if (!force_update)
        return;

    if (ui->showing_eta && ctx->eta_secs > 0.5)
    {
        char buffer2[BUF_TINY];

        file_eta_prepare_for_show (buffer2, ctx->eta_secs, FALSE);
        if (ctx->bps == 0)
            g_snprintf (buffer, BUF_TINY, "%s %s", buffer2, stalled_msg);
        else
        {
            char buffer3[BUF_TINY];

            file_bps_prepare_for_show (buffer3, ctx->bps);
            g_snprintf (buffer, BUF_TINY, "%s (%s) %s", buffer2, buffer3, stalled_msg);
        }
    }
    else
    {
        g_snprintf (buffer, BUF_TINY, "%s", stalled_msg);
    }

    label_set_text (ui->progress_file_label, buffer);
}
Exemplo n.º 3
0
void
file_progress_show (FileOpContext * ctx, off_t done, off_t total,
                    const char *stalled_msg, gboolean force_update)
{
    FileOpContextUI *ui;
    char buffer[BUF_TINY];
    char buffer2[BUF_TINY];
    char buffer3[BUF_TINY];

    if (!verbose)
        return;

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

    ui = ctx->ui;

    if (total == 0)
    {
        gauge_show (ui->progress_file_gauge, 0);
        return;
    }

    gauge_set_value (ui->progress_file_gauge, 1024, (int) (1024 * done / total));
    gauge_show (ui->progress_file_gauge, 1);

    if (!force_update)
        return;

    if (ui->showing_eta && ctx->eta_secs > 0.5)
    {
        file_eta_prepare_for_show (buffer2, ctx->eta_secs, FALSE);
        if (ctx->bps == 0)
            g_snprintf (buffer, BUF_TINY, "%s %s", buffer2, stalled_msg);
        else
        {
            file_bps_prepare_for_show (buffer3, ctx->bps);
            g_snprintf (buffer, BUF_TINY, "%s (%s) %s", buffer2, buffer3, stalled_msg);
        }
    }
    else
    {
        g_snprintf (buffer, BUF_TINY, "%s", stalled_msg);
    }

    label_set_text (ui->progress_file_label, buffer);
}
Exemplo n.º 4
0
Arquivo: filegui.c Projeto: artzub/mc
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);
}
Exemplo n.º 5
0
Arquivo: filegui.c Projeto: CTU-OSP/mc
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);
    }
}