Proper download notification code, should also open the file if the notification is

double-clicked, although it doesn't seem to work.

svn path=/trunk/netsurf/; revision=10037
This commit is contained in:
Chris Young 2010-02-13 17:31:10 +00:00
parent 30e97149ef
commit b2376c1656
9 changed files with 40 additions and 19 deletions

View File

@ -393,6 +393,7 @@ Abort:Abgebrochen
# #
amiDownload:%ld von %ld Bytes heruntergeladen amiDownload:%ld von %ld Bytes heruntergeladen
amiDownloadU:%ld Bytes heruntergeladen amiDownloadU:%ld Bytes heruntergeladen
amiDownloadComplete:NetSurf: Download completed
# GTK download window tokens # GTK download window tokens
# #

View File

@ -393,6 +393,7 @@ Abort:Abort
# #
amiDownload:%ld of %ld bytes downloaded amiDownload:%ld of %ld bytes downloaded
amiDownloadU:%ld bytes downloaded amiDownloadU:%ld bytes downloaded
amiDownloadComplete:NetSurf: Download completed
# GTK download window tokens # GTK download window tokens
# #

View File

@ -393,6 +393,7 @@ Abort:Abort
# #
amiDownload:%ld of %ld bytes downloaded amiDownload:%ld of %ld bytes downloaded
amiDownloadU:%ld bytes downloaded amiDownloadU:%ld bytes downloaded
amiDownloadComplete:NetSurf: Download completed
# GTK download window tokens # GTK download window tokens
# #

View File

@ -395,6 +395,7 @@ Abort:Annulla
# #
amiDownload:%ld di %ld byte scaricati amiDownload:%ld di %ld byte scaricati
amiDownloadU:%ld byte scaricati amiDownloadU:%ld byte scaricati
amiDownloadComplete:NetSurf: Download completed
# GTK download window tokens # GTK download window tokens
# #

View File

