diff -u --recursive --new-file gpdf-tools/configure.in gpdf/configure.in
--- gpdf-tools/configure.in	2003-09-25 14:16:45.000000000 -0500
+++ gpdf/configure.in	2003-10-20 00:41:24.000000000 -0500
@@ -130,6 +130,14 @@
                            [set app-defaults directory]),
             AC_DEFINE_UNQUOTED(APPDEFDIR, "$with_appdef_dir"))
 
+AH_TEMPLATE([WITH_GPDF_HIGHLIGHTS],
+            [Enable document highlighting suport.])
+AC_ARG_WITH(highlighting,
+            AC_HELP_STRING([--with-highlighting],
+                           [enable document highlighting support]),
+            AC_DEFINE_UNQUOTED(WITH_GPDF_HIGHLIGHTS, "$with_appdef_dir"))
+
+
 dnl ##### Path to xpdfrc.
 dnl This ugly kludge to get the sysconfdir path is needed because
 dnl autoconf doesn't actually set the prefix variable until later.
diff -u --recursive --new-file gpdf-tools/xpdf/Makefile.am gpdf/xpdf/Makefile.am
--- gpdf-tools/xpdf/Makefile.am	2003-10-20 00:38:38.000000000 -0500
+++ gpdf/xpdf/Makefile.am	2003-10-20 00:41:57.000000000 -0500
@@ -150,6 +150,8 @@
 	gpdf-util.h			\
 	gpdf-view.cc			\
 	gpdf-view.h			\
+	gpdf-highlights.cc              \
+	gpdf-highlights.h               \
 	gpdf-bookmarks-view.cc		\
 	gpdf-bookmarks-view.h		\
 	gpdf-thumbnails-view.cc		\
diff -u --recursive --new-file gpdf-tools/xpdf/gpdf-annots-view.cc gpdf/xpdf/gpdf-annots-view.cc
--- gpdf-tools/xpdf/gpdf-annots-view.cc	2003-09-29 18:17:19.000000000 -0500
+++ gpdf/xpdf/gpdf-annots-view.cc	2003-10-20 01:32:41.000000000 -0500
@@ -76,6 +76,10 @@
         Annot *annot;
 	gint refnum;
 	gint refgen;
+#ifdef WITH_GPDF_HIGHLIGHTS
+	gint gpdf_highlight;
+#endif /* WITH_GPDF_HIGHLIGHTS */
+
 } GPdfAnnotData;
 
 static const gchar * const gpdf_annotation_types_str[NUM_ANNOT_TYPES] = {
@@ -587,6 +591,52 @@
 	
 }
 
