Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evince/ChangeLog,v
retrieving revision 1.203
diff -u -u -r1.203 ChangeLog
--- ChangeLog	23 Feb 2005 11:07:11 -0000	1.203
+++ ChangeLog	23 Feb 2005 12:11:00 -0000
@@ -1,3 +1,10 @@
+2005-02-23  Carlos Garcia Campos <carlosgc@gnome.org> 
+
+	* shell/ev-sidebar.[ch], shell/ev-window.c: Improved sidebar widget.
+	Fixes #166683
+
+	* data/evince.schemas.in: Added a new key to store the sidebar size
+
 2005-02-23  Tommi Vainikainen  <thv@iki.fi>
 
 	* shell/ev-view.c (update_find_status_message): Give translators
Index: data/evince.schemas.in
===================================================================
RCS file: /cvs/gnome/evince/data/evince.schemas.in,v
retrieving revision 1.2
diff -u -u -r1.2 evince.schemas.in
--- data/evince.schemas.in	7 Feb 2005 15:59:28 -0000	1.2
+++ data/evince.schemas.in	23 Feb 2005 12:11:00 -0000
@@ -33,5 +33,16 @@
         <long>Show statusbar by default.</long>
       </locale>
     </schema>
+    <schema>
+      <key>/schemas/apps/evince/sidebar_size</key>
+      <applyto>/apps/evince/sidebar_size</applyto>
+      <owner>evince</owner>
+      <type>int</type>
+      <default>132</default>
+      <locale name="C">
+        <short>Sidebar size by default</short>
+        <long>Sidebar size by default.</long>
+      </locale>
+    </schema>
   </schemalist>
 </gconfschemafile>
Index: shell/ev-sidebar.c
===================================================================
RCS file: /cvs/gnome/evince/shell/ev-sidebar.c,v
retrieving revision 1.7
diff -u -u -r1.7 ev-sidebar.c
--- shell/ev-sidebar.c	10 Jan 2005 19:08:15 -0000	1.7
+++ shell/ev-sidebar.c	23 Feb 2005 12:11:01 -0000
@@ -26,6 +26,7 @@
 
 #include <string.h>
 #include <gtk/gtk.h>
+#include <gdk/gdkkeysyms.h>
 
 #include "ev-sidebar.h"
 #include "ev-document-thumbnails.h"
@@ -35,109 +36,282 @@
 
 typedef struct
 {
-	char *id;
-	char *title;
-	GtkWidget *main_widget;
+	   char *id;
+	   char *title;
+	   GtkWidget *main_widget;
 } EvSidebarPage;
 
 enum
 {
-	PAGE_COLUMN_ID,
-	PAGE_COLUMN_TITLE,
-	PAGE_COLUMN_MAIN_WIDGET,
-	PAGE_COLUMN_NOTEBOOK_INDEX,
-	PAGE_COLUMN_NUM_COLS
+	   PAGE_COLUMN_ID,
+	   PAGE_COLUMN_TITLE,
+	   PAGE_COLUMN_MENU_ITEM,
+	   PAGE_COLUMN_MAIN_WIDGET,
+	   PAGE_COLUMN_NOTEBOOK_INDEX,
+	   PAGE_COLUMN_NUM_COLS
 };
 
 struct _EvSidebarPrivate {
-	GtkWidget *option_menu;
-	GtkWidget *notebook;
-
-	GtkTreeModel *page_model;
+	   GtkWidget *notebook;
+	   GtkWidget *menu;
+	   GtkWidget *frame;
+	   GtkWidget *hbox;
+	   GtkWidget *label;
+	   
+	   GtkTreeModel *page_model;
 };
 
-static void ev_sidebar_omenu_changed_cb (GtkComboBox *combo_box,
-					 gpointer     user_data);
-
 G_DEFINE_TYPE (EvSidebar, ev_sidebar, GTK_TYPE_VBOX)
 
 #define EV_SIDEBAR_GET_PRIVATE(object) \
