about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorMarco Peereboom <marco@conformal.com>2011-01-05 01:17:43 +0000
committerMarco Peereboom <marco@conformal.com>2011-01-05 01:17:43 +0000
commit6e09e135e56c20ee1f5e8cfeaf991484dde2170c (patch)
tree39f577ee02bc81c3cf6b363a4136a1c99fd501a2
parent804d57b2a10e673f04fbf593dc6e6ae2f251543a (diff)
downloadxombrero-6e09e135e56c20ee1f5e8cfeaf991484dde2170c.tar.gz
when undoing tab close make forward history work too.
from Stevan Andjelkovic <stevan@student.chalmers.se>
-rw-r--r--xxxterm.112
-rw-r--r--xxxterm.c98
2 files changed, 73 insertions, 37 deletions
diff --git a/xxxterm.1 b/xxxterm.1
index 4d35e9d..7e39196 100644
--- a/xxxterm.1
+++ b/xxxterm.1
@@ -266,10 +266,10 @@ Navigation:
 .Pp
 .Bl -tag -width "tabnew, tabedit, tabe [URI]" -offset indent -compact
 .It Cm F5, C-r, C-l
-Refresh page
-.It Cm Backspace
-Previous page
-.It Cm M-Left
+Reload page
+.It Cm C-R
+Reload page without using any cached data
+.It Cm Backspace, M-Left
 Previous page
 .It Cm S-BackSpace, M-Right
 Forward page
@@ -310,9 +310,9 @@ Toggle source view.
 Tab Manipulation:
 .Pp
 .Bl -tag -width "tabnew, tabedit, tabe [URI]" -offset indent -compact
-.It Cm C-T
+.It Cm C-t
 Create new tab with focus in URI entry
-.It Cm C-W
+.It Cm C-w
 Destroy current tab
 .It Cm U
 Undo close tab
diff --git a/xxxterm.c b/xxxterm.c
index 25181eb..270f6a5 100644
--- a/xxxterm.c
+++ b/xxxterm.c
@@ -221,6 +221,8 @@ struct undo {
         TAILQ_ENTRY(undo)	entry;
         gchar			*uri;
 	GList			*history;
+	int			back; /* Keeps track of how many back
+				       * history items there are. */
 };
 TAILQ_HEAD(undo_tailq, undo);
 
@@ -334,6 +336,7 @@ struct karg {
 #define XT_NAV_BACK		(1)
 #define XT_NAV_FORWARD		(2)
 #define XT_NAV_RELOAD		(3)
+#define XT_NAV_RELOAD_CACHE	(4)
 
 #define XT_FOCUS_INVALID	(0)
 #define XT_FOCUS_URI		(1)
@@ -674,7 +677,7 @@ struct mime_type_list	mtl;
 struct alias_list	aliases;
 
 /* protos */
-void			create_new_tab(char *, GList *, int);
+void			create_new_tab(char *, struct undo *, int);
 void			delete_tab(struct tab *);
 void			adjustfont_webkit(struct tab *, int);
 int			run_script(struct tab *, char *);
@@ -2256,6 +2259,9 @@ navaction(struct tab *t, struct karg *args)
 	case XT_NAV_RELOAD:
 		webkit_web_view_reload(t->wv);
 		break;
+	case XT_NAV_RELOAD_CACHE:
+		webkit_web_view_reload_bypass_cache(t->wv);
+		break;
 	}
 	return (XT_CB_PASSTHROUGH);
 }