+#ifdef WITH_GPDF_HIGHLIGHTS
+gboolean
+gpdf_annots_view_highlights_displayed(GPdfAnnotsView *annots_view, gint page)
+{
+       GPdfAnnotsViewPrivate *priv;
+       GtkTreeModel *model;
+       GtkTreeIter iter;
+       gboolean active = FALSE;
+        GPdfAnnotData *annot_data;
+       gboolean found = FALSE;
+
+       g_return_val_if_fail (GPDF_IS_NON_NULL_ANNOTS_VIEW (annots_view),
+                             gTrue);
+
+       priv = annots_view->priv;
+
+       if (!GTK_IS_TREE_MODEL (priv->model))
+         return gTrue;
+
+       model = GTK_TREE_MODEL (priv->model);
+
+       if (gtk_tree_model_get_iter_first (model, &iter))
+       {
+               do
+               {
+                       gtk_tree_model_get (model, &iter,
+                                           GPDF_ANNVIEW_COLUMN3, &active,
+                                           GPDF_ANNVIEW_COLUMN4, &annot_data,
+                                           -1);
+                       if (! annot_data->annot &&
+                               annot_data->page_nr == priv->current_page) {
+                               found = TRUE;
+                               break;
+                       }
+               }
+               while (model && gtk_tree_model_iter_next (model, &iter));
+
+               /* Just to be warned */
+               // Might not exist
+               // g_assert (found);
+       }
+       return (((found && active) || !found) ? gTrue : gFalse);
+}
+#endif /* WITH_GPDF_HIGHLIGHTS */
+
+
 gboolean
 gpdf_annots_view_is_annot_displayed (Annot *annot, gpointer user_data)
 {
@@ -657,6 +707,27 @@
         num_annots = annots->getNumAnnots ();
 
         //g_message ("Page #%d have %d annots", page_nr, num_annots);
+	
+#ifdef WITH_GPDF_HIGHLIGHTS
+       if (gpdf_view_page_highlighted(priv->gpdf_view, page_nr)) {
+               /* Allocate annotation assiociated data */
+               annot_data = g_new0 (GPdfAnnotData, 1);
+               annot_data->page_nr = page_nr;
+               annot_data->annot = NULL;
+               annot_data->type = GPDF_ANNOT_TYPE_HIGHLIGHT;
+               annot_data->refnum = -1;
+               annot_data->refgen = -1;
+               annot_data->gpdf_highlight = 1;
+               /* Add an item to the list model */
+               gtk_list_store_append (GTK_LIST_STORE (priv->model), iter);
+               gtk_list_store_set (GTK_LIST_STORE (priv->model), iter,
+                                   GPDF_ANNVIEW_COLUMN1, priv->stock_annots_pixbuf[GPDF_ANNOT_TYPE_HIGHLIGHT],
+                                   GPDF_ANNVIEW_COLUMN2, "GPDF Highlight",
+                                   GPDF_ANNVIEW_COLUMN3, TRUE,
+                                   GPDF_ANNVIEW_COLUMN4, (gpointer)annot_data,
+                                   -1);
+       }
+#endif /* WITH_GPDF_HIGHLIGHTS */
 
         if (!num_annots) return;
               
@@ -673,7 +744,11 @@
                 annot_data->type = gpdf_annots_view_get_annot_subtype (annot);
 		annot_data->refnum = annot->getRefNum ();
 		annot_data->refgen = annot->getRefGen ();
-
+#ifdef WITH_GPDF_HIGHLIGHTS
+		annot_data->gpdf_highlight = 0;
+#endif /* WITH_GPDF_HIGHLIGHTS */
+	
+		
                 //g_message ("Processing annot #%d of type '%s' in page #%d",
 		//	   annot_nr, 
 		//	   gpdf_annotation_types_str[annot_data->type], 
diff -u --recursive --new-file gpdf-tools/xpdf/gpdf-annots-view.h gpdf/xpdf/gpdf-annots-view.h
--- gpdf-tools/xpdf/gpdf-annots-view.h	2003-09-29 18:17:19.000000000 -0500
+++ gpdf/xpdf/gpdf-annots-view.h	2003-10-20 00:46:26.000000000 -0500
@@ -65,6 +65,10 @@
 void	   gpdf_annots_view_show	   (GPdfAnnotsView*);
 GtkWidget* gpdf_annots_view_get_tools_menu (GPdfAnnotsView*);
 gboolean   gpdf_annots_view_is_annot_displayed (Annot *annot, gpointer user_data);
+#ifdef WITH_GPDF_HIGHLIGHTS
+gboolean gpdf_annots_view_highlights_displayed(GPdfAnnotsView *annots_view, gint page);
+#endif /* WITH_GPDF_HIGHLIGHTS */
+
 
 G_END_DECLS
 
diff -u --recursive --new-file gpdf-tools/xpdf/gpdf-control-private.h gpdf/xpdf/gpdf-control-private.h
--- gpdf-tools/xpdf/gpdf-control-private.h	2003-10-20 00:38:38.000000000 -0500
+++ gpdf/xpdf/gpdf-control-private.h	2003-10-20 00:48:04.000000000 -0500
@@ -11,6 +11,7 @@
 #ifndef GPDF_CONTROL_PRIVATE_H
 #define GPDF_CONTROL_PRIVATE_H
 
+#include <aconf.h>
 #include "gpdf-control.h"
 
 BEGIN_EXTERN_C
@@ -59,6 +60,9 @@
 /* Get annotations view */
 GtkWidget*	gpdf_control_private_get_annots_view	(GPdfControl * control);
 
+/* Get window title (should be URI) */
+char *gpdf_control_private_get_title (GPdfControl * control);
+
 /* Get current tool */
 GPdfControlTool  gpdf_control_private_get_current_tool  (GPdfControl * control);
 
diff -u --recursive --new-file gpdf-tools/xpdf/gpdf-control-ui.xml gpdf/xpdf/gpdf-control-ui.xml
--- gpdf-tools/xpdf/gpdf-control-ui.xml	2003-10-20 00:38:38.000000000 -0500
+++ gpdf/xpdf/gpdf-control-ui.xml	2003-10-20 00:49:51.000000000 -0500
@@ -32,6 +32,9 @@
     <cmd name="Scroll" _label="_Scroll"
       _tip="Scroll viewable portion of page"/>
 
+    <cmd name="Highlight"  _label="_Highlight"
+      _tip="Highlight document"/>
+
     <cmd name="EditFind"  _label="_Find Text"
       _tip="Find text in document" accel="*Control*F"
       pixtype="stock" pixname="gtk-find"/>
@@ -175,6 +178,7 @@
 
     <toolitem name="Select" _label="Select" verb=""/>
     <toolitem name="Scroll" _label="Scroll" verb=""/>
+    <toolitem name="Highlight" _label="Highlight" verb=""/>
 
   </dockitem>
 
diff -u --recursive --new-file gpdf-tools/xpdf/gpdf-control.cc gpdf/xpdf/gpdf-control.cc
--- gpdf-tools/xpdf/gpdf-control.cc	2003-10-20 00:38:38.000000000 -0500
+++ gpdf/xpdf/gpdf-control.cc	2003-10-20 01:28:04.000000000 -0500
@@ -422,6 +422,12 @@
 	return control->priv->current_tool;
 }
 