-	(G_TYPE_INSTANCE_GET_PRIVATE ((object), EV_TYPE_SIDEBAR, EvSidebarPrivate))
+		(G_TYPE_INSTANCE_GET_PRIVATE ((object), EV_TYPE_SIDEBAR, EvSidebarPrivate))
+
+static void
+ev_sidebar_destroy (GtkObject *object)
+{
+	   EvSidebar *ev_sidebar = EV_SIDEBAR (object);
+	
+	   if (ev_sidebar->priv->menu) {
+			 gtk_menu_detach (GTK_MENU (ev_sidebar->priv->menu));
+			 ev_sidebar->priv->menu = NULL;
+	   }
+	   
+	   (* GTK_OBJECT_CLASS (ev_sidebar_parent_class)->destroy) (object);
+}
 
 static void
 ev_sidebar_class_init (EvSidebarClass *ev_sidebar_class)
 {
-	GObjectClass *g_object_class;
+	   GObjectClass *g_object_class;
+	   GtkWidgetClass *widget_class;
+	   GtkObjectClass *gtk_object_klass;
+	   
+	   g_object_class = G_OBJECT_CLASS (ev_sidebar_class);
+	   widget_class = GTK_WIDGET_CLASS (ev_sidebar_class);
+	   gtk_object_klass = GTK_OBJECT_CLASS (ev_sidebar_class);
+	   
+	   g_type_class_add_private (g_object_class, sizeof (EvSidebarPrivate));
+	   
+	   gtk_object_klass->destroy = ev_sidebar_destroy;
+}
 
-	g_object_class = G_OBJECT_CLASS (ev_sidebar_class);
+static void
+ev_sidebar_menu_position_under (GtkMenu *menu,
+						  int *x,
+						  int *y,
+						  gboolean *push_in,
+						  gpointer user_data)
+{
+	   GtkWidget *widget;
+	   
+	   g_return_if_fail (GTK_IS_BUTTON (user_data));
+	   g_return_if_fail (GTK_WIDGET_NO_WINDOW (user_data));
+	   
+	   widget = GTK_WIDGET (user_data);
+	   
+	   gdk_window_get_origin (widget->window, x, y);
+	   
+	   *x += widget->allocation.x;
+	   *y += widget->allocation.y + widget->allocation.height;
+	   
+	   *push_in = FALSE;
+}
 
-	g_type_class_add_private (g_object_class, sizeof (EvSidebarPrivate));
+static gboolean
+ev_sidebar_select_button_press_cb (GtkWidget *widget,
+							GdkEventButton *event,
+							gpointer user_data)
+{
+	   EvSidebar *ev_sidebar = EV_SIDEBAR (user_data);
+	   
+	   if (event->button == 1) {
+			 gtk_widget_grab_focus (widget);
+			 
+			 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE);
+			 gtk_menu_popup (GTK_MENU (ev_sidebar->priv->menu),
+						  NULL, NULL, ev_sidebar_menu_position_under, widget,
+						  event->button, event->time);
+			 
+			 return TRUE;
+	   }
+	   
+	   return FALSE;
+}
 
+static gboolean
+ev_sidebar_select_button_key_press_cb (GtkWidget *widget,
+							    GdkEventKey *event,
+							    gpointer user_data)
+{
+	   EvSidebar *ev_sidebar = EV_SIDEBAR (user_data);
+	   
+	   if (event->keyval == GDK_space ||
+		  event->keyval == GDK_KP_Space ||
+		  event->keyval == GDK_Return ||
+		  event->keyval == GDK_KP_Enter) {
+			 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE);
+			 gtk_menu_popup (GTK_MENU (ev_sidebar->priv->menu),
+						  NULL, NULL, ev_sidebar_menu_position_under, widget,
+						  1, event->time);
+			 return TRUE;
+	   }
+	   
+	   return FALSE;
 }
 
 static void
-ev_sidebar_init (EvSidebar *ev_sidebar)
+ev_sidebar_close_clicked_cb (GtkWidget *widget,
+					    gpointer user_data)
 {
-	GtkWidget *hbox;
-	GtkCellRenderer *renderer;
-	
-	ev_sidebar->priv = EV_SIDEBAR_GET_PRIVATE (ev_sidebar);
-	gtk_box_set_spacing (GTK_BOX (ev_sidebar), 6);
+	   EvSidebar *ev_sidebar = EV_SIDEBAR (user_data);
+	   
+	   gtk_widget_hide (GTK_WIDGET (ev_sidebar));
+}
 
