int download_is_progressing( struct download *download ) { if ( download == 0 || download->state.basic != 8 ) { return 0; } return has_progress( &download->progress->estimated_time.sec ) != 0; }
static void draw_file_download(struct listbox_item *item, struct listbox_context *context, int x, int y, int width) { struct file_download *file_download = item->udata; struct download *download = &file_download->download; unsigned char *stylename; struct color_pair *color; unsigned char *text; int length; int trimmedlen; int meter = DOWNLOAD_METER_WIDTH; /* We have nothing to work with */ if (width < 4) return; stylename = (item == context->box->sel) ? "menu.selected" : ((item->marked) ? "menu.marked" : "menu.normal"); color = get_bfu_color(context->term, stylename); text = get_file_download_text(item, context->term); if (!text) return; length = strlen(text); /* Show atleast the required percentage of the URI */ if (length * DOWNLOAD_URI_PERCENTAGE / 100 < width - meter - 4) { trimmedlen = int_min(length, width - meter - 4); } else { trimmedlen = int_min(length, width - 3); } draw_text(context->term, x, y, text, trimmedlen, 0, color); if (trimmedlen < length) { draw_text(context->term, x + trimmedlen, y, "...", 3, 0, color); trimmedlen += 3; } mem_free(text); if (!download->progress || download->progress->size < 0 || !is_in_state(download->state, S_TRANS) || !has_progress(download->progress)) { /* TODO: Show trimmed error message. */ return; } if (!dialog_has_refresh(context->dlg_data)) refresh_dialog(context->dlg_data, refresh_file_download, NULL); if (trimmedlen + meter >= width) return; x += width - meter; draw_progress_bar(download->progress, context->term, x, y, meter, NULL, NULL); }