+char *
+gpdf_control_private_get_title (GPdfControl * control)
+{
+	return control->priv->title; /* should be URI */
+}
+
 static void
 gpdf_control_private_destroy_dialog (GtkWidget *w, GtkWidget *dlg)
 {
@@ -771,6 +777,24 @@
        gpdf_control_set_current_tool((GPdfControl *)user_data, GPDF_TOOL_SCROLL, cursor);
 }
 
+#ifdef WITH_GPDF_HIGHLIGHTS
+static void
+verb_Highlight_cb (BonoboUIComponent * uic, gpointer user_data,
+                const char *cname)
+{
+	GPdfControlPrivate *priv;
+	GdkDisplay *display;
+	GdkCursor *cursor;
+
+	g_return_if_fail(GPDF_IS_NON_NULL_CONTROL(user_data));
+
+	priv = ((GPdfControl *) user_data)->priv;
+	display = gtk_widget_get_display(priv->vbox);
+	cursor = gdk_cursor_new_for_display(display, GDK_PENCIL);
+	gpdf_control_set_current_tool((GPdfControl *)user_data, GPDF_TOOL_HIGHLIGHT, cursor);
+}
+#endif /* WITH_GPDF_HIGHLIGHTS */
+
 
 static void
 verb_GoHistoryPrev_cb (BonoboUIComponent *uic, gpointer user_data,
@@ -1230,6 +1254,10 @@
 
 	BONOBO_UI_VERB ("Select",         verb_Select_cb),
 	BONOBO_UI_VERB ("Scroll",         verb_Scroll_cb),
+#ifdef WITH_GPDF_HIGHLIGHTS
+	BONOBO_UI_VERB ("Highlight",      verb_Highlight_cb),
+#endif /* WITH_GPDF_HIGHLIGHTS */
+
 
 	BONOBO_UI_VERB ("EditSelectAll",  verb_EditSelectAll_cb),
 	BONOBO_UI_VERB ("EditCopy",   	  verb_EditCopy_cb),
diff -u --recursive --new-file gpdf-tools/xpdf/gpdf-control.h gpdf/xpdf/gpdf-control.h
--- gpdf-tools/xpdf/gpdf-control.h	2003-10-20 00:38:38.000000000 -0500
+++ gpdf/xpdf/gpdf-control.h	2003-10-20 00:59:07.000000000 -0500
@@ -14,6 +14,7 @@
 #include "gpdf-g-switch.h"
 #  include <bonobo/bonobo-control.h>
 #include "gpdf-g-switch.h"
+#include <aconf.h>
 
 G_BEGIN_DECLS
 
@@ -39,7 +40,10 @@
 
 enum GPdfControlTool {
 	GPDF_TOOL_SCROLL,
-	GPDF_TOOL_SELECT
+	GPDF_TOOL_SELECT,
+#ifdef WITH_GPDF_HIGHLIGHTS
+	GPDF_TOOL_HIGHLIGHT
+#endif /* WITH_GPDF_HIGHLIGHTS */
 };
 
 GType        gpdf_control_get_type  (void);
diff -u --recursive --new-file gpdf-tools/xpdf/gpdf-highlights.cc gpdf/xpdf/gpdf-highlights.cc
--- gpdf-tools/xpdf/gpdf-highlights.cc	1969-12-31 18:00:00.000000000 -0600
+++ gpdf/xpdf/gpdf-highlights.cc	2003-10-20 01:19:27.000000000 -0500
@@ -0,0 +1,137 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*  PDF view widget
+ *
+ *  Copyright (C) 2002 W. Michael Petullo
+ *
+ *  Author:
+ *    W. Michael Petullo <mike@flyn.org>
+ *
+ * GPdf is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * GPdf is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include "gpdf-highlights.h"
+
+#ifdef WITH_GPDF_HIGHLIGHTS
+
+#include <stdio.h>
+#include "gpdf-g-switch.h"
+#include <glib.h>
+#include <libgnome/libgnome.h>
+#include <libgnomeui/libgnomeui.h>
+#include <libgnomecanvas/libgnomecanvas.h>
+#include "gpdf-g-switch.h"
+
+Highlights::Highlights()
+{
+	highlight = NULL;
+}
+
+Highlights::Highlights(gchar *path)
+{
+	gint page;
+	gdouble x1, y1, x2, y2;
+	FILE *saved_highlights;
+	highlight = NULL;
+	char conf_path[PATH_MAX + 1];
+	g_strlcpy(conf_path, ".gpdf/", PATH_MAX + 1);
+	gchar *md5 = gnome_thumbnail_md5(path);
+	g_strlcat(conf_path, md5, PATH_MAX + 1);
+	highlights_path = gnome_util_prepend_user_home(conf_path);
+	if (! (saved_highlights = fopen(highlights_path, "r")))
+		return;
+	while (fscanf(saved_highlights, "%d %lf %lf %lf %lf\n", &page, 
+				&x1, &y1, &x2, &y2) != EOF)
+		add(page, x1, y1, x2, y2);
+	fclose(saved_highlights);
+}
+
+Highlights::~Highlights()
+{
+	g_list_free(highlight); /* FIXME: delete indiv. items? */
+	/* FIXME: delete gnome_canvas_items that are not NULL? */
+	g_free(highlights_path);
+}
+
+void Highlights::erase(GPdfView *view)
+{
+	gint n = 0;
+	Highlight *h;
+	while(h = nth(n++))
+		if (h->canvas_item) {
+			gtk_object_destroy ((GtkObject *) h->canvas_item);
+			h->canvas_item = NULL;
+		}
+}
+
+void Highlights::draw(gint page, GPdfView *view)
+{
+	gint n = 0;
+	Highlight *h;
+	erase(view);
+	while(h = nth(n++))
+		if (h->page == page)
+			h->canvas_item = gnome_canvas_item_new ( 
+				gnome_canvas_root (GNOME_CANVAS (view)), 
+				gnome_canvas_rect_get_type(), 
+				"x1", h->x1, 
+				"y1", h->y1, 
+				"x2", h->x2, 
+				"y2", h->y2, 
+				"fill_color_rgba", GPDF_HIGHLIGHT_RGBA, 
+				NULL);
+}
+
+void Highlights::add(gint page, gdouble x1, gdouble y1, gdouble x2, gdouble y2)
+{
+	Highlight *h = g_new0 (Highlight, 1);
+	h->page = page;
+	h->x1 = x1;
+	h->y1 = y1;
+	h->x2 = x2;
+	h->y2 = y2;
+	h->canvas_item = NULL;
+	highlight = g_list_append(highlight, (void *) h);
+}
+
+void Highlights::save()
+{
+	gint n = 0;
+	Highlight *h;
+	FILE *saved_highlights;
+	if (! (saved_highlights = fopen(highlights_path, "w")))
+		return; /* FIXME: display an error? */
+	while(h = nth(n++))
+		fprintf(saved_highlights, "%d %lf %lf %lf %lf\n", h->page,
+				h->x1, h->y1, h->x2, h->y2);
+	fclose(saved_highlights);
+}
+
+gboolean Highlights::page_highlighted(gint page)
+{
+	gint n = 0;
+	Highlight *h;
+	while(h = nth(n++))
+		if (h->page == page)
+			return gTrue;
+	return gFalse;
+}
+
+Highlight *Highlights::nth(gint n)
+{
+	Highlight *h = (Highlight *) g_list_nth_data(highlight, n);
+	return h;
+}
+
+#endif /* WITH_GPDF_HIGHLIGHTS */
diff -u --recursive --new-file gpdf-tools/xpdf/gpdf-highlights.h gpdf/xpdf/gpdf-highlights.h
--- gpdf-tools/xpdf/gpdf-highlights.h	1969-12-31 18:00:00.000000000 -0600
+++ gpdf/xpdf/gpdf-highlights.h	2003-10-20 01:19:27.000000000 -0500
@@ -0,0 +1,68 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*  PDF view widget
+ *
+ *  Copyright (C) 2002 W. Michael Petullo
+ *
+ *  Author:
+ *    W. Michael Petullo <mike@flyn.org>
+ *
+ * GPdf is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * GPdf is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+
+#ifndef GPDF_HIGHLIGHTS_H
+#define GPDF_HIGHLIGHTS_H
+
+#include <aconf.h>
+
+#ifdef WITH_GPDF_HIGHLIGHTS
+
+#include "gpdf-view.h"
+#include <glib.h>
+
+#define GPDF_HIGHLIGHT_RGBA 0xffff0088
+
+G_BEGIN_DECLS
+
+struct Highlight {
+	gint page;
+	double x1;
+	double y1;
+	double x2;
+	double y2;
+	GnomeCanvasItem *canvas_item;
+}; 
+
+class Highlights {
+	public:
+		Highlights();
+		Highlights(gchar *path);
+		~Highlights();
+		void erase(GPdfView *view);
+		void draw(gint page, GPdfView *view);
+		void add(gint page, gdouble x1, gdouble y1, gdouble x2, gdouble y2);
+		void save();
+		gboolean page_highlighted(gint page);
+		Highlight *nth(gint n);
+	private:
+		G_List *highlight;
+		gchar *highlights_path;
+};
+
+G_END_DECLS
+
+#endif /* WITH_GPDF_HIGHLIGHTS */
+
+#endif /* GPDF_HIGHLIGHTS_H */
diff -u --recursive --new-file gpdf-tools/xpdf/gpdf-view.cc gpdf/xpdf/gpdf-view.cc
--- gpdf-tools/xpdf/gpdf-view.cc	2003-10-22 09:02:48.000000000 -0500
+++ gpdf/xpdf/gpdf-view.cc	2003-10-22 09:02:34.000000000 -0500
@@ -47,6 +47,7 @@
 #include "gpdf-g-switch.h"
 #include "gpdf-control.h"
 #include "gpdf-control-private.h"
+#include "gpdf-highlights.h"
 #include "GPOutputDev.h"
 #include "TextOutputDev.h"
 #include "PDFDoc.h"
@@ -67,6 +68,9 @@
 	GnomeCanvasItem *page_background;
 	GnomeCanvasItem *page_shadow;
 	GnomeCanvasItem *page_selection; 
+#ifdef WITH_GPDF_HIGHLIGHTS
+	GnomeCanvasItem *new_highlight;
+#endif /* WITH_GPDF_HIGHLIGHTS */
 
 	GtkGestureHandler *gesture_handler;
 	GtkWidget *selection_widget;
@@ -85,6 +89,11 @@
 	guchar dragging : 1;
 	guchar dragndroping :1; 
 	guchar selecting : 1;
+#ifdef WITH_GPDF_HIGHLIGHTS
+	guchar highlighting : 1;
+	Highlights *highlights;
+#endif /* WITH_GPDF_HIGHLIGHTS */
+
 
 	gint drag_anchor_x, drag_anchor_y;
 	gint drag_offset_x, drag_offset_y;
@@ -174,6 +183,59 @@
 
 #define PAGE_PAD  ((gdouble)3.0)
 
+#ifdef WITH_GPDF_HIGHLIGHTS
+
+static void
+gpdf_view_page_highlights_show (GPdfView *gpdf_view)
+{
+       g_return_if_fail (GPDF_IS_NON_NULL_VIEW (gpdf_view));
+
+       int n = 0;
+       while(Highlight *h = gpdf_view->priv->highlights->nth(n++))
+               if (h->canvas_item)
+                       gnome_canvas_item_show (h->canvas_item);
+}
+
+static void
+gpdf_view_page_highlights_hide(GPdfView *gpdf_view)
+{
+       g_return_if_fail (GPDF_IS_NON_NULL_VIEW (gpdf_view));
+
+       int n = 0;
+       while(Highlight *h = gpdf_view->priv->highlights->nth(n++))
+               if (h->canvas_item)
+                       gnome_canvas_item_hide (h->canvas_item);
+}
+
+static void
+gpdf_view_page_highlights_raise (GPdfView *gpdf_view)
+{
+       g_return_if_fail (GPDF_IS_NON_NULL_VIEW (gpdf_view));
+
+       int n = 0;
+       while(Highlight *h = gpdf_view->priv->highlights->nth(n++))
+               if (h->canvas_item)
+                       gnome_canvas_item_raise_to_top (h->canvas_item);
+}
+
+static void
+gpdf_view_new_highlight_show (GPdfView *gpdf_view)
+{
+       g_return_if_fail (GPDF_IS_NON_NULL_VIEW (gpdf_view));
+
+       gnome_canvas_item_show (gpdf_view->priv->new_highlight);
+}
+
+static void
+gpdf_view_new_highlight_hide (GPdfView *gpdf_view)
+{
+       g_return_if_fail (GPDF_IS_NON_NULL_VIEW (gpdf_view));
+
+       gnome_canvas_item_hide (gpdf_view->priv->new_highlight);
+}
+
+#endif /* WITH_GPDF_HIGHLIGHTS */
+
 static void
 gpdf_view_page_background_show (GPdfView *gpdf_view)
 {
@@ -1550,6 +1612,15 @@
 	gnome_canvas_item_affine_relative (
 		GNOME_CANVAS_ITEM (priv->links_layer), page_transform);
 
+#ifdef WITH_GPDF_HIGHLIGHTS
+	if (gpdf_annots_view_highlights_displayed(gpdf_view_get_annots_view (gpdf_view), priv->current_page))
+		priv->highlights->draw(priv->current_page, gpdf_view);
+	else
+		priv->highlights->erase(gpdf_view);
+	gnome_canvas_item_raise_to_top (gpdf_view->priv->new_highlight);
+#endif /* WITH_GPDF_HIGHLIGHTS */
+	
+
 	gnome_canvas_item_raise_to_top (gpdf_view->priv->page_selection);
 	gnome_canvas_item_raise_to_top (GNOME_CANVAS_ITEM (priv->links_layer));
 
@@ -1631,6 +1702,15 @@
 	  priv->requested_page : priv->current_page; 
 }
 
+#ifdef WITH_GPDF_HIGHLIGHTS
+gint
+gpdf_view_page_highlighted (GPdfView *gpdf_view, gint page)
+{
+	return gpdf_view->priv->highlights->page_highlighted(page);
+}
+#endif /* WITH_GPDF_HIGHLIGHTS */
+
+
 void
 gpdf_view_page_prev (GPdfView *gpdf_view)
 {
@@ -2198,7 +2278,11 @@
 	if (!GTK_WIDGET_HAS_FOCUS (widget))
 		gtk_widget_grab_focus (widget);
 
-	if (priv->dragging || priv->selecting)
+	if (priv->dragging || priv->selecting
+#ifdef WITH_GPDF_HIGHLIGHTS
+            || priv->highlighting
+#endif /* WITH_GPDF_HIGHLIGHTS */
+	   )
 		return FALSE;
 	
 	switch (event->button) {
@@ -2213,6 +2297,12 @@
 				gpdf_view_button_press_select_event (
 					widget, event);
 				break;
+#ifdef WITH_GPDF_HIGHLIGHTS
+			case GPDF_TOOL_HIGHLIGHT:
+				priv->highlighting = TRUE;
+				gpdf_view_button_press_select_event (widget, event);
+				break;
+#endif /* WITH_GPDF_HIGHLIGHTS */
 		}
 
 		return TRUE;
@@ -2259,6 +2349,56 @@
 	}
 }
 