-	/* data model */
-	ev_sidebar->priv->page_model = (GtkTreeModel *)
-		gtk_list_store_new (PAGE_COLUMN_NUM_COLS,
-				    G_TYPE_STRING,
-				    G_TYPE_STRING,
-				    GTK_TYPE_WIDGET,
-				    G_TYPE_INT);
-
-	/* top option menu */
-	hbox = gtk_hbox_new (FALSE, 6);
-	gtk_box_pack_start (GTK_BOX (ev_sidebar), hbox,
-			    FALSE, FALSE, 0);
-	ev_sidebar->priv->option_menu =
-		gtk_combo_box_new_with_model (ev_sidebar->priv->page_model);
-	g_signal_connect (ev_sidebar->priv->option_menu, "changed",
-			  G_CALLBACK (ev_sidebar_omenu_changed_cb), ev_sidebar);
-	gtk_box_pack_start (GTK_BOX (hbox),
-			    ev_sidebar->priv->option_menu,
-			    FALSE, FALSE, 0);
-	
-	renderer = gtk_cell_renderer_text_new ();
-	gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (ev_sidebar->priv->option_menu),
-				    renderer, TRUE);
-	gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (ev_sidebar->priv->option_menu),
-					renderer,
-					"text", PAGE_COLUMN_TITLE,
-					NULL);
-
-	ev_sidebar->priv->notebook = gtk_notebook_new ();
-	gtk_notebook_set_show_border (GTK_NOTEBOOK (ev_sidebar->priv->notebook), FALSE);
-	gtk_notebook_set_show_tabs (GTK_NOTEBOOK (ev_sidebar->priv->notebook), FALSE);
-	gtk_box_pack_start (GTK_BOX (ev_sidebar), ev_sidebar->priv->notebook,
-			    TRUE, TRUE, 0);
-	gtk_widget_show_all (GTK_WIDGET (ev_sidebar));
+static void
+ev_sidebar_menu_deactivate_cb (GtkWidget *widget,
+						 gpointer user_data)
+{
+	   GtkWidget *menu_button;
+	   
+	   menu_button = GTK_WIDGET (user_data);
+	   
+	   gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (menu_button), FALSE);
 }
 
 static void
