Index: Makefile.am
===================================================================
RCS file: /cvs/gnome/evince/Makefile.am,v
retrieving revision 1.9
diff -p -u -u -p -U8 -r1.9 Makefile.am
--- Makefile.am	2 Jan 2005 12:27:01 -0000	1.9
+++ Makefile.am	6 Feb 2005 21:12:50 -0000
@@ -3,8 +3,10 @@ SUBDIRS = cut-n-paste data backend po pd
 intltool_extra = intltool-extract.in intltool-merge.in intltool-update.in
 
 EXTRA_DIST = $(intltool_extra)
 
 DISTCLEANFILES = 		\
 	intltool-extract 	\
 	intltool-merge 		\
 	intltool-update
+
+DISTCHECK_CONFIGURE_FLAGS = --disable-schemas-install
Index: configure.ac
===================================================================
RCS file: /cvs/gnome/evince/configure.ac,v
retrieving revision 1.22
diff -p -u -u -p -U8 -r1.22 configure.ac
--- configure.ac	4 Feb 2005 15:27:25 -0000	1.22
+++ configure.ac	6 Feb 2005 21:12:50 -0000
@@ -26,17 +26,17 @@ ALL_LINGUAS="cs da de en_CA ja no nb nl 
 AM_GLIB_GNU_GETTEXT
 
 GETTEXT_PACKAGE=AC_PACKAGE_NAME
 AC_SUBST(GETTEXT_PACKAGE)
 AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE", [Gettext package.])
 
 PKG_CHECK_MODULES(LIBEVPRIVATE, gtk+-2.0 >= 2.4.0)
 PKG_CHECK_MODULES(RECENT_FILES, gtk+-2.0 >= 2.4.0 libgnomeui-2.0 >= 2.4.0)
-PKG_CHECK_MODULES(SHELL, gtk+-2.0 >= 2.5.0 libgnomeui-2.0 gnome-vfs-2.0 libgnomeprint-2.2 libgnomeprintui-2.2 libglade-2.0)
+PKG_CHECK_MODULES(SHELL, gtk+-2.0 >= 2.6.0 libgnomeui-2.0 gnome-vfs-2.0 libgnomeprint-2.2 libgnomeprintui-2.2 libglade-2.0 gconf-2.0)
 PKG_CHECK_MODULES(DVI, gtk+-2.0 >= 2.6.0)
 PKG_CHECK_MODULES(GTK, gtk+-2.0 >= 2.6.0)
 PKG_CHECK_MODULES(PS, gtk+-2.0 >= 2.6.0 gnome-vfs-2.0 libgnomeui-2.0)
 
 GLIB_GENMARSHAL=`$PKG_CONFIG --variable=glib_genmarshal glib-2.0`  
 AC_SUBST(GLIB_GENMARSHAL)
 
 dnl Compile with disable-deprecated switches