+#ifdef WITH_GPDF_HIGHLIGHTS
+static gboolean
+gpdf_view_button_highlight_release_event (GtkWidget *widget, GdkEventButton *event)
+{
+       /* FIXME: share code with gpdf_view_button_select_release_event */
+       GPdfViewPrivate *priv;
+       gdouble x, y;
+       gdouble rx1, ry1, rx2, ry2;
+       gdouble sx1, sy1, sx2, sy2;
+       gint cx, cy;
+
+       priv = GPDF_VIEW (widget)->priv;
+
+       gnome_canvas_get_scroll_region (GNOME_CANVAS (widget),
+               &rx1, &ry1, &rx2, &ry2);
+       gnome_canvas_get_scroll_offsets (GNOME_CANVAS (widget),
+               &cx, &cy);
+
+       x = (double)(event->x + cx);
+       y = (double)(event->y + cy);
+
+       gnome_canvas_window_to_world (GNOME_CANVAS (widget),
+               x, y, &x, &y);
+
+       if (abs ((int)(priv->select_anchor_x -x)) <= 1 &&
+               (abs ((int)(priv->select_anchor_y -y)) <= 1 )) {
+               sx1 = sy1 = 0.0;
+                 sx2 = sy2 = 0.0;
+       }
+       else {
+               sx1 = MAX (MIN (priv->select_anchor_x, x), rx1 +PAGE_PAD -1.0);
+               sy1 = MAX (MIN (priv->select_anchor_y, y), ry1 +PAGE_PAD -1.0);
+               sx2 = MIN (MAX (priv->select_anchor_x, x), rx2 -PAGE_PAD +1.0);
+               sy2 = MIN (MAX (priv->select_anchor_y, y), ry2 -PAGE_PAD +1.0);
+       }
+
+       gpdf_view_new_highlight_hide (GPDF_VIEW(widget));
+       priv->highlights->add(priv->current_page, sx1, sy1, sx2, sy2);
+       priv->highlights->save();
+       priv->highlights->draw(priv->current_page, GPDF_VIEW(widget));
+
+       LOG ("gpdf_view_button_release_event: "
+              "Selection region = [%.2f, %.2f] x [%.2f, %.2f]",
+               sx1, sy1, sx2, sy2);
+
+       gdk_pointer_ungrab (event->time);
+}
+#endif /* WITH_GPDF_HIGHLIGHTS */
+
+
 static gboolean
 gpdf_view_button_select_release_event (GtkWidget *widget, GdkEventButton *event)
 {
@@ -2317,7 +2457,11 @@
 
 	priv = GPDF_VIEW (widget)->priv;
 
-	if ((!priv->dragging && !priv->selecting && !priv->dragndroping) || event->button != 1)
+	if ((!priv->dragging && !priv->selecting && !priv->dragndroping
+#ifdef WITH_GPDF_HIGHLIGHTS
+             && !priv->highlighting
+#endif /* WITH_GPDF_HIGHLIGHTS */
+             ) || event->button != 1)
 		return FALSE;
 
 	if (priv->dragging) {
@@ -2345,6 +2489,13 @@
 
 		gdk_pointer_ungrab (event->time);
 	}
+#ifdef WITH_GPDF_HIGHLIGHTS
+	else if (priv->highlighting) {
+		priv->highlighting = FALSE;
+		gpdf_view_button_highlight_release_event (widget, event);
+	}
+#endif /* WITH_GPDF_HIGHLIGHTS */
+
 
 	return TRUE;
 }