-ev_sidebar_omenu_changed_cb (GtkComboBox *combo_box,
-			     gpointer     user_data)
-{
-	GtkTreeIter iter;
-	EvSidebar *ev_sidebar = EV_SIDEBAR (user_data);
-
-	if (gtk_combo_box_get_active_iter (combo_box, &iter)) {
-		gint index;
-
-		gtk_tree_model_get (ev_sidebar->priv->page_model,
-				    &iter,
-				    PAGE_COLUMN_NOTEBOOK_INDEX, &index,
-				    -1);
-		gtk_notebook_set_current_page (GTK_NOTEBOOK (ev_sidebar->priv->notebook),
-					       index);
-					       
-	}
+ev_sidebar_menu_detach_cb (GtkWidget *widget,
+					  GtkMenu *menu)
+{
+	   EvSidebar *ev_sidebar = EV_SIDEBAR (widget);
+	   
+	   ev_sidebar->priv->menu = NULL;
+}
+
+static void
+ev_sidebar_menu_item_activate_cb (GtkWidget *widget,
+						    gpointer user_data)
+{
+	   EvSidebar *ev_sidebar = EV_SIDEBAR (user_data);
+	   GtkTreeIter iter;
+	   GtkWidget *menu_item, *item;
+	   gchar *title;
+	   gboolean valid;
+	   gint index;
+	   
+	   menu_item = gtk_menu_get_active (GTK_MENU (ev_sidebar->priv->menu));
+	   valid = gtk_tree_model_get_iter_first (ev_sidebar->priv->page_model, &iter);
+	   
+	   while (valid) {
+			 gtk_tree_model_get (ev_sidebar->priv->page_model,
+							 &iter,
+							 PAGE_COLUMN_TITLE, &title, 
+							 PAGE_COLUMN_MENU_ITEM, &item,
+							 PAGE_COLUMN_NOTEBOOK_INDEX, &index,
+							 -1);
+			 
+			 if (item == menu_item) {
+				    gtk_notebook_set_current_page (GTK_NOTEBOOK (ev_sidebar->priv->notebook),
+											index);
+				    gtk_label_set_text (GTK_LABEL (ev_sidebar->priv->label), title);
+				    
+				    valid = FALSE;
+			 } else {
+				    valid = gtk_tree_model_iter_next (ev_sidebar->priv->page_model, &iter);
+			 }
+	   }
+}
+
+static void
+ev_sidebar_init (EvSidebar *ev_sidebar)
+{
+	   GtkWidget *frame;
+	   GtkWidget *hbox;
+	   GtkWidget *close_button;
+	   GtkWidget *select_button;
+	   GtkWidget *select_hbox;
+	   GtkWidget *arrow;
+	   GtkWidget *image;
+	   
+	   ev_sidebar->priv = EV_SIDEBAR_GET_PRIVATE (ev_sidebar);
+	   gtk_box_set_spacing (GTK_BOX (ev_sidebar), 6);
+	   
+	   /* data model */
+	   ev_sidebar->priv->page_model = (GtkTreeModel *)
+			 gtk_list_store_new (PAGE_COLUMN_NUM_COLS,
+							 G_TYPE_STRING,
+							 G_TYPE_STRING,
+							 GTK_TYPE_WIDGET,
+							 GTK_TYPE_WIDGET,
+							 G_TYPE_INT);
+	   
+	   /* top option menu */
+	   frame = gtk_frame_new (NULL);
+	   ev_sidebar->priv->frame = frame;
+	   gtk_box_pack_start (GTK_BOX (ev_sidebar), frame, FALSE, FALSE, 0);
+	   gtk_widget_show (frame);
+	   
+	   hbox = gtk_hbox_new (FALSE, 0);
+	   ev_sidebar->priv->hbox = hbox;
+	   gtk_container_add (GTK_CONTAINER (frame), hbox);
+	   gtk_widget_show (hbox);
+	   
+	   select_button = gtk_toggle_button_new ();
+	   gtk_button_set_relief (GTK_BUTTON (select_button), GTK_RELIEF_NONE);
+	   g_signal_connect (select_button, "button_press_event",
+					 G_CALLBACK (ev_sidebar_select_button_press_cb),
+					 ev_sidebar);
+	   g_signal_connect (select_button, "key_press_event",
+					 G_CALLBACK (ev_sidebar_select_button_key_press_cb),
+					 ev_sidebar);
+	   
+	   select_hbox = gtk_hbox_new (FALSE, 0);
+	   
+	   ev_sidebar->priv->label = gtk_label_new ("");
+	   gtk_box_pack_start (GTK_BOX (select_hbox),
+					   ev_sidebar->priv->label,
+					   TRUE, FALSE, 0);
+	   gtk_widget_show (ev_sidebar->priv->label);
+
+	   arrow = gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_NONE);
+	   gtk_box_pack_end (GTK_BOX (select_hbox), arrow, FALSE, FALSE, 0);
+	   gtk_widget_show (arrow);
+	
+	   gtk_container_add (GTK_CONTAINER (select_button), select_hbox);
+	   gtk_widget_show (select_hbox);
+	   
+	   gtk_box_pack_start (GTK_BOX (hbox), select_button, FALSE, FALSE, 0);
+	   gtk_widget_show (select_button);
+	   
+	   close_button = gtk_button_new ();
+	   gtk_button_set_relief (GTK_BUTTON (close_button), GTK_RELIEF_NONE);
+	   g_signal_connect (close_button, "clicked",
+					 G_CALLBACK (ev_sidebar_close_clicked_cb),
+					 ev_sidebar);
+	   
+	   image = gtk_image_new_from_stock (GTK_STOCK_CLOSE,
+								  GTK_ICON_SIZE_SMALL_TOOLBAR);
+	   gtk_container_add (GTK_CONTAINER (close_button), image);
+	   gtk_widget_show (image);
+	   
+	   gtk_box_pack_end (GTK_BOX (hbox), close_button, FALSE, FALSE, 0);
+	   gtk_widget_show (close_button);
+	   
+	   ev_sidebar->priv->menu = gtk_menu_new ();
+	   g_signal_connect (ev_sidebar->priv->menu, "deactivate",
+					 G_CALLBACK (ev_sidebar_menu_deactivate_cb),
+					 select_button);
+	   gtk_menu_attach_to_widget (GTK_MENU (ev_sidebar->priv->menu),
+							GTK_WIDGET (ev_sidebar),
+							ev_sidebar_menu_detach_cb);
+	   gtk_widget_show (ev_sidebar->priv->menu);
+	   
+	   ev_sidebar->priv->notebook = gtk_notebook_new ();
+	   gtk_notebook_set_show_border (GTK_NOTEBOOK (ev_sidebar->priv->notebook), FALSE);
+	   gtk_notebook_set_show_tabs (GTK_NOTEBOOK (ev_sidebar->priv->notebook), FALSE);
+	   gtk_box_pack_start (GTK_BOX (ev_sidebar), ev_sidebar->priv->notebook,
+					   TRUE, TRUE, 0);
+	   gtk_widget_show (ev_sidebar->priv->notebook);
 }
 
 /* Public functions */
