diff --git a/backend/comics/comics-document.c b/backend/comics/comics-document.c
index 1b46fac..f6e7ade 100644
--- a/backend/comics/comics-document.c
+++ b/backend/comics/comics-document.c
@@ -1,5 +1,6 @@
 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8; c-indent-level: 8 -*- */
 /*
+ * Copyright (C) 2009, Juanjo Marín <juanj.marin@juntadeandalucia.es>
  * Copyright (C) 2005, Teemu Tervo <teemu.tervo@gmx.net>
  *
  * This program is free software; you can redistribute it and/or modify
@@ -643,6 +644,8 @@ comics_document_render (EvDocument      *document,
 	cairo_surface_t *surface;
 
 	pixbuf = comics_document_render_pixbuf (document, rc);
+	if (rc->inverted_colors)
+		ev_document_misc_inverted_colors_pixbuf (pixbuf);
 	surface = ev_document_misc_surface_from_pixbuf (pixbuf);
 	g_object_unref (pixbuf);
 	
@@ -777,6 +780,9 @@ comics_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document,
 	GdkPixbuf *thumbnail;
 
 	thumbnail = comics_document_render_pixbuf (EV_DOCUMENT (document), rc);
+	
+	if (rc->inverted_colors)
+		ev_document_misc_inverted_colors_pixbuf (thumbnail);
 
 	if (border) {
 	      GdkPixbuf *tmp_pixbuf = thumbnail;
@@ -784,6 +790,8 @@ comics_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document,
 	      thumbnail = ev_document_misc_get_thumbnail_frame (-1, -1, tmp_pixbuf);
 	      g_object_unref (tmp_pixbuf);
 	}
+	if (rc->inverted_colors)
+	      ev_document_misc_inverted_colors_pixbuf (thumbnail);
 
 	return thumbnail;
 }
diff --git a/backend/djvu/djvu-document.c b/backend/djvu/djvu-document.c
index 46bbd40..0b9a5ff 100644
--- a/backend/djvu/djvu-document.c
+++ b/backend/djvu/djvu-document.c
@@ -315,7 +315,7 @@ djvu_document_render (EvDocument      *document,
 		      EvRenderContext *rc)
 {
 	DjvuDocument *djvu_document = DJVU_DOCUMENT (document);
-	cairo_surface_t *surface;
+	cairo_surface_t *surface, *surface_aux;
 	gchar *pixels;
 	gint   rowstride;
     	ddjvu_rect_t rrect;
@@ -324,6 +324,7 @@ djvu_document_render (EvDocument      *document,
 	ddjvu_page_rotation_t rotation;
 	double page_width, page_height, tmp;
 	static const cairo_user_data_key_t key;
+	cairo_t *cr;
 
 	d_page = ddjvu_page_create_by_pageno (djvu_document->d_document, rc->page->index);
 	
@@ -382,8 +383,18 @@ djvu_document_render (EvDocument      *document,
 			   djvu_document->d_format,
 			   rowstride,
 			   pixels);
-
-	return surface;
+			   
+	if (rc->inverted_colors) {
+		cr = cairo_create (surface);
+		surface_aux = ev_document_misc_inverted_colors_surface (cr);
+		cairo_destroy (cr);
+		
+	} else {
+		surface_aux = surface;
+		cairo_surface_reference (surface);
+	}
+	cairo_surface_destroy (surface);
+	return surface_aux;
 }
 
 static void
@@ -543,6 +554,8 @@ djvu_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document,
 	      g_object_unref (tmp_pixbuf);
 	}
 	
+	if (rc->inverted_colors)
+		ev_document_misc_inverted_colors_pixbuf (rotated_pixbuf);
 	return rotated_pixbuf;
 }
 
diff --git a/backend/dvi/dvi-document.c b/backend/dvi/dvi-document.c
index 863276d..57be3ee 100644
--- a/backend/dvi/dvi-document.c
+++ b/backend/dvi/dvi-document.c
@@ -159,11 +159,12 @@ dvi_document_render (EvDocument      *document,
 		     EvRenderContext *rc)
 {
 	cairo_surface_t *surface;
-	cairo_surface_t *rotated_surface;
+	cairo_surface_t *rotated_surface, *surface_aux;
 	DviDocument *dvi_document = DVI_DOCUMENT(document);
 	gint required_width, required_height;
 	gint proposed_width, proposed_height;
 	gint xmargin = 0, ymargin = 0;
+	cairo_t *cr;
 
 	/* We should protect our context since it's not 
 	 * thread safe. The work to the future - 
@@ -200,7 +201,17 @@ dvi_document_render (EvDocument      *document,
 								     rc->rotation);
 	cairo_surface_destroy (surface);
 	
-	return rotated_surface;
+	if (rc->inverted_colors) {
+		cr = cairo_create (rotated_surface);
+		surface_aux = ev_document_misc_inverted_colors_surface (cr);
+		cairo_destroy (cr);
+		
+	} else {
+		surface_aux = rotated_surface;
+		cairo_surface_reference (rotated_surface);
+	}
+	cairo_surface_destroy (rotated_surface);
+	return surface_aux;
 }
 
 static void
@@ -322,6 +333,8 @@ dvi_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document,
 		rotated_pixbuf = ev_document_misc_get_thumbnail_frame (-1, -1, tmp_pixbuf);
 		g_object_unref (tmp_pixbuf);
 	}
+	if (rc->inverted_colors)
+		ev_document_misc_inverted_colors_pixbuf (rotated_pixbuf);
 
 	return rotated_pixbuf;
 }
diff --git a/backend/impress/impress-document.c b/backend/impress/impress-document.c
index 5c2e160..a7b7d7e 100644
--- a/backend/impress/impress-document.c
+++ b/backend/impress/impress-document.c
@@ -398,6 +398,9 @@ impress_document_render_pixbuf (EvDocument      *document,
 
   pixbuf = impress_document->pixbuf;
   impress_document->pixbuf = NULL;
+  
+  if (rc->inverted_colors)
+		ev_document_misc_inverted_colors_pixbuf (pixbuf);
 
   return pixbuf;
 }
diff --git a/backend/pdf/ev-poppler.cc b/backend/pdf/ev-poppler.cc
index 9306445..b036675 100644
--- a/backend/pdf/ev-poppler.cc
+++ b/backend/pdf/ev-poppler.cc
@@ -1,5 +1,6 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8; c-indent-level: 8 -*- */
 /* pdfdocument.h: Implementation of EvDocument for PDF
+ * Copyright (C) 2009, Juanjo Marín <juanj.marin@juntadeandalucia.es>
  * Copyright (C) 2004, Red Hat, Inc.
  *
  * This program is free software; you can redistribute it and/or modify
@@ -362,7 +363,7 @@ pdf_page_render (PopplerPage     *page,
 		 gint             height,
 		 EvRenderContext *rc)
 {
-	cairo_surface_t *surface;
+	cairo_surface_t *surface, *surface_aux;
 
 #ifdef HAVE_POPPLER_PAGE_RENDER
 	cairo_t *cr;
@@ -384,15 +385,24 @@ pdf_page_render (PopplerPage     *page,
 	        default:
 			cairo_translate (cr, 0, 0);
 	}
+
 	cairo_scale (cr, rc->scale, rc->scale);
 	cairo_rotate (cr, rc->rotation * G_PI / 180.0);
 	poppler_page_render (page, cr);
 
 	cairo_set_operator (cr, CAIRO_OPERATOR_DEST_OVER);
-	cairo_set_source_rgb (cr, 1., 1., 1.);
+	cairo_set_source_rgb (cr, 1., 1., 1.); 	// sets background color
 	cairo_paint (cr);
 
+	if (rc->inverted_colors)
+		surface_aux = ev_document_misc_inverted_colors_surface (cr);
+	else {
+		surface_aux = cairo_get_target (cr);
+		cairo_surface_reference (surface);
+	}
 	cairo_destroy (cr);
+	cairo_surface_destroy (surface);
+
 #else /* HAVE_POPPLER_PAGE_RENDER */
 	GdkPixbuf *pixbuf;
 	
