--- shell/ev-jobs.c-old	2008-03-19 22:56:09.000000000 +0100
+++ shell/ev-jobs.c	2008-03-19 23:56:18.000000000 +0100
@@ -789,22 +789,7 @@
 	return MIN (max_page, last_page);
 }
 
-static gboolean
-ev_print_job_print_page_in_set (EvJobPrint *job,
-				gint        page)
-{
-	switch (job->page_set) {
-	        case EV_PRINT_PAGE_SET_EVEN:
-			return page % 2 == 0;
-	        case EV_PRINT_PAGE_SET_ODD:
-			return page % 2 != 0;
-	        case EV_PRINT_PAGE_SET_ALL:
-			return TRUE;
-	}
-
-	return FALSE;
-}
-
+// allocate and fill page_list
 static gint *
 ev_job_print_get_page_list (EvJobPrint *job,
 			    gint       *n_pages)
@@ -815,27 +800,12 @@
 
 	max_page = ev_document_get_n_pages (EV_JOB (job)->document) - 1;
 
+	// compute number of pages
 	for (i = 0; i < job->n_ranges; i++) {
-		gint rsize;
-		gint start, end;
-
-		if (job->ranges[i].start > max_page)
-			continue;
-		
-		start = job->ranges[i].start + 1;
-		end = job->ranges[i].end <= max_page ? job->ranges[i].end + 1 : max_page + 1;
-		rsize = end - start + 1;
-
-		switch (job->page_set) {
-		        case EV_PRINT_PAGE_SET_EVEN:
-				pages += start % 2 == 0 ? (rsize / 2) + (rsize % 2) : (rsize / 2);
-				break;
-		        case EV_PRINT_PAGE_SET_ODD:
-				pages += start % 2 != 0 ? (rsize / 2) + (rsize % 2) : (rsize / 2);
-				break;
-		        default:
-				pages += rsize;
+		for (j = job->ranges[i].start; j <= job->ranges[i].end; j++) {
+			if (j > max_page)
 				break;
+			pages++;
 		}
 	}
 
@@ -844,6 +814,7 @@
 	if (pages == 0)
 		return NULL;
 
+	// fill page_list
 	page_list = g_new (gint, pages);
 
 	page = 0;
@@ -851,9 +822,7 @@
 		for (j = job->ranges[i].start; j <= job->ranges[i].end; j++) {
 			if (j > max_page)
 				break;
-		
-			if (ev_print_job_print_page_in_set (job, j + 1))
-				page_list[page++] = j;
+			page_list[page++] = j;
 		}
 	}
 
@@ -871,7 +840,7 @@
 	gint                   n_pages;
 	gint                   last_page;
 	gint                   first_page;
-	gint                   i, j;
+	gint                   i, oddeven;
 	gchar                 *filename;
 	
 	g_return_if_fail (EV_IS_JOB_PRINT (job));
@@ -917,32 +886,48 @@
 	ev_document_doc_mutex_lock ();
 	ev_file_exporter_begin (EV_FILE_EXPORTER (document), &fc);
 
+	// odd/even: it refers to the pages to be printed, not to the pages in the doc
+	//   (they are different if there are several pages per sheet); this allows
+	//   someone to print all odd pages, put the same paper in the printer again
+	//   and print all the even pages on the back of these sheets
+	// reverse: here it does never start with a blank page.  As I do not know the
+	//   usefullness of reverse, there may be a problem with reverse and odd/even:
+	//   if there are 2 odd and and 1 even pages, should even reverse start with
+	//   a blank page or not?
+	// page is between 0 and n_pages-1
+	// n_pages is the number of pages to be printed (odd AND even, no matter what
+	//   the user chose)
 	for (i = 0; i < job->copies; i++) {
 		gint page, step;
 		gint n_copies;
-		
+
+		oddeven = 1;
 		step = job->reverse ? -1 * job->pages_per_sheet : job->pages_per_sheet;
 		page = job->reverse ? ((n_pages - 1) / job->pages_per_sheet) * job->pages_per_sheet : 0;
 		n_copies = job->collate ? 1 : job->copies;
 
 		while ((job->reverse && (page >= 0)) || (!job->reverse && (page < n_pages))) {
-			gint k;
-
-			for (k = 0; k < n_copies; k++) {
-				ev_file_exporter_begin_page (EV_FILE_EXPORTER (document));
-				for (j = 0; j < job->pages_per_sheet; j++) {
-					gint p = page + j;
-
-					if (p < 0 || p >= n_pages)
-						break;
-					ev_render_context_set_page (rc, page_list[p]);
-					ev_file_exporter_do_page (EV_FILE_EXPORTER (document), rc);
+			if (job->page_set == EV_PRINT_PAGE_SET_ALL
+				|| (job->page_set == EV_PRINT_PAGE_SET_EVEN && oddeven % 2 == 0)
+				|| (job->page_set == EV_PRINT_PAGE_SET_ODD && oddeven % 2 != 0)) {
+
+				gint j, k;
+
+				for (k = 0; k < n_copies; k++) {
+					ev_file_exporter_begin_page (EV_FILE_EXPORTER (document));
+					for (j = 0; j < job->pages_per_sheet; j++) {
+						gint p = page + j;
+
+						if (p < 0 || p >= n_pages)
+							break;
+						ev_render_context_set_page (rc, page_list[p]);
+						ev_file_exporter_do_page (EV_FILE_EXPORTER (document), rc);
+					}
+					ev_file_exporter_end_page (EV_FILE_EXPORTER (document));
 				}
-
-				ev_file_exporter_end_page (EV_FILE_EXPORTER (document));
 			}
-
 			page += step;
+			oddeven++;
 		}
 
 		if (!job->collate)