@@ -145,86 +319,104 @@
 GtkWidget *
 ev_sidebar_new (void)
 {
-	GtkWidget *ev_sidebar;
-
-	ev_sidebar = g_object_new (EV_TYPE_SIDEBAR, NULL);
-
-	return ev_sidebar;
+	   GtkWidget *ev_sidebar;
+	   
+	   ev_sidebar = g_object_new (EV_TYPE_SIDEBAR, NULL);
+	   
+	   return ev_sidebar;
 }
 
 void
 ev_sidebar_add_page (EvSidebar   *ev_sidebar,
-		     const gchar *page_id,
-		     const gchar *title,
-		     GtkWidget   *main_widget)
-{
-	GtkTreeIter iter;
-	int index;
-
-	g_return_if_fail (EV_IS_SIDEBAR (ev_sidebar));
-	g_return_if_fail (page_id != NULL);
-	g_return_if_fail (title != NULL);
-	g_return_if_fail (GTK_IS_WIDGET (main_widget));
-
-	index = gtk_notebook_append_page (GTK_NOTEBOOK (ev_sidebar->priv->notebook),
-					  main_widget, NULL);
-					  
-	gtk_list_store_insert_with_values (GTK_LIST_STORE (ev_sidebar->priv->page_model),
-					   &iter, 0,
-					   PAGE_COLUMN_ID, page_id,
-					   PAGE_COLUMN_TITLE, title,
-					   PAGE_COLUMN_MAIN_WIDGET, main_widget,
-					   PAGE_COLUMN_NOTEBOOK_INDEX, index,
+				 const gchar *page_id,
+				 const gchar *title,
+				 GtkWidget   *main_widget)
+{
+	   GtkTreeIter iter;
+	   GtkWidget *menu_item;
+	   gchar *label_title;
+	   int index;
+	   
+	   g_return_if_fail (EV_IS_SIDEBAR (ev_sidebar));
+	   g_return_if_fail (page_id != NULL);
+	   g_return_if_fail (title != NULL);
+	   g_return_if_fail (GTK_IS_WIDGET (main_widget));
+	   
+	   index = gtk_notebook_append_page (GTK_NOTEBOOK (ev_sidebar->priv->notebook),
+								  main_widget, NULL);
+	   
+	   menu_item = gtk_image_menu_item_new_with_label (title);
+	   g_signal_connect (menu_item, "activate",
+					 G_CALLBACK (ev_sidebar_menu_item_activate_cb),
+					 ev_sidebar);
+	   gtk_widget_show (menu_item);
+	   gtk_menu_shell_append (GTK_MENU_SHELL (ev_sidebar->priv->menu),
+						 menu_item);
+	   
+	   gtk_list_store_insert_with_values (GTK_LIST_STORE (ev_sidebar->priv->page_model),
+								   &iter, 0,
+								   PAGE_COLUMN_ID, page_id,
+								   PAGE_COLUMN_TITLE, title,
+								   PAGE_COLUMN_MENU_ITEM, menu_item,
+								   PAGE_COLUMN_MAIN_WIDGET, main_widget,
+								   PAGE_COLUMN_NOTEBOOK_INDEX, index,
+								   -1);
+	   
+	   /* Set the first item added as active */
+	   gtk_tree_model_get_iter_first (ev_sidebar->priv->page_model, &iter);
+	   gtk_tree_model_get (ev_sidebar->priv->page_model,
+					   &iter,
+					   PAGE_COLUMN_TITLE, &label_title,
+					   PAGE_COLUMN_NOTEBOOK_INDEX, &index,
 					   -1);
-
-	/* Set the first item added as active */
-	if (gtk_combo_box_get_active (GTK_COMBO_BOX (ev_sidebar->priv->option_menu)))
-		gtk_combo_box_set_active (GTK_COMBO_BOX (ev_sidebar->priv->option_menu), 0);
+	
+	   gtk_menu_set_active (GTK_MENU (ev_sidebar->priv->menu), index);
+	   gtk_label_set_text (GTK_LABEL (ev_sidebar->priv->label), label_title);
+	   gtk_notebook_set_current_page (GTK_NOTEBOOK (ev_sidebar->priv->notebook),
+							    index);
 }
 
 void
 ev_sidebar_set_document (EvSidebar   *sidebar,
-			 EvDocument  *document)
+					EvDocument  *document)
 {
-	EvSidebarPrivate *priv;
-	GtkTreeIter iter;
-	gboolean result;
-
-	g_return_if_fail (EV_IS_SIDEBAR (sidebar));
-	g_return_if_fail (EV_IS_DOCUMENT (document));
-
-	priv = sidebar->priv;
-	
-	/* FIXME: We should prolly make sidebars have an interface.  For now, we
-	 * do this bad hack (TM)
-	 */
-	for (result = gtk_tree_model_get_iter_first (priv->page_model, &iter);
-	     result;
-	     result = gtk_tree_model_iter_next (priv->page_model, &iter)) {
-		GtkWidget *widget;
-
-		gtk_tree_model_get (priv->page_model, &iter,
-				    PAGE_COLUMN_MAIN_WIDGET, &widget,
-				    -1);
-
-		if (EV_IS_SIDEBAR_LINKS (widget)
-		    && EV_IS_DOCUMENT_LINKS (document)
-		    && ev_document_links_has_document_links (EV_DOCUMENT_LINKS (document)))
-			ev_sidebar_links_set_document (EV_SIDEBAR_LINKS (widget),
-						       document);
-		else if (EV_IS_SIDEBAR_THUMBNAILS (widget) &&
-			 EV_IS_DOCUMENT_THUMBNAILS (document))
-			ev_sidebar_thumbnails_set_document (EV_SIDEBAR_THUMBNAILS (widget),
-							    document);
-	}
+	   EvSidebarPrivate *priv;
+	   GtkTreeIter iter;
+	   gboolean result;
+	   
+	   g_return_if_fail (EV_IS_SIDEBAR (sidebar));
+	   g_return_if_fail (EV_IS_DOCUMENT (document));
+	   
+	   priv = sidebar->priv;
 	
-
+	   /* FIXME: We should prolly make sidebars have an interface.  For now, we	
+	    * do this bad hack (TM)	
+	    */
+	   for (result = gtk_tree_model_get_iter_first (priv->page_model, &iter);
+		   result;
+		   result = gtk_tree_model_iter_next (priv->page_model, &iter)) {
+			 GtkWidget *widget;
+			 
+			 gtk_tree_model_get (priv->page_model, &iter,
+							 PAGE_COLUMN_MAIN_WIDGET, &widget,
+							 -1);
+			 
+			 if (EV_IS_SIDEBAR_LINKS (widget)
+				&& EV_IS_DOCUMENT_LINKS (document)
+				&& ev_document_links_has_document_links (EV_DOCUMENT_LINKS (document)))
+				    ev_sidebar_links_set_document (EV_SIDEBAR_LINKS (widget),
+											document);
+			 else if (EV_IS_SIDEBAR_THUMBNAILS (widget) &&
+					EV_IS_DOCUMENT_THUMBNAILS (document))
+				    ev_sidebar_thumbnails_set_document (EV_SIDEBAR_THUMBNAILS (widget),
+												document);
+	   }
 }
 
 void
 ev_sidebar_clear (EvSidebar *ev_sidebar)
 {
-	g_return_if_fail (EV_IS_SIDEBAR (ev_sidebar));
-
-	gtk_list_store_clear (GTK_LIST_STORE (ev_sidebar->priv->page_model));
+	   g_return_if_fail (EV_IS_SIDEBAR (ev_sidebar));
+	   
+	   gtk_list_store_clear (GTK_LIST_STORE (ev_sidebar->priv->page_model));
 }
