From ad8a96554865092f340e239731d2e44bce1df526 Mon Sep 17 00:00:00 2001 From: Chris Young Date: Sat, 15 Oct 2011 14:09:35 +0000 Subject: Start to consolidate user file operation into one file svn path=/trunk/netsurf/; revision=13062 --- amiga/Makefile.target | 2 +- amiga/context_menu.c | 9 ++++++++ amiga/download.c | 1 + amiga/gui.c | 15 ++++++------ amiga/gui.h | 2 -- amiga/menu.c | 63 ++------------------------------------------------- amiga/tree.c | 44 +++++++++++++++++++---------------- 7 files changed, 44 insertions(+), 92 deletions(-) (limited to 'amiga') diff --git a/amiga/Makefile.target b/amiga/Makefile.target index d80f91016..e92335ec3 100644 --- a/amiga/Makefile.target +++ b/amiga/Makefile.target @@ -68,7 +68,7 @@ endif # ---------------------------------------------------------------------------- # S_AMIGA are sources purely for the Amiga build -S_AMIGA := gui.c tree.c history.c hotlist.c schedule.c \ +S_AMIGA := gui.c tree.c history.c hotlist.c schedule.c file.c \ thumbnail.c misc.c bitmap.c font.c filetype.c utf8.c login.c \ plotters.c object.c menu.c save_pdf.c arexx.c version.c \ cookies.c context_menu.c clipboard.c save_complete.c \ diff --git a/amiga/context_menu.c b/amiga/context_menu.c index fdf94415f..a0a3a640f 100755 --- a/amiga/context_menu.c +++ b/amiga/context_menu.c @@ -29,6 +29,7 @@ #include "amiga/context_menu.h" #include "amiga/clipboard.h" #include "amiga/bitmap.h" +#include "amiga/file.h" #include "amiga/filetype.h" #include "amiga/gui.h" #include "amiga/history_local.h" @@ -190,11 +191,13 @@ void ami_context_menu_add_submenu(Object *ctxmenuobj, ULONG cmsub, void *userdat PMIA_Title, (ULONG)ctxmenulab[CMID_PAGEOPEN], PMIA_ID, CMID_PAGEOPEN, PMIA_UserData, userdata, + PMIA_CommKey, "O", TAG_DONE), PMA_AddItem, NewObject(POPUPMENU_GetItemClass(), NULL, PMIA_Title, (ULONG)ctxmenulab[CMID_PAGESAVE], PMIA_ID, CMID_PAGESAVE, PMIA_UserData, userdata, + PMIA_CommKey, "S", TAG_DONE), PMA_AddItem, NewObject(POPUPMENU_GetItemClass(), NULL, PMIA_Title, (ULONG)ctxmenulab[CMID_PAGESAVECOMPLETE], @@ -208,6 +211,7 @@ void ami_context_menu_add_submenu(Object *ctxmenuobj, ULONG cmsub, void *userdat PMIA_Title, (ULONG)ctxmenulab[CMID_PAGECLOSE], PMIA_ID, CMID_PAGECLOSE, PMIA_UserData, userdata, + PMIA_CommKey, "K", TAG_DONE), PMA_AddItem,NewObject(POPUPMENU_GetItemClass(), NULL, PMIA_Title, ~0, @@ -216,6 +220,7 @@ void ami_context_menu_add_submenu(Object *ctxmenuobj, ULONG cmsub, void *userdat PMIA_Title, (ULONG)ctxmenulab[CMID_PAGEHOTLIST], PMIA_ID, CMID_PAGEHOTLIST, PMIA_UserData, nsurl_access(content_get_url(userdata)), + PMIA_CommKey, "B", TAG_DONE), TAG_DONE), TAG_DONE), @@ -707,6 +712,10 @@ static uint32 ami_context_menu_hook(struct Hook *hook,Object *item,APTR reserved } break; + case CMID_PAGEOPEN: + ami_file_open(gwin); + break; + case CMID_FRAMECOPYURL: case CMID_COPYURL: case CMID_COPYOBJ: diff --git a/amiga/download.c b/amiga/download.c index dfb225182..2a5cae8e6 100644 --- a/amiga/download.c +++ b/amiga/download.c @@ -39,6 +39,7 @@ #include "amiga/iff_dr2d.h" #include "amiga/theme.h" #include "amiga/utf8.h" +#include "amiga/file.h" #include "desktop/download.h" #include "desktop/selection.h" diff --git a/amiga/gui.c b/amiga/gui.c index a3ce7ad8c..bdf7b76aa 100755 --- a/amiga/gui.c +++ b/amiga/gui.c @@ -46,6 +46,7 @@ #include "amiga/datatypes.h" #include "amiga/download.h" #include "amiga/drag.h" +#include "amiga/file.h" #include "amiga/filetype.h" #include "amiga/font.h" #include "amiga/gui.h" @@ -305,12 +306,7 @@ void ami_open_resources(void) ASO_NoTrack,FALSE, TAG_DONE))) die(messages_get("NoMemory")); - filereq = (struct FileRequester *)AllocAslRequest(ASL_FileRequest,NULL); - savereq = (struct FileRequester *)AllocAslRequestTags(ASL_FileRequest, - ASLFR_DoSaveMode,TRUE, - ASLFR_RejectIcons,TRUE, - ASLFR_InitialDrawer,option_download_dir, - TAG_DONE); + ami_file_req_init(); } void ami_set_options(void) @@ -1425,6 +1421,10 @@ void ami_handle_msg(void) browser_window_destroy(gwin->bw); break; + case 'o': + ami_file_open(gwin); + break; + case 'p': ami_print_ui(gwin->bw->current_content); break; @@ -2174,8 +2174,7 @@ void gui_quit(void) FreeSysObject(ASOT_PORT,appport); FreeSysObject(ASOT_PORT,sport); - FreeAslRequest(filereq); - FreeAslRequest(savereq); + ami_file_req_free(); ami_openurl_close(); FreeStringClass(urlStringClass); diff --git a/amiga/gui.h b/amiga/gui.h index 938954fc9..19a3c4d4d 100755 --- a/amiga/gui.h +++ b/amiga/gui.h @@ -148,8 +148,6 @@ struct TextFont *origrpfont; struct MinList *window_list; struct Screen *scrn; STRPTR nsscreentitle; -struct FileRequester *filereq; -struct FileRequester *savereq; struct MsgPort *sport; bool win_destroyed; struct browser_window *curbw; diff --git a/amiga/menu.c b/amiga/menu.c index 0671fb1b1..e4d303e95 100755 --- a/amiga/menu.c +++ b/amiga/menu.c @@ -43,6 +43,7 @@ #include "amiga/clipboard.h" #include "amiga/cookies.h" #include "amiga/download.h" +#include "amiga/file.h" #include "amiga/filetype.h" #include "amiga/gui.h" #include "amiga/gui_options.h" @@ -86,7 +87,6 @@ BOOL menualreadyinit; const char * const netsurf_version; const char * const versvn; const char * const verdate; -static struct Hook aslhookfunc; ULONG ami_menu_scan(struct tree *tree, bool count, struct gui_window_2 *gwin); void ami_menu_scan_2(struct tree *tree, struct node *root, WORD *gen, @@ -309,15 +309,6 @@ struct NewMenu *ami_create_menu(struct gui_window_2 *gwin) ami_menu_scan(ami_tree_get_tree(hotlist_window), false, gwin); ami_menu_arexx_scan(gwin); - if(!menualreadyinit) - { - aslhookfunc.h_Entry = (void *)&ami_asl_mime_hook; - aslhookfunc.h_SubEntry = NULL; - aslhookfunc.h_Data = NULL; - - menualreadyinit = TRUE; - } - /* Set up scheduler to refresh the hotlist menu Disabled as it causes everything to slow down to a halt after several iterations @@ -489,27 +480,7 @@ void ami_menupick(ULONG code,struct gui_window_2 *gwin,struct MenuItem *item) break; case 3: // open local file - if(AslRequestTags(filereq, - ASLFR_TitleText,messages_get("NetSurf"), - ASLFR_Screen,scrn, - ASLFR_DoSaveMode,FALSE, - ASLFR_RejectIcons,TRUE, - ASLFR_FilterFunc,&aslhookfunc, -// ASLFR_DoPatterns,TRUE, -// ASLFR_InitialPattern,"~(#?.info)", - TAG_DONE)) - { - if(temp = AllocVec(1024,MEMF_PRIVATE | MEMF_CLEAR)) - { - char *temp2; - strlcpy(temp,filereq->fr_Drawer,1024); - AddPart(temp,filereq->fr_File,1024); - temp2 = path_to_url(temp); - browser_window_go(gwin->bw,temp2,NULL, true); - free(temp2); - FreeVec(temp); - } - } + ami_file_open(gwin); break; case 4: // save @@ -874,36 +845,6 @@ void ami_menupick(ULONG code,struct gui_window_2 *gwin,struct MenuItem *item) } } -static const ULONG ami_asl_mime_hook(struct Hook *mh,struct FileRequester *fr,struct AnchorPathOld *ap) -{ - BPTR file = 0; - char buffer[10]; - char fname[1024]; - BOOL ret = FALSE; - char *mt = NULL; - lwc_string *lwc_mt = NULL; - lwc_error lerror; - content_type ct; - - if(ap->ap_Info.fib_DirEntryType > 0) return(TRUE); - - strcpy(fname,fr->fr_Drawer); - AddPart(fname,ap->ap_Info.fib_FileName,1024); - - mt = fetch_mimetype(fname); - lerror = lwc_intern_string(mt, strlen(mt), &lwc_mt); - if (lerror != lwc_error_ok) - return FALSE; - - ct = content_factory_type_from_mime_type(lwc_mt); - lwc_string_unref(lwc_mt); - - if(ct != CONTENT_NONE) ret = TRUE; - - free(mt); - return ret; -} - void ami_menu_update_disabled(struct gui_window *g, hlcache_handle *c) { struct Window *win = g->shared->win; diff --git a/amiga/tree.c b/amiga/tree.c index a4006720d..57bf9e6fc 100755 --- a/amiga/tree.c +++ b/amiga/tree.c @@ -23,41 +23,45 @@ #include #include #include -#include -#include -#include -#include -#include -#include -#include "amiga/gui.h" -#include "content/urldb.h" #include -#include #include -#include "amiga/tree.h" #include -#include -#include -#include "utils/messages.h" #include -#include #include -#include #include #include -#include #include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "amiga/file.h" +#include "amiga/gui.h" +#include "amiga/tree.h" #include "amiga/utf8.h" -#include "desktop/cookies.h" -#include "desktop/history_global_core.h" -#include "desktop/hotlist.h" -#include "desktop/tree_url_node.h" #include "amiga/sslcert.h" #include "amiga/drag.h" /* drag icon stuff */ #include "amiga/theme.h" /* pointers */ #include "amiga/filetype.h" #include "amiga/options.h" +#include "content/urldb.h" +#include "desktop/cookies.h" +#include "desktop/history_global_core.h" +#include "desktop/hotlist.h" +#include "desktop/tree_url_node.h" #include "utils/utils.h" +#include "utils/messages.h" + +#include +#include #define AMI_TREE_MENU_ITEMS 21 #define AMI_TREE_MENU_DELETE FULLMENUNUM(1,0,0) -- cgit v1.2.3