Gitweb links:
...log
http://git.netsurf-browser.org/netsurf.git/shortlog/a016445a8265a03719d52c49e069c7f6914c7e4d
...commit
http://git.netsurf-browser.org/netsurf.git/commit/a016445a8265a03719d52c49e069c7f6914c7e4d
...tree
http://git.netsurf-browser.org/netsurf.git/tree/a016445a8265a03719d52c49e069c7f6914c7e4d
The branch, master has been updated
via a016445a8265a03719d52c49e069c7f6914c7e4d (commit)
via 5239163f4dd47a3f9ca74501575053a69c5a95b8 (commit)
via 0fa5f81a52a62a04f4564d84e391543995cf9418 (commit)
via 5c377cd285536f4bec2a6cfb6352a45cfe6cb39e (commit)
via f3bdee255d3c4252640b2337224e2f0b95944d7f (commit)
via d25fada8cf820b8748a822b510b18f34f8a6ed30 (commit)
from bc1810ed61d235aac76cfc19200155ec37f55b6e (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff
http://git.netsurf-browser.org/netsurf.git/commit/?id=a016445a8265a03719d52c49e069c7f6914c7e4d
commit a016445a8265a03719d52c49e069c7f6914c7e4d
Author: Daniel Silverstone <[email protected]>
Commit: Daniel Silverstone <[email protected]>
GTK: Add a location focus state machine
Because the initial navigation process on new browser window
creation is somewhat complex, we need a small state machine in
the GTK UI to ensure that we handle the correct combination
of focussing needed to maintain selection through initial tab
opening.
Signed-off-by: Daniel Silverstone <[email protected]>
diff --git a/frontends/gtk/toolbar.c b/frontends/gtk/toolbar.c
index c9ec19c..f2b1d05 100644
--- a/frontends/gtk/toolbar.c
+++ b/frontends/gtk/toolbar.c
@@ -144,6 +144,25 @@ struct nsgtk_toolbar_item {
void *dataminus;
};
+/**
+ * Location focus state machine
+ *
+ * 1. If we don't care, we're in LFS_IDLE
+ * 2. When we create a new toolbar, we can put it into
+ * LFS_WANT which means that we want the url bar to focus
+ * 3. When we start throbbing if we're in LFS_WANT we move to LFS_THROB
+ * 4. When we stop throbbing, if we're in LFS_THROB we move to LFS_LAST
+ *
+ * While not in LFS_IDLE, if the url bar is updated and we previously had it
+ * fully selected then we reselect it all. If we're in LFS_LAST we move to
+ * LFS_IDLE at that point.
+ */
+typedef enum {
+ LFS_IDLE, /**< Nothing to do */
+ LFS_WANT, /**< Want focus, will apply */
+ LFS_THROB, /**< Want focus, we have started throbbing */
+ LFS_LAST, /**< Last chance for a focus update */
+} nsgtk_toolbar_location_focus_state;
/**
* control toolbar context
@@ -182,6 +201,11 @@ struct nsgtk_toolbar {
* context passed to get_bw function
*/
void *get_ctx;
+
+ /**
+ * Location focus state machine, current state
+ */
+ nsgtk_toolbar_location_focus_state loc_focus;
};
@@ -3416,6 +3440,7 @@ nserror
nsgtk_toolbar_create(GtkBuilder *builder,
struct browser_window *(*get_bw)(void *ctx),
void *get_ctx,
+ bool want_location_focus,
struct nsgtk_toolbar **tb_out)
{
nserror res;
@@ -3431,6 +3456,11 @@ nsgtk_toolbar_create(GtkBuilder *builder,
tb->get_ctx = get_ctx;
/* set the throbber start frame. */
tb->throb_frame = 0;
+ if (want_location_focus) {
+ tb->loc_focus = LFS_WANT;
+ } else {
+ tb->loc_focus = LFS_IDLE;
+ }
tb->widget = GTK_TOOLBAR(gtk_builder_get_object(builder, "toolbar"));
gtk_toolbar_set_show_arrow(tb->widget, TRUE);
@@ -3515,6 +3545,24 @@ nserror nsgtk_toolbar_throbber(struct nsgtk_toolbar *tb,
bool active)
nserror res;
struct browser_window *bw;
+ /* Manage the location focus state */
+ switch (tb->loc_focus) {
+ case LFS_IDLE:
+ break;
+ case LFS_WANT:
+ if (active) {
+ tb->loc_focus = LFS_THROB;
+ }
+ break;
+ case LFS_THROB:
+ if (!active) {
+ tb->loc_focus = LFS_LAST;
+ }
+ break;
+ case LFS_LAST:
+ break;
+ }
+
/* when activating the throbber simply schedule the next frame update */
if (active) {
nsgtk_schedule(THROBBER_FRAME_TIME, next_throbber_frame, tb);
@@ -3627,7 +3675,23 @@ nserror nsgtk_toolbar_set_url(struct nsgtk_toolbar *tb,
nsurl *url)
url_text = nsurl_access(url);
}
- gtk_entry_set_text(url_entry, url_text);
+ if (strcmp(url_text, gtk_entry_get_text(url_entry)) != 0) {
+ /* The URL bar content has changed, we need to update it */
+ gint startpos, endpos;
+ bool was_selected;
+ gtk_editable_get_selection_bounds(GTK_EDITABLE(url_entry),
+ &startpos, &endpos);
+ was_selected = gtk_widget_is_focus(GTK_WIDGET(url_entry)) &&
+ startpos == 0 &&
+ endpos == gtk_entry_get_text_length(url_entry);
+ gtk_entry_set_text(url_entry, url_text);
+ if (was_selected && tb->loc_focus != LFS_IDLE) {
+ gtk_widget_grab_focus(GTK_WIDGET(url_entry));
+ if (tb->loc_focus == LFS_LAST) {
+ tb->loc_focus = LFS_IDLE;
+ }
+ }
+ }
if (idn_url_s != NULL) {
free(idn_url_s);
diff --git a/frontends/gtk/toolbar.h b/frontends/gtk/toolbar.h
index 9bb859b..77c3bcd 100644
--- a/frontends/gtk/toolbar.h
+++ b/frontends/gtk/toolbar.h
@@ -32,7 +32,11 @@ struct nsgtk_scaffolding;
* \param[out] toolbar a pointer to receive the result.
* \return NSERROR_OK and toolbar updated on success else error code
*/
-nserror nsgtk_toolbar_create(GtkBuilder *builder, struct browser_window
*(*get_bw)(void *ctx), void *get_bw_ctx,struct nsgtk_toolbar **toolbar);
+nserror nsgtk_toolbar_create(GtkBuilder *builder,
+ struct browser_window *(*get_bw)(void *ctx),
+ void *get_bw_ctx,
+ bool want_location_focus,
+ struct nsgtk_toolbar **toolbar);
/**
diff --git a/frontends/gtk/window.c b/frontends/gtk/window.c
index 64f09eb..925c378 100644
--- a/frontends/gtk/window.c
+++ b/frontends/gtk/window.c
@@ -862,7 +862,9 @@ gui_window_create(struct browser_window *bw,
/* create toolbar */
- res = nsgtk_toolbar_create(tab_builder, bw_from_gw, g, &g->toolbar);
+ res = nsgtk_toolbar_create(tab_builder, bw_from_gw, g,
+ !!(flags & GW_CREATE_FOCUS_LOCATION),
+ &g->toolbar);
if (res != NSERROR_OK) {
free(g);
g_object_unref(tab_builder);
commitdiff
http://git.netsurf-browser.org/netsurf.git/commit/?id=5239163f4dd47a3f9ca74501575053a69c5a95b8
commit 5239163f4dd47a3f9ca74501575053a69c5a95b8
Author: Daniel Silverstone <[email protected]>
Commit: Daniel Silverstone <[email protected]>
GTK: Request and honour location focus
So that when we create a new tab we automatically focus the
location box, pass the flag into create, and honour it when it
comes back to us.
Signed-off-by: Daniel Silverstone <[email protected]>
diff --git a/frontends/gtk/toolbar.c b/frontends/gtk/toolbar.c
index 1a6bc12..c9ec19c 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 | BW_CREATE_FOREGROUND;
+ int flags = BW_CREATE_HISTORY | BW_CREATE_FOREGROUND |
BW_CREATE_FOCUS_LOCATION;
if (intab) {
flags |= BW_CREATE_TAB;
diff --git a/frontends/gtk/window.c b/frontends/gtk/window.c
index b47a1b0..64f09eb 100644
--- a/frontends/gtk/window.c
+++ b/frontends/gtk/window.c
@@ -969,6 +969,13 @@ gui_window_create(struct browser_window *bw,
*/
g_object_unref(tab_builder);
+ /* Finally we need to focus the location bar if requested */
+ if (flags & GW_CREATE_FOCUS_LOCATION) {
+ if (nsgtk_window_item_activate(g, OPENLOCATION_BUTTON) !=
NSERROR_OK) {
+ NSLOG(netsurf, WARNING, "Unable to focus location
input");
+ }
+ }
+
return g;
}
commitdiff
http://git.netsurf-browser.org/netsurf.git/commit/?id=0fa5f81a52a62a04f4564d84e391543995cf9418
commit 0fa5f81a52a62a04f4564d84e391543995cf9418
Author: Daniel Silverstone <[email protected]>
Commit: Daniel Silverstone <[email protected]>
Browser: Support requesting location focus
In the creation of a browser window it may be valuable to request
that the GUI focus the location input box. This can be used when
the user requests a new tab/window to allow the entry box to be
focussed properly immediately.
Signed-off-by: Daniel Silverstone <[email protected]>
diff --git a/desktop/browser_window.c b/desktop/browser_window.c
index fcee085..2a3948f 100644
--- a/desktop/browser_window.c
+++ b/desktop/browser_window.c
@@ -3044,6 +3044,8 @@ browser_window_create(enum browser_window_create_flags
flags,
gw_flags |= GW_CREATE_CLONE;
if (flags & BW_CREATE_FOREGROUND)
gw_flags |= GW_CREATE_FOREGROUND;
+ if (flags & BW_CREATE_FOCUS_LOCATION)
+ gw_flags |= GW_CREATE_FOCUS_LOCATION;
ret->window = guit->window->create(ret,
(existing != NULL) ?
existing->window : NULL,
diff --git a/include/netsurf/browser_window.h b/include/netsurf/browser_window.h
index 75977ac..f8b86d0 100644
--- a/include/netsurf/browser_window.h
+++ b/include/netsurf/browser_window.h
@@ -112,6 +112,9 @@ enum browser_window_create_flags {
/** Request foreground opening. */
BW_CREATE_FOREGROUND = (1 << 4),
+
+ /** Request location bar focus. */
+ BW_CREATE_FOCUS_LOCATION = (1 << 5),
};
/** flags to browser_window_navigate */
diff --git a/include/netsurf/window.h b/include/netsurf/window.h
index a393a35..16fd95e 100644
--- a/include/netsurf/window.h
+++ b/include/netsurf/window.h
@@ -68,6 +68,7 @@ typedef enum {
GW_CREATE_CLONE = (1 << 0), /**< Clone existing window */
GW_CREATE_TAB = (1 << 1), /**< Create tab in same window as existing */
GW_CREATE_FOREGROUND = (1 << 2), /**< Request this window/tab is
foregrounded */
+ GW_CREATE_FOCUS_LOCATION = (1 << 3) , /** Request this window/tab
focusses the URL input */
} gui_window_create_flags;
/**
commitdiff
http://git.netsurf-browser.org/netsurf.git/commit/?id=5c377cd285536f4bec2a6cfb6352a45cfe6cb39e
commit 5c377cd285536f4bec2a6cfb6352a45cfe6cb39e
Author: Daniel Silverstone <[email protected]>
Commit: Daniel Silverstone <[email protected]>
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 <[email protected]>
diff --git a/frontends/gtk/scaffolding.c b/frontends/gtk/scaffolding.c
index 03d7160..0b3fe67 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 f191bc1..1a6bc12 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 39b7413..b47a1b0 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 728c653..b126a95 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
commitdiff
http://git.netsurf-browser.org/netsurf.git/commit/?id=f3bdee255d3c4252640b2337224e2f0b95944d7f
commit f3bdee255d3c4252640b2337224e2f0b95944d7f
Author: Daniel Silverstone <[email protected]>
Commit: Daniel Silverstone <[email protected]>
Browser: Add FOREGROUND flag to window creation
To better support new-tab / new-window operations as well as
GUIs which want to allow tabs to open in the background by default,
add a flag to request a new browser window be foregrounded. This
will allow us to simplify at least the GTK frontend a little.
Signed-off-by: Daniel Silverstone <[email protected]>
diff --git a/desktop/browser_window.c b/desktop/browser_window.c
index dea507f..fcee085 100644
--- a/desktop/browser_window.c
+++ b/desktop/browser_window.c
@@ -3042,6 +3042,8 @@ browser_window_create(enum browser_window_create_flags
flags,
gw_flags |= GW_CREATE_TAB;
if (flags & BW_CREATE_CLONE)
gw_flags |= GW_CREATE_CLONE;
+ if (flags & BW_CREATE_FOREGROUND)
+ gw_flags |= GW_CREATE_FOREGROUND;
ret->window = guit->window->create(ret,
(existing != NULL) ?
existing->window : NULL,
diff --git a/include/netsurf/browser_window.h b/include/netsurf/browser_window.h
index 98139aa..75977ac 100644
--- a/include/netsurf/browser_window.h
+++ b/include/netsurf/browser_window.h
@@ -109,6 +109,9 @@ enum browser_window_create_flags {
* have that option.
*/
BW_CREATE_UNVERIFIABLE = (1 << 3),
+
+ /** Request foreground opening. */
+ BW_CREATE_FOREGROUND = (1 << 4),
};
/** flags to browser_window_navigate */
diff --git a/include/netsurf/window.h b/include/netsurf/window.h
index 8f14a8c..a393a35 100644
--- a/include/netsurf/window.h
+++ b/include/netsurf/window.h
@@ -66,7 +66,8 @@ typedef enum {
typedef enum {
GW_CREATE_NONE = 0, /**< New window */
GW_CREATE_CLONE = (1 << 0), /**< Clone existing window */
- GW_CREATE_TAB = (1 << 1) /**< Create tab in same window as existing */
+ GW_CREATE_TAB = (1 << 1), /**< Create tab in same window as existing */
+ GW_CREATE_FOREGROUND = (1 << 2), /**< Request this window/tab is
foregrounded */
} gui_window_create_flags;
/**
commitdiff
http://git.netsurf-browser.org/netsurf.git/commit/?id=d25fada8cf820b8748a822b510b18f34f8a6ed30
commit d25fada8cf820b8748a822b510b18f34f8a6ed30
Author: Daniel Silverstone <[email protected]>
Commit: Daniel Silverstone <[email protected]>
gitignore: Ignore nsgtk2 properly
Signed-off-by: Daniel Silverstone <[email protected]>
diff --git a/.gitignore b/.gitignore
index 4e84e75..054455b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -9,7 +9,7 @@ frontends/riscos/appdir/Resources/nl/Templates,fec
resources/*/Messages
frontends/*/res/*/Messages
codedocs
-nsgtk
+nsgtk2
nsgtk3
nsfb
nsmonkey
-----------------------------------------------------------------------
Summary of changes:
.gitignore | 2 +-
desktop/browser_window.c | 4 +++
frontends/gtk/scaffolding.c | 4 ---
frontends/gtk/toolbar.c | 72 +++++++++++++++++++++++++++++++++++---
frontends/gtk/toolbar.h | 6 +++-
frontends/gtk/window.c | 35 +++++++++---------
frontends/gtk/window.h | 1 -
include/netsurf/browser_window.h | 6 ++++
include/netsurf/window.h | 4 ++-
9 files changed, 104 insertions(+), 30 deletions(-)
diff --git a/.gitignore b/.gitignore
index 4e84e75..054455b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -9,7 +9,7 @@ frontends/riscos/appdir/Resources/nl/Templates,fec
resources/*/Messages
frontends/*/res/*/Messages
codedocs
-nsgtk
+nsgtk2
nsgtk3
nsfb
nsmonkey
diff --git a/desktop/browser_window.c b/desktop/browser_window.c
index dea507f..2a3948f 100644
--- a/desktop/browser_window.c
+++ b/desktop/browser_window.c
@@ -3042,6 +3042,10 @@ browser_window_create(enum browser_window_create_flags
flags,
gw_flags |= GW_CREATE_TAB;
if (flags & BW_CREATE_CLONE)
gw_flags |= GW_CREATE_CLONE;
+ if (flags & BW_CREATE_FOREGROUND)
+ gw_flags |= GW_CREATE_FOREGROUND;
+ if (flags & BW_CREATE_FOCUS_LOCATION)
+ gw_flags |= GW_CREATE_FOCUS_LOCATION;
ret->window = guit->window->create(ret,
(existing != NULL) ?
existing->window : NULL,
diff --git a/frontends/gtk/scaffolding.c b/frontends/gtk/scaffolding.c
index 03d7160..0b3fe67 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 f191bc1..f2b1d05 100644
--- a/frontends/gtk/toolbar.c
+++ b/frontends/gtk/toolbar.c
@@ -144,6 +144,25 @@ struct nsgtk_toolbar_item {
void *dataminus;
};
+/**
+ * Location focus state machine
+ *
+ * 1. If we don't care, we're in LFS_IDLE
+ * 2. When we create a new toolbar, we can put it into
+ * LFS_WANT which means that we want the url bar to focus
+ * 3. When we start throbbing if we're in LFS_WANT we move to LFS_THROB
+ * 4. When we stop throbbing, if we're in LFS_THROB we move to LFS_LAST
+ *
+ * While not in LFS_IDLE, if the url bar is updated and we previously had it
+ * fully selected then we reselect it all. If we're in LFS_LAST we move to
+ * LFS_IDLE at that point.
+ */
+typedef enum {
+ LFS_IDLE, /**< Nothing to do */
+ LFS_WANT, /**< Want focus, will apply */
+ LFS_THROB, /**< Want focus, we have started throbbing */
+ LFS_LAST, /**< Last chance for a focus update */
+} nsgtk_toolbar_location_focus_state;
/**
* control toolbar context
@@ -182,6 +201,11 @@ struct nsgtk_toolbar {
* context passed to get_bw function
*/
void *get_ctx;
+
+ /**
+ * Location focus state machine, current state
+ */
+ nsgtk_toolbar_location_focus_state loc_focus;
};
@@ -926,7 +950,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 |
BW_CREATE_FOCUS_LOCATION;
if (intab) {
flags |= BW_CREATE_TAB;
@@ -1995,16 +2019,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) {
@@ -3418,6 +3440,7 @@ nserror
nsgtk_toolbar_create(GtkBuilder *builder,
struct browser_window *(*get_bw)(void *ctx),
void *get_ctx,
+ bool want_location_focus,
struct nsgtk_toolbar **tb_out)
{
nserror res;
@@ -3433,6 +3456,11 @@ nsgtk_toolbar_create(GtkBuilder *builder,
tb->get_ctx = get_ctx;
/* set the throbber start frame. */
tb->throb_frame = 0;
+ if (want_location_focus) {
+ tb->loc_focus = LFS_WANT;
+ } else {
+ tb->loc_focus = LFS_IDLE;
+ }
tb->widget = GTK_TOOLBAR(gtk_builder_get_object(builder, "toolbar"));
gtk_toolbar_set_show_arrow(tb->widget, TRUE);
@@ -3517,6 +3545,24 @@ nserror nsgtk_toolbar_throbber(struct nsgtk_toolbar *tb,
bool active)
nserror res;
struct browser_window *bw;
+ /* Manage the location focus state */
+ switch (tb->loc_focus) {
+ case LFS_IDLE:
+ break;
+ case LFS_WANT:
+ if (active) {
+ tb->loc_focus = LFS_THROB;
+ }
+ break;
+ case LFS_THROB:
+ if (!active) {
+ tb->loc_focus = LFS_LAST;
+ }
+ break;
+ case LFS_LAST:
+ break;
+ }
+
/* when activating the throbber simply schedule the next frame update */
if (active) {
nsgtk_schedule(THROBBER_FRAME_TIME, next_throbber_frame, tb);
@@ -3629,7 +3675,23 @@ nserror nsgtk_toolbar_set_url(struct nsgtk_toolbar *tb,
nsurl *url)
url_text = nsurl_access(url);
}
- gtk_entry_set_text(url_entry, url_text);
+ if (strcmp(url_text, gtk_entry_get_text(url_entry)) != 0) {
+ /* The URL bar content has changed, we need to update it */
+ gint startpos, endpos;
+ bool was_selected;
+ gtk_editable_get_selection_bounds(GTK_EDITABLE(url_entry),
+ &startpos, &endpos);
+ was_selected = gtk_widget_is_focus(GTK_WIDGET(url_entry)) &&
+ startpos == 0 &&
+ endpos == gtk_entry_get_text_length(url_entry);
+ gtk_entry_set_text(url_entry, url_text);
+ if (was_selected && tb->loc_focus != LFS_IDLE) {
+ gtk_widget_grab_focus(GTK_WIDGET(url_entry));
+ if (tb->loc_focus == LFS_LAST) {
+ tb->loc_focus = LFS_IDLE;
+ }
+ }
+ }
if (idn_url_s != NULL) {
free(idn_url_s);
diff --git a/frontends/gtk/toolbar.h b/frontends/gtk/toolbar.h
index 9bb859b..77c3bcd 100644
--- a/frontends/gtk/toolbar.h
+++ b/frontends/gtk/toolbar.h
@@ -32,7 +32,11 @@ struct nsgtk_scaffolding;
* \param[out] toolbar a pointer to receive the result.
* \return NSERROR_OK and toolbar updated on success else error code
*/
-nserror nsgtk_toolbar_create(GtkBuilder *builder, struct browser_window
*(*get_bw)(void *ctx), void *get_bw_ctx,struct nsgtk_toolbar **toolbar);
+nserror nsgtk_toolbar_create(GtkBuilder *builder,
+ struct browser_window *(*get_bw)(void *ctx),
+ void *get_bw_ctx,
+ bool want_location_focus,
+ struct nsgtk_toolbar **toolbar);
/**
diff --git a/frontends/gtk/window.c b/frontends/gtk/window.c
index 39b7413..925c378 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);
@@ -861,7 +862,9 @@ gui_window_create(struct browser_window *bw,
/* create toolbar */
- res = nsgtk_toolbar_create(tab_builder, bw_from_gw, g, &g->toolbar);
+ res = nsgtk_toolbar_create(tab_builder, bw_from_gw, g,
+ !!(flags & GW_CREATE_FOCUS_LOCATION),
+ &g->toolbar);
if (res != NSERROR_OK) {
free(g);
g_object_unref(tab_builder);
@@ -953,18 +956,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);
@@ -977,6 +971,13 @@ gui_window_create(struct browser_window *bw,
*/
g_object_unref(tab_builder);
+ /* Finally we need to focus the location bar if requested */
+ if (flags & GW_CREATE_FOCUS_LOCATION) {
+ if (nsgtk_window_item_activate(g, OPENLOCATION_BUTTON) !=
NSERROR_OK) {
+ NSLOG(netsurf, WARNING, "Unable to focus location
input");
+ }
+ }
+
return g;
}
diff --git a/frontends/gtk/window.h b/frontends/gtk/window.h
index 728c653..b126a95 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
diff --git a/include/netsurf/browser_window.h b/include/netsurf/browser_window.h
index 98139aa..f8b86d0 100644
--- a/include/netsurf/browser_window.h
+++ b/include/netsurf/browser_window.h
@@ -109,6 +109,12 @@ enum browser_window_create_flags {
* have that option.
*/
BW_CREATE_UNVERIFIABLE = (1 << 3),
+
+ /** Request foreground opening. */
+ BW_CREATE_FOREGROUND = (1 << 4),
+
+ /** Request location bar focus. */
+ BW_CREATE_FOCUS_LOCATION = (1 << 5),
};
/** flags to browser_window_navigate */
diff --git a/include/netsurf/window.h b/include/netsurf/window.h
index 8f14a8c..16fd95e 100644
--- a/include/netsurf/window.h
+++ b/include/netsurf/window.h
@@ -66,7 +66,9 @@ typedef enum {
typedef enum {
GW_CREATE_NONE = 0, /**< New window */
GW_CREATE_CLONE = (1 << 0), /**< Clone existing window */
- GW_CREATE_TAB = (1 << 1) /**< Create tab in same window as existing */
+ GW_CREATE_TAB = (1 << 1), /**< Create tab in same window as existing */
+ GW_CREATE_FOREGROUND = (1 << 2), /**< Request this window/tab is
foregrounded */
+ GW_CREATE_FOCUS_LOCATION = (1 << 3) , /** Request this window/tab
focusses the URL input */
} gui_window_create_flags;
/**
--
NetSurf Browser
_______________________________________________
netsurf-commits mailing list
[email protected]
http://listmaster.pepperfish.net/cgi-bin/mailman/listinfo/netsurf-commits-netsurf-browser.org