summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorportix <none@none>2012-09-17 21:16:40 +0200
committerportix <none@none>2012-09-17 21:16:40 +0200
commit3e6ba3478f1200df7d7cd5ccd57728e3f5122be9 (patch)
treef59d35a3e7d922b0e11496f21434b0f2a3954214 /src
parent39bf9b69013e2bf04564f1ab8dc6c46511534c77 (diff)
downloaddwb-3e6ba3478f1200df7d7cd5ccd57728e3f5122be9.zip
New option show-single-tab
Diffstat (limited to 'src')
-rw-r--r--src/commands.c2
-rw-r--r--src/config.h2
-rw-r--r--src/dwb.c16
-rw-r--r--src/dwb.h1
-rw-r--r--src/view.c14
5 files changed, 32 insertions, 3 deletions
diff --git a/src/commands.c b/src/commands.c
index da2645da..5e85035c 100644
--- a/src/commands.c
+++ b/src/commands.c
@@ -679,7 +679,7 @@ commands_only(KeyMap *km, Arg *arg) {
}/*}}}*/
static void
commands_set_bars(int status) {
- gtk_widget_set_visible(dwb.gui.topbox, status & BAR_VIS_TOP);
+ gtk_widget_set_visible(dwb.gui.topbox, (status & BAR_VIS_TOP) && (GET_BOOL("show-single-tab") || dwb.state.views->next));
gtk_widget_set_visible(dwb.gui.bottombox, status & BAR_VIS_STATUS);
if ((status & BAR_VIS_STATUS) ) {
dwb_dom_remove_from_parent(WEBKIT_DOM_NODE(CURRENT_VIEW()->hover.element), NULL);
diff --git a/src/config.h b/src/config.h
index 7ce5e77c..ed1c098f 100644
--- a/src/config.h
+++ b/src/config.h
@@ -1165,4 +1165,6 @@ static WebSettings DWB_SETTINGS[] = {
SETTING_GLOBAL, INTEGER, { .i = 0 }, NULL, { 0 }, },
{ { "searchengine-submit-pattern", "The pattern which will be replaced with the search terms", },
SETTING_GLOBAL, CHAR, { .p = NULL }, NULL, { 0 }, },
+ { { "show-single-tab", "Whether to show tabbar if only on tab is opened", },
+ SETTING_GLOBAL | SETTING_ONINIT, BOOLEAN, { .b = true }, (S_Func)dwb_set_show_single_tab, { 0 }, },
};/*}}}*/
diff --git a/src/dwb.c b/src/dwb.c
index 3cb62475..d1689157 100644
--- a/src/dwb.c
+++ b/src/dwb.c
@@ -75,6 +75,7 @@ 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);
+static DwbStatus dwb_set_show_single_tab(GList *gl, WebSettings *s);
#ifdef WITH_LIBSOUP_2_38
static DwbStatus dwb_set_dns_lookup(GList *gl, WebSettings *s);
#endif
@@ -182,6 +183,21 @@ dwb_set_do_not_track(GList *gl, WebSettings *s) {
return STATUS_OK;
}/*}}}*/
+/* dwb_set_cookies {{{ */
+static DwbStatus
+dwb_set_show_single_tab(GList *gl, WebSettings *s) {
+ dwb.misc.show_single_tab = s->arg_local.b;
+ if (dwb.state.views) {
+ if (!dwb.state.views->next) {
+ if (!dwb.misc.show_single_tab)
+ gtk_widget_hide(dwb.gui.topbox);
+ else if (dwb.state.bar_visible & BAR_VIS_TOP)
+ gtk_widget_show(dwb.gui.topbox);
+ }
+ }
+ return STATUS_OK;
+}/*}}}*/
+
static DwbStatus
dwb_set_close_last_tab_policy(GList *gl, WebSettings *s) {
if (!g_strcmp0("clear", s->arg_local.p))
diff --git a/src/dwb.h b/src/dwb.h
index 73de9464..e364803c 100644
--- a/src/dwb.h
+++ b/src/dwb.h
@@ -759,6 +759,7 @@ struct _Misc {
gboolean tabbed_browsing;
gboolean private_browsing;
+ gboolean show_single_tab;
double scroll_step;
diff --git a/src/view.c b/src/view.c
index 5a0f31f3..78e228bd 100644
--- a/src/view.c
+++ b/src/view.c
@@ -1131,6 +1131,8 @@ view_remove(GList *gl) {
dwb_source_remove();
dwb.state.views = g_list_delete_link(dwb.state.views, gl);
+ if (!dwb.state.views->next && !dwb.misc.show_single_tab)
+ gtk_widget_hide(dwb.gui.topbox);
gtk_widget_show(CURRENT_VIEW()->scroll);
dwb_update_layout();
@@ -1169,10 +1171,11 @@ view_add(const char *uri, gboolean background) {
}
View *v = view_create_web_view();
gtk_box_pack_end(GTK_BOX(dwb.gui.topbox), v->tabevent, true, true, 0);
+ int length = g_list_length(dwb.state.views);
if (dwb.state.fview) {
int p;
if (dwb.misc.tab_position & TAB_POSITION_RIGHTMOST)
- p = g_list_length(dwb.state.views);
+ p = length;
else if (dwb.misc.tab_position & TAB_POSITION_LEFT)
p = g_list_position(dwb.state.views, dwb.state.fview);
else if (dwb.misc.tab_position & TAB_POSITION_LEFTMOST)
@@ -1180,7 +1183,7 @@ view_add(const char *uri, gboolean background) {
else
p = g_list_position(dwb.state.views, dwb.state.fview) + 1;
- gtk_box_reorder_child(GTK_BOX(dwb.gui.topbox), v->tabevent, g_list_length(dwb.state.views) - p);
+ gtk_box_reorder_child(GTK_BOX(dwb.gui.topbox), v->tabevent, length - p);
gtk_box_insert(GTK_BOX(dwb.gui.mainbox), v->scroll, true, true, 0, p, GTK_PACK_START);
dwb.state.views = g_list_insert(dwb.state.views, v, p);
ret = g_list_nth(dwb.state.views, p);
@@ -1204,6 +1207,13 @@ view_add(const char *uri, gboolean background) {
scripts_create_tab(ret);
dwb_focus(ret);
}
+ if (!dwb.misc.show_single_tab) {
+ if (length == 0) {
+ gtk_widget_hide(dwb.gui.topbox);
+ }
+ else if (length == 1 && (dwb.state.bar_visible & BAR_VIS_TOP))
+ gtk_widget_show(dwb.gui.topbox);
+ }
view_init_signals(ret);
view_init_settings(ret);