@@ -2374,6 +2525,99 @@
 					 &priv->drag_offset_y);
 }
 
+#ifdef WITH_GPDF_HIGHLIGHTS
+static void
+gpdf_view_new_highlight_region (GPdfView *gpdf_view,
+                        double x1, double y1,
+                        double x2, double y2,
+                        gboolean scrollit)
+{
+       /* FIXME: share code with gpdf_view_select_region */
+       gchar *status;
+
+       g_return_if_fail (GPDF_IS_NON_NULL_VIEW (gpdf_view));
+
+       /* Be sure to have points in correct order */
+       gpdf_view->priv->select_x1 = MIN (x1, x2);
+       gpdf_view->priv->select_y1 = MIN (y1, y2);
+       gpdf_view->priv->select_x2 = MAX (x1, x2);
+       gpdf_view->priv->select_y2 = MAX (y1, y2);
+
+       status = g_strdup_printf ("[%03.2f, %03.2f]x[%03.2f, %03.2f]",
+                                 gpdf_view->priv->select_x1, gpdf_view->priv->select_y1,
+                                 gpdf_view->priv->select_x2, gpdf_view->priv->select_y2);
+       gpdf_control_private_set_status (gpdf_view->priv->parent,
+                                        status);
+       g_free (status);
+
+       gnome_canvas_item_set (gpdf_view->priv->new_highlight,
+                              "x1", gpdf_view->priv->select_x1,
+                              "y1", gpdf_view->priv->select_y1,
+                              "x2", gpdf_view->priv->select_x2,
+                              "y2", gpdf_view->priv->select_y2,
+                              NULL);
+
+       if (scrollit)
+         gnome_canvas_scroll_to (GNOME_CANVAS (gpdf_view),
+                                 (int)((x1 + x2) / 2),
+                                 (int)((y1 + y2) / 2));
+}
+
+static void
+gpdf_view_handle_highlight_motion (GPdfView *gpdf_view, GdkEventMotion *event,
+                               gint x, gint y)
+{
+       /* FIXME: share code with gpdf_view_handle_select_motion */
+       GPdfViewPrivate *priv;
+       gint dx, dy;
+       gdouble sx, sy;
+       gint cx, cy;
+       gdouble rx1, ry1, rx2, ry2;
+       gdouble sx1, sy1, sx2, sy2;
+       gdouble hpgsz, vpgsz;
+
+       g_return_if_fail (GPDF_IS_NON_NULL_VIEW (gpdf_view));
+
+       priv = gpdf_view->priv;
+
+       gnome_canvas_get_scroll_region (GNOME_CANVAS (gpdf_view),
+                                       &rx1, &ry1, &rx2, &ry2);
+       gnome_canvas_get_scroll_offsets (GNOME_CANVAS (gpdf_view),
+                                        &cx, &cy);
+
+       sx = (gdouble)(x + cx);
+       sy = (gdouble)(y + cy);
+
+       gnome_canvas_window_to_world (GNOME_CANVAS (gpdf_view),
+                                     sx, sy, &sx, &sy);
+
+       hpgsz = GTK_LAYOUT (gpdf_view)->hadjustment->page_size;
+       vpgsz = GTK_LAYOUT (gpdf_view)->vadjustment->page_size;
+
+       if (x < 0)
+         gtk_adjustment_set_value (GTK_LAYOUT (gpdf_view)->hadjustment,
+                                   GTK_LAYOUT (gpdf_view)->hadjustment->value + x/3);
+       if (y < 0)
+         gtk_adjustment_set_value (GTK_LAYOUT (gpdf_view)->vadjustment,
+                                   GTK_LAYOUT (gpdf_view)->vadjustment->value + y/3);
+       if (x > hpgsz && ((gdouble)cx <= (priv->zoom * (rx2-rx1)) -hpgsz))
+         gtk_adjustment_set_value (GTK_LAYOUT (gpdf_view)->hadjustment,
+                                   GTK_LAYOUT (gpdf_view)->hadjustment->value +(x -hpgsz) / 3);
+       if (y > vpgsz && ((gdouble)cy <= (priv->zoom * (ry2-ry1)) -vpgsz))
+         gtk_adjustment_set_value (GTK_LAYOUT (gpdf_view)->vadjustment,
+                                   GTK_LAYOUT (gpdf_view)->vadjustment->value +(y -vpgsz) / 3);
+
+
+       sx1 = MAX (MIN (priv->select_anchor_x, sx), rx1 +PAGE_PAD -1.0);
+       sy1 = MAX (MIN (priv->select_anchor_y, sy), ry1 +PAGE_PAD -1.0);
+       sx2 = MIN (MAX (priv->select_anchor_x, sx), rx2 -PAGE_PAD +1.0);
+       sy2 = MIN (MAX (priv->select_anchor_y, sy), ry2 -PAGE_PAD +1.0);
+
+       gpdf_view_new_highlight_region (gpdf_view, sx1, sy1, sx2, sy2, FALSE);
+       gpdf_view_new_highlight_show (gpdf_view);
+}
+#endif /* WITH_GPDF_HIGHLIGHTS */
+
 static void
 gpdf_view_handle_select_motion (GPdfView *gpdf_view, GdkEventMotion *event,
 				gint x, gint y)
