summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers@digital-scurf.org>2020-02-22 11:51:10 +0000
committerDaniel Silverstone <dsilvers@digital-scurf.org>2020-02-22 11:51:10 +0000
commit5c377cd285536f4bec2a6cfb6352a45cfe6cb39e (patch)
treee87a9e2f7e3d8207714717fac427d1e97158625c
parentf3bdee255d3c4252640b2337224e2f0b95944d7f (diff)
downloadnetsurf-5c377cd285536f4bec2a6cfb6352a45cfe6cb39e.tar.gz
netsurf-5c377cd285536f4bec2a6cfb6352a45cfe6cb39e.tar.bz2
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>
-rw-r--r--frontends/gtk/scaffolding.c4
-rw-r--r--frontends/gtk/toolbar.c6
-rw-r--r--frontends/gtk/window.c24
-rw-r--r--frontends/gtk/window.h1
4 files changed, 10 insertions, 25 deletions
diff --git a/frontends/gtk/scaffolding.c b/frontends/gtk/scaffolding.c
index 03d7160a8..0b3fe6783 100644
--- a/frontends/gtk/scaffolding.c
+++ b/frontends/gtk/scaffolding.c
@@ -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;
}
diff --git a/frontends/gtk/toolbar.c b/frontends/gtk/toolbar.c
index f191bc174..1a6bc124e 100644
--- a/frontends/gtk/toolbar.c
+++ b/frontends/gtk/toolbar.c
@@ -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) {
diff --git a/frontends/gtk/window.c b/frontends/gtk/window.c
index 39b7413d3..b47a1b07d 100644
--- a/frontends/gtk/window.c
+++ b/frontends/gtk/window.c
@@ -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);
diff --git a/frontends/gtk/window.h b/frontends/gtk/window.h
index 728c653a8..b126a955f 100644
--- a/frontends/gtk/window.h
+++ b/frontends/gtk/window.h
@@ -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