about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorStevan Andjelkovic <stevan@student.chalmers.se>2011-01-16 21:56:30 +0000
committerStevan Andjelkovic <stevan@student.chalmers.se>2011-01-16 21:56:30 +0000
commit6b8371f3aad9747b3d88acb45857831f61720249 (patch)
tree72c937ec60902518ae2bd3687811be8e3790757a
parent80e55b2cfce5c3cbfbe2e6c5f95d46d19256747a (diff)
downloadxombrero-6b8371f3aad9747b3d88acb45857831f61720249.tar.gz
Made save_tabs respect the order in which the tabs appear in the
notebook.
-rw-r--r--xxxterm.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/xxxterm.c b/xxxterm.c
index f139628..bdcb95c 100644
--- a/xxxterm.c
+++ b/xxxterm.c
@@ -1604,6 +1604,8 @@ save_tabs(struct tab *t, struct karg *a)
 	struct tab		*ti;
 	WebKitWebFrame		*frame;
 	const gchar		*uri;
+	int			len = 0, i;
+	gchar			**arr = NULL;
 
 	if (a == NULL)
 		return (1);
@@ -1621,14 +1623,24 @@ save_tabs(struct tab *t, struct karg *a)
 	/* save session name */
 	fprintf(f, "%s%s\n", XT_SAVE_SESSION_ID, named_session);
 
-	/* save tabs */
+	/* save tabs, in the order they are arranged in the notebook */
+	TAILQ_FOREACH(ti, &tabs, entry)
+		len++;
+
+	arr = g_malloc0(len * sizeof(gchar *));
+
 	TAILQ_FOREACH(ti, &tabs, entry) {
 		frame = webkit_web_view_get_main_frame(ti->wv);
 		uri = webkit_web_frame_get_uri(frame);
 		if (uri && strlen(uri) > 0)
-			fprintf(f, "%s\n", uri);
+			arr[gtk_notebook_page_num(notebook, ti->vbox)] = (gchar *)uri;
 	}
 
+	for (i = 0; i < len; i++)
+		if (arr[i])
+			fprintf(f, "%s\n", arr[i]);
+
+	g_free(arr);
 	fclose(f);
 
 	return (0);
@@ -3926,7 +3938,7 @@ session_cmd(struct tab *t, struct karg *args)
 		action = "show";
 
 	if (!strcmp(action, "show"))
-		show_oops(t, "Current session: %s", named_session[0] == '\0' ? 
+		show_oops(t, "Current session: %s", named_session[0] == '\0' ?
 		    XT_SAVED_TABS_FILE : named_session);
 	else if (g_str_has_prefix(action, "save ")) {
 		if (session_save(t, action, &filename)) {