Index: configure.in
===================================================================
RCS file: /cvs/gnome/totem/configure.in,v
retrieving revision 1.280
diff -u -p -r1.280 configure.in
--- configure.in	4 Aug 2006 10:52:13 -0000	1.280
+++ configure.in	11 Aug 2006 08:53:01 -0000
@@ -29,7 +29,7 @@ AC_PROG_LIBTOOL()
 PKG_PROG_PKG_CONFIG
 
 # Requirements
-GLIB_REQS=2.6.3
+GLIB_REQS=2.8.0
 GTK_REQS=2.5.6
 GNOMEVFS_REQS=2.8.2
 GNOMEUI_REQS=2.3.3
Index: data/totem.schemas.in
===================================================================
RCS file: /cvs/gnome/totem/data/totem.schemas.in,v
retrieving revision 1.32
diff -u -p -r1.32 totem.schemas.in
--- data/totem.schemas.in	17 Jun 2006 10:18:24 -0000	1.32
+++ data/totem.schemas.in	11 Aug 2006 08:53:01 -0000
@@ -115,17 +115,6 @@
       </schema>
 
       <schema>
-        <key>/schemas/apps/totem/sidebar_shown</key>
-	<applyto>/apps/totem/sidebar_shown</applyto>
-	<owner>totem</owner>
-	<type>bool</type>
-	<default>true</default>
-	<locale name="C">
-	  <short>Whether the sidebar is shown</short>
-	</locale>
-      </schema>
-
-      <schema>
         <key>/schemas/apps/totem/debug</key>
 	<applyto>/apps/totem/debug</applyto>
 	<owner>totem</owner>
@@ -166,28 +155,6 @@
 	  <long>
 	    Whether the main window should stay on top of the other ones
 	  </long>
-	</locale>
-      </schema>
-
-      <schema>
-        <key>/schemas/apps/totem/window_w</key>
-	<applyto>/apps/totem/window_w</applyto>
-	<owner>totem</owner>
-	<type>int</type>
-	<default>-1</default>
-	<locale name="C">
-	  <short>Width of the video widget</short>
-        </locale>
-      </schema>
-
-      <schema>
-        <key>/schemas/apps/totem/window_h</key>
-	<applyto>/apps/totem/window_h</applyto>
-	<owner>totem</owner>
-	<type>int</type>
-	<default>-1</default>
-	<locale name="C">
-	  <short>Height of the video widget</short>
 	</locale>
       </schema>
 
Index: src/totem-private.h
===================================================================
RCS file: /cvs/gnome/totem/src/totem-private.h,v
retrieving revision 1.40
diff -u -p -r1.40 totem-private.h
--- src/totem-private.h	18 Jun 2006 17:11:35 -0000	1.40
+++ src/totem-private.h	11 Aug 2006 08:53:02 -0000
@@ -143,6 +143,10 @@ struct Totem {
 	gint64 seek_to;
 	guint index;
 
+	/* Window State */
+	int bvw_size_w, bvw_size_h;
+	gboolean maximised;
+
 	/* other */
 	char *mrl;
 	TotemPlaylist *playlist;
Index: src/totem-sidebar.c
===================================================================
RCS file: /cvs/gnome/totem/src/totem-sidebar.c,v
retrieving revision 1.7
diff -u -p -r1.7 totem-sidebar.c
--- src/totem-sidebar.c	12 Jul 2006 09:50:25 -0000	1.7
+++ src/totem-sidebar.c	11 Aug 2006 08:53:02 -0000
@@ -106,10 +106,9 @@ totem_sidebar_is_visible (Totem *totem)
 }
 
 void