Index: shell/ev-sidebar.h
===================================================================
RCS file: /cvs/gnome/evince/shell/ev-sidebar.h,v
retrieving revision 1.3
diff -u -u -r1.3 ev-sidebar.h
--- shell/ev-sidebar.h	22 Dec 2004 18:41:31 -0000	1.3
+++ shell/ev-sidebar.h	23 Feb 2005 12:11:01 -0000
@@ -33,31 +33,31 @@
 typedef struct _EvSidebarClass EvSidebarClass;
 typedef struct _EvSidebarPrivate EvSidebarPrivate;
 
-#define EV_TYPE_SIDEBAR			(ev_sidebar_get_type())
-#define EV_SIDEBAR(object)		(G_TYPE_CHECK_INSTANCE_CAST((object), EV_TYPE_SIDEBAR, EvSidebar))
+#define EV_TYPE_SIDEBAR			     (ev_sidebar_get_type())
+#define EV_SIDEBAR(object)		     (G_TYPE_CHECK_INSTANCE_CAST((object), EV_TYPE_SIDEBAR, EvSidebar))
 #define EV_SIDEBAR_CLASS(klass)		(G_TYPE_CHACK_CLASS_CAST((klass), EV_TYPE_SIDEBAR, EvSidebarClass))
-#define EV_IS_SIDEBAR(object)		(G_TYPE_CHECK_INSTANCE_TYPE((object), EV_TYPE_SIDEBAR))
-#define EV_IS_SIDEBAR_CLASS(klass)	(G_TYPE_CHECK_CLASS_TYPE((klass), EV_TYPE_SIDEBAR))
+#define EV_IS_SIDEBAR(object)		     (G_TYPE_CHECK_INSTANCE_TYPE((object), EV_TYPE_SIDEBAR))
+#define EV_IS_SIDEBAR_CLASS(klass)	     (G_TYPE_CHECK_CLASS_TYPE((klass), EV_TYPE_SIDEBAR))
 #define EV_SIDEBAR_GET_CLASS(object)	(G_TYPE_INSTANCE_GET_CLASS((object), EV_TYPE_SIDEBAR, EvSidebarClass))
 
 struct _EvSidebar {
-	GtkVBox base_instance;
+	   GtkVBox base_instance;
 
-	EvSidebarPrivate *priv;
+	   EvSidebarPrivate *priv;
 };
 
 struct _EvSidebarClass {
-	GtkVBoxClass base_class;
+	   GtkVBoxClass base_class;
 };
 
 GType      ev_sidebar_get_type     (void);
 GtkWidget *ev_sidebar_new          (void);
 void       ev_sidebar_add_page     (EvSidebar   *ev_sidebar,
-				    const gchar *page_id,
-				    const gchar *title,
-				    GtkWidget   *main_widget);
+							 const gchar *page_id,
+							 const gchar *title,
+							 GtkWidget   *main_widget);
 void       ev_sidebar_set_document (EvSidebar   *ev_sidebar,
-				    EvDocument  *document);
+							 EvDocument  *document);
 void       ev_sidebar_clear        (EvSidebar   *ev_sidebar);
 
 G_END_DECLS
