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
This commit is contained in:
Chris Young 2011-07-02 11:41:06 +00:00
parent f9566b6405
commit 4147c185c8
12 changed files with 42 additions and 21 deletions

View File

@ -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:

View File

@ -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);
}

View File

@ -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

View File

@ -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);
}

View File

@ -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

View File

@ -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);
}

View File

@ -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);

View File

@ -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;

View File

@ -258,6 +258,6 @@ MENUHANDLER(collapse_addresses)
MENUHANDLER(launch)
{
history_global_launch_selected();
history_global_launch_selected(true);
return TRUE;
}

View File

@ -274,6 +274,6 @@ MENUHANDLER(collapse_addresses)
MENUHANDLER(launch)
{
hotlist_launch_selected();
hotlist_launch_selected(true);
return TRUE;
}

View File

@ -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();

View File

@ -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();