-totem_sidebar_setup (Totem *totem)
+totem_sidebar_setup (Totem *totem, gboolean visible)
 {
 	GtkWidget *item, *item2;
-	gboolean visible;
 
 	item = glade_xml_get_widget (totem->xml, "tmw_main_pane");
 	totem->sidebar = ev_sidebar_new ();
@@ -122,9 +121,6 @@ totem_sidebar_setup (Totem *totem)
 	gtk_widget_set_sensitive (GTK_WIDGET (totem->properties), FALSE);
 	gtk_paned_pack2 (GTK_PANED (item), totem->sidebar, FALSE, FALSE);
 
-	visible = gconf_client_get_bool (totem->gc,
-				GCONF_PREFIX"/sidebar_shown",
-				NULL);
 	totem->sidebar_shown = visible;
 
 	item = glade_xml_get_widget (totem->xml, "tmw_sidebar_button");
@@ -142,9 +138,8 @@ totem_sidebar_setup (Totem *totem)
 			G_CALLBACK (totem_sidebar_toggle), totem);
 
 	gtk_widget_show_all (totem->sidebar);
-	
 	gtk_widget_realize (totem->sidebar);
-	
+
 	if (!visible)
 		gtk_widget_hide (totem->sidebar);
 }
Index: src/totem-sidebar.h
===================================================================
RCS file: /cvs/gnome/totem/src/totem-sidebar.h,v
retrieving revision 1.1
diff -u -p -r1.1 totem-sidebar.h
--- src/totem-sidebar.h	4 Jul 2005 19:03:58 -0000	1.1
+++ src/totem-sidebar.h	11 Aug 2006 08:53:02 -0000
@@ -25,7 +25,7 @@
 
 G_BEGIN_DECLS
 
-void totem_sidebar_setup (Totem *totem);
+void totem_sidebar_setup (Totem *totem, gboolean visible);
 void totem_sidebar_toggle (Totem *totem);
 void totem_sidebar_set_visibility (Totem *totem, gboolean visible);
 gboolean totem_sidebar_is_visible (Totem *totem);
Index: src/totem.c
===================================================================
RCS file: /cvs/gnome/totem/src/totem.c,v
retrieving revision 1.509
diff -u -p -r1.509 totem.c
--- src/totem.c	10 Aug 2006 09:12:49 -0000	1.509
+++ src/totem.c	11 Aug 2006 08:53:06 -0000
@@ -151,13 +151,35 @@ totem_action_save_size (Totem *totem)
 		return;
 
 	/* Save the size of the video widget */
-	gconf_client_set_int (totem->gc,
-			GCONF_PREFIX"/window_w",
-			GTK_WIDGET(totem->bvw)->allocation.width, NULL);
-	gconf_client_set_int (totem->gc,
-			GCONF_PREFIX"/window_h",
-			GTK_WIDGET(totem->bvw)->allocation.height,
-			NULL);
+	totem->bvw_size_w = GTK_WIDGET(totem->bvw)->allocation.width
+		+ BVW_VBOX_BORDER_WIDTH;
+	totem->bvw_size_h = GTK_WIDGET(totem->bvw)->allocation.height
+		+ BVW_VBOX_BORDER_WIDTH;
+}
+
+static void
+totem_action_save_state (Totem *totem)
+{
+	GKeyFile *keyfile;
+	char *contents, *filename;
+
+	keyfile = g_key_file_new ();
+	g_key_file_set_integer (keyfile, "State",
+			"window_w", totem->bvw_size_w);
+	g_key_file_set_integer (keyfile, "State",
+			"window_h", totem->bvw_size_h);
+	g_key_file_set_boolean (keyfile, "State",
+			"show_sidebar", totem_sidebar_is_visible (totem));
+	g_key_file_set_boolean (keyfile, "State",
+			"maximised", totem->maximised);
+
+	contents = g_key_file_to_data (keyfile, NULL, NULL);
+	g_key_file_free (keyfile);
+	filename = g_build_filename (g_get_home_dir (), ".gnome2", "totem", NULL);
+	g_file_set_contents (filename, contents, -1, NULL);
+
+	g_free (filename);
+	g_free (contents);
 }
 
 void
@@ -190,8 +212,17 @@ totem_action_exit (Totem *totem)
 	if (display != NULL)
 		gdk_display_sync (display);
 
+	if (totem->bvw) {
+		//FIXME move the volume to the static file?
+		gconf_client_set_int (totem->gc,
+				GCONF_PREFIX"/volume",
+				bacon_video_widget_get_volume (totem->bvw),
+				NULL);
+		totem_action_save_size (totem);
+	}
+
 	bacon_message_connection_free (totem->conn);