@@ -406,11 +416,14 @@ pdf_page_render (PopplerPage     *page,
 				       rc->scale,
 				       rc->rotation,
 				       pixbuf);
-	surface = ev_document_misc_surface_from_pixbuf (pixbuf);
+	if (rc->inverted_colors)
+		ev_document_misc_inverted_colors_pixbuf (pixbuf);
+	
+	surface_aux = ev_document_misc_surface_from_pixbuf (pixbuf);
 	g_object_unref (pixbuf);
 #endif /* HAVE_POPPLER_PAGE_RENDER */
 
-	return surface;	
+	return surface_aux;
 }
 
 static cairo_surface_t *
@@ -1267,6 +1280,9 @@ make_thumbnail_for_page (PopplerPage     *poppler_page,
 	poppler_page_render_to_pixbuf (poppler_page, 0, 0,
 				       width, height,
 				       rc->scale, rc->rotation, pixbuf);
+	//Inversion
+	if (rc->inverted_colors)
+		ev_document_misc_inverted_colors_pixbuf (pixbuf);
 	ev_document_fc_mutex_unlock ();
 #else
 	cairo_surface_t *surface;
@@ -1297,7 +1313,7 @@ pdf_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document_thumbnails
 
 	pdf_document_thumbnails_get_dimensions (EV_DOCUMENT_THUMBNAILS (pdf_document),
 						rc, &width, &height);
-	
+
 #ifdef POPPLER_WITH_GDK
 	pixbuf = poppler_page_get_thumbnail_pixbuf (poppler_page);
 #else
@@ -1323,21 +1339,21 @@ pdf_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document_thumbnails
 			g_object_unref (pixbuf);
 			pixbuf = rotated_pixbuf;
 		} else {
+
 			/* The provided thumbnail has a different size */
 			g_object_unref (pixbuf);
 			pixbuf = make_thumbnail_for_page (poppler_page, rc, width, height);
+
 		}
 	} else {
 		/* There is no provided thumbnail. We need to make one. */
 		pixbuf = make_thumbnail_for_page (poppler_page, rc, width, height);
 	}
-
-        if (border && pixbuf) {
+	if (border && pixbuf) {
 		border_pixbuf = ev_document_misc_get_thumbnail_frame (-1, -1, pixbuf);
 		g_object_unref (pixbuf);
 		pixbuf = border_pixbuf;
 	}		
-
 	return pixbuf;
 }
 
diff --git a/backend/pixbuf/pixbuf-document.c b/backend/pixbuf/pixbuf-document.c
index b508810..cfc7afb 100644
--- a/backend/pixbuf/pixbuf-document.c
+++ b/backend/pixbuf/pixbuf-document.c
@@ -120,7 +120,10 @@ pixbuf_document_render (EvDocument      *document,
 	
         rotated_pixbuf = gdk_pixbuf_rotate_simple (scaled_pixbuf, 360 - rc->rotation);
         g_object_unref (scaled_pixbuf);
-
+	
+	if (rc->inverted_colors)
+		ev_document_misc_inverted_colors_pixbuf (rotated_pixbuf);
+		
 	surface = ev_document_misc_surface_from_pixbuf (rotated_pixbuf);
 	g_object_unref (rotated_pixbuf);
 
@@ -171,7 +174,10 @@ pixbuf_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document,
 
 	rotated_pixbuf = gdk_pixbuf_rotate_simple (pixbuf, 360 - rc->rotation);
         g_object_unref (pixbuf);
-
+	
+	if (rc->inverted_colors)
+		ev_document_misc_inverted_colors_pixbuf (rotated_pixbuf);
+		
         return rotated_pixbuf;
 }
 
diff --git a/backend/ps/ev-spectre.c b/backend/ps/ev-spectre.c
index 8ee1732..9821ecb 100644
--- a/backend/ps/ev-spectre.c
+++ b/backend/ps/ev-spectre.c
@@ -272,8 +272,9 @@ ps_document_render (EvDocument      *document,
 	guchar               *data = NULL;
 	gint                  stride;
 	gint                  rotation;
-	cairo_surface_t      *surface;
+	cairo_surface_t      *surface, *surface_aux;
 	static const cairo_user_data_key_t key;
+	cairo_t *cr;
 
 	ps_page = (SpectrePage *)rc->page->backend_page;
 	
@@ -316,7 +317,18 @@ ps_document_render (EvDocument      *document,
 						       stride);
 	cairo_surface_set_user_data (surface, &key,
 				     data, (cairo_destroy_func_t)g_free);
-	return surface;
+	
+	if (rc->inverted_colors) {
+		cr = cairo_create (surface);
+		surface_aux = ev_document_misc_inverted_colors_surface (cr);
+		cairo_destroy (cr);
+		
+	} else {
+		surface_aux = surface;
+		cairo_surface_reference (surface);
+	}
+	cairo_surface_destroy (surface);
+	return surface_aux;
 }
 
 static void
@@ -352,10 +364,10 @@ ps_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document_thumbnails,
 		g_warning ("Error rendering thumbnail");
 		return NULL;
 	}
-		
+	
 	pixbuf = ev_document_misc_pixbuf_from_surface (surface);
 	cairo_surface_destroy (surface);