Index: shell/ev-window.c
===================================================================
RCS file: /cvs/gnome/evince/shell/ev-window.c,v
retrieving revision 1.71
diff -u -u -r1.71 ev-window.c
--- shell/ev-window.c	18 Feb 2005 21:07:58 -0000	1.71
+++ shell/ev-window.c	23 Feb 2005 12:11:01 -0000
@@ -82,6 +82,7 @@
 	GtkWidget *toolbar;
 	GtkWidget *hpaned;
 	GtkWidget *sidebar;
+	gint sidebar_size;
 	GtkWidget *thumbs_sidebar;
 	GtkWidget *find_bar;
 	GtkWidget *scrolled_window;
@@ -125,6 +126,9 @@
 #define GCONF_CHROME_SIDEBAR	"/apps/evince/show_sidebar"
 #define GCONF_CHROME_STATUSBAR	"/apps/evince/show_statusbar"
 
+#define GCONF_SIDEBAR_SIZE      "/apps/evince/sidebar_size"
+#define SIDEBAR_DEFAULT_SIZE    132
+
 static void     ev_window_update_fullscreen_popup (EvWindow         *window);
 static void     ev_window_set_page_mode           (EvWindow         *window,
 						   EvWindowPageMode  page_mode);
@@ -216,6 +220,15 @@
 }
 
 static void
+set_widget_visibility (GtkWidget *widget, gboolean visible)
+{
+	if (visible)
+		gtk_widget_show (widget);
+	else
+		gtk_widget_hide (widget);
+}
+
+static void
 update_chrome_visibility (EvWindow *window)
 {
 	EvWindowPrivate *priv = window->priv;
@@ -228,16 +241,16 @@
 	statusbar = (priv->chrome & EV_CHROME_STATUSBAR) != 0 && !priv->fullscreen_mode;
 	findbar = (priv->chrome & EV_CHROME_FINDBAR) != 0;
 
-	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->fullscreen_toolbar, "visible", fullscreen_toolbar, NULL);
-
-	if (priv->fullscreen_popup) {
-		g_object_set (priv->fullscreen_popup, "visible", priv->fullscreen_mode, NULL);
-	} 
+	set_widget_visibility (priv->menubar, menubar);
+	set_widget_visibility (priv->toolbar_dock, toolbar);
+	set_widget_visibility (priv->sidebar, sidebar);
+	set_widget_visibility (priv->find_bar, findbar);
+	set_widget_visibility (priv->statusbar, statusbar);
+	set_widget_visibility (priv->fullscreen_toolbar, fullscreen_toolbar);
+
+	if (priv->fullscreen_popup != NULL) {
+		set_widget_visibility (priv->fullscreen_popup, priv->fullscreen_mode);
+	}
 }
 
 static void