@ -393,6 +393,7 @@ Abort:Abort
# #
amiDownload:%ld of %ld bytes downloaded amiDownload:%ld of %ld bytes downloaded
amiDownloadU:%ld bytes downloaded amiDownloadU:%ld bytes downloaded
amiDownloadComplete:NetSurf: Download completed
# GTK download window tokens # GTK download window tokens
# #

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2008,2009 Chris Young <chris@unsatisfactorysoftware.co.uk> * Copyright 2008-2010 Chris Young <chris@unsatisfactorysoftware.co.uk>
* *
* This file is part of NetSurf, http://www.netsurf-browser.org/ * This file is part of NetSurf, http://www.netsurf-browser.org/
* *
@ -23,6 +23,7 @@
#include <proto/intuition.h> #include <proto/intuition.h>
#include <proto/utility.h> #include <proto/utility.h>
#include <proto/icon.h> #include <proto/icon.h>
#include <proto/application.h>
#include <graphics/blitattr.h> #include <graphics/blitattr.h>
#include <workbench/icon.h> #include <workbench/icon.h>
@ -32,7 +33,6 @@
#include "amiga/options.h" #include "amiga/options.h"
#include "amiga/bitmap.h" #include "amiga/bitmap.h"
#include "amiga/iff_dr2d.h" #include "amiga/iff_dr2d.h"
#include "amiga/arexx.h" /* temporarily required for notifications */
#include "content/fetch.h" #include "content/fetch.h"
@ -58,7 +58,6 @@ struct gui_download_window *gui_download_window_create(const char *url,
const char *mime_type, struct fetch *fetch, const char *mime_type, struct fetch *fetch,
unsigned int total_size, struct gui_window *gui) unsigned int total_size, struct gui_window *gui)
{ {
char fname[1024];
struct gui_download_window *dw; struct gui_download_window *dw;
APTR va[3]; APTR va[3];
@ -68,7 +67,7 @@ struct gui_download_window *gui_download_window_create(const char *url,
if((!IsListEmpty(&gui->dllist)) && (dw->dln = (struct dlnode *)FindName(&gui->dllist,url))) if((!IsListEmpty(&gui->dllist)) && (dw->dln = (struct dlnode *)FindName(&gui->dllist,url)))
{ {
strcpy(fname,dw->dln->filename); strcpy(dw->fname, dw->dln->filename);
free(dw->dln->node.ln_Name); free(dw->dln->node.ln_Name);
dw->dln->node.ln_Name = NULL; dw->dln->node.ln_Name = NULL;
} }
@ -80,8 +79,8 @@ struct gui_download_window *gui_download_window_create(const char *url,
ASLFR_InitialFile,FilePart(url), ASLFR_InitialFile,FilePart(url),
TAG_DONE)) TAG_DONE))
{ {
strlcpy(&fname,savereq->fr_Drawer,1024); strlcpy(&dw->fname,savereq->fr_Drawer,1024);
AddPart((STRPTR)&fname,savereq->fr_File,1024); AddPart((STRPTR)&dw->fname,savereq->fr_File,1024);
} }
else return NULL; else return NULL;
} }
@ -95,14 +94,12 @@ struct gui_download_window *gui_download_window_create(const char *url,
va[1] = (APTR)dw->size; va[1] = (APTR)dw->size;
va[2] = 0; va[2] = 0;
if(!(dw->fh = FOpen((STRPTR)&fname,MODE_NEWFILE,0))) if(!(dw->fh = FOpen((STRPTR)&dw->fname,MODE_NEWFILE,0)))
{ {
FreeVec(dw); FreeVec(dw);
return NULL; return NULL;
} }
SetComment(fname,url);
dw->objects[OID_MAIN] = WindowObject, dw->objects[OID_MAIN] = WindowObject,
WA_ScreenTitle,nsscreentitle, WA_ScreenTitle,nsscreentitle,
WA_Title, dw->url, WA_Title, dw->url,
@ -114,7 +111,7 @@ struct gui_download_window *gui_download_window_create(const char *url,
WA_CustomScreen,scrn, WA_CustomScreen,scrn,
WINDOW_SharedPort,sport, WINDOW_SharedPort,sport,
WINDOW_UserData,dw, WINDOW_UserData,dw,
WINDOW_IconifyGadget, TRUE, WINDOW_IconifyGadget, FALSE,
WINDOW_LockHeight,TRUE, WINDOW_LockHeight,TRUE,
WINDOW_Position, WPOS_CENTERSCREEN, WINDOW_Position, WPOS_CENTERSCREEN,
WINDOW_ParentGroup, dw->gadgets[GID_MAIN] = VGroupObject, WINDOW_ParentGroup, dw->gadgets[GID_MAIN] = VGroupObject,
@ -203,14 +200,16 @@ void gui_download_window_done(struct gui_download_window *dw)
if(!dw) return; if(!dw) return;
SetComment(dw->fname, dw->url);
if(option_download_notify) if(option_download_notify)
{ {
if(sendcmd = ASPrintf("RINGHIO APP=NetSurf SCREEN=FRONT TITLE=NetSurf \"%s downloaded\"",dw->url)) Notify(ami_appid, APPNOTIFY_Title, messages_get("amiDownloadComplete"),
{ APPNOTIFY_PubScreenName, "FRONT",
IDoMethod(arexx_obj, AM_EXECUTE, sendcmd, "RINGHIO", APPNOTIFY_BackMsg, dw->fname,
NULL, NULL, NULL, NULL); APPNOTIFY_CloseOnDC, TRUE,
FreeVec(sendcmd); APPNOTIFY_Text, dw->fname,
} TAG_DONE);
} }
bw->download = false; bw->download = false;

View File

@ -39,6 +39,7 @@ struct gui_download_window {
struct browser_window *bw; struct browser_window *bw;
struct fetch *fetch; struct fetch *fetch;
char *url; char *url;
char fname[1024];
}; };
int drag_save; int drag_save;

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2008-9 Chris Young <chris@unsatisfactorysoftware.co.uk> * Copyright 2008-2010 Chris Young <chris@unsatisfactorysoftware.co.uk>
* *
* This file is part of NetSurf, http://www.netsurf-browser.org/ * This file is part of NetSurf, http://www.netsurf-browser.org/
* *
@ -81,6 +81,8 @@
#include <libraries/application.h> #include <libraries/application.h>
#include <proto/application.h> #include <proto/application.h>
#include <desktop/searchweb.h> #include <desktop/searchweb.h>
#include <proto/wb.h>
#include <proto/utility.h>
#include "amiga/stringview/stringview.h" #include "amiga/stringview/stringview.h"
#include "amiga/stringview/urlhistory.h" #include "amiga/stringview/urlhistory.h"
@ -130,7 +132,6 @@ ULONG throbber_width,throbber_height,throbber_frames,throbber_update_interval;
BOOL rmbtrapped; BOOL rmbtrapped;
BOOL locked_screen = FALSE; BOOL locked_screen = FALSE;
BOOL screen_closed = FALSE; BOOL screen_closed = FALSE;
uint32 ami_appid;
struct MsgPort *applibport = NULL; struct MsgPort *applibport = NULL;
ULONG applibsig = 0; ULONG applibsig = 0;
@ -732,6 +733,7 @@ void gui_init2(int argc, char** argv)
REGAPP_HasPrefsWindow, TRUE, REGAPP_HasPrefsWindow, TRUE,
REGAPP_CanCreateNewDocs, TRUE, REGAPP_CanCreateNewDocs, TRUE,
REGAPP_UniqueApplication, TRUE, REGAPP_UniqueApplication, TRUE,
REGAPP_Description, "Small as a mouse, fast as a cheetah and available for free. NetSurf is a multi-platform web browser.",
TAG_DONE); TAG_DONE);
} }
else else
@ -744,6 +746,7 @@ void gui_init2(int argc, char** argv)
REGAPP_HasPrefsWindow, TRUE, REGAPP_HasPrefsWindow, TRUE,
REGAPP_CanCreateNewDocs, TRUE, REGAPP_CanCreateNewDocs, TRUE,
REGAPP_UniqueApplication, TRUE, REGAPP_UniqueApplication, TRUE,
REGAPP_Description, "Small as a mouse, fast as a cheetah and available for free. NetSurf is a multi-platform web browser.",
TAG_DONE); TAG_DONE);
} }
@ -1699,6 +1702,18 @@ void ami_handle_applib(void)
case APPLIBMT_ForceQuit: case APPLIBMT_ForceQuit:
ami_quit_netsurf(); ami_quit_netsurf();
break; break;
case APPLIBMT_CustomMsg:
{
struct ApplicationCustomMsg *applibcustmsg = applibmsg;
STRPTR tempmsg;
if(tempmsg = ASPrintf("\"%s\"",applibcustmsg->customMsg))
{
OpenWorkbenchObjectA(tempmsg, NULL);
FreeVec(tempmsg);
}
}
break;
} }
ReplyMsg((struct Message *)applibmsg); ReplyMsg((struct Message *)applibmsg);
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2008-9 Chris Young <chris@unsatisfactorysoftware.co.uk> * Copyright 2008-2010 Chris Young <chris@unsatisfactorysoftware.co.uk>
* *
* This file is part of NetSurf, http://www.netsurf-browser.org/ * This file is part of NetSurf, http://www.netsurf-browser.org/
* *
@ -142,4 +142,5 @@ struct MsgPort *sport;
bool win_destroyed; bool win_destroyed;
struct browser_window *curbw; struct browser_window *curbw;
struct gui_globals browserglob; struct gui_globals browserglob;
uint32 ami_appid;
#endif #endif