Index: shell/ev-sidebar-thumbnails.c
===================================================================
RCS file: /cvs/gnome/evince/shell/ev-sidebar-thumbnails.c,v
retrieving revision 1.39
diff -u -p -r1.39 ev-sidebar-thumbnails.c
--- shell/ev-sidebar-thumbnails.c	30 Jul 2005 23:11:25 -0000	1.39
+++ shell/ev-sidebar-thumbnails.c	23 Aug 2005 21:50:14 -0000
@@ -59,6 +59,7 @@ struct _EvSidebarThumbnailsPrivate {
 
 	/* Visible pages */
 	gint start_page, end_page;
+	gint rotation;
 };
 
 enum {
@@ -83,6 +84,7 @@ static void         ev_sidebar_thumbnail
 static const gchar* ev_sidebar_thumbnails_get_label        (EvSidebarPage       *sidebar_page);
 static void         thumbnail_job_completed_callback       (EvJobThumbnail      *job,
 							    EvSidebarThumbnails *sidebar_thumbnails);
+static void         ev_sidebar_thumbnails_refresh          (EvSidebarThumbnails *sidebar_thumbnails);
 
 G_DEFINE_TYPE_EXTENDED (EvSidebarThumbnails, 
                         ev_sidebar_thumbnails, 
@@ -230,7 +232,7 @@ add_range (EvSidebarThumbnails *sidebar_
 
 		if (job == NULL && !thumbnail_set) {
 			/* FIXME: Need rotation */
-			job = (EvJobThumbnail *)ev_job_thumbnail_new (priv->document, page, 0, THUMBNAIL_WIDTH);
+			job = (EvJobThumbnail *)ev_job_thumbnail_new (priv->document, page, priv->rotation, THUMBNAIL_WIDTH);
 			ev_job_queue_add_job (EV_JOB (job), EV_JOB_PRIORITY_HIGH);
 			g_object_set_data_full (G_OBJECT (job), "tree_iter",
 						gtk_tree_iter_copy (&iter),
@@ -355,7 +357,7 @@ ev_sidebar_thumbnails_fill_model (EvSide
 	}
 }
 
-void
+static void
 ev_sidebar_thumbnails_refresh (EvSidebarThumbnails *sidebar_thumbnails)
 {
 	ev_sidebar_thumbnails_clear_model (sidebar_thumbnails);
@@ -647,4 +649,21 @@ ev_sidebar_thumbnails_page_iface_init (E
 	iface->set_document = ev_sidebar_thumbnails_set_document;
 	iface->get_label = ev_sidebar_thumbnails_get_label;
 }
+
+void
+ev_sidebar_thumbnails_set_rotation (EvSidebarThumbnails *sidebar_thumbnails,
+				    int                  rotation)
+{
+	if (sidebar_thumbnails->priv->rotation != rotation) {
+		sidebar_thumbnails->priv->rotation = rotation;
+		ev_sidebar_thumbnails_refresh (sidebar_thumbnails);	
+	}
+}
+				    
+int
+ev_sidebar_thumbnails_get_rotation (EvSidebarThumbnails *sidebar_thumbnails)
+{
+	return sidebar_thumbnails->priv->rotation;
+}
+	
 
Index: shell/ev-sidebar-thumbnails.h
===================================================================
RCS file: /cvs/gnome/evince/shell/ev-sidebar-thumbnails.h,v
retrieving revision 1.8
diff -u -p -r1.8 ev-sidebar-thumbnails.h
--- shell/ev-sidebar-thumbnails.h	18 Jun 2005 15:51:52 -0000	1.8
+++ shell/ev-sidebar-thumbnails.h	23 Aug 2005 21:50:14 -0000
@@ -53,7 +53,9 @@ struct _EvSidebarThumbnailsClass {
 
 GType      ev_sidebar_thumbnails_get_type     (void);
 GtkWidget *ev_sidebar_thumbnails_new          (void);
-void       ev_sidebar_thumbnails_refresh      (EvSidebarThumbnails *sidebar_thumbnails);
+void       ev_sidebar_thumbnails_set_rotation (EvSidebarThumbnails *sidebar_thumbnails,
+					       int                  rotation);
+int        ev_sidebar_thumbnails_get_rotation (EvSidebarThumbnails *view);
 
 G_END_DECLS
 
Index: shell/ev-view.c
===================================================================
RCS file: /cvs/gnome/evince/shell/ev-view.c,v
retrieving revision 1.148
diff -u -p -r1.148 ev-view.c
--- shell/ev-view.c	23 Aug 2005 08:33:52 -0000	1.148
+++ shell/ev-view.c	23 Aug 2005 21:50:15 -0000
@@ -2400,30 +2400,6 @@ ev_view_zoom_out (EvView *view)
 }
 
 void
-ev_view_rotate_right (EvView *view)
-{
-	int rotation = view->rotation + 90;
-
-	if (rotation >= 360) {
-		rotation -= 360;
-	}
-
-	ev_view_set_rotation (view, rotation);
-}
-
-void
-ev_view_rotate_left (EvView *view)
-{
-	int rotation = view->rotation - 90;
-
-	if (rotation < 0) {
-		rotation += 360;
-	}
-
-	ev_view_set_rotation (view, rotation);
-}
-
-void
 ev_view_set_rotation (EvView *view, int rotation)
 {
 	view->rotation = rotation;
Index: shell/ev-view.h
===================================================================
RCS file: /cvs/gnome/evince/shell/ev-view.h,v
retrieving revision 1.37
diff -u -p -r1.37 ev-view.h
--- shell/ev-view.h	15 Aug 2005 04:41:30 -0000	1.37
+++ shell/ev-view.h	23 Aug 2005 21:50:15 -0000
@@ -99,8 +99,6 @@ void		ev_view_set_zoom_for_size (EvView 
 		    			   int             height,
 					   int             vsb_width,
 					   int             hsb_height);
-void		ev_view_rotate_left       (EvView         *view);
-void            ev_view_rotate_right      (EvView         *view);
 void            ev_view_set_rotation      (EvView         *view,
 					   int             rotation);
 int             ev_view_get_rotation      (EvView         *view);
Index: shell/ev-window.c
===================================================================
RCS file: /cvs/gnome/evince/shell/ev-window.c,v
retrieving revision 1.208
diff -u -p -r1.208 ev-window.c
--- shell/ev-window.c	16 Aug 2005 15:49:48 -0000	1.208
+++ shell/ev-window.c	23 Aug 2005 21:50:16 -0000
@@ -944,6 +944,7 @@ static void
 setup_view_from_metadata (EvWindow *window)
 {
 	EvView *view = EV_VIEW (window->priv->view);
+	EvSidebarThumbnails *sidebar_thumbs = EV_SIDEBAR_THUMBNAILS (window->priv->sidebar_thumbs);
 	char *uri = window->priv->uri;
 	GEnumValue *enum_value;
 	GValue width = { 0, };
@@ -1023,20 +1024,11 @@ setup_view_from_metadata (EvWindow *wind
 
 	/* Rotation */
 	if (ev_metadata_manager_get (uri, "rotation", &rotation)) {
-		if (g_value_get_int (&rotation)) {
-			switch (g_value_get_int (&rotation)) {
-			case 90:
-				ev_view_set_rotation (view, 90);
-				break;
-			case 180:
-				ev_view_set_rotation (view, 180);
-				break;
-			case 270:
-				ev_view_set_rotation (view, 270);
-				break;
-			default:
-				break;
-			}
+		int value = g_value_get_int (&rotation);
+
+		if (value == 90 || value == 180 || value == 270) {
+			ev_view_set_rotation (view, value);
+			ev_sidebar_thumbnails_set_rotation (sidebar_thumbs, value);
 		}
 	}
 }
@@ -2078,16 +2070,30 @@ save_rotation_to_file (EvWindow *window)
 static void
 ev_window_cmd_edit_rotate_left (GtkAction *action, EvWindow *ev_window)
 {
-	ev_view_rotate_left (EV_VIEW (ev_window->priv->view));
-	ev_sidebar_thumbnails_refresh (EV_SIDEBAR_THUMBNAILS (ev_window->priv->sidebar_thumbs));
+	int rotation;
+	
+	rotation = ev_view_get_rotation (EV_VIEW (ev_window->priv->view));
+	
+	rotation = (rotation + 270) % 360;
+	
+	ev_view_set_rotation (EV_VIEW (ev_window->priv->view), rotation);
+	ev_sidebar_thumbnails_set_rotation (EV_SIDEBAR_THUMBNAILS (ev_window->priv->sidebar_thumbs),
+					    rotation);
 	save_rotation_to_file (ev_window);
 }
 
 static void
 ev_window_cmd_edit_rotate_right (GtkAction *action, EvWindow *ev_window)
 {
-	ev_view_rotate_right (EV_VIEW (ev_window->priv->view));
-	ev_sidebar_thumbnails_refresh (EV_SIDEBAR_THUMBNAILS (ev_window->priv->sidebar_thumbs));
+	int rotation;
+	
+	rotation = ev_view_get_rotation (EV_VIEW (ev_window->priv->view));
+	
+	rotation = (rotation + 90) % 360;
+	
+	ev_view_set_rotation (EV_VIEW (ev_window->priv->view), rotation);
+	ev_sidebar_thumbnails_set_rotation (EV_SIDEBAR_THUMBNAILS (ev_window->priv->sidebar_thumbs),
+					    rotation);
 	save_rotation_to_file (ev_window);
 }
 
