Move new blank tab into own function

This commit is contained in:
Chris Young 2014-01-03 18:17:25 +00:00
parent 5fe89ab135
commit c25728b011
3 changed files with 33 additions and 24 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright 2008-2013 Chris Young <chris@unsatisfactorysoftware.co.uk>
* Copyright 2008-2014 Chris Young <chris@unsatisfactorysoftware.co.uk>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
*
@ -3139,6 +3139,34 @@ void ami_gui_tabs_toggle_all(void)
} while(node = nnode);
}
nserror ami_gui_new_blank_tab(struct gui_window_2 *gwin)
{
nsurl *url;
nserror error;
struct browser_window *bw = NULL;
error = nsurl_create(nsoption_charp(homepage_url), &url);
if (error == NSERROR_OK) {
error = browser_window_create(BROWSER_WINDOW_VERIFIABLE |
BROWSER_WINDOW_HISTORY |
BROWSER_WINDOW_TAB,
url,
NULL,
gwin->bw,
&bw);
nsurl_unref(url);
}
if (error != NSERROR_OK) {
warn_user(messages_get_errorcode(error), 0);
return error;
}
history_destroy(bw->history);
bw->history = history_create();
return NSERROR_OK;
}
struct gui_window *gui_create_browser_window(struct browser_window *bw,
struct browser_window *clone, bool new_tab)
{

View File

@ -1,5 +1,5 @@
/*
* Copyright 2008-2012 Chris Young <chris@unsatisfactorysoftware.co.uk>
* Copyright 2008-2014 Chris Young <chris@unsatisfactorysoftware.co.uk>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
*
@ -164,6 +164,7 @@ void ami_gui_hotlist_toolbar_update_all(void);
void ami_gui_tabs_toggle_all(void);
bool ami_locate_resource(char *fullpath, const char *file);
void ami_gui_update_hotlist_button(struct gui_window_2 *gwin);
nserror ami_gui_new_blank_tab(struct gui_window_2 *gwin);
struct TextFont *origrpfont;
struct MinList *window_list;

View File

@ -714,30 +714,10 @@ static void ami_menu_item_project_newwin(struct Hook *hook, APTR window, struct
static void ami_menu_item_project_newtab(struct Hook *hook, APTR window, struct IntuiMessage *msg)
{
struct gui_window_2 *gwin;
nsurl *url;
nserror error;
struct browser_window *bw = NULL;
GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
error = nsurl_create(nsoption_charp(homepage_url), &url);
if (error == NSERROR_OK) {
error = browser_window_create(BROWSER_WINDOW_VERIFIABLE |
BROWSER_WINDOW_HISTORY |
BROWSER_WINDOW_TAB,
url,
NULL,
gwin->bw,
&bw);
nsurl_unref(url);
}
if (error != NSERROR_OK) {
warn_user(messages_get_errorcode(error), 0);
return;
}
history_destroy(bw->history);
bw->history = history_create();
error = ami_gui_new_blank_tab(gwin);
}
static void ami_menu_item_project_open(struct Hook *hook, APTR window, struct IntuiMessage *msg)