@@ -56,16 +56,23 @@ AC_MSG_CHECKING([whether to disable depr
 if test "$set_enable_deprecated" != "yes"; then
 	AC_MSG_RESULT(yes)
 	EVINCE_DISABLE_DEPRECATED="-DG_DISABLE_DEPRECATED -DGDK_DISABLE_DEPRECATED -DGTK_DISABLE_DEPRECATED -DGNOME_DISABLE_DEPRECATED -DBONOBO_DISABLE_DEPRECATED"
 else
 	AC_MSG_RESULT(no)
 	EVINCE_DISABLE_DEPRECATED=""
 fi
 AC_SUBST(EVINCE_DISABLE_DEPRECATED)
+
+AM_GCONF_SOURCE_2
+
+AC_PATH_PROG([GCONFTOOL], [gconftool-2], [no])
+if test "x$GCONFTOOL" = "xno"; then
+	AC_MSG_ERROR([gconftool-2 executable not found in your path - should be installed with GConf])
+fi
 
 dnl ================== Xpdf aconf.h.in checks ==================================
 
 AH_TEMPLATE([HAVE_LIBSM], [Define to 1 if you have session management.])
 AH_TEMPLATE([ENABLE_NLS], [Use Native Language Support.])
 AH_TEMPLATE([HAVE_CATGETS], [Use catgets functions.])
 AH_TEMPLATE([HAVE_GETTEXT], [Use gettext functions.])
 
Index: data/.cvsignore
===================================================================
RCS file: /cvs/gnome/evince/data/.cvsignore,v
retrieving revision 1.2
diff -p -u -u -p -U8 -r1.2 .cvsignore
--- data/.cvsignore	21 Jan 2005 11:28:48 -0000	1.2
+++ data/.cvsignore	6 Feb 2005 21:12:50 -0000
@@ -1,3 +1,4 @@
 Makefile
 Makefile.in
 evince.desktop
+evince.schemas
Index: data/Makefile.am
===================================================================
RCS file: /cvs/gnome/evince/data/Makefile.am,v
retrieving revision 1.6
diff -p -u -u -p -U8 -r1.6 Makefile.am
--- data/Makefile.am	24 Jan 2005 08:24:48 -0000	1.6
+++ data/Makefile.am	6 Feb 2005 21:12:50 -0000
@@ -1,9 +1,10 @@
 @INTLTOOL_DESKTOP_RULE@
+@INTLTOOL_SCHEMAS_RULE@
 
 NULL =
 
 uidir = $(pkgdatadir)
 ui_DATA =				\
 	evince-ui.xml			\
 	$(NULL)
 
@@ -18,17 +19,32 @@ stock_DATA =				\
 	$(NULL)
 
 DESKTOP_IN_FILES= evince.desktop.in
 DESKTOP_FILES= $(DESKTOP_IN_FILES:.desktop.in=.desktop)
 
 desktopdir = $(datadir)/applications
 desktop_DATA = $(DESKTOP_FILES)
 
+schema_in_files = evince.schemas.in
+schemadir = $(GCONF_SCHEMA_FILE_DIR)
+schema_DATA = $(schema_in_files:.schemas.in=.schemas)
+
+install-data-local:
+if GCONF_SCHEMAS_INSTALL
+	if test -z "$(DESTDIR)" ; then \
+	for p in $(schema_DATA) ; do \
+	GCONF_CONFIG_SOURCE=$(GCONF_SCHEMA_CONFIG_SOURCE) $(GCONFTOOL) --makefile-install-rule $(top_builddir)/data/$$p >&1 > /dev/null; \
+	done \
+	fi
+endif
+
 EXTRA_DIST =				\
 	$(stock_DATA)			\
 	$(glade_DATA)			\
 	$(ui_DATA)			\
 	$(DESKTOP_IN_FILES)		\
+	$(schema_in_files)		\
 	$(NULL)
 
 DISTCLEANFILES = \
-	$(DESKTOP_FILES)
+	$(DESKTOP_FILES)	\
+	$(schema_DATA)
Index: data/evince-ui.xml
===================================================================
RCS file: /cvs/gnome/evince/data/evince-ui.xml,v
retrieving revision 1.10
diff -p -u -u -p -U8 -r1.10 evince-ui.xml
--- data/evince-ui.xml	2 Feb 2005 13:22:52 -0000	1.10
+++ data/evince-ui.xml	6 Feb 2005 21:12:50 -0000
@@ -57,9 +57,15 @@
     <toolitem action="ViewBestFit"/>
     <toolitem action="ViewPageWidth"/>
 <!--
     <separator/>
     <toolitem action="SinglePage"/>
     <toolitem action="ContinuousPage"/>
 -->
   </toolbar>
+
+  <toolbar name="LeaveFullscreenToolbar">
+    <toolitem action="LeaveFullscreen"/>
+  </toolbar>
+
+  <accelerator name="LeaveFullscreenAccel" action="LeaveFullscreen"/>
 </ui>
Index: data/evince.schemas.in
===================================================================
RCS file: data/evince.schemas.in
diff -N data/evince.schemas.in
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ data/evince.schemas.in	6 Feb 2005 21:12:50 -0000
@@ -0,0 +1,37 @@
+<gconfschemafile>
+  <schemalist>
+    <schema>
+      <key>/schemas/apps/evince/show_toolbar_bar</key>
+      <applyto>/apps/evince/show_toolbar/applyto>
+      <owner>evince</owner>
+      <type>bool</type>
+      <default>true</default>
+      <locale name="C">
+        <short>Show toolbar by default</short>
+        <long>Show toolbar by default.</long>
+      </locale>
+    </schema>
+    <schema>
+      <key>/schemas/apps/evince/show_sidebar_bar</key>
+      <applyto>/apps/evince/show_sidebar/applyto>
+      <owner>evince</owner>
+      <type>bool</type>
+      <default>true</default>
+      <locale name="C">
+        <short>Show sidebar by default</short>
+        <long>Show sidebar by default.</long>
+      </locale>
+    </schema>
+    <schema>
+      <key>/schemas/apps/evince/show_statusbar_bar</key>
+      <applyto>/apps/evince/show_statusbar/applyto>
+      <owner>evince</owner>
+      <type>bool</type>
+      <default>true</default>
+      <locale name="C">
+        <short>Show statusbar by default</short>
+        <long>Show statusbar by default.</long>
+      </locale>
+    </schema>
+  </schemalist>
+</gconfschemafile>
Index: shell/ev-stock-icons.c
===================================================================
RCS file: /cvs/gnome/evince/shell/ev-stock-icons.c,v
retrieving revision 1.1
diff -p -u -u -p -U8 -r1.1 ev-stock-icons.c
--- shell/ev-stock-icons.c	22 Dec 2004 13:28:08 -0000	1.1
+++ shell/ev-stock-icons.c	6 Feb 2005 21:12:51 -0000
@@ -45,18 +45,35 @@
 	}								        \
         gtk_icon_factory_add (factory, id, icon_set);   		        \
         gtk_icon_set_unref (icon_set);					        \
 }
 
 void
 ev_stock_icons_init (void)
 {
+	static const char *icon_theme_items[] =	{
+		EV_STOCK_LEAVE_FULLSCREEN
+	};
         GtkIconFactory *factory;
+	guint i;
 
         factory = gtk_icon_factory_new ();
         gtk_icon_factory_add_default (factory);
 
 	/* fitwidth stock icon */
 	EV_ADD_STOCK_ICON (EV_STOCK_ZOOM_FIT_WIDTH, STOCK_ZOOM_FIT_WIDTH_FILE, GTK_STOCK_ZOOM_FIT);
-	
+
+	for (i = 0; i < G_N_ELEMENTS (icon_theme_items); i++) {
+		GtkIconSet *icon_set;
+		GtkIconSource *icon_source;
+
+		icon_set = gtk_icon_set_new ();
+		icon_source = gtk_icon_source_new ();
+		gtk_icon_source_set_icon_name (icon_source, icon_theme_items[i]);
+		gtk_icon_set_add_source (icon_set, icon_source);
+		gtk_icon_factory_add (factory, icon_theme_items[i], icon_set);
+		gtk_icon_set_unref (icon_set);
+		gtk_icon_source_free (icon_source);
+	}
+
 	g_object_unref (G_OBJECT (factory));
 }
