summaryrefslogtreecommitdiff
path: root/src/view.c
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/view.c
parent39bf9b69013e2bf04564f1ab8dc6c46511534c77 (diff)
downloaddwb-3e6ba3478f1200df7d7cd5ccd57728e3f5122be9.zip
New option show-single-tab
Diffstat (limited to 'src/view.c')
-rw-r--r--src/view.c14
1 files changed, 12 insertions, 2 deletions
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);