From eaae7169898fa026ae9da5f8a5dde4bc4bbbceb1 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Tue, 13 Aug 2013 12:41:04 +0100 Subject: Move old hotlist out of the way. --- amiga/context_menu.c | 16 +- amiga/hotlist.c | 8 +- amiga/menu.c | 4 +- amiga/tree.c | 24 +- atari/deskmenu.c | 2 +- atari/gui.c | 4 +- atari/hotlist.c | 34 +-- atari/hotlist.h | 10 +- cocoa/BookmarksController.m | 22 +- desktop/Makefile | 2 +- desktop/browser.c | 4 +- desktop/hotlist.c | 526 -------------------------------------------- desktop/hotlist.h | 64 ------ desktop/hotlist_old.c | 526 ++++++++++++++++++++++++++++++++++++++++++++ desktop/hotlist_old.h | 64 ++++++ desktop/treeview.c | 4 +- gtk/hotlist.c | 36 +-- gtk/scaffolding.c | 4 +- riscos/gui.c | 4 +- riscos/hotlist.c | 52 ++--- riscos/menus.c | 1 - riscos/save.c | 4 +- riscos/window.c | 1 - 23 files changed, 708 insertions(+), 708 deletions(-) delete mode 100644 desktop/hotlist.c delete mode 100644 desktop/hotlist.h create mode 100644 desktop/hotlist_old.c create mode 100644 desktop/hotlist_old.h diff --git a/amiga/context_menu.c b/amiga/context_menu.c index be52865fd..e7bbe6237 100644 --- a/amiga/context_menu.c +++ b/amiga/context_menu.c @@ -41,7 +41,7 @@ #include "amiga/utf8.h" #include "desktop/browser_private.h" #include "desktop/local_history.h" -#include "desktop/hotlist.h" +#include "desktop/hotlist_old.h" #include "desktop/searchweb.h" #include "desktop/textinput.h" #include "desktop/tree_url_node.h" @@ -768,7 +768,7 @@ static uint32 ami_context_menu_hook(struct Hook *hook,Object *item,APTR reserved case CMID_URLHOTLIST: case CMID_PAGEHOTLIST: - hotlist_add_page(userdata); + hotlist_old_add_page(userdata); break; case CMID_FRAMECOPYURL: @@ -1216,7 +1216,7 @@ static uint32 ami_context_menu_hook_tree(struct Hook *hook, Object *item, APTR r break; case CMID_TREE_EDITFOLDER: - hotlist_edit_selected(); + hotlist_old_edit_selected(); break; case CMID_TREE_EDITTITLE: @@ -1228,23 +1228,23 @@ static uint32 ami_context_menu_hook_tree(struct Hook *hook, Object *item, APTR r break; case CMID_TREE_NEWFOLDER: - hotlist_add_folder(true); + hotlist_old_add_folder(true); break; case CMID_TREE_NEWITEM: - hotlist_add_entry(true); + hotlist_old_add_entry(true); break; case CMID_TREE_SETDEFAULT: - hotlist_set_default_folder(false); + hotlist_old_set_default_folder(false); break; case CMID_TREE_CLEARDEFAULT: - hotlist_set_default_folder(true); + hotlist_old_set_default_folder(true); break; case CMID_TREE_ADDHOTLIST: - hotlist_add_page(tree_url_node_get_url(userdata)); + hotlist_old_add_page(tree_url_node_get_url(userdata)); break; case CMID_TREE_DELETE: diff --git a/amiga/hotlist.c b/amiga/hotlist.c index c82b92f72..073296771 100755 --- a/amiga/hotlist.c +++ b/amiga/hotlist.c @@ -19,7 +19,7 @@ #include #include "amiga/hotlist.h" #include "amiga/tree.h" -#include "desktop/hotlist.h" +#include "desktop/hotlist_old.h" #include "utils/messages.h" bool ami_hotlist_find_dir(struct tree *tree, const char *dir_name) @@ -56,11 +56,11 @@ void ami_hotlist_add_default_dirs(struct tree *tree) void ami_hotlist_initialise(const char *hotlist_file) { - hotlist_window = ami_tree_create(hotlist_get_tree_flags(), NULL); + hotlist_window = ami_tree_create(hotlist_old_get_tree_flags(), NULL); if(!hotlist_window) return; - hotlist_initialise(ami_tree_get_tree(hotlist_window), + hotlist_old_initialise(ami_tree_get_tree(hotlist_window), hotlist_file, tree_directory_icon_name); @@ -69,7 +69,7 @@ void ami_hotlist_initialise(const char *hotlist_file) void ami_hotlist_free(const char *hotlist_file) { - hotlist_cleanup(hotlist_file); + hotlist_old_cleanup(hotlist_file); ami_tree_destroy(hotlist_window); hotlist_window = NULL; } diff --git a/amiga/menu.c b/amiga/menu.c index ef1338cc8..4f2e1556d 100644 --- a/amiga/menu.c +++ b/amiga/menu.c @@ -57,7 +57,7 @@ #include "amiga/tree.h" #include "amiga/utf8.h" #include "desktop/tree_url_node.h" -#include "desktop/hotlist.h" +#include "desktop/hotlist_old.h" #include "desktop/browser_private.h" #include "desktop/gui.h" #include "desktop/textinput.h" @@ -888,7 +888,7 @@ static void ami_menu_item_hotlist_add(struct Hook *hook, APTR window, struct Int nsurl_access(hlcache_handle_get_url(bw->current_content)) == NULL) return; - hotlist_add_page(nsurl_access(hlcache_handle_get_url(bw->current_content))); + hotlist_old_add_page(nsurl_access(hlcache_handle_get_url(bw->current_content))); } static void ami_menu_item_hotlist_show(struct Hook *hook, APTR window, struct IntuiMessage *msg) diff --git a/amiga/tree.c b/amiga/tree.c index 327e91195..a8dda20b7 100644 --- a/amiga/tree.c +++ b/amiga/tree.c @@ -57,7 +57,7 @@ #include "content/urldb.h" #include "desktop/cookies_old.h" #include "desktop/history_global_core.h" -#include "desktop/hotlist.h" +#include "desktop/hotlist_old.h" #include "desktop/sslcert_viewer.h" #include "desktop/tree_url_node.h" #include "utils/utils.h" @@ -340,7 +340,7 @@ void ami_tree_drag_end(struct treeview_window *twin, int x, int y) else if((tw = ami_window_at_pointer(AMINS_TVWINDOW)) && (tw != twin) && (tw->type == AMI_TREE_HOTLIST)) { - hotlist_add_page_xy(tree_url_node_get_url(selected_node), x, y); + hotlist_old_add_page_xy(tree_url_node_get_url(selected_node), x, y); } } tree_drag_end(twin->tree, twin->mouse_state, @@ -1014,7 +1014,7 @@ BOOL ami_tree_event(struct treeview_window *twin) if(twin->type == AMI_TREE_HISTORY) history_global_export(fname); else if(twin->type == AMI_TREE_HOTLIST) - hotlist_export(fname); + hotlist_old_export(fname); ami_update_pointer(twin->win, GUI_POINTER_DEFAULT); } break; @@ -1032,7 +1032,7 @@ BOOL ami_tree_event(struct treeview_window *twin) cookies_expand_all(); break; case AMI_TREE_HOTLIST: - hotlist_expand_all(); + hotlist_old_expand_all(); break; } break; @@ -1047,7 +1047,7 @@ BOOL ami_tree_event(struct treeview_window *twin) cookies_expand_domains(); break; case AMI_TREE_HOTLIST: - hotlist_expand_directories(); + hotlist_old_expand_directories(); break; } break; @@ -1062,7 +1062,7 @@ BOOL ami_tree_event(struct treeview_window *twin) cookies_expand_cookies(); break; case AMI_TREE_HOTLIST: - hotlist_expand_addresses(); + hotlist_old_expand_addresses(); break; } break; @@ -1082,7 +1082,7 @@ BOOL ami_tree_event(struct treeview_window *twin) cookies_collapse_all(); break; case AMI_TREE_HOTLIST: - hotlist_collapse_all(); + hotlist_old_collapse_all(); break; } break; @@ -1097,7 +1097,7 @@ BOOL ami_tree_event(struct treeview_window *twin) cookies_collapse_domains(); break; case AMI_TREE_HOTLIST: - hotlist_collapse_directories(); + hotlist_old_collapse_directories(); break; } break; @@ -1112,7 +1112,7 @@ BOOL ami_tree_event(struct treeview_window *twin) cookies_collapse_cookies(); break; case AMI_TREE_HOTLIST: - hotlist_collapse_addresses(); + hotlist_old_collapse_addresses(); break; } break; @@ -1163,7 +1163,7 @@ BOOL ami_tree_event(struct treeview_window *twin) cookies_delete_selected(); break; case AMI_TREE_HOTLIST: - hotlist_delete_selected(); + hotlist_old_delete_selected(); break; } ami_tree_update_buttons(twin); @@ -1179,7 +1179,7 @@ BOOL ami_tree_event(struct treeview_window *twin) cookies_select_all(); break; case AMI_TREE_HOTLIST: - hotlist_select_all(); + hotlist_old_select_all(); break; } ami_tree_update_buttons(twin); @@ -1195,7 +1195,7 @@ BOOL ami_tree_event(struct treeview_window *twin) cookies_clear_selection(); break; case AMI_TREE_HOTLIST: - hotlist_clear_selection(); + hotlist_old_clear_selection(); break; } ami_tree_update_buttons(twin); diff --git a/atari/deskmenu.c b/atari/deskmenu.c index 113998c08..0de2cc124 100644 --- a/atari/deskmenu.c +++ b/atari/deskmenu.c @@ -478,7 +478,7 @@ static void __CDECL menu_add_bookmark(short item, short title, void *data) static void __CDECL menu_bookmarks(short item, short title, void *data) { LOG(("%s", __FUNCTION__)); - hotlist_open(); + atari_hotlist_open(); } static void __CDECL menu_vlog(short item, short title, void *data) diff --git a/atari/gui.c b/atari/gui.c index df205aa6e..5c384b7f6 100644 --- a/atari/gui.c +++ b/atari/gui.c @@ -811,7 +811,7 @@ void gui_quit(void) } atari_global_history_destroy(); - hotlist_destroy(); + atari_hotlist_destroy(); toolbar_exit(); urldb_save_cookies(nsoption_charp(cookie_file)); @@ -1022,7 +1022,7 @@ static void gui_init2(int argc, char** argv) } gemtk_wm_init(); atari_global_history_init(); - hotlist_init(); + atari_hotlist_init(); toolbar_init(); } diff --git a/atari/hotlist.c b/atari/hotlist.c index f3b093d6f..77e2755e1 100755 --- a/atari/hotlist.c +++ b/atari/hotlist.c @@ -28,7 +28,7 @@ #include "content/hlcache.h" #include "content/urldb.h" #include "utils/nsoption.h" -#include "desktop/hotlist.h" +#include "desktop/hotlist_old.h" #include "desktop/tree.h" #include "desktop/tree_url_node.h" #include "desktop/gui.h" @@ -62,7 +62,7 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8]) switch (msg[4]) { case TOOLBAR_HOTLIST_CREATE_FOLDER: - hotlist_add_folder(true); + hotlist_old_add_folder(true); break; case TOOLBAR_HOTLIST_ADD: @@ -70,12 +70,12 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8]) break; case TOOLBAR_HOTLIST_DELETE: - hotlist_delete_selected(); + hotlist_old_delete_selected(); gemtk_wm_exec_redraw(tv->window, NULL); break; case TOOLBAR_HOTLIST_EDIT: - hotlist_edit_selected(); + hotlist_old_edit_selected(); break; } @@ -86,7 +86,7 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8]) break; case WM_CLOSED: - hotlist_close(); + atari_hotlist_close(); break; default: break; @@ -99,7 +99,7 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8]) -void hotlist_init(void) +void atari_hotlist_init(void) { if (hl.init == false) { if( strcmp(nsoption_charp(hotlist_file), "") == 0 ){ @@ -129,7 +129,7 @@ void hotlist_init(void) gemtk_wm_set_toolbar(hl.window, tree, 0, 0); gemtk_wm_unlink(hl.window); hl.tv = atari_treeview_create( - hotlist_get_tree_flags(), + hotlist_old_get_tree_flags(), hl.window, handle_event ); @@ -139,7 +139,7 @@ void hotlist_init(void) return; } - hotlist_initialise( + hotlist_old_initialise( hl.tv->tree, (char*)&hl.path, "dir.png" @@ -153,7 +153,7 @@ void hotlist_init(void) } -void hotlist_open(void) +void atari_hotlist_open(void) { if( hl.init == false ) { return; @@ -175,23 +175,23 @@ void hotlist_open(void) } } -void hotlist_close(void) +void atari_hotlist_close(void) { wind_close(gemtk_wm_get_handle(hl.window)); hl.open = false; atari_treeview_close(hl.tv); } -void hotlist_destroy(void) +void atari_hotlist_destroy(void) { if( hl.init == false) { return; } if( hl.window != NULL ) { - hotlist_cleanup( (char*)&hl.path ); + hotlist_old_cleanup( (char*)&hl.path ); if (hl.open) - hotlist_close(); + atari_hotlist_close(); wind_delete(gemtk_wm_get_handle(hl.window)); gemtk_wm_remove(hl.window); hl.window = NULL; @@ -201,7 +201,7 @@ void hotlist_destroy(void) LOG(("done")); } -void hotlist_redraw(void) +void atari_hotlist_redraw(void) { int i = 01; atari_treeview_redraw(hl.tv); @@ -218,11 +218,11 @@ void atari_hotlist_add_page( const char * url, const char * title ) if(hl.tv == NULL ) return; - hotlist_open(); + atari_hotlist_open(); if( hl.tv->click.x >= 0 && hl.tv->click.y >= 0 ){ - hotlist_add_page_xy( url, hl.tv->click.x, hl.tv->click.y ); + hotlist_old_add_page_xy( url, hl.tv->click.x, hl.tv->click.y ); } else { - hotlist_add_page( url ); + hotlist_old_add_page( url ); } } diff --git a/atari/hotlist.h b/atari/hotlist.h index 9fbf38932..fc9cba615 100755 --- a/atari/hotlist.h +++ b/atari/hotlist.h @@ -34,13 +34,13 @@ struct atari_hotlist { extern struct atari_hotlist hl; -void hotlist_init( void ); -void hotlist_open( void ); -void hotlist_close( void ); -void hotlist_destroy( void ); +void atari_hotlist_init( void ); +void atari_hotlist_open( void ); +void atari_hotlist_close( void ); +void atari_hotlist_destroy( void ); void atari_hotlist_add_page( const char * url, const char * title ); -void hotlist_redraw( void ); +void atari_hotlist_redraw( void ); #endif diff --git a/cocoa/BookmarksController.m b/cocoa/BookmarksController.m index ef5fc974e..c86562f6e 100644 --- a/cocoa/BookmarksController.m +++ b/cocoa/BookmarksController.m @@ -24,7 +24,7 @@ #import "cocoa/gui.h" #import "desktop/browser_private.h" -#import "desktop/hotlist.h" +#import "desktop/hotlist_old.h" #import "desktop/tree.h" #import "desktop/tree_url_node.h" #import "utils/messages.h" @@ -49,8 +49,8 @@ static const char *cocoa_hotlist_path( void ) { if ((self = [super initWithWindowNibName: @"BookmarksWindow"]) == nil) return nil; - tree = [[Tree alloc] initWithFlags: hotlist_get_tree_flags()]; - hotlist_initialise( [tree tree], cocoa_hotlist_path(), "directory.png" ); + tree = [[Tree alloc] initWithFlags: hotlist_old_get_tree_flags()]; + hotlist_old_initialise( [tree tree], cocoa_hotlist_path(), "directory.png" ); nodeForMenu = NSCreateMapTable( NSNonOwnedPointerMapKeyCallBacks, NSNonOwnedPointerMapValueCallBacks, 0 ); [[NSNotificationCenter defaultCenter] addObserver:self @@ -68,14 +68,14 @@ static const char *cocoa_hotlist_path( void ) - (void) save; { - hotlist_export( cocoa_hotlist_path() ); + hotlist_old_export( cocoa_hotlist_path() ); } - (void) dealloc; { [self setView: nil]; NSFreeMapTable( nodeForMenu ); - hotlist_cleanup( cocoa_hotlist_path() ); + hotlist_old_cleanup( cocoa_hotlist_path() ); [tree release]; [[NSNotificationCenter defaultCenter] removeObserver: self]; @@ -167,7 +167,7 @@ static const char *cocoa_hotlist_path( void ) struct browser_window *bw = [[(NetSurfApp *)NSApp frontTab] browser]; if (bw && bw->current_content) { const char *url = nsurl_access(hlcache_handle_get_url( bw->current_content )); - hotlist_add_page( url ); + hotlist_old_add_page( url ); } } @@ -184,8 +184,8 @@ static const char *cocoa_hotlist_path( void ) - (void) windowDidLoad; { - hotlist_expand_all(); - hotlist_collapse_all(); + hotlist_old_expand_all(); + hotlist_old_collapse_all(); [view setTree: tree]; } @@ -200,17 +200,17 @@ static const char *cocoa_hotlist_path( void ) - (IBAction) editSelected: (id) sender; { - hotlist_edit_selected(); + hotlist_old_edit_selected(); } - (IBAction) deleteSelected: (id) sender; { - hotlist_delete_selected(); + hotlist_old_delete_selected(); } - (IBAction) addFolder: (id) sender; { - hotlist_add_folder(true); + hotlist_old_add_folder(true); } @end diff --git a/desktop/Makefile b/desktop/Makefile index 7983ff92c..162b7364c 100644 --- a/desktop/Makefile +++ b/desktop/Makefile @@ -1,6 +1,6 @@ # Sources for desktop -S_DESKTOP := cookie_manager.c cookies_old.c history_global_core.c hotlist.c knockout.c \ +S_DESKTOP := cookie_manager.c cookies_old.c history_global_core.c hotlist_old.c knockout.c \ mouse.c plot_style.c print.c search.c searchweb.c \ scrollbar.c sslcert.c sslcert_viewer.c textarea.c thumbnail.c tree.c \ tree_url_node.c version.c system_colour.c global_history.c treeview.c diff --git a/desktop/browser.c b/desktop/browser.c index 9f3636ed9..f0213a18e 100644 --- a/desktop/browser.c +++ b/desktop/browser.c @@ -48,7 +48,7 @@ #include "desktop/global_history.h" #include "desktop/gui.h" #include "desktop/history_global_core.h" -#include "desktop/hotlist.h" +#include "desktop/hotlist_old.h" #include "desktop/knockout.h" #include "desktop/local_history.h" #include "utils/nsoption.h" @@ -1285,7 +1285,7 @@ static nserror browser_window_callback(hlcache_handle *c, browser_window_update_favicon(c, bw, NULL); history_update(bw->history, c); - hotlist_visited(c); + hotlist_old_visited(c); if (bw->refresh_interval != -1) schedule(bw->refresh_interval, diff --git a/desktop/hotlist.c b/desktop/hotlist.c deleted file mode 100644 index adc9e5f8f..000000000 --- a/desktop/hotlist.c +++ /dev/null @@ -1,526 +0,0 @@ -/* - * Copyright 2004, 2005 Richard Wilson - * Copyright 2009 Paul Blokus - * - * 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 . - */ - -#include -#include - -#include "content/content.h" -#include "content/hlcache.h" -#include "content/urldb.h" -#include "desktop/browser.h" -#include "desktop/hotlist.h" -#include "desktop/plotters.h" -#include "desktop/tree.h" -#include "desktop/tree_url_node.h" - -#include "utils/messages.h" -#include "utils/utils.h" -#include "utils/log.h" - -#define URL_CHUNK_LENGTH 512 - -static struct tree *hotlist_tree; -static struct node *hotlist_tree_root; - -static bool creating_node; -static hlcache_handle *folder_icon; - -static const struct { - const char *url; - const char *msg_key; -} hotlist_default_entries[] = { - { "http://www.netsurf-browser.org/", "HotlistHomepage" }, - { "http://www.netsurf-browser.org/downloads/riscos/testbuilds", - "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" } -}; -#define HOTLIST_ENTRIES_COUNT (sizeof(hotlist_default_entries) / sizeof(hotlist_default_entries[0])) - -static node_callback_resp hotlist_node_callback(void *user_data, - struct node_msg_data *msg_data) -{ - struct node *node = msg_data->node; - const char *text; - char *norm_text; - bool is_folder = tree_node_is_folder(node); - bool cancelled = false; - - switch (msg_data->msg) { - case NODE_ELEMENT_EDIT_CANCELLED: - cancelled = true; - /* fall through */ - case NODE_ELEMENT_EDIT_FINISHED: - if (creating_node && !cancelled && - (is_folder == false) && - (msg_data->flag == TREE_ELEMENT_TITLE)) { - tree_url_node_edit_url(hotlist_tree, node); - } else { - creating_node = false; - } - return NODE_CALLBACK_HANDLED; - - case NODE_ELEMENT_EDIT_FINISHING: - if (creating_node && (is_folder == false)) - return tree_url_node_callback(hotlist_tree, msg_data); - - if (is_folder == true) { - text = msg_data->data.text; - while (isspace(*text)) - text++; - norm_text = strdup(text); - if (norm_text == NULL) { - LOG(("malloc failed")); - warn_user("NoMemory", 0); - return NODE_CALLBACK_REJECT; - } - /* don't allow zero length entry text, return false */ - if (norm_text[0] == '\0') { - warn_user("NoNameError", 0); - msg_data->data.text = NULL; - return NODE_CALLBACK_CONTINUE; - } - msg_data->data.text = norm_text; - } - break; - - case NODE_DELETE_ELEMENT_IMG: - return NODE_CALLBACK_HANDLED; - - default: - if (is_folder == false) - return tree_url_node_callback(hotlist_tree, msg_data); - } - - return NODE_CALLBACK_NOT_HANDLED; -} - -/* exported interface documented in hotlist.h */ -bool hotlist_initialise(struct tree *tree, const char *hotlist_path, - const char* folder_icon_name) -{ - struct node *node; - const struct url_data *url_data; - int hlst_loop; - - /* Either load or create a hotlist */ - - creating_node = false; - - folder_icon = tree_load_icon(folder_icon_name); - - tree_url_node_init(folder_icon_name); - - if (tree == NULL) - return false; - - hotlist_tree = tree; - hotlist_tree_root = tree_get_root(hotlist_tree); - - if (tree_urlfile_load(hotlist_path, hotlist_tree, - hotlist_node_callback, NULL)) { - return true; - } - - /* failed to load hotlist file, use default list */ - node = tree_create_folder_node(hotlist_tree, - hotlist_tree_root, - messages_get("NetSurf"), - true, - false, - false); - if (node == NULL) { - warn_user(messages_get_errorcode(NSERROR_NOMEM), 0); - return false; - } - - tree_set_node_user_callback(node, hotlist_node_callback, NULL); - tree_set_node_icon(hotlist_tree, node, folder_icon); - - for (hlst_loop = 0; hlst_loop != HOTLIST_ENTRIES_COUNT; hlst_loop++) { - nsurl *url; - if (nsurl_create(hotlist_default_entries[hlst_loop].url, - &url) != NSERROR_OK) { - return false; - } - url_data = urldb_get_url_data(url); - if (url_data == NULL) { - urldb_add_url(url); - urldb_set_url_persistence(url, true); - url_data = urldb_get_url_data(url); - } - if (url_data != NULL) { - tree_create_URL_node(hotlist_tree, node, url, - messages_get(hotlist_default_entries[hlst_loop].msg_key), - hotlist_node_callback, NULL); - tree_update_URL_node(hotlist_tree, node, url, url_data); - } - nsurl_unref(url); - } - - return true; -} - - -/** - * Get flags with which the hotlist tree should be created; - * - * \return the flags - */ -unsigned int hotlist_get_tree_flags(void) -{ - return TREE_MOVABLE | TREE_HOTLIST; -} - - -/** - * Deletes the global history tree and saves the hotlist. - * \param hotlist_path the path where the hotlist should be saved - */ -void hotlist_cleanup(const char *hotlist_path) -{ - LOG(("Exporting hotlist...")); - hotlist_export(hotlist_path); - LOG(("Releasing handles...")); - hlcache_handle_release(folder_icon); - LOG(("Clearing hotlist tree nodes...")); - tree_url_node_cleanup(); - LOG(("Hotlist cleaned up.")); -} - - -/** - * Informs the hotlist that some content has been visited. Internal procedure. - * - * \param content the content visited - * \param node the node to update siblings and children of - */ -static void hotlist_visited_internal(hlcache_handle *content, struct node *node) -{ - struct node *child; - const char *text; - const char *url; - nsurl *nsurl; - - if (content == NULL || - hlcache_handle_get_url(content) == NULL || - hotlist_tree == NULL) - return; - - nsurl = hlcache_handle_get_url(content); - url = nsurl_access(nsurl); - - for (; node; node = tree_node_get_next(node)) { - if (!tree_node_is_folder(node)) { - text = tree_url_node_get_url(node); - if (strcmp(text, url) == 0) { - tree_update_URL_node(hotlist_tree, node, - nsurl, NULL); - } - } - child = tree_node_get_child(node); - if (child != NULL) { - hotlist_visited_internal(content, child); - } - } -} - -/** - * Informs the hotlist that some content has been visited - * - * \param content the content visited - */ -void hotlist_visited(hlcache_handle *content) -{ - if (hotlist_tree != NULL) { - hotlist_visited_internal(content, tree_get_root(hotlist_tree)); - } -} - -/** - * Save the hotlist in a human-readable form under the given location. - * - * \param path the path where the hotlist will be saved - */ -bool hotlist_export(const char *path) -{ - return tree_urlfile_save(hotlist_tree, path, "NetSurf hotlist"); -} - -/** - * Edit the node which is currently selected. Works only if one node is - * selected. - */ -void hotlist_edit_selected(void) -{ - struct node *node; - struct node_element *element; - - node = tree_get_selected_node(hotlist_tree_root); - - if (node != NULL) { - creating_node = true; - element = tree_node_find_element(node, TREE_ELEMENT_TITLE, NULL); - tree_start_edit(hotlist_tree, element); - } -} - -/** - * Delete nodes which are currently selected. - */ -void hotlist_delete_selected(void) -{ - tree_delete_selected_nodes(hotlist_tree, hotlist_tree_root); -} - -/** - * Select all nodes in the tree. - */ -void hotlist_select_all(void) -{ - tree_set_node_selected(hotlist_tree, hotlist_tree_root, - true, true); -} - -/** - * Unselect all nodes. - */ -void hotlist_clear_selection(void) -{ - tree_set_node_selected(hotlist_tree, hotlist_tree_root, - true, false); -} - -/** - * Expand grouping folders and history entries. - */ -void hotlist_expand_all(void) -{ - tree_set_node_expanded(hotlist_tree, hotlist_tree_root, - true, true, true); -} - -/** - * Expand grouping folders only. - */ -void hotlist_expand_directories(void) -{ - tree_set_node_expanded(hotlist_tree, hotlist_tree_root, - true, true, false); -} - -/** - * Expand history entries only. - */ -void hotlist_expand_addresses(void) -{ - tree_set_node_expanded(hotlist_tree, hotlist_tree_root, - true, false, true); -} - -/** - * Collapse grouping folders and history entries. - */ -void hotlist_collapse_all(void) -{ - tree_set_node_expanded(hotlist_tree, hotlist_tree_root, - false, true, true); -} - -/** - * Collapse grouping folders only. - */ -void hotlist_collapse_directories(void) -{ - tree_set_node_expanded(hotlist_tree, hotlist_tree_root, - false, true, false); -} - -/** - * Collapse history entries only. - */ -void hotlist_collapse_addresses(void) -{ - tree_set_node_expanded(hotlist_tree, - hotlist_tree_root, false, false, true); -} - -/** - * Add a folder node. - * - * \param selected create the folder in the currently-selected node - */ -void hotlist_add_folder(bool selected) -{ - struct node *node, *parent = NULL; - - creating_node = true; - - if (selected == true) { - parent = tree_get_selected_node(tree_get_root(hotlist_tree)); - if (parent && (tree_node_is_folder(parent) == false)) { - parent = tree_node_get_parent(parent); - } - } - - if (parent == NULL) { - parent = tree_get_default_folder_node(hotlist_tree); - } - - node = tree_create_folder_node(hotlist_tree, - parent, - messages_get("Untitled"), - true, - false, - false); - if (node == NULL) { - warn_user(messages_get_errorcode(NSERROR_NOMEM), 0); - return; - } - - tree_set_node_user_callback(node, hotlist_node_callback, NULL); - tree_set_node_icon(hotlist_tree, node, folder_icon); - tree_start_edit(hotlist_tree, - tree_node_find_element(node, TREE_ELEMENT_TITLE, NULL)); -} - -/** - * Add an entry node. - * - * \param selected add the entry in the currently-selected node - */ -void hotlist_add_entry(bool selected) -{ - struct node *node; - struct node *parent = NULL; - nsurl *url; - creating_node = true; - - if (selected == true) { - parent = tree_get_selected_node(tree_get_root(hotlist_tree)); - if (parent && (tree_node_is_folder(parent) == false)) { - parent = tree_node_get_parent(parent); - } - } - - if (parent == NULL) { - parent = tree_get_default_folder_node(hotlist_tree); - } - - if (nsurl_create("http://netsurf-browser.org/", &url) != NSERROR_OK) - return; - node = tree_create_URL_node(hotlist_tree, parent, url, "Untitled", - hotlist_node_callback, NULL); - - nsurl_unref(url); - - if (node == NULL) - return; - tree_set_node_user_callback(node, hotlist_node_callback, NULL); - tree_url_node_edit_title(hotlist_tree, node); -} - -/** - * Adds the currently viewed page to the hotlist - */ -void hotlist_add_page(const char *url) -{ - const struct url_data *data; - struct node *node, *parent; - nsurl *nsurl; - - if (url == NULL) - return; - - if (nsurl_create(url, &nsurl) != NSERROR_OK) - return; - - data = urldb_get_url_data(nsurl); - if (data == NULL) - return; - - parent = tree_get_default_folder_node(hotlist_tree); - node = tree_create_URL_node(hotlist_tree, parent, nsurl, NULL, - hotlist_node_callback, NULL); - tree_update_URL_node(hotlist_tree, node, nsurl, data); - nsurl_unref(nsurl); -} - -/** - * Adds the currently viewed page to the hotlist at the given co-ordinates - * \param url url of the page - * \param x X cooridinate with respect to tree origin - * \param y Y cooridinate with respect to tree origin - */ -void hotlist_add_page_xy(const char *url, int x, int y) -{ - const struct url_data *data; - struct node *link, *node; - bool before; - nsurl *nsurl; - - if (url == NULL) - return; - - if (nsurl_create(url, &nsurl) != NSERROR_OK) - return; - - data = urldb_get_url_data(nsurl); - if (data == NULL) { - urldb_add_url(nsurl); - urldb_set_url_persistence(nsurl, true); - data = urldb_get_url_data(nsurl); - } - if (data != NULL) { - link = tree_get_link_details(hotlist_tree, x, y, &before); - node = tree_create_URL_node(NULL, NULL, nsurl, - NULL, hotlist_node_callback, NULL); - tree_link_node(hotlist_tree, link, node, before); - } - nsurl_unref(nsurl); -} - -/** - * Open the selected entries in separate browser windows. - * - * \param tabs open multiple entries in tabs in the new window - */ -void hotlist_launch_selected(bool tabs) -{ - tree_launch_selected(hotlist_tree, tabs); -} - -/** - * Set the hotlist's default folder to the selected node. - * - * \param clear reset the default to tree root - */ -bool hotlist_set_default_folder(bool clear) -{ - if (clear == true) { - tree_clear_default_folder_node(hotlist_tree); - return true; - } else { - return tree_set_default_folder_node(hotlist_tree, NULL); - } -} diff --git a/desktop/hotlist.h b/desktop/hotlist.h deleted file mode 100644 index fa7fee228..000000000 --- a/desktop/hotlist.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright 2004, 2005 Richard Wilson - * Copyright 2009 Paul Blokus - * - * 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 . - */ - - - -/** \file - * Hotlist (interface). - */ - -#ifndef _NETSURF_DESKTOP_HOTLIST_H_ -#define _NETSURF_DESKTOP_HOTLIST_H_ - -#include - -#include "desktop/tree.h" - -/** - * Initialise the hotlist from a frontend. - * - * \param tree The tree object which holds the hotlist. - * \param hotlist_path The file path to initialise the hotlist entries from. - * \param folder_icon_name The name to use for folder icons. - */ -bool hotlist_initialise(struct tree *tree, const char *hotlist_path, const char* folder_icon_name); - -unsigned int hotlist_get_tree_flags(void); -void hotlist_cleanup(const char *hotlist_path); - -void hotlist_visited(struct hlcache_handle *c); - -bool hotlist_export(const char *path); -void hotlist_edit_selected(void); -void hotlist_delete_selected(void); -void hotlist_select_all(void); -void hotlist_clear_selection(void); -void hotlist_expand_all(void); -void hotlist_expand_directories(void); -void hotlist_expand_addresses(void); -void hotlist_collapse_all(void); -void hotlist_collapse_directories(void); -void hotlist_collapse_addresses(void); -void hotlist_add_folder(bool selected); -void hotlist_add_entry(bool selected); -void hotlist_add_page(const char *url); -void hotlist_add_page_xy(const char *url, int x, int y); -void hotlist_launch_selected(bool tabs); -bool hotlist_set_default_folder(bool clear); -#endif diff --git a/desktop/hotlist_old.c b/desktop/hotlist_old.c new file mode 100644 index 000000000..bee38d3b4 --- /dev/null +++ b/desktop/hotlist_old.c @@ -0,0 +1,526 @@ +/* + * Copyright 2004, 2005 Richard Wilson + * Copyright 2009 Paul Blokus + * + * 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 . + */ + +#include +#include + +#include "content/content.h" +#include "content/hlcache.h" +#include "content/urldb.h" +#include "desktop/browser.h" +#include "desktop/hotlist_old.h" +#include "desktop/plotters.h" +#include "desktop/tree.h" +#include "desktop/tree_url_node.h" + +#include "utils/messages.h" +#include "utils/utils.h" +#include "utils/log.h" + +#define URL_CHUNK_LENGTH 512 + +static struct tree *hotlist_old_tree; +static struct node *hotlist_old_tree_root; + +static bool creating_node; +static hlcache_handle *folder_icon; + +static const struct { + const char *url; + const char *msg_key; +} hotlist_old_default_entries[] = { + { "http://www.netsurf-browser.org/", "HotlistHomepage" }, + { "http://www.netsurf-browser.org/downloads/riscos/testbuilds", + "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" } +}; +#define hotlist_old_ENTRIES_COUNT (sizeof(hotlist_old_default_entries) / sizeof(hotlist_old_default_entries[0])) + +static node_callback_resp hotlist_old_node_callback(void *user_data, + struct node_msg_data *msg_data) +{ + struct node *node = msg_data->node; + const char *text; + char *norm_text; + bool is_folder = tree_node_is_folder(node); + bool cancelled = false; + + switch (msg_data->msg) { + case NODE_ELEMENT_EDIT_CANCELLED: + cancelled = true; + /* fall through */ + case NODE_ELEMENT_EDIT_FINISHED: + if (creating_node && !cancelled && + (is_folder == false) && + (msg_data->flag == TREE_ELEMENT_TITLE)) { + tree_url_node_edit_url(hotlist_old_tree, node); + } else { + creating_node = false; + } + return NODE_CALLBACK_HANDLED; + + case NODE_ELEMENT_EDIT_FINISHING: + if (creating_node && (is_folder == false)) + return tree_url_node_callback(hotlist_old_tree, msg_data); + + if (is_folder == true) { + text = msg_data->data.text; + while (isspace(*text)) + text++; + norm_text = strdup(text); + if (norm_text == NULL) { + LOG(("malloc failed")); + warn_user("NoMemory", 0); + return NODE_CALLBACK_REJECT; + } + /* don't allow zero length entry text, return false */ + if (norm_text[0] == '\0') { + warn_user("NoNameError", 0); + msg_data->data.text = NULL; + return NODE_CALLBACK_CONTINUE; + } + msg_data->data.text = norm_text; + } + break; + + case NODE_DELETE_ELEMENT_IMG: + return NODE_CALLBACK_HANDLED; + + default: + if (is_folder == false) + return tree_url_node_callback(hotlist_old_tree, msg_data); + } + + return NODE_CALLBACK_NOT_HANDLED; +} + +/* exported interface documented in hotlist.h */ +bool hotlist_old_initialise(struct tree *tree, const char *hotlist_path, + const char* folder_icon_name) +{ + struct node *node; + const struct url_data *url_data; + int hlst_loop; + + /* Either load or create a hotlist */ + + creating_node = false; + + folder_icon = tree_load_icon(folder_icon_name); + + tree_url_node_init(folder_icon_name); + + if (tree == NULL) + return false; + + hotlist_old_tree = tree; + hotlist_old_tree_root = tree_get_root(hotlist_old_tree); + + if (tree_urlfile_load(hotlist_path, hotlist_old_tree, + hotlist_old_node_callback, NULL)) { + return true; + } + + /* failed to load hotlist file, use default list */ + node = tree_create_folder_node(hotlist_old_tree, + hotlist_old_tree_root, + messages_get("NetSurf"), + true, + false, + false); + if (node == NULL) { + warn_user(messages_get_errorcode(NSERROR_NOMEM), 0); + return false; + } + + tree_set_node_user_callback(node, hotlist_old_node_callback, NULL); + tree_set_node_icon(hotlist_old_tree, node, folder_icon); + + for (hlst_loop = 0; hlst_loop != hotlist_old_ENTRIES_COUNT; hlst_loop++) { + nsurl *url; + if (nsurl_create(hotlist_old_default_entries[hlst_loop].url, + &url) != NSERROR_OK) { + return false; + } + url_data = urldb_get_url_data(url); + if (url_data == NULL) { + urldb_add_url(url); + urldb_set_url_persistence(url, true); + url_data = urldb_get_url_data(url); + } + if (url_data != NULL) { + tree_create_URL_node(hotlist_old_tree, node, url, + messages_get(hotlist_old_default_entries[hlst_loop].msg_key), + hotlist_old_node_callback, NULL); + tree_update_URL_node(hotlist_old_tree, node, url, url_data); + } + nsurl_unref(url); + } + + return true; +} + + +/** + * Get flags with which the hotlist tree should be created; + * + * \return the flags + */ +unsigned int hotlist_old_get_tree_flags(void) +{ + return TREE_MOVABLE | TREE_HOTLIST; +} + + +/** + * Deletes the global history tree and saves the hotlist. + * \param hotlist_path the path where the hotlist should be saved + */ +void hotlist_old_cleanup(const char *hotlist_path) +{ + LOG(("Exporting hotlist...")); + hotlist_old_export(hotlist_path); + LOG(("Releasing handles...")); + hlcache_handle_release(folder_icon); + LOG(("Clearing hotlist tree nodes...")); + tree_url_node_cleanup(); + LOG(("Hotlist cleaned up.")); +} + + +/** + * Informs the hotlist that some content has been visited. Internal procedure. + * + * \param content the content visited + * \param node the node to update siblings and children of + */ +static void hotlist_old_visited_internal(hlcache_handle *content, struct node *node) +{ + struct node *child; + const char *text; + const char *url; + nsurl *nsurl; + + if (content == NULL || + hlcache_handle_get_url(content) == NULL || + hotlist_old_tree == NULL) + return; + + nsurl = hlcache_handle_get_url(content); + url = nsurl_access(nsurl); + + for (; node; node = tree_node_get_next(node)) { + if (!tree_node_is_folder(node)) { + text = tree_url_node_get_url(node); + if (strcmp(text, url) == 0) { + tree_update_URL_node(hotlist_old_tree, node, + nsurl, NULL); + } + } + child = tree_node_get_child(node); + if (child != NULL) { + hotlist_old_visited_internal(content, child); + } + } +} + +/** + * Informs the hotlist that some content has been visited + * + * \param content the content visited + */ +void hotlist_old_visited(hlcache_handle *content) +{ + if (hotlist_old_tree != NULL) { + hotlist_old_visited_internal(content, tree_get_root(hotlist_old_tree)); + } +} + +/** + * Save the hotlist in a human-readable form under the given location. + * + * \param path the path where the hotlist will be saved + */ +bool hotlist_old_export(const char *path) +{ + return tree_urlfile_save(hotlist_old_tree, path, "NetSurf hotlist"); +} + +/** + * Edit the node which is currently selected. Works only if one node is + * selected. + */ +void hotlist_old_edit_selected(void) +{ + struct node *node; + struct node_element *element; + + node = tree_get_selected_node(hotlist_old_tree_root); + + if (node != NULL) { + creating_node = true; + element = tree_node_find_element(node, TREE_ELEMENT_TITLE, NULL); + tree_start_edit(hotlist_old_tree, element); + } +} + +/** + * Delete nodes which are currently selected. + */ +void hotlist_old_delete_selected(void) +{ + tree_delete_selected_nodes(hotlist_old_tree, hotlist_old_tree_root); +} + +/** + * Select all nodes in the tree. + */ +void hotlist_old_select_all(void) +{ + tree_set_node_selected(hotlist_old_tree, hotlist_old_tree_root, + true, true); +} + +/** + * Unselect all nodes. + */ +void hotlist_old_clear_selection(void) +{ + tree_set_node_selected(hotlist_old_tree, hotlist_old_tree_root, + true, false); +} + +/** + * Expand grouping folders and history entries. + */ +void hotlist_old_expand_all(void) +{ + tree_set_node_expanded(hotlist_old_tree, hotlist_old_tree_root, + true, true, true); +} + +/** + * Expand grouping folders only. + */ +void hotlist_old_expand_directories(void) +{ + tree_set_node_expanded(hotlist_old_tree, hotlist_old_tree_root, + true, true, false); +} + +/** + * Expand history entries only. + */ +void hotlist_old_expand_addresses(void) +{ + tree_set_node_expanded(hotlist_old_tree, hotlist_old_tree_root, + true, false, true); +} + +/** + * Collapse grouping folders and history entries. + */ +void hotlist_old_collapse_all(void) +{ + tree_set_node_expanded(hotlist_old_tree, hotlist_old_tree_root, + false, true, true); +} + +/** + * Collapse grouping folders only. + */ +void hotlist_old_collapse_directories(void) +{ + tree_set_node_expanded(hotlist_old_tree, hotlist_old_tree_root, + false, true, false); +} + +/** + * Collapse history entries only. + */ +void hotlist_old_collapse_addresses(void) +{ + tree_set_node_expanded(hotlist_old_tree, + hotlist_old_tree_root, false, false, true); +} + +/** + * Add a folder node. + * + * \param selected create the folder in the currently-selected node + */ +void hotlist_old_add_folder(bool selected) +{ + struct node *node, *parent = NULL; + + creating_node = true; + + if (selected == true) { + parent = tree_get_selected_node(tree_get_root(hotlist_old_tree)); + if (parent && (tree_node_is_folder(parent) == false)) { + parent = tree_node_get_parent(parent); + } + } + + if (parent == NULL) { + parent = tree_get_default_folder_node(hotlist_old_tree); + } + + node = tree_create_folder_node(hotlist_old_tree, + parent, + messages_get("Untitled"), + true, + false, + false); + if (node == NULL) { + warn_user(messages_get_errorcode(NSERROR_NOMEM), 0); + return; + } + + tree_set_node_user_callback(node, hotlist_old_node_callback, NULL); + tree_set_node_icon(hotlist_old_tree, node, folder_icon); + tree_start_edit(hotlist_old_tree, + tree_node_find_element(node, TREE_ELEMENT_TITLE, NULL)); +} + +/** + * Add an entry node. + * + * \param selected add the entry in the currently-selected node + */ +void hotlist_old_add_entry(bool selected) +{ + struct node *node; + struct node *parent = NULL; + nsurl *url; + creating_node = true; + + if (selected == true) { + parent = tree_get_selected_node(tree_get_root(hotlist_old_tree)); + if (parent && (tree_node_is_folder(parent) == false)) { + parent = tree_node_get_parent(parent); + } + } + + if (parent == NULL) { + parent = tree_get_default_folder_node(hotlist_old_tree); + } + + if (nsurl_create("http://netsurf-browser.org/", &url) != NSERROR_OK) + return; + node = tree_create_URL_node(hotlist_old_tree, parent, url, "Untitled", + hotlist_old_node_callback, NULL); + + nsurl_unref(url); + + if (node == NULL) + return; + tree_set_node_user_callback(node, hotlist_old_node_callback, NULL); + tree_url_node_edit_title(hotlist_old_tree, node); +} + +/** + * Adds the currently viewed page to the hotlist + */ +void hotlist_old_add_page(const char *url) +{ + const struct url_data *data; + struct node *node, *parent; + nsurl *nsurl; + + if (url == NULL) + return; + + if (nsurl_create(url, &nsurl) != NSERROR_OK) + return; + + data = urldb_get_url_data(nsurl); + if (data == NULL) + return; + + parent = tree_get_default_folder_node(hotlist_old_tree); + node = tree_create_URL_node(hotlist_old_tree, parent, nsurl, NULL, + hotlist_old_node_callback, NULL); + tree_update_URL_node(hotlist_old_tree, node, nsurl, data); + nsurl_unref(nsurl); +} + +/** + * Adds the currently viewed page to the hotlist at the given co-ordinates + * \param url url of the page + * \param x X cooridinate with respect to tree origin + * \param y Y cooridinate with respect to tree origin + */ +void hotlist_old_add_page_xy(const char *url, int x, int y) +{ + const struct url_data *data; + struct node *link, *node; + bool before; + nsurl *nsurl; + + if (url == NULL) + return; + + if (nsurl_create(url, &nsurl) != NSERROR_OK) + return; + + data = urldb_get_url_data(nsurl); + if (data == NULL) { + urldb_add_url(nsurl); + urldb_set_url_persistence(nsurl, true); + data = urldb_get_url_data(nsurl); + } + if (data != NULL) { + link = tree_get_link_details(hotlist_old_tree, x, y, &before); + node = tree_create_URL_node(NULL, NULL, nsurl, + NULL, hotlist_old_node_callback, NULL); + tree_link_node(hotlist_old_tree, link, node, before); + } + nsurl_unref(nsurl); +} + +/** + * Open the selected entries in separate browser windows. + * + * \param tabs open multiple entries in tabs in the new window + */ +void hotlist_old_launch_selected(bool tabs) +{ + tree_launch_selected(hotlist_old_tree, tabs); +} + +/** + * Set the hotlist's default folder to the selected node. + * + * \param clear reset the default to tree root + */ +bool hotlist_old_set_default_folder(bool clear) +{ + if (clear == true) { + tree_clear_default_folder_node(hotlist_old_tree); + return true; + } else { + return tree_set_default_folder_node(hotlist_old_tree, NULL); + } +} diff --git a/desktop/hotlist_old.h b/desktop/hotlist_old.h new file mode 100644 index 000000000..776bef290 --- /dev/null +++ b/desktop/hotlist_old.h @@ -0,0 +1,64 @@ +/* + * Copyright 2004, 2005 Richard Wilson + * Copyright 2009 Paul Blokus + * + * 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 . + */ + + + +/** \file + * Hotlist (interface). + */ + +#ifndef _NETSURF_DESKTOP_HOTLIST_OLD_H_ +#define _NETSURF_DESKTOP_HOTLIST_OLD_H_ + +#include + +#include "desktop/tree.h" + +/** + * Initialise the hotlist from a frontend. + * + * \param tree The tree object which holds the hotlist. + * \param hotlist_path The file path to initialise the hotlist entries from. + * \param folder_icon_name The name to use for folder icons. + */ +bool hotlist_old_initialise(struct tree *tree, const char *hotlist_path, const char* folder_icon_name); + +unsigned int hotlist_old_get_tree_flags(void); +void hotlist_old_cleanup(const char *hotlist_path); + +void hotlist_old_visited(struct hlcache_handle *c); + +bool hotlist_old_export(const char *path); +void hotlist_old_edit_selected(void); +void hotlist_old_delete_selected(void); +void hotlist_old_select_all(void); +void hotlist_old_clear_selection(void); +void hotlist_old_expand_all(void); +void hotlist_old_expand_directories(void); +void hotlist_old_expand_addresses(void); +void hotlist_old_collapse_all(void); +void hotlist_old_collapse_directories(void); +void hotlist_old_collapse_addresses(void); +void hotlist_old_add_folder(bool selected); +void hotlist_old_add_entry(bool selected); +void hotlist_old_add_page(const char *url); +void hotlist_old_add_page_xy(const char *url, int x, int y); +void hotlist_old_launch_selected(bool tabs); +bool hotlist_old_set_default_folder(bool clear); +#endif diff --git a/desktop/treeview.c b/desktop/treeview.c index c45e91435..5b52db5f7 100644 --- a/desktop/treeview.c +++ b/desktop/treeview.c @@ -148,12 +148,14 @@ struct treeview_resource { bool ready; }; /**< Treeview content resource data */ enum treeview_resource_id { - TREE_RES_CONTENT = 0, + TREE_RES_ARROW = 0, + TREE_RES_CONTENT, TREE_RES_FOLDER, TREE_RES_SEARCH, TREE_RES_LAST }; static struct treeview_resource treeview_res[TREE_RES_LAST] = { + { "resource:icons/arrow-l.png", NULL, 0, false }, { "resource:icons/content.png", NULL, 0, false }, { "resource:icons/directory.png", NULL, 0, false }, { "resource:icons/search.png", NULL, 0, false } diff --git a/gtk/hotlist.c b/gtk/hotlist.c index d249d3444..834699a1d 100644 --- a/gtk/hotlist.c +++ b/gtk/hotlist.c @@ -17,7 +17,7 @@ */ -#include "desktop/hotlist.h" +#include "desktop/hotlist_old.h" #include "utils/nsoption.h" #include "desktop/plotters.h" #include "desktop/tree.h" @@ -121,7 +121,7 @@ bool nsgtk_hotlist_init(const char *glade_file_location) "hotlistDrawingArea")); - hotlist_window = nsgtk_treeview_create(hotlist_get_tree_flags(), window, + hotlist_window = nsgtk_treeview_create(hotlist_old_get_tree_flags(), window, scrolled, drawing_area); if (hotlist_window == NULL) @@ -133,7 +133,7 @@ bool nsgtk_hotlist_init(const char *glade_file_location) CONNECT(window, "delete_event", gtk_widget_hide_on_delete, NULL); CONNECT(window, "hide", nsgtk_tree_window_hide, hotlist_window); - hotlist_initialise(nsgtk_treeview_get_tree(hotlist_window), + hotlist_old_initialise(nsgtk_treeview_get_tree(hotlist_window), nsoption_charp(hotlist_path), tree_directory_icon_name); @@ -168,7 +168,7 @@ void nsgtk_hotlist_init_menu(void) void nsgtk_hotlist_destroy(void) { /* TODO: what about gladeFile? */ - hotlist_cleanup(nsoption_charp(hotlist_path)); + hotlist_old_cleanup(nsoption_charp(hotlist_path)); nsgtk_treeview_destroy(hotlist_window); } @@ -194,7 +194,7 @@ MENUHANDLER(export) gchar *filename = gtk_file_chooser_get_filename( GTK_FILE_CHOOSER(save_dialog)); - hotlist_export(filename); + hotlist_old_export(filename); g_free(filename); } @@ -205,80 +205,80 @@ MENUHANDLER(export) MENUHANDLER(new_folder) { - hotlist_add_folder(true); + hotlist_old_add_folder(true); return TRUE; } MENUHANDLER(new_entry) { - hotlist_add_entry(true); + hotlist_old_add_entry(true); return TRUE; } /* edit menu */ MENUHANDLER(edit_selected) { - hotlist_edit_selected(); + hotlist_old_edit_selected(); return TRUE; } MENUHANDLER(delete_selected) { - hotlist_delete_selected(); + hotlist_old_delete_selected(); return TRUE; } MENUHANDLER(select_all) { - hotlist_select_all(); + hotlist_old_select_all(); return TRUE; } MENUHANDLER(clear_selection) { - hotlist_clear_selection(); + hotlist_old_clear_selection(); return TRUE; } /* view menu*/ MENUHANDLER(expand_all) { - hotlist_expand_all(); + hotlist_old_expand_all(); return TRUE; } MENUHANDLER(expand_directories) { - hotlist_expand_directories(); + hotlist_old_expand_directories(); return TRUE; } MENUHANDLER(expand_addresses) { - hotlist_expand_addresses(); + hotlist_old_expand_addresses(); return TRUE; } MENUHANDLER(collapse_all) { - hotlist_collapse_all(); + hotlist_old_collapse_all(); return TRUE; } MENUHANDLER(collapse_directories) { - hotlist_collapse_directories(); + hotlist_old_collapse_directories(); return TRUE; } MENUHANDLER(collapse_addresses) { - hotlist_collapse_addresses(); + hotlist_old_collapse_addresses(); return TRUE; } MENUHANDLER(launch) { - hotlist_launch_selected(true); + hotlist_old_launch_selected(true); return TRUE; } diff --git a/gtk/scaffolding.c b/gtk/scaffolding.c index c0736985c..d2aabafb4 100644 --- a/gtk/scaffolding.c +++ b/gtk/scaffolding.c @@ -34,7 +34,7 @@ #include "css/utils.h" #include "desktop/browser_private.h" #include "desktop/local_history.h" -#include "desktop/hotlist.h" +#include "desktop/hotlist_old.h" #include "desktop/gui.h" #include "desktop/netsurf.h" #include "utils/nsoption.h" @@ -1540,7 +1540,7 @@ MULTIHANDLER(addbookmarks) if (bw == NULL || bw->current_content == NULL || hlcache_handle_get_url(bw->current_content) == NULL) return TRUE; - hotlist_add_page(nsurl_access(hlcache_handle_get_url(bw->current_content))); + hotlist_old_add_page(nsurl_access(hlcache_handle_get_url(bw->current_content))); return TRUE; } diff --git a/riscos/gui.c b/riscos/gui.c index 4e6deaf7d..3365d813c 100644 --- a/riscos/gui.c +++ b/riscos/gui.c @@ -58,7 +58,7 @@ #include "desktop/cookies_old.h" #include "desktop/gui.h" #include "desktop/history_global_core.h" -#include "desktop/hotlist.h" +#include "desktop/hotlist_old.h" #include "desktop/netsurf.h" #include "utils/nsoption.h" #include "desktop/save_complete.h" @@ -942,7 +942,7 @@ void gui_quit(void) ro_gui_window_quit(); history_global_cleanup(); cookies_cleanup(); - hotlist_cleanup(nsoption_charp(hotlist_save)); + hotlist_old_cleanup(nsoption_charp(hotlist_save)); ro_gui_saveas_quit(); rufl_quit(); free(gui_sprites); diff --git a/riscos/hotlist.c b/riscos/hotlist.c index b8449cd21..fc97a0287 100644 --- a/riscos/hotlist.c +++ b/riscos/hotlist.c @@ -33,7 +33,7 @@ #include "content/content.h" #include "content/hlcache.h" #include "content/urldb.h" -#include "desktop/hotlist.h" +#include "desktop/hotlist_old.h" #include "desktop/tree.h" #include "riscos/dialog.h" #include "riscos/hotlist.h" @@ -131,7 +131,7 @@ void ro_gui_hotlist_postinitialise(void) hotlist_window.tv = ro_treeview_create(hotlist_window.window, hotlist_window.toolbar, &ro_hotlist_treeview_callbacks, - hotlist_get_tree_flags()); + hotlist_old_get_tree_flags()); if (hotlist_window.tv == NULL) { LOG(("Failed to allocate treeview")); return; @@ -142,7 +142,7 @@ void ro_gui_hotlist_postinitialise(void) /* Initialise the hotlist into the tree. */ - hotlist_initialise(ro_treeview_get_tree(hotlist_window.tv), + hotlist_old_initialise(ro_treeview_get_tree(hotlist_window.tv), nsoption_charp(hotlist_path), tree_directory_icon_name); @@ -236,31 +236,31 @@ void ro_gui_hotlist_toolbar_click(button_bar_action action) { switch (action) { case TOOLBAR_BUTTON_DELETE: - hotlist_delete_selected(); + hotlist_old_delete_selected(); break; case TOOLBAR_BUTTON_EXPAND: - hotlist_expand_addresses(); + hotlist_old_expand_addresses(); break; case TOOLBAR_BUTTON_COLLAPSE: - hotlist_collapse_addresses(); + hotlist_old_collapse_addresses(); break; case TOOLBAR_BUTTON_OPEN: - hotlist_expand_directories(); + hotlist_old_expand_directories(); break; case TOOLBAR_BUTTON_CLOSE: - hotlist_collapse_directories(); + hotlist_old_collapse_directories(); break; case TOOLBAR_BUTTON_LAUNCH: - hotlist_launch_selected(false); + hotlist_old_launch_selected(false); break; case TOOLBAR_BUTTON_CREATE: - hotlist_add_folder(true); + hotlist_old_add_folder(true); break; default: @@ -375,43 +375,43 @@ bool ro_gui_hotlist_menu_select(wimp_w w, wimp_i i, wimp_menu *menu, ro_gui_dialog_open_persistent(w, dialog_saveas, true); return true; case TREE_NEW_FOLDER: - hotlist_add_folder(true); + hotlist_old_add_folder(true); return true; case TREE_NEW_LINK: - hotlist_add_entry(true); + hotlist_old_add_entry(true); return true; case TREE_EXPAND_ALL: - hotlist_expand_all(); + hotlist_old_expand_all(); return true; case TREE_EXPAND_FOLDERS: - hotlist_expand_directories(); + hotlist_old_expand_directories(); return true; case TREE_EXPAND_LINKS: - hotlist_expand_addresses(); + hotlist_old_expand_addresses(); return true; case TREE_COLLAPSE_ALL: - hotlist_collapse_all(); + hotlist_old_collapse_all(); return true; case TREE_COLLAPSE_FOLDERS: - hotlist_collapse_directories(); + hotlist_old_collapse_directories(); return true; case TREE_COLLAPSE_LINKS: - hotlist_collapse_addresses(); + hotlist_old_collapse_addresses(); return true; case TREE_SELECTION_EDIT: - hotlist_edit_selected(); + hotlist_old_edit_selected(); return true; case TREE_SELECTION_LAUNCH: - hotlist_launch_selected(false); + hotlist_old_launch_selected(false); return true; case TREE_SELECTION_DELETE: - hotlist_delete_selected(); + hotlist_old_delete_selected(); return true; case TREE_SELECT_ALL: - hotlist_select_all(); + hotlist_old_select_all(); return true; case TREE_CLEAR_SELECTION: - hotlist_clear_selection(); + hotlist_old_clear_selection(); return true; case TOOLBAR_BUTTONS: ro_toolbar_set_display_buttons(hotlist_window.toolbar, @@ -482,7 +482,7 @@ void ro_gui_hotlist_add_page(const char *url) */ if (!nsoption_bool(external_hotlists)) { - hotlist_add_page(url); + hotlist_old_add_page(url); return; } @@ -543,7 +543,7 @@ static void ro_gui_hotlist_addurl_bounce(wimp_message *message) LOG(("Hotlist AddURL Bounced")); if (hotlist_url != NULL) - hotlist_add_page(hotlist_url); + hotlist_old_add_page(hotlist_url); ro_gui_hotlist_add_cleanup(); @@ -606,7 +606,7 @@ void ro_gui_hotlist_url_drop(wimp_message *message, const char *url) message->data.data_xfer.pos.x, message->data.data_xfer.pos.y, &x, &y); - hotlist_add_page_xy(url, x, y); + hotlist_old_add_page_xy(url, x, y); } #endif diff --git a/riscos/menus.c b/riscos/menus.c index bf9fa84a2..5a576f879 100644 --- a/riscos/menus.c +++ b/riscos/menus.c @@ -39,7 +39,6 @@ #include "desktop/gui.h" #include "desktop/history_global_core.h" #include "desktop/local_history.h" -#include "desktop/hotlist.h" #include "desktop/netsurf.h" #include "desktop/textinput.h" #include "riscos/dialog.h" diff --git a/riscos/save.c b/riscos/save.c index 390165d3b..0a9114080 100644 --- a/riscos/save.c +++ b/riscos/save.c @@ -37,7 +37,7 @@ #include "oslib/wimpspriteop.h" #include "content/content.h" #include "content/hlcache.h" -#include "desktop/hotlist.h" +#include "desktop/hotlist_old.h" #include "desktop/history_global_core.h" #include "desktop/netsurf.h" #include "desktop/save_complete.h" @@ -882,7 +882,7 @@ bool ro_gui_save_content(hlcache_handle *h, char *path, bool force_overwrite) LINK_TEXT, path); case GUI_SAVE_HOTLIST_EXPORT_HTML: - if (!hotlist_export(path)) + if (!hotlist_old_export(path)) return false; error = xosfile_set_type(path, 0xfaf); if (error) diff --git a/riscos/window.c b/riscos/window.c index cbb31cf63..797176378 100644 --- a/riscos/window.c +++ b/riscos/window.c @@ -50,7 +50,6 @@ #include "desktop/scrollbar.h" #include "desktop/frames.h" #include "desktop/local_history.h" -#include "desktop/hotlist.h" #include "desktop/mouse.h" #include "desktop/plotters.h" #include "desktop/textinput.h" -- cgit v1.2.3