Index: shell/ev-stock-icons.h
===================================================================
RCS file: /cvs/gnome/evince/shell/ev-stock-icons.h,v
retrieving revision 1.1
diff -p -u -u -p -U8 -r1.1 ev-stock-icons.h
--- shell/ev-stock-icons.h	22 Dec 2004 13:28:08 -0000	1.1
+++ shell/ev-stock-icons.h	6 Feb 2005 21:12:51 -0000
@@ -25,14 +25,15 @@
 #define __EV_STOCK_ICONS_H__
 
 #include <glib/gmacros.h>
 
 G_BEGIN_DECLS
 
 /* Toolbar icons */
 #define EV_STOCK_ZOOM_FIT_WIDTH "ev-zoom-fit-width"
+#define EV_STOCK_LEAVE_FULLSCREEN "stock_leave-fullscreen"
 
 void ev_stock_icons_init (void);
 
 G_END_DECLS
 
 #endif /* __EV_STOCK_ICONS_H__ */
Index: shell/ev-window.c
===================================================================
RCS file: /cvs/gnome/evince/shell/ev-window.c,v
retrieving revision 1.58
diff -p -u -u -p -U8 -r1.58 ev-window.c
--- shell/ev-window.c	4 Feb 2005 15:17:10 -0000	1.58
+++ shell/ev-window.c	6 Feb 2005 21:12:51 -0000
@@ -1,15 +1,15 @@
 /* -*- 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) 2004 Martin Kretzschmar
  *  Copyright (C) 2004 Red Hat, Inc.
  *  Copyright (C) 2000, 2001, 2002, 2003, 2004 Marco Pesenti Gritti
- *  Copyright (C) 2003, 2004 Christian Persch
+ *  Copyright (C) 2003, 2004, 2005 Christian Persch
  *
  *  Author:
  *    Martin Kretzschmar <martink@gnome.org>
  *
  * Evince 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.
@@ -47,61 +47,79 @@
 #include "ps-document.h"
 
 #include <glib/gi18n.h>
 #include <gtk/gtk.h>
 
 #include <libgnomevfs/gnome-vfs-mime-utils.h>
 #include <libgnomeprintui/gnome-print-dialog.h>
 
+#include <gconf/gconf-client.h>
+
 #include <string.h>
 
 #include "ev-application.h"
 #include "ev-stock-icons.h"
 
 typedef enum {
 	PAGE_MODE_SINGLE_PAGE,
 	PAGE_MODE_CONTINUOUS_PAGE,
 	PAGE_MODE_PASSWORD,
 } EvWindowPageMode;
 
+typedef enum {
+	EV_CHROME_MENUBAR	= 1 << 0,
+	EV_CHROME_TOOLBAR	= 1 << 1,
+	EV_CHROME_SIDEBAR	= 1 << 2,
+	EV_CHROME_FINDBAR	= 1 << 3,
+	EV_CHROME_STATUSBAR	= 1 << 4,
+	EV_CHROME_NORMAL	= EV_CHROME_MENUBAR | EV_CHROME_TOOLBAR | EV_CHROME_SIDEBAR | EV_CHROME_STATUSBAR
+} EvChrome;
+
 struct _EvWindowPrivate {
 	GtkWidget *main_box;
+	GtkWidget *menubar;
+	GtkWidget *toolbar_dock;
+	GtkWidget *toolbar;
 	GtkWidget *hpaned;
 	GtkWidget *sidebar;
 	GtkWidget *thumbs_sidebar;
 	GtkWidget *find_bar;
 	GtkWidget *scrolled_window;
 	GtkWidget *view;
 	GtkWidget *page_view;
 	GtkWidget *password_view;
 	GtkActionGroup *action_group;
 	GtkUIManager *ui_manager;
 	GtkWidget *statusbar;
 	guint help_message_cid;
 	guint view_message_cid;
 	GtkWidget *exit_fullscreen_popup;
+	GtkWidget *exit_fullscreen_toolbar;
 	char *uri;
 
 	EvDocument *document;
 
 	EvWindowPageMode page_mode;
 	/* These members are used temporarily when in PAGE_MODE_PASSWORD */
 	EvDocument *password_document;
 	GtkWidget *password_dialog;
 	char *password_uri;
 
+	EvChrome chrome;
 	gboolean fullscreen_mode;
 };
 #define EV_WINDOW_GET_PRIVATE(object) \
 	(G_TYPE_INSTANCE_GET_PRIVATE ((object), EV_TYPE_WINDOW, EvWindowPrivate))
 
+#define PAGE_SELECTOR_ACTION	"PageSelector"
 
-#define PAGE_SELECTOR_ACTION "PageSelector"
-
+#define GCONF_CHROME_TOOLBAR	"/apps/evince/show_toolbar"
+#define GCONF_CHROME_SIDEBAR	"/apps/evince/show_sidebar"
+#define GCONF_CHROME_STATUSBAR	"/apps/evince/show_statusbar"
 
 static void     ev_window_update_fullscreen_popup (EvWindow         *window);
 static void     ev_window_set_page_mode           (EvWindow         *window,
 						   EvWindowPageMode  page_mode);
 static gboolean start_loading_document            (EvWindow         *ev_window,
 						   EvDocument       *document,
 						   const char       *uri);
 
@@ -182,16 +200,62 @@ update_action_sensitivity (EvWindow *ev_
 	/* Help menu */
 	/* "HelpContents": always sensitive */
 	/* "HelpAbout": always sensitive */
 
 	/* Toolbar-specific actions: */
 	set_action_sensitive (ev_window, PAGE_SELECTOR_ACTION, document!=NULL);
 }
 