-	totem_action_save_size (totem);
+	totem_action_save_state (totem);
 
 	totem_action_fullscreen (totem, FALSE);
 
@@ -199,12 +230,6 @@ totem_action_exit (Totem *totem)
 	totem_destroy_file_filters ();
 	totem_named_icons_dispose (totem);
 
-	if (totem->bvw)
-		gconf_client_set_int (totem->gc,
-				GCONF_PREFIX"/volume",
-				bacon_video_widget_get_volume (totem->bvw),
-				NULL);
-
 	if (totem->gc)
 		g_object_unref (G_OBJECT (totem->gc));
 
@@ -550,6 +575,12 @@ static gboolean
 window_state_event_cb (GtkWidget *window, GdkEventWindowState *event,
 		Totem *totem)
 {
+	if (event->changed_mask == GDK_WINDOW_STATE_MAXIMIZED) {
+		totem->maximised = (event->new_window_state
+				& GDK_WINDOW_STATE_MAXIMIZED);
+		return;
+	}
+
 	if (event->changed_mask != GDK_WINDOW_STATE_FULLSCREEN) {
 		return FALSE;
 	}
@@ -2977,18 +3008,62 @@ update_buttons (Totem *totem)
 static void
 totem_setup_window (Totem *totem)
 {
-	GtkWidget *item;
+	GKeyFile *keyfile;
 	int w, h;
+	gboolean show_sidebar;
+	char *filename;
+	GError *err = NULL;
 
-	w = gconf_client_get_int (totem->gc, GCONF_PREFIX"/window_w", NULL);
-	h = gconf_client_get_int (totem->gc, GCONF_PREFIX"/window_h", NULL);
+	filename = g_build_filename (g_get_home_dir (), ".gnome2", "totem", NULL);
+	keyfile = g_key_file_new ();
+	if (g_key_file_load_from_file (keyfile, filename,
+			G_KEY_FILE_NONE, NULL) == FALSE) {
+		w = h = 0;
+		show_sidebar = TRUE;
+		g_free (filename);
+	} else {
+		g_free (filename);
 
-	if (w <= 0 || h <= 0)
-		return;
+		w = g_key_file_get_integer (keyfile, "State", "window_w", &err);
+		if (err != NULL) {
+			w = 0;
+			g_error_free (err);
+			err = NULL;
+		}
+
+		h = g_key_file_get_integer (keyfile, "State", "window_h", &err);
+		if (err != NULL) {
+			h = 0;
+			g_error_free (err);
+			err = NULL;
+		}
+
+		show_sidebar = g_key_file_get_boolean (keyfile, "State",
+				"show_sidebar", &err);
+		if (err != NULL) {
+			show_sidebar = TRUE;
+			g_error_free (err);
+			err = NULL;
+		}
+
+		totem->maximised = g_key_file_get_boolean (keyfile, "State",
+				"maximised", &err);
+		if (err != NULL)
+			g_error_free (err);
+		g_key_file_free (keyfile);
+	}
+
+	if (w > 0 && h > 0 && totem->maximised == FALSE) {
+		GtkWidget *item;
+
+		item = glade_xml_get_widget (totem->xml, "tmw_bvw_vbox");
+		gtk_widget_set_size_request (item,
+				w + BVW_VBOX_BORDER_WIDTH, h + BVW_VBOX_BORDER_WIDTH);
+	} else if (totem->maximised != FALSE) {
+		gtk_window_maximize (GTK_WINDOW (totem->win));
+	}
 
-	item = glade_xml_get_widget (totem->xml, "tmw_bvw_vbox");
-	gtk_widget_set_size_request (item,
-			w + BVW_VBOX_BORDER_WIDTH, h + BVW_VBOX_BORDER_WIDTH);
+	totem_sidebar_setup (totem, show_sidebar);
 }
 
 static void
@@ -3582,7 +3657,6 @@ main (int argc, char **argv)
 	/* The sidebar */
 	playlist_widget_setup (totem);
 	totem->properties = bacon_video_widget_properties_new ();
-	totem_sidebar_setup (totem);
 
 	/* The rest of the widgets */
 	totem->state = STATE_STOPPED;