@@ -1018,6 +1031,13 @@
 }
 
 static void
+ev_window_sidebar_position_change_cb (GObject *object, GParamSpec *pspec,
+				      EvWindow *ev_window)
+{
+	ev_window->priv->sidebar_size = gtk_paned_get_position (GTK_PANED (object));
+}
+
+static void
 destroy_fullscreen_popup (EvWindow *window)
 {
 	if (window->priv->fullscreen_popup != NULL)
@@ -1621,6 +1641,33 @@
 }
 
 static void
+ev_window_sidebar_visibility_changed_cb (EvSidebar *ev_sidebar, GParamSpec *pspec,
+					 EvWindow   *ev_window)
+{
+	GtkAction *action;
+	gboolean visible;
+
+	visible = GTK_WIDGET_VISIBLE (ev_sidebar);
+
+	/* In fullscreen mode the sidebar is not visible,
+	 * but we don't want to update the chrome
+	 */
+	if (ev_window->priv->fullscreen_mode)
+		return;
+	
+	action = gtk_action_group_get_action (ev_window->priv->action_group, "ViewSidebar");
+	
+	g_signal_handlers_block_by_func
+		(action, G_CALLBACK (ev_window_view_sidebar_cb), ev_window);
+	gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), visible);
+	g_signal_handlers_unblock_by_func
+		(action, G_CALLBACK (ev_window_view_sidebar_cb), ev_window);
+
+	update_chrome_flag (ev_window, EV_CHROME_SIDEBAR,
+			    GCONF_CHROME_SIDEBAR, visible);
+}
+
+static void
 menu_item_select_cb (GtkMenuItem *proxy, EvWindow *ev_window)
 {
 	GtkAction *action;
@@ -1803,6 +1850,7 @@
 {
 	EvWindow *window = EV_WINDOW (object);
 	EvWindowPrivate *priv = window->priv;
+	GConfClient *client;
 
 	if (priv->ui_manager) {
 		g_object_unref (priv->ui_manager);
@@ -1841,6 +1889,10 @@
 
 	destroy_fullscreen_popup (window);
 
+	client = gconf_client_get_default ();
+	gconf_client_set_int (client, GCONF_SIDEBAR_SIZE, priv->sidebar_size, NULL);
+	g_object_unref (client);
+
 	G_OBJECT_CLASS (ev_window_parent_class)->dispose (object);
 }
 
@@ -2106,6 +2158,8 @@
 	GtkAccelGroup *accel_group;
 	GError *error = NULL;
 	GtkWidget *sidebar_widget, *toolbar_dock;
+	GConfValue *value;
+	GConfClient *client;
 
 	ev_window->priv = EV_WINDOW_GET_PRIVATE (ev_window);
 
@@ -2182,11 +2236,33 @@
 
 	/* Add the main area */
 	ev_window->priv->hpaned = gtk_hpaned_new ();
-	gtk_widget_show (ev_window->priv->hpaned);
+	g_signal_connect (ev_window->priv->hpaned,
+			  "notify::position",
+			  G_CALLBACK (ev_window_sidebar_position_change_cb),
+			  ev_window);
+
+	ev_window->priv->sidebar_size = SIDEBAR_DEFAULT_SIZE;
+	client = gconf_client_get_default ();
+	value = gconf_client_get (client, GCONF_SIDEBAR_SIZE, NULL);
+	if (value != NULL) {
+		if (value->type == GCONF_VALUE_INT) {
+			ev_window->priv->sidebar_size = gconf_value_get_int (value);
+		}
+		gconf_value_free (value);
+	}
+	g_object_unref (client);
+
+	gtk_paned_set_position (GTK_PANED (ev_window->priv->hpaned),
+				ev_window->priv->sidebar_size);
 	gtk_box_pack_start (GTK_BOX (ev_window->priv->main_box), ev_window->priv->hpaned,
 			    TRUE, TRUE, 0);
-
+	gtk_widget_show (ev_window->priv->hpaned);
+	
 	ev_window->priv->sidebar = ev_sidebar_new ();
+	g_signal_connect (ev_window->priv->sidebar,
+			  "notify::visible",
+			  G_CALLBACK (ev_window_sidebar_visibility_changed_cb),
+			  ev_window);
 	gtk_paned_add1 (GTK_PANED (ev_window->priv->hpaned),
 			ev_window->priv->sidebar);
 
