? help/gnome-search-tool-C.omf
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gnome-utils/gsearchtool/ChangeLog,v
retrieving revision 1.447
diff -u -u -p -r1.447 ChangeLog
--- ChangeLog	3 Dec 2005 07:01:02 -0000	1.447
+++ ChangeLog	20 Dec 2005 00:15:56 -0000
@@ -1,3 +1,14 @@
+2005-12-20  Emmanuele Bassi  <ebassi@cvs.gnome.org>
+
+	* gsearchtool.h: add default_width and default_height.
+	* gsearchtool.c: (gsearchtool_size_allocate), (gsearch_app_create),
+	(add_constraint): set and store the allocated size.
+	* gsearchtool-support.h: add gsearchtool_gconf_set_int and
+	get_stored_window_geometry.
+	* gsearchtool-support.c: ditto.
+	* gnome-search-tool.schemas.in: add window-width and window-height keys
+	to the schema.
+
 2005-12-02  Dennis Cranston  <dennis_cranston@yahoo.com>
 
 	* gsearchtool-callbacks.c: (save_results_cb):  Make this
Index: gnome-search-tool.schemas.in
===================================================================
RCS file: /cvs/gnome/gnome-utils/gsearchtool/gnome-search-tool.schemas.in,v
retrieving revision 1.11
diff -u -u -p -r1.11 gnome-search-tool.schemas.in
--- gnome-search-tool.schemas.in	5 Nov 2005 19:15:19 -0000	1.11
+++ gnome-search-tool.schemas.in	20 Dec 2005 00:15:56 -0000
@@ -331,5 +331,35 @@ To change the gconftool target use the -
         </long>
       </locale>
     </schema>
+    <schema>
+      <applyto>/apps/gnome-search-tool/window-width</applyto>
+      <key>/schemas/apps/gnome-search-tool/window-width</key>
+      <owner>gnome-search-tool</owner>
+      <type>int</type>
+      <default>-1</default>
+      <locale name="C">
+        <short>Window width</short>
+	<long>
+	  This key defines the window width, and it's used to remember the
+	  size of the search tool between sessions.  Setting it to -1 will
+	  make the search tool use the default size.
+	</long>
+      </locale>
+    </schema>
+    <schema>
+      <applyto>/apps/gnome-search-tool/window-height</applyto>
+      <key>/schemas/apps/gnome-search-tool/window-height</key>
+      <owner>gnome-search-tool</owner>
+      <type>int</type>
+      <default>-1</default>
+      <locale name="C">
+        <short>Window width</short>
+	<long>
+	  This key defines the window height, and it's used to remember the
+	  size of the search tool between sessions.  Setting it to -1 will
+	  make the search tool use the default size.
+	</long>
+      </locale>
+    </schema>
   </schemalist>
 </gconfschemafile>
Index: gsearchtool-support.c
===================================================================
RCS file: /cvs/gnome/gnome-utils/gsearchtool/gsearchtool-support.c,v
retrieving revision 1.86
diff -u -u -p -r1.86 gsearchtool-support.c
--- gsearchtool-support.c	5 Nov 2005 19:15:19 -0000	1.86
+++ gsearchtool-support.c	20 Dec 2005 00:15:56 -0000
@@ -182,6 +182,23 @@ gsearchtool_gconf_get_int (const gchar *
 	return result;
 }
 
+void
+gsearchtool_gconf_set_int (const gchar * key,
+                           const gint    value)
+{
+	GConfClient * client;
+	GError * error = NULL;
+	
+	g_return_if_fail (key != NULL);
+	
+	client = gsearchtool_gconf_client_get_global ();
+	g_return_if_fail (client != NULL);
+	
+	gconf_client_set_int (client, key, value, &error);
+	
+	gsearchtool_gconf_handle_error (&error);
+}
+
 gboolean 
 gsearchtool_gconf_get_boolean (const gchar * key)
 {
@@ -1475,4 +1492,25 @@ gsearchtool_set_columns_order (GtkTreeVi
 		}
 	}
 	g_slist_free (order);
+}
+
+void
+get_stored_window_geometry (gint *width,
+			    gint *height)
+{
+	gint saved_width, saved_height;
+
+	saved_width = gsearchtool_gconf_get_int ("/apps/gnome-search-tool/window-width");
+	if (saved_width == -1)
+		saved_width = MINIMUM_WINDOW_WIDTH;
+
+	saved_height = gsearchtool_gconf_get_int ("/apps/gnome-search-tool/window-height");
+	if (saved_height == -1)
+		saved_width = MINIMUM_WINDOW_HEIGHT;
+
+	if (width)
+		*width = saved_width;
+
+	if (height)
+		*height = saved_height;
 }
Index: gsearchtool-support.h
===================================================================
RCS file: /cvs/gnome/gnome-utils/gsearchtool/gsearchtool-support.h,v
retrieving revision 1.31
diff -u -u -p -r1.31 gsearchtool-support.h
--- gsearchtool-support.h	5 Nov 2005 19:15:19 -0000	1.31
+++ gsearchtool-support.h	20 Dec 2005 00:15:56 -0000
@@ -46,6 +46,10 @@ gsearchtool_gconf_set_boolean (const gch
 gint 
 gsearchtool_gconf_get_int (const gchar * key);
 
+void
+gsearchtool_gconf_set_int (const gchar * key,
+			   const gint    value);
+
 char *
 gsearchtool_gconf_get_string (const gchar * key);
 
@@ -121,6 +125,11 @@ gsearchtool_get_columns_order (GtkTreeVi
 
 void
 gsearchtool_set_columns_order (GtkTreeView * treeview);
+
+void
+get_stored_window_geometry (gint *width,
+			    gint *height);
+
 #ifdef __cplusplus
 }
 #endif
Index: gsearchtool.c
===================================================================
RCS file: /cvs/gnome/gnome-utils/gsearchtool/gsearchtool.c,v
retrieving revision 1.296
diff -u -u -p -r1.296 gsearchtool.c
--- gsearchtool.c	2 Dec 2005 22:10:07 -0000	1.296
+++ gsearchtool.c	20 Dec 2005 00:15:56 -0000
@@ -2052,7 +2052,8 @@ add_constraint (GSearchWindow * gsearch,
 			gtk_widget_show (gsearch->available_options_vbox);
 		}
 	} 