+static void
+update_chrome_visibility (EvWindow *window)
+{
+	EvWindowPrivate *priv = window->priv;
+	gboolean menubar, toolbar, sidebar, findbar, statusbar;
+
+	menubar = (priv->chrome & EV_CHROME_MENUBAR) != 0 && !priv->fullscreen_mode;
+	toolbar = (priv->chrome & EV_CHROME_TOOLBAR) != 0;
+	sidebar = (priv->chrome & EV_CHROME_SIDEBAR) != 0;
+	findbar = (priv->chrome & EV_CHROME_FINDBAR) != 0;
+	statusbar = (priv->chrome & EV_CHROME_STATUSBAR) != 0 && !priv->fullscreen_mode;
+
+	g_object_set (priv->menubar, "visible", menubar, NULL);
+	g_object_set (priv->toolbar_dock, "visible", toolbar, NULL);
+	g_object_set (priv->sidebar, "visible", sidebar, NULL);
+	g_object_set (priv->find_bar, "visible", findbar, NULL);
+	g_object_set (priv->statusbar, "visible", statusbar, NULL);
+
+	g_object_set (priv->exit_fullscreen_toolbar, "visible", priv->fullscreen_mode, NULL);
+	if (priv->exit_fullscreen_popup != NULL) {
+		g_object_set (priv->exit_fullscreen_popup, "visible", !toolbar, NULL);
+	}
+}
+
+static void
+update_chrome_flag (EvWindow *window, EvChrome flag, const char *pref, gboolean active)
+{
+	EvWindowPrivate *priv = window->priv;
+	GConfClient *client;
+	
+	if (active) {
+		priv->chrome |= flag;
+	}
+	else {
+		priv->chrome &= ~flag;
+	}
+
+	if (pref != NULL) {
+		client = gconf_client_get_default ();
+		gconf_client_set_bool (client, pref, active, NULL);
+		g_object_unref (client);
+	}
+
+	update_chrome_visibility (window);
+}
+
 void
 ev_window_open_page (EvWindow *ev_window, int page)
 {
 	ev_view_set_page (EV_VIEW (ev_window->priv->view), page);
 }
 
 void
 ev_window_open_link (EvWindow *ev_window, EvLink *link)
