Re: combined patches



And here's the new patch. That should hopefully work now.

Can I commit this?

- Frank


Index: src/nautilus-application.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/nautilus-application.c,v
retrieving revision 1.189
diff -u -p -r1.189 nautilus-application.c
--- src/nautilus-application.c	31 May 2002 20:00:56 -0000	1.189
+++ src/nautilus-application.c	9 Jun 2002 02:56:40 -0000
@@ -641,6 +641,59 @@ nautilus_window_delete_event_callback (G
 	return TRUE;
 }				       
 
+static gboolean
+save_window_geometry_idle (gpointer callback_data)
+{
+	NautilusWindow *window;
+	
+	window = NAUTILUS_WINDOW (callback_data);
+	
+	nautilus_window_save_geometry (window);
+	
+	window->save_geometry_idle_id = 0;
+	return FALSE;
+}
+ 
+static gboolean
+nautilus_window_configure_event_callback (GtkWidget *widget,
+						GdkEventConfigure *event,
+						gpointer callback_data)
+{
+	NautilusWindow *window;
+	
+	window = NAUTILUS_WINDOW (widget);
+	
+	/* Only save the geometry when we are idle, 
+	 * since we receive configure events all the time.
+	 */
+	if (window->save_geometry_idle_id == 0) {
+		window->save_geometry_idle_id = 
+				g_idle_add (save_window_geometry_idle, window);
+	}
+
+	return FALSE;
+}
+
+static gboolean
+nautilus_window_unrealize_event_callback (GtkWidget *widget,
+						GdkEvent *event,
+						gpointer callback_data)
+{
+	NautilusWindow *window;
+	
+	window = NAUTILUS_WINDOW (widget);
+
+	g_warning ("FRANKW: got unrealize event!");
+	
+	if (window->save_geometry_idle_id != 0) {
+		g_source_remove (window->save_geometry_idle_id);
+		window->save_geometry_idle_id = 0;
+		nautilus_window_save_geometry (window);
+	}
+
+	return FALSE;
+}
+
 NautilusWindow *
 nautilus_application_create_window (NautilusApplication *application)
 {
@@ -657,6 +710,12 @@ nautilus_application_create_window (Naut
 
 	g_signal_connect_object (window, "destroy",
 				 G_CALLBACK (nautilus_application_destroyed_window), application, 0);
+
+	g_signal_connect (window, "configure_event",
+				G_CALLBACK (nautilus_window_configure_event_callback), NULL);
+
+	g_signal_connect (window, "unrealize",
+				G_CALLBACK (nautilus_window_unrealize_event_callback), NULL);
 
 	nautilus_application_window_list = g_list_prepend (nautilus_application_window_list, window);
 
Index: src/nautilus-window-manage-views.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/nautilus-window-manage-views.c,v
retrieving revision 1.298
diff -u -p -r1.298 nautilus-window-manage-views.c
--- src/nautilus-window-manage-views.c	3 Jun 2002 19:16:56 -0000	1.298
+++ src/nautilus-window-manage-views.c	9 Jun 2002 02:56:40 -0000
@@ -608,12 +608,6 @@ ref_now_unref_at_idle_time (GObject *obj
         g_idle_add (unref_callback, object);
 }
 
-static gboolean
-use_saved_window_positions (void)
-{
-        return eel_preferences_get_boolean (NAUTILUS_PREFERENCES_WINDOW_ALWAYS_NEW);
-}
-
 /* This is called when we have decided we can actually change to the new view/location situation. */
 static void
 location_has_really_changed (NautilusWindow *window)
@@ -658,8 +652,7 @@ location_has_really_changed (NautilusWin
          * metadata. Then tell the callback it needs to show the
          * window
          */
-        if (!use_saved_window_positions () ||
-            window->show_state == NAUTILUS_WINDOW_POSITION_SET) {
+        if (window->show_state == NAUTILUS_WINDOW_POSITION_SET) {
                 gtk_widget_show (GTK_WIDGET (window));
         } else {
                 window->show_state = NAUTILUS_WINDOW_SHOULD_SHOW;
@@ -1124,18 +1117,17 @@ position_and_show_window_callback (Nauti
         
 	window = NAUTILUS_WINDOW (callback_data);
 
-	if (use_saved_window_positions ()) {
-		geometry_string = nautilus_file_get_metadata 
+	/* load the saved window geometry */
+	geometry_string = nautilus_file_get_metadata 
 			(file, NAUTILUS_METADATA_KEY_WINDOW_GEOMETRY, NULL);
-		if (geometry_string != NULL) {
-			eel_gtk_window_set_initial_geometry_from_string 
-				(GTK_WINDOW (window), 
-				 geometry_string,
-				 NAUTILUS_WINDOW_MIN_WIDTH, 
-				 NAUTILUS_WINDOW_MIN_HEIGHT);
-		}
-		g_free (geometry_string);
+	if (geometry_string != NULL) {
+		eel_gtk_window_set_initial_geometry_from_string 
+			(GTK_WINDOW (window), 
+			 geometry_string,
+			 NAUTILUS_WINDOW_MIN_WIDTH, 
+			 NAUTILUS_WINDOW_MIN_HEIGHT);
 	}
+	g_free (geometry_string);
 
         /* If we finished constructing the window by now we need
          * to show the window here.
@@ -1190,22 +1182,20 @@ determined_initial_view_callback (Nautil
 		 * windows), position and show it only after we've got the
 		 * metadata (since position info is stored there).
 		 */
-                if (use_saved_window_positions ()) {
-                        window->show_state = NAUTILUS_WINDOW_NOT_SHOWN;
-                        if (!GTK_WIDGET_VISIBLE (window)) {
-                                file = nautilus_file_get (location);
+		window->show_state = NAUTILUS_WINDOW_NOT_SHOWN;
+		if (!GTK_WIDGET_VISIBLE (window)) {
+			file = nautilus_file_get (location);
                                 
-                                attributes = g_list_prepend (NULL, NAUTILUS_FILE_ATTRIBUTE_METADATA);
-                                nautilus_file_call_when_ready (file,
-                                                               attributes,
-                                                               position_and_show_window_callback,
-                                                               window);
-                                g_list_free (attributes);
-                        }
-                }
+			attributes = g_list_prepend (NULL, NAUTILUS_FILE_ATTRIBUTE_METADATA);
+			nautilus_file_call_when_ready (file,
+								attributes,
+								position_and_show_window_callback,
+								window);
+			g_list_free (attributes);
+		}
 
-                load_content_view (window, initial_view);
-                return;
+		load_content_view (window, initial_view);
+		return;
         }
         
         /* Some sort of failure occurred. How 'bout we tell the user? */
Index: src/nautilus-window.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/nautilus-window.c,v
retrieving revision 1.388
diff -u -p -r1.388 nautilus-window.c
--- src/nautilus-window.c	24 May 2002 21:54:05 -0000	1.388
+++ src/nautilus-window.c	9 Jun 2002 02:56:40 -0000
@@ -864,7 +864,7 @@ nautilus_window_finalize (GObject *objec
 	G_OBJECT_CLASS (parent_class)->finalize (object);
 }
 
-static void
+void
 nautilus_window_save_geometry (NautilusWindow *window)
 {
 	char *geometry_string;
@@ -884,15 +884,7 @@ nautilus_window_save_geometry (NautilusW
 void
 nautilus_window_close (NautilusWindow *window)
 {
-        g_return_if_fail (NAUTILUS_IS_WINDOW (window));
-
-	/* Save the window position in the directory's metadata only if
-	 * we're in every-location-in-its-own-window mode. Otherwise it
-	 * would be too apparently random when the stored positions change.
-	 */
-	if (eel_preferences_get_boolean (NAUTILUS_PREFERENCES_WINDOW_ALWAYS_NEW)) {
-	        nautilus_window_save_geometry (window);
-	}
+	g_return_if_fail (NAUTILUS_IS_WINDOW (window));
 
 	gtk_widget_destroy (GTK_WIDGET (window));
 }
Index: src/nautilus-window.h
===================================================================
RCS file: /cvs/gnome/nautilus/src/nautilus-window.h,v
retrieving revision 1.100
diff -u -p -r1.100 nautilus-window.h
--- src/nautilus-window.h	21 Apr 2002 21:15:41 -0000	1.100
+++ src/nautilus-window.h	9 Jun 2002 02:56:40 -0000
@@ -82,7 +82,8 @@ struct NautilusWindow {
         GtkWidget *navigation_bar;
         
         guint status_bar_clear_id;
-        
+        guint save_geometry_idle_id;
+	  
         /** CORBA-related elements **/
         NautilusApplication *application;
         
@@ -153,5 +154,6 @@ gboolean	 nautilus_window_sidebar_showin
 void 		 nautilus_window_hide_status_bar      (NautilusWindow 	 *window);
 void 		 nautilus_window_show_status_bar      (NautilusWindow 	 *window);
 gboolean	 nautilus_window_status_bar_showing   (NautilusWindow    *window);
+void		 nautilus_window_save_geometry	  (NautilusWindow 	 *window);
 
 #endif
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]