From 4147c185c8d547e041c1d0c81c283ef0c7942cc8 Mon Sep 17 00:00:00 2001 From: Chris Young Date: Sat, 2 Jul 2011 11:41:06 +0000 Subject: When launching multiple URLs from a treeview, allow to open one window with multiple tabs instead of one window per URL. Make compatible frontends do this by default. svn path=/trunk/netsurf/; revision=12552 --- amiga/tree.c | 2 +- desktop/history_global_core.c | 6 ++++-- desktop/history_global_core.h | 2 +- desktop/hotlist.c | 6 ++++-- desktop/hotlist.h | 2 +- desktop/tree.c | 20 +++++++++++++++----- desktop/tree.h | 4 +++- desktop/tree_url_node.c | 9 +++++++-- gtk/history.c | 2 +- gtk/hotlist.c | 2 +- riscos/global_history.c | 4 ++-- riscos/hotlist.c | 4 ++-- 12 files changed, 42 insertions(+), 21 deletions(-) diff --git a/amiga/tree.c b/amiga/tree.c index efd8f450c..f975e87ee 100755 --- a/amiga/tree.c +++ b/amiga/tree.c @@ -765,7 +765,7 @@ BOOL ami_tree_event(struct treeview_window *twin) ami_tree_close(twin); return TRUE; } - else tree_launch_selected(twin->tree); + else tree_launch_selected(twin->tree, true); break; case GID_CANCEL: diff --git a/desktop/history_global_core.c b/desktop/history_global_core.c index 8c8834834..f06d79d8b 100644 --- a/desktop/history_global_core.c +++ b/desktop/history_global_core.c @@ -452,8 +452,10 @@ void history_global_collapse_addresses(void) /** * Open the selected entries in seperate browser windows. + * + * \param tabs open multiple entries in tabs in the new window */ -void history_global_launch_selected(void) +void history_global_launch_selected(bool tabs) { - tree_launch_selected(global_history_tree); + tree_launch_selected(global_history_tree, tabs); } diff --git a/desktop/history_global_core.h b/desktop/history_global_core.h index 1bb343dd6..7b8e6823a 100644 --- a/desktop/history_global_core.h +++ b/desktop/history_global_core.h @@ -39,6 +39,6 @@ void history_global_expand_addresses(void); void history_global_collapse_all(void); void history_global_collapse_directories(void); void history_global_collapse_addresses(void); -void history_global_launch_selected(void); +void history_global_launch_selected(bool tabs); #endif diff --git a/desktop/hotlist.c b/desktop/hotlist.c index a740458cb..acfef10cd 100644 --- a/desktop/hotlist.c +++ b/desktop/hotlist.c @@ -454,8 +454,10 @@ void hotlist_add_page_xy(const char *url, int x, int y) /** * Open the selected entries in separate browser windows. + * + * \param tabs open multiple entries in tabs in the new window */ -void hotlist_launch_selected(void) +void hotlist_launch_selected(bool tabs) { - tree_launch_selected(hotlist_tree); + tree_launch_selected(hotlist_tree, tabs); } diff --git a/desktop/hotlist.h b/desktop/hotlist.h index efce84696..b17d98baa 100644 --- a/desktop/hotlist.h +++ b/desktop/hotlist.h @@ -57,6 +57,6 @@ void hotlist_add_folder(void); void hotlist_add_entry(void); void hotlist_add_page(const char *url); void hotlist_add_page_xy(const char *url, int x, int y); -void hotlist_launch_selected(void); +void hotlist_launch_selected(bool tabs); #endif diff --git a/desktop/tree.c b/desktop/tree.c index c33f29df8..f8105bb19 100644 --- a/desktop/tree.c +++ b/desktop/tree.c @@ -2152,20 +2152,29 @@ struct node *tree_get_link_details(struct tree *tree, int x, int y, * * \param tree the tree for which all nodes will be launched * \param node the node which will be checked together with its children + * \param tabs launch node in a new tab instead of a new window */ -static void tree_launch_selected_internal(struct tree *tree, struct node *node) +static void tree_launch_selected_internal(struct tree *tree, struct node *node, + bool tabs) { struct node_msg_data msg_data; + msg_data.data.bw = NULL; + for (; node != NULL; node = node->next) { if (node->selected && node->user_callback != NULL) { msg_data.msg = NODE_LAUNCH; - msg_data.flag = TREE_ELEMENT_TITLE; + if (tabs == true) { + msg_data.flag = TREE_ELEMENT_LAUNCH_IN_TABS; + } else { + msg_data.flag = TREE_ELEMENT_TITLE; + } + msg_data.node = node; node->user_callback(node->callback_data, &msg_data); } if (node->child != NULL) - tree_launch_selected_internal(tree, node->child); + tree_launch_selected_internal(tree, node->child, tabs); } } @@ -2174,11 +2183,12 @@ static void tree_launch_selected_internal(struct tree *tree, struct node *node) * Launches all the selected nodes of the tree * * \param tree the tree for which all nodes will be launched + * \param tabs launch nodes in new tabs instead of new windows */ -void tree_launch_selected(struct tree *tree) +void tree_launch_selected(struct tree *tree, bool tabs) { if (tree->root->child != NULL) - tree_launch_selected_internal(tree, tree->root->child); + tree_launch_selected_internal(tree, tree->root->child, tabs); } diff --git a/desktop/tree.h b/desktop/tree.h index e3dc8c98a..0ff8948bc 100644 --- a/desktop/tree.h +++ b/desktop/tree.h @@ -54,6 +54,7 @@ enum tree_flags { * to indicate teh type of data a node element contains. */ #define TREE_ELEMENT_TITLE 0x00 +#define TREE_ELEMENT_LAUNCH_IN_TABS 0x05 /* Launch in tabs instead of windows */ struct tree; struct node; @@ -102,6 +103,7 @@ struct node_msg_data { union { char *text; /**< textural data. */ void *bitmap; /**< bitmap data. */ + struct browser_window *bw; /**< clone browser_window. */ } data; /**< The message data. */ }; @@ -186,7 +188,7 @@ void tree_delete_selected_nodes(struct tree *tree, struct node *node); struct node *tree_get_selected_node(struct node *node); struct node *tree_get_link_details(struct tree *tree, int x, int y, bool *before); -void tree_launch_selected(struct tree *tree); +void tree_launch_selected(struct tree *tree, bool tabs); bool tree_mouse_action(struct tree *tree, browser_mouse_state mouse, int x, int y); diff --git a/desktop/tree_url_node.c b/desktop/tree_url_node.c index 50b3f338e..b524f9b8c 100644 --- a/desktop/tree_url_node.c +++ b/desktop/tree_url_node.c @@ -383,8 +383,13 @@ node_callback_resp tree_url_node_callback(void *user_data, TREE_ELEMENT_URL, NULL); if (element != NULL) { text = tree_node_element_get_text(element); - browser_window_create(text, NULL, 0, - true, false); + if (msg_data->flag == TREE_ELEMENT_LAUNCH_IN_TABS) { + msg_data->data.bw = browser_window_create(text, + msg_data->data.bw, 0, true, true); + } else { + browser_window_create(text, NULL, 0, + true, false); + } return NODE_CALLBACK_HANDLED; } break; diff --git a/gtk/history.c b/gtk/history.c index b5c019f76..34c76cd7d 100644 --- a/gtk/history.c +++ b/gtk/history.c @@ -258,6 +258,6 @@ MENUHANDLER(collapse_addresses) MENUHANDLER(launch) { - history_global_launch_selected(); + history_global_launch_selected(true); return TRUE; } diff --git a/gtk/hotlist.c b/gtk/hotlist.c index 6a821d7a3..f6f11c73b 100644 --- a/gtk/hotlist.c +++ b/gtk/hotlist.c @@ -274,6 +274,6 @@ MENUHANDLER(collapse_addresses) MENUHANDLER(launch) { - hotlist_launch_selected(); + hotlist_launch_selected(true); return TRUE; } diff --git a/riscos/global_history.c b/riscos/global_history.c index 28fd107ce..a6b43b863 100644 --- a/riscos/global_history.c +++ b/riscos/global_history.c @@ -213,7 +213,7 @@ void ro_gui_global_history_toolbar_click(button_bar_action action) break; case TOOLBAR_BUTTON_LAUNCH: - history_global_launch_selected(); + history_global_launch_selected(false); break; default: @@ -352,7 +352,7 @@ bool ro_gui_global_history_menu_select(wimp_w w, wimp_i i, wimp_menu *menu, history_global_collapse_addresses(); return true; case TREE_SELECTION_LAUNCH: - history_global_launch_selected(); + history_global_launch_selected(false); return true; case TREE_SELECTION_DELETE: history_global_delete_selected(); diff --git a/riscos/hotlist.c b/riscos/hotlist.c index 3bb2c59e7..7c52d6d37 100644 --- a/riscos/hotlist.c +++ b/riscos/hotlist.c @@ -217,7 +217,7 @@ void ro_gui_hotlist_toolbar_click(button_bar_action action) break; case TOOLBAR_BUTTON_LAUNCH: - hotlist_launch_selected(); + hotlist_launch_selected(false); break; case TOOLBAR_BUTTON_CREATE: @@ -365,7 +365,7 @@ bool ro_gui_hotlist_menu_select(wimp_w w, wimp_i i, wimp_menu *menu, hotlist_edit_selected(); return true; case TREE_SELECTION_LAUNCH: - hotlist_launch_selected(); + hotlist_launch_selected(false); return true; case TREE_SELECTION_DELETE: hotlist_delete_selected(); -- cgit v1.2.3