summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorportix <none@none>2012-12-26 02:20:16 +0100
committerportix <none@none>2012-12-26 02:20:16 +0100
commit2fbdba9c84bdaaeb5640c245d9228df6411c8929 (patch)
tree0f26a654556d6c1577ba429a5ea8c0b165c3fa52 /src
parent7f198e7deff463210ed44251fc03c449261f2002 (diff)
downloaddwb-2fbdba9c84bdaaeb5640c245d9228df6411c8929.zip
New option 'load-on-focus'
Diffstat (limited to 'src')
-rw-r--r--src/completion.c16
-rw-r--r--src/config.h2
-rw-r--r--src/dwb.c15
-rw-r--r--src/dwb.h2
-rw-r--r--src/view.c23
5 files changed, 50 insertions, 8 deletions
diff --git a/src/completion.c b/src/completion.c
index 41159758..7c0f2482 100644
--- a/src/completion.c
+++ b/src/completion.c
@@ -557,10 +557,18 @@ completion_complete_buffer()
format = g_list_length(dwb.state.views) > 10 ? "%02d : %s" : "%d : %s";
for (GList *l = dwb.state.views;l; l=l->next)
{
- wv = WEBVIEW(l);
- title = webkit_web_view_get_title(wv);
- uri = webkit_web_view_get_uri(wv);
- text = g_strdup_printf(format, i, title != NULL ? title : uri);
+ if (VIEW(l)->status->deferred)
+ {
+ text = g_strdup_printf(format, i, VIEW(l)->status->deferred_uri);
+ uri = "deferred";
+ }
+ else
+ {
+ wv = WEBVIEW(l);
+ title = webkit_web_view_get_title(wv);
+ uri = webkit_web_view_get_uri(wv);
+ text = g_strdup_printf(format, i, title != NULL ? title : uri);
+ }
c = completion_get_completion_item(text, uri, NULL, l);
gtk_box_pack_start(GTK_BOX(dwb.gui.compbox), c->event, false, false, 0);
diff --git a/src/config.h b/src/config.h
index a473080e..36db4718 100644
--- a/src/config.h
+++ b/src/config.h
@@ -1181,4 +1181,6 @@ static WebSettings DWB_SETTINGS[] = {
SETTING_GLOBAL | SETTING_ONINIT, BOOLEAN, { .b = true }, (S_Func)dwb_set_show_single_tab, { 0 }, },
{ { "hints-key-lock", "Timeout keypresses are ignored after following a hint", },
SETTING_GLOBAL, INTEGER, { .i = 250 }, NULL, { 0 }, },
+ { { "load-on-focus", "Load uris at the earliest when a tab gets focus", },
+ SETTING_GLOBAL, BOOLEAN, { .b = false }, NULL, { 0 }, },
};/*}}}*/
diff --git a/src/dwb.c b/src/dwb.c
index 8275f96a..2d2dce74 100644
--- a/src/dwb.c
+++ b/src/dwb.c
@@ -2504,9 +2504,13 @@ dwb_update_layout()
{
for (GList *gl = dwb.state.views; gl; gl = gl->next)
{
- View *v = gl->data;
- const char *title = webkit_web_view_get_title(WEBKIT_WEB_VIEW(v->web));
- dwb_tab_label_set_text(gl, title);
+ if (!VIEW(gl)->status->deferred)
+ {
+ View *v = gl->data;
+ const char *title = webkit_web_view_get_title(WEBKIT_WEB_VIEW(v->web));
+ dwb_tab_label_set_text(gl, title);
+ }
+
}
dwb_update_tabs();
}/*}}}*/
@@ -2521,7 +2525,10 @@ dwb_focus(GList *gl)
dwb.state.fview = gl;
view_set_active_style(gl);
dwb_focus_scroll(gl);
- dwb_update_status(gl, NULL);
+ if (!VIEW(gl)->status->deferred)
+ dwb_update_status(gl, NULL);
+ else if (VIEW(gl)->status->deferred_uri)
+ webkit_web_view_load_uri(WEBVIEW(gl), VIEW(gl)->status->deferred_uri);
}/*}}}*/
/* dwb_new_window(const char *arg) {{{*/
diff --git a/src/dwb.h b/src/dwb.h
index 10a9495f..059dcfef 100644
--- a/src/dwb.h
+++ b/src/dwb.h
@@ -654,6 +654,8 @@ struct _ViewStatus {
GSList *frames;
WebKitDOMElement *exc_style;
guint group;
+ gboolean deferred;
+ char *deferred_uri;
};
struct _View {
GtkWidget *web;
diff --git a/src/view.c b/src/view.c
index 1b6f8703..29db6b7c 100644
--- a/src/view.c
+++ b/src/view.c
@@ -484,6 +484,26 @@ view_navigation_policy_cb(WebKitWebView *web, WebKitWebFrame *frame, WebKitNetwo
return true;
}
}
+ if (VIEW(gl)->status->deferred)
+ {
+ if (gl != dwb.state.fview)
+ {
+ char buffer[128];
+ const char *stripped;
+
+ VIEW(gl)->status->deferred_uri = g_strdup(uri);
+
+ stripped = strstr(uri, "://");
+ snprintf(buffer, sizeof(buffer), "*%s", stripped ? stripped + 3 : uri);
+
+ dwb_tab_label_set_text(gl, buffer);
+ webkit_web_policy_decision_ignore(policy);
+ return true;
+ }
+ else
+ VIEW(gl)->status->deferred = false;
+ }
+
/* Check if tab is locked */
if (LP_LOCKED_URI(VIEW(gl)))
@@ -1037,6 +1057,8 @@ view_create_web_view()
status->lockprotect = 0;
status->frames = NULL;
status->group = 0;
+ status->deferred = GET_BOOL("load-on-focus");
+ status->deferred_uri = NULL;
v->js_base = NULL;
v->inspector_window = NULL;
@@ -1184,6 +1206,7 @@ view_clean(GList *gl)
gtk_widget_destroy(v->web);
gtk_widget_destroy(v->scroll);
+ FREE0(v->status->deferred_uri);
FREE0(v->status->hover_uri);
#ifdef WITH_LIBSOUP_2_38
FREE0(v->status->request_uri);