Index: src/planner-window.c
===================================================================
RCS file: /cvs/gnome/planner/src/planner-window.c,v
retrieving revision 1.11
diff -u -p -r1.11 planner-window.c
--- src/planner-window.c	17 Apr 2004 15:02:27 -0000	1.11
+++ src/planner-window.c	23 Apr 2004 04:03:21 -0000
@@ -193,9 +193,15 @@ static GtkWidget *window_create_dialog_b
 							  const gchar                  *text);
 static gchar *    window_recent_tooltip_func             (EggRecentItem                *item,
 							  gpointer                      user_data);
+static void       window_save_state                      (PlannerWindow *window);
+static void       window_restore_state                   (PlannerWindow *window);
 
-
-
+#define GCONF_MAIN_WINDOW_DIR       "/apps/planner/ui"
+#define GCONF_MAIN_WINDOW_MAXIMIZED "/apps/planner/ui/main_window_maximized"
+#define GCONF_MAIN_WINDOW_WIDTH     "/apps/planner/ui/main_window_width"
+#define GCONF_MAIN_WINDOW_HEIGHT    "/apps/planner/ui/main_window_height"
+#define GCONF_MAIN_WINDOW_POS_X     "/apps/planner/ui/main_window_position_x"
+#define GCONF_MAIN_WINDOW_POS_Y     "/apps/planner/ui/main_window_position_y"
 
 #define VIEW_PATH "/menu/View/Views placeholder"
 #define VIEW_GROUP "view group"
@@ -1112,6 +1118,8 @@ window_delete_event_cb (PlannerWindow *w
 {
 	g_return_val_if_fail (PLANNER_IS_MAIN_WINDOW (window), FALSE);
 
+	window_save_state (window);
+
 	planner_window_close (window);
 
 	return TRUE;
@@ -1523,7 +1531,7 @@ planner_window_new (PlannerApplication *
 			  G_CALLBACK (window_project_notify_name_cb),
 			  window);
 	
-	gtk_window_set_default_size (GTK_WINDOW (window), 800, 600);
+	window_restore_state (window);
 
 	g_signal_connect (window, "delete_event", 
 			  G_CALLBACK (window_delete_event_cb),
@@ -1768,3 +1776,97 @@ planner_window_get_cmd_manager (PlannerW
 	return window->priv->cmd_manager;
 }
 
+static void
+window_save_state (PlannerWindow *window)
+{
+	GConfClient *gconf_client;
+	PlannerWindowPriv *priv;
+	GdkWindowState state;
+	gboolean       maximized;
+
+	priv = window->priv;
+	gconf_client = planner_application_get_gconf_client (priv->application);
+
+	state = gdk_window_get_state (GTK_WIDGET (window)->window);
+	if (state & GDK_WINDOW_STATE_MAXIMIZED) {
+		maximized = TRUE;
+	} else {
+		maximized = FALSE;
+	}
+
+	gconf_client_set_bool (gconf_client,
+			       GCONF_MAIN_WINDOW_MAXIMIZED,
+			       maximized, NULL);
+
+	/* If maximized don't save the size and position */
+	if (!maximized) {
+		int width, height;
+		int x, y;
+
+		gtk_window_get_size (GTK_WINDOW (window), &width, &height);
+		gconf_client_set_int (gconf_client,
+				      GCONF_MAIN_WINDOW_WIDTH,
+				      width, NULL);
+		gconf_client_set_int (gconf_client,
+				      GCONF_MAIN_WINDOW_HEIGHT,
+				      height, NULL);
+
+		gtk_window_get_position (GTK_WINDOW (window), &x, &y);
+		gconf_client_set_int (gconf_client,
+				      GCONF_MAIN_WINDOW_POS_X,
+				      x, NULL);
+		gconf_client_set_int (gconf_client,
+				      GCONF_MAIN_WINDOW_POS_Y,
+				      y, NULL);
+	}
+}
+
+static void
+window_restore_state (PlannerWindow *window)
+{
+	GConfClient *gconf_client;
+	PlannerWindowPriv *priv;
+	gboolean exists;
+	gboolean maximized;
+	int      width, height;
+	int      x, y;
+
+	priv = window->priv;
+	gconf_client = planner_application_get_gconf_client (priv->application);
+
+	exists = gconf_client_dir_exists (gconf_client,
+					   GCONF_MAIN_WINDOW_DIR,
+	                   NULL);
+	
+    if (exists) {	
+		maximized = gconf_client_get_bool (gconf_client,
+					   GCONF_MAIN_WINDOW_MAXIMIZED,
+					   NULL);
+	
+		if (maximized) {
+			gtk_window_maximize (GTK_WINDOW (window));
+		} else {
+			width = gconf_client_get_int (gconf_client,
+					      GCONF_MAIN_WINDOW_WIDTH,
+					      NULL);
+		
+			height = gconf_client_get_int (gconf_client,
+					       GCONF_MAIN_WINDOW_HEIGHT,
+					       NULL);
+		
+			gtk_window_set_default_size (GTK_WINDOW (window), 
+					     width, height);
+
+			x = gconf_client_get_int (gconf_client,
+					  GCONF_MAIN_WINDOW_POS_X,
+					  NULL);
+			y = gconf_client_get_int (gconf_client,
+					  GCONF_MAIN_WINDOW_POS_Y,
+					  NULL);
+
+			gtk_window_move (GTK_WINDOW (window), x, y);
+		}
+	} else {
+		gtk_window_set_default_size (GTK_WINDOW (window), 800, 600);
+	}
+}
