summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/dwb.112
-rw-r--r--src/commands.c36
-rw-r--r--src/commands.h2
-rw-r--r--src/config.h12
-rw-r--r--src/dwb.c14
-rw-r--r--src/dwb.h7
-rw-r--r--src/view.c11
-rw-r--r--util/keys.in4
8 files changed, 93 insertions, 5 deletions
diff --git a/doc/dwb.1 b/doc/dwb.1
index bdae1ba4..34a41863 100644
--- a/doc/dwb.1
+++ b/doc/dwb.1
@@ -421,6 +421,18 @@ Toggle hidden files when browsing local filesystem.
.BR C-F11
Toggle fullscreen.
.TP
+.BR C-F12
+Toggle presentation mode.
+.TP
+.BR xx
+Toggle visibility of tabbar and statusbar.
+.TP
+.BR xt
+Toggle visibility of tabbar.
+.TP
+.BR xb
+Toggle visibility of statusbar.
+.TP
.BR C-M-p
Print focused frame.
.TP
diff --git a/src/commands.c b/src/commands.c
index 336ac532..d3eb1d29 100644
--- a/src/commands.c
+++ b/src/commands.c
@@ -449,13 +449,29 @@ commands_push_master(KeyMap *km, Arg *arg) {
return view_push_master(arg);
}/*}}}*/
+static gboolean
+commands_hide_tabbar(int *running) {
+ if (! (dwb.state.bar_visible & BAR_VIS_TOP)) {
+ gtk_widget_hide(dwb.gui.topbox);
+ }
+ *running = 0;
+ return false;
+}
+
/* commands_focus(KeyMap *km, Arg *arg) {{{*/
DwbStatus
commands_focus(KeyMap *km, Arg *arg) {
+ static int running;
if (dwb.state.views->next) {
int pos = modulo(g_list_position(dwb.state.views, dwb.state.fview) + NUMMOD * arg->n, g_list_length(dwb.state.views));
GList *g = g_list_nth(dwb.state.views, pos);
dwb_focus_view(g);
+ if (! (dwb.state.bar_visible & BAR_VIS_TOP)) {
+ gtk_widget_show(dwb.gui.topbox);
+ if (running != 0)
+ g_source_remove(running);
+ running = g_timeout_add(2000, (GSourceFunc)commands_hide_tabbar, &running);
+ }
return STATUS_OK;
}
return STATUS_ERROR;
@@ -842,4 +858,24 @@ commands_only(KeyMap *km, Arg *arg) {
}
return ret;
}/*}}}*/
+/* commands_toggle_bars {{{*/
+DwbStatus
+commands_toggle_bars(KeyMap *km, Arg *arg) {
+ dwb.state.bar_visible ^= arg->n;
+ if (dwb.state.tabbar_visible != HIDE_TB_ALWAYS && (dwb.state.tabbar_visible == HIDE_TB_NEVER || (HIDE_TB_TILED && (dwb.state.layout & MAXIMIZED)))) {
+ gtk_widget_set_visible(dwb.gui.topbox, dwb.state.bar_visible & BAR_VIS_TOP);
+ }
+ for (GList *l = dwb.state.views; l; l=l->next) {
+ gtk_widget_set_visible(VIEW(l)->statusbox, dwb.state.bar_visible & BAR_VIS_STATUS);
+ }
+ return STATUS_OK;
+}/*}}}*/
+DwbStatus
+commands_presentation_mode(KeyMap *km, Arg *arg) {
+ if (! dwb.state.fullscreen)
+ dwb.state.bar_visible = BAR_VIS_TOP | BAR_VIS_STATUS;
+ commands_fullscreen(km, arg);
+ commands_toggle_bars(km, arg);
+ return STATUS_OK;
+}
/*}}}*/
diff --git a/src/commands.h b/src/commands.h
index 3400a3db..5452d7fe 100644
--- a/src/commands.h
+++ b/src/commands.h
@@ -93,5 +93,7 @@ DwbStatus commands_open_editor(KeyMap *, Arg *);
DwbStatus commands_insert_mode(KeyMap *, Arg *);
DwbStatus commands_command_mode(KeyMap *, Arg *);
DwbStatus commands_only(KeyMap *, Arg *);
+DwbStatus commands_toggle_bars(KeyMap *, Arg *);
+DwbStatus commands_presentation_mode(KeyMap *, Arg *);
#endif
diff --git a/src/config.h b/src/config.h
index e31722a6..531e9d0f 100644
--- a/src/config.h
+++ b/src/config.h
@@ -153,12 +153,24 @@ static KeyValue KEYS[] = {
{ "fullscreen", { "F11", GDK_CONTROL_MASK }, },
{ "pass_through", { "i", GDK_CONTROL_MASK }, },
{ "open_editor", { "e", GDK_CONTROL_MASK }, },
+ { "toggle_bars", { "xx", 0 }, },
+ { "toggle_topbar", { "xt", 0 }, },
+ { "toggle_bottombar", { "xb", 0 }, },
+ { "presentation_mode", { "F12", GDK_CONTROL_MASK }, },
};
/* FUNCTION_MAP{{{*/
static FunctionMap FMAP [] = {
{ { "add_view", "Add a new view", }, 1,
(Func)commands_add_view, NULL, ALWAYS_SM, { .p = NULL }, },
+ { { "toggle_bars", "Toggle visibility of status and tabbar" }, 1,
+ (Func) commands_toggle_bars, NULL, ALWAYS_SM, { .n = BAR_VIS_STATUS | BAR_VIS_TOP } },
+ { { "toggle_topbar", "Toggle visibility of tabbar" }, 1,
+ (Func) commands_toggle_bars, NULL, ALWAYS_SM, { .n = BAR_VIS_TOP } },
+ { { "toggle_bottombar", "Toggle visibility of statusbar" }, 1,
+ (Func) commands_toggle_bars, NULL, ALWAYS_SM, { .n = BAR_VIS_STATUS } },
+ { { "presentation_mode", "Toggle presentation mode" }, 1,
+ (Func) commands_presentation_mode, NULL, ALWAYS_SM, { .n = BAR_VIS_STATUS | BAR_VIS_TOP } },
{ { "allow_cookie", "Cookie allowed", }, 1,
(Func)commands_allow_cookie, "No new domain in current context", POST_SM, },
{ { "bookmark", "Bookmark current page", }, 1,
diff --git a/src/dwb.c b/src/dwb.c
index c68271d3..bda273b1 100644
--- a/src/dwb.c
+++ b/src/dwb.c
@@ -1056,8 +1056,10 @@ dwb_eval_tabbar_visible(const char *arg) {
/* dwb_toggle_tabbar() {{{*/
void
dwb_toggle_tabbar(void) {
+ if (! (dwb.state.bar_visible & BAR_VIS_TOP))
+ return;
gboolean visible = gtk_widget_get_visible(dwb.gui.topbox);
- if (visible ) {
+ if (visible) {
if (dwb.state.tabbar_visible != HIDE_TB_NEVER &&
(dwb.state.tabbar_visible == HIDE_TB_ALWAYS || (HIDE_TB_TILED && !(dwb.state.layout & MAXIMIZED)))) {
gtk_widget_hide(dwb.gui.topbox);
@@ -1172,6 +1174,10 @@ dwb_entry_set_text(const char *text) {
/* dwb_focus_entry() {{{*/
void
dwb_focus_entry() {
+ if (! (dwb.state.bar_visible & BAR_VIS_STATUS)) {
+ gtk_widget_show(CURRENT_VIEW()->statusbox);
+ gtk_widget_set_size_request(dwb.gui.entry, -1, dwb.misc.bar_height);
+ }
gtk_widget_show(dwb.gui.entry);
gtk_widget_grab_focus(dwb.gui.entry);
gtk_widget_set_can_focus(CURRENT_WEBVIEW_WIDGET(), false);
@@ -1183,7 +1189,10 @@ void
dwb_focus_scroll(GList *gl) {
if (gl == NULL)
return;
+
View *v = gl->data;
+ if (! (dwb.state.bar_visible & BAR_VIS_STATUS))
+ gtk_widget_hide(v->statusbox);
gtk_widget_set_can_focus(v->web, true);
gtk_widget_grab_focus(v->web);
gtk_widget_hide(dwb.gui.entry);
@@ -2944,6 +2953,8 @@ dwb_init() {
dwb.state.last_cookies = NULL;
dwb.state.fullscreen = false;
+ dwb.state.bar_visible = BAR_VIS_TOP | BAR_VIS_STATUS;
+
dwb.comps.completions = NULL;
dwb.comps.active_comp = NULL;
dwb.comps.view = NULL;
@@ -2953,6 +2964,7 @@ dwb_init() {
dwb.misc.proxyuri = NULL;
dwb.misc.scripts = NULL;
dwb.misc.synctimer = 0;
+ dwb.misc.bar_height = 0;
char *path = util_get_data_file(PLUGIN_FILE);
if (path) {
diff --git a/src/dwb.h b/src/dwb.h
index 229de5f7..586494e9 100644
--- a/src/dwb.h
+++ b/src/dwb.h
@@ -125,6 +125,7 @@
#define VIEW_FROM_ARG(X) (X && X->p ? ((GSList*)X->p)->data : dwb.state.fview->data)
#define WEBVIEW_FROM_ARG(arg) (WEBKIT_WEB_VIEW(((View*)(arg && arg->p ? ((GSList*)arg->p)->data : dwb.state.fview->data))->web))
#define CLEAR_COMMAND_TEXT(X) dwb_set_status_bar_text(VIEW(X)->lstatus, NULL, NULL, NULL, false)
+#define BOOLEAN(X) (!(!(X)))
#define CURRENT_URL() webkit_web_view_get_uri(CURRENT_WEBVIEW())
@@ -241,6 +242,10 @@ typedef enum {
HIDE_TB_ALWAYS = 0x03,
HIDE_TB_TILED = 0x05,
} TabBarVisible;
+typedef enum {
+ BAR_VIS_TOP = 1<<0,
+ BAR_VIS_STATUS = 1<<1,
+} BarVisibility;
typedef enum {
NORMAL_MODE = 1<<0,
@@ -490,6 +495,7 @@ struct _State {
TabBarVisible tabbar_visible;
gboolean fullscreen;
+ BarVisibility bar_visible;
};
typedef enum _SettingsApply {
@@ -623,6 +629,7 @@ struct _Misc {
char *pbbackground;
gboolean top_statusbar;
+ int bar_height;
int synctimer;
};
struct _Files {
diff --git a/src/view.c b/src/view.c
index 2361b829..1e6903d8 100644
--- a/src/view.c
+++ b/src/view.c
@@ -591,6 +591,7 @@ view_load_error_cb(WebKitWebView *web, WebKitWebFrame *frame, char *uri, GError
/* view_entry_size_allocate_cb {{{*/
void
view_entry_size_allocate_cb(GtkWidget *entry, GdkRectangle *rect, View *v) {
+ dwb.misc.bar_height = rect->height;
gtk_widget_set_size_request(v->entry, -1, rect->height);
g_signal_handlers_disconnect_by_func(entry, view_entry_size_allocate_cb, v);
}/*}}}*/
@@ -932,7 +933,10 @@ view_create_web_view() {
gtk_widget_show(v->bottombox);
gtk_widget_show_all(v->scroll);
gtk_widget_show_all(v->tabevent);
- g_signal_connect(v->bottombox, "size-allocate", G_CALLBACK(view_entry_size_allocate_cb), v);
+ if (dwb.misc.bar_height != 0)
+ gtk_widget_set_size_request(v->entry, -1, dwb.misc.bar_height);
+ else
+ g_signal_connect(v->bottombox, "size-allocate", G_CALLBACK(view_entry_size_allocate_cb), v);
return v;
} /*}}}*/
@@ -1004,7 +1008,8 @@ view_remove(GList *g) {
if (gl == dwb.state.fview) {
if ( !(dwb.state.fview = dwb.state.fview->prev) ) {
dwb.state.fview = g_list_first(dwb.state.views)->next;
- gtk_widget_show_all(dwb.gui.topbox);
+ if (dwb.state.bar_visible & BAR_VIS_TOP)
+ gtk_widget_show_all(dwb.gui.topbox);
}
}
}
@@ -1135,8 +1140,6 @@ view_add(const char *uri, gboolean background) {
dwb_focus(ret);
}
-
-
view_init_signals(ret);
view_init_settings(ret);
diff --git a/util/keys.in b/util/keys.in
index c77b6fb1..da763238 100644
--- a/util/keys.in
+++ b/util/keys.in
@@ -84,6 +84,10 @@ focus_prev Focus previous view
push_master Push to master area
toggle_bottomstack Toggle bottomstack
fullscreen Toggle fullscreen
+toggle_bars Toggle tabbar and statusbar
+toggle_topbar Toggle tabbar
+toggle_bottombar Toggle bottombar
+presentation_mode Toggle presentation mode
# completion Completion
buffers Show all open tabs