Enable displaying download progress within a notification.

Requires Enhancer Pack (Ringhio 53.65+)
Defaults to 0 (off) as there is currently no check to see if this version is installed.
This is currently potentially dangerous to toggle whilst a download is in progress, so cannot be changed through the GUI.
This commit is contained in:
Chris Young 2017-03-20 20:35:40 +00:00
parent 3c94073590
commit ee88653dc0
4 changed files with 53 additions and 7 deletions

View File

@ -146,6 +146,7 @@ There are a couple of Amiga-specific options which can only be changed directly
@{b}mask_alpha@{ub} Threshold to use when determining which alpha values to convert to full transparency (0 - 255, where 255 will convert even opaque pixels to transparent). Defaults to 0. This is only used in palette-mapped modes where alpha blending is not currently supported.
@{b}tab_new_session{ub} If NetSurf is already running, this will cause any passed URLs to open in a new tab rather than a new window.
@{b}use_extmem@{ub} Defaults to 1 (enabled). Setting to 0 will prevent NetSurf using Extended Memory to store uncompressed images - this may have a performance benefit and no disadvantage for <2GB configurations. OS4.1FEU1 only.
@{b}download_notify_progress@{ub} Defaults to 0 (disabled). Display download progress in a Ringhio notification. Requires Enhancer Pack (Ringhio 53.65+), behaviour without it is undefined.
@{b}url_file@{ub} Path to URL database file
@{b}hotlist_file@{ub} Path to Hotlist file
@{b}arexx_dir@{ub} Path to ARexx scripts dir

View File

@ -68,6 +68,14 @@
#include "amiga/theme.h"
#include "amiga/utf8.h"
#ifndef APPNOTIFY_DisplayTime
#define APPNOTIFY_DisplayTime ( TAG_USER + 13 )
#endif
#ifndef APPNOTIFY_Percentage
#define APPNOTIFY_Percentage ( TAG_USER + 14 )
#endif
struct gui_download_window {
struct ami_generic_window w;
struct Window *win;
@ -157,7 +165,15 @@ static struct gui_download_window *gui_download_window_create(download_context *
return NULL;
}
dw->objects[OID_MAIN] = WindowObj,
if((nsoption_bool(download_notify_progress) == true)) {
Notify(ami_gui_get_app_id(), APPNOTIFY_Title, messages_get("NetSurf"),
APPNOTIFY_PubScreenName, "FRONT",
APPNOTIFY_Text, dw->fname,
APPNOTIFY_DisplayTime, TRUE,
APPNOTIFY_Percentage, 0,
TAG_DONE);
} else {
dw->objects[OID_MAIN] = WindowObj,
WA_ScreenTitle, ami_gui_get_screen_title(),
WA_Title, dw->url,
WA_Activate, TRUE,
@ -195,7 +211,9 @@ static struct gui_download_window *gui_download_window_create(download_context *
EndGroup,
EndWindow;
dw->win = (struct Window *)RA_OpenWindow(dw->objects[OID_MAIN]);
dw->win = (struct Window *)RA_OpenWindow(dw->objects[OID_MAIN]);
}
dw->ctx = ctx;
ami_gui_win_list_add(dw, AMINS_DLWINDOW, &ami_download_table);
@ -219,21 +237,33 @@ static nserror gui_download_window_data(struct gui_download_window *dw,
va[1] = (APTR)dw->size;
va[2] = 0;
if(dw->size)
{
RefreshSetGadgetAttrs((struct Gadget *)dw->objects[GID_STATUS], dw->win, NULL,
if(dw->size) {
if((nsoption_bool(download_notify_progress) == true)) {
Notify(ami_gui_get_app_id(),
APPNOTIFY_Percentage, (dw->downloaded * 100) / dw->size,
TAG_DONE);
} else {
RefreshSetGadgetAttrs((struct Gadget *)dw->objects[GID_STATUS], dw->win, NULL,
FUELGAUGE_Level, dw->downloaded,
GA_Text, messages_get("amiDownload"),
FUELGAUGE_VarArgs, va,
TAG_DONE);
}
}
else
{
RefreshSetGadgetAttrs((struct Gadget *)dw->objects[GID_STATUS], dw->win, NULL,
if((nsoption_bool(download_notify_progress) == true)) {
/* unknown size, not entirely sure how to deal with this atm... */
Notify(ami_gui_get_app_id(),
APPNOTIFY_Percentage, 0,
TAG_DONE);
} else {
RefreshSetGadgetAttrs((struct Gadget *)dw->objects[GID_STATUS], dw->win, NULL,
FUELGAUGE_Level, dw->downloaded,
GA_Text, messages_get("amiDownloadU"),
FUELGAUGE_VarArgs, va,
TAG_DONE);
}
}
return NSERROR_OK;
@ -248,6 +278,12 @@ static void gui_download_window_done(struct gui_download_window *dw)
if(!dw) return;
bw = dw->bw;
if((nsoption_bool(download_notify_progress) == true)) {
Notify(ami_gui_get_app_id(),
APPNOTIFY_Update, TRUE,
TAG_DONE);
}
if((nsoption_bool(download_notify)) && (dw->result == AMINS_DLOAD_OK))
{
Notify(ami_gui_get_app_id(), APPNOTIFY_Title, messages_get("amiDownloadComplete"),
@ -275,7 +311,10 @@ static void gui_download_window_done(struct gui_download_window *dw)
downloads_in_progress--;
DisposeObject(dw->objects[OID_MAIN]);
if(dw->objects[OID_MAIN] != NULL) {
DisposeObject(dw->objects[OID_MAIN]);
}
ami_gui_win_list_remove(dw);
if(queuedl) {
nsurl *url;

View File

@ -49,6 +49,7 @@ NSOPTION_STRING(arexx_startup, "Startup.nsrx")
NSOPTION_STRING(arexx_shutdown, "Shutdown.nsrx")
NSOPTION_STRING(download_dir, NULL)
NSOPTION_BOOL(download_notify, true)
NSOPTION_BOOL(download_notify_progress, false)
NSOPTION_BOOL(faster_scroll, true)
NSOPTION_BOOL(scale_quality, false)
NSOPTION_INTEGER(dither_quality, 0)

View File

@ -1564,6 +1564,11 @@ nl.all.Abort:Breek af
# This section contains tokens which are used in the Amiga
# download window.
#
en.ami.amiDownloading:NetSurf: Downloading...
de.ami.amiDownloading:NetSurf: Downloading...
fr.ami.amiDownloading:NetSurf: Downloading...
it.ami.amiDownloading:NetSurf: Downloading...
nl.ami.amiDownloading:NetSurf: Downloading...
en.ami.amiDownload:%ld of %ld bytes downloaded
de.ami.amiDownload:%ld von %ld Bytes heruntergeladen
fr.ami.amiDownload:%ld of %ld bytes downloaded