now abort button becomes close button when download is completed.

svn path=/trunk/netsurf/; revision=13510
This commit is contained in:
Ole Loots 2012-03-11 15:42:41 +00:00
parent cf86788d3e
commit b01229d9cc
2 changed files with 31 additions and 19 deletions

View File

@ -64,8 +64,12 @@ static void __CDECL evnt_bt_abort_click
{
struct gui_download_window * dw = (struct gui_download_window *)data;
assert( dw != NULL );
ObjcChange( OC_FORM, win, index, ~SELECTED, TRUE);
if( dw->status != NSATARI_DOWNLOAD_CANCELED ){
ObjcChange( OC_FORM, win, index, ~SELECTED, TRUE);
if( dw->status == NSATARI_DOWNLOAD_COMPLETE
|| dw->status == NSATARI_DOWNLOAD_ERROR ) {
ApplWrite( _AESapid, WM_CLOSED, win->handle, 0,0,0,0);
}
else if( dw->status != NSATARI_DOWNLOAD_CANCELED ){
dw->abort = true;
}
}
@ -297,28 +301,35 @@ void gui_download_window_error(struct gui_download_window *dw,
}
void gui_download_window_done(struct gui_download_window *dw)
{
LOG((""));
dw->status = NSATARI_DOWNLOAD_COMPLETE;
{
OBJECT * tree;
LOG((""));
dw->status = NSATARI_DOWNLOAD_COMPLETE;
if( dw->fd != NULL ) {
fclose( dw->fd );
dw->fd = NULL;
}
OBJECT * tree = ObjcTree(OC_FORM, dw->form );
tree[DOWNLOAD_PROGRESS_DONE].ob_width = DOWNLOAD_BAR_MAX;
snprintf( (char*)&dw->lbl_percent, MAX_SLEN_LBL_PERCENT,
"%lu%s", 100, "%"
);
snprintf( (char*)&dw->lbl_done, MAX_SLEN_LBL_DONE, "%s / %s",
human_friendly_bytesize(dw->size_downloaded),
(dw->size_total>0) ? human_friendly_bytesize(dw->size_total) : human_friendly_bytesize(dw->size_downloaded)
);
ObjcString( tree, DOWNLOAD_LBL_BYTES, (char*)&dw->lbl_done );
ObjcString( tree, DOWNLOAD_LBL_PERCENT, (char*)&dw->lbl_percent );
ObjcChange( OC_FORM, dw->form, DOWNLOAD_BT_ABORT, DISABLED, FALSE);
snd_rdw( dw->form );
tree = ObjcTree(OC_FORM, dw->form );
if( (tree[DOWNLOAD_CB_CLOSE_RDY].ob_state & SELECTED) != 0 ) {
ApplWrite( _AESapid, WM_CLOSED, dw->form->handle, 0,0,0,0);
} else {
tree[DOWNLOAD_PROGRESS_DONE].ob_width = DOWNLOAD_BAR_MAX;
snprintf( (char*)&dw->lbl_percent, MAX_SLEN_LBL_PERCENT,
"%lu%s", 100, "%"
);
snprintf( (char*)&dw->lbl_done, MAX_SLEN_LBL_DONE, "%s / %s",
human_friendly_bytesize(dw->size_downloaded),
(dw->size_total>0) ? human_friendly_bytesize(dw->size_total) : human_friendly_bytesize(dw->size_downloaded)
);
ObjcString( tree, DOWNLOAD_LBL_BYTES, (char*)&dw->lbl_done );
ObjcString( tree, DOWNLOAD_LBL_PERCENT, (char*)&dw->lbl_percent );
ObjcString( tree, DOWNLOAD_BT_ABORT, (char*)"Close" );
snd_rdw( dw->form );
}
gui_window_set_status(input_window, messages_get("Done") );
}

View File

@ -22,7 +22,8 @@
#define MAX_SLEN_LBL_DONE 64
#define MAX_SLEN_LBL_PERCENT 5
#define MAX_SLEN_LBL_SPEED 13
#define MAX_SLEN_LBL_FILE 256
#define MAX_SLEN_LBL_FILE 256
#define MAX_SLEN_BT_ABORT 5
#define DOWNLOAD_BAR_MAX 300