@@ -778,20 +842,17 @@ ev_window_cmd_edit_find (GtkAction *acti
 {
         g_return_if_fail (EV_IS_WINDOW (ev_window));
 
 	if (ev_window->priv->document == NULL) {
 		g_printerr ("We should have set the Find menu item insensitive since there's no document\n");
 	} else if (!EV_IS_DOCUMENT_FIND (ev_window->priv->document)) {
 		find_not_supported_dialog (ev_window);
 	} else {
-		gtk_widget_show (ev_window->priv->find_bar);
-
-		if (ev_window->priv->exit_fullscreen_popup)
-			ev_window_update_fullscreen_popup (ev_window);
+		update_chrome_flag (ev_window, EV_CHROME_FINDBAR, NULL, TRUE);
 
 		egg_find_bar_grab_focus (EGG_FIND_BAR (ev_window->priv->find_bar));
 	}
 }
 
 static void
 ev_window_cmd_edit_copy (GtkAction *action, EvWindow *ev_window)
 {
@@ -804,47 +865,37 @@ static void
 ev_window_update_fullscreen_popup (EvWindow *window)
 {
 	GtkWidget *popup = window->priv->exit_fullscreen_popup;
 	int popup_width, popup_height;
 	GdkRectangle screen_rect;
 
 	g_return_if_fail (popup != NULL);
 
-	if (!popup)
-		return;
-
 	popup_width = popup->requisition.width;
 	popup_height = popup->requisition.height;
 
 	/* FIXME multihead */
 	gdk_screen_get_monitor_geometry (gdk_screen_get_default (),
 			gdk_screen_get_monitor_at_window
                         (gdk_screen_get_default (),
                          GTK_WIDGET (window)->window),
                          &screen_rect);
 
-	if (GTK_WIDGET_VISIBLE (window->priv->find_bar)) {
-		GtkRequisition req;
-
-		gtk_widget_size_request (window->priv->find_bar, &req);
-
-		screen_rect.height -= req.height;
-	}
-
 	if (gtk_widget_get_direction (popup) == GTK_TEXT_DIR_RTL)
 	{
 		gtk_window_move (GTK_WINDOW (popup),
-				 screen_rect.x + screen_rect.width - popup_width,
-				 screen_rect.height - popup_height);
+				 screen_rect.x,
+				 screen_rect.y);
 	}
 	else
 	{
 		gtk_window_move (GTK_WINDOW (popup),
-                	        screen_rect.x, screen_rect.height - popup_height);
+				 screen_rect.x + screen_rect.width - popup_width,
+				 screen_rect.y);
 	}
 }
 
 static void
 screen_size_changed_cb (GdkScreen *screen,
 			EvWindow *window)
 {
 	ev_window_update_fullscreen_popup (window);
@@ -880,71 +931,65 @@ static void
 fullscreen_popup_size_request_cb (GtkWidget *popup, GtkRequisition *req, EvWindow *window)
 {
 	ev_window_update_fullscreen_popup (window);
 }
 
 static void
 ev_window_fullscreen (EvWindow *window)
 {
-	GtkWidget *popup, *button, *icon, *label, *hbox, *main_menu;
+	GtkWidget *popup, *button, *icon, *label, *hbox;
 
 	window->priv->fullscreen_mode = TRUE;
 
+	g_return_if_fail (window->priv->exit_fullscreen_popup == NULL);
+
 	popup = gtk_window_new (GTK_WINDOW_POPUP);
 	window->priv->exit_fullscreen_popup = popup;
 
 	button = gtk_button_new ();
 	g_signal_connect (button, "clicked",
 			  G_CALLBACK (exit_fullscreen_button_clicked_cb),
 			  window);
 	gtk_widget_show (button);
 	gtk_container_add (GTK_CONTAINER (popup), button);
 
 	hbox = gtk_hbox_new (FALSE, 2);
 	gtk_widget_show (hbox);
 	gtk_container_add (GTK_CONTAINER (button), hbox);
 
-	icon = gtk_image_new_from_stock (GTK_STOCK_QUIT, GTK_ICON_SIZE_BUTTON);
+	icon = gtk_image_new_from_stock (EV_STOCK_LEAVE_FULLSCREEN, GTK_ICON_SIZE_BUTTON);
 	gtk_widget_show (icon);
 	gtk_box_pack_start (GTK_BOX (hbox), icon, FALSE, FALSE, 0);
 
-	label = gtk_label_new (_("Exit Fullscreen"));
+	label = gtk_label_new (_("Leave Fullscreen"));
 	gtk_widget_show (label);
 	gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
 
 	gtk_window_set_resizable (GTK_WINDOW (popup), FALSE);
 
 	/* FIXME multihead */
 	g_signal_connect (gdk_screen_get_default (), "size-changed",
 			  G_CALLBACK (screen_size_changed_cb), window);
 	g_signal_connect (popup, "size_request",
 			  G_CALLBACK (fullscreen_popup_size_request_cb), window);
 
-	main_menu = gtk_ui_manager_get_widget (window->priv->ui_manager, "/MainMenu");
-	gtk_widget_hide (main_menu);
-	gtk_widget_hide (window->priv->statusbar);
+	update_chrome_visibility (window);
 
 	ev_window_update_fullscreen_popup (window);
-
-	gtk_widget_show (popup);
 }
 
 static void
 ev_window_unfullscreen (EvWindow *window)
 {
-	GtkWidget *main_menu;
-
 	window->priv->fullscreen_mode = FALSE;
 
-	main_menu = gtk_ui_manager_get_widget (window->priv->ui_manager, "/MainMenu");
-	gtk_widget_show (main_menu);
-	gtk_widget_show (window->priv->statusbar);
-
 	destroy_exit_fullscreen_popup (window);
+
+	update_chrome_visibility (window);
 }
 
 static void
 ev_window_cmd_view_fullscreen (GtkAction *action, EvWindow *ev_window)
 {
 	gboolean fullscreen;
 
         g_return_if_fail (EV_IS_WINDOW (ev_window));
@@ -988,21 +1033,43 @@ ev_window_state_event_cb (GtkWidget *wid
 			(action, G_CALLBACK (ev_window_cmd_view_fullscreen), window);
 
 	}
 
 	return FALSE;
 }
 
 static gboolean
-ev_window_focus_out_cb (GtkWidget *widget, GdkEventFocus *event, EvWindow *ev_window)
+ev_window_focus_in_event (GtkWidget *widget, GdkEventFocus *event)
 {
-	gtk_window_unfullscreen (GTK_WINDOW (ev_window));
+	EvWindow *window = EV_WINDOW (widget);
+	EvWindowPrivate *priv = window->priv;
 
-	return FALSE;
+	if (priv->exit_fullscreen_popup != NULL &&
+	    (priv->chrome & EV_CHROME_TOOLBAR) == 0)
+	{
+		gtk_widget_show (priv->exit_fullscreen_popup);
+	}
+
+	return GTK_WIDGET_CLASS (ev_window_parent_class)->focus_in_event (widget, event);
+}
+
+static gboolean
+ev_window_focus_out_event (GtkWidget *widget, GdkEventFocus *event)
+{
+	EvWindow *window = EV_WINDOW (widget);
+	EvWindowPrivate *priv = window->priv;
+
+	if (priv->exit_fullscreen_popup != NULL &&
+	    (priv->chrome & EV_CHROME_TOOLBAR) == 0)
+	{
+		gtk_widget_hide (priv->exit_fullscreen_popup);
+	}
+
+	return GTK_WIDGET_CLASS (ev_window_parent_class)->focus_out_event (widget, event);
 }
 
 static void
 ev_window_set_page_mode (EvWindow         *window,
 			 EvWindowPageMode  page_mode)
 {
 	GtkWidget *child = NULL;
 	GtkWidget *real_child;
@@ -1114,16 +1181,22 @@ static void
 ev_window_cmd_help_contents (GtkAction *action, EvWindow *ev_window)
 {
         g_return_if_fail (EV_IS_WINDOW (ev_window));
 
         /* FIXME */
 }
 
 static void
+ev_window_cmd_leave_fullscreen (GtkAction *action, EvWindow *window)
+{
+	gtk_window_unfullscreen (GTK_WINDOW (window));
+}
+
+static void
 ev_window_cmd_help_about (GtkAction *action, EvWindow *ev_window)
 {
 	const char *authors[] = {
 		N_("Many..."),
 		NULL
 	};
 
 	const char *documenters[] = {
@@ -1175,43 +1248,35 @@ ev_window_cmd_help_about (GtkAction *act
 		NULL);
 
 	g_free (license_trans);
 }
 
 static void
 ev_window_view_toolbar_cb (GtkAction *action, EvWindow *ev_window)
 {
-	g_object_set (
-		G_OBJECT (gtk_ui_manager_get_widget (
-				  ev_window->priv->ui_manager,
-				  "/ToolBar")),
-		"visible",
-		gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)),
-		NULL);
+	update_chrome_flag (ev_window, EV_CHROME_TOOLBAR,
+			    GCONF_CHROME_TOOLBAR,
+			    gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)));
 }
 
 static void
 ev_window_view_statusbar_cb (GtkAction *action, EvWindow *ev_window)
 {
-	g_object_set (
-		ev_window->priv->statusbar,
-		"visible",
-		gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)),
-		NULL);
+	update_chrome_flag (ev_window, EV_CHROME_STATUSBAR,
+			    GCONF_CHROME_STATUSBAR,
+			    gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)));
 }
 
 static void
 ev_window_view_sidebar_cb (GtkAction *action, EvWindow *ev_window)
 {
-	g_object_set (
-		ev_window->priv->sidebar,
-		"visible",
-		gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)),
-		NULL);
+	update_chrome_flag (ev_window, EV_CHROME_SIDEBAR,
+			    GCONF_CHROME_SIDEBAR,
+			    gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)));
 }
 
 static void
 menu_item_select_cb (GtkMenuItem *proxy, EvWindow *ev_window)
 {
 	GtkAction *action;
 	char *message;
 
@@ -1326,20 +1391,17 @@ find_bar_next_cb (EggFindBar *find_bar,
 {
 	ev_view_find_next (EV_VIEW (ev_window->priv->view));
 }
 
 static void
 find_bar_close_cb (EggFindBar *find_bar,
 		   EvWindow   *ev_window)
 {
-	gtk_widget_hide (ev_window->priv->find_bar);
-
-	if (ev_window->priv->exit_fullscreen_popup)
-		ev_window_update_fullscreen_popup (ev_window);
+	update_chrome_flag (ev_window, EV_CHROME_FINDBAR, NULL, FALSE);
 }
 
 static void
 ev_window_page_mode_cb (GtkRadioAction *action,
 			GtkRadioAction *activated_action,
 			EvWindow       *window)
 {
 	int mode;
@@ -1388,21 +1450,18 @@ find_bar_search_changed_cb (EggFindBar *
 			gtk_widget_queue_draw (GTK_WIDGET (ev_window->priv->view));
 		}
 	}
 }
 
 static void
 ev_window_dispose (GObject *object)
 {
-	EvWindowPrivate *priv;
-
-	g_return_if_fail (object != NULL && EV_IS_WINDOW (object));
-
-	priv = EV_WINDOW (object)->priv;
+	EvWindow *window = EV_WINDOW (object);
+	EvWindowPrivate *priv = window->priv;
 
 	if (priv->ui_manager) {
 		g_object_unref (priv->ui_manager);
 		priv->ui_manager = NULL;
 	}
 
 	if (priv->action_group) {
 		g_object_unref (priv->action_group);
@@ -1418,30 +1477,34 @@ ev_window_dispose (GObject *object)
 		g_object_unref (priv->password_document);
 		priv->password_document = NULL;
 	}
 	
 	if (priv->password_uri) {
 		g_free (priv->password_uri);
 		priv->password_uri = NULL;
 	}
-	
+
+	destroy_exit_fullscreen_popup (window);
+
 	G_OBJECT_CLASS (ev_window_parent_class)->dispose (object);
 }
 
 static void
 ev_window_class_init (EvWindowClass *ev_window_class)
 {
-	GObjectClass *g_object_class;
+	GObjectClass *g_object_class = G_OBJECT_CLASS (ev_window_class);
+	GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (ev_window_class);
 
-	g_object_class = G_OBJECT_CLASS (ev_window_class);
 	g_object_class->dispose = ev_window_dispose;
 
-	g_type_class_add_private (g_object_class, sizeof (EvWindowPrivate));
+	widget_class->focus_in_event = ev_window_focus_in_event;
+	widget_class->focus_out_event = ev_window_focus_out_event;
 
+	g_type_class_add_private (g_object_class, sizeof (EvWindowPrivate));
 }
 
 /* Normal items */
 static GtkActionEntry entries[] = {
 	{ "File", NULL, N_("_File") },
         { "Edit", NULL, N_("_Edit") },
 	{ "View", NULL, N_("_View") },
         { "Go", NULL, N_("_Go") },
@@ -1506,16 +1569,21 @@ static GtkActionEntry entries[] = {
 	/* Help menu */
 	{ "HelpContents", GTK_STOCK_HELP, N_("_Contents"), NULL,
 	  N_("Display help for the viewer application"),
 	  G_CALLBACK (ev_window_cmd_help_contents) },
 
 	{ "HelpAbout", GTK_STOCK_ABOUT, N_("_About"), NULL,
 	  N_("Display credits for the document viewer creators"),
 	  G_CALLBACK (ev_window_cmd_help_about) },
+
+	/* Toolbar-only */
+	{ "LeaveFullscreen", EV_STOCK_LEAVE_FULLSCREEN, N_("Leave Fullscreen"), "Escape",
+	  N_("Leave fullscreen mode"),
+	  G_CALLBACK (ev_window_cmd_leave_fullscreen) }
 };
 
 /* Toggle items */
 static GtkToggleActionEntry toggle_entries[] = {
 	/* View Menu */
 	{ "ViewToolbar", NULL, N_("_Toolbar"), "<shift><control>T",
 	  N_("Show or hide toolbar"),
 	  G_CALLBACK (ev_window_view_toolbar_cb), TRUE },
@@ -1561,37 +1629,108 @@ register_custom_actions (EvWindow *windo
 			       NULL);
 	g_signal_connect (action, "goto_page",
 			  G_CALLBACK (goto_page_cb), window);
 	gtk_action_group_add_action (group, action);
 	g_object_unref (action);
 }
 
 static void
-set_short_labels (GtkActionGroup *action_group)
+set_action_properties (GtkActionGroup *action_group)
 {
 	GtkAction *action;
 
 	action = gtk_action_group_get_action (action_group, "GoPageUp");
 	g_object_set (action, "short_label", _("Up"), NULL);
 	action = gtk_action_group_get_action (action_group, "GoPageDown");
 	g_object_set (action, "short_label", _("Down"), NULL);
 	action = gtk_action_group_get_action (action_group, "ViewPageWidth");
 	g_object_set (action, "short_label", _("Fit Width"), NULL);
+
+	action = gtk_action_group_get_action (action_group, "LeaveFullscreen");
+	g_object_set (action, "is-important", TRUE, NULL);
+}
+
+static void
+set_chrome_actions (EvWindow *window)
+{
+	EvWindowPrivate *priv = window->priv;
+	GtkActionGroup *action_group = priv->action_group;
+	GtkAction *action;
+
+	action= gtk_action_group_get_action (action_group, "ViewToolbar");
+	g_signal_handlers_block_by_func
+		(action, G_CALLBACK (ev_window_view_toolbar_cb), window);
+	gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
+				      (priv->chrome & EV_CHROME_TOOLBAR) != 0);
+	g_signal_handlers_unblock_by_func
+		(action, G_CALLBACK (ev_window_view_toolbar_cb), window);
+
+	action= gtk_action_group_get_action (action_group, "ViewSidebar");
+	g_signal_handlers_block_by_func
+		(action, G_CALLBACK (ev_window_view_sidebar_cb), window);
+	gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
+				      (priv->chrome & EV_CHROME_SIDEBAR) != 0);
+	g_signal_handlers_unblock_by_func
+		(action, G_CALLBACK (ev_window_view_sidebar_cb), window);
+
+	action= gtk_action_group_get_action (action_group, "ViewStatusbar");
+	g_signal_handlers_block_by_func
+		(action, G_CALLBACK (ev_window_view_statusbar_cb), window);
+	gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
+				      (priv->chrome & EV_CHROME_STATUSBAR) != 0);
+	g_signal_handlers_unblock_by_func
+		(action, G_CALLBACK (ev_window_view_statusbar_cb), window);
+}
+
+static EvChrome
+load_chrome (void)
+{
+	GConfClient *client;
+	GConfValue *value;	
+	EvChrome chrome = EV_CHROME_NORMAL;
+
+	client = gconf_client_get_default ();
+
+	value = gconf_client_get (client, GCONF_CHROME_TOOLBAR, NULL);
+	if (value != NULL) {
+		if (value->type == GCONF_VALUE_BOOL && !gconf_value_get_bool (value)) {
+			chrome &= ~EV_CHROME_TOOLBAR;
+		}
+		gconf_value_free (value);
+	}
+
+	value = gconf_client_get (client, GCONF_CHROME_SIDEBAR, NULL);
+	if (value != NULL) {
+		if (value->type == GCONF_VALUE_BOOL && !gconf_value_get_bool (value)) {
+			chrome &= ~EV_CHROME_SIDEBAR;
+		}
+		gconf_value_free (value);
+	}
+
+	value = gconf_client_get (client, GCONF_CHROME_STATUSBAR, NULL);
+	if (value != NULL) {
+		if (value->type == GCONF_VALUE_BOOL && !gconf_value_get_bool (value)) {
+			chrome &= ~EV_CHROME_STATUSBAR;
+		}
+		gconf_value_free (value);
+	}
+
+	g_object_unref (client);
+
+	return chrome;
 }
 
 static void
 ev_window_init (EvWindow *ev_window)
 {
 	GtkActionGroup *action_group;
 	GtkAccelGroup *accel_group;
 	GError *error = NULL;
-	GtkWidget *menubar;
-	GtkWidget *toolbar;
-	GtkWidget *sidebar_widget;
+	GtkWidget *sidebar_widget, *toolbar_dock;
 
 	ev_window->priv = EV_WINDOW_GET_PRIVATE (ev_window);
 
 	ev_window->priv->page_mode = PAGE_MODE_SINGLE_PAGE;
 	update_window_title (NULL, NULL, ev_window);
 
 	ev_window->priv->main_box = gtk_vbox_new (FALSE, 0);
 	gtk_container_add (GTK_CONTAINER (ev_window), ev_window->priv->main_box);
@@ -1605,17 +1744,17 @@ ev_window_init (EvWindow *ev_window)
 	gtk_action_group_add_toggle_actions (action_group, toggle_entries,
 					     G_N_ELEMENTS (toggle_entries),
 					     ev_window);
 	gtk_action_group_add_radio_actions (action_group, page_view_entries,
 					    G_N_ELEMENTS (page_view_entries),
 					    ev_window->priv->page_mode,
 					    G_CALLBACK (ev_window_page_mode_cb),
 					    ev_window);
-	set_short_labels (action_group);
+	set_action_properties (action_group);
 	register_custom_actions (ev_window, action_group);
 
 	ev_window->priv->ui_manager = gtk_ui_manager_new ();
 	gtk_ui_manager_insert_action_group (ev_window->priv->ui_manager,
 					    action_group, 0);
 
 	accel_group =
 		gtk_ui_manager_get_accel_group (ev_window->priv->ui_manager);
@@ -1628,34 +1767,57 @@ ev_window_init (EvWindow *ev_window)
 
 	if (!gtk_ui_manager_add_ui_from_file (ev_window->priv->ui_manager,
 					      DATADIR"/evince-ui.xml",
 					      &error)) {
 		g_message ("building menus failed: %s", error->message);
 		g_error_free (error);
 	}
 
-	menubar = gtk_ui_manager_get_widget (ev_window->priv->ui_manager,
-					     "/MainMenu");
-	gtk_box_pack_start (GTK_BOX (ev_window->priv->main_box), menubar,
+	ev_window->priv->menubar =
+		 gtk_ui_manager_get_widget (ev_window->priv->ui_manager,
+					    "/MainMenu");
+	gtk_box_pack_start (GTK_BOX (ev_window->priv->main_box),
+			    ev_window->priv->menubar,
 			    FALSE, FALSE, 0);
 
-	toolbar = gtk_ui_manager_get_widget (ev_window->priv->ui_manager,
-					     "/ToolBar");
-	gtk_box_pack_start (GTK_BOX (ev_window->priv->main_box), toolbar,
+	/* This sucks, but there is no way to have a draw=no, expand=true separator
+	 * in a GtkUIManager-built toolbar. So, just add another toolbar.
+	 * See gtk+ bug 166489.
+	 */
+	toolbar_dock = ev_window->priv->toolbar_dock = gtk_hbox_new (FALSE, 0);
+	gtk_box_pack_start (GTK_BOX (ev_window->priv->main_box), toolbar_dock,
 			    FALSE, FALSE, 0);
+	gtk_widget_show (toolbar_dock);
+
+	ev_window->priv->toolbar =
+		gtk_ui_manager_get_widget (ev_window->priv->ui_manager,
+					   "/ToolBar");
+	gtk_box_pack_start (GTK_BOX (toolbar_dock), ev_window->priv->toolbar,
+			    TRUE, TRUE, 0);
+	gtk_widget_show (ev_window->priv->toolbar);
+
+	ev_window->priv->exit_fullscreen_toolbar =
+		gtk_ui_manager_get_widget (ev_window->priv->ui_manager,
+					   "/LeaveFullscreenToolbar");
+	gtk_box_pack_start (GTK_BOX (toolbar_dock),
+			    ev_window->priv->exit_fullscreen_toolbar,
+			    FALSE, FALSE, 0);
+	gtk_toolbar_set_show_arrow (GTK_TOOLBAR (ev_window->priv->exit_fullscreen_toolbar),
+				    FALSE);
+	gtk_toolbar_set_style (GTK_TOOLBAR (ev_window->priv->exit_fullscreen_toolbar),
+			       GTK_TOOLBAR_BOTH_HORIZ);
 
 	/* Add the main area */
 	ev_window->priv->hpaned = gtk_hpaned_new ();
 	gtk_widget_show (ev_window->priv->hpaned);
 	gtk_box_pack_start (GTK_BOX (ev_window->priv->main_box), ev_window->priv->hpaned,
 			    TRUE, TRUE, 0);
 
 	ev_window->priv->sidebar = ev_sidebar_new ();
-	gtk_widget_show (ev_window->priv->sidebar);
 	gtk_paned_add1 (GTK_PANED (ev_window->priv->hpaned),
 			ev_window->priv->sidebar);
 
 	/* Stub sidebar, for now */
 	sidebar_widget = ev_sidebar_links_new ();
 	gtk_widget_show (sidebar_widget);
 	ev_sidebar_add_page (EV_SIDEBAR (ev_window->priv->sidebar),
 			     "index",
@@ -1707,30 +1869,33 @@ ev_window_init (EvWindow *ev_window)
 			  G_CALLBACK (view_find_status_changed_cb),
 			  ev_window);
 	g_signal_connect (ev_window->priv->view,
 			  "notify::status",
 			  G_CALLBACK (view_status_changed_cb),
 			  ev_window);
 
 	ev_window->priv->statusbar = gtk_statusbar_new ();
-	gtk_widget_show (ev_window->priv->statusbar);
 	gtk_box_pack_end (GTK_BOX (ev_window->priv->main_box),
 			  ev_window->priv->statusbar,
 			  FALSE, TRUE, 0);
 	ev_window->priv->help_message_cid = gtk_statusbar_get_context_id
 		(GTK_STATUSBAR (ev_window->priv->statusbar), "help_message");
 	ev_window->priv->view_message_cid = gtk_statusbar_get_context_id
 		(GTK_STATUSBAR (ev_window->priv->statusbar), "view_message");
 
 	ev_window->priv->find_bar = egg_find_bar_new ();
 	gtk_box_pack_end (GTK_BOX (ev_window->priv->main_box),
 			  ev_window->priv->find_bar,
 			  FALSE, TRUE, 0);
 
+	ev_window->priv->chrome = load_chrome ();
+	set_chrome_actions (ev_window);
+	update_chrome_visibility (ev_window);
+
 	/* Connect to find bar signals */
 	g_signal_connect (ev_window->priv->find_bar,
 			  "previous",
 			  G_CALLBACK (find_bar_previous_cb),
 			  ev_window);
 	g_signal_connect (ev_window->priv->find_bar,
 			  "next",
 			  G_CALLBACK (find_bar_next_cb),
@@ -1749,18 +1914,15 @@ ev_window_init (EvWindow *ev_window)
 			  ev_window);
 	g_signal_connect (ev_window->priv->find_bar,
 			  "notify::visible",
 			  G_CALLBACK (find_bar_search_changed_cb),
 			  ev_window);
 
 	g_signal_connect (ev_window, "window-state-event",
 			  G_CALLBACK (ev_window_state_event_cb),
-			  ev_window);
-	g_signal_connect (ev_window, "focus_out_event",
-			  G_CALLBACK (ev_window_focus_out_cb),
 			  ev_window);
 
 	/* Give focus to the scrolled window */
 	gtk_widget_grab_focus (ev_window->priv->scrolled_window);
 
 	update_action_sensitivity (ev_window);
 }