-
+	
 	if (border) {
 		GdkPixbuf *border_pixbuf;
 		
diff --git a/backend/tiff/tiff-document.c b/backend/tiff/tiff-document.c
index aabcd6d..267891b 100644
--- a/backend/tiff/tiff-document.c
+++ b/backend/tiff/tiff-document.c
@@ -220,9 +220,10 @@ tiff_document_render (EvDocument      *document,
 	guchar *pixels = NULL;
 	guchar *p;
 	int orientation;
-	cairo_surface_t *surface;
+	cairo_surface_t *surface, *surface_aux;
 	cairo_surface_t *rotated_surface;
 	static const cairo_user_data_key_t key;
+	cairo_t *cr;
 	
 	g_return_val_if_fail (TIFF_IS_DOCUMENT (document), NULL);
 	g_return_val_if_fail (tiff_document->tiff != NULL, NULL);
@@ -308,7 +309,17 @@ tiff_document_render (EvDocument      *document,
 								     rc->rotation);
 	cairo_surface_destroy (surface);
 	
-	return rotated_surface;
+	if (rc->inverted_colors) {
+		cr = cairo_create (rotated_surface);
+		surface_aux = ev_document_misc_inverted_colors_surface (cr);
+		cairo_destroy (cr);
+		
+	} else {
+		surface_aux = rotated_surface;
+		cairo_surface_reference (rotated_surface);
+	}
+	cairo_surface_destroy (rotated_surface);
+	return surface_aux;
 }
 
 static GdkPixbuf *
@@ -380,6 +391,9 @@ tiff_document_render_pixbuf (EvDocument      *document,
 	rotated_pixbuf = gdk_pixbuf_rotate_simple (scaled_pixbuf, 360 - rc->rotation);
 	g_object_unref (scaled_pixbuf);
 	
+	if (rc->inverted_colors)
+		ev_document_misc_inverted_colors_pixbuf (rotated_pixbuf);
+	
 	return rotated_pixbuf;
 }
 
diff --git a/data/evince-toolbar.xml b/data/evince-toolbar.xml
index 6922a9f..b87bf71 100644
--- a/data/evince-toolbar.xml
+++ b/data/evince-toolbar.xml
@@ -6,6 +6,7 @@
     <toolitem name="FileSaveAs"/>
     <toolitem name="ViewContinuous"/>
     <toolitem name="ViewDual"/>
+    <toolitem name="ViewInvertedColors"/>
     <toolitem name="ViewReload"/>
     <toolitem name="ViewAutoscroll"/>
     <toolitem name="ViewSidebar"/>
diff --git a/data/evince-ui.xml b/data/evince-ui.xml
index 7ac4edb..85c9057 100644
--- a/data/evince-ui.xml
+++ b/data/evince-ui.xml
@@ -39,6 +39,8 @@
       <separator/>
       <menuitem name="ViewContinuousMenu" action="ViewContinuous"/>
       <menuitem name="ViewDualMenu" action="ViewDual"/>
+      <menuitem name="ViewInvertedColors" action="ViewInvertedColors"/>
+      <separator/>
       <menuitem name="ViewZoomInMenu" action="ViewZoomIn"/>
       <menuitem name="ViewZoomOutMenu" action="ViewZoomOut"/>
       <menuitem name="ViewBestFitMenu" action="ViewBestFit"/>
diff --git a/libdocument/ev-document-misc.c b/libdocument/ev-document-misc.c
index 889e4a8..393fd70 100644
--- a/libdocument/ev-document-misc.c
+++ b/libdocument/ev-document-misc.c
@@ -1,4 +1,5 @@
 /*
+ *  Copyright (C) 2009 Juanjo Marín <juanj.marin@juntadeandalucia.es>
  *  Copyright (c) 2007 Carlos Garcia Campos <carlosgc@gnome.org>
  *  Copyright (C) 2000-2003 Marco Pesenti Gritti
  *
@@ -294,4 +295,53 @@ ev_document_misc_surface_rotate_and_scale (cairo_surface_t *surface,
 
 	return new_surface;
 }
+
+cairo_surface_t * ev_document_misc_inverted_colors_surface (cairo_t *cr) {
+#if CAIRO_VERSION > CAIRO_VERSION_ENCODE(1, 9, 2)
+	// white + DIFFERENCE -> invert
+	cairo_set_operator (cr, CAIRO_OPERATOR_DIFFERENCE);
+	cairo_set_source_rgb (cr, 1., 1., 1.);	
+	cairo_paint(cr);
+	cairo_surface_reference (cairo_get_target (cr));
+	return (cairo_get_target (cr));
+#else
+	cairo_surface_t *surface;
+	GdkPixbuf *pixbuf;
+	cairo_t *cr_aux;
 	
+	cairo_paint (cr);
+	surface = cairo_get_target (cr);
+	pixbuf = ev_document_misc_pixbuf_from_surface (surface);
+	ev_document_misc_inverted_colors_pixbuf (pixbuf);
+	return (ev_document_misc_surface_from_pixbuf (pixbuf));
+#endif
+}
+
+void ev_document_misc_inverted_colors_pixbuf (GdkPixbuf *pixbuf)
+{
+	guchar *data, *p;
+	guint   width, height, x, y, rowstride, n_channels;
+    
+	n_channels = gdk_pixbuf_get_n_channels (pixbuf);
+	g_assert (gdk_pixbuf_get_colorspace (pixbuf) == GDK_COLORSPACE_RGB);
+	g_assert (gdk_pixbuf_get_bits_per_sample (pixbuf) == 8);
+	
+	/* First grab a pointer to the raw pixel data. */
+	data = gdk_pixbuf_get_pixels (pixbuf);
+
+	/* Find the number of bytes per row (could be padded). */
+	rowstride = gdk_pixbuf_get_rowstride (pixbuf);
+	
+	width = gdk_pixbuf_get_width (pixbuf);
+	height = gdk_pixbuf_get_height (pixbuf);
+	for (x = 0; x < width; x++) {
+		for (y = 0; y < height; y++) {
+			/* Calculate pixel's offset into the data array. */
+			p = data + x * n_channels + y * rowstride;
+			/* Change the RGB values*/
+			p[0] = 255 - p[0];
+			p[1] = 255 - p[1];
+			p[2] = 255 - p[2];
+		}
+	}
+}
diff --git a/libdocument/ev-document-misc.h b/libdocument/ev-document-misc.h
index 5a2ea03..1e64b2a 100644
--- a/libdocument/ev-document-misc.h
+++ b/libdocument/ev-document-misc.h
@@ -51,6 +51,8 @@ cairo_surface_t *ev_document_misc_surface_rotate_and_scale (cairo_surface_t *sur
 							    gint             dest_width,
 							    gint             dest_height,
 							    gint             dest_rotation);
+cairo_surface_t *ev_document_misc_inverted_colors_surface (cairo_t   *cr);
+void		 ev_document_misc_inverted_colors_pixbuf  (GdkPixbuf *pixbuf);
 
 G_END_DECLS
 
diff --git a/libdocument/ev-render-context.c b/libdocument/ev-render-context.c
index 4574066..5834113 100644
--- a/libdocument/ev-render-context.c
+++ b/libdocument/ev-render-context.c
@@ -54,9 +54,10 @@ ev_render_context_class_init (EvRenderContextClass *class)
 }
 
 EvRenderContext *
