GTK: Use new BW_CREATE_FOREGROUND flags

This gets rid of temp_open_background which was, frankly, a bit
of an eyesore.  In addition it makes the open-in-new-tab context
menu action behave like Firefox's with respect to the user's preference
regarding whether or not to immediately focus new tabs.

Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
This commit is contained in:
Daniel Silverstone 2020-02-22 11:51:10 +00:00
parent f3bdee255d
commit 5c377cd285
No known key found for this signature in database
GPG Key ID: C30DF439F2987D74
4 changed files with 10 additions and 25 deletions

View File

@ -547,8 +547,6 @@ nsgtk_on_link_opentab_activate_menu(GtkMenuItem *widget, gpointer data)
if (current_menu_features.link == NULL)
return FALSE;
temp_open_background = 1;
err = browser_window_create(BW_CREATE_CLONE |
BW_CREATE_HISTORY |
BW_CREATE_TAB,
@ -557,8 +555,6 @@ nsgtk_on_link_opentab_activate_menu(GtkMenuItem *widget, gpointer data)
nsgtk_warning(messages_get_errorcode(err), 0);
}
temp_open_background = -1;
return TRUE;
}

View File

@ -926,7 +926,7 @@ nsgtk_browser_window_create(struct browser_window *bw, bool intab)
{
nserror res = NSERROR_OK;
nsurl *url = NULL;
int flags = BW_CREATE_HISTORY;
int flags = BW_CREATE_HISTORY | BW_CREATE_FOREGROUND;
if (intab) {
flags |= BW_CREATE_TAB;
@ -1995,16 +1995,14 @@ static gboolean websearch_entry_activate_cb(GtkWidget *widget, gpointer data)
SEARCH_WEB_OMNI_SEARCHONLY,
&url);
if (res == NSERROR_OK) {
temp_open_background = 0;
bw = tb->get_bw(tb->get_ctx);
res = browser_window_create(
BW_CREATE_HISTORY | BW_CREATE_TAB,
BW_CREATE_HISTORY | BW_CREATE_TAB | BW_CREATE_FOREGROUND,
url,
NULL,
bw,
NULL);
temp_open_background = -1;
nsurl_unref(url);
}
if (res != NSERROR_OK) {

View File

@ -143,9 +143,6 @@ struct gui_window {
/**< first entry in window list */
struct gui_window *window_list = NULL;
/** flag controlling opening of tabs in the background */
int temp_open_background = -1;
static void
nsgtk_select_menu_clicked(GtkCheckMenuItem *checkmenuitem,
gpointer user_data)
@ -806,9 +803,13 @@ gui_window_create(struct browser_window *bw,
gui_window_create_flags flags)
{
struct gui_window *g; /* what is being created to return */
bool tempback;
bool open_in_background = !(nsoption_bool(focus_new));
GtkBuilder* tab_builder;
/* If there is a foreground request, override user preference */
if (flags & GW_CREATE_FOREGROUND)
open_in_background = false;
nserror res;
res = nsgtk_builder_new_from_resname("tabcontents", &tab_builder);
@ -953,18 +954,9 @@ gui_window_create(struct browser_window *bw,
nsgtk_window_input_method_commit, g);
/* add the tab container to the scaffold notebook */
switch (temp_open_background) {
case -1:
tempback = !(nsoption_bool(focus_new));
break;
case 0:
tempback = false;
break;
default:
tempback = true;
break;
}
nsgtk_tab_add(g, g->container, tempback, messages_get("NewTab"), g->icon);
nsgtk_tab_add(g, g->container,
open_in_background,
messages_get("NewTab"), g->icon);
/* initialy should not be visible */
nsgtk_search_toggle_visibility(g->search);

View File

@ -23,7 +23,6 @@ extern struct gui_window_table *nsgtk_window_table;
extern struct gui_search_web_table *nsgtk_search_web_table;
extern struct gui_window *window_list;
extern int temp_open_background;
/**
* get core browsing context from gui window handle