From 11d7e4574a06a2c34e53e2ce31b17576fba9520a Mon Sep 17 00:00:00 2001 From: Chris Young Date: Sat, 23 Aug 2008 21:56:49 +0000 Subject: Basic hotlist support svn path=/trunk/netsurf/; revision=5188 --- amiga/gui.c | 45 ++++++++++++++++++++++++++++++-------- amiga/hotlist.c | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ amiga/hotlist.h | 25 +++++++++++++++++++++ 3 files changed, 128 insertions(+), 9 deletions(-) create mode 100755 amiga/hotlist.h (limited to 'amiga') diff --git a/amiga/gui.c b/amiga/gui.c index 010aade42..557dcae0a 100755 --- a/amiga/gui.c +++ b/amiga/gui.c @@ -47,6 +47,7 @@ #include #include "utils/utf8.h" #include "amiga/utf8.h" +#include "amiga/hotlist.h" #ifdef WITH_HUBBUB #include @@ -94,6 +95,7 @@ static struct RastPort dummyrp; struct FileRequester *filereq; struct IFFHandle *iffh = NULL; STRPTR nsscreentitle = NULL; +struct tree *hotlist; void ami_update_buttons(struct gui_window *); void ami_scroller_hook(struct Hook *,Object *,struct IntuiMessage *); @@ -238,7 +240,9 @@ void gui_init(int argc, char** argv) urldb_load("Resources/URLs"); urldb_load_cookies(option_cookie_file); + hotlist = options_load_tree("Resources/Hotlist"); + if(!hotlist) ami_hotlist_init(&hotlist); } void gui_init2(int argc, char** argv) @@ -432,7 +436,7 @@ void ami_get_msg(void) menunum = MENUNUM(code); itemnum = ITEMNUM(code); subnum = SUBNUM(code); -printf("%ld,%ld,%ld\n",menunum,itemnum,subnum); + switch(menunum) { case 0: // project @@ -462,6 +466,22 @@ printf("%ld,%ld,%ld\n",menunum,itemnum,subnum); break; } break; + + case 2: // hotlist + switch(itemnum) + { + case 0: // add + ami_hotlist_add(hotlist->root,gwin->bw->current_content); + options_save_tree(hotlist,"Resources/Hotlist","NetSurf hotlist"); + break; + + case 1: // show +/* this along with save_tree above is very temporary! */ + browser_window_go(gwin->bw,"file:///netsurf/resources/hotlist",NULL,true); + break; + } + break; + } code = item->NextSelect; } @@ -543,6 +563,7 @@ void gui_quit(void) { // urldb_save("resources/URLs"); urldb_save_cookies(option_cookie_file); + options_save_tree(hotlist,"Resources/Hotlist","NetSurf hotlist"); #ifdef WITH_HUBBUB hubbub_finalise(myrealloc,NULL); @@ -610,14 +631,17 @@ struct NewMenu *ami_create_menu(ULONG type) } STATIC struct NewMenu menu[] = { - {NM_TITLE,0,0,0,0,0,}, - { NM_ITEM,0,"N",0,0,0,}, - { NM_ITEM,NM_BARLABEL,0,0,0,0,}, - { NM_ITEM,0,"K",0,0,0,}, - {NM_TITLE,0,0,0,0,0,}, - { NM_ITEM,0,"C",0,0,0,}, - { NM_ITEM,0,"V",0,0,0,}, - { NM_END,0,0,0,0,0,}, + {NM_TITLE,0,0,0,0,0,}, // project + { NM_ITEM,0,"N",0,0,0,}, // new window + { NM_ITEM,NM_BARLABEL,0,0,0,0,}, + { NM_ITEM,0,"K",0,0,0,}, // close window + {NM_TITLE,0,0,0,0,0,}, // edit + { NM_ITEM,0,"C",0,0,0,}, // copy + { NM_ITEM,0,"V",0,0,0,}, // paste + {NM_TITLE,0,0,0,0,0,}, // hotlist + { NM_ITEM,0,0,0,0,0,}, // add to hotlist + { NM_ITEM,0,"H",0,0,0,}, // show hotlist + { NM_END,0,0,0,0,0,}, }; menu[0].nm_Label = messages_get("Project"); @@ -628,6 +652,9 @@ struct NewMenu *ami_create_menu(ULONG type) menu[4].nm_Label = messages_get("Edit"); menu[5].nm_Label = messages_get("Copy"); menu[6].nm_Label = messages_get("Paste"); + menu[7].nm_Label = messages_get("Hotlist"); + menu[8].nm_Label = messages_get("HotlistAdd"); + menu[9].nm_Label = messages_get("HotlistShow"); return(menu); } diff --git a/amiga/hotlist.c b/amiga/hotlist.c index c05a55ea3..2b61f93bd 100755 --- a/amiga/hotlist.c +++ b/amiga/hotlist.c @@ -1,4 +1,5 @@ /* + * Copyright 2004, 2005 Richard Wilson * Copyright 2008 Chris Young * * This file is part of NetSurf, http://www.netsurf-browser.org/ @@ -17,7 +18,73 @@ */ #include "desktop/browser.h" +#include "desktop/tree.h" +#include +#include "content/urldb.h" void hotlist_visited(struct content *content) { } + +void ami_hotlist_init(struct tree **hotlist) +{ + struct tree *hotlist_tree; + struct node *node; + *hotlist = AllocVec(sizeof(struct tree),MEMF_CLEAR); + hotlist_tree = *hotlist; + + if (!hotlist_tree) { + warn_user("NoMemory", 0); + return; + } + + hotlist_tree->root = tree_create_folder_node(NULL, "Root"); + if (!hotlist_tree->root) { + warn_user("NoMemory", 0); + FreeVec(hotlist_tree); + hotlist_tree = NULL; + } + + hotlist_tree->root->expanded = true; + node = tree_create_folder_node(hotlist_tree->root, "NetSurf"); + if (!node) + node = hotlist_tree->root; + +/* + for (i = 0; i != ENTRIES_COUNT; i++) { + data = urldb_get_url_data(default_entries[i].url); + if (!data) { + urldb_add_url(default_entries[i].url); + urldb_set_url_persistence( + default_entries[i].url, + true); + data = urldb_get_url_data( + default_entries[i].url); + } + if (data) { + tree_create_URL_node(node, + default_entries[i].url, data, + messages_get(default_entries[i].msg_key)); + } + } +*/ + tree_initialise(hotlist_tree); +} + +void ami_hotlist_add(struct node *node,struct content *c) +{ + const struct url_data *data; + + data = urldb_get_url_data(c->url); + if (!data) + { + urldb_add_url(c->url); + urldb_set_url_persistence(c->url,true); + data = urldb_get_url_data(c->url); + } + + if (data) + { + tree_create_URL_node(node,c->url,data,c->title); + } +} diff --git a/amiga/hotlist.h b/amiga/hotlist.h new file mode 100755 index 000000000..92e4a0e98 --- /dev/null +++ b/amiga/hotlist.h @@ -0,0 +1,25 @@ +/* + * 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_HOTLIST_H +#define AMIGA_HOTLIST_H +#include "desktop/tree.h" + +void ami_hotlist_init(struct tree **hotlist); +void ami_hotlist_add(struct node *node,struct content *c); +#endif -- cgit v1.2.3