-ev_render_context_new (EvPage *page,
-		       gint    rotation,
-		       gdouble scale)
+ev_render_context_new (EvPage  *page,
+		       gint     rotation,
+		       gdouble  scale,
+		       gboolean inverted_colors)
 {
 	EvRenderContext *rc;
 
@@ -65,6 +66,7 @@ ev_render_context_new (EvPage *page,
 	rc->page = page ? g_object_ref (page) : NULL;
 	rc->rotation = rotation;
 	rc->scale = scale;
+	rc->inverted_colors = inverted_colors;
 
 	return rc;
 }
@@ -99,3 +101,11 @@ ev_render_context_set_scale (EvRenderContext *rc,
 	rc->scale = scale;
 }
 
+void
+ev_render_context_set_inverted_colors (EvRenderContext *rc,
+				     gboolean         inverted_colors)
+{
+	g_return_if_fail (rc != NULL);
+
+	rc->inverted_colors = inverted_colors;
+}
diff --git a/libdocument/ev-render-context.h b/libdocument/ev-render-context.h
index 96664bb..9c73c9f 100644
--- a/libdocument/ev-render-context.h
+++ b/libdocument/ev-render-context.h
@@ -47,22 +47,26 @@ struct _EvRenderContext
 {
 	GObject parent;
 	
-	EvPage *page;
-	gint    rotation;
-	gdouble scale;
+	EvPage  *page;
+	gint     rotation;
+	gdouble  scale;
+	gboolean inverted_colors;
 };
 
 
-GType            ev_render_context_get_type        (void) G_GNUC_CONST;
-EvRenderContext *ev_render_context_new             (EvPage          *page,
-						    gint             rotation,
-						    gdouble          scale);
-void             ev_render_context_set_page        (EvRenderContext *rc,
-						    EvPage          *page);
-void             ev_render_context_set_rotation    (EvRenderContext *rc,
-						    gint             rotation);
-void             ev_render_context_set_scale       (EvRenderContext *rc,
-						    gdouble          scale);
+GType            ev_render_context_get_type	       (void) G_GNUC_CONST;
+EvRenderContext *ev_render_context_new		       (EvPage          *page,
+						        gint             rotation,
+						        gdouble          scale,
+						        gboolean         inverted_colors);
+void             ev_render_context_set_page            (EvRenderContext *rc,
+						        EvPage          *page);
+void             ev_render_context_set_rotation        (EvRenderContext *rc,
+						        gint             rotation);
+void             ev_render_context_set_scale	       (EvRenderContext *rc,
+						        gdouble          scale);
+void             ev_render_context_set_inverted_colors (EvRenderContext *rc,
+						        gboolean         inverted_colors);
 
 
 G_END_DECLS
diff --git a/libview/ev-document-model.c b/libview/ev-document-model.c
index 2e3db25..9cecc7c 100644
--- a/libview/ev-document-model.c
+++ b/libview/ev-document-model.c
@@ -33,6 +33,7 @@ struct _EvDocumentModel
 
 	gint page;
 	gint rotation;
+	gboolean inverted_colors;
 	gdouble scale;
 	EvSizingMode sizing_mode;
 	guint continuous : 1;
@@ -58,6 +59,7 @@ enum {
 	PROP_DOCUMENT,
 	PROP_PAGE,
 	PROP_ROTATION,
+	PROP_INVERTED_COLORS,
 	PROP_SCALE,
 	PROP_SIZING_MODE,
 	PROP_CONTINUOUS,
@@ -106,6 +108,9 @@ ev_document_model_set_property (GObject      *object,
 	case PROP_ROTATION:
 		ev_document_model_set_rotation (model, g_value_get_int (value));
 		break;
+	case PROP_INVERTED_COLORS:
+		ev_document_model_set_inverted_colors (model, g_value_get_boolean (value));
+		break;
 	case PROP_SCALE:
 		ev_document_model_set_scale (model, g_value_get_double (value));
 		break;
@@ -144,6 +149,9 @@ ev_document_model_get_property (GObject    *object,
 	case PROP_ROTATION:
 		g_value_set_int (value, model->rotation);
 		break;
+	case PROP_INVERTED_COLORS:
+		g_value_set_boolean (value, model->inverted_colors);
+		break;
 	case PROP_SCALE:
 		g_value_set_double (value, model->scale);
 		break;
@@ -196,6 +204,13 @@ ev_document_model_class_init (EvDocumentModelClass *klass)
 							   0, 360, 0,
 							   G_PARAM_READWRITE));
 	g_object_class_install_property (g_object_class,
+					 PROP_INVERTED_COLORS,
+					 g_param_spec_boolean ("inverted-colors",
+							       "inverted Colors",
+							       "inverted Colors",
+							       FALSE,
+							       G_PARAM_READWRITE));
+	g_object_class_install_property (g_object_class,
 					 PROP_SCALE,
 					 g_param_spec_double ("scale",
 							      "Scale",
@@ -251,6 +266,7 @@ ev_document_model_init (EvDocumentModel *model)
 	model->scale = 1.;
 	model->sizing_mode = EV_SIZING_FIT_WIDTH;
 	model->continuous = TRUE;
+	model->inverted_colors = FALSE;
 	model->min_scale = 0.;
 	model->max_scale = G_MAXDOUBLE;
 }
@@ -461,6 +477,28 @@ ev_document_model_get_rotation (EvDocumentModel *model)
 }
 
 void
+ev_document_model_set_inverted_colors (EvDocumentModel *model,
+				       gboolean         inverted_colors)
+{
+	g_return_if_fail (EV_IS_DOCUMENT_MODEL (model));
+
+	if (inverted_colors == model->inverted_colors)
+		return;
+
+	model->inverted_colors = inverted_colors;
+
+	g_object_notify (G_OBJECT (model), "inverted-colors");
+}
+
+gboolean
+ev_document_model_get_inverted_colors (EvDocumentModel *model)
+{
+	g_return_val_if_fail (EV_IS_DOCUMENT_MODEL (model), FALSE);
+
+	return model->inverted_colors;
+}
+
+void
 ev_document_model_set_continuous (EvDocumentModel *model,
 				  gboolean         continuous)
 {
diff --git a/libview/ev-document-model.h b/libview/ev-document-model.h
index 26c6d7b..32c7098 100644
--- a/libview/ev-document-model.h
+++ b/libview/ev-document-model.h
@@ -49,32 +49,55 @@ EvDocumentModel *ev_document_model_new_with_document (EvDocument      *document)
 void             ev_document_model_set_document      (EvDocumentModel *model,
 						      EvDocument      *document);
 EvDocument      *ev_document_model_get_document      (EvDocumentModel *model);
+
+
 void             ev_document_model_set_page          (EvDocumentModel *model,
 						      gint             page);
 void             ev_document_model_set_page_by_label (EvDocumentModel *model,
 						      const gchar     *page_label);
 gint             ev_document_model_get_page          (EvDocumentModel *model);
+
+
 void             ev_document_model_set_scale         (EvDocumentModel *model,
 						      gdouble          scale);
 gdouble          ev_document_model_get_scale         (EvDocumentModel *model);
+
+
 void             ev_document_model_set_max_scale     (EvDocumentModel *model,
 						      gdouble          max_scale);
 gdouble          ev_document_model_get_max_scale     (EvDocumentModel *model);
+
+
 void             ev_document_model_set_min_scale     (EvDocumentModel *model,
 						      gdouble          min_scale);
 gdouble          ev_document_model_get_min_scale     (EvDocumentModel *model);
+
+
 void             ev_document_model_set_sizing_mode   (EvDocumentModel *model,
 						      EvSizingMode     mode);
 EvSizingMode     ev_document_model_get_sizing_mode   (EvDocumentModel *model);
+
+
 void             ev_document_model_set_rotation      (EvDocumentModel *model,
 						      gint             rotation);
 gint             ev_document_model_get_rotation      (EvDocumentModel *model);
+
+
+void             ev_document_model_set_inverted_colors (EvDocumentModel *model,
+				                        gboolean         inverted_colors);
+gboolean         ev_document_model_get_inverted_colors (EvDocumentModel *model);
+
+
 void             ev_document_model_set_continuous    (EvDocumentModel *model,
 						      gboolean         continuous);
 gboolean         ev_document_model_get_continuous    (EvDocumentModel *model);
+
+
 void             ev_document_model_set_dual_page     (EvDocumentModel *model,
 						      gboolean         dual_page);
 gboolean         ev_document_model_get_dual_page     (EvDocumentModel *model);
+
+
 void             ev_document_model_set_fullscreen    (EvDocumentModel *model,
 						      gboolean         fullscreen);
 gboolean         ev_document_model_get_fullscreen    (EvDocumentModel *model);
diff --git a/libview/ev-jobs.c b/libview/ev-jobs.c
index c0aa0b4..6b74968 100644
--- a/libview/ev-jobs.c
+++ b/libview/ev-jobs.c
@@ -518,7 +518,7 @@ ev_job_render_run (EvJob *job)
 	ev_document_fc_mutex_lock ();
 
 	job_render->ev_page = ev_document_get_page (job->document, job_render->page);
-	rc = ev_render_context_new (job_render->ev_page, job_render->rotation, job_render->scale);
+	rc = ev_render_context_new (job_render->ev_page, job_render->rotation, job_render->scale, job_render->inverted_colors);
 		
 	job_render->surface = ev_document_render (job->document, rc);
 	/* If job was cancelled during the page rendering,
@@ -600,7 +600,8 @@ EvJob *
 ev_job_render_new (EvDocument   *document,
 		   gint          page,
 		   gint          rotation,
-		   gdouble       scale, 
+		   gboolean      inverted_colors,
+		   gdouble       scale,
 		   gint          width,
 		   gint          height,
 		   EvRenderFlags flags)
@@ -614,6 +615,7 @@ ev_job_render_new (EvDocument   *document,
 	EV_JOB (job)->document = g_object_ref (document);
 	job->page = page;
 	job->rotation = rotation;
+	job->inverted_colors = inverted_colors;
 	job->scale = scale;
 	job->target_width = width;
 	job->target_height = height;
@@ -674,7 +676,8 @@ ev_job_thumbnail_run (EvJob *job)
 	ev_document_doc_mutex_lock ();
 
 	page = ev_document_get_page (job->document, job_thumb->page);
-	rc = ev_render_context_new (page, job_thumb->rotation, job_thumb->scale);
+	rc = ev_render_context_new (page, job_thumb->rotation, job_thumb->scale, job_thumb->inverted_colors);
+
 	g_object_unref (page);
 
 	job_thumb->thumbnail = ev_document_thumbnails_get_thumbnail (EV_DOCUMENT_THUMBNAILS (job->document),
@@ -701,7 +704,8 @@ EvJob *
 ev_job_thumbnail_new (EvDocument *document,
 		      gint        page,
 		      gint        rotation,
-		      gdouble     scale)
+		      gdouble     scale,
+		      gboolean    inverted_colors)
 {
 	EvJobThumbnail *job;
 
@@ -712,6 +716,7 @@ ev_job_thumbnail_new (EvDocument *document,
 	EV_JOB (job)->document = g_object_ref (document);
 	job->page = page;
 	job->rotation = rotation;
+	job->inverted_colors = inverted_colors;
 	job->scale = scale;
 
 	return EV_JOB (job);
@@ -1333,7 +1338,7 @@ ev_job_export_run (EvJob *job)
 		
 		ev_render_context_set_page (job_export->rc, ev_page);
 	} else {
-		job_export->rc = ev_render_context_new (ev_page, 0, 1.0);
+		job_export->rc = ev_render_context_new (ev_page, 0, 1.0, FALSE);
 	}
 	g_object_unref (ev_page);
 	
diff --git a/libview/ev-jobs.h b/libview/ev-jobs.h
index 144ec06..ec96a9a 100644
--- a/libview/ev-jobs.h
+++ b/libview/ev-jobs.h
@@ -207,6 +207,7 @@ struct _EvJobRender
 	gint page;
 	gint rotation;
 	gdouble scale;
+	gboolean inverted_colors;	
 
 	EvPage *ev_page;
 	gboolean page_ready;
@@ -244,6 +245,7 @@ struct _EvJobThumbnail
 	gint page;
 	gint rotation;
 	gdouble scale;
+	gboolean inverted_colors;
 	
 	GdkPixbuf *thumbnail;
 };
@@ -386,6 +388,7 @@ GType           ev_job_render_get_type    (void) G_GNUC_CONST;
 EvJob          *ev_job_render_new         (EvDocument      *document,
 					   gint             page,
 					   gint             rotation,
+					   gboolean         inverted_colors,
 					   gdouble          scale,
 					   gint             width,
 					   gint             height,
@@ -400,7 +403,9 @@ GType           ev_job_thumbnail_get_type (void) G_GNUC_CONST;
 EvJob          *ev_job_thumbnail_new      (EvDocument      *document,
 					   gint             page,
 					   gint             rotation,
-					   gdouble          scale);
+					   gdouble          scale,
+					   gboolean         inverted_colors);
+
 /* EvJobFonts */
 GType 		ev_job_fonts_get_type 	  (void) G_GNUC_CONST;
 EvJob 	       *ev_job_fonts_new 	  (EvDocument      *document);
diff --git a/libview/ev-pixbuf-cache.c b/libview/ev-pixbuf-cache.c
index df06705..32c28d8 100644
--- a/libview/ev-pixbuf-cache.c
+++ b/libview/ev-pixbuf-cache.c
@@ -457,11 +457,13 @@ copy_job_page_and_selection_to_job_info (EvJobRender   *job_render,
 	if (job_info->rc == NULL) {
 		job_info->rc = ev_render_context_new (job_render->ev_page,
 						      job_render->rotation,
+						      job_render->inverted_colors,
 						      job_render->scale);
 	} else {
 		ev_render_context_set_page (job_info->rc, job_render->ev_page);
 		ev_render_context_set_rotation (job_info->rc, job_render->rotation);
 		ev_render_context_set_scale (job_info->rc, job_render->scale);
+		ev_render_context_set_inverted_colors  (job_info->rc, job_render->inverted_colors);
 	}
 	
 	if (job_info->surface) {
@@ -616,6 +618,7 @@ add_job (EvPixbufCache *pixbuf_cache,
 	 gint           height,
 	 gint           page,
 	 gint           rotation,
+	 gboolean       inverted_colors,
 	 gfloat         scale,
 	 EvJobPriority  priority)
 {
@@ -640,9 +643,8 @@ add_job (EvPixbufCache *pixbuf_cache,
 		flags |= EV_RENDER_INCLUDE_TEXT;
 
 	job_info->job = ev_job_render_new (pixbuf_cache->document,
-					   page, rotation, scale,
-					   width, height,
-					   flags);
+					   page, rotation, inverted_colors,
+					   scale,width, height, flags);
 	
 	if (new_selection_surface_needed (pixbuf_cache, job_info, page, scale)) {
 		GdkColor *text, *base;
@@ -669,6 +671,7 @@ add_job_if_needed (EvPixbufCache *pixbuf_cache,
 		   CacheJobInfo  *job_info,
 		   gint           page,
 		   gint           rotation,
+		   gboolean       inverted_colors,
 		   gfloat         scale,
 		   EvJobPriority  priority)
 {
@@ -687,13 +690,14 @@ add_job_if_needed (EvPixbufCache *pixbuf_cache,
 		return;
 
 	add_job (pixbuf_cache, job_info, NULL,
-		 width, height, page, rotation, scale,
+		 width, height, page, rotation, inverted_colors, scale,
 		 priority);
 }
 
 static void
 ev_pixbuf_cache_add_jobs_if_needed (EvPixbufCache *pixbuf_cache,
 				    gint           rotation,
+				    gboolean       inverted_colors,
 				    gfloat         scale)
 {
 	CacheJobInfo *job_info;
@@ -705,7 +709,7 @@ ev_pixbuf_cache_add_jobs_if_needed (EvPixbufCache *pixbuf_cache,
 		page = pixbuf_cache->start_page + i;
 
 		add_job_if_needed (pixbuf_cache, job_info,
-				   page, rotation, scale,
+				   page, rotation, inverted_colors, scale,
 				   EV_JOB_PRIORITY_URGENT);
 	}
 
@@ -714,7 +718,7 @@ ev_pixbuf_cache_add_jobs_if_needed (EvPixbufCache *pixbuf_cache,
 		page = pixbuf_cache->start_page - pixbuf_cache->preload_cache_size + i;
 
 		add_job_if_needed (pixbuf_cache, job_info,
-				   page, rotation, scale,
+				   page, rotation, inverted_colors, scale,
 				   EV_JOB_PRIORITY_LOW);
 	}
 
@@ -723,7 +727,7 @@ ev_pixbuf_cache_add_jobs_if_needed (EvPixbufCache *pixbuf_cache,
 		page = pixbuf_cache->end_page + 1 + i;
 
 		add_job_if_needed (pixbuf_cache, job_info,
-				   page, rotation, scale,
+				   page, rotation, inverted_colors, scale,
 				   EV_JOB_PRIORITY_LOW);
 	}
 
@@ -734,6 +738,7 @@ ev_pixbuf_cache_set_page_range (EvPixbufCache  *pixbuf_cache,
 				gint            start_page,
 				gint            end_page,
 				gint            rotation,
+				gboolean        inverted_colors,
 				gfloat          scale,
 				GList          *selection_list)
 {
@@ -756,7 +761,7 @@ ev_pixbuf_cache_set_page_range (EvPixbufCache  *pixbuf_cache,
 
 	/* Finally, we add the new jobs for all the sizes that don't have a
 	 * pixbuf */
-	ev_pixbuf_cache_add_jobs_if_needed (pixbuf_cache, rotation, scale);
+	ev_pixbuf_cache_add_jobs_if_needed (pixbuf_cache, rotation, inverted_colors, scale);
 }
 
 cairo_surface_t *
@@ -1002,7 +1007,7 @@ ev_pixbuf_cache_get_selection_surface (EvPixbufCache  *pixbuf_cache,
 	if (job_info->rc == NULL) {
 		EvPage  *ev_page;
 		ev_page = ev_document_get_page (pixbuf_cache->document, page);
-		job_info->rc = ev_render_context_new (ev_page, 0, scale);
+		job_info->rc = ev_render_context_new (ev_page, 0, scale, FALSE);
 		g_object_unref (ev_page);
 	}
 
@@ -1240,6 +1245,7 @@ ev_pixbuf_cache_reload_page (EvPixbufCache *pixbuf_cache,
 			     GdkRegion     *region,
 			     gint           page,
 			     gint           rotation,
+			     gboolean       inverted_colors,
 			     gdouble        scale)
 {
 	CacheJobInfo *job_info;
@@ -1253,7 +1259,7 @@ ev_pixbuf_cache_reload_page (EvPixbufCache *pixbuf_cache,
 					       page, scale, rotation,
 					       &width, &height);
         add_job (pixbuf_cache, job_info, region,
-		 width, height, page, rotation, scale,
+		 width, height, page, rotation, inverted_colors, scale,
 		 EV_JOB_PRIORITY_URGENT);
 }
 
diff --git a/libview/ev-pixbuf-cache.h b/libview/ev-pixbuf-cache.h
index 4ab0fce..a00b8de 100644
--- a/libview/ev-pixbuf-cache.h
+++ b/libview/ev-pixbuf-cache.h
@@ -60,6 +60,7 @@ void           ev_pixbuf_cache_set_page_range       (EvPixbufCache *pixbuf_cache
 						     gint           start_page,
 						     gint           end_page,
 						     gint	    rotation,
+						     gboolean	    inverted_colors,
 						     gfloat         scale,
 						     GList          *selection_list);
 cairo_surface_t *ev_pixbuf_cache_get_surface        (EvPixbufCache *pixbuf_cache,
@@ -80,7 +81,8 @@ void           ev_pixbuf_cache_reload_page 	    (EvPixbufCache *pixbuf_cache,
 						     GdkRegion     *region,
                     				     gint           page,
 			                             gint           rotation,
-                         			     gdouble         scale);
+			                             gboolean       inverted_colors,
+                         			     gdouble        scale);
 /* Selection */
 cairo_surface_t *ev_pixbuf_cache_get_selection_surface (EvPixbufCache *pixbuf_cache,
 							gint           page,
diff --git a/libview/ev-stock-icons.c b/libview/ev-stock-icons.c
index d450462..67db47c 100644
--- a/libview/ev-stock-icons.c
+++ b/libview/ev-stock-icons.c
@@ -45,7 +45,8 @@ static const EvStockIcon stock_icons [] = {
 	{ EV_STOCK_VISIBLE,          "eye"},
 	{ EV_STOCK_RESIZE_SE,        "resize-se"},
 	{ EV_STOCK_RESIZE_SW,        "resize-sw"},
-	{ EV_STOCK_CLOSE,            "close"}
+	{ EV_STOCK_CLOSE,            "close"},
+	{ EV_STOCK_INVERTED_COLORS,  "stock_filters-invert"}
 };
 
 static gchar *ev_icons_path;
diff --git a/libview/ev-stock-icons.h b/libview/ev-stock-icons.h
index 4cad90e..550ff04 100644
--- a/libview/ev-stock-icons.h
+++ b/libview/ev-stock-icons.h
@@ -45,6 +45,7 @@ G_BEGIN_DECLS
 #define EV_STOCK_RESIZE_SE              "resize-se"
 #define EV_STOCK_RESIZE_SW              "resize-sw"
 #define EV_STOCK_CLOSE                  "close"
+#define EV_STOCK_INVERTED_COLORS        "inverted"
 
 void ev_stock_icons_init       (void);
 void ev_stock_icons_shutdown   (void);
diff --git a/libview/ev-view-private.h b/libview/ev-view-private.h
index c3c7554..a5f3652 100644
--- a/libview/ev-view-private.h
+++ b/libview/ev-view-private.h
@@ -160,6 +160,8 @@ struct _EvView {
 
 	gint rotation;
 	gdouble scale;
+	gboolean inverted_colors;
+
 	gint spacing;
 
 	gboolean loading;
diff --git a/libview/ev-view.c b/libview/ev-view.c
index 973da90..6f2652e 100644
--- a/libview/ev-view.c
+++ b/libview/ev-view.c
@@ -44,6 +44,7 @@
 #include "ev-view-private.h"
 #include "ev-view-type-builtins.h"
 
+
 #define EV_VIEW_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), EV_TYPE_VIEW, EvViewClass))
 #define EV_IS_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EV_TYPE_VIEW))
 #define EV_VIEW_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), EV_TYPE_VIEW, EvViewClass))
@@ -57,6 +58,7 @@ enum {
 	PROP_SIZING_MODE,
 	PROP_ZOOM,
 	PROP_ROTATION,
+	PROP_INVERTED_COLORS,
 	PROP_HAS_SELECTION,
 };
 
@@ -700,6 +702,7 @@ view_update_range_and_current_page (EvView *view)
 					view->start_page,
 					view->end_page,
 					view->rotation,
+					view->inverted_colors,
 					view->scale,
 					view->selection_info.selections);
 }
@@ -814,7 +817,8 @@ compute_scroll_increment (EvView        *view,
 		EvPage  *ev_page;
 
 		ev_page = ev_document_get_page (view->document, page);
-		rc = ev_render_context_new (ev_page, view->rotation, view->scale);
+		rc = ev_render_context_new (ev_page, view->rotation,
+					    view->scale, view->inverted_colors);
 		g_object_unref (ev_page);
 		/* Get the selection region to know the height of the line */
 		doc_rect.x1 = doc_rect.x2 = recs[0].x + 0.5;
@@ -4568,6 +4572,9 @@ ev_view_set_property (GObject      *object,
 	        case PROP_ROTATION:
 			ev_view_set_rotation (view, g_value_get_int (value));
 			break;
+	        case PROP_INVERTED_COLORS:
+			ev_view_set_inverted_colors (view, g_value_get_boolean (value));
+			break;
 	        default:
 			G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
 	}
@@ -4634,6 +4641,9 @@ ev_view_get_property (GObject *object,
 	        case PROP_ROTATION:
 			g_value_set_int (value, view->rotation);
 			break;
+	        case PROP_INVERTED_COLORS:
+			g_value_set_boolean (value, view->inverted_colors);
+			break;
 	        case PROP_HAS_SELECTION:
 			g_value_set_boolean (value,
 					     view->selection_info.selections != NULL);
@@ -4776,6 +4786,13 @@ ev_view_class_init (EvViewClass *class)
 							      G_PARAM_READWRITE));
 
 	g_object_class_install_property (object_class,
+					 PROP_INVERTED_COLORS,
+					 g_param_spec_boolean ("inverted-colors",
+							       "inverted colors",
+							       "inverted colors",
+							       FALSE,
+							       G_PARAM_READWRITE));
+	g_object_class_install_property (object_class,
 					 PROP_HAS_SELECTION,
 					 g_param_spec_boolean ("has-selection",
 							       "Has selection",
@@ -5179,6 +5196,21 @@ ev_view_rotation_changed_cb (EvDocumentModel *model,
 }
 
 static void
+ev_view_inverted_colors_changed_cb (EvDocumentModel *model,
+			     GParamSpec      *pspec,
+			     EvView          *view)
+{
+	gboolean inverted_colors = ev_document_model_get_inverted_colors (model);
+
+	ev_view_set_inverted_colors (view, inverted_colors);
+
+	if (view->pixbuf_cache) {
+		ev_pixbuf_cache_clear (view->pixbuf_cache);
+		gtk_widget_queue_resize (GTK_WIDGET (view));
+	}
+}
+
+static void
 ev_view_sizing_mode_changed_cb (EvDocumentModel *model,
 				GParamSpec      *pspec,
 				EvView          *view)
@@ -5277,6 +5309,9 @@ ev_view_set_model (EvView          *view,
 	g_signal_connect (view->model, "notify::rotation",
 			  G_CALLBACK (ev_view_rotation_changed_cb),
 			  view);
+	g_signal_connect (view->model, "notify::inverted-colors",
+			  G_CALLBACK (ev_view_inverted_colors_changed_cb),
+			  view);
 	g_signal_connect (view->model, "notify::sizing-mode",
 			  G_CALLBACK (ev_view_sizing_mode_changed_cb),
 			  view);
@@ -5306,6 +5341,7 @@ ev_view_reload_page (EvView    *view,
 				     region,
 				     page,
 				     view->rotation,
+				     view->inverted_colors,
 				     view->scale);
 }
 
@@ -5544,6 +5580,7 @@ ev_view_zoom_out (EvView *view)
 	ev_document_model_set_scale (view->model, scale);
 }
 
+
 void
 ev_view_set_rotation (EvView *view, int rotation)
 {
@@ -5558,6 +5595,28 @@ ev_view_get_rotation (EvView *view)
 	return view->rotation;
 }
 
+void
+ev_view_set_inverted_colors (EvView *view, gboolean inverted_colors)
+{
+	view->inverted_colors = inverted_colors;
+
+	if (view->pixbuf_cache) {
+		ev_pixbuf_cache_clear (view->pixbuf_cache);
+		gtk_widget_queue_resize (GTK_WIDGET (view));
+	}
+
+	if (inverted_colors)
+		clear_selection (view);
+
+	g_object_notify (G_OBJECT (view), "inverted-colors");
+}
+
+gboolean
+ev_view_get_inverted_colors (EvView *view)
+{
+	return view->inverted_colors;
+}
+
 static double
 zoom_for_size_fit_width (gdouble doc_width,
 			 gdouble doc_height,
@@ -6278,7 +6337,7 @@ get_selected_text (EvView *view)
 	EvRenderContext *rc;
 
 	text = g_string_new (NULL);
-	rc = ev_render_context_new (NULL, view->rotation, view->scale);
+	rc = ev_render_context_new (NULL, view->rotation, view->scale, view->inverted_colors);
 
 	ev_document_doc_mutex_lock ();
 
diff --git a/libview/ev-view.h b/libview/ev-view.h
index fde6854..ca5dd64 100644
--- a/libview/ev-view.h
+++ b/libview/ev-view.h
@@ -94,6 +94,10 @@ void            ev_view_rotate_right      (EvView         *view);
 void            ev_view_set_rotation      (EvView         *view,
 					   int             rotation);
 int             ev_view_get_rotation      (EvView         *view);
+void            ev_view_inverted_colors     (EvView         *view);
+void            ev_view_set_inverted_colors (EvView         *view,
+					     gboolean        inverted_colors);
+gboolean        ev_view_get_inverted_colors (EvView         *view);
 
 /* Find */
 void            ev_view_find_next                 (EvView         *view);
diff --git a/shell/ev-sidebar-thumbnails.c b/shell/ev-sidebar-thumbnails.c
index 78784ed..075bb11 100644
--- a/shell/ev-sidebar-thumbnails.c
+++ b/shell/ev-sidebar-thumbnails.c
@@ -72,6 +72,7 @@ struct _EvSidebarThumbnailsPrivate {
 	gint n_pages, pages_done;
 
 	int rotation;
+	gboolean inverted_colors;
 
 	/* Visible pages */
 	gint start_page, end_page;
@@ -138,7 +139,7 @@ ev_thumbnails_size_cache_new (EvDocument *document)
 		ev_document_get_page_size (document, i, &page_width, &page_height);
 
 		if (!rc) {
-			rc = ev_render_context_new (page, 0, (gdouble)THUMBNAIL_WIDTH / page_width);
+			rc = ev_render_context_new (page, 0, (gdouble)THUMBNAIL_WIDTH / page_width, FALSE);
 		} else {
 			ev_render_context_set_page (rc, page);
 			ev_render_context_set_scale (rc, (gdouble)THUMBNAIL_WIDTH / page_width);
@@ -441,7 +442,8 @@ add_range (EvSidebarThumbnails *sidebar_thumbnails,
 		if (job == NULL && !thumbnail_set) {
 			job = ev_job_thumbnail_new (priv->document,
 						    page, priv->rotation,
-						    get_scale_for_page (sidebar_thumbnails, page));
+						    get_scale_for_page (sidebar_thumbnails, page),
+						    priv->inverted_colors);
 			ev_job_scheduler_push_job (EV_JOB (job), EV_JOB_PRIORITY_HIGH);
 			
 			g_object_set_data_full (G_OBJECT (job), "tree_iter",
@@ -791,6 +793,34 @@ ev_sidebar_thumbnails_rotation_changed_cb (EvDocumentModel     *model,
 }
 
 static void
+ev_sidebar_thumbnails_inverted_colors_changed_cb (EvDocumentModel     *model,
+ 					   GParamSpec          *pspec,
+ 					   EvSidebarThumbnails *sidebar_thumbnails)
+{
+	gboolean inverted_colors = ev_document_model_get_inverted_colors (model);
+
+	sidebar_thumbnails->priv->inverted_colors = inverted_colors;
+	if (sidebar_thumbnails->priv->loading_icons)
+		g_hash_table_remove_all (sidebar_thumbnails->priv->loading_icons);
+ 
+	if (sidebar_thumbnails->priv->document == NULL ||
+	    sidebar_thumbnails->priv->n_pages <= 0)
+		return;
+ 
+	ev_sidebar_thumbnails_clear_model (sidebar_thumbnails);
+	ev_sidebar_thumbnails_fill_model (sidebar_thumbnails);
+ 	
+	sidebar_thumbnails->priv->start_page = -1;
+	sidebar_thumbnails->priv->end_page = -1;
+ 
+	/* Remarks the current thumbnail */
+	ev_sidebar_thumbnails_set_current_page (sidebar_thumbnails, 
+ 						ev_document_model_get_page (model));
+	/* Trigger a redraw */
+	g_idle_add ((GSourceFunc)refresh, sidebar_thumbnails);
+}
+
+static void
 thumbnail_job_completed_callback (EvJobThumbnail      *job,
 				  EvSidebarThumbnails *sidebar_thumbnails)
 {
@@ -864,6 +894,9 @@ ev_sidebar_thumbnails_document_changed_cb (EvDocumentModel     *model,
 	g_signal_connect (priv->model, "notify::rotation",
 			  G_CALLBACK (ev_sidebar_thumbnails_rotation_changed_cb),
 			  sidebar_thumbnails);
+	g_signal_connect (priv->model, "notify::inverted-colors",
+			  G_CALLBACK (ev_sidebar_thumbnails_inverted_colors_changed_cb),
+			  sidebar_thumbnails);
 	sidebar_thumbnails->priv->start_page = -1;
 	sidebar_thumbnails->priv->end_page = -1;
 	ev_sidebar_thumbnails_set_current_page (sidebar_thumbnails,
@@ -936,3 +969,47 @@ ev_sidebar_thumbnails_page_iface_init (EvSidebarPageIface *iface)
 	iface->get_label = ev_sidebar_thumbnails_get_label;
 }
 
+
+void
+ev_sidebar_thumbnails_refresh_rotation (EvSidebarThumbnails *sidebar_thumbnails,
+				        int                  rotation)
+{
+	sidebar_thumbnails->priv->rotation = rotation;
+	if (sidebar_thumbnails->priv->loading_icons)
+		g_hash_table_remove_all (sidebar_thumbnails->priv->loading_icons);
+
+	if (sidebar_thumbnails->priv->document == NULL ||
+	    sidebar_thumbnails->priv->n_pages <= 0)
+		return;
+
+	ev_sidebar_thumbnails_clear_model (sidebar_thumbnails);
+	ev_sidebar_thumbnails_fill_model (sidebar_thumbnails);
+
+	/* Trigger a redraw */
+	sidebar_thumbnails->priv->start_page = -1;
+	sidebar_thumbnails->priv->end_page = -1;
+	g_idle_add ((GSourceFunc)refresh, sidebar_thumbnails);
+}
+
+void       
+ev_sidebar_thumbnails_refresh_inverted_colors (EvSidebarThumbnails *sidebar_thumbnails,
+					     gboolean              inverted_colors)
+{
+/*
+	sidebar_thumbnails->priv->inverted_colors = inverted_colors;
+	if (sidebar_thumbnails->priv->loading_icons)
+		g_hash_table_remove_all (sidebar_thumbnails->priv->loading_icons);
+
+	if (sidebar_thumbnails->priv->document == NULL ||
+	    sidebar_thumbnails->priv->n_pages <= 0)
+		return;
+
+	ev_sidebar_thumbnails_clear_model (sidebar_thumbnails);
+	ev_sidebar_thumbnails_fill_model (sidebar_thumbnails);
+*/
+	/* Trigger a redraw */
+	sidebar_thumbnails->priv->start_page = -1;
+	sidebar_thumbnails->priv->end_page = -1;
+	g_idle_add ((GSourceFunc)refresh, sidebar_thumbnails);
+}
+
diff --git a/shell/ev-sidebar-thumbnails.h b/shell/ev-sidebar-thumbnails.h
index d49836d..ff73684 100644
--- a/shell/ev-sidebar-thumbnails.h
+++ b/shell/ev-sidebar-thumbnails.h
@@ -49,8 +49,12 @@ struct _EvSidebarThumbnailsClass {
 	GtkVBoxClass base_class;
 };
 
-GType      ev_sidebar_thumbnails_get_type     (void) G_GNUC_CONST;
-GtkWidget *ev_sidebar_thumbnails_new          (void);
+GType      ev_sidebar_thumbnails_get_type              (void) G_GNUC_CONST;
+GtkWidget *ev_sidebar_thumbnails_new                   (void);
+void       ev_sidebar_thumbnails_refresh_rotation      (EvSidebarThumbnails *sidebar_thumbnails,
+							int                  rotation);
+void       ev_sidebar_thumbnails_refresh_inverted_colors (EvSidebarThumbnails *sidebar_thumbnails,
+							  gboolean             inverted_colors);
 
 G_END_DECLS
 
diff --git a/shell/ev-window.c b/shell/ev-window.c
index 97c9aa1..660c681 100644
--- a/shell/ev-window.c
+++ b/shell/ev-window.c
@@ -1,6 +1,7 @@
 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8; c-indent-level: 8 -*- */
 /* this file is part of evince, a gnome document viewer
  *
+ *  Copyright (C) 2009 Juanjo Marin
  *  Copyright (C) 2008 Carlos Garcia Campos
  *  Copyright (C) 2004 Martin Kretzschmar
  *  Copyright (C) 2004 Red Hat, Inc.
@@ -90,6 +91,7 @@
 #include "ev-print-operation.h"
 #include "ev-progress-message-area.h"
 
+
 #ifdef ENABLE_DBUS
 #include "ev-media-player-keys.h"
 #endif /* ENABLE_DBUS */
@@ -398,6 +400,7 @@ ev_window_setup_action_sensitivity (EvWindow *ev_window)
 	ev_window_set_action_sensitive (ev_window, "Slash", can_find);
 	ev_window_set_action_sensitive (ev_window, "EditRotateLeft", has_pages);
 	ev_window_set_action_sensitive (ev_window, "EditRotateRight", has_pages);
+	ev_window_set_action_sensitive (ev_window, "ViewInvertedColors", has_pages);
 
         /* View menu */
 	ev_window_set_action_sensitive (ev_window, "ViewContinuous", has_pages);
@@ -928,6 +931,7 @@ setup_model_from_metadata (EvWindow *window)
 	gchar   *sizing_mode;
 	gdouble  zoom;
 	gint     rotation;
+	gboolean inverted_colors = { 0, };
 	gboolean continuous = { 0, };
 	gboolean dual_page = { 0, };
 	gboolean fullscreen = { 0, };
@@ -974,7 +978,13 @@ setup_model_from_metadata (EvWindow *window)
 		}
 		ev_document_model_set_rotation (window->priv->model, rotation);
 	}
-
+	
+	/* Inverted Colors */
+	if (ev_metadata_get_boolean (window->priv->metadata, "inverted_colors",
+	    &inverted_colors)) {
+		ev_document_model_set_inverted_colors (window->priv->model,
+		                                     inverted_colors);
+	}
 	/* Continuous */
 	if (ev_metadata_get_boolean (window->priv->metadata, "continuous", &continuous)) {
 		ev_document_model_set_continuous (window->priv->model, continuous);
@@ -1124,7 +1134,7 @@ ev_window_set_icon_from_thumbnail (EvJobThumbnail *job,
 }
 
 static void
-ev_window_refresh_window_thumbnail (EvWindow *ev_window, int rotation)
+ev_window_refresh_window_thumbnail (EvWindow *ev_window, int rotation, gboolean inverted_colors)
 {
 	gdouble page_width;
 	gdouble scale;
@@ -1141,7 +1151,7 @@ ev_window_refresh_window_thumbnail (EvWindow *ev_window, int rotation)
 	ev_document_get_page_size (document, 0, &page_width, NULL);
 	scale = 128. / page_width;
 
-	ev_window->priv->thumbnail_job = ev_job_thumbnail_new (document, 0, rotation, scale);
+	ev_window->priv->thumbnail_job = ev_job_thumbnail_new (document, 0, rotation, scale, inverted_colors);
 	g_signal_connect (ev_window->priv->thumbnail_job, "finished",
 			  G_CALLBACK (ev_window_set_icon_from_thumbnail),
 			  ev_window);
@@ -1157,7 +1167,7 @@ ev_window_setup_document (EvWindow *ev_window)
 
 	ev_window->priv->setup_document_idle = 0;
 	
-	ev_window_refresh_window_thumbnail (ev_window, 0);
+	ev_window_refresh_window_thumbnail (ev_window, 0, FALSE);
 
 	ev_window_set_page_mode (ev_window, PAGE_MODE_DOCUMENT);
 	ev_window_title_set_document (ev_window->priv->title, document);
@@ -3692,6 +3702,14 @@ ev_window_cmd_edit_rotate_right (GtkAction *action, EvWindow *ev_window)
 }
 
 static void
+ev_window_cmd_edit_inverted_colors (GtkAction *action, EvWindow *ev_window)
+{
+	gboolean inverted_colors = 
+		   ev_document_model_get_inverted_colors (ev_window->priv->model);
+	ev_document_model_set_inverted_colors (ev_window->priv->model, !inverted_colors);
+}
+
+static void
 ev_window_cmd_edit_toolbar_cb (GtkDialog *dialog, gint response, gpointer data)
 {
 	EvWindow *ev_window = EV_WINDOW (data);
@@ -3995,12 +4013,26 @@ ev_window_rotation_changed_cb (EvDocumentModel *model,
 			       EvWindow        *window)
 {
 	gint rotation = ev_document_model_get_rotation (model);
-
+	gboolean inverted_colors = ev_document_model_get_inverted_colors (model);
+	
 	if (window->priv->metadata && !ev_window_is_empty (window))
 		ev_metadata_set_int (window->priv->metadata, "rotation",
 				     rotation);
+	ev_window_refresh_window_thumbnail (window, rotation, inverted_colors);
+}
 
-	ev_window_refresh_window_thumbnail (window, rotation);
+static void
+ev_window_inverted_colors_changed_cb (EvDocumentModel *model,
+			              GParamSpec      *pspec,
+			              EvWindow        *window)
+{
+	gint rotation = ev_document_model_get_rotation (model);	
+	gboolean inverted_colors = ev_document_model_get_inverted_colors (model);
+	
+	if (window->priv->metadata && !ev_window_is_empty (window))
+		ev_metadata_set_boolean (window->priv->metadata, "inverted-colors",
+					 inverted_colors);
+	ev_window_refresh_window_thumbnail (window, rotation, inverted_colors);
 }
 
 static void
@@ -4874,6 +4906,7 @@ static const GtkActionEntry entries[] = {
 	{ "EditRotateRight", EV_STOCK_ROTATE_RIGHT, N_("Rotate _Right"), "<control>Right", NULL,
 	  G_CALLBACK (ev_window_cmd_edit_rotate_right) },
 
+
         /* View menu */
         { "ViewZoomIn", GTK_STOCK_ZOOM_IN, NULL, "<control>plus",
           N_("Enlarge the document"),
@@ -4993,6 +5026,9 @@ static const GtkToggleActionEntry toggle_entries[] = {
         { "ViewPageWidth", EV_STOCK_ZOOM_WIDTH, N_("Fit Page _Width"), NULL,
           N_("Make the current document fill the window width"),
           G_CALLBACK (ev_window_cmd_view_page_width) },
+	{ "ViewInvertedColors", EV_STOCK_INVERTED_COLORS, N_("_Inverted Colors"), "<control>I", NULL,
+	  G_CALLBACK (ev_window_cmd_edit_inverted_colors) },
+
 };
 
 /* Popups specific items */
@@ -6067,6 +6103,10 @@ ev_window_init (EvWindow *ev_window)
 			  ev_window);
 
 	/* Connect to view signals */
+	g_signal_connect (ev_window->priv->model,
+			  "notify::inverted-colors",
+			  G_CALLBACK (ev_window_inverted_colors_changed_cb),
+			  ev_window);
 	g_signal_connect (ev_window->priv->view,
 			  "notify::has-selection",
 			  G_CALLBACK (ev_window_has_selection_changed_cb),
diff --git a/thumbnailer/evince-thumbnailer.c b/thumbnailer/evince-thumbnailer.c
index 31486bf..14ee58f 100644
--- a/thumbnailer/evince-thumbnailer.c
+++ b/thumbnailer/evince-thumbnailer.c
@@ -86,7 +86,7 @@ evince_thumbnail_pngenc_get (EvDocument *document, const char *thumbnail, int si
 	
 	ev_document_get_page_size (document, 0, &width, &height);
 
-	rc = ev_render_context_new (page, 0, size / width);
+	rc = ev_render_context_new (page, 0, size / width, FALSE);
 	pixbuf = ev_document_thumbnails_get_thumbnail (EV_DOCUMENT_THUMBNAILS (document),
 						       rc, FALSE);
 	g_object_unref (rc);
