mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05:00
[download] refresh_dialog in display_download
Results are promising, lower CPU usage while displaying download info dialog. Need to check bittorrent.
This commit is contained in:
parent
f3dffb9fd8
commit
af7bed47e6
@ -228,12 +228,20 @@ download_dialog_layouter(struct dialog_data *dlg_data)
|
|||||||
mem_free(msg);
|
mem_free(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static enum dlg_refresh_code
|
||||||
|
refresh_file_download(struct dialog_data *dlg_data, void *data)
|
||||||
|
{
|
||||||
|
/* Always refresh (until we keep finished downloads) */
|
||||||
|
return are_there_downloads() ? REFRESH_DIALOG : REFRESH_STOP;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
display_download(struct terminal *term, struct file_download *file_download,
|
display_download(struct terminal *term, struct file_download *file_download,
|
||||||
struct session *ses)
|
struct session *ses)
|
||||||
{
|
{
|
||||||
/* [gettext_accelerator_context(display_download)] */
|
/* [gettext_accelerator_context(display_download)] */
|
||||||
struct dialog *dlg;
|
struct dialog *dlg;
|
||||||
|
struct dialog_data *ret;
|
||||||
|
|
||||||
if (!is_in_downloads_list(file_download))
|
if (!is_in_downloads_list(file_download))
|
||||||
return;
|
return;
|
||||||
@ -282,9 +290,12 @@ display_download(struct terminal *term, struct file_download *file_download,
|
|||||||
add_dlg_end(dlg, DOWNLOAD_WIDGETS_COUNT - !!file_download->external_handler);
|
add_dlg_end(dlg, DOWNLOAD_WIDGETS_COUNT - !!file_download->external_handler);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
do_dialog(term, dlg, getml(dlg, (void *) NULL));
|
ret = do_dialog(term, dlg, getml(dlg, (void *) NULL));
|
||||||
}
|
|
||||||
|
|
||||||
|
if (ret) {
|
||||||
|
refresh_dialog(ret, refresh_file_download, NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* The download manager */
|
/* The download manager */
|
||||||
|
|
||||||
@ -360,12 +371,6 @@ delete_file_download(struct listbox_item *item, int last)
|
|||||||
register_bottom_half(do_abort_download, file_download);
|
register_bottom_half(do_abort_download, file_download);
|
||||||
}
|
}
|
||||||
|
|
||||||
static enum dlg_refresh_code
|
|
||||||
refresh_file_download(struct dialog_data *dlg_data, void *data)
|
|
||||||
{
|
|
||||||
/* Always refresh (until we keep finished downloads) */
|
|
||||||
return are_there_downloads() ? REFRESH_DIALOG : REFRESH_STOP;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* TODO: Make it configurable */
|
/* TODO: Make it configurable */
|
||||||
#define DOWNLOAD_METER_WIDTH 15
|
#define DOWNLOAD_METER_WIDTH 15
|
||||||
|
@ -141,8 +141,12 @@ abort_download(struct file_download *file_download)
|
|||||||
if (file_download->ses)
|
if (file_download->ses)
|
||||||
check_questions_queue(file_download->ses);
|
check_questions_queue(file_download->ses);
|
||||||
|
|
||||||
if (file_download->dlg_data)
|
if (file_download->dlg_data) {
|
||||||
|
if (file_download->dlg_data->dlg && file_download->dlg_data->dlg->refresh) {
|
||||||
|
kill_timer(&file_download->dlg_data->dlg->refresh->timer);
|
||||||
|
}
|
||||||
cancel_dialog(file_download->dlg_data, NULL);
|
cancel_dialog(file_download->dlg_data, NULL);
|
||||||
|
}
|
||||||
cancel_download(&file_download->download, file_download->stop);
|
cancel_download(&file_download->download, file_download->stop);
|
||||||
if (file_download->uri) done_uri(file_download->uri);
|
if (file_download->uri) done_uri(file_download->uri);
|
||||||
|
|
||||||
@ -481,8 +485,6 @@ download_data_store(struct download *download, struct file_download *file_downlo
|
|||||||
if_assert_failed term = file_download->term = NULL;
|
if_assert_failed term = file_download->term = NULL;
|
||||||
|
|
||||||
if (is_in_progress_state(download->state)) {
|
if (is_in_progress_state(download->state)) {
|
||||||
if (file_download->dlg_data)
|
|
||||||
redraw_dialog(file_download->dlg_data, 1);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -600,9 +602,6 @@ download_data(struct download *download, struct file_download *file_download)
|
|||||||
file_download->uri = get_uri_reference(cached->redirect);
|
file_download->uri = get_uri_reference(cached->redirect);
|
||||||
file_download->download.state = connection_state(S_WAIT_REDIR);
|
file_download->download.state = connection_state(S_WAIT_REDIR);
|
||||||
|
|
||||||
if (file_download->dlg_data)
|
|
||||||
redraw_dialog(file_download->dlg_data, 1);
|
|
||||||
|
|
||||||
load_uri(file_download->uri, cached->uri, &file_download->download,
|
load_uri(file_download->uri, cached->uri, &file_download->download,
|
||||||
PRI_DOWNLOAD, CACHE_MODE_NORMAL,
|
PRI_DOWNLOAD, CACHE_MODE_NORMAL,
|
||||||
download->progress ? download->progress->start : 0);
|
download->progress ? download->progress->start : 0);
|
||||||
|
Loading…
Reference in New Issue
Block a user