@@ -2490,6 +2734,12 @@
 	if (GPDF_VIEW (widget)->priv->dragging)
 	  gpdf_view_handle_drag_motion (GPDF_VIEW (widget), event, x, y);
 
+#ifdef WITH_GPDF_HIGHLIGHTS
+	else if (GPDF_VIEW (widget)->priv->highlighting)
+		gpdf_view_handle_highlight_motion (GPDF_VIEW (widget), event, x, y);
+#endif /* WITH_GPDF_HIGHLIGHTS */
+
+
 	else if (GPDF_VIEW (widget)->priv->selecting)
 	  gpdf_view_handle_select_motion (GPDF_VIEW (widget), event, x, y);
 
@@ -2593,6 +2843,15 @@
 	gpdf_view_zoom_out (gpdf_view);
 }
 
+#ifdef WITH_GPDF_HIGHLIGHTS
+static void
+gpdf_view_open_page_highlights (GPdfView *gpdf_view)
+{
+	gpdf_view->priv->highlights = new Highlights(gpdf_control_private_get_title(gpdf_view->priv->parent));
+}
+#endif /* WITH_GPDF_HIGHLIGHTS */
+
+
 
 void
 gpdf_view_set_pdf_doc (GPdfView *gpdf_view, PDFDoc *pdf_doc)
