about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorJosh Rickmar <jrick@devio.us>2012-06-26 10:06:19 -0400
committerJosh Rickmar <jrick@devio.us>2012-06-28 15:28:03 -0400
commit375e29bed3993b912011d10418bd54ca473989c4 (patch)
tree5f5bb19cc7b2ceaec90c5c66a9c791f26f22ed58
parentead88eca150b84b8fad610e5181dc0f08225751d (diff)
downloadxombrero-375e29bed3993b912011d10418bd54ca473989c4.tar.gz
Add a link to the top of about:history to remove all items from the
history.

Make the "No History" row expand across 4 columns instead of 3.
-rw-r--r--about.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/about.c b/about.c
index 3108ac7..2788ff2 100644
--- a/about.c
+++ b/about.c
@@ -80,6 +80,7 @@
 /* XTP history actions */
 #define XT_XTP_HL_LIST		(1)
 #define XT_XTP_HL_REMOVE	(2)
+#define XT_XTP_HL_REMOVE_ALL	(3)
 
 /* XTP cookie actions */
 #define XT_XTP_CL_LIST		(1)
@@ -544,14 +545,10 @@ xtp_handle_dl(struct tab *t, uint8_t cmd, int id)
 	xtp_page_dl(t, NULL);
 }
 
-/*
- * Actions on history, only does one thing for now, but
- * we provide the function for future actions
- */
 void
 xtp_handle_hl(struct tab *t, uint8_t cmd, int id)
 {
-	struct history		*h, *next;
+	struct history		*h, *next, *ht;
 	int			i = 1;
 
 	switch (cmd) {
@@ -569,6 +566,10 @@ xtp_handle_hl(struct tab *t, uint8_t cmd, int id)
 			i++;
 		}
 		break;
+	case XT_XTP_HL_REMOVE_ALL:
+		RB_FOREACH_SAFE(h, history_list, &hl, ht)
+			RB_REMOVE(history_list, &hl, h);
+		break;
 	case XT_XTP_HL_LIST:
 		/* Nothing - just xtp_page_hl() below */
 		break;
@@ -1638,8 +1639,12 @@ xtp_page_hl(struct tab *t, struct karg *args)
 		generate_xtp_session_key(&hl_session_key);
 
 	/* body */
-	body = g_strdup_printf("<table style='table-layout:fixed'><tr>"
-	    "<th>URI</th><th>Title</th><th>Last visited</th><th style='width: 40px'>Rm</th></tr>\n");
+	body = g_strdup_printf("<div align=\"center\"><a href=\"%s%d/%s/%d\">"
+	    "[ Remove All ]</a></div>"
+	    "<table style='table-layout:fixed'><tr>"
+	    "<th>URI</th><th>Title</th><th>Last visited</th>"
+	    "<th style='width: 40px'>Rm</th></tr>\n",
+	    XT_XTP_STR, XT_XTP_HL, hl_session_key, XT_XTP_HL_REMOVE_ALL);
 
 	RB_FOREACH_REVERSE(h, history_list, &hl) {
 		tmp = body;
@@ -1662,7 +1667,7 @@ xtp_page_hl(struct tab *t, struct karg *args)
 	if (i == 1) {
 		tmp = body;
 		body = g_strdup_printf("%s\n<tr><td style='text-align:center'"
-		    "colspan='3'>No History</td></tr>\n", body);
+		    "colspan='4'>No History</td></tr>\n", body);
 		g_free(tmp);
 	}