diff --git a/Makefile.sources b/Makefile.sources index cb263db67..17b94b36d 100644 --- a/Makefile.sources +++ b/Makefile.sources @@ -1,193 +1,194 @@ -# -# NetSurf source file inclusion -# -# Included by main makefile -- indicates sources -# for each build. -# - -S_CONTENT := content.c fetch.c fetchcache.c urldb.c \ - fetchers/fetch_curl.c fetchers/fetch_data.c -S_CSS := css.c css_enum.c parser.c ruleset.c scanner.c -S_RENDER := box.c box_construct.c box_normalise.c directory.c \ - form.c html.c html_redraw.c hubbub_binding.c imagemap.c \ - layout.c libxml_binding.c list.c table.c textplain.c -S_UTILS := base64.c filename.c hashtable.c locale.c messages.c talloc.c \ - url.c utf8.c utils.c useragent.c -S_DESKTOP := knockout.c options.c tree.c version.c - -# S_COMMON are sources common to all builds -S_COMMON := $(addprefix content/,$(S_CONTENT)) \ - $(addprefix css/,$(S_CSS)) \ - $(addprefix render/,$(S_RENDER)) \ - $(addprefix utils/,$(S_UTILS)) \ - $(addprefix desktop/,$(S_DESKTOP)) - -# S_IMAGE are sources related to image management -S_IMAGE := bmp.c gif.c ico.c jpeg.c mng.c nssprite.c png.c svg.c rsvg.c -S_IMAGE := $(addprefix image/,$(S_IMAGE)) - -# S_PDF are sources of the pdf plotter + the ones for paged-printing -S_PDF := pdf_plotters.c font_haru.c -S_PRINT := print.c -S_LOOSE := loosen.c -S_PDF := $(addprefix desktop/save_pdf/,$(S_PDF)) \ - $(addprefix desktop/,$(S_PRINT)) \ - $(addprefix render/,$(S_LOOSE)) - -# S_BROWSER are sources related to full browsers but are common -# between RISC OS, GTK, BeOS and AmigaOS builds -S_BROWSER := browser.c frames.c history_core.c netsurf.c save_text.c \ - selection.c textinput.c -S_BROWSER := $(addprefix desktop/,$(S_BROWSER)) - -# S_RISCOS are sources purely for the RISC OS build -S_RISCOS := 401login.c artworks.c assert.c awrender.s bitmap.c buffer.c \ - cookies.c configure.c debugwin.c dialog.c download.c draw.c \ - filetype.c font.c global_history.c gui.c help.c history.c \ - hotlist.c image.c menus.c message.c palettes.c plotters.c \ - plugin.c print.c query.c save.c save_complete.c save_draw.c \ - save_pdf.c schedule.c search.c sprite.c sslcert.c textarea.c \ - textselection.c theme.c theme_install.c thumbnail.c \ - treeview.c ucstables.c uri.c url_complete.c url_protocol.c \ - wimp.c wimp_event.c window.c gui/progress_bar.c \ - gui/status_bar.c \ - $(addprefix configure/,con_cache.c con_connect.c con_content.c \ - con_fonts.c con_home.c con_image.c con_inter.c con_language.c \ - con_memory.c con_secure.c con_theme.c) -S_RISCOS := $(addprefix riscos/,$(S_RISCOS)) -TPL_RISCOS := de en fr nl # TODO: It'd be nice to auto-detect these -TPL_RISCOS := $(addprefix riscos/templates/,$(TPL_RISCOS)) - -# S_GTK are sources purely for the GTK build -S_GTK := font_pango.c gtk_bitmap.c gtk_gui.c gtk_schedule.c \ - gtk_thumbnail.c gtk_plotters.c gtk_treeview.c gtk_scaffolding.c \ - gtk_completion.c gtk_login.c gtk_throbber.c gtk_selection.c \ - gtk_history.c gtk_window.c gtk_filetype.c gtk_download.c \ - gtk_print.c gtk_tabs.c \ - $(addprefix dialogs/,gtk_options.c gtk_about.c) -S_GTK := $(addprefix gtk/,$(S_GTK)) - -# S_BEOS are sources purely for the BeOS build -S_BEOS := beos_bitmap.cpp beos_fetch_rsrc.cpp beos_filetype.cpp \ - beos_font.cpp beos_gui.cpp beos_history.cpp beos_login.cpp \ - beos_options.cpp beos_plotters.cpp beos_scaffolding.cpp \ - beos_schedule.cpp beos_thumbnail.cpp beos_treeview.cpp \ - beos_throbber.cpp beos_window.cpp -S_BEOS := $(addprefix beos/,$(S_BEOS)) -RDEF_BEOS := beos_res.rdef -RDEF_BEOS := $(addprefix beos/,$(RDEF_BEOS)) -RDEP_BEOS := adblock.css beosdefault.css default.css ca-bundle.txt \ - messages -RDEP_BEOS := $(addprefix beos/res/,$(RDEP_BEOS)) \ - $(wildcard beos/res/throbber/throbber*.png) - -# S_DEBUG are sources purely for the debug build -S_DEBUG := netsurfd.c debug_bitmap.c filetyped.c fontd.c -S_DEBUG := $(addprefix debug/,$(S_DEBUG)) - -# S_AMIGA are sources purely for the Amiga build -S_AMIGA := compat.c gui.c tree.c history.c hotlist.c schedule.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 -S_AMIGA := $(addprefix amiga/,$(S_AMIGA)) - -# S_FRAMEBUFFER are sources purely for the framebuffer build -S_FRAMEBUFFER := fb_gui.c tree.c history.c hotlist.c fb_schedule.c \ - thumbnail.c misc.c fb_bitmap.c fb_font.c font_8x16.c \ - fb_filetype.c login.c fb_cursor.c fb_plotters.c \ - fb_8bpp_plotters.c fb_16bpp_plotters.c fb_32bpp_plotters.c \ - fb_findfile.c -# fb_1bpp_plotters.c - -ifeq ($(NETSURF_FB_FRONTEND),linux) -S_FRAMEBUFFER += fb_frontend_linuxfb.c -endif -ifeq ($(NETSURF_FB_FRONTEND),able) -S_FRAMEBUFFER += fb_frontend_ablefb.c -endif -ifeq ($(NETSURF_FB_FRONTEND),dummy) -S_FRAMEBUFFER += fb_frontend_dummy.c -endif - -S_FRAMEBUFFER := $(addprefix framebuffer/,$(S_FRAMEBUFFER)) - -# Some extra rules for building the scanner etc. -css/css_enum.c css/css_enum.h: css/css_enums css/makeenum - $(VQ)echo "MAKEENUM: css" - $(Q)$(PERL) css/makeenum css/css_enum < css/css_enums -ifeq ($(HOST),riscos) -css/parser.c css/parser.h: css/parser.y - $(VQ)echo " LEMON: css/parser.y" - $(Q)dir css - $(Q)-lemon parser.y - $(Q)dir ^ - $(Q)touch css/parser.c css/parser.h -css/scanner.c: css/scanner.l - $(VQ)echo " RE2C: css/scanner.l" - $(Q)dir css - $(Q)re2c -s scanner.l > scanner.c - $(Q)dir ^ -utils/translit.c: transtab - $(VQ)echo "TRANSTAB: utils/translit.c" - $(Q)dir utils - $(Q)$(PERL) tt2code < transtab > translit.c - $(Q)dir ^ -else -css/parser.c css/parser.h: css/parser.y - $(VQ)echo " LEMON: css/parser.y" - $(Q)# If lemon really fails hard, we'll never know, sorry - $(Q)cd css; lemon parser.y || true - $(Q)# Unfortunately if the output hasn't changed, lemon doesn't - $(Q)# alter the file and thus make gets confused. - $(Q)touch css/parser.c css/parser.h -css/scanner.c: css/scanner.l - $(VQ)echo " RE2C: css/scanner.l" - $(Q)cd css; re2c -s scanner.l > scanner.c -utils/translit.c: transtab - $(VQ)echo "TRANSTAB: utils/translit.c" - $(Q)cd utils; $(PERL) tt2code < transtab > translit.c -endif - -clean-intermediates: - $(VQ)echo " CLEAN: intermediates" - $(Q)$(RM) css/css_enum.c css/css_enum.h css/parser.c \ - css/parser.out css/parser.h - $(Q)$(RM) css/scanner.c utils/translit.c - -CLEANS += clean-intermediates - -# Finally select the correct set of sources for this build... - -ifeq ($(TARGET),riscos) -SOURCES := $(S_COMMON) $(S_IMAGE) $(S_BROWSER) $(S_PDF) $(S_RISCOS) -EXETARGET := !NetSurf/!RunImage$(EXEEXT) -endif - -ifeq ($(TARGET),gtk) -SOURCES := $(S_COMMON) $(S_IMAGE) $(S_BROWSER) $(S_PDF) $(S_GTK) -EXETARGET := nsgtk -endif - -ifeq ($(TARGET),beos) -SOURCES := $(S_COMMON) $(S_IMAGE) $(S_BROWSER) $(S_BEOS) -EXETARGET := NetSurf -endif - -ifeq ($(TARGET),debug) -SOURCES := $(S_COMMON) $(S_IMAGE) $(S_DEBUG) -EXETARGET := nsdebug -endif - -ifeq ($(TARGET),amiga) -SOURCES := $(S_COMMON) $(S_IMAGE) $(S_BROWSER) $(S_AMIGA) $(S_PDF) -EXETARGET := NetSurf -endif - -ifeq ($(TARGET),framebuffer) -SOURCES := $(S_COMMON) $(S_IMAGE) $(S_BROWSER) $(S_FRAMEBUFFER) -EXETARGET := nsfb$(SUBTARGET) -endif - -ifeq ($(SOURCES),) -$(error Unable to build NetSurf, could not determine set of sources to build) -endif +# +# NetSurf source file inclusion +# +# Included by main makefile -- indicates sources +# for each build. +# + +S_CONTENT := content.c fetch.c fetchcache.c urldb.c \ + fetchers/fetch_curl.c fetchers/fetch_data.c +S_CSS := css.c css_enum.c parser.c ruleset.c scanner.c +S_RENDER := box.c box_construct.c box_normalise.c directory.c \ + form.c html.c html_redraw.c hubbub_binding.c imagemap.c \ + layout.c libxml_binding.c list.c table.c textplain.c +S_UTILS := base64.c filename.c hashtable.c locale.c messages.c talloc.c \ + url.c utf8.c utils.c useragent.c +S_DESKTOP := knockout.c options.c tree.c version.c + +# S_COMMON are sources common to all builds +S_COMMON := $(addprefix content/,$(S_CONTENT)) \ + $(addprefix css/,$(S_CSS)) \ + $(addprefix render/,$(S_RENDER)) \ + $(addprefix utils/,$(S_UTILS)) \ + $(addprefix desktop/,$(S_DESKTOP)) + +# S_IMAGE are sources related to image management +S_IMAGE := bmp.c gif.c ico.c jpeg.c mng.c nssprite.c png.c svg.c rsvg.c +S_IMAGE := $(addprefix image/,$(S_IMAGE)) + +# S_PDF are sources of the pdf plotter + the ones for paged-printing +S_PDF := pdf_plotters.c font_haru.c +S_PRINT := print.c +S_LOOSE := loosen.c +S_PDF := $(addprefix desktop/save_pdf/,$(S_PDF)) \ + $(addprefix desktop/,$(S_PRINT)) \ + $(addprefix render/,$(S_LOOSE)) + +# S_BROWSER are sources related to full browsers but are common +# between RISC OS, GTK, BeOS and AmigaOS builds +S_BROWSER := browser.c frames.c history_core.c netsurf.c save_text.c \ + selection.c textinput.c +S_BROWSER := $(addprefix desktop/,$(S_BROWSER)) + +# S_RISCOS are sources purely for the RISC OS build +S_RISCOS := 401login.c artworks.c assert.c awrender.s bitmap.c buffer.c \ + cookies.c configure.c debugwin.c dialog.c download.c draw.c \ + filetype.c font.c global_history.c gui.c help.c history.c \ + hotlist.c image.c menus.c message.c palettes.c plotters.c \ + plugin.c print.c query.c save.c save_complete.c save_draw.c \ + save_pdf.c schedule.c search.c sprite.c sslcert.c textarea.c \ + textselection.c theme.c theme_install.c thumbnail.c \ + treeview.c ucstables.c uri.c url_complete.c url_protocol.c \ + wimp.c wimp_event.c window.c gui/progress_bar.c \ + gui/status_bar.c \ + $(addprefix configure/,con_cache.c con_connect.c con_content.c \ + con_fonts.c con_home.c con_image.c con_inter.c con_language.c \ + con_memory.c con_secure.c con_theme.c) +S_RISCOS := $(addprefix riscos/,$(S_RISCOS)) +TPL_RISCOS := de en fr nl # TODO: It'd be nice to auto-detect these +TPL_RISCOS := $(addprefix riscos/templates/,$(TPL_RISCOS)) + +# S_GTK are sources purely for the GTK build +S_GTK := font_pango.c gtk_bitmap.c gtk_gui.c gtk_schedule.c \ + gtk_thumbnail.c gtk_plotters.c gtk_treeview.c gtk_scaffolding.c \ + gtk_completion.c gtk_login.c gtk_throbber.c gtk_selection.c \ + gtk_history.c gtk_window.c gtk_filetype.c gtk_download.c \ + gtk_print.c gtk_tabs.c \ + $(addprefix dialogs/,gtk_options.c gtk_about.c) +S_GTK := $(addprefix gtk/,$(S_GTK)) + +# S_BEOS are sources purely for the BeOS build +S_BEOS := beos_bitmap.cpp beos_fetch_rsrc.cpp beos_filetype.cpp \ + beos_font.cpp beos_gui.cpp beos_history.cpp beos_login.cpp \ + beos_options.cpp beos_plotters.cpp beos_scaffolding.cpp \ + beos_schedule.cpp beos_thumbnail.cpp beos_treeview.cpp \ + beos_throbber.cpp beos_window.cpp +S_BEOS := $(addprefix beos/,$(S_BEOS)) +RDEF_BEOS := beos_res.rdef +RDEF_BEOS := $(addprefix beos/,$(RDEF_BEOS)) +RDEP_BEOS := adblock.css beosdefault.css default.css ca-bundle.txt \ + messages +RDEP_BEOS := $(addprefix beos/res/,$(RDEP_BEOS)) \ + $(wildcard beos/res/throbber/throbber*.png) + +# S_DEBUG are sources purely for the debug build +S_DEBUG := netsurfd.c debug_bitmap.c filetyped.c fontd.c +S_DEBUG := $(addprefix debug/,$(S_DEBUG)) + +# S_AMIGA are sources purely for the Amiga build +S_AMIGA := compat.c gui.c tree.c history.c hotlist.c schedule.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 +S_AMIGA := $(addprefix amiga/,$(S_AMIGA)) + +# S_FRAMEBUFFER are sources purely for the framebuffer build +S_FRAMEBUFFER := fb_gui.c tree.c history.c hotlist.c fb_schedule.c \ + thumbnail.c misc.c fb_bitmap.c fb_font.c font_8x16.c \ + fb_filetype.c login.c fb_cursor.c fb_plotters.c \ + fb_8bpp_plotters.c fb_16bpp_plotters.c fb_32bpp_plotters.c \ + fb_findfile.c +# fb_1bpp_plotters.c + +ifeq ($(NETSURF_FB_FRONTEND),linux) +S_FRAMEBUFFER += fb_frontend_linuxfb.c +endif +ifeq ($(NETSURF_FB_FRONTEND),able) +S_FRAMEBUFFER += fb_frontend_ablefb.c +endif +ifeq ($(NETSURF_FB_FRONTEND),dummy) +S_FRAMEBUFFER += fb_frontend_dummy.c +endif + +S_FRAMEBUFFER := $(addprefix framebuffer/,$(S_FRAMEBUFFER)) + +# Some extra rules for building the scanner etc. +css/css_enum.c css/css_enum.h: css/css_enums css/makeenum + $(VQ)echo "MAKEENUM: css" + $(Q)$(PERL) css/makeenum css/css_enum < css/css_enums +ifeq ($(HOST),riscos) +css/parser.c css/parser.h: css/parser.y + $(VQ)echo " LEMON: css/parser.y" + $(Q)dir css + $(Q)-lemon parser.y + $(Q)dir ^ + $(Q)touch css/parser.c css/parser.h +css/scanner.c: css/scanner.l + $(VQ)echo " RE2C: css/scanner.l" + $(Q)dir css + $(Q)re2c -s scanner.l > scanner.c + $(Q)dir ^ +utils/translit.c: transtab + $(VQ)echo "TRANSTAB: utils/translit.c" + $(Q)dir utils + $(Q)$(PERL) tt2code < transtab > translit.c + $(Q)dir ^ +else +css/parser.c css/parser.h: css/parser.y + $(VQ)echo " LEMON: css/parser.y" + $(Q)# If lemon really fails hard, we'll never know, sorry + $(Q)cd css; lemon parser.y || true + $(Q)# Unfortunately if the output hasn't changed, lemon doesn't + $(Q)# alter the file and thus make gets confused. + $(Q)touch css/parser.c css/parser.h +css/scanner.c: css/scanner.l + $(VQ)echo " RE2C: css/scanner.l" + $(Q)cd css; re2c -s scanner.l > scanner.c +utils/translit.c: transtab + $(VQ)echo "TRANSTAB: utils/translit.c" + $(Q)cd utils; $(PERL) tt2code < transtab > translit.c +endif + +clean-intermediates: + $(VQ)echo " CLEAN: intermediates" + $(Q)$(RM) css/css_enum.c css/css_enum.h css/parser.c \ + css/parser.out css/parser.h + $(Q)$(RM) css/scanner.c utils/translit.c + +CLEANS += clean-intermediates + +# Finally select the correct set of sources for this build... + +ifeq ($(TARGET),riscos) +SOURCES := $(S_COMMON) $(S_IMAGE) $(S_BROWSER) $(S_PDF) $(S_RISCOS) +EXETARGET := !NetSurf/!RunImage$(EXEEXT) +endif + +ifeq ($(TARGET),gtk) +SOURCES := $(S_COMMON) $(S_IMAGE) $(S_BROWSER) $(S_PDF) $(S_GTK) +EXETARGET := nsgtk +endif + +ifeq ($(TARGET),beos) +SOURCES := $(S_COMMON) $(S_IMAGE) $(S_BROWSER) $(S_BEOS) +EXETARGET := NetSurf +endif + +ifeq ($(TARGET),debug) +SOURCES := $(S_COMMON) $(S_IMAGE) $(S_DEBUG) +EXETARGET := nsdebug +endif + +ifeq ($(TARGET),amiga) +SOURCES := $(S_COMMON) $(S_IMAGE) $(S_BROWSER) $(S_AMIGA) $(S_PDF) +EXETARGET := NetSurf +endif + +ifeq ($(TARGET),framebuffer) +SOURCES := $(S_COMMON) $(S_IMAGE) $(S_BROWSER) $(S_FRAMEBUFFER) +EXETARGET := nsfb$(SUBTARGET) +endif + +ifeq ($(SOURCES),) +$(error Unable to build NetSurf, could not determine set of sources to build) +endif diff --git a/amiga/gui.c b/amiga/gui.c index 9fed117c1..a149cba53 100755 --- a/amiga/gui.c +++ b/amiga/gui.c @@ -64,6 +64,8 @@ #include "utils/url.h" #include #include "amiga/arexx.h" +#include "amiga/hotlist.h" +#include "amiga/history.h" #ifdef WITH_HUBBUB #include @@ -260,6 +262,9 @@ void gui_init(int argc, char** argv) if((!option_url_file) || (option_url_file[0] == '\0')) option_url_file = (char *)strdup("Resources/URLs"); + if((!option_recent_file) || (option_recent_file[0] == '\0')) + option_recent_file = (char *)strdup("Resources/Recent"); + /* if((!option_cookie_jar) || (option_cookie_jar[0] == '\0')) option_cookie_jar = (char *)strdup("Resources/CookieJar"); @@ -303,6 +308,8 @@ void gui_init(int argc, char** argv) hotlist = options_load_tree(option_hotlist_file); if(!hotlist) ami_hotlist_init(&hotlist); + ami_global_history_initialise(); + ami_cookies_initialise(); if(dto = NewDTObject("Resources/Throbber", DTA_GroupID,GID_PICTURE, @@ -980,6 +987,10 @@ void gui_quit(void) urldb_save(option_url_file); urldb_save_cookies(option_cookie_file); options_save_tree(hotlist,option_hotlist_file,messages_get("TreeHotlist")); + void ami_global_history_save(); + + ami_cookies_free(); + ami_global_history_free(); #ifdef WITH_HUBBUB hubbub_finalise(myrealloc,NULL); @@ -1163,7 +1174,7 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw, } gwin->shared->scrollerhook.h_Entry = ami_scroller_hook; - gwin->shared->scrollerhook.h_Data = gwin; + gwin->shared->scrollerhook.h_Data = gwin->shared; switch(bw->browser_window_type) { @@ -2531,7 +2542,7 @@ bool gui_search_term_highlighted(struct gui_window *g, void ami_scroller_hook(struct Hook *hook,Object *object,struct IntuiMessage *msg) { ULONG gid,x,y; - struct gui_window *gwin = hook->h_Data; + struct gui_window_2 *gwin = hook->h_Data; if (msg->Class == IDCMP_IDCMPUPDATE) { @@ -2540,11 +2551,11 @@ void ami_scroller_hook(struct Hook *hook,Object *object,struct IntuiMessage *msg switch( gid ) { case OID_HSCROLL: - gwin->shared->redraw_required = true; + gwin->redraw_required = true; break; case OID_VSCROLL: - gwin->shared->redraw_required = true; + gwin->redraw_required = true; break; } } diff --git a/amiga/gui.h b/amiga/gui.h index 01c59b7dc..2678c7cb1 100755 --- a/amiga/gui.h +++ b/amiga/gui.h @@ -55,6 +55,12 @@ enum GID_LOGIN, GID_CANCEL, GID_TREEBROWSER, + GID_OPEN, + GID_UP, + GID_DOWN, + GID_NEWF, + GID_NEWB, + GID_DEL, GID_LAST }; diff --git a/amiga/history.c b/amiga/history.c index 927828f8b..8ccd63bbf 100755 --- a/amiga/history.c +++ b/amiga/history.c @@ -1,4 +1,5 @@ /* + * Copyright 2005 Richard Wilson * Copyright 2008 Chris Young * * This file is part of NetSurf, http://www.netsurf-browser.org/ @@ -17,16 +18,288 @@ */ #include "desktop/browser.h" +#include "amiga/history.h" +#include "amiga/tree.h" +#include "content/urldb.h" +#include +#include "amiga/options.h" +#include +#include +#include + +#define MAXIMUM_URL_LENGTH 1024 +#define MAXIMUM_BASE_NODES 16 + +static struct node *global_history_base_node[MAXIMUM_BASE_NODES]; +static int global_history_base_node_time[MAXIMUM_BASE_NODES]; +static int global_history_base_node_count = 0; + +static char *global_history_recent_url[GLOBAL_HISTORY_RECENT_URLS]; +static int global_history_recent_count = 0; + +static bool global_history_init; + +static struct node *ami_global_history_find(const char *url); +static bool global_history_add_internal(const char *url, + const struct url_data *data); + +void ami_global_history_initialise(void) +{ + char s[MAXIMUM_URL_LENGTH]; + BPTR *fp; + + if(global_history_tree) return; + + /* Create an empty tree */ + global_history_tree = AllocVec(sizeof(struct tree), MEMF_CLEAR | MEMF_PRIVATE); + if (!global_history_tree) { + warn_user("NoMemory", 0); + return; + } + global_history_tree->root = tree_create_folder_node(NULL, "Root"); + if (!global_history_tree->root) { + warn_user("NoMemory", 0); + FreeVec(global_history_tree); + global_history_tree = NULL; + } + global_history_tree->root->expanded = true; + global_history_tree->movable = false; + + /* load recent URLs */ + fp = FOpen(option_recent_file, MODE_OLDFILE,0); + if (!fp) + LOG(("Failed to open file '%s' for reading", + option_recent_file)); + else { + while (FGets(fp,s, MAXIMUM_URL_LENGTH)) { + if (s[strlen(s) - 1] == '\n') + s[strlen(s) - 1] = '\0'; + global_history_add_recent(s); + } + FClose(fp); + } + + global_history_init = true; + urldb_iterate_entries(global_history_add_internal); + global_history_init = false; + tree_initialise(global_history_tree); + +} void global_history_add(const char *url) { + const struct url_data *data; + + data = urldb_get_url_data(url); + if (!data) + return; + + global_history_add_internal(url, data); +} + +/** + * Internal routine to actually perform global history addition + * + * \param url The URL to add + * \param data URL data associated with URL + * \return true (for urldb_iterate_entries) + */ +bool global_history_add_internal(const char *url, + const struct url_data *data) +{ + int i, j; + struct node *parent = NULL; + struct node *link; + struct node *node; + bool before = false; + int visit_date; + + assert(url && data); + + visit_date = data->last_visit; + + /* find parent node */ + for (i = 0; i < global_history_base_node_count; i++) { + if (global_history_base_node_time[i] <= visit_date) { + parent = global_history_base_node[i]; + break; + } + } + + /* the entry is too old to care about */ + if (!parent) + return true; + + if (parent->deleted) { + /* parent was deleted, so find place to insert it */ + link = global_history_tree->root; + + for (j = global_history_base_node_count - 1; j >= 0; j--) { + if (!global_history_base_node[j]->deleted && + global_history_base_node_time[j] > + global_history_base_node_time[i]) { + link = global_history_base_node[j]; + before = true; + break; + } + } + + tree_set_node_selected(global_history_tree, + parent, false); + tree_set_node_expanded(global_history_tree, + parent, false); + tree_link_node(link, parent, before); +/* + if (!global_history_init) { + tree_recalculate_node(global_history_tree, parent, true); + tree_recalculate_node_positions(global_history_tree, + global_history_tree->root); + tree_redraw_area(global_history_tree, + 0, 0, 16384, 16384); + } +*/ + } + + /* find any previous occurance */ + + if (!global_history_init) { + node = ami_global_history_find(url); + if (node) { + /* \todo: calculate old/new positions and redraw + * only the relevant portion */ +/* + tree_redraw_area(global_history_tree, + 0, 0, 16384, 16384); +*/ + tree_update_URL_node(node, url, data); + tree_delink_node(node); + tree_link_node(parent, node, false); + tree_handle_node_changed(global_history_tree, + node, false, true); + return true; + } + } + + /* Add the node at the bottom */ + node = tree_create_URL_node_shared(parent, url, data); + if ((!global_history_init) && (node)) { +/* + tree_redraw_area(global_history_tree, + node->box.x - NODE_INSTEP, + 0, NODE_INSTEP, 16384); +*/ + tree_handle_node_changed(global_history_tree, node, + true, false); + } + + return true; +} + +/** + * Find an entry in the global history + * + * \param url The URL to find + * \return Pointer to node, or NULL if not found + */ +struct node *ami_global_history_find(const char *url) +{ + int i; + struct node *node; + struct node_element *element; + + for (i = 0; i < global_history_base_node_count; i++) { + if (!global_history_base_node[i]->deleted) { + for (node = global_history_base_node[i]->child; + node; node = node->next) { + element = tree_find_element(node, + TREE_ELEMENT_URL); + if ((element) && !strcmp(url, element->text)) + return node; + } + } + } + return NULL; +} + +/** + * Saves the global history's recent URL data. + */ +void ami_global_history_save(void) +{ + BPTR *fp; + int i; + + /* save recent URLs */ + fp = fopen(option_recent_file, "w"); + if (!fp) + LOG(("Failed to open file '%s' for writing", + option_recent_file)); + else { + for (i = global_history_recent_count - 1; i >= 0; i--) + if (strlen(global_history_recent_url[i]) < + MAXIMUM_URL_LENGTH) + fprintf(fp, "%s\n", + global_history_recent_url[i]); + fclose(fp); + } } void global_history_add_recent(const char *url) { + int i; + int j = -1; + char *current; + + /* try to find a string already there */ + for (i = 0; i < global_history_recent_count; i++) + if (global_history_recent_url[i] && + !strcmp(global_history_recent_url[i], url)) + j = i; + + /* already at head of list */ + if (j == 0) + return; + + if (j < 0) { + /* add to head of list */ + free(global_history_recent_url[ + GLOBAL_HISTORY_RECENT_URLS - 1]); + memmove(&global_history_recent_url[1], + &global_history_recent_url[0], + (GLOBAL_HISTORY_RECENT_URLS - 1) * + sizeof(char *)); + global_history_recent_url[0] = strdup(url); + global_history_recent_count++; + if (global_history_recent_count > GLOBAL_HISTORY_RECENT_URLS) + global_history_recent_count = + GLOBAL_HISTORY_RECENT_URLS; +/* + if (global_history_recent_count == 1) + ro_gui_window_prepare_navigate_all(); +*/ + } else { + /* move to head of list */ + current = global_history_recent_url[j]; + for (i = j; i > 0; i--) + global_history_recent_url[i] = + global_history_recent_url[i - 1]; + global_history_recent_url[0] = current; + } } +/** + * Gets details of the currently used URL list. + * + * \param count set to the current number of entries in the URL array on exit + * \return the current URL array + */ char **global_history_get_recent(int *count) { + *count = global_history_recent_count; + return global_history_recent_url; } +void ami_global_history_free() +{ + FreeVec(global_history_tree); +} diff --git a/amiga/history.h b/amiga/history.h new file mode 100755 index 000000000..5e9bca88c --- /dev/null +++ b/amiga/history.h @@ -0,0 +1,28 @@ +/* + * Copyright 2008 Chris Young + * + * This file is part of NetSurf, http://www.netsurf-browser.org/ + * + * NetSurf is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * NetSurf is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef AMIGA_HISTORY_H +#define AMIGA_HISTORY_H +#include "desktop/tree.h" + +#define GLOBAL_HISTORY_RECENT_URLS 16 + +void ami_global_history_initialise(void); + +struct tree *global_history_tree; +#endif diff --git a/amiga/hotlist.c b/amiga/hotlist.c index 2b61f93bd..3dbd1e00f 100755 --- a/amiga/hotlist.c +++ b/amiga/hotlist.c @@ -21,15 +21,68 @@ #include "desktop/tree.h" #include #include "content/urldb.h" +#include "amiga/hotlist.h" + +void ami_gui_hotlist_visited(struct content *content, struct tree *tree, + struct node *node); + +static const struct { + const char *url; + const char *msg_key; +} default_entries[] = { + { "http://www.netsurf-browser.org/", "HotlistHomepage" }, +// { "http://www.netsurf-browser.org/builds/", "HotlistTestBuild" }, + { "http://www.netsurf-browser.org/documentation/", "HotlistDocumentation" }, + { "http://sourceforge.net/tracker/?atid=464312&group_id=51719", + "HotlistBugTracker" }, + { "http://sourceforge.net/tracker/?atid=464315&group_id=51719", + "HotlistFeatureRequest" }, + { "http://www.unsatisfactorysoftware.co.uk", + "Unsatisfactory Software" } +}; +#define ENTRIES_COUNT (sizeof(default_entries) / sizeof(default_entries[0])) void hotlist_visited(struct content *content) { + if ((!content) || (!content->url) || (!hotlist)) + return; + ami_gui_hotlist_visited(content, hotlist, hotlist->root); +} + +/** + * Informs the hotlist that some content has been visited + * + * \param content the content visited + * \param tree the tree to find the URL data from + * \param node the node to update siblings and children of + */ +void ami_gui_hotlist_visited(struct content *content, struct tree *tree, + struct node *node) +{ + struct node_element *element; + + for (; node; node = node->next) { + if (!node->folder) { + element = tree_find_element(node, TREE_ELEMENT_URL); + if ((element) && (!strcmp(element->text, + content->url))) { + tree_update_URL_node(node, content->url, NULL); + tree_handle_node_changed(tree, node, true, + false); + } + } + if (node->child) + ami_gui_hotlist_visited(content, tree, node->child); + } } void ami_hotlist_init(struct tree **hotlist) { struct tree *hotlist_tree; struct node *node; + int i; + const struct url_data *data; + *hotlist = AllocVec(sizeof(struct tree),MEMF_CLEAR); hotlist_tree = *hotlist; @@ -50,7 +103,6 @@ void ami_hotlist_init(struct tree **hotlist) if (!node) node = hotlist_tree->root; -/* for (i = 0; i != ENTRIES_COUNT; i++) { data = urldb_get_url_data(default_entries[i].url); if (!data) { @@ -67,7 +119,7 @@ void ami_hotlist_init(struct tree **hotlist) messages_get(default_entries[i].msg_key)); } } -*/ + tree_initialise(hotlist_tree); } @@ -87,4 +139,6 @@ void ami_hotlist_add(struct node *node,struct content *c) { tree_create_URL_node(node,c->url,data,c->title); } + + tree_handle_node_changed(hotlist,node,false,true); } diff --git a/amiga/menu.c b/amiga/menu.c index 6af77e821..b4f728528 100755 --- a/amiga/menu.c +++ b/amiga/menu.c @@ -32,6 +32,8 @@ #include "desktop/save_pdf/pdf_plotters.h" #include #include "amiga/tree.h" +#include "amiga/history.h" +#include "amiga/cookies.h" void ami_free_menulabs(void) { @@ -69,6 +71,8 @@ void ami_init_menulabs(void) menulab[21] = ami_utf8_easy((char *)messages_get("Settings")); menulab[22] = ami_utf8_easy((char *)messages_get("SnapshotWindow")); menulab[23] = ami_utf8_easy((char *)messages_get("SettingsSave")); + menulab[24] = ami_utf8_easy((char *)messages_get("GlobalHistory")); + menulab[25] = ami_utf8_easy((char *)messages_get("ShowCookies")); } struct NewMenu *ami_create_menu(ULONG type) @@ -100,6 +104,8 @@ struct NewMenu *ami_create_menu(ULONG type) {NM_TITLE,0,0,0,0,0,}, // settings { NM_ITEM,0,0,0,0,0,}, // snapshot window { NM_ITEM,0,0,0,0,0,}, // save settings + { NM_ITEM,0,0,0,0,0,}, // show history + { NM_ITEM,0,0,0,0,0,}, // show cookies { NM_END,0,0,0,0,0,}, }; @@ -276,7 +282,7 @@ config option for this? */ break; case 1: // show - ami_open_tree(hotlist); + ami_open_tree(hotlist,AMI_TREE_HOTLIST); break; } break; @@ -294,6 +300,14 @@ config option for this? */ case 1: // save settings options_write("Resources/Options"); break; + + case 2: // global history + ami_open_tree(global_history_tree,AMI_TREE_HISTORY); + break; + + case 3: // cookies tree + ami_open_tree(cookies_tree,AMI_TREE_COOKIES); + break; } break; } diff --git a/amiga/menu.h b/amiga/menu.h index 6b005fe79..77c56bc72 100755 --- a/amiga/menu.h +++ b/amiga/menu.h @@ -1,31 +1,31 @@ -/* - * Copyright 2008 Chris Young - * - * This file is part of NetSurf, http://www.netsurf-browser.org/ - * - * NetSurf is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * NetSurf is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#ifndef AMIGA_MENU_H -#define AMIGA_MENU_H -#include -#include "amiga/gui.h" - -#define AMI_MENU_MAX 23 -char *menulab[AMI_MENU_MAX+1]; - -struct NewMenu *ami_create_menu(ULONG type); -void ami_init_menulabs(void); -void ami_free_menulabs(void); -void ami_menupick(ULONG code,struct gui_window_2 *gwin); -#endif +/* + * Copyright 2008 Chris Young + * + * This file is part of NetSurf, http://www.netsurf-browser.org/ + * + * NetSurf is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * NetSurf is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef AMIGA_MENU_H +#define AMIGA_MENU_H +#include +#include "amiga/gui.h" + +#define AMI_MENU_MAX 25 +char *menulab[AMI_MENU_MAX+1]; + +struct NewMenu *ami_create_menu(ULONG type); +void ami_init_menulabs(void); +void ami_free_menulabs(void); +void ami_menupick(ULONG code,struct gui_window_2 *gwin); +#endif diff --git a/amiga/misc.c b/amiga/misc.c index b4af03c53..851f3c837 100755 --- a/amiga/misc.c +++ b/amiga/misc.c @@ -49,9 +49,6 @@ void die(const char *error) exit(1); } -bool cookies_update(const char *domain, const struct cookie_data *data) -{ return true; } - char *url_to_path(const char *url) { return (char *)strdup(url + 5); diff --git a/amiga/options.h b/amiga/options.h index 50b52a089..406a97b45 100644 --- a/amiga/options.h +++ b/amiga/options.h @@ -1,69 +1,72 @@ -/* - * Copyright 2008 Chris Young - * - * This file is part of NetSurf, http://www.netsurf-browser.org/ - * - * NetSurf is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * NetSurf is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#ifndef AMIGA_OPTIONS_H -#define AMIGA_OPTIONS_H -#include "desktop/options.h" - -extern bool option_verbose_log; -extern char *option_url_file; -extern char *option_hotlist_file; -extern bool option_use_wb; -extern int option_modeid; -extern char *option_toolbar_images; -extern bool option_no_iframes; -extern bool option_utf8_clipboard; -extern int option_throbber_frames; -extern bool option_truecolour_mouse_pointers; -extern bool option_use_os_pointers; -extern bool option_force_tabs; -extern bool option_new_tab_active; -extern bool option_kiosk_mode; - -#define EXTRA_OPTION_DEFINE \ -bool option_verbose_log = false; \ -char *option_url_file = 0; \ -char *option_hotlist_file = 0; \ -bool option_use_wb = false; \ -int option_modeid = 0; \ -char *option_toolbar_images = 0; \ -bool option_no_iframes = false; \ -bool option_utf8_clipboard = false; \ -int option_throbber_frames = 1; \ -bool option_truecolour_mouse_pointers = true; \ -bool option_use_os_pointers = false; \ -bool option_force_tabs = false; \ -bool option_new_tab_active = false; \ -bool option_kiosk_mode = false; \ - -#define EXTRA_OPTION_TABLE \ -{ "verbose_log", OPTION_BOOL, &option_verbose_log}, \ -{ "url_file", OPTION_STRING, &option_url_file }, \ -{ "hotlist_file", OPTION_STRING, &option_hotlist_file }, \ -{ "use_workbench", OPTION_BOOL, &option_use_wb}, \ -{ "screen_modeid", OPTION_INTEGER, &option_modeid}, \ -{ "toolbar_images", OPTION_STRING, &option_toolbar_images }, \ -{ "no_iframes", OPTION_BOOL, &option_no_iframes}, \ -{ "clipboard_write_utf8", OPTION_BOOL, &option_utf8_clipboard}, \ -{ "throbber_frames", OPTION_INTEGER, &option_throbber_frames}, \ -{ "truecolour_mouse_pointers", OPTION_BOOL, &option_truecolour_mouse_pointers}, \ -{ "os_mouse_pointers", OPTION_BOOL, &option_use_os_pointers}, \ -{ "always_open_tabs", OPTION_BOOL, &option_force_tabs}, \ -{ "new_tab_is_active", OPTION_BOOL, &option_new_tab_active}, \ -{ "kiosk_mode", OPTION_BOOL, &option_kiosk_mode}, -#endif +/* + * Copyright 2008 Chris Young + * + * This file is part of NetSurf, http://www.netsurf-browser.org/ + * + * NetSurf is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * NetSurf is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef AMIGA_OPTIONS_H +#define AMIGA_OPTIONS_H +#include "desktop/options.h" + +extern bool option_verbose_log; +extern char *option_url_file; +extern char *option_hotlist_file; +extern bool option_use_wb; +extern int option_modeid; +extern char *option_toolbar_images; +extern bool option_no_iframes; +extern bool option_utf8_clipboard; +extern int option_throbber_frames; +extern bool option_truecolour_mouse_pointers; +extern bool option_use_os_pointers; +extern bool option_force_tabs; +extern bool option_new_tab_active; +extern bool option_kiosk_mode; +extern char *option_recent_file; + +#define EXTRA_OPTION_DEFINE \ +bool option_verbose_log = false; \ +char *option_url_file = 0; \ +char *option_hotlist_file = 0; \ +bool option_use_wb = false; \ +int option_modeid = 0; \ +char *option_toolbar_images = 0; \ +bool option_no_iframes = false; \ +bool option_utf8_clipboard = false; \ +int option_throbber_frames = 1; \ +bool option_truecolour_mouse_pointers = true; \ +bool option_use_os_pointers = false; \ +bool option_force_tabs = false; \ +bool option_new_tab_active = false; \ +bool option_kiosk_mode = false; \ +char *option_recent_file = 0; \ + +#define EXTRA_OPTION_TABLE \ +{ "verbose_log", OPTION_BOOL, &option_verbose_log}, \ +{ "url_file", OPTION_STRING, &option_url_file }, \ +{ "hotlist_file", OPTION_STRING, &option_hotlist_file }, \ +{ "use_workbench", OPTION_BOOL, &option_use_wb}, \ +{ "screen_modeid", OPTION_INTEGER, &option_modeid}, \ +{ "toolbar_images", OPTION_STRING, &option_toolbar_images }, \ +{ "no_iframes", OPTION_BOOL, &option_no_iframes}, \ +{ "clipboard_write_utf8", OPTION_BOOL, &option_utf8_clipboard}, \ +{ "throbber_frames", OPTION_INTEGER, &option_throbber_frames}, \ +{ "truecolour_mouse_pointers", OPTION_BOOL, &option_truecolour_mouse_pointers}, \ +{ "os_mouse_pointers", OPTION_BOOL, &option_use_os_pointers}, \ +{ "always_open_tabs", OPTION_BOOL, &option_force_tabs}, \ +{ "new_tab_is_active", OPTION_BOOL, &option_new_tab_active}, \ +{ "kiosk_mode", OPTION_BOOL, &option_kiosk_mode}, \ +{ "recent_file", OPTION_STRING, &option_recent_file }, +#endif diff --git a/amiga/tree.c b/amiga/tree.c index b88444a91..e9333c54b 100755 --- a/amiga/tree.c +++ b/amiga/tree.c @@ -30,10 +30,17 @@ #include #include #include "amiga/tree.h" +#include +#include +#include +#include "utils/messages.h" void ami_add_elements(struct treeview_window *twin,struct node *root,WORD *gen); bool ami_tree_launch_node(struct tree *tree, struct node *node); void free_browserlist(struct List *list); +void ami_move_node(struct treeview_window *twin,bool up); +void ami_new_bookmark(struct treeview_window *twin); +void ami_recreate_listbrowser(struct treeview_window *twin); void tree_initialise_redraw(struct tree *tree) { @@ -49,6 +56,8 @@ void tree_draw_line(int x, int y, int width, int height) void tree_draw_node_element(struct tree *tree, struct node_element *element) { + return; +#if 0 /* add element to listbrowser list */ struct Node *lbnode; @@ -88,10 +97,12 @@ void tree_draw_node_element(struct tree *tree, struct node_element *element) } break; } +#endif } void tree_draw_node_expansion(struct tree *tree, struct node *node) { + DebugPrintF("tree_draw_node_expansion\n"); } void tree_recalculate_node_element(struct node_element *element) @@ -104,9 +115,12 @@ void tree_update_URL_node(struct node *node, const char *url, struct node_element *element; char buffer[256]; + DebugPrintF("tree_update_URL_node\n"); + assert(node); element = tree_find_element(node, TREE_ELEMENT_URL); +DebugPrintF("%s\n",element->text); if (!element) return; if (data) { @@ -139,22 +153,22 @@ void tree_update_URL_node(struct node *node, const char *url, element = tree_find_element(node, TREE_ELEMENT_LAST_VISIT); if (element) { - snprintf(buffer, 256, messages_get("TreeLast"), + snprintf(buffer, 256, (char *)messages_get("TreeLast"), (data->last_visit > 0) ? ctime((time_t *)&data->last_visit) : - messages_get("TreeUnknown")); + (char *)messages_get("TreeUnknown")); if (data->last_visit > 0) buffer[strlen(buffer) - 1] = '\0'; free((void *)element->text); - element->text = strdup(buffer); + element->text = (char *)strdup(buffer); } element = tree_find_element(node, TREE_ELEMENT_VISITS); if (element) { - snprintf(buffer, 256, messages_get("TreeVisits"), + snprintf(buffer, 256, (char *)messages_get("TreeVisits"), data->visits); free((void *)element->text); - element->text = strdup(buffer); + element->text = (char *)strdup(buffer); } } @@ -171,15 +185,16 @@ void tree_set_node_sprite(struct node *node, const char *sprite, { } -void ami_open_tree(struct tree *tree) +void ami_open_tree(struct tree *tree,int type) { struct treeview_window *twin; - BOOL msel = TRUE; + BOOL msel = TRUE,nothl = TRUE; static WORD gen=0; + char *wintitle; if(tree->handle) { - twin = tree->handle; + twin = (struct treeview_window *)tree->handle; WindowToFront(twin->win); ActivateWindow(twin->win); return; @@ -192,12 +207,28 @@ void ami_open_tree(struct tree *tree) { { 22,"Name", CIF_DRAGGABLE | CIF_SORTABLE}, { 5,"URL", CIF_DRAGGABLE }, - { 5,"Visits", CIF_DRAGGABLE }, +// { 5,"Visits", CIF_DRAGGABLE }, { -1, (STRPTR)~0, -1 } }; if(tree->single_selection) msel = FALSE; + switch(type) + { + case AMI_TREE_HOTLIST: + nothl = FALSE; + wintitle = (char *)messages_get("Hotlist"); + break; + case AMI_TREE_COOKIES: + nothl = TRUE; + wintitle = (char *)messages_get("Cookies"); + break; + case AMI_TREE_HISTORY: + nothl = TRUE; + wintitle = (char *)messages_get("History"); + break; + } + NewList(twin->listbrowser_list); tree->handle = (void *)twin; @@ -206,7 +237,7 @@ void ami_open_tree(struct tree *tree) twin->objects[OID_MAIN] = WindowObject, WA_ScreenTitle,nsscreentitle, - WA_Title, "treeview window", + WA_Title,wintitle, WA_Activate, TRUE, WA_DepthGadget, TRUE, WA_DragBar, TRUE, @@ -216,24 +247,62 @@ void ami_open_tree(struct tree *tree) WINDOW_SharedPort,sport, WINDOW_UserData,twin, WINDOW_IconifyGadget, TRUE, - WINDOW_Position, WPOS_CENTERSCREEN, - WINDOW_ParentGroup, twin->gadgets[GID_MAIN] = VGroupObject, + WINDOW_Position, WPOS_CENTERSCREEN, + WINDOW_ParentGroup, twin->gadgets[GID_MAIN] = VGroupObject, LAYOUT_AddChild, twin->gadgets[GID_TREEBROWSER] = ListBrowserObject, GA_ID, GID_TREEBROWSER, GA_RelVerify, TRUE, GA_ReadOnly,FALSE, LISTBROWSER_ColumnInfo, &columninfo, - LISTBROWSER_ColumnTitles, TRUE, +// LISTBROWSER_ColumnTitles, TRUE, LISTBROWSER_Hierarchical,TRUE, LISTBROWSER_Editable,TRUE, // LISTBROWSER_TitleClickable,TRUE, LISTBROWSER_AutoFit, TRUE, LISTBROWSER_HorizontalProp, TRUE, LISTBROWSER_Labels, twin->listbrowser_list, - LISTBROWSER_MultiSelect,msel, +// LISTBROWSER_MultiSelect,msel, LISTBROWSER_ShowSelected,TRUE, - ListBrowserEnd, + ListBrowserEnd, CHILD_NominalSize,TRUE, + LAYOUT_AddChild, HGroupObject, + LAYOUT_AddChild, twin->gadgets[GID_OPEN] = ButtonObject, + GA_ID,GID_OPEN, + GA_Text,messages_get("Open"), + GA_RelVerify,TRUE, + GA_Disabled,nothl, + ButtonEnd, + LAYOUT_AddChild, twin->gadgets[GID_NEWF] = ButtonObject, + GA_ID,GID_NEWF, + BUTTON_AutoButton,BAG_POPDRAWER, + GA_RelVerify,TRUE, + GA_Disabled,nothl, + ButtonEnd, + LAYOUT_AddChild, twin->gadgets[GID_NEWB] = ButtonObject, + GA_ID,GID_NEWB, + BUTTON_AutoButton,BAG_POPFILE, + GA_RelVerify,TRUE, + GA_Disabled,nothl, + ButtonEnd, + LAYOUT_AddChild, twin->gadgets[GID_UP] = ButtonObject, + GA_ID,GID_UP, + BUTTON_AutoButton,BAG_UPARROW, + GA_RelVerify,TRUE, + GA_Disabled,nothl, //(!tree->movable), + ButtonEnd, + LAYOUT_AddChild, twin->gadgets[GID_DOWN] = ButtonObject, + GA_ID,GID_DOWN, + BUTTON_AutoButton,BAG_DNARROW, + GA_RelVerify,TRUE, + GA_Disabled,nothl, //(!tree->movable), + ButtonEnd, + LAYOUT_AddChild, twin->gadgets[GID_DEL] = ButtonObject, + GA_ID,GID_DEL, + GA_Text,messages_get("Delete"), + GA_RelVerify,TRUE, + ButtonEnd, + EndGroup, + CHILD_WeightedHeight,0, EndGroup, EndWindow; @@ -276,7 +345,7 @@ bool ami_tree_launch_node(struct tree *tree, struct node *node) void ami_tree_close(struct treeview_window *twin) { - twin->tree->handle = NULL; + twin->tree->handle = 0; DisposeObject(twin->objects[OID_MAIN]); FreeListBrowserList(twin->listbrowser_list); FreeVec(twin->listbrowser_list); @@ -295,7 +364,7 @@ void free_browserlist(struct List *list) do { nextnode = GetSucc(node); - FreeVec(node->ln_Name); +// FreeVec(node->ln_Name); FreeListBrowserNode(node); } while(node = nextnode); } @@ -319,15 +388,23 @@ void ami_add_elements(struct treeview_window *twin,struct node *root,WORD *gen) if(!element) element = tree_find_element(node, TREE_ELEMENT_TITLE); if(element && element->text) { - text1 = element->text; + text1 = (char *)element->text; } -// printf("node %lx url %s gen %ld\n",node,element->text,*gen); +/* Really, the second column needs axing - relevant data should appear in an +area below the listview when items are selected */ + element2 = tree_find_element(node, TREE_ELEMENT_URL); + if(!element2) element2 = tree_find_element(node, TREE_ELEMENT_VALUE); + if(!element2) element2 = tree_find_element(node, TREE_ELEMENT_COMMENT); if(element2 && element2->text) { - text2 = element2->text; + text2 = (char *)element2->text; + } + else + { + text2 = ""; } // element = tree_find_element(node, TREE_ELEMENT_VISITS); @@ -351,12 +428,7 @@ void ami_add_elements(struct treeview_window *twin,struct node *root,WORD *gen) LBNCA_CopyText,TRUE, LBNCA_MaxChars,256, LBNCA_Text, text2, - LBNCA_Editable,node->editable, - LBNA_Column, 2, - LBNCA_CopyText,TRUE, - LBNCA_MaxChars,256, - LBNCA_Text,"", - LBNCA_Editable,node->editable, + LBNCA_Editable,FALSE, TAG_DONE)) { AddTail(twin->listbrowser_list, lbnode); @@ -376,10 +448,15 @@ BOOL ami_tree_event(struct treeview_window *twin) { /* return TRUE if window destroyed */ ULONG class,result,relevent = 0; + ULONG column; uint16 code; struct MenuItem *item; struct node *treenode; struct Node *lbnode; + struct node_element *element; + char *text; +// ULONG editcols[] = {TREE_ELEMENT_TITLE,TREE_ELEMENT_URL}; + static WORD gen=0; while((result = RA_HandleInput(twin->objects[OID_MAIN],&code)) != WMHI_LASTMSG) { @@ -402,8 +479,92 @@ BOOL ami_tree_event(struct treeview_window *twin) TAG_DONE); ami_tree_launch_node(twin->tree,treenode); break; + + case LBRE_EDIT: + GetAttrs(twin->gadgets[GID_TREEBROWSER], + LISTBROWSER_SelectedNode,(ULONG *)&lbnode, +// LISTBROWSER_RelColumn,(ULONG *)&column, + TAG_DONE); + + GetListBrowserNodeAttrs(lbnode, + LBNA_UserData,(ULONG *)&treenode, + TAG_DONE); + + element = tree_find_element(treenode,TREE_ELEMENT_TITLE); + GetListBrowserNodeAttrs(lbnode, + LBNA_Column,column, + LBNCA_Text,(ULONG *)&text, + TAG_DONE); + element->text = (char *)strdup(text); + tree_handle_node_element_changed(twin->tree, element); + break; + + case LBRE_HIDECHILDREN: + GetAttr(LISTBROWSER_SelectedNode,twin->gadgets[GID_TREEBROWSER],(ULONG *)&lbnode); + GetListBrowserNodeAttrs(lbnode, + LBNA_UserData,(ULONG *)&treenode, + TAG_DONE); + tree_set_node_expanded(twin->tree, treenode, false); + break; + + case LBRE_SHOWCHILDREN: + GetAttr(LISTBROWSER_SelectedNode,twin->gadgets[GID_TREEBROWSER],(ULONG *)&lbnode); + GetListBrowserNodeAttrs(lbnode, + LBNA_UserData,(ULONG *)&treenode, + TAG_DONE); + tree_set_node_expanded(twin->tree, treenode, true); + break; } break; + + case GID_OPEN: + GetAttr(LISTBROWSER_SelectedNode,twin->gadgets[GID_TREEBROWSER],(ULONG *)&lbnode); + GetListBrowserNodeAttrs(lbnode, + LBNA_UserData,(ULONG *)&treenode, + TAG_DONE); + ami_tree_launch_node(twin->tree,treenode); + break; + + case GID_NEWF: + GetAttr(LISTBROWSER_SelectedNode,twin->gadgets[GID_TREEBROWSER],(ULONG *)&lbnode); + if(lbnode) + { + GetListBrowserNodeAttrs(lbnode, + LBNA_UserData,(ULONG *)&treenode, + TAG_DONE); + } + else + { + treenode = twin->tree->root; + } + + tree_create_folder_node(treenode,(char *)messages_get("TreeNewFolder")); + + ami_recreate_listbrowser(twin); + break; + + case GID_NEWB: + ami_new_bookmark(twin); + break; + + case GID_UP: + ami_move_node(twin,true); + break; + + case GID_DOWN: + ami_move_node(twin,false); + break; + + case GID_DEL: + GetAttr(LISTBROWSER_SelectedNode,twin->gadgets[GID_TREEBROWSER],(ULONG *)&lbnode); + GetListBrowserNodeAttrs(lbnode, + LBNA_UserData,(ULONG *)&treenode, + TAG_DONE); + tree_delete_node(twin->tree, treenode, true); +/* We are recreating the list from scratch as there is no obvious easy way + to delete children from a listbrowser list */ + ami_recreate_listbrowser(twin); + break; } break; @@ -427,3 +588,83 @@ BOOL ami_tree_event(struct treeview_window *twin) } return FALSE; } + +void ami_move_node(struct treeview_window *twin,bool up) +{ + struct Node *lbnode = NULL; + struct node *treenode; + BOOL sel = FALSE; + + GetAttr(LISTBROWSER_SelectedNode,twin->gadgets[GID_TREEBROWSER],(ULONG *)&lbnode); + + if(lbnode) + { + GetListBrowserNodeAttrs(lbnode, + LBNA_UserData,(ULONG *)&treenode, + LBNA_Selected,(BOOL *)&sel, + TAG_DONE); + } + + if(sel) + { + tree_set_node_selected(twin->tree,treenode,true); + + tree_move_selected_nodes(twin->tree,treenode,up); + } + + tree_set_node_selected(twin->tree,treenode,false); + ami_recreate_listbrowser(twin); +} + +void ami_new_bookmark(struct treeview_window *twin) +{ + const struct url_data *data; + struct Node *lbnode; + struct node *treenode; + char *url,*title; + + GetAttr(LISTBROWSER_SelectedNode,twin->gadgets[GID_TREEBROWSER],(ULONG *)&lbnode); + if(lbnode) + { + GetListBrowserNodeAttrs(lbnode, + LBNA_UserData,(ULONG *)&treenode, + TAG_DONE); + } + else + { + treenode = twin->tree->root; + } + + url = (char *)strdup("http://www.netsurf-browser.org"); + title = (char *)messages_get("NewBookmark"); + + data = urldb_get_url_data(url); + if (!data) + { + urldb_add_url(url); + urldb_set_url_persistence(url,true); + data = urldb_get_url_data(url); + } + + if (data) + { + tree_create_URL_node(treenode,url,data,title); + ami_recreate_listbrowser(twin); + } +} + +void ami_recreate_listbrowser(struct treeview_window *twin) +{ + static WORD gen=0; + + SetGadgetAttrs(twin->gadgets[GID_TREEBROWSER],twin->win,NULL, + LISTBROWSER_Labels,~0, + TAG_DONE); + + FreeListBrowserList(twin->listbrowser_list); + ami_add_elements(twin,twin->tree->root,&gen); + + RefreshSetGadgetAttrs(twin->gadgets[GID_TREEBROWSER],twin->win,NULL, + LISTBROWSER_Labels,twin->listbrowser_list, + TAG_DONE); +} diff --git a/amiga/tree.h b/amiga/tree.h index 244551086..4ff38edfc 100755 --- a/amiga/tree.h +++ b/amiga/tree.h @@ -19,6 +19,10 @@ #ifndef AMIGA_TREE_H #define AMIGA_TREE_H +#include +#include +#include "amiga/gui.h" + struct treeview_window { struct Window *win; Object *objects[OID_LAST]; @@ -29,7 +33,14 @@ struct treeview_window { struct List *listbrowser_list; }; -void ami_open_tree(struct tree *tree); +enum +{ + AMI_TREE_HOTLIST, + AMI_TREE_HISTORY, + AMI_TREE_COOKIES +}; + +void ami_open_tree(struct tree *tree,int type); void ami_tree_close(struct treeview_window *twin); BOOL ami_tree_event(struct treeview_window *twin); #endif