@@ -2410,8 +2416,7 @@ tabaction(struct tab *t, struct karg *args)
 		} else {
 			undo_count--;
 			u = TAILQ_FIRST(&undos);
-			DPRINTF("%s: uri: %s", __func__, u->uri);
-			create_new_tab(u->uri, u->history, 1);
+			create_new_tab(u->uri, u, 1);
 
 			TAILQ_REMOVE(&undos, u, entry);
 			g_free(u->uri);
@@ -3203,6 +3208,7 @@ struct key_bindings {
 	{ GDK_MOD1_MASK,	0,	GDK_Right,	navaction,	{.i = XT_NAV_FORWARD} },
 	{ 0,			0,	GDK_F5,		navaction,	{.i = XT_NAV_RELOAD} },
 	{ GDK_CONTROL_MASK,	0,	GDK_r,		navaction,	{.i = XT_NAV_RELOAD} },
+	{ GDK_CONTROL_MASK|GDK_SHIFT_MASK, 0, GDK_R,	navaction,	{.i = XT_NAV_RELOAD_CACHE} },
 	{ GDK_CONTROL_MASK,	0,	GDK_l,		navaction,	{.i = XT_NAV_RELOAD} },
 	{ GDK_MOD1_MASK,	1,	GDK_f,		xtp_page_fl,	{0} },
 
@@ -4600,13 +4606,13 @@ recalc_tabs(void)
 int
 undo_close_tab_save(struct tab *t)
 {
-	int				n;
+	int				m, n;
 	const gchar			*uri;
 	struct undo			*u1, *u2;
 	WebKitWebFrame                  *frame;
 	WebKitWebBackForwardList        *bfl;
-	GList                           *list, *elem;
-	WebKitWebHistoryItem            *hi1, *hi2;
+	GList                           *items;
+	WebKitWebHistoryItem            *item;
 
 	frame = webkit_web_view_get_main_frame(t->wv);
 	uri = webkit_web_frame_get_uri(frame);
@@ -4618,13 +4624,37 @@ undo_close_tab_save(struct tab *t)
 	u1->uri = g_strdup(uri);
 
 	bfl = webkit_web_view_get_back_forward_list(t->wv);
+
+	m = webkit_web_back_forward_list_get_forward_length(bfl);
 	n = webkit_web_back_forward_list_get_back_length(bfl);
-	list = webkit_web_back_forward_list_get_back_list_with_limit(bfl, n);
+	u1->back = n;
+
+	/* forward history */
+	items = webkit_web_back_forward_list_get_forward_list_with_limit(bfl, m);
 
-	for (elem = list; elem; elem = elem->next) {
-		hi1 = elem->data;
-		hi2 = webkit_web_history_item_copy(hi1);
-		u1->history = g_list_prepend(u1->history, hi2);
+	while (items) {
+		item = items->data;
+		u1->history = g_list_prepend(u1->history,
+		    webkit_web_history_item_copy(item));
+		items = g_list_next(items);
+	}
+
+	/* current item */
+	if (m) {
+		item = webkit_web_back_forward_list_get_current_item(bfl);
+		u1->history = g_list_prepend(u1->history,
+		    webkit_web_history_item_copy(item));
+	}
+
+
+	/* back history */
+	items = webkit_web_back_forward_list_get_back_list_with_limit(bfl, n);
+
+	while (items) {
+		item = items->data;
+		u1->history = g_list_prepend(u1->history,
+		    webkit_web_history_item_copy(item));
+		items = g_list_next(items);
 	}
 
 	TAILQ_INSERT_HEAD(&undos, u1, entry);
@@ -4692,16 +4722,15 @@ append_tab(struct tab *t)
 }
 
 void
-create_new_tab(char *title, GList *history, int focus)
+create_new_tab(char *title, struct undo *u, int focus)
 {
-	struct tab		*t, *tt;
-	int			load = 1, id, notfound;
-	char			*newuri = NULL;
-	GtkWidget		*image, *b, *bb;
-	WebKitWebHistoryItem	*hi;
-	GList			*elem;
-	WebKitWebBackForwardList *bfl;
-
+	struct tab			*t, *tt;
+	int				load = 1, id, notfound;
+	char				*newuri = NULL;
+	GtkWidget			*image, *b, *bb;
+	WebKitWebHistoryItem		*item;
+	GList				*items;
+	WebKitWebBackForwardList	*bfl;
 
 	DNPRINTF(XT_D_TAB, "create_new_tab: title %s focus %d\n", title, focus);
 
@@ -4847,22 +4876,29 @@ create_new_tab(char *title, GList *history, int focus)
 		    t->tab_id);
 	}
 
-	/* restore the tab's history */
-	if (history) {
-		for (elem = history; elem; elem = elem->next) {
-			hi  = elem->data;
-			bfl = webkit_web_view_get_back_forward_list(t->wv);
-			webkit_web_back_forward_list_add_item(bfl, hi);
-		}
-		g_list_free(history);
-		g_list_free(elem);
-	}
-
 	if (load)
 		webkit_web_view_load_uri(t->wv, title);
 	else
 		gtk_widget_grab_focus(GTK_WIDGET(t->uri_entry));
 
+	/* restore the tab's history */
+	if (u && u->history) {
+		bfl = webkit_web_view_get_back_forward_list(t->wv);
+
+		items = u->history;
+		while (items) {
+			item = items->data;
+			webkit_web_back_forward_list_add_item(bfl, item);
+			items = g_list_next(items);
+		}
+
+		item = g_list_nth_data(u->history, u->back);
+		webkit_web_view_go_to_back_forward_item(t->wv, item);
+
+		g_list_free(items);
+		g_list_free(u->history);
+	}
+
 	if (newuri)
 		g_free(newuri);
 }
44'>444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564