-	
+
+#if 0
 	gsearch->window_geometry.min_height += WINDOW_HEIGHT_STEP;
 	
 	if (GTK_WIDGET_VISIBLE (gsearch->available_options_vbox)) {
@@ -2061,6 +2062,14 @@ add_constraint (GSearchWindow * gsearch,
 		                               &gsearch->window_geometry, 
 		                               GDK_HINT_MIN_SIZE);
 	}
+#endif
+	gsearch->default_height += WINDOW_HEIGHT_STEP;
+
+	if (GTK_WIDGET_VISIBLE (gsearch->available_options_vbox)) {
+		gtk_window_set_default_size (GTK_WINDOW (gsearch->window),
+					     gsearch->default_width,
+					     gsearch->default_height);
+	}
 		
 	constraint->constraint_id = constraint_id;
 	set_constraint_info_defaults (constraint);
@@ -2721,6 +2730,26 @@ gsearchtool_ui_manager (GSearchWindow * 
 	                                                                          "/PopupMenu/SaveResultsAs");
 }
 
+static void
+gsearch_window_size_allocate (GtkWidget     *widget,
+			      GtkAllocation *allocation,
+			      GSearchWindow *gsearch)
+{
+	if (gsearch->default_width != allocation->width) {
+		gsearch->default_width = allocation->width;
+		
+		gsearchtool_gconf_set_int ("/apps/gnome-search-tool/window-width",
+					   gsearch->default_width);
+	}
+
+	if (gsearch->default_height != allocation->height) {
+		gsearch->default_height = allocation->height;
+		
+		gsearchtool_gconf_set_int ("/apps/gnome-search-tool/window-height",
+					   gsearch->default_height);
+	}
+}
+
 static GtkWidget *
 gsearch_app_create (GSearchWindow * gsearch)
 {
@@ -2736,13 +2765,28 @@ gsearch_app_create (GSearchWindow * gsea
 	GdkPixbuf * pixbuf;
 	
 	gsearch->window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+	g_signal_connect (G_OBJECT (gsearch->window), "size-allocate",
+			  G_CALLBACK (gsearch_window_size_allocate),
+			  gsearch);
 	gsearch->command_details = g_new0 (GSearchCommandDetails, 1);
-	gsearch->window_geometry.min_height = MINIMUM_WINDOW_HEIGHT;
-	gsearch->window_geometry.min_width  = MINIMUM_WINDOW_WIDTH;
-	
-	gtk_window_set_position (GTK_WINDOW (gsearch->window), GTK_WIN_POS_CENTER);	
-	gtk_window_set_geometry_hints (GTK_WINDOW (gsearch->window), GTK_WIDGET (gsearch->window),
-				       &gsearch->window_geometry, GDK_HINT_MIN_SIZE);
+
+#if 0
+	get_window_geometry (&(gsearch->window_geometry.min_width),
+			     &(gsearch->window_geometry.min_height));
+#endif
+	get_stored_window_geometry (&gsearch->default_width,
+				    &gsearch->default_height);
+	
+	gtk_window_set_position (GTK_WINDOW (gsearch->window), GTK_WIN_POS_CENTER);
+#if 0
+	gtk_window_set_geometry_hints (GTK_WINDOW (gsearch->window),
+				       GTK_WIDGET (gsearch->window),
+				       &gsearch->window_geometry,
+				       GDK_HINT_MIN_SIZE);
+#endif
+	gtk_window_set_default_size (GTK_WINDOW (gsearch->window),
+				     gsearch->default_width,
+				     gsearch->default_height);
 	
 	container = gtk_vbox_new (FALSE, 6);
 	gtk_container_add (GTK_CONTAINER (gsearch->window), container);	
@@ -2922,9 +2966,10 @@ gsearch_window_finalize (GObject * objec
 static void
 gsearch_window_class_init (GSearchWindowClass * klass)
 {
-	GObjectClass * object_class = (GObjectClass *) klass;
+	GObjectClass * object_class = G_OBJECT_CLASS (klass);
 
 	object_class->finalize = gsearch_window_finalize;
+
 	parent_class = g_type_class_peek_parent (klass);
 }
 
Index: gsearchtool.h
===================================================================
RCS file: /cvs/gnome/gnome-utils/gsearchtool/gsearchtool.h,v
retrieving revision 1.51
diff -u -u -p -r1.51 gsearchtool.h
--- gsearchtool.h	2 Dec 2005 22:10:07 -0000	1.51
+++ gsearchtool.h	20 Dec 2005 00:15:57 -0000
@@ -84,6 +84,8 @@ struct _GSearchWindow {
 	GtkWidget             * window;
 	GtkUIManager          * window_ui_manager;
 	GdkGeometry             window_geometry;
+	gint                    default_width;
+	gint                    default_height;
 	gboolean                is_window_accessible;
 	
 	GtkWidget             * name_contains_entry;
