From 09bc58f7c2926922e59542e8ca2de2f5941714df Mon Sep 17 00:00:00 2001 From: Chris Young Date: Wed, 28 Nov 2012 19:29:43 +0000 Subject: Create a toolbar from the "Toolbar" folder within the hotlist. Note: makes no attempt to either free the toolbar or make the toolbar work. --- amiga/gui.c | 86 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- amiga/gui.h | 6 +++++ 2 files changed, 91 insertions(+), 1 deletion(-) (limited to 'amiga') diff --git a/amiga/gui.c b/amiga/gui.c index 293379283..3a00435de 100755 --- a/amiga/gui.c +++ b/amiga/gui.c @@ -30,6 +30,7 @@ #include "desktop/selection.h" #include "desktop/textinput.h" #include "desktop/tree.h" +#include "desktop/tree_url_node.h" #include "image/ico.h" #include "utils/log.h" #include "utils/messages.h" @@ -109,6 +110,7 @@ #include #include #include +#include #include #include @@ -118,6 +120,7 @@ #include #include #include +#include #include #include #include @@ -1930,7 +1933,7 @@ void ami_handle_msg(void) if(ami_menu_window_close) { - if(ami_menu_window_close == AMI_MENU_WINDOW_CLOSE_ALL) + if(ami_menu_window_close == (void *)AMI_MENU_WINDOW_CLOSE_ALL) ami_quit_netsurf(); else ami_close_all_tabs(ami_menu_window_close); @@ -2425,6 +2428,81 @@ void ami_update_buttons(struct gui_window_2 *gwin) } } +void ami_gui_hotlist_scan_2(struct tree *tree, struct node *root, WORD *gen, uint16 *item, + struct List *speed_button_list, struct gui_window_2 *gwin) +{ + struct node *tempnode; + struct node_element *element=NULL; + struct node *node; + struct Node *speed_button_node; + + *gen = *gen + 1; + + for (node = root; node; node = tree_node_get_next(node)) + { + if((*gen == 1) && (*item < AMI_GUI_TOOLBAR_MAX)) /* Don't cascade into sub-dirs */ + { + gwin->hotlist_toolbar_lab[*item] = ami_utf8_easy((char *)tree_url_node_get_title(node)); + + speed_button_node = AllocSpeedButtonNode(*item, + SBNA_Text, gwin->hotlist_toolbar_lab[*item], + SBNA_UserData, (void *)tree_url_node_get_url(node), + TAG_DONE); + + AddTail(speed_button_list, speed_button_node); + + *item = *item + 1; + } + + /* Don't need this atm as it cascades into sub-dirs + if (tree_node_get_child(node)) + { + ami_gui_hotlist_scan_2(tree, tree_node_get_child(node), gen); + } + */ + } + + *gen = *gen - 1; +} + +int ami_gui_hotlist_scan(struct tree *tree, struct List *speed_button_list, struct gui_window_2 *gwin) +{ + struct node *root = tree_node_get_child(tree_get_root(tree)); + struct node *node; + struct node_element *element; + static WORD gen = 0; + static uint16 item = 0; + + for (node = root; node; node = tree_node_get_next(node)) + { + 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), "Toolbar") == 0)) + { + ami_gui_hotlist_scan_2(tree, tree_node_get_child(node), &gen, &item, speed_button_list, gwin); + } + } + + return item; +} + +void ami_gui_hotlist_toolbar_add(struct gui_window_2 *gwin) +{ + NewList(&gwin->hotlist_toolbar_list); + + if(ami_gui_hotlist_scan(ami_tree_get_tree(hotlist_window), &gwin->hotlist_toolbar_list, gwin) > 0) { + gwin->objects[GID_HOTLIST] = + SpeedBarObject, + GA_ID, GID_HOTLIST, + GA_RelVerify, TRUE, + SPEEDBAR_Buttons, &gwin->hotlist_toolbar_list, + SpeedBarEnd; + + IDoMethod(gwin->objects[GID_HOTLISTLAYOUT], LM_ADDCHILD, + gwin->win, gwin->objects[GID_HOTLIST], NULL); + } +} + void ami_toggletabbar(struct gui_window_2 *gwin, bool show) { if(ClickTabBase->lib_Version < 53) return; @@ -2908,6 +2986,10 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw, CHILD_WeightedHeight,0, LayoutEnd, CHILD_WeightedHeight,0, + LAYOUT_AddChild, g->shared->objects[GID_HOTLISTLAYOUT] = HGroupObject, + LAYOUT_SpaceInner, FALSE, + LayoutEnd, + CHILD_WeightedHeight,0, LAYOUT_AddChild, g->shared->objects[GID_BROWSER] = SpaceObject, GA_ID,GID_BROWSER, SPACE_Transparent,TRUE, @@ -3039,6 +3121,8 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw, RefreshGadgets((APTR)g->shared->objects[GID_STATUS], g->shared->win, NULL); + + ami_gui_hotlist_toolbar_add(g->shared); /* is this the right place for this? */ } else { diff --git a/amiga/gui.h b/amiga/gui.h index 181bd4f3b..59c60f4c9 100755 --- a/amiga/gui.h +++ b/amiga/gui.h @@ -64,6 +64,8 @@ enum GID_SHOWALL, GID_CASE, GID_TOOLBARLAYOUT, + GID_HOTLIST, + GID_HOTLISTLAYOUT, GID_HSCROLL, GID_LAST }; @@ -71,6 +73,8 @@ enum struct find_window; struct history_window; +#define AMI_GUI_TOOLBAR_MAX 20 + struct gui_window_2 { struct nsObject *node; struct Window *win; @@ -98,6 +102,8 @@ struct gui_window_2 { UBYTE *menutype; struct NewMenu *menu; ULONG hotlist_items; + char *hotlist_toolbar_lab[AMI_GUI_TOOLBAR_MAX]; + struct List hotlist_toolbar_list; char *svbuffer; char *status; char *wintitle; -- cgit v1.2.3