summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/dwb.116
-rw-r--r--doc/dwb.1.txt6
-rw-r--r--src/config.h4
-rw-r--r--src/dwb.c14
-rw-r--r--src/dwb.h8
-rw-r--r--src/view.c7
-rw-r--r--util/settings.pre2
7 files changed, 39 insertions, 18 deletions
diff --git a/doc/dwb.1 b/doc/dwb.1
index e2cfc487..aab02bf5 100644
--- a/doc/dwb.1
+++ b/doc/dwb.1
@@ -2,12 +2,12 @@
.\" Title: dwb
.\" Author: [FIXME: author] [see http://docbook.sf.net/el/author]
.\" Generator: DocBook XSL Stylesheets v1.77.1 <http://docbook.sf.net/>
-.\" Date: 07/26/2012
+.\" Date: 07/28/2012
.\" Manual: \ \&
.\" Source: \ \&
.\" Language: English
.\"
-.TH "DWB" "1" "07/26/2012" "\ \&" "\ \&"
+.TH "DWB" "1" "07/28/2012" "\ \&" "\ \&"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
@@ -3047,12 +3047,14 @@ and
\fIwebbrowser\fR\&.
.RE
.PP
-\fBclose\-last\-tab\fR
+\fBclose\-last\-tab\-policy\fR
.RS 4
-Whether to close the last tab if
-\fIclose_tab\fR
-is called, if set to true the last tab\(cqs history is cleared and the window is closed; default value:
-\fIfalse\fR\&.
+Behaviour when the last tab is closed, possible values are
+\fIignore\fR,
+\fIclear\fR
+and
+\fIclose\fR; default value:
+\fIignore\fR\&.
.RE
.PP
\fBclose\-tab\-focus\-policy\fR
diff --git a/doc/dwb.1.txt b/doc/dwb.1.txt
index 80c34e81..1ace0ef1 100644
--- a/doc/dwb.1.txt
+++ b/doc/dwb.1.txt
@@ -1196,9 +1196,9 @@ The cache model used by webkit, possible values are 'webbrowser' and
usage, documentviewer reduces memory usage but also decreases browsing speed.
Default Value: 'webbrowser'.
-*close-last-tab*::
-Whether to close the last tab if 'close_tab' is called, if set to true the last
-tab's history is cleared and the window is closed; default value: 'false'.
+*close-last-tab-policy*::
+Behaviour when the last tab is closed, possible values are 'ignore', 'clear' and
+'close'; default value: 'ignore'.
*close-tab-focus-policy*::
Controls the focus when the focused tab is closed, possible values are 'right',
diff --git a/src/config.h b/src/config.h
index 2911d204..a3444ba4 100644
--- a/src/config.h
+++ b/src/config.h
@@ -1134,8 +1134,8 @@ static WebSettings DWB_SETTINGS[] = {
SETTING_GLOBAL | SETTING_ONINIT, CHAR, { .p = "right", .n = CLOSE_TAB_POSITION_MASK, .i = 0 }, (S_Func)dwb_set_new_tab_position_policy, { 0 }, },
{ { "close-tab-focus-policy", "Number of seconds the tabbar is shown when switching tabs", },
SETTING_GLOBAL | SETTING_ONINIT, CHAR, { .p = "left" }, (S_Func)dwb_set_close_tab_position_policy, { 0 }, },
- { { "close-last-tab", "Whether close_tab closes the last tab", },
- SETTING_GLOBAL, BOOLEAN, { .b = false }, NULL, { 0 }, },
+ { { "close-last-tab-policy", "Behaviour when the last tab is closed", },
+ SETTING_GLOBAL | SETTING_ONINIT, CHAR, { .p = "ignore" }, (S_Func)dwb_set_close_last_tab_policy, { 0 }, },
{ { "bars-padding", "Padding of the status, download, completion and tab bars", },
SETTING_GLOBAL, INTEGER, { .i = 0 }, NULL, { 0 }, },
{ { "searchengine-submit-pattern", "The pattern which will be replaced with the search terms", },
diff --git a/src/dwb.c b/src/dwb.c
index 3a22c1be..3bef44cc 100644
--- a/src/dwb.c
+++ b/src/dwb.c
@@ -69,6 +69,7 @@ static DwbStatus dwb_set_cookie_accept_policy(GList *, WebSettings *);
static DwbStatus dwb_set_favicon(GList *, WebSettings *);
static DwbStatus dwb_set_auto_insert_mode(GList *, WebSettings *);
static DwbStatus dwb_set_tabbar_delay(GList *, WebSettings *);
+static DwbStatus dwb_set_close_last_tab_policy(GList *, WebSettings *);
static DwbStatus dwb_set_ntlm(GList *gl, WebSettings *s);
static DwbStatus dwb_set_find_delay(GList *gl, WebSettings *s);
static DwbStatus dwb_set_do_not_track(GList *gl, WebSettings *s);
@@ -179,7 +180,18 @@ dwb_set_do_not_track(GList *gl, WebSettings *s) {
return STATUS_OK;
}/*}}}*/
-
+static DwbStatus
+dwb_set_close_last_tab_policy(GList *gl, WebSettings *s) {
+ if (!g_strcmp0("clear", s->arg_local.p))
+ dwb.misc.clt_policy = CLT_POLICY_CLEAR;
+ else if (!g_strcmp0("close", s->arg_local.p))
+ dwb.misc.clt_policy = CLT_POLICY_CLOSE;
+ else if (!g_strcmp0("ignore", s->arg_local.p))
+ dwb.misc.clt_policy = CLT_POLICY_INGORE;
+ else
+ return STATUS_ERROR;
+ return STATUS_OK;
+}
static DwbStatus
dwb_set_ntlm(GList *gl, WebSettings *s) {
diff --git a/src/dwb.h b/src/dwb.h
index 1f2796ff..b03cd2ec 100644
--- a/src/dwb.h
+++ b/src/dwb.h
@@ -388,6 +388,12 @@ enum {
} ClipboardAction;
typedef enum {
+ CLT_POLICY_INGORE,
+ CLT_POLICY_CLEAR,
+ CLT_POLICY_CLOSE,
+} CloseLastTabPolicy;
+
+typedef enum {
COOKIE_STORE_SESSION,
COOKIE_STORE_PERSISTENT,
COOKIE_STORE_NEVER,
@@ -745,7 +751,7 @@ struct _Misc {
TabPosition tab_position;
char *hint_style;
int script_signals;
-
+ CloseLastTabPolicy clt_policy;
};
enum Files {
FILES_FIRST = 0,
diff --git a/src/view.c b/src/view.c
index b20a52e9..8156ae14 100644
--- a/src/view.c
+++ b/src/view.c
@@ -1037,13 +1037,14 @@ view_clean(GList *gl) {
DwbStatus
view_remove(GList *gl) {
if (!dwb.state.views->next) {
- if (GET_BOOL("close-last-tab")) {
+ if (dwb.misc.clt_policy == CLT_POLICY_CLOSE) {
view_clear_tab(dwb.state.fview);
dwb_end();
return STATUS_END;
}
- else
- return STATUS_OK;
+ if (dwb.misc.clt_policy == CLT_POLICY_CLEAR)
+ view_clear_tab(dwb.state.fview);
+ return STATUS_OK;
}
if (dwb.state.nummod >= 0) {
gl = g_list_nth(dwb.state.views, dwb.state.nummod - 1);
diff --git a/util/settings.pre b/util/settings.pre
index 74b7df45..60e4b1f2 100644
--- a/util/settings.pre
+++ b/util/settings.pre
@@ -122,7 +122,7 @@ complete-userscripts checkbox Whether to enable tabcompletion for userscripts
# misc Miscellaneous
auto-insert-mode checkbox Whether to automatically go in insert mode if an editable element has focus after loading
cache-model select @webbrowser @documentviewer The cache-model used by webkit
-close-last-tab checkbox Whether to close the window if the last tab is closed
+close-last-tab-policy select @ignore @clear @close Behaviour when the last tab is closed
custom-encoding text The custom encoding of the view
download-external-command text External application used for downloads
download-directory text Default download directory