From 516dc93a6948222aff7f5e8608ee736837ac28cd Mon Sep 17 00:00:00 2001
From: Daniel Carl <danielcarl@gmx.de>
Date: Fri, 18 Apr 2014 23:45:20 +0200
Subject: [PATCH] Allow to toggle fullsceen.

---
 doc/vimb.1    |  3 +++
 src/main.h    |  1 +
 src/setting.c | 27 +++++++++++++++++++++++++++
 3 files changed, 31 insertions(+)

diff --git a/doc/vimb.1 b/doc/vimb.1
index 9cb624d..268312a 100644
--- a/doc/vimb.1
+++ b/doc/vimb.1
@@ -708,6 +708,9 @@ the download is started '~/', '~user', '$VAR' and '${VAR}'.
 Command with placeholder '%s' called if form filed is opened with editor to
 spawn the editor like `x-terminal-emulator -e vi %s'.
 .TP
+.B fullscreen (bool)
+Show the current window full-screen.
+.TP
 .B header (string)
 Comma separated list of headers that replaces default header sent by webkit or
 new headers. The format for the header list elements is `name[=[value]]'.
diff --git a/src/main.h b/src/main.h
index 5609edd..db1cf64 100644
--- a/src/main.h
+++ b/src/main.h
@@ -300,6 +300,7 @@ typedef struct {
     char         *cafile;         /* path to the ca file */
     GTlsDatabase *tls_db;         /* tls database */
     float        default_zoom;    /* default zoomlevel that is applied on zz zoom reset */
+    gboolean     fullscreen;      /* indicates if full screen mode is on */
 } Config;
 
 typedef struct {
diff --git a/src/setting.c b/src/setting.c
index b732e92..09a357c 100644
--- a/src/setting.c
+++ b/src/setting.c
@@ -53,6 +53,7 @@ static SettingStatus editor_command(const Setting *s, const SettingType type);
 static SettingStatus timeoutlen(const Setting *s, const SettingType type);
 static SettingStatus headers(const Setting *s, const SettingType type);
 static SettingStatus nextpattern(const Setting *s, const SettingType type);
+static SettingStatus fullscreen(const Setting *s, const SettingType type);
 
 static gboolean validate_js_regexp_list(const char *pattern);
 
@@ -125,6 +126,7 @@ static Setting default_settings[] = {
     {NULL, "header", TYPE_CHAR, headers, {.s = ""}},
     {NULL, "nextpattern", TYPE_CHAR, nextpattern, {.s = "/\\bnext\\b/i,/^(>\\|>>\\|»)$/,/^(>\\|>>\\|»)/,/(>\\|>>\\|»)$/,/\\bmore\\b/i"}},
     {NULL, "previouspattern", TYPE_CHAR, nextpattern, {.s = "/\\bprev\\|previous\\b/i,/^(<\\|<<\\|«)$/,/^(<\\|<<\\|«)/,/(<\\|<<\\|«)$/"}},
+    {NULL, "fullscreen", TYPE_BOOLEAN, fullscreen, {.i = 0}},
 };
 
 void setting_init(void)
@@ -896,6 +898,31 @@ static SettingStatus nextpattern(const Setting *s, const SettingType type)
     return SETTING_ERROR | SETTING_USER_NOTIFIED;
 }
 
+static SettingStatus fullscreen(const Setting *s, const SettingType type)
+{
+    if (type == SETTING_GET) {
+        print_value(s, &vb.config.fullscreen);
+
+        return SETTING_OK;
+    }
+
+    if (type == SETTING_SET) {
+        vb.config.fullscreen = s->arg.i ? true : false;
+    } else {
+        vb.config.fullscreen = !vb.config.fullscreen;
+        print_value(s, &vb.config.fullscreen);
+    }
+
+    /* apply the new set or toggled value */
+    if (vb.config.fullscreen) {
+        gtk_window_fullscreen(GTK_WINDOW(vb.gui.window));
+    } else {
+        gtk_window_unfullscreen(GTK_WINDOW(vb.gui.window));
+    }
+
+    return SETTING_OK;
+}
+
 /**
  * Validated syntax given list of JavaScript RegExp patterns.
  * If validation fails, the error is shown to the user.
-- 
2.20.1