summaryrefslogtreecommitdiff
path: root/amiga
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2010-10-05 19:14:46 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2010-10-05 19:14:46 +0000
commit6173bb0e6c3bf51cd463f7bc4f725429d9087b2b (patch)
treede3e013699742960b97ee4a5eda240908d0ea8e6 /amiga
parent195c1ea3193f169c6825eca1fc6207e138126e98 (diff)
downloadnetsurf-6173bb0e6c3bf51cd463f7bc4f725429d9087b2b.tar.gz
netsurf-6173bb0e6c3bf51cd463f7bc4f725429d9087b2b.tar.bz2
Merge treeview-redux to trunk
svn path=/trunk/netsurf/; revision=10865
Diffstat (limited to 'amiga')
-rwxr-xr-xamiga/cookies.c149
-rwxr-xr-xamiga/cookies.h5
-rwxr-xr-xamiga/gui.c89
-rwxr-xr-xamiga/gui.h12
-rwxr-xr-xamiga/history.c357
-rwxr-xr-xamiga/history.h3
-rwxr-xr-xamiga/hotlist.c134
-rwxr-xr-xamiga/hotlist.h9
-rwxr-xr-xamiga/menu.c476
-rwxr-xr-xamiga/menu.h15
-rwxr-xr-xamiga/object.c14
-rwxr-xr-xamiga/object.h1
-rw-r--r--amiga/options.h3
-rwxr-xr-xamiga/plotters.c20
-rwxr-xr-xamiga/resources/Themes/AISS/Theme8
-rwxr-xr-xamiga/resources/Themes/Default/Theme8
l---------amiga/resources/Themes/Default/content.png1
l---------amiga/resources/Themes/Default/directory.png1
-rw-r--r--amiga/sslcert.c216
-rw-r--r--amiga/sslcert.h24
-rw-r--r--amiga/theme.c17
-rw-r--r--amiga/theme.h2
-rwxr-xr-xamiga/tree.c1313
-rwxr-xr-xamiga/tree.h29
24 files changed, 1254 insertions, 1652 deletions
diff --git a/amiga/cookies.c b/amiga/cookies.c
index cffa52337..76e2173f2 100755
--- a/amiga/cookies.c
+++ b/amiga/cookies.c
@@ -1,6 +1,5 @@
/*
- * Copyright 2006 Richard Wilson <info@tinct.net>
- * Copyright 2008 Chris Young <chris@unsatisfactorysoftware.co.uk>
+ * Copyright 2008, 2009 Chris Young <chris@unsatisfactorysoftware.co.uk>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
*
@@ -17,151 +16,23 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-/** \file
- * Cookies (implementation).
- */
-
-#include <string.h>
-#include "content/urldb.h"
-#include "desktop/cookies.h"
-#include "desktop/tree.h"
-#include "utils/messages.h"
-#include "utils/log.h"
-#include "amiga/cookies.h"
#include <proto/exec.h>
-#include <assert.h>
-#include "utils/utils.h"
-
-static bool cookies_init;
-
-struct node *ami_cookies_find(const char *url);
+#include "amiga/cookies.h"
+#include "desktop/cookies.h"
+#include "amiga/tree.h"
-/**
- * Initialise cookies tree
- */
void ami_cookies_initialise(void)
{
- if(cookies_tree) return;
-
- /* Create an empty tree */
- cookies_tree = AllocVec(sizeof(struct tree),MEMF_CLEAR | MEMF_PRIVATE);
- if (!cookies_tree) {
- warn_user("NoMemory", 0);
- return;
- }
- cookies_tree->root = tree_create_folder_node(NULL, "Root");
- if (!cookies_tree->root) {
- warn_user("NoMemory", 0);
- FreeVec(cookies_tree);
- cookies_tree = NULL;
- }
- cookies_tree->root->expanded = true;
- cookies_tree->movable = false;
- cookies_tree->no_drag = true;
-
- cookies_init = true;
- urldb_iterate_cookies(cookies_update);
- cookies_init = false;
- tree_initialise(cookies_tree);
-}
-
-/**
- * Perform cookie addition
- *
- * \param data Cookie data for a domain, or NULL
- * \return true (for urldb_iterate_entries)
- */
-bool cookies_update(const char *domain, const struct cookie_data *data)
-{
- struct node *parent;
- struct node *node = NULL;
- struct node *child;
- struct node *add;
- const struct cookie_data *cookie = NULL;
- bool expanded;
-
- assert(domain);
-
- /* check if we're a domain, and add get the first cookie */
- if (data)
- for (cookie = data; cookie->prev; cookie = cookie->prev);
-
- if (!cookies_init) {
- node = ami_cookies_find(domain);
- if (node) {
- /* mark as deleted so we don't remove the cookies */
- expanded = node->expanded;
- for (child = node->child; child; child = child->next)
- child->deleted = true;
- if (node->child)
- tree_delete_node(cookies_tree, node->child,
- true);
- /* deleting will have contracted our node */
- node->expanded = expanded;
- }
- if (!data) {
- if (!node)
- return true;
- tree_delete_node(cookies_tree, node, false);
- tree_handle_node_changed(cookies_tree,
- cookies_tree->root, true, false);
- return true;
- }
- }
-
- if (!node) {
- for (parent = cookies_tree->root->child; parent;
- parent = parent->next) {
- if (strcmp(domain, parent->data.text) == 0)
- break;
- }
- if (!parent) {
- node = tree_create_folder_node(cookies_tree->root,
- domain);
- } else {
- node = parent;
- }
- }
- if (!node)
- return true;
- node->editable = false;
+ cookies_window = ami_tree_create(cookies_get_tree_flags(), NULL);
- for (; cookie; cookie = cookie->next) {
- add = tree_create_cookie_node(node, cookie);
- if (add && !cookies_init)
- tree_handle_node_changed(cookies_tree, add,
- true, false);
- }
- if (!cookies_init) {
- tree_handle_node_changed(cookies_tree, node,
- true, false);
-/*
- tree_redraw_area(cookies_tree,
- node->box.x - NODE_INSTEP,
- 0, NODE_INSTEP, 16384);
-*/
- }
- return true;
-}
-
-/**
- * Find an entry in the cookie tree
- *
- * \param url The URL to find
- * \return Pointer to node, or NULL if not found
- */
-struct node *ami_cookies_find(const char *url)
-{
- struct node *node;
+ if(!cookies_window) return;
- for (node = cookies_tree->root->child; node; node = node->next) {
- if (!strcmp(url, node->data.text))
- return node;
- }
- return NULL;
+ cookies_initialise(ami_tree_get_tree(cookies_window));
}
void ami_cookies_free()
{
- FreeVec(cookies_tree);
+ cookies_cleanup();
+ ami_tree_destroy(cookies_window);
+ cookies_window = NULL;
}
diff --git a/amiga/cookies.h b/amiga/cookies.h
index 4d376434c..d6922750c 100755
--- a/amiga/cookies.h
+++ b/amiga/cookies.h
@@ -1,5 +1,5 @@
/*
- * Copyright 2008 Chris Young <chris@unsatisfactorysoftware.co.uk>
+ * Copyright 2008, 2009 Chris Young <chris@unsatisfactorysoftware.co.uk>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
*
@@ -19,9 +19,10 @@
#ifndef AMIGA_COOKIES_H
#define AMIGA_COOKIES_H
#include "desktop/tree.h"
+#include "amiga/tree.h"
void ami_cookies_initialise(void);
void ami_cookies_free(void);
-struct tree *cookies_tree;
+struct treeview_window *cookies_window;
#endif
diff --git a/amiga/gui.c b/amiga/gui.c
index 6372a435a..759b4f932 100755
--- a/amiga/gui.c
+++ b/amiga/gui.c
@@ -143,6 +143,8 @@ BOOL screen_closed = FALSE;
struct MsgPort *applibport = NULL;
ULONG applibsig = 0;
+const char tree_directory_icon_name[100];
+const char tree_content_icon_name[100];
extern colour scroll_widget_fg_colour;
extern colour scroll_widget_bg_colour;
extern colour scroll_widget_arrow_colour;
@@ -324,9 +326,6 @@ void ami_set_options(void)
if((!option_url_file) || (option_url_file[0] == '\0'))
option_url_file = (char *)strdup("PROGDIR:Resources/URLs");
- if((!option_recent_file) || (option_recent_file[0] == '\0'))
- option_recent_file = (char *)strdup("PROGDIR:Resources/Recent");
-
/*
if((!option_cookie_jar) || (option_cookie_jar[0] == '\0'))
option_cookie_jar = (char *)strdup("PROGDIR:Resources/CookieJar");
@@ -453,7 +452,6 @@ void gui_init(int argc, char** argv)
plot=amiplot;
- ami_init_menulabs();
if(option_context_menu) ami_context_menu_init();
schedule_list = NewObjList();
@@ -462,15 +460,6 @@ void gui_init(int argc, char** argv)
urldb_load(option_url_file);
urldb_load_cookies(option_cookie_file);
- if(lock = Lock(option_hotlist_file,SHARED_LOCK))
- {
- UnLock(lock);
- hotlist = options_load_tree(option_hotlist_file);
- }
-
- if(!hotlist) ami_hotlist_init(&hotlist);
- ami_global_history_initialise();
- ami_cookies_initialise();
save_complete_init();
ami_theme_init();
ami_init_mouse_pointers();
@@ -567,6 +556,18 @@ static void gui_init2(int argc, char** argv)
notalreadyrunning = ami_arexx_init();
+ /* Treeview init code ends up calling a font function which needs this */
+ browserglob.scale = 1.0;
+ glob = &browserglob;
+ /**/
+
+ ami_get_theme_filename(&tree_directory_icon_name,"theme_list_folder",true);
+ ami_get_theme_filename(&tree_content_icon_name,"theme_list_content",true);
+ ami_hotlist_initialise(option_hotlist_file);
+ ami_cookies_initialise();
+ ami_global_history_initialise();
+ sslcert_init();
+
search_web_provider_details(option_search_provider);
if(argc) // argc==0 is started from wb
@@ -1331,7 +1332,7 @@ void ami_handle_msg(void)
case 'h':
if((option_kiosk_mode == false) &&
(gwin->bw->browser_window_type == BROWSER_WINDOW_NORMAL))
- ami_open_tree(hotlist,AMI_TREE_HOTLIST);
+ ami_tree_open(hotlist_window, AMI_TREE_HOTLIST);
break;
/* The following aren't available from the menu at the moment */
@@ -2002,11 +2003,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_hotlist_free(option_hotlist_file);
ami_cookies_free();
ami_global_history_free();
+ sslcert_cleanup();
hubbub_finalise(ns_realloc,NULL);
@@ -2033,7 +2033,10 @@ void gui_quit(void)
FreeVec(nsscreentitle);
if(option_context_menu) ami_context_menu_free();
- ami_free_menulabs();
+
+/* fixme: need newmenu struct propd to this function - should this be freed here?
+ ami_free_menulabs(menu);
+*/
ami_mouse_pointers_free();
ami_clipboard_free();
@@ -2187,7 +2190,6 @@ void ami_toggletabbar(struct gui_window_2 *gwin, bool show)
struct gui_window *gui_create_browser_window(struct browser_window *bw,
struct browser_window *clone, bool new_tab)
{
- struct NewMenu *menu;
struct gui_window *gwin = NULL;
bool closegadg=TRUE;
struct Node *node;
@@ -2357,7 +2359,7 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw,
{
ULONG addtabclosegadget = TAG_IGNORE;
- menu = ami_create_menu(bw->browser_window_type);
+ ami_create_menu(bw->browser_window_type, gwin->shared);
NewList(&gwin->shared->tab_list);
gwin->tab_node = AllocClickTabNode(TNA_Text,messages_get("NetSurf"),
@@ -2389,28 +2391,28 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw,
gwin->shared->helphints[GID_ADDTAB] =
remove_escape_chars(messages_get("HelpAddTab"), true);
- ami_get_theme_filename(nav_west,"theme_nav_west");
- ami_get_theme_filename(nav_west_s,"theme_nav_west_s");
- ami_get_theme_filename(nav_west_g,"theme_nav_west_g");
- ami_get_theme_filename(nav_east,"theme_nav_east");
- ami_get_theme_filename(nav_east_s,"theme_nav_east_s");
- ami_get_theme_filename(nav_east_g,"theme_nav_east_g");
- ami_get_theme_filename(stop,"theme_stop");
- ami_get_theme_filename(stop_s,"theme_stop_s");
- ami_get_theme_filename(stop_g,"theme_stop_g");
- ami_get_theme_filename(reload,"theme_reload");
- ami_get_theme_filename(reload_s,"theme_reload_s");
- ami_get_theme_filename(reload_g,"theme_reload_g");
- ami_get_theme_filename(home,"theme_home");
- ami_get_theme_filename(home_s,"theme_home_s");
- ami_get_theme_filename(home_g,"theme_home_g");
- ami_get_theme_filename(closetab,"theme_closetab");
- ami_get_theme_filename(closetab_s,"theme_closetab_s");
- ami_get_theme_filename(closetab_g,"theme_closetab_g");
- ami_get_theme_filename(addtab,"theme_addtab");
- ami_get_theme_filename(addtab_s,"theme_addtab_s");
- ami_get_theme_filename(addtab_g,"theme_addtab_g");
- ami_get_theme_filename(tabthrobber,"theme_tab_loading");
+ ami_get_theme_filename(nav_west,"theme_nav_west",false);
+ ami_get_theme_filename(nav_west_s,"theme_nav_west_s",false);
+ ami_get_theme_filename(nav_west_g,"theme_nav_west_g",false);
+ ami_get_theme_filename(nav_east,"theme_nav_east",false);
+ ami_get_theme_filename(nav_east_s,"theme_nav_east_s",false);
+ ami_get_theme_filename(nav_east_g,"theme_nav_east_g",false);
+ ami_get_theme_filename(stop,"theme_stop",false);
+ ami_get_theme_filename(stop_s,"theme_stop_s",false);
+ ami_get_theme_filename(stop_g,"theme_stop_g",false);
+ ami_get_theme_filename(reload,"theme_reload",false);
+ ami_get_theme_filename(reload_s,"theme_reload_s",false);
+ ami_get_theme_filename(reload_g,"theme_reload_g",false);
+ ami_get_theme_filename(home,"theme_home",false);
+ ami_get_theme_filename(home_s,"theme_home_s",false);
+ ami_get_theme_filename(home_g,"theme_home_g",false);
+ ami_get_theme_filename(closetab,"theme_closetab",false);
+ ami_get_theme_filename(closetab_s,"theme_closetab_s",false);
+ ami_get_theme_filename(closetab_g,"theme_closetab_g",false);
+ ami_get_theme_filename(addtab,"theme_addtab",false);
+ ami_get_theme_filename(addtab_s,"theme_addtab_s",false);
+ ami_get_theme_filename(addtab_g,"theme_addtab_g",false);
+ ami_get_theme_filename(tabthrobber,"theme_tab_loading",false);
gwin->shared->objects[GID_ADDTAB_BM] = BitMapObject,
BITMAP_SourceFile, addtab,
@@ -2482,7 +2484,7 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw,
IDCMP_GADGETUP | IDCMP_IDCMPUPDATE |
IDCMP_ACTIVEWINDOW | IDCMP_INTUITICKS |
IDCMP_EXTENDEDMOUSE | IDCMP_GADGETDOWN,
- WINDOW_NewMenu,menu,
+ WINDOW_NewMenu, gwin->shared->menu,
WINDOW_VertProp,1,
WINDOW_IDCMPHook,&gwin->shared->scrollerhook,
WINDOW_IDCMPHookBits,IDCMP_IDCMPUPDATE |
@@ -2934,6 +2936,7 @@ void gui_window_destroy(struct gui_window *g)
DisposeObject(g->shared->objects[OID_MAIN]);
+ ami_free_menulabs(g->shared);
free(g->shared->wintitle);
ami_utf8_free(g->shared->status);
FreeVec(g->shared->svbuffer);
diff --git a/amiga/gui.h b/amiga/gui.h
index dce118b89..70c1d2db3 100755
--- a/amiga/gui.h
+++ b/amiga/gui.h
@@ -23,8 +23,10 @@
#include <intuition/classusr.h>
#include "desktop/browser.h"
#include <dos/dos.h>
+#include <devices/inputevent.h>
#include "desktop/gui.h"
#include "amiga/plotters.h"
+#include "amiga/menu.h"
enum
{
@@ -56,11 +58,7 @@ enum
GID_PASS,
GID_LOGIN,
GID_CANCEL,
- GID_TREEBROWSER,
GID_OPEN,
- GID_LEFT,
- GID_UP,
- GID_DOWN,
GID_NEWF,
GID_NEWB,
GID_DEL,
@@ -98,6 +96,11 @@ struct gui_window_2 {
ULONG oldv;
bool redraw_scroll;
bool new_content;
+ char *menulab[AMI_MENU_AREXX_MAX + 1];
+ char menukey[AMI_MENU_AREXX_MAX + 1];
+ UBYTE *menutype;
+ struct NewMenu *menu;
+ ULONG hotlist_items;
char *svbuffer;
char *status;
char *wintitle;
@@ -127,6 +130,7 @@ void ami_close_all_tabs(struct gui_window_2 *gwin);
void ami_quit_netsurf(void);
void ami_do_redraw(struct gui_window_2 *g);
STRPTR ami_locale_langs(void);
+int ami_key_to_nskey(ULONG keycode, struct InputEvent *ie);
struct box *ami_text_box_at_point(struct gui_window_2 *gwin, ULONG *x, ULONG *y);
struct gui_window_2 *ami_window_at_pointer(void);
diff --git a/amiga/history.c b/amiga/history.c
index 5e685b76a..19ba9aff9 100755
--- a/amiga/history.c
+++ b/amiga/history.c
@@ -1,6 +1,5 @@
/*
- * Copyright 2005 Richard Wilson <info@tinct.net>
- * Copyright 2008 Chris Young <chris@unsatisfactorysoftware.co.uk>
+ * Copyright 2008, 2009 Chris Young <chris@unsatisfactorysoftware.co.uk>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
*
@@ -17,362 +16,24 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "desktop/browser.h"
#include "amiga/history.h"
#include "amiga/tree.h"
-#include "content/urldb.h"
-#include <proto/dos.h>
-#include "amiga/options.h"
+#include "desktop/history_global_core.h"
#include <proto/exec.h>
-#include <assert.h>
-#include <utils/log.h>
-
-#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_node(const char *title,
- time_t base, int days_back);
-void ami_global_history_initialise_nodes(void);
+#include "amiga/tree.h"
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;
- ami_global_history_initialise_nodes();
- 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;
- }
- }
+ global_history_window = ami_tree_create(history_global_get_tree_flags(), NULL);
- 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_window) return;
- 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;
+ history_global_initialise(ami_tree_get_tree(global_history_window));
}
void ami_global_history_free()
{
- FreeVec(global_history_tree);
-}
-
-/**
- * Initialises the base nodes
- */
-void ami_global_history_initialise_nodes(void)
-{
- struct tm *full_time;
- time_t t;
- int weekday;
- int i;
-
- /* get the current time */
- t = time(NULL);
- if (t == -1)
- return;
-
- /* get the time at the start of today */
- full_time = localtime(&t);
- weekday = full_time->tm_wday;
- full_time->tm_sec = 0;
- full_time->tm_min = 0;
- full_time->tm_hour = 0;
- t = mktime(full_time);
- if (t == -1)
- return;
-
- ami_global_history_initialise_node((char *)messages_get("DateToday"), t, 0);
- if (weekday > 0)
- ami_global_history_initialise_node(
- (char *)messages_get("DateYesterday"), t, -1);
- for (i = 2; i <= weekday; i++)
- ami_global_history_initialise_node(NULL, t, -i);
- ami_global_history_initialise_node((char *)messages_get("Date1Week"),
- t, -weekday - 7);
- ami_global_history_initialise_node((char *)messages_get("Date2Week"),
- t, -weekday - 14);
- ami_global_history_initialise_node((char *)messages_get("Date3Week"),
- t, -weekday - 21);
+ history_global_cleanup();
+ ami_tree_destroy(global_history_window);
+ global_history_window = NULL;
}
-
-/**
- * Create and initialise a node
- */
-void ami_global_history_initialise_node(const char *title,
- time_t base, int days_back)
-{
- struct tm *full_time;
- char buffer[64];
- struct node *node;
-
- base += days_back * 60 * 60 * 24;
- if (!title) {
- full_time = localtime(&base);
- strftime((char *)&buffer, (size_t)64, "%A", full_time);
- node = tree_create_folder_node(NULL, buffer);
- } else
- node = tree_create_folder_node(NULL, title);
-
- if (!node)
- return;
-
- node->retain_in_memory = true;
- node->deleted = true;
- node->editable = false;
- global_history_base_node[global_history_base_node_count] = node;
- global_history_base_node_time[global_history_base_node_count] = base;
- global_history_base_node_count++;
-}
-
diff --git a/amiga/history.h b/amiga/history.h
index c9f8254dc..b69d46c6a 100755
--- a/amiga/history.h
+++ b/amiga/history.h
@@ -19,11 +19,12 @@
#ifndef AMIGA_HISTORY_H
#define AMIGA_HISTORY_H
#include "desktop/tree.h"
+#include "desktop/history_global_core.h"
#define GLOBAL_HISTORY_RECENT_URLS 16
void ami_global_history_initialise(void);
void ami_global_history_free(void);
-struct tree *global_history_tree;
+struct treeview_window *global_history_window;
#endif
diff --git a/amiga/hotlist.c b/amiga/hotlist.c
index 71c5ddbba..f90f3645e 100755
--- a/amiga/hotlist.c
+++ b/amiga/hotlist.c
@@ -1,5 +1,4 @@
/*
- * Copyright 2004, 2005 Richard Wilson <info@tinct.net>
* Copyright 2008, 2009 Chris Young <chris@unsatisfactorysoftware.co.uk>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
@@ -17,137 +16,24 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "desktop/browser.h"
-#include "desktop/tree.h"
#include <proto/exec.h>
-#include "content/urldb.h"
#include "amiga/hotlist.h"
+#include "desktop/hotlist.h"
#include "amiga/tree.h"
-void ami_gui_hotlist_visited(hlcache_handle *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/downloads/amiga/", "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(hlcache_handle *c)
+void ami_hotlist_initialise(const char *hotlist_file)
{
- if ((!c) || (!content_get_url(c)) || (!hotlist))
- return;
- ami_gui_hotlist_visited(c, hotlist, hotlist->root);
-}
+ hotlist_window = ami_tree_create(hotlist_get_tree_flags(), NULL);
-/**
- * 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(hlcache_handle *content, struct tree *tree,
- struct node *node)
-{
- struct node_element *element;
+ if(!hotlist_window) return;
- for (; node; node = node->next) {
- if (!node->folder) {
- element = tree_find_element(node, TREE_ELEMENT_URL);
- if ((element) && (!strcmp(element->text,
- content_get_url(content)))) {
- tree_update_URL_node(node, content_get_url(content), NULL);
- tree_handle_node_changed(tree, node, true,
- false);
- }
- }
- if (node->child)
- ami_gui_hotlist_visited(content, tree, node->child);
- }
+ hotlist_initialise(ami_tree_get_tree(hotlist_window),
+ hotlist_file);
}
-void ami_hotlist_init(struct tree **hotlist)
+void ami_hotlist_free(const char *hotlist_file)
{
- struct tree *hotlist_tree;
- struct node *node;
- int i;
- const struct url_data *data;
-
- *hotlist = AllocVec(sizeof(struct tree),MEMF_PRIVATE | 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, "Menu");
- if (!node)
- node = hotlist_tree->root;
-
- node = tree_create_folder_node(node, "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 hlcache_handle *c)
-{
- const struct url_data *data;
-
- data = urldb_get_url_data(content_get_url(c));
- if (!data)
- {
- urldb_add_url(content_get_url(c));
- urldb_set_url_persistence(content_get_url(c),true);
- data = urldb_get_url_data(content_get_url(c));
- }
-
- if (data)
- {
- tree_create_URL_node(node,content_get_url(c),data,content_get_title(c));
- }
-
- tree_handle_node_changed(hotlist,node,false,true);
-
- if(hotlist->handle)
- ami_recreate_listbrowser((struct treeview_window *)hotlist->handle);
+ hotlist_cleanup(hotlist_file);
+ ami_tree_destroy(hotlist_window);
+ hotlist_window = NULL;
}
diff --git a/amiga/hotlist.h b/amiga/hotlist.h
index eed5b0eed..ee258af7b 100755
--- a/amiga/hotlist.h
+++ b/amiga/hotlist.h
@@ -1,5 +1,5 @@
/*
- * Copyright 2008 Chris Young <chris@unsatisfactorysoftware.co.uk>
+ * Copyright 2008, 2009 Chris Young <chris@unsatisfactorysoftware.co.uk>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
*
@@ -19,9 +19,10 @@
#ifndef AMIGA_HOTLIST_H
#define AMIGA_HOTLIST_H
#include "desktop/tree.h"
+#include "amiga/tree.h"
-void ami_hotlist_init(struct tree **hotlist);
-void ami_hotlist_add(struct node *node, struct hlcache_handle *c);
+void ami_hotlist_initialise(const char *hotlist_file);
+void ami_hotlist_free(const char *hotlist_file);
-struct tree *hotlist;
+struct treeview_window *hotlist_window;
#endif
diff --git a/amiga/menu.c b/amiga/menu.c
index 9f5aab757..081b1e568 100755
--- a/amiga/menu.c
+++ b/amiga/menu.c
@@ -41,6 +41,11 @@
#include "amiga/iff_dr2d.h"
#include "amiga/clipboard.h"
#include "amiga/gui_options.h"
+#include "desktop/tree_url_node.h"
+#include <classes/window.h>
+#include <proto/intuition.h>
+#include "desktop/hotlist.h"
+#include <proto/gadtools.h>
#include "amiga/print.h"
#include "amiga/download.h"
@@ -61,226 +66,221 @@ const char * const versvn;
const char * const verdate;
static struct Hook aslhookfunc;
-void ami_menu_scan(struct tree *tree,struct NewMenu *menu);
-void ami_menu_scan_2(struct tree *tree,struct node *root,WORD *gen,ULONG *item,struct NewMenu *menu);
-void ami_menu_arexx_scan(struct NewMenu *menu);
+ULONG ami_menu_scan(struct tree *tree, bool count, struct gui_window_2 *gwin);
+void ami_menu_scan_2(struct tree *tree, struct node *root, WORD *gen,
+ ULONG *item, bool count, struct gui_window_2 *gwin);
+void ami_menu_arexx_scan(struct gui_window_2 *gwin);
static const ULONG ami_asl_mime_hook(struct Hook *mh,struct FileRequester *fr,struct AnchorPathOld *ap);
-void ami_free_menulabs(void)
+void ami_free_menulabs(struct gui_window_2 *gwin)
{
int i;
- for(i=0;i<=AMI_MENU_MAX;i++)
+ for(i=0;i<=AMI_MENU_AREXX_MAX;i++)
{
- if(menulab[i] && (menulab[i] != NM_BARLABEL)) ami_utf8_free(menulab[i]);
+ if(gwin->menulab[i] && (gwin->menulab[i] != NM_BARLABEL))
+ ami_utf8_free(gwin->menulab[i]);
+
+ gwin->menulab[i] = NULL;
+ gwin->menukey[i] = 0;
}
- for(i=AMI_MENU_MAX+1;i<=AMI_MENU_AREXX_MAX;i++)
+ FreeVec(gwin->menutype);
+ FreeVec(gwin->menu);
+
+ gwin->menutype = NULL;
+ gwin->menu = NULL;
+}
+
+void ami_init_menulabs(struct gui_window_2 *gwin)
+{
+ int i;
+
+ gwin->menutype = AllocVec(AMI_MENU_AREXX_MAX + 1, MEMF_PRIVATE | MEMF_CLEAR);
+
+ for(i=0;i <= AMI_MENU_AREXX_MAX;i++)
{
- if(menulab[i] && (menulab[i] != NM_BARLABEL)) free(menulab[i]);
+ gwin->menutype[i] = NM_IGNORE;
+ gwin->menulab[i] = NULL;
}
+
+ gwin->menutype[0] = NM_TITLE;
+ gwin->menulab[0] = ami_utf8_easy((char *)messages_get("Project"));
+ gwin->menutype[1] = NM_ITEM;
+ gwin->menulab[1] = ami_utf8_easy((char *)messages_get("NewWindowNS"));
+ gwin->menukey[1] = 'N';
+ gwin->menutype[2] = NM_ITEM;
+ gwin->menulab[2] = ami_utf8_easy((char *)messages_get("NewTab"));
+ gwin->menukey[1] = 'T';
+ gwin->menutype[3] = NM_ITEM;
+ gwin->menulab[3] = NM_BARLABEL;
+ gwin->menutype[4] = NM_ITEM;
+ gwin->menulab[4] = ami_utf8_easy((char *)messages_get("OpenFile"));
+ gwin->menukey[4] = 'O';
+ gwin->menutype[5] = NM_ITEM;
+ gwin->menulab[5] = ami_utf8_easy((char *)messages_get("SaveAsNS"));
+ gwin->menukey[5] = 'S';
+ gwin->menutype[6] = NM_SUB;
+ gwin->menulab[6] = ami_utf8_easy((char *)messages_get("Source"));
+ gwin->menutype[7] = NM_SUB;
+ gwin->menulab[7] = ami_utf8_easy((char *)messages_get("TextNS"));
+ gwin->menutype[8] = NM_SUB;
+ gwin->menulab[8] = ami_utf8_easy((char *)messages_get("SaveCompNS"));
+ gwin->menutype[9] = NM_SUB;
+ gwin->menulab[9] = ami_utf8_easy((char *)messages_get("PDFNS"));
+ gwin->menutype[10] = NM_SUB;
+ gwin->menulab[10] = ami_utf8_easy((char *)messages_get("IFF"));
+ gwin->menutype[11] = NM_ITEM;
+ gwin->menulab[11] = NM_BARLABEL;
+ gwin->menutype[12] = NM_ITEM;
+ gwin->menulab[12] = ami_utf8_easy((char *)messages_get("CloseTab"));
+ gwin->menukey[12] = 'K';
+ gwin->menutype[13] = NM_ITEM;
+ gwin->menulab[13] = ami_utf8_easy((char *)messages_get("CloseWindow"));
+ gwin->menutype[14] = NM_ITEM;
+ gwin->menulab[14] = NM_BARLABEL;
+ gwin->menutype[15] = NM_ITEM;
+ gwin->menulab[15] = ami_utf8_easy((char *)messages_get("PrintNS"));
+ gwin->menukey[15] = 'P';
+ gwin->menutype[16] = NM_ITEM;
+ gwin->menulab[16] = NM_BARLABEL;
+ gwin->menutype[17] = NM_ITEM;
+ gwin->menulab[17] = ami_utf8_easy((char *)messages_get("About"));
+ gwin->menukey[17] = '?';
+ gwin->menutype[18] = NM_ITEM;
+ gwin->menulab[18] = ami_utf8_easy((char *)messages_get("Quit"));
+ gwin->menukey[18] = 'Q';
+ gwin->menutype[19] = NM_TITLE;
+ gwin->menulab[19] = ami_utf8_easy((char *)messages_get("Edit"));
+ gwin->menutype[20] = NM_ITEM;
+ gwin->menulab[20] = ami_utf8_easy((char *)messages_get("CutNS"));
+ gwin->menukey[20] = 'X';
+ gwin->menutype[21] = NM_ITEM;
+ gwin->menulab[21] = ami_utf8_easy((char *)messages_get("CopyNS"));
+ gwin->menukey[21] = 'C';
+ gwin->menutype[22] = NM_ITEM;
+ gwin->menulab[22] = ami_utf8_easy((char *)messages_get("PasteNS"));
+ gwin->menukey[22] = 'V';
+ gwin->menutype[23] = NM_ITEM;
+ gwin->menulab[23] = NM_BARLABEL;
+ gwin->menutype[24] = NM_ITEM;
+ gwin->menulab[24] = ami_utf8_easy((char *)messages_get("SelectAllNS"));
+ gwin->menukey[24] = 'A';
+ gwin->menutype[25] = NM_ITEM;
+ gwin->menulab[25] = ami_utf8_easy((char *)messages_get("ClearNS"));
+ gwin->menukey[25] = 'Z';
+ gwin->menutype[26] = NM_TITLE;
+ gwin->menulab[26] = ami_utf8_easy((char *)messages_get("Browser"));
+ gwin->menutype[27] = NM_ITEM;
+ gwin->menulab[27] = ami_utf8_easy((char *)messages_get("FindTextNS"));
+ gwin->menukey[27] = 'F';
+ gwin->menutype[28] = NM_ITEM;
+ gwin->menulab[28] = NM_BARLABEL;
+ gwin->menutype[29] = NM_ITEM;
+ gwin->menulab[29] = ami_utf8_easy((char *)messages_get("HistLocalNS"));
+ gwin->menutype[30] = NM_ITEM;
+ gwin->menulab[30] = ami_utf8_easy((char *)messages_get("HistGlobalNS"));
+ gwin->menutype[31] = NM_ITEM;
+ gwin->menulab[31] = NM_BARLABEL;
+ gwin->menutype[32] = NM_ITEM;
+ gwin->menulab[32] = ami_utf8_easy((char *)messages_get("ShowCookies"));
+ gwin->menutype[33] = NM_ITEM;
+ gwin->menulab[33] = NM_BARLABEL;
+ gwin->menutype[34] = NM_ITEM;
+ gwin->menulab[34] = ami_utf8_easy((char *)messages_get("ScaleNS"));
+ gwin->menutype[35] = NM_SUB;
+ gwin->menulab[35] = ami_utf8_easy((char *)messages_get("ScaleDec"));
+ gwin->menukey[35] = '-';
+ gwin->menutype[36] = NM_SUB;
+ gwin->menulab[36] = ami_utf8_easy((char *)messages_get("ScaleNorm"));
+ gwin->menukey[36] = '=';
+ gwin->menutype[37] = NM_SUB;
+ gwin->menulab[37] = ami_utf8_easy((char *)messages_get("ScaleInc"));
+ gwin->menukey[37] = '+';
+ gwin->menutype[38] = NM_ITEM;
+ gwin->menulab[38] = ami_utf8_easy((char *)messages_get("Redraw"));
+ gwin->menutype[39] = NM_TITLE;
+ gwin->menulab[39] = ami_utf8_easy((char *)messages_get("Hotlist"));
+ gwin->menukey[39] = 'H';
+ gwin->menutype[40] = NM_ITEM;
+ gwin->menulab[40] = ami_utf8_easy((char *)messages_get("HotlistAdd"));
+ gwin->menutype[41] = NM_ITEM;
+ gwin->menulab[41] = ami_utf8_easy((char *)messages_get("HotlistShowNS"));
+ gwin->menutype[42] = NM_ITEM;
+ gwin->menulab[42] = NM_BARLABEL;
+
+ gwin->menutype[AMI_MENU_HOTLIST_MAX + 1] = NM_TITLE;
+ gwin->menulab[AMI_MENU_HOTLIST_MAX + 1] = ami_utf8_easy((char *)messages_get("Settings"));
+ gwin->menutype[AMI_MENU_HOTLIST_MAX + 2] = NM_ITEM;
+ gwin->menulab[AMI_MENU_HOTLIST_MAX + 2] = ami_utf8_easy((char *)messages_get("SettingsEdit"));
+ gwin->menutype[AMI_MENU_HOTLIST_MAX + 3] = NM_ITEM;
+ gwin->menulab[AMI_MENU_HOTLIST_MAX + 3] = NM_BARLABEL;
+ gwin->menutype[AMI_MENU_HOTLIST_MAX + 4] = NM_ITEM;
+ gwin->menulab[AMI_MENU_HOTLIST_MAX + 4] = ami_utf8_easy((char *)messages_get("SnapshotWindow"));
+ gwin->menutype[AMI_MENU_HOTLIST_MAX + 5] = NM_ITEM;
+ gwin->menulab[AMI_MENU_HOTLIST_MAX + 5] = ami_utf8_easy((char *)messages_get("SettingsSave"));
+ gwin->menutype[AMI_MENU_HOTLIST_MAX + 6] = NM_TITLE;
+ gwin->menulab[AMI_MENU_HOTLIST_MAX + 6] = ami_utf8_easy((char *)messages_get("ARexx"));
+ gwin->menutype[AMI_MENU_HOTLIST_MAX + 7] = NM_ITEM;
+ gwin->menulab[AMI_MENU_HOTLIST_MAX + 7] = ami_utf8_easy((char *)messages_get("ARexxExecute"));
+ gwin->menutype[AMI_MENU_HOTLIST_MAX + 8] = NM_ITEM;
+ gwin->menulab[AMI_MENU_HOTLIST_MAX + 8] = NM_BARLABEL;
+
+ gwin->menutype[AMI_MENU_AREXX_MAX] = NM_END;
}
-void ami_init_menulabs(void)
+void ami_menu_refresh(struct gui_window_2 *gwin)
{
- menulab[0] = ami_utf8_easy((char *)messages_get("Project"));
- menulab[1] = ami_utf8_easy((char *)messages_get("NewWindowNS"));
- menulab[2] = ami_utf8_easy((char *)messages_get("NewTab"));
- menulab[3] = NM_BARLABEL;
- menulab[4] = ami_utf8_easy((char *)messages_get("OpenFile"));
- menulab[5] = ami_utf8_easy((char *)messages_get("SaveAsNS"));
- menulab[6] = ami_utf8_easy((char *)messages_get("Source"));
- menulab[7] = ami_utf8_easy((char *)messages_get("TextNS"));
- menulab[8] = ami_utf8_easy((char *)messages_get("SaveCompNS"));
- menulab[9] = ami_utf8_easy((char *)messages_get("PDFNS"));
- menulab[10] = ami_utf8_easy((char *)messages_get("IFF"));
- menulab[11] = NM_BARLABEL;
- menulab[12] = ami_utf8_easy((char *)messages_get("CloseTab"));
- menulab[13] = ami_utf8_easy((char *)messages_get("CloseWindow"));
- menulab[14] = NM_BARLABEL;
- menulab[15] = ami_utf8_easy((char *)messages_get("PrintNS"));
- menulab[16] = NM_BARLABEL;
- menulab[17] = ami_utf8_easy((char *)messages_get("About"));
- menulab[18] = ami_utf8_easy((char *)messages_get("Quit"));
- menulab[19] = ami_utf8_easy((char *)messages_get("Edit"));
- menulab[20] = ami_utf8_easy((char *)messages_get("CutNS"));
- menulab[21] = ami_utf8_easy((char *)messages_get("CopyNS"));
- menulab[22] = ami_utf8_easy((char *)messages_get("PasteNS"));
- menulab[23] = NM_BARLABEL;
- menulab[24] = ami_utf8_easy((char *)messages_get("SelectAllNS"));
- menulab[25] = ami_utf8_easy((char *)messages_get("ClearNS"));
- menulab[26] = ami_utf8_easy((char *)messages_get("Browser"));
- menulab[27] = ami_utf8_easy((char *)messages_get("FindTextNS"));
- menulab[28] = NM_BARLABEL;
- menulab[29] = ami_utf8_easy((char *)messages_get("HistLocalNS"));
- menulab[30] = ami_utf8_easy((char *)messages_get("HistGlobalNS"));
- menulab[31] = NM_BARLABEL;
- menulab[32] = ami_utf8_easy((char *)messages_get("ShowCookies"));
- menulab[33] = NM_BARLABEL;
- menulab[34] = ami_utf8_easy((char *)messages_get("ScaleNS"));
- menulab[35] = ami_utf8_easy((char *)messages_get("ScaleDec"));
- menulab[36] = ami_utf8_easy((char *)messages_get("ScaleNorm"));
- menulab[37] = ami_utf8_easy((char *)messages_get("ScaleInc"));
- menulab[38] = ami_utf8_easy((char *)messages_get("Redraw"));
- menulab[39] = ami_utf8_easy((char *)messages_get("Hotlist"));
- menulab[40] = ami_utf8_easy((char *)messages_get("HotlistAdd"));
- menulab[41] = ami_utf8_easy((char *)messages_get("HotlistShowNS"));
- menulab[42] = NM_BARLABEL;
-
- menulab[AMI_MENU_HOTLIST_MAX] = ami_utf8_easy((char *)messages_get("Settings"));
- menulab[AMI_MENU_HOTLIST_MAX+1] = ami_utf8_easy((char *)messages_get("SettingsEdit"));
- menulab[AMI_MENU_HOTLIST_MAX+2] = NM_BARLABEL;
- menulab[AMI_MENU_HOTLIST_MAX+3] = ami_utf8_easy((char *)messages_get("SnapshotWindow"));
- menulab[AMI_MENU_HOTLIST_MAX+4] = ami_utf8_easy((char *)messages_get("SettingsSave"));
- menulab[AMI_MENU_HOTLIST_MAX+5] = ami_utf8_easy((char *)messages_get("ARexx"));
- menulab[AMI_MENU_HOTLIST_MAX+6] = ami_utf8_easy((char *)messages_get("ARexxExecute"));
- menulab[AMI_MENU_HOTLIST_MAX+7] = NM_BARLABEL;
+ SetAttrs(gwin->objects[OID_MAIN],
+ WINDOW_NewMenu, NULL,
+ TAG_DONE);
+
+ ami_free_menulabs(gwin);
+ ami_create_menu(BROWSER_WINDOW_NORMAL, gwin);
+
+ SetAttrs(gwin->objects[OID_MAIN],
+ WINDOW_NewMenu, gwin->menu,
+ TAG_DONE);
+
+ schedule(6000,(void *)ami_menu_refresh,gwin);
}
-struct NewMenu *ami_create_menu(ULONG type)
+struct NewMenu *ami_create_menu(ULONG type, struct gui_window_2 *gwin)
{
int i;
ULONG menuflags = 0;
- STATIC struct NewMenu menu[] = {
- {NM_TITLE,0,0,0,0,0,}, // project
- { NM_ITEM,0,"N",0,0,0,}, // new window
- { NM_ITEM,0,"T",0,0,0,}, // new tab
- { NM_ITEM,NM_BARLABEL,0,0,0,0,},
- { NM_ITEM,0,"O",0,0,0,}, // open local file
- { NM_ITEM,0,0,0,0,0,}, // save
- { NM_SUB,0,"S",0,0,0,}, // save as source
- { NM_SUB,0,0,0,0,0,}, // save as text
- { NM_SUB,0,0,0,0,0,}, // save as complete
- { NM_SUB,0,0,0,0,0,}, // save as pdf
- { NM_SUB,0,0,0,0,0,}, // save as iff
- { NM_ITEM,NM_BARLABEL,0,0,0,0,},
- { NM_ITEM,0,"K",0,0,0,}, // close tab
- { NM_ITEM,0,0,0,0,0,}, // close window
- { NM_ITEM,NM_BARLABEL,0,0,0,0,},
- { NM_ITEM,0,"P",0,0,0,}, // print
- { NM_ITEM,NM_BARLABEL,0,0,0,0,},
- { NM_ITEM,0,"?",0,0,0,}, // about
- { NM_ITEM,0,"Q",0,0,0,}, // quit
- {NM_TITLE,0,0,0,0,0,}, // edit
- { NM_ITEM,0,"X",0,0,0,}, // cut
- { NM_ITEM,0,"C",0,0,0,}, // copy
- { NM_ITEM,0,"V",0,0,0,}, // paste
- { NM_ITEM,NM_BARLABEL,0,0,0,0,},
- { NM_ITEM,0,"A",0,0,0,}, // select all
- { NM_ITEM,0,"Z",0,0,0,}, // clear selection
- {NM_TITLE,0,0,0,0,0,}, // browser
- { NM_ITEM,0,"F",0,0,0,}, // find in page
- { NM_ITEM,NM_BARLABEL,0,0,0,0,},
- { NM_ITEM,0,0,0,0,0,}, // local history
- { NM_ITEM,0,0,0,0,0,}, // global history
- { NM_ITEM,NM_BARLABEL,0,0,0,0,},
- { NM_ITEM,0,0,0,0,0,}, // cookies
- { NM_ITEM,NM_BARLABEL,0,0,0,0,},
- { NM_ITEM,0,0,0,0,0,}, // scale
- { NM_SUB,0,"-",0,0,0,}, // decrease
- { NM_SUB,0,"=",0,0,0,}, // normal
- { NM_SUB,0,"+",0,0,0,}, // increase
- { NM_ITEM,0,0,0,0,0,}, // redraw
- {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 (treeview)
- { NM_ITEM,NM_BARLABEL,0,0,0,0,},
- { NM_IGNORE,0,0,0,0,0,}, // ** hotlist entry **
- { NM_IGNORE,0,0,0,0,0,}, // ** hotlist entry **
- { NM_IGNORE,0,0,0,0,0,}, // ** hotlist entry **
- { NM_IGNORE,0,0,0,0,0,}, // ** hotlist entry **
- { NM_IGNORE,0,0,0,0,0,}, // ** hotlist entry **
- { NM_IGNORE,0,0,0,0,0,}, // ** hotlist entry **
- { NM_IGNORE,0,0,0,0,0,}, // ** hotlist entry **
- { NM_IGNORE,0,0,0,0,0,}, // ** hotlist entry **
- { NM_IGNORE,0,0,0,0,0,}, // ** hotlist entry **
- { NM_IGNORE,0,0,0,0,0,}, // ** hotlist entry **
- { NM_IGNORE,0,0,0,0,0,}, // ** hotlist entry **
- { NM_IGNORE,0,0,0,0,0,}, // ** hotlist entry **
- { NM_IGNORE,0,0,0,0,0,}, // ** hotlist entry **
- { NM_IGNORE,0,0,0,0,0,}, // ** hotlist entry **
- { NM_IGNORE,0,0,0,0,0,}, // ** hotlist entry **
- { NM_IGNORE,0,0,0,0,0,}, // ** hotlist entry **
- { NM_IGNORE,0,0,0,0,0,}, // ** hotlist entry **
- { NM_IGNORE,0,0,0,0,0,}, // ** hotlist entry **
- { NM_IGNORE,0,0,0,0,0,}, // ** hotlist entry **
- { NM_IGNORE,0,0,0,0,0,}, // ** hotlist entry **
- { NM_IGNORE,0,0,0,0,0,}, // ** hotlist entry **
- { NM_IGNORE,0,0,0,0,0,}, // ** hotlist entry **
- { NM_IGNORE,0,0,0,0,0,}, // ** hotlist entry **
- { NM_IGNORE,0,0,0,0,0,}, // ** hotlist entry **
- { NM_IGNORE,0,0,0,0,0,}, // ** hotlist entry **
- { NM_IGNORE,0,0,0,0,0,}, // ** hotlist entry **
- { NM_IGNORE,0,0,0,0,0,}, // ** hotlist entry **
- { NM_IGNORE,0,0,0,0,0,}, // ** hotlist entry **
- { NM_IGNORE,0,0,0,0,0,}, // ** hotlist entry **
- { NM_IGNORE,0,0,0,0,0,}, // ** hotlist entry **
- { NM_IGNORE,0,0,0,0,0,}, // ** hotlist entry **
- { NM_IGNORE,0,0,0,0,0,}, // ** hotlist entry **
- { NM_IGNORE,0,0,0,0,0,}, // ** hotlist entry **
- { NM_IGNORE,0,0,0,0,0,}, // ** hotlist entry **
- { NM_IGNORE,0,0,0,0,0,}, // ** hotlist entry **
- { NM_IGNORE,0,0,0,0,0,}, // ** hotlist entry **
- { NM_IGNORE,0,0,0,0,0,}, // ** hotlist entry **
- { NM_IGNORE,0,0,0,0,0,}, // ** hotlist entry **
- { NM_IGNORE,0,0,0,0,0,}, // ** hotlist entry **
- { NM_IGNORE,0,0,0,0,0,}, // ** hotlist entry **
- {NM_TITLE,0,0,0,0,0,}, // settings
- { NM_ITEM,0,0,0,0,0,}, // edit prefs
- { NM_ITEM,NM_BARLABEL,0,0,0,0,},
- { NM_ITEM,0,0,0,0,0,}, // snapshot window
- { NM_ITEM,0,0,0,0,0,}, // save settings
- {NM_TITLE,0,0,0,0,0,}, // arexx
- { NM_ITEM,0,0,0,0,0,}, // execute arexx
- { NM_ITEM,NM_BARLABEL,0,0,0,0,},
- { NM_IGNORE,0,0,0,0,0,}, // ** arexx entry **
- { NM_IGNORE,0,0,0,0,0,}, // ** arexx entry **
- { NM_IGNORE,0,0,0,0,0,}, // ** arexx entry **
- { NM_IGNORE,0,0,0,0,0,}, // ** arexx entry **
- { NM_IGNORE,0,0,0,0,0,}, // ** arexx entry **
- { NM_IGNORE,0,0,0,0,0,}, // ** arexx entry **
- { NM_IGNORE,0,0,0,0,0,}, // ** arexx entry **
- { NM_IGNORE,0,0,0,0,0,}, // ** arexx entry **
- { NM_IGNORE,0,0,0,0,0,}, // ** arexx entry **
- { NM_IGNORE,0,0,0,0,0,}, // ** arexx entry **
- { NM_IGNORE,0,0,0,0,0,}, // ** arexx entry **
- { NM_IGNORE,0,0,0,0,0,}, // ** arexx entry **
- { NM_IGNORE,0,0,0,0,0,}, // ** arexx entry **
- { NM_IGNORE,0,0,0,0,0,}, // ** arexx entry **
- { NM_IGNORE,0,0,0,0,0,}, // ** arexx entry **
- { NM_IGNORE,0,0,0,0,0,}, // ** arexx entry **
- { NM_IGNORE,0,0,0,0,0,}, // ** arexx entry **
- { NM_IGNORE,0,0,0,0,0,}, // ** arexx entry **
- { NM_IGNORE,0,0,0,0,0,}, // ** arexx entry **
- { NM_IGNORE,0,0,0,0,0,}, // ** arexx entry **
- { NM_END,0,0,0,0,0,},
- };
+
+ ami_init_menulabs(gwin);
+ gwin->menu = AllocVec(sizeof(struct NewMenu) * (AMI_MENU_AREXX_MAX + 1), MEMF_CLEAR);
if(type != BROWSER_WINDOW_NORMAL)
{
menuflags = NM_ITEMDISABLED;
}
- for(i=0;i<=AMI_MENU_MAX;i++)
+ for(i=0;i<=AMI_MENU_AREXX_MAX;i++)
{
- menu[i].nm_Label = menulab[i];
+ gwin->menu[i].nm_Type = gwin->menutype[i];
+ gwin->menu[i].nm_Label = gwin->menulab[i];
+ if(gwin->menukey[i]) gwin->menu[i].nm_CommKey = &gwin->menukey[i];
+ gwin->menu[i].nm_Flags = 0;
}
- menu[1].nm_Flags = menuflags;
- menu[2].nm_Flags = menuflags;
- menu[12].nm_Flags = menuflags;
- menu[13].nm_Flags = menuflags;
+ gwin->menu[1].nm_Flags = menuflags;
+ gwin->menu[2].nm_Flags = menuflags;
+ gwin->menu[12].nm_Flags = menuflags;
+ gwin->menu[13].nm_Flags = menuflags;
#ifndef WITH_PDF_EXPORT
- menu[9].nm_Flags = NM_ITEMDISABLED;
+ gwin->menu[9].nm_Flags = NM_ITEMDISABLED;
#endif
+ ami_menu_scan(ami_tree_get_tree(hotlist_window), false, gwin);
+ ami_menu_arexx_scan(gwin);
+
if(!menualreadyinit)
{
- ami_menu_scan(hotlist,menu);
- ami_menu_arexx_scan(&menu);
-
aslhookfunc.h_Entry = (void *)&ami_asl_mime_hook;
aslhookfunc.h_SubEntry = NULL;
aslhookfunc.h_Data = NULL;
@@ -288,10 +288,16 @@ struct NewMenu *ami_create_menu(ULONG type)
menualreadyinit = TRUE;
}
- return(menu);
+/* Set up scheduler to refresh the hotlist menu
+ Disabled as it causes everything to slow down to a halt after
+ several iterations
+ schedule(6000,(void *)ami_menu_refresh,gwin);
+*/
+
+ return(gwin->menu);
}
-void ami_menu_arexx_scan(struct NewMenu *menu)
+void ami_menu_arexx_scan(struct gui_window_2 *gwin)
{
int item = AMI_MENU_AREXX;
BPTR lock = 0;
@@ -323,23 +329,20 @@ void ami_menu_arexx_scan(struct NewMenu *menu)
for(ead = (struct ExAllData *)buffer; ead; ead = ead->ed_Next)
{
if(item >= AMI_MENU_AREXX_MAX) continue;
- if(!strcasecmp(ead->ed_Name, option_arexx_startup)) continue;
- if(!strcasecmp(ead->ed_Name, option_arexx_shutdown)) continue;
-
if(EAD_IS_FILE(ead))
{
- menu[item].nm_Type = NM_ITEM;
+ gwin->menu[item].nm_Type = NM_ITEM;
if(ead->ed_Comment[0] != '\0')
{
- menulab[item] = (char *)strdup(ead->ed_Comment);
+ gwin->menulab[item] = (char *)strdup(ead->ed_Comment);
}
else
{
- menulab[item] = (char *)strdup(ead->ed_Name);
+ gwin->menulab[item] = (char *)strdup(ead->ed_Name);
}
- menu[item].nm_Label = menulab[item];
- menu[item].nm_UserData = (char *)strdup(ead->ed_Name);
+ gwin->menu[item].nm_Label = gwin->menulab[item];
+ gwin->menu[item].nm_UserData = (char *)strdup(ead->ed_Name);
item++;
}
@@ -351,31 +354,37 @@ void ami_menu_arexx_scan(struct NewMenu *menu)
}
UnLock(lock);
}
+
+ gwin->menu[item].nm_Type = NM_END;
+ gwin->menu[item].nm_Label = NULL;
}
-void ami_menu_scan(struct tree *tree,struct NewMenu *menu)
+ULONG ami_menu_scan(struct tree *tree, bool count, struct gui_window_2 *gwin)
{
- struct node *root = tree->root->child;
- struct node_element *element=NULL;
+ struct node *root = tree_node_get_child(tree_get_root(tree));
struct node *node;
+ struct node_element *element;
static WORD gen = 0;
static ULONG item;
item = AMI_MENU_HOTLIST;
- for (node = root; node; node = node->next)
+ for (node = root; node; node = tree_node_get_next(node))
{
- element = tree_find_element(node, TREE_ELEMENT_NAME);
- if(!element) element = tree_find_element(node, TREE_ELEMENT_TITLE);
- if(element && (strcmp(element->text,"Menu")==0))
+ element = tree_node_find_element(node, TREE_ELEMENT_TITLE, NULL);
+ if(!element) element = tree_node_find_element(node, TREE_ELEMENT_TITLE, NULL);
+ if(element && (strcmp(tree_node_element_get_text(element),"Menu")==0))
{
// found menu
- ami_menu_scan_2(tree,node->child,&gen,&item,menu);
+ ami_menu_scan_2(tree,tree_node_get_child(node),&gen,&item,count,gwin);
}
}
+
+ return(item - AMI_MENU_HOTLIST);
}
-void ami_menu_scan_2(struct tree *tree,struct node *root,WORD *gen,ULONG *item,struct NewMenu *menu)
+void ami_menu_scan_2(struct tree *tree,struct node *root,WORD *gen,
+ ULONG *item, bool count, struct gui_window_2 *gwin)
{
struct node *tempnode;
struct node_element *element=NULL;
@@ -383,38 +392,39 @@ void ami_menu_scan_2(struct tree *tree,struct node *root,WORD *gen,ULONG *item,s
*gen = *gen + 1;
- for (node = root; node; node = node->next)
+ for (node = root; node; node = tree_node_get_next(node))
{
- element = tree_find_element(node, TREE_ELEMENT_TITLE);
-
if((*gen > 0) && (*gen < 3))
{
- if(*item >= AMI_MENU_HOTLIST_MAX) return;
-
- if(*gen == 1) menu[*item].nm_Type = NM_ITEM;
- if(*gen == 2) menu[*item].nm_Type = NM_SUB;
+// if(*item >= AMI_MENU_HOTLIST_MAX) return;
- if(strcmp(element->text,"--"))
- {
- menulab[*item] = ami_utf8_easy((char *)element->text);
- }
- else
+ if(!count)
{
- menulab[*item] = NM_BARLABEL;
- }
+ if(*gen == 1) gwin->menu[*item].nm_Type = NM_ITEM;
+ if(*gen == 2) gwin->menu[*item].nm_Type = NM_SUB;
+
+ if(strcmp(tree_url_node_get_title(node),"--"))
+ {
+ gwin->menulab[*item] = ami_utf8_easy((char *)tree_url_node_get_title(node));
+ }
+ else
+ {
+ gwin->menulab[*item] = NM_BARLABEL;
+ }
- menu[*item].nm_Label = menulab[*item];
+ gwin->menu[*item].nm_Label = gwin->menulab[*item];
- element = tree_find_element(node, TREE_ELEMENT_URL);
- if(element && element->text) menu[*item].nm_UserData = (void *)element->text;
- if(node->folder && (!node->child)) menu[*item].nm_Flags = NM_ITEMDISABLED;
+ gwin->menu[*item].nm_UserData = (void *)tree_url_node_get_url(node);
+ if(tree_node_is_folder(node) && (!tree_node_get_child(node)))
+ gwin->menu[*item].nm_Flags = NM_ITEMDISABLED;
+ }
*item = *item + 1;
}
- if (node->child)
+ if (tree_node_get_child(node))
{
- ami_menu_scan_2(tree,node->child,gen,item,menu);
+ ami_menu_scan_2(tree,tree_node_get_child(node),gen,item,count,gwin);
}
}
@@ -698,11 +708,11 @@ void ami_menupick(ULONG code,struct gui_window_2 *gwin,struct MenuItem *item)
break;
case 3: // global history
- ami_open_tree(global_history_tree,AMI_TREE_HISTORY);
+ ami_tree_open(global_history_window,AMI_TREE_HISTORY);
break;
case 5: // cookies tree
- ami_open_tree(cookies_tree,AMI_TREE_COOKIES);
+ ami_tree_open(cookies_window,AMI_TREE_COOKIES);
break;
case 7: // size
@@ -736,12 +746,18 @@ void ami_menupick(ULONG code,struct gui_window_2 *gwin,struct MenuItem *item)
switch(itemnum)
{
case 0: // add
- ami_hotlist_add(hotlist->root,gwin->bw->current_content);
- options_save_tree(hotlist,option_hotlist_file,messages_get("TreeHotlist"));
+ if (bw == NULL ||
+ bw->current_content
+ == NULL ||
+ content_get_url(bw->current_content)
+ == NULL)
+ break;
+ hotlist_add_page(content_get_url(gwin->bw->
+ current_content));
break;
case 1: // show
- ami_open_tree(hotlist,AMI_TREE_HOTLIST);
+ ami_tree_open(hotlist_window, AMI_TREE_HOTLIST);
break;
default: // bookmarks
diff --git a/amiga/menu.h b/amiga/menu.h
index 8f925411a..5a739d616 100755
--- a/amiga/menu.h
+++ b/amiga/menu.h
@@ -19,12 +19,14 @@
#ifndef AMIGA_MENU_H
#define AMIGA_MENU_H
#include <exec/types.h>
-#include "amiga/gui.h"
#include <intuition/intuition.h>
+#include <libraries/gadtools.h>
+#include "content/hlcache.h"
/* Number of hotlist items, menu structure needs to be changed in ami_create_menu()
* if this value is changed. */
-#define AMI_HOTLIST_ITEMS 40
+#define AMI_HOTLIST_ITEMS 60
+//gwin->hotlist_items
/* Maximum number of menu items - first value is number of static items
* (ie. everything not intially defined as NM_IGNORE) */
@@ -61,11 +63,12 @@
#define AMI_MENU_CLEAR FULLMENUNUM(1,5,0)
#define AMI_MENU_FIND FULLMENUNUM(2,0,0)
-char *menulab[AMI_MENU_AREXX_MAX+1];
+struct gui_window;
+struct gui_window_2;
-struct NewMenu *ami_create_menu(ULONG type);
-void ami_init_menulabs(void);
-void ami_free_menulabs(void);
+void ami_free_menulabs(struct gui_window_2 *gwin);
+struct NewMenu *ami_create_menu(ULONG type, struct gui_window_2 *gwin);
+void ami_menu_refresh(struct gui_window_2 *gwin);
void ami_menupick(ULONG code,struct gui_window_2 *gwin,struct MenuItem *item);
void ami_menu_update_disabled(struct gui_window *g, hlcache_handle *c);
#endif
diff --git a/amiga/object.c b/amiga/object.c
index a51be81c1..93094cbda 100755
--- a/amiga/object.c
+++ b/amiga/object.c
@@ -48,14 +48,24 @@ struct nsObject *AddObject(struct MinList *objlist,ULONG otype)
return(dtzo);
}
-void DelObject(struct nsObject *dtzo)
+void DelObjectInternal(struct nsObject *dtzo, BOOL free_obj)
{
Remove((struct Node *)dtzo);
- if(dtzo->objstruct) FreeVec(dtzo->objstruct);
+ if(dtzo->objstruct && free_obj) FreeVec(dtzo->objstruct);
FreeVec(dtzo);
dtzo = NULL;
}
+void DelObject(struct nsObject *dtzo)
+{
+ DelObjectInternal(dtzo, TRUE);
+}
+
+void DelObjectNoFree(struct nsObject *dtzo)
+{
+ DelObjectInternal(dtzo, FALSE);
+}
+
void FreeObjList(struct MinList *objlist)
{
struct nsObject *node;
diff --git a/amiga/object.h b/amiga/object.h
index 82d01098d..db7869df8 100755
--- a/amiga/object.h
+++ b/amiga/object.h
@@ -48,6 +48,7 @@ struct nsObject
struct MinList *NewObjList(void);
struct nsObject *AddObject(struct MinList *objlist,ULONG otype);
void DelObject(struct nsObject *dtzo);
+void DelObjectNoFree(struct nsObject *dtzo);
void FreeObjList(struct MinList *objlist);
#endif
diff --git a/amiga/options.h b/amiga/options.h
index 7e4e6cc15..f32938969 100644
--- a/amiga/options.h
+++ b/amiga/options.h
@@ -34,7 +34,6 @@ extern bool option_truecolour_mouse_pointers;
extern bool option_use_os_pointers;
extern bool option_new_tab_active;
extern bool option_kiosk_mode;
-extern char *option_recent_file;
extern char *option_search_engines_file;
extern char *option_search_ico_file;
extern char *option_arexx_dir;
@@ -68,7 +67,6 @@ bool option_truecolour_mouse_pointers = false; \
bool option_use_os_pointers = true; \
bool option_new_tab_active = false; \
bool option_kiosk_mode = false; \
-char *option_recent_file = 0; \
char *option_search_engines_file = 0; \
char *option_search_ico_file = 0; \
char *option_arexx_dir = 0; \
@@ -102,7 +100,6 @@ bool option_drag_save_icons = true; \
{ "os_mouse_pointers", OPTION_BOOL, &option_use_os_pointers}, \
{ "new_tab_is_active", OPTION_BOOL, &option_new_tab_active}, \
{ "kiosk_mode", OPTION_BOOL, &option_kiosk_mode}, \
-{ "recent_file", OPTION_STRING, &option_recent_file }, \
{ "search_engines_file", OPTION_STRING, &option_search_engines_file }, \
{ "search_ico_file", OPTION_STRING, &option_search_ico_file }, \
{ "arexx_dir", OPTION_STRING, &option_arexx_dir }, \
diff --git a/amiga/plotters.c b/amiga/plotters.c
index de60b9518..5bd34d2bc 100755
--- a/amiga/plotters.c
+++ b/amiga/plotters.c
@@ -91,7 +91,7 @@ void ami_cairo_set_colour(cairo_t *cr,colour c)
void ami_cairo_set_solid(cairo_t *cr)
{
double dashes = 0;
-
+
cairo_set_dash(glob->cr, &dashes, 0, 0);
}
@@ -240,7 +240,7 @@ bool ami_rectangle(int x0, int y0, int x1, int y1, const plot_style_t *style)
glob->rp.LinePtrn = PATT_DASH;
break;
}
-
+
SetRPAttrs(&glob->rp,
RPTAG_APenColor,
p96EncodeColor(RGBFB_A8B8G8R8, style->stroke_colour),
@@ -272,7 +272,7 @@ bool ami_rectangle(int x0, int y0, int x1, int y1, const plot_style_t *style)
break;
}
- if (style->stroke_width == 0)
+ if (style->stroke_width == 0)
cairo_set_line_width(glob->cr, 1);
else
cairo_set_line_width(glob->cr, style->stroke_width);
@@ -337,13 +337,17 @@ bool ami_line(int x0, int y0, int x1, int y1, const plot_style_t *style)
break;
}
- if (style->stroke_width == 0)
+ if (style->stroke_width == 0)
cairo_set_line_width(glob->cr, 1);
else
cairo_set_line_width(glob->cr, style->stroke_width);
- cairo_move_to(glob->cr, x0 + 0.5, y0 + 0.5);
- cairo_line_to(glob->cr, x1 + 0.5, y1 + 0.5);
+ /* core expects horizontal and vertical lines to be on pixels, not
+ * between pixels */
+ cairo_move_to(current_cr, (x0 == x1) ? x0 + 0.5 : x0,
+ (y0 == y1) ? y0 + 0.5 : y0);
+ cairo_line_to(current_cr, (x0 == x1) ? x1 + 0.5 : x1,
+ (y0 == y1) ? y1 + 0.5 : y1);
cairo_stroke(glob->cr);
#endif
return true;
@@ -426,7 +430,7 @@ bool ami_clip(int x0, int y0, int x1, int y1)
return true;
}
-bool ami_text(int x, int y, const char *text, size_t length,
+bool ami_text(int x, int y, const char *text, size_t length,
const plot_font_style_t *fstyle)
{
#ifdef AMI_PLOTTER_DEBUG
@@ -459,7 +463,7 @@ bool ami_disc(int x, int y, int radius, const plot_style_t *style)
p96EncodeColor(RGBFB_A8B8G8R8, style->stroke_colour),
TAG_DONE);
- DrawEllipse(&glob->rp,x,y,radius,radius);
+ DrawEllipse(&glob->rp,x,y,radius,radius);
}
#else
if (style->fill_type != PLOT_OP_TYPE_NONE) {
diff --git a/amiga/resources/Themes/AISS/Theme b/amiga/resources/Themes/AISS/Theme
index 8f3dd8aec..8dfa1d3a7 100755
--- a/amiga/resources/Themes/AISS/Theme
+++ b/amiga/resources/Themes/AISS/Theme
@@ -24,12 +24,8 @@ theme_closetab_g:*TBImages:list_cancel
theme_addtab:*TBImages:list_add
theme_addtab_s:*TBImages:list_add
theme_addtab_g:*TBImages:list_add
-theme_list_folder_closed:*TBImages:list_folderfold
-theme_list_folder_open:*TBImages:list_folderunfold
-theme_list_bookmark:*TBImages:list_bookmark
-theme_list_cookie:*TBImages:list_abstract
-theme_list_history:*TBImages:list_archive
-theme_list_sslcert:*TBImages:list_crypt
+theme_list_folder:*TBImages:list_drawer
+theme_list_content:*TBImages:list_abstract
theme_throbber:Throbber
theme_throbber_frames:13
theme_throbber_delay:100
diff --git a/amiga/resources/Themes/Default/Theme b/amiga/resources/Themes/Default/Theme
index eb6b9c3ce..2497af467 100755
--- a/amiga/resources/Themes/Default/Theme
+++ b/amiga/resources/Themes/Default/Theme
@@ -37,12 +37,8 @@ theme_closetab_g:closetab_g.png
theme_addtab:
theme_addtab_s:
theme_addtab_g:
-theme_list_folder_closed:
-theme_list_folder_open:
-theme_list_bookmark:
-theme_list_cookie:
-theme_list_history:
-theme_list_sslcert:
+theme_list_folder:directory.png
+theme_list_content:content.png
theme_throbber:Throbber
theme_throbber_frames:9
theme_throbber_delay:100
diff --git a/amiga/resources/Themes/Default/content.png b/amiga/resources/Themes/Default/content.png
new file mode 120000
index 000000000..4b8c13c1c
--- /dev/null
+++ b/amiga/resources/Themes/Default/content.png
@@ -0,0 +1 @@
+../../../../!NetSurf/Resources/Icons/content.png \ No newline at end of file
diff --git a/amiga/resources/Themes/Default/directory.png b/amiga/resources/Themes/Default/directory.png
new file mode 120000
index 000000000..0e6ce854d
--- /dev/null
+++ b/amiga/resources/Themes/Default/directory.png
@@ -0,0 +1 @@
+../../../../!NetSurf/Resources/Icons/directory.png \ No newline at end of file
diff --git a/amiga/sslcert.c b/amiga/sslcert.c
index c02329449..8eede70f2 100644
--- a/amiga/sslcert.c
+++ b/amiga/sslcert.c
@@ -16,224 +16,28 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include <assert.h>
-#include <string.h>
-#include <proto/dos.h>
#include <proto/exec.h>
-#include <proto/utility.h>
-#include "utils/errors.h"
-#include "utils/utils.h"
-#include "utils/messages.h"
-#include "content/urldb.h"
-#include "content/fetch.h"
-#include "desktop/tree.h"
#include "amiga/tree.h"
-#include "amiga/gui.h"
-
-struct session_data {
- struct session_cert *certs;
- unsigned long num;
- nserror (*cb)(bool proceed, void *pw);
- void *cbpw;
- char *url;
- struct tree *tree;
-};
-struct session_cert {
- char version[16], valid_from[32], valid_to[32], type[8], serial[32];
- char *issuer_t;
- char *subject_t;
- uintptr_t issuer;
- uintptr_t subject;
-};
-
-void ami_gui_cert_close(struct session_data *data);
-bool ami_gui_cert_apply(struct session_data *session);
+#include "amiga/sslcert.h"
void gui_cert_verify(const char *url,
const struct ssl_cert_info *certs, unsigned long num,
nserror (*cb)(bool proceed, void *pw), void *cbpw)
{
- const struct ssl_cert_info *from;
- struct session_cert *to;
- struct session_data *data;
- struct tree *tree;
- struct node *node;
- long i;
- STRPTR yesorno,reqcontents;
- int res = 0;
- struct treeview_window *twin;
-
- assert(certs);
-
- /* copy the certificate information */
- data = calloc(1, sizeof(struct session_data));
- if (!data) {
- warn_user("NoMemory", 0);
- return;
- }
- data->url = strdup(url);
- if (!data->url) {
- free(data);
- warn_user("NoMemory", 0);
- return;
- }
- data->cb = cb;
- data->cbpw = cbpw;
- data->num = num;
- data->certs = calloc(num, sizeof(struct session_cert));
- if (!data->certs) {
- free(data->url);
- free(data);
- warn_user("NoMemory", 0);
- return;
- }
- for (i = 0; i < (long)num; i++) {
- to = &data->certs[i];
- from = &certs[i];
- to->subject_t = strdup(from->subject);
- to->issuer_t = strdup(from->issuer);
- if ((!to->subject_t) || (!to->issuer_t)) {
- for (; i >= 0; i--) {
- to = &data->certs[i];
- free(to->subject_t);
- free(to->issuer_t);
- }
- free(data->certs);
- free(data->url);
- free(data);
- warn_user("NoMemory", 0);
- return;
- }
- snprintf(to->version, sizeof data->certs->version, "%ld",
- from->version);
- snprintf(to->valid_from, sizeof data->certs->valid_from, "%s",
- from->not_before);
- snprintf(to->type, sizeof data->certs->type, "%d",
- from->cert_type);
- snprintf(to->valid_to, sizeof data->certs->valid_to, "%s",
- from->not_after);
- snprintf(to->serial, sizeof data->certs->serial, "%ld",
- from->serial);
- }
-
- tree = calloc(sizeof(struct tree), 1);
- if (!tree) {
- //ro_gui_cert_close(ssl_w);
- warn_user("NoMemory", 0);
- return;
- }
- tree->root = tree_create_folder_node(NULL, "Root");
- if (!tree->root) {
-// ro_gui_cert_close(ssl_w);
- warn_user("NoMemory", 0);
- free(tree);
- tree = NULL;
- return;
- }
- tree->root->expanded = true;
- tree->handle = 0;
- tree->movable = false;
- tree->no_drag = true;
- tree->no_vscroll = true;
- tree->no_furniture = true;
- tree->single_selection = true;
- data->tree = tree;
-
- /* put the SSL names in the tree */
- for (i = 0; i < (long)num; i++) {
- node = tree_create_leaf_node(tree->root, certs[i].subject);
- if (node) {
- node->data.data = TREE_ELEMENT_SSL;
- tree_set_node_sprite(node, "small_xxx", "small_xxx");
- }
- }
- tree_initialise(tree);
-
- ami_open_tree(tree,AMI_TREE_SSLCERT);
- twin = (struct treeview_window *)data->tree->handle;
-
- if(yesorno = ASPrintf("%s|%s",messages_get("Accept"),messages_get("Reject")))
- {
- if(reqcontents = ASPrintf("%s\n\n%s: %s\n%s: %s\n%s: %s\n%s: %s\n%s: %s",
- messages_get("SSLError"),
- messages_get("Subject"),
- to->subject_t,
- messages_get("Issuer"),
- to->issuer_t,
- messages_get("Version"),
- to->version,
- messages_get("ValidFrom"),
- to->valid_from,
- messages_get("ValidTo"),
- to->valid_to))
- {
- res = TimedDosRequesterTags(TDR_ImageType,TDRIMAGE_QUESTION,
- TDR_Window,twin->win,
- TDR_TitleString,messages_get("NetSurf"),
- TDR_GadgetString,yesorno,
- TDR_FormatString,reqcontents,
- TAG_DONE);
-
- FreeVec(reqcontents);
- }
-
- FreeVec(yesorno);
- }
-
- if(res == 1)
- {
- ami_gui_cert_apply(data);
- }
- ami_gui_cert_close(data);
-
-}
-
-void ami_gui_cert_close(struct session_data *data)
-{
- unsigned long i;
-
- if(data->tree->handle)
- {
- ami_tree_close((struct treeview_window *)data->tree->handle);
- win_destroyed = true;
- }
+ struct sslcert_session_data *data;
+ struct treeview_window *ssl_window;
- assert(data);
+ data = sslcert_create_session_data(num, url, cb, cbpw);
-/*
- for (i = 0; i < data->num; i++) {
- if (data->certs[i].subject)
- textarea_destroy(data->certs[i].subject);
- if (data->certs[i].issuer)
- textarea_destroy(data->certs[i].issuer);
- }
-*/
+ ssl_window = ami_tree_create(sslcert_get_tree_flags(), data);
+ if(!ssl_window) return;
- /* Send failure if callback exists */
- if (data->cb != NULL)
- data->cb(false, data->cbpw);
+ sslcert_load_tree(ami_tree_get_tree(ssl_window), certs, data);
- if (data->tree) {
- tree_delete_node(data->tree, data->tree->root, false);
- free(data->tree);
- }
-
- free(data->certs);
- free(data->url);
- free(data);
+ ami_tree_open(ssl_window, AMI_TREE_SSLCERT);
}
-bool ami_gui_cert_apply(struct session_data *session)
+void ami_ssl_free(struct treeview_window *twin)
{
- assert(session);
-
- urldb_set_cert_permissions(session->url, true);
-
- session->cb(true, session->cbpw);
-
- /* Invalidate callback */
- session->cb = NULL;
- session->cbpw = NULL;
-
- return true;
+ ami_tree_destroy(twin);
}
diff --git a/amiga/sslcert.h b/amiga/sslcert.h
new file mode 100644
index 000000000..10078d9bb
--- /dev/null
+++ b/amiga/sslcert.h
@@ -0,0 +1,24 @@
+/*
+ * Copyright 2009 Chris Young <chris@unsatisfactorysoftware.co.uk>
+ *
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef AMIGA_SSLCERT_H
+#define AMIGA_SSLCERT_H
+#include "desktop/sslcert.h"
+
+void ami_ssl_free(struct treeview_window *twin);
+#endif
diff --git a/amiga/theme.c b/amiga/theme.c
index cf9148581..7b10e139b 100644
--- a/amiga/theme.c
+++ b/amiga/theme.c
@@ -121,7 +121,7 @@ void ami_theme_throbber_setup(void)
char throbberfile[1024];
Object *dto;
- ami_get_theme_filename(throbberfile,"theme_throbber");
+ ami_get_theme_filename(throbberfile,"theme_throbber",false);
throbber_frames=atoi(messages_get("theme_throbber_frames"));
throbber_update_interval = atoi(messages_get("theme_throbber_delay"));
if(throbber_update_interval == 0) throbber_update_interval = 100;
@@ -170,15 +170,20 @@ void ami_theme_throbber_free(void)
p96FreeBitMap(throbber);
}
-void ami_get_theme_filename(char *filename, char *themestring)
+void ami_get_theme_filename(char *filename, char *themestring, bool protocol)
{
+ if(protocol)
+ strcpy(filename,"file:///");
+ else
+ strcpy(filename,"");
+
if(messages_get(themestring)[0] == '*')
{
- strncpy(filename, messages_get(themestring) + 1, 100);
+ strncat(filename,messages_get(themestring)+1,100);
}
else
{
- strcpy(filename, option_theme);
+ strcat(filename, option_theme);
AddPart(filename, messages_get(themestring), 100);
}
}
@@ -273,7 +278,7 @@ void ami_init_mouse_pointers(void)
if(option_truecolour_mouse_pointers)
{
- ami_get_theme_filename(&ptrfname,ptrs32[i]);
+ ami_get_theme_filename(&ptrfname,ptrs32[i], false);
if(dobj = GetIconTags(ptrfname,ICONGETA_UseFriendBitMap,TRUE,TAG_DONE))
{
if(IconControl(dobj, ICONCTRLA_GetImageDataFormat, &format, TAG_DONE))
@@ -325,7 +330,7 @@ void ami_init_mouse_pointers(void)
if(!mouseptrobj[i])
{
- ami_get_theme_filename(ptrfname,ptrs[i]);
+ ami_get_theme_filename(ptrfname,ptrs[i], false);
if(ptrfile = Open(ptrfname,MODE_OLDFILE))
{
int mx,my;
diff --git a/amiga/theme.h b/amiga/theme.h
index 3a396fdb1..ba1295d61 100644
--- a/amiga/theme.h
+++ b/amiga/theme.h
@@ -27,7 +27,7 @@
ULONG throbber_width, throbber_height;
void ami_theme_init(void);
-void ami_get_theme_filename(char *filename, char *themestring);
+void ami_get_theme_filename(char *filename, char *themestring, bool protocol);
void ami_theme_throbber_setup(void);
void ami_theme_throbber_free(void);
diff --git a/amiga/tree.c b/amiga/tree.c
index 7000fb76c..f01805314 100755
--- a/amiga/tree.c
+++ b/amiga/tree.c
@@ -1,5 +1,5 @@
/*
- * Copyright 2008,2009 Chris Young <chris@unsatisfactorysoftware.co.uk>
+ * Copyright 2008, 2009 Chris Young <chris@unsatisfactorysoftware.co.uk>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
*
@@ -16,13 +16,16 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "desktop/tree.h"
-#include <proto/listbrowser.h>
#include <proto/window.h>
#include <proto/layout.h>
+#include <proto/space.h>
+#include <proto/label.h>
+#include <proto/scroller.h>
#include <classes/window.h>
-#include <gadgets/listbrowser.h>
+#include <gadgets/space.h>
+#include <images/label.h>
#include <gadgets/layout.h>
+#include <gadgets/scroller.h>
#include <reaction/reaction_macros.h>
#include "amiga/gui.h"
#include "content/urldb.h"
@@ -36,222 +39,395 @@
#include "utils/messages.h"
#include <proto/bitmap.h>
#include <images/bitmap.h>
+#include <proto/graphics.h>
+#include <intuition/icclass.h>
+#include <proto/asl.h>
+#include <proto/utility.h>
+#include <libraries/gadtools.h>
+#include <proto/dos.h>
+#include "amiga/utf8.h"
+#include "desktop/cookies.h"
+#include "desktop/history_global_core.h"
+#include "desktop/hotlist.h"
+#include "amiga/sslcert.h"
+#include "utils/utils.h"
+
+#define AMI_TREE_MENU_ITEMS 19
+
+struct treeview_window {
+ struct Window *win;
+ Object *objects[OID_LAST];
+ struct Gadget *gadgets[GID_LAST];
+ struct nsObject *node;
+ ULONG pad[5];
+ int type;
+ struct NewMenu *menu;
+ char *menu_name[AMI_TREE_MENU_ITEMS];
+ struct tree *tree;
+ struct Hook scrollerhook;
+ uint32 key_state;
+ uint32 mouse_state;
+ int drag_x;
+ int drag_y;
+ struct timeval lastclick;
+ int max_width;
+ int max_height;
+ struct gui_globals globals;
+ struct sslcert_session_data *ssl_data;
+};
+
+void ami_tree_draw(struct treeview_window *twin);
+static void ami_tree_redraw_request(int x, int y, int width, int height,
+ void *data);
+static void ami_tree_resized(struct tree *tree, int width,
+ int height, void *data);
+static void ami_tree_scroll_visible(int y, int height, void *data);
+static void ami_tree_get_window_dimensions(int *width, int *height, void *data);
+
+const struct treeview_table ami_tree_callbacks = {
+ .redraw_request = ami_tree_redraw_request,
+ .resized = ami_tree_resized,
+ .scroll_visible = ami_tree_scroll_visible,
+ .get_window_dimensions = ami_tree_get_window_dimensions
+};
+
+struct treeview_window *ami_tree_create(uint8 flags,
+ struct sslcert_session_data *ssl_data)
+{
+ struct treeview_window *twin;
-struct Node *selectednode;
-struct node *selectednode2;
+ twin = AllocVec(sizeof(struct treeview_window),
+ MEMF_PRIVATE | MEMF_CLEAR);
+
+ if(!twin)
+ {
+ warn_user("NoMemory", 0);
+ return NULL;
+ }
-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,int move);
-void ami_new_bookmark(struct treeview_window *twin);
-void ami_recreate_listbrowser(struct treeview_window *twin);
+ twin->ssl_data = ssl_data;
-void tree_initialise_redraw(struct tree *tree)
-{
+ twin->tree = tree_create(flags, &ami_tree_callbacks, twin);
+ return twin;
}
-void tree_redraw_area(struct tree *tree, int x, int y, int width, int height)
+void ami_tree_destroy(struct treeview_window *twin)
{
+ tree_delete(twin->tree);
+ FreeVec(twin);
}
-void tree_draw_line(int x, int y, int width, int height)
+struct tree *ami_tree_get_tree(struct treeview_window *twin)
{
+ return twin->tree;
}
-void tree_draw_node_element(struct tree *tree, struct node_element *element)
+void ami_tree_resized(struct tree *tree, int width, int height, void *data)
{
- return;
-#if 0
-/* add element to listbrowser list */
+ struct treeview_window *twin = data;
+ struct IBox *bbox;
- struct Node *lbnode;
- struct treeview_window *twin = tree->handle;
- struct node *tempnode;
- int generation=1;
- BOOL edit = FALSE;
+ twin->max_height = height;
+ twin->max_width = width;
- tempnode = element->parent;
- edit = tempnode->editable;
-
- while(tempnode)
+ if(twin->win)
{
- tempnode = tempnode->parent;
- generation++;
- }
+ GetAttr(SPACE_AreaBox,twin->gadgets[GID_BROWSER],(ULONG *)&bbox);
- switch (element->type) {
- case NODE_ELEMENT_TEXT_PLUS_SPRITE:
- case NODE_ELEMENT_TEXT:
- if (lbnode = AllocListBrowserNode(3,
-// LBNA_UserData,nodetime,
- LBNA_Generation,1,
- LBNA_Column, 0,
- LBNCA_CopyText,TRUE,
- LBNCA_Text, element->text,
- LBNCA_Editable,edit,
- LBNA_Column, 1,
- LBNCA_CopyText,TRUE,
- LBNCA_Text, "",
- LBNA_Column, 2,
- LBNCA_CopyText,TRUE,
- LBNCA_Text, "",
- TAG_DONE))
- {
- AddTail(twin->listbrowser_list, lbnode);
- }
- break;
+ RefreshSetGadgetAttrs((APTR)twin->objects[OID_VSCROLL], twin->win, NULL,
+ SCROLLER_Total, height,
+ SCROLLER_Visible, bbox->Height,
+ TAG_DONE);
+
+ RefreshSetGadgetAttrs((APTR)twin->objects[OID_HSCROLL], twin->win, NULL,
+ SCROLLER_Total, width,
+ SCROLLER_Visible, bbox->Width,
+ TAG_DONE);
}
-#endif
}
-void tree_draw_node_expansion(struct tree *tree, struct node *node)
+/**
+ * Retrieves the dimensions of the window with the tree
+ *
+ * \param data user data assigned to the tree on tree creation
+ * \param width will be updated to window width if not NULL
+ * \param height will be updated to window height if not NULL
+ */
+void ami_tree_get_window_dimensions(int *width, int *height, void *data)
{
- DebugPrintF("tree_draw_node_expansion\n");
+ struct treeview_window *twin = data;
+ struct IBox *bbox;
+
+ GetAttr(SPACE_AreaBox,twin->gadgets[GID_BROWSER],(ULONG *)&bbox);
+
+ if(width) *width = bbox->Width;
+ if(height) *height = bbox->Height;
}
-void tree_recalculate_node_element(struct node_element *element)
+/**
+ * Translates a content_type to the name of a respective icon
+ *
+ * \param content_type content type
+ * \param buffer buffer for the icon name
+ */
+void tree_icon_name_from_content_type(char *buffer, content_type type)
{
+ // TODO: design/acquire icons
+ switch (type) {
+ case CONTENT_HTML:
+ case CONTENT_TEXTPLAIN:
+ case CONTENT_CSS:
+#if defined(WITH_MNG) || defined(WITH_PNG)
+ case CONTENT_PNG:
+#endif
+#ifdef WITH_MNG
+ case CONTENT_JNG:
+ case CONTENT_MNG:
+#endif
+#ifdef WITH_JPEG
+ case CONTENT_JPEG:
+#endif
+#ifdef WITH_GIF
+ case CONTENT_GIF:
+#endif
+#ifdef WITH_BMP
+ case CONTENT_BMP:
+ case CONTENT_ICO:
+#endif
+#ifdef WITH_NSSPRITE
+ case CONTENT_SPRITE:
+#endif
+#ifdef WITH_NS_SVG
+ case CONTENT_SVG:
+#endif
+ default:
+ ami_get_theme_filename(buffer,"theme_list_content",true);
+ break;
+ }
}
-void tree_update_URL_node(struct node *node, const char *url,
- const struct url_data *data)
+/**
+ * Scrolls the tree to make an element visible
+ *
+ * \param y Y coordinate of the element
+ * \param height height of the element
+ * \param data user data assigned to the tree on tree creation
+ */
+void ami_tree_scroll_visible(int y, int height, void *data)
{
- struct node_element *element;
- char buffer[256];
+ ULONG sy, scrollset;
+ struct IBox *bbox;
+ struct treeview_window *twin = data;
- assert(node);
+ GetAttr(SCROLLER_Top, twin->objects[OID_VSCROLL], (ULONG *)&sy);
+ GetAttr(SPACE_AreaBox,twin->gadgets[GID_BROWSER],(ULONG *)&bbox);
- element = tree_find_element(node, TREE_ELEMENT_URL);
+ if((y > sy) && ((y + height) < (sy + bbox->Height))) return;
- if (!element)
- return;
- if (data) {
- /* node is linked, update */
- assert(!node->editable);
- if (!data->title)
- urldb_set_url_title(url, url);
-
- if (!data->title)
- return;
-
- node->data.text = data->title;
- } else {
- /* node is not linked, find data */
- assert(node->editable);
- data = urldb_get_url_data(element->text);
- if (!data)
- return;
- }
+ if((y <= sy) || (height > bbox->Height)) scrollset = (ULONG)y;
+ else scrollset = sy + (y + height) - (sy + bbox->Height);
-/* not implemented yet
- if (element) {
- sprintf(buffer, "small_%.3x", ro_content_filetype_from_type(data->type));
- if (ro_gui_wimp_sprite_exists(buffer))
- tree_set_node_sprite(node, buffer, buffer);
- else
- tree_set_node_sprite(node, "small_xxx", "small_xxx");
- }
-*/
-
- element = tree_find_element(node, TREE_ELEMENT_LAST_VISIT);
- if (element) {
- snprintf(buffer, 256, (char *)messages_get("TreeLast"),
- (data->last_visit > 0) ?
- ctime((time_t *)&data->last_visit) :
- (char *)messages_get("TreeUnknown"));
- if (data->last_visit > 0)
- buffer[strlen(buffer) - 1] = '\0';
- free((void *)element->text);
- element->text = (char *)strdup(buffer);
- }
+ RefreshSetGadgetAttrs((APTR)twin->objects[OID_VSCROLL], twin->win, NULL,
+ SCROLLER_Top, scrollset,
+ TAG_DONE);
- element = tree_find_element(node, TREE_ELEMENT_VISITS);
- if (element) {
- snprintf(buffer, 256, (char *)messages_get("TreeVisits"),
- data->visits);
- free((void *)element->text);
- element->text = (char *)strdup(buffer);
- }
+ ami_tree_draw(twin);
}
-void tree_resized(struct tree *tree)
+void ami_tree_scroll(struct treeview_window *twin, int sx, int sy)
{
+ int x, y;
+
+ if(!twin) return;
+ if(sx<0) sx=0;
+ if(sy<0) sy=0;
+
+ GetAttr(SCROLLER_Top, twin->objects[OID_HSCROLL], (ULONG *)&x);
+ GetAttr(SCROLLER_Top, twin->objects[OID_VSCROLL], (ULONG *)&y);
+
+ RefreshSetGadgetAttrs((APTR)twin->objects[OID_VSCROLL], twin->win, NULL,
+ SCROLLER_Top, y + sy,
+ TAG_DONE);
+
+ RefreshSetGadgetAttrs((APTR)twin->objects[OID_HSCROLL], twin->win, NULL,
+ SCROLLER_Top, x + sx,
+ TAG_DONE);
+
+ ami_tree_draw(twin);
}
-void tree_set_node_sprite_folder(struct node *node)
+
+void ami_tree_scroller_hook(struct Hook *hook,Object *object,struct IntuiMessage *msg)
{
-}
+ ULONG gid,x,y;
+ struct treeview_window *twin = hook->h_Data;
+ struct IntuiWheelData *wheel;
+
+ switch(msg->Class)
+ {
+ case IDCMP_IDCMPUPDATE:
+ gid = GetTagData( GA_ID, 0, msg->IAddress );
+
+ switch( gid )
+ {
+ case OID_HSCROLL:
+ case OID_VSCROLL:
+ ami_tree_draw(twin);
+ break;
+ }
+ break;
+
+ case IDCMP_EXTENDEDMOUSE:
+ if(msg->Code == IMSGCODE_INTUIWHEELDATA)
+ {
+ wheel = (struct IntuiWheelData *)msg->IAddress;
+
+ ami_tree_scroll(twin, (wheel->WheelX * 20), (wheel->WheelY * 20));
+ }
+ break;
+ }
+}
-void tree_set_node_sprite(struct node *node, const char *sprite,
- const char *expanded)
+void ami_tree_menu(struct treeview_window *twin)
{
+ if(twin->menu) return;
+
+ if(twin->menu = AllocVec(sizeof(struct NewMenu) * AMI_TREE_MENU_ITEMS, MEMF_CLEAR))
+ {
+ twin->menu[0].nm_Type = NM_TITLE;
+ twin->menu_name[0] = ami_utf8_easy((char *)messages_get("Tree"));
+ twin->menu[0].nm_Label = twin->menu_name[0];
+
+ twin->menu[1].nm_Type = NM_ITEM;
+ twin->menu_name[1] = ami_utf8_easy((char *)messages_get("TreeExport"));
+ twin->menu[1].nm_Label = twin->menu_name[1];
+ if(twin->type == AMI_TREE_COOKIES)
+ twin->menu[1].nm_Flags = NM_ITEMDISABLED;
+ twin->menu[1].nm_CommKey = "S";
+
+ twin->menu[2].nm_Type = NM_ITEM;
+ twin->menu[2].nm_Label = NM_BARLABEL;
+
+ twin->menu[3].nm_Type = NM_ITEM;
+ twin->menu_name[3] = ami_utf8_easy((char *)messages_get("Expand"));
+ twin->menu[3].nm_Label = twin->menu_name[3];
+
+ twin->menu[4].nm_Type = NM_SUB;
+ twin->menu_name[4] = ami_utf8_easy((char *)messages_get("All"));
+ twin->menu[4].nm_Label = twin->menu_name[4];
+ twin->menu[4].nm_CommKey = "+";
+
+ if(twin->type == AMI_TREE_COOKIES)
+ {
+ twin->menu_name[5] = ami_utf8_easy((char *)messages_get("Domains"));
+ twin->menu_name[6] = ami_utf8_easy((char *)messages_get("Cookies"));
+ }
+ else
+ {
+ twin->menu_name[5] = ami_utf8_easy((char *)messages_get("Folders"));
+ twin->menu_name[6] = ami_utf8_easy((char *)messages_get("Links"));
+ }
+
+ twin->menu[5].nm_Type = NM_SUB;
+ twin->menu[5].nm_Label = twin->menu_name[5]; // tree-specific title
+
+ twin->menu[6].nm_Type = NM_SUB;
+ twin->menu[6].nm_Label = twin->menu_name[6]; // tree-specific title
+
+ twin->menu[7].nm_Type = NM_ITEM;
+ twin->menu_name[7] = ami_utf8_easy((char *)messages_get("Collapse"));
+ twin->menu[7].nm_Label = twin->menu_name[7];
+
+ twin->menu[8].nm_Type = NM_SUB;
+ twin->menu[8].nm_Label = twin->menu_name[4];
+ twin->menu[8].nm_CommKey = "-";
+
+ twin->menu[9].nm_Type = NM_SUB;
+ twin->menu[9].nm_Label = twin->menu_name[5]; // tree-specific title
+
+ twin->menu[10].nm_Type = NM_SUB;
+ twin->menu[10].nm_Label = twin->menu_name[6]; // tree-specific title
+
+ twin->menu[11].nm_Type = NM_ITEM;
+ twin->menu[11].nm_Label = NM_BARLABEL;
+
+ twin->menu[12].nm_Type = NM_ITEM;
+ twin->menu_name[12] = ami_utf8_easy((char *)messages_get("CloseWindow"));
+ twin->menu[12].nm_Label = twin->menu_name[12];
+ twin->menu[12].nm_CommKey = "K";
+
+ twin->menu[13].nm_Type = NM_TITLE;
+ twin->menu_name[13] = ami_utf8_easy((char *)messages_get("Edit"));
+ twin->menu[13].nm_Label = twin->menu_name[13];
+
+ twin->menu[14].nm_Type = NM_ITEM;
+ twin->menu_name[14] = ami_utf8_easy((char *)messages_get("TreeDelete"));
+ twin->menu[14].nm_Label = twin->menu_name[14];
+ twin->menu[14].nm_CommKey = "D";
+
+ twin->menu[15].nm_Type = NM_ITEM;
+ twin->menu[15].nm_Label = NM_BARLABEL;
+
+ twin->menu[16].nm_Type = NM_ITEM;
+ twin->menu_name[16] = ami_utf8_easy((char *)messages_get("SelectAllNS"));
+ twin->menu[16].nm_Label = twin->menu_name[16];
+ twin->menu[16].nm_CommKey = "A";
+
+ twin->menu[17].nm_Type = NM_ITEM;
+ twin->menu_name[17] = ami_utf8_easy((char *)messages_get("ClearNS"));
+ twin->menu[17].nm_Label = twin->menu_name[17];
+ twin->menu[17].nm_CommKey = "Z";
+
+ twin->menu[18].nm_Type = NM_END;
+ }
}
-void ami_open_tree(struct tree *tree,int type)
+void ami_tree_open(struct treeview_window *twin,int type)
{
- struct treeview_window *twin;
BOOL msel = TRUE,nothl = TRUE,launchdisable=FALSE;
static WORD gen=0;
char *wintitle;
char folderclosed[100],folderopen[100],item[100];
- if(tree->handle)
+ if(twin->win)
{
- twin = (struct treeview_window *)tree->handle;
WindowToFront(twin->win);
ActivateWindow(twin->win);
return;
}
- twin = AllocVec(sizeof(struct treeview_window),MEMF_PRIVATE | MEMF_CLEAR);
- twin->listbrowser_list = AllocVec(sizeof(struct List),MEMF_PRIVATE | MEMF_CLEAR);
+ twin->type = type;
- static struct ColumnInfo columninfo[] =
- {
- { 80,"Name", CIF_DRAGGABLE | CIF_SORTABLE},
- { 20,"URL", CIF_DRAGGABLE },
-// { 5,"Visits", CIF_DRAGGABLE },
- { -1, (STRPTR)~0, -1 }
- };
-
- if(tree->single_selection) msel = FALSE;
-
- ami_get_theme_filename(&folderclosed,"theme_list_folder_closed");
- ami_get_theme_filename(&folderopen,"theme_list_folder_open");
-
- switch(type)
+ switch(twin->type)
{
case AMI_TREE_HOTLIST:
nothl = FALSE;
wintitle = (char *)messages_get("Hotlist");
- ami_get_theme_filename(&item,"theme_list_bookmark");
break;
case AMI_TREE_COOKIES:
nothl = TRUE;
launchdisable=TRUE;
wintitle = (char *)messages_get("Cookies");
- ami_get_theme_filename(&item,"theme_list_cookie");
break;
case AMI_TREE_HISTORY:
nothl = TRUE;
wintitle = (char *)messages_get("GlobalHistory");
- ami_get_theme_filename(&item,"theme_list_history");
break;
case AMI_TREE_SSLCERT:
nothl = TRUE;
wintitle = (char *)messages_get("SSLCerts");
- ami_get_theme_filename(&item,"theme_list_sslcert");
break;
}
- NewList(twin->listbrowser_list);
+ twin->scrollerhook.h_Entry = (void *)ami_tree_scroller_hook;
+ twin->scrollerhook.h_Data = twin;
- tree->handle = (void *)twin;
- twin->tree = tree;
- ami_add_elements(twin,twin->tree->root,&gen);
+ ami_init_layers(&twin->globals, scrn->Width, scrn->Height);
+ ami_tree_menu(twin);
- twin->objects[OID_MAIN] = WindowObject,
+ if(type == AMI_TREE_SSLCERT)
+ {
+ twin->objects[OID_MAIN] = WindowObject,
WA_ScreenTitle,nsscreentitle,
WA_Title,wintitle,
WA_Activate, TRUE,
@@ -259,43 +435,77 @@ void ami_open_tree(struct tree *tree,int type)
WA_DragBar, TRUE,
WA_CloseGadget, TRUE,
WA_SizeGadget, TRUE,
+ WA_Height, scrn->Height / 2,
WA_CustomScreen,scrn,
+ WA_ReportMouse,TRUE,
+ WA_IDCMP,IDCMP_MOUSEMOVE | IDCMP_MOUSEBUTTONS | IDCMP_NEWSIZE |
+ IDCMP_RAWKEY | IDCMP_GADGETUP | IDCMP_IDCMPUPDATE |
+ IDCMP_EXTENDEDMOUSE,
+ WINDOW_HorizProp,1,
+ WINDOW_VertProp,1,
+ WINDOW_IDCMPHook,&twin->scrollerhook,
+ WINDOW_IDCMPHookBits,IDCMP_IDCMPUPDATE | IDCMP_EXTENDEDMOUSE,
WINDOW_SharedPort,sport,
WINDOW_UserData,twin,
- WINDOW_IconifyGadget, TRUE,
+ /* WINDOW_NewMenu, twin->menu, -> No menu for SSL Cert */
+ WINDOW_IconifyGadget, FALSE,
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_Hierarchical,TRUE,
- LISTBROWSER_Editable,TRUE,
-// LISTBROWSER_TitleClickable,TRUE,
- LISTBROWSER_AutoFit, TRUE,
- LISTBROWSER_HorizontalProp, TRUE,
- LISTBROWSER_Labels, twin->listbrowser_list,
-// LISTBROWSER_MultiSelect,msel,
- LISTBROWSER_ShowSelected,TRUE,
- LISTBROWSER_ShowImage,BitMapObject,
- BITMAP_SourceFile,folderclosed,
- BITMAP_Screen,scrn,
- BITMAP_Masking,TRUE,
- BitMapEnd,
- LISTBROWSER_HideImage,BitMapObject,
- BITMAP_SourceFile,folderopen,
- BITMAP_Screen,scrn,
- BITMAP_Masking,TRUE,
- BitMapEnd,
- LISTBROWSER_LeafImage,BitMapObject,
- BITMAP_SourceFile,item,
- BITMAP_Screen,scrn,
- BITMAP_Masking,TRUE,
- BitMapEnd,
- ListBrowserEnd,
- CHILD_NominalSize,TRUE,
+ LAYOUT_AddImage, LabelObject,
+ LABEL_Text, messages_get("SSLError"),
+ LabelEnd,
+ LAYOUT_AddChild, twin->gadgets[GID_BROWSER] = SpaceObject,
+ GA_ID, GID_BROWSER,
+ SPACE_Transparent,TRUE,
+ SPACE_BevelStyle, BVS_DISPLAY,
+ SpaceEnd,
+ LAYOUT_AddChild, HGroupObject,
+ LAYOUT_AddChild, twin->gadgets[GID_OPEN] = ButtonObject,
+ GA_ID,GID_OPEN,
+ GA_Text,messages_get("Accept"),
+ GA_RelVerify,TRUE,
+ ButtonEnd,
+ LAYOUT_AddChild, twin->gadgets[GID_CANCEL] = ButtonObject,
+ GA_ID,GID_CANCEL,
+ GA_Text,messages_get("Reject"),
+ GA_RelVerify,TRUE,
+ ButtonEnd,
+ EndGroup,
+ CHILD_WeightedHeight,0,
+ EndGroup,
+ EndWindow;
+ }
+ else
+ {
+ twin->objects[OID_MAIN] = WindowObject,
+ WA_ScreenTitle,nsscreentitle,
+ WA_Title,wintitle,
+ WA_Activate, TRUE,
+ WA_DepthGadget, TRUE,
+ WA_DragBar, TRUE,
+ WA_CloseGadget, TRUE,
+ WA_SizeGadget, TRUE,
+ WA_Height, scrn->Height / 2,
+ WA_CustomScreen,scrn,
+ WA_ReportMouse,TRUE,
+ WA_IDCMP,IDCMP_MOUSEMOVE | IDCMP_MOUSEBUTTONS | IDCMP_NEWSIZE |
+ IDCMP_RAWKEY | IDCMP_GADGETUP | IDCMP_IDCMPUPDATE |
+ IDCMP_EXTENDEDMOUSE,
+ WINDOW_HorizProp,1,
+ WINDOW_VertProp,1,
+ WINDOW_IDCMPHook,&twin->scrollerhook,
+ WINDOW_IDCMPHookBits,IDCMP_IDCMPUPDATE | IDCMP_EXTENDEDMOUSE,
+ WINDOW_SharedPort,sport,
+ WINDOW_UserData,twin,
+ WINDOW_NewMenu, twin->menu,
+ WINDOW_IconifyGadget, FALSE,
+ WINDOW_Position, WPOS_CENTERSCREEN,
+ WINDOW_ParentGroup, twin->gadgets[GID_MAIN] = VGroupObject,
+ LAYOUT_AddChild, twin->gadgets[GID_BROWSER] = SpaceObject,
+ GA_ID, GID_BROWSER,
+ SPACE_Transparent,TRUE,
+ SPACE_BevelStyle, BVS_DISPLAY,
+ SpaceEnd,
LAYOUT_AddChild, HGroupObject,
LAYOUT_AddChild, twin->gadgets[GID_OPEN] = ButtonObject,
GA_ID,GID_OPEN,
@@ -315,24 +525,6 @@ void ami_open_tree(struct tree *tree,int type)
GA_RelVerify,TRUE,
GA_Disabled,nothl,
ButtonEnd,
- LAYOUT_AddChild, twin->gadgets[GID_LEFT] = ButtonObject,
- GA_ID,GID_LEFT,
- BUTTON_AutoButton,BAG_LFARROW,
- GA_RelVerify,TRUE,
- GA_Disabled,nothl, //(!tree->movable),
- 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("TreeDelete"),
@@ -342,161 +534,89 @@ void ami_open_tree(struct tree *tree,int type)
CHILD_WeightedHeight,0,
EndGroup,
EndWindow;
+ }
twin->win = (struct Window *)RA_OpenWindow(twin->objects[OID_MAIN]);
- twin->node = AddObject(window_list,AMINS_TVWINDOW);
- twin->node->objstruct = twin;
-}
-
-/**
- * Launches a node using all known methods.
- *
- * \param node the node to launch
- * \return whether the node could be launched
- */
-bool ami_tree_launch_node(struct tree *tree, struct node *node)
-{
- struct node_element *element;
+ GetAttr(WINDOW_HorizObject, twin->objects[OID_MAIN],
+ (ULONG *)&twin->objects[OID_HSCROLL]);
+ GetAttr(WINDOW_VertObject, twin->objects[OID_MAIN],
+ (ULONG *)&twin->objects[OID_VSCROLL]);
- assert(node);
+ RefreshSetGadgetAttrs((APTR)twin->objects[OID_VSCROLL], twin->win, NULL,
+ GA_ID,OID_VSCROLL,
+ ICA_TARGET,ICTARGET_IDCMP,
+ TAG_DONE);
- element = tree_find_element(node, TREE_ELEMENT_URL);
- if (element) {
- browser_window_create(element->text, NULL, 0, true, false);
- return true;
- }
+ RefreshSetGadgetAttrs((APTR)twin->objects[OID_HSCROLL], twin->win, NULL,
+ GA_ID,OID_HSCROLL,
+ ICA_TARGET,ICTARGET_IDCMP,
+ TAG_DONE);
-/* not implemented yet
- element = tree_find_element(node, TREE_ELEMENT_SSL);
- if (element) {
- ro_gui_cert_open(tree, node);
- return true;
- }
-*/
+ twin->node = AddObject(window_list,AMINS_TVWINDOW);
+ twin->node->objstruct = twin;
- return false;
+ ami_tree_resized(twin->tree, twin->max_width, twin->max_height, twin);
+ tree_set_redraw(twin->tree, true);
+ ami_tree_draw(twin);
}
void ami_tree_close(struct treeview_window *twin)
{
- twin->tree->handle = 0;
- DisposeObject(twin->objects[OID_MAIN]);
- FreeListBrowserList(twin->listbrowser_list);
- FreeVec(twin->listbrowser_list);
- //free_browserlist(twin->listbrowser_list);
- DelObject(twin->node);
-}
-
-void free_browserlist(struct List *list)
-{
- struct Node *node, *nextnode;
-
- if(IsListEmpty(list)) return;
+ int i;
- node = GetHead(list);
+ tree_set_redraw(twin->tree, false);
+ twin->win = NULL;
+ DisposeObject(twin->objects[OID_MAIN]);
+ DelObjectNoFree(twin->node);
+ ami_free_layers(&twin->globals);
- do
- {
- nextnode = GetSucc(node);
-// FreeVec(node->ln_Name);
- FreeListBrowserNode(node);
- } while(node = nextnode);
+ for(i=0;i<AMI_TREE_MENU_ITEMS;i++)
+ {
+ if(twin->menu_name[i] && (twin->menu_name[i] != NM_BARLABEL)) ami_utf8_free(twin->menu_name[i]);
+ }
+ FreeVec(twin->menu);
+ twin->menu = NULL;
+ if(twin->type == AMI_TREE_SSLCERT) ami_ssl_free(twin);
}
-void ami_add_elements(struct treeview_window *twin,struct node *root,WORD *gen)
+void ami_tree_update_quals(struct treeview_window *twin)
{
- struct Node *lbnode;
- struct tree *tree = twin->tree;
- struct node *tempnode;
- int generation=1;
- BOOL edit = FALSE;
- struct node_element *element=NULL,*element2=NULL,*element3=NULL;
- struct node *node;
- ULONG flags = 0;
- STRPTR text1 = "",text2 = "",text3 = "";
-
- *gen = *gen + 1;
- for (node = root; node; node = node->next)
- {
- element = tree_find_element(node, TREE_ELEMENT_NAME);
- if(!element) element = tree_find_element(node, TREE_ELEMENT_TITLE);
- if(!element) element = tree_find_element(node, TREE_ELEMENT_SSL);
- if(element && element->text)
- {
- text1 = (char *)element->text;
- }
+ uint32 quals = 0;
-/* Really, the second column needs axing - relevant data should appear in an
-area below the listview when items are selected */
+ GetAttr(WINDOW_Qualifier, twin->objects[OID_MAIN], (uint32 *)&quals);
- 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);
+ twin->key_state = 0;
- if(element2 && element2->text)
- {
- text2 = (char *)element2->text;
- }
- else
- {
- text2 = "";
- }
+ if((quals & IEQUALIFIER_LSHIFT) || (quals & IEQUALIFIER_RSHIFT))
+ {
+ twin->key_state |= BROWSER_MOUSE_MOD_1;
+ }
-// element = tree_find_element(node, TREE_ELEMENT_VISITS);
-
- flags = 0;
- /*if(node->expanded) */ flags = LBFLG_SHOWCHILDREN;
- if(node->folder) flags |= LBFLG_HASCHILDREN;
- if(!node->parent) flags |= LBFLG_HIDDEN;
-
- switch (element->type) {
- case NODE_ELEMENT_TEXT_PLUS_SPRITE:
- case NODE_ELEMENT_TEXT:
- if (lbnode = AllocListBrowserNode(3,
- LBNA_UserData,node,
- LBNA_Generation,*gen - 1,
- LBNA_Selected,node->selected,
- LBNA_Flags,flags,
- LBNA_Column, 0,
- LBNCA_CopyText,TRUE,
- LBNCA_MaxChars,256,
- LBNCA_Text, text1,
- LBNCA_Editable,node->editable,
- LBNA_Column, 1,
- LBNCA_CopyText,TRUE,
- LBNCA_MaxChars,256,
- LBNCA_Text, text2,
- LBNCA_Editable,FALSE,
- TAG_DONE))
- {
- AddTail(twin->listbrowser_list, lbnode);
- if(node == selectednode2) selectednode = lbnode;
- }
- break;
- }
+ if(quals & IEQUALIFIER_CONTROL)
+ {
+ twin->key_state |= BROWSER_MOUSE_MOD_2;
+ }
- if (node->child)
- {
- ami_add_elements(twin,node->child,gen);
- }
+ if((quals & IEQUALIFIER_LALT) || (quals & IEQUALIFIER_RALT))
+ {
+ twin->key_state |= BROWSER_MOUSE_MOD_3;
}
- *gen = *gen - 1;
}
BOOL ami_tree_event(struct treeview_window *twin)
{
/* return TRUE if window destroyed */
- ULONG class,result,relevent = 0;
- ULONG column;
+ ULONG class,result,storage = 0;
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;
+ ULONG menunum=0,itemnum=0,subnum=0;
+ int xs, ys, x, y;
+ struct IBox *bbox;
+ struct timeval curtime;
+ struct InputEvent *ie;
+ int nskey;
+ char fname[1024];
while((result = RA_HandleInput(twin->objects[OID_MAIN],&code)) != WMHI_LASTMSG)
{
@@ -505,126 +625,386 @@ BOOL ami_tree_event(struct treeview_window *twin)
case WMHI_GADGETUP:
switch(result & WMHI_GADGETMASK)
{
- case GID_TREEBROWSER:
- GetAttrs(twin->gadgets[GID_TREEBROWSER],
- LISTBROWSER_RelEvent,&relevent,
- TAG_DONE);
-
- switch(relevent)
+ case GID_OPEN:
+ if(twin->type == AMI_TREE_SSLCERT)
{
- case LBRE_DOUBLECLICK:
- 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 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;
+ sslcert_accept(twin->ssl_data);
+ ami_tree_close(twin);
+ return TRUE;
}
+ else tree_launch_selected(twin->tree);
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);
+ case GID_CANCEL:
+ sslcert_reject(twin->ssl_data);
+ ami_tree_close(twin);
+ return TRUE;
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);
+ hotlist_add_folder();
break;
case GID_NEWB:
- ami_new_bookmark(twin);
+ hotlist_add_entry();
break;
- case GID_UP:
- ami_move_node(twin,AMI_MOVE_UP);
+ case GID_DEL:
+ switch(twin->type)
+ {
+ case AMI_TREE_HISTORY:
+ history_global_delete_selected();
+ break;
+ case AMI_TREE_COOKIES:
+ cookies_delete_selected();
+ break;
+ case AMI_TREE_HOTLIST:
+ hotlist_delete_selected();
+ break;
+ }
break;
+ }
+ break;
- case GID_DOWN:
- ami_move_node(twin,AMI_MOVE_DOWN);
- break;
+ case WMHI_MOUSEMOVE:
+ GetAttr(SPACE_AreaBox, twin->gadgets[GID_BROWSER], (ULONG *)&bbox);
- case GID_LEFT:
- ami_move_node(twin,AMI_MOVE_OUT);
- break;
+ GetAttr(SCROLLER_Top, twin->objects[OID_HSCROLL], (ULONG *)&xs);
+ x = twin->win->MouseX - bbox->Left + xs;
- 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, false);
-/* 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);
+ GetAttr(SCROLLER_Top, twin->objects[OID_VSCROLL], (ULONG *)&ys);
+ y = twin->win->MouseY - bbox->Top + ys;
+
+ if((x >= xs) && (y >= ys) && (x < bbox->Width + xs) &&
+ (y < bbox->Height + ys))
+ {
+ ami_tree_update_quals(twin);
+
+ if(twin->mouse_state & BROWSER_MOUSE_PRESS_1)
+ {
+ tree_mouse_action(twin->tree,
+ BROWSER_MOUSE_DRAG_1 | twin->key_state, x, y);
+ twin->mouse_state = BROWSER_MOUSE_HOLDING_1 |
+ BROWSER_MOUSE_DRAG_ON;
+ if(twin->drag_x == 0) twin->drag_x = x;
+ if(twin->drag_y == 0) twin->drag_y = y;
+
+ }
+ else if(twin->mouse_state & BROWSER_MOUSE_PRESS_2)
+ {
+ tree_mouse_action(twin->tree,
+ BROWSER_MOUSE_DRAG_2 | twin->key_state, x, y);
+ twin->mouse_state = BROWSER_MOUSE_HOLDING_2 |
+ BROWSER_MOUSE_DRAG_ON;
+ if(twin->drag_x == 0) twin->drag_x = x;
+ if(twin->drag_y == 0) twin->drag_y = y;
+ }
+ else
+ {
+ tree_mouse_action(twin->tree,
+ twin->mouse_state | twin->key_state, x, y);
+ }
+ }
+ twin->lastclick.tv_sec = 0;
+ twin->lastclick.tv_usec = 0;
+ break;
+
+ case WMHI_MOUSEBUTTONS:
+ GetAttr(SPACE_AreaBox, twin->gadgets[GID_BROWSER], (ULONG *)&bbox);
+ GetAttr(SCROLLER_Top, twin->objects[OID_HSCROLL], (ULONG *)&xs);
+ x = twin->win->MouseX - bbox->Left + xs;
+ GetAttr(SCROLLER_Top, twin->objects[OID_VSCROLL], (ULONG *)&ys);
+ y = twin->win->MouseY - bbox->Top + ys;
+
+ ami_tree_update_quals(twin);
+
+ if((x >= xs) && (y >= ys) && (x < bbox->Width + xs) &&
+ (y < bbox->Height + ys))
+ {
+ switch(code)
+ {
+ case SELECTDOWN:
+ twin->mouse_state = BROWSER_MOUSE_PRESS_1;
+ break;
+ case MIDDLEDOWN:
+ twin->mouse_state = BROWSER_MOUSE_PRESS_2;
+ break;
+ }
+ tree_mouse_action(twin->tree,
+ twin->mouse_state | twin->key_state, x, y);
+ }
+
+ if(x < xs) x = xs;
+ if(y < ys) y = ys;
+ if(x >= bbox->Width + xs) x = bbox->Width + xs - 1;
+ if(y >= bbox->Height + ys) y = bbox->Height + ys - 1;
+
+ switch(code)
+ {
+ case SELECTUP:
+ if(twin->mouse_state & BROWSER_MOUSE_PRESS_1)
+ {
+ CurrentTime(&curtime.tv_sec,&curtime.tv_usec);
+
+ twin->mouse_state = BROWSER_MOUSE_CLICK_1;
+
+ if(twin->lastclick.tv_sec)
+ {
+ if(DoubleClick(twin->lastclick.tv_sec,
+ twin->lastclick.tv_usec,
+ curtime.tv_sec, curtime.tv_usec))
+ twin->mouse_state |= BROWSER_MOUSE_DOUBLE_CLICK;
+ }
+ tree_mouse_action(twin->tree,
+ twin->mouse_state | twin->key_state, x, y);
+
+ if(twin->mouse_state & BROWSER_MOUSE_DOUBLE_CLICK)
+ {
+ twin->lastclick.tv_sec = 0;
+ twin->lastclick.tv_usec = 0;
+ }
+ else
+ {
+ twin->lastclick.tv_sec = curtime.tv_sec;
+ twin->lastclick.tv_usec = curtime.tv_usec;
+ }
+ }
+ else
+ {
+ tree_drag_end(twin->tree, twin->mouse_state,
+ twin->drag_x, twin->drag_y, x, y);
+ }
+ twin->mouse_state=0;
+ twin->drag_x = 0;
+ twin->drag_y = 0;
+ break;
+ case MIDDLEUP:
+ if(twin->mouse_state & BROWSER_MOUSE_PRESS_2)
+ {
+ tree_mouse_action(twin->tree,
+ BROWSER_MOUSE_CLICK_2 | twin->key_state, x, y);
+ }
+ else
+ {
+ tree_drag_end(twin->tree, twin->mouse_state,
+ twin->drag_x, twin->drag_y, x, y);
+ }
+ twin->mouse_state=0;
+ twin->drag_x = 0;
+ twin->drag_y = 0;
break;
}
break;
-/* no menus yet, copied in as will probably need it later
+ case WMHI_RAWKEY:
+ storage = result & WMHI_GADGETMASK;
+
+ GetAttr(WINDOW_InputEvent,twin->objects[OID_MAIN],(ULONG *)&ie);
+ nskey = ami_key_to_nskey(storage, ie);
+ tree_keypress(twin->tree, nskey);
+ break;
+
case WMHI_MENUPICK:
- item = ItemAddress(gwin->win->MenuStrip,code);
+ item = ItemAddress(twin->win->MenuStrip,code);
while (code != MENUNULL)
{
- ami_menupick(code,gwin);
+ menunum = MENUNUM(code);
+ itemnum = ITEMNUM(code);
+ subnum = SUBNUM(code);
+
+ switch(menunum)
+ {
+ case 0: // tree
+ switch(itemnum)
+ {
+ case 0: // export
+ if(AslRequestTags(savereq,
+ ASLFR_TitleText,messages_get("NetSurf"),
+ ASLFR_Screen,scrn,
+ ASLFR_InitialFile,"tree_export.html",
+ TAG_DONE))
+ {
+ strlcpy(&fname,savereq->fr_Drawer,1024);
+ AddPart(fname,savereq->fr_File,1024);
+ ami_update_pointer(twin->win,GUI_POINTER_WAIT);
+ if(twin->type == AMI_TREE_HISTORY)
+ history_global_export(fname);
+ else if(twin->type == AMI_TREE_HOTLIST)
+ hotlist_export(fname);
+ ami_update_pointer(twin->win,GUI_POINTER_DEFAULT);
+ }
+ break;
+
+ case 2: // expand
+ switch(subnum)
+ {
+ case 0: // all
+ switch(twin->type)
+ {
+ case AMI_TREE_HISTORY:
+ history_global_expand_all();
+ break;
+ case AMI_TREE_COOKIES:
+ cookies_expand_all();
+ break;
+ case AMI_TREE_HOTLIST:
+ hotlist_expand_all();
+ break;
+ }
+ break;
+
+ case 1: // lev 1
+ switch(twin->type)
+ {
+ case AMI_TREE_HISTORY:
+ history_global_expand_directories();
+ break;
+ case AMI_TREE_COOKIES:
+ cookies_expand_domains();
+ break;
+ case AMI_TREE_HOTLIST:
+ hotlist_expand_directories();
+ break;
+ }
+ break;
+
+ case 2: // lev 2
+ switch(twin->type)
+ {
+ case AMI_TREE_HISTORY:
+ history_global_expand_addresses();
+ break;
+ case AMI_TREE_COOKIES:
+ cookies_expand_cookies();
+ break;
+ case AMI_TREE_HOTLIST:
+ hotlist_expand_addresses();
+ break;
+ }
+ break;
+ }
+ break;
+
+ case 3: // collapse
+ switch(subnum)
+ {
+ case 0: // all
+ switch(twin->type)
+ {
+ case AMI_TREE_HISTORY:
+ history_global_collapse_all();
+ break;
+ case AMI_TREE_COOKIES:
+ cookies_collapse_all();
+ break;
+ case AMI_TREE_HOTLIST:
+ hotlist_collapse_all();
+ break;
+ }
+ break;
+
+ case 1: // lev 1
+ switch(twin->type)
+ {
+ case AMI_TREE_HISTORY:
+ history_global_collapse_directories();
+ break;
+ case AMI_TREE_COOKIES:
+ cookies_collapse_domains();
+ break;
+ case AMI_TREE_HOTLIST:
+ hotlist_collapse_directories();
+ break;
+ }
+ break;
+
+ case 2: // lev 2
+ switch(twin->type)
+ {
+ case AMI_TREE_HISTORY:
+ history_global_collapse_addresses();
+ break;
+ case AMI_TREE_COOKIES:
+ cookies_collapse_cookies();
+ break;
+ case AMI_TREE_HOTLIST:
+ hotlist_collapse_addresses();
+ break;
+ }
+ break;
+ }
+ break;
+
+ case 5: // close
+ ami_tree_close(twin);
+ return TRUE;
+ break;
+ }
+ break;
+
+ case 1: // edit
+ switch(itemnum)
+ {
+ case 0: // delete
+ switch(twin->type)
+ {
+ case AMI_TREE_HISTORY:
+ history_global_delete_selected();
+ break;
+ case AMI_TREE_COOKIES:
+ cookies_delete_selected();
+ break;
+ case AMI_TREE_HOTLIST:
+ hotlist_delete_selected();
+ break;
+ }
+ break;
+
+ case 2: // select all
+ switch(twin->type)
+ {
+ case AMI_TREE_HISTORY:
+ history_global_select_all();
+ break;
+ case AMI_TREE_COOKIES:
+ cookies_select_all();
+ break;
+ case AMI_TREE_HOTLIST:
+ hotlist_select_all();
+ break;
+ }
+ break;
+
+ case 3: // clear
+ switch(twin->type)
+ {
+ case AMI_TREE_HISTORY:
+ history_global_clear_selection();
+ break;
+ case AMI_TREE_COOKIES:
+ cookies_clear_selection();
+ break;
+ case AMI_TREE_HOTLIST:
+ hotlist_clear_selection();
+ break;
+ }
+ break;
+ }
+ break;
+ }
+
if(win_destroyed) break;
code = item->NextSelect;
}
break;
-*/
+
+ case WMHI_NEWSIZE:
+ ami_tree_draw(twin);
+ break;
case WMHI_CLOSEWINDOW:
+ if(twin->type == AMI_TREE_SSLCERT)
+ sslcert_reject(twin->ssl_data);
ami_tree_close(twin);
return TRUE;
break;
@@ -633,103 +1013,44 @@ BOOL ami_tree_event(struct treeview_window *twin)
return FALSE;
}
-void ami_move_node(struct treeview_window *twin,int move)
+void ami_tree_draw(struct treeview_window *twin)
{
- struct Node *lbnode = NULL;
- struct node *treenode,*moveto;
- bool before;
-
- GetAttr(LISTBROWSER_SelectedNode,twin->gadgets[GID_TREEBROWSER],(ULONG *)&lbnode);
-
- if(!lbnode) return;
-
- GetListBrowserNodeAttrs(lbnode,
- LBNA_UserData,(ULONG *)&treenode,
-// for multiselects? LBNA_Selected,(BOOL *)&sel,
- TAG_DONE);
-
- selectednode2 = treenode;
+ struct IBox *bbox;
+ int x, y;
- tree_set_node_selected(twin->tree,twin->tree->root,false);
- tree_set_node_selected(twin->tree,treenode,true);
-
- switch(move)
- {
- case AMI_MOVE_UP:
- moveto = treenode->previous;
- before = true;
- break;
-
- case AMI_MOVE_DOWN:
- moveto = treenode->next;
- before = false;
- break;
-
- case AMI_MOVE_OUT:
- moveto = treenode->parent->previous;
- before = false;
- break;
- }
+ if(!twin) return;
- if(!moveto) return;
+ GetAttr(SCROLLER_Top, twin->objects[OID_HSCROLL], (ULONG *)&x);
+ GetAttr(SCROLLER_Top, twin->objects[OID_VSCROLL], (ULONG *)&y);
+ GetAttr(SPACE_AreaBox,twin->gadgets[GID_BROWSER],(ULONG *)&bbox);
- tree_delink_node(treenode);
- //tree_move_selected_nodes(twin->tree,moveto,before);
- tree_link_node(moveto,treenode,before);
- ami_recreate_listbrowser(twin);
- selectednode2 = NULL;
+ ami_tree_redraw_request(x, y, bbox->Width, bbox->Height, twin);
}
-void ami_new_bookmark(struct treeview_window *twin)
+void ami_tree_redraw_request(int x, int y, int width, int height, void *data)
{
- const struct url_data *data;
- struct Node *lbnode;
- struct node *treenode;
- char *url,*title;
+ struct treeview_window *twin = data;
+ struct IBox *bbox;
+ int pos_x, pos_y;
- GetAttr(LISTBROWSER_SelectedNode,twin->gadgets[GID_TREEBROWSER],(ULONG *)&lbnode);
- if(lbnode)
- {
- GetListBrowserNodeAttrs(lbnode,
- LBNA_UserData,(ULONG *)&treenode,
- TAG_DONE);
- }
- else
- {
- treenode = twin->tree->root;
- }
+ if(!twin->win) return;
+// if(tree_get_redraw(twin->tree) == false) return;
- url = (char *)strdup("http://www.netsurf-browser.org");
+ ami_update_pointer(twin->win, GUI_POINTER_WAIT);
+ glob = &twin->globals;
- data = urldb_get_url_data(url);
- if (!data)
- {
- urldb_add_url(url);
- urldb_set_url_persistence(url,true);
- data = urldb_get_url_data(url);
- }
+ GetAttr(SPACE_AreaBox,twin->gadgets[GID_BROWSER],(ULONG *)&bbox);
+ GetAttr(SCROLLER_Top, twin->objects[OID_HSCROLL], (ULONG *)&pos_x);
+ GetAttr(SCROLLER_Top, twin->objects[OID_VSCROLL], (ULONG *)&pos_y);
- if (data)
- {
- title = data->title;
- tree_create_URL_node(treenode,url,data,title);
- ami_recreate_listbrowser(twin);
- }
-}
-
-void ami_recreate_listbrowser(struct treeview_window *twin)
-{
- static WORD gen=0;
+ if(x - pos_x + width > bbox->Width) width = bbox->Width - (x - pos_x);
+ if(y - pos_y + height > bbox->Height) height = bbox->Height - (y - pos_y);
- SetGadgetAttrs(twin->gadgets[GID_TREEBROWSER],twin->win,NULL,
- LISTBROWSER_Labels,~0,
- TAG_DONE);
+ tree_draw(twin->tree, -pos_x, -pos_y, x, y, width, height);
- FreeListBrowserList(twin->listbrowser_list);
- ami_add_elements(twin,twin->tree->root,&gen);
+ BltBitMapRastPort(twin->globals.bm, x - pos_x, y - pos_y, twin->win->RPort,
+ bbox->Left + x - pos_x, bbox->Top + y - pos_y, width, height, 0x0C0);
- RefreshSetGadgetAttrs(twin->gadgets[GID_TREEBROWSER],twin->win,NULL,
- LISTBROWSER_Labels,twin->listbrowser_list,
- LISTBROWSER_SelectedNode,selectednode,
- TAG_DONE);
+ ami_update_pointer(twin->win, GUI_POINTER_DEFAULT);
+ glob = &browserglob;
}
diff --git a/amiga/tree.h b/amiga/tree.h
index 4129df1d2..315938d0d 100755
--- a/amiga/tree.h
+++ b/amiga/tree.h
@@ -1,5 +1,5 @@
/*
- * Copyright 2008 Chris Young <chris@unsatisfactorysoftware.co.uk>
+ * Copyright 2008, 2009 Chris Young <chris@unsatisfactorysoftware.co.uk>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
*
@@ -22,15 +22,10 @@
#include <exec/types.h>
#include <intuition/classusr.h>
#include "amiga/gui.h"
+#include "desktop/tree.h"
+#include "desktop/sslcert.h"
-struct treeview_window {
- struct nsObject *node;
- struct Window *win;
- Object *objects[OID_LAST];
- struct Gadget *gadgets[GID_LAST];
- struct tree *tree;
- struct List *listbrowser_list;
-};
+struct treeview_window;
enum
{
@@ -40,15 +35,15 @@ enum
AMI_TREE_SSLCERT
};
-enum
-{
- AMI_MOVE_UP,
- AMI_MOVE_DOWN,
- AMI_MOVE_OUT
-};
+struct treeview_window *ami_tree_create(uint8 flags,
+ struct sslcert_session_data *ssl_data);
+void ami_tree_destroy(struct treeview_window *twin);
+struct tree *ami_tree_get_tree(struct treeview_window *twin);
-void ami_open_tree(struct tree *tree,int type);
+void ami_tree_open(struct treeview_window *twin,int type);
void ami_tree_close(struct treeview_window *twin);
BOOL ami_tree_event(struct treeview_window *twin);
-void ami_recreate_listbrowser(struct treeview_window *twin);
+
+extern const struct treeview_table ami_tree_callbacks;
+
#endif