@@ -2615,6 +2874,10 @@
 	gpdf_view_page_background_show (gpdf_view);
 	gpdf_view_goto_page_no_history (gpdf_view, 1);
 
+#ifdef WITH_GPDF_HIGHLIGHTS
+	gpdf_view_open_page_highlights (gpdf_view);
+#endif /* WITH_GPDF_HIGHLIGHTS */
+
 	g_signal_connect (GTK_LAYOUT (gpdf_view)->hadjustment, "value_changed",
 			  G_CALLBACK (gpdf_view_scroll_adjustments_changed_cb),
 			  gpdf_view); 
@@ -3126,6 +3389,27 @@
 	return TRUE; 
 }
 
+#ifdef WITH_GPDF_HIGHLIGHTS
+static void
+gpdf_view_setup_new_highlight(GPdfView *gpdf_view)
+{
+	GPdfViewPrivate *priv;
+
+	g_return_if_fail (GPDF_IS_NON_NULL_VIEW (gpdf_view));
+
+	priv = gpdf_view->priv;
+
+	priv->new_highlight = gnome_canvas_item_new (
+               gnome_canvas_root (GNOME_CANVAS (gpdf_view)),
+               gnome_canvas_rect_get_type(),
+              "fill_color_rgba", GPDF_HIGHLIGHT_RGBA,
+               NULL);
+	gpdf_view_new_highlight_hide (gpdf_view);
+	gnome_canvas_item_raise_to_top (priv->new_highlight);
+}
+#endif /* WITH_GPDF_HIGHLIGHTS */
+
+
 static void
 gpdf_view_setup_page_background (GPdfView *gpdf_view)
 {
@@ -3204,6 +3488,10 @@
 	gpdf_view_setup_page_background (gpdf_view);
 	gpdf_view_setup_page_selection (gpdf_view);
 	gpdf_view_setup_gesture_handler (gpdf_view);
+#ifdef WITH_GPDF_HIGHLIGHTS
+	gpdf_view_setup_new_highlight (gpdf_view);
+#endif /* WITH_GPDF_HIGHLIGHTS */
+
 
 	priv = gpdf_view->priv;
 	priv->output_dev = new GPOutputDev ();
diff -u --recursive --new-file gpdf-tools/xpdf/gpdf-view.h gpdf/xpdf/gpdf-view.h
--- gpdf-tools/xpdf/gpdf-view.h	2003-10-20 00:38:39.000000000 -0500
+++ gpdf/xpdf/gpdf-view.h	2003-10-20 01:18:06.000000000 -0500
@@ -82,6 +82,10 @@
 
 gint       gpdf_view_get_current_page 	 (GPdfView * gpdf_view); 
 
+#ifdef WITH_GPDF_HIGHLIGHTS
+gint gpdf_view_page_highlighted (GPdfView *gpdf_view, gint page);
+#endif /* WITH_GPDF_HIGHLIGHTS */
+
 void       gpdf_view_scroll_to_top    	 (GPdfView * gpdf_view);
 
 void       gpdf_view_scroll_to_bottom 	 (GPdfView * gpdf_view);
