From: Daniel Carl <danielcarl@gmx.de>
Date: Tue, 22 Oct 2013 18:54:24 +0000 (+0200)
Subject: Show history indicator '[+-]' in statusbar.
X-Git-Url: https://git.owens.tech/assets/wrapped.html/assets/wrapped.html/git?a=commitdiff_plain;h=a27d8cb259be03f3f8f89856d8de6bfe2bae6c75;p=vimb.git

Show history indicator '[+-]' in statusbar.
---

diff --git a/src/config.def.h b/src/config.def.h
index 3cd5876..6b65997 100644
--- a/src/config.def.h
+++ b/src/config.def.h
@@ -27,6 +27,8 @@
 #define FEATURE_NO_SCROLLBARS
 #define FEATURE_TITLE_IN_COMPLETION
 #define FEATURE_QUEUE
+/* should the history indicator [+-] be shown in status bar after url */
+#define FEATURE_HISTORY_INDICATOR
 
 
 /* time in seconds after that message will be removed from inputbox if the
diff --git a/src/main.c b/src/main.c
index 6d49db6..72f205d 100644
--- a/src/main.c
+++ b/src/main.c
@@ -311,7 +311,25 @@ void vb_update_input_style(void)
 
 void vb_update_urlbar(const char *uri)
 {
-    gtk_label_set_text(GTK_LABEL(vb.gui.statusbar.left), uri);
+    Gui *gui = &vb.gui;
+#ifdef FEATURE_HISTORY_INDICATOR
+    gboolean back, fwd;
+    char *str;
+
+    back = webkit_web_view_can_go_back(gui->webview);
+    fwd  = webkit_web_view_can_go_forward(gui->webview);
+
+    /* show history indicator only if there is something to show */
+    if (back || fwd) {
+        str = g_strdup_printf("%s [%s]", uri, back ? (fwd ? "+-" : "+") : "-");
+        gtk_label_set_text(GTK_LABEL(gui->statusbar.left), str);
+        g_free(str);
+    } else {
+        gtk_label_set_text(GTK_LABEL(gui->statusbar.left), uri);
+    }
+#else
+    gtk_label_set_text(GTK_LABEL(gui->statusbar.left), uri);
+#endif
 }
 